Skip to content

Commit

Permalink
[androiddebugbridge] fix start-intent channel (openhab#12791)
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Álvarez Díez <[email protected]>
  • Loading branch information
GiviMAD authored May 23, 2022
1 parent c16e9df commit 6a6cf3e
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
Expand Down Expand Up @@ -416,7 +417,7 @@ public void startIntent(String command)
Map<String, Float> extraFloats = new HashMap<>();
Map<String, Long> extraLongs = new HashMap<>();
Map<String, URI> extraUris = new HashMap<>();
for (var i = 1; i < commandParts.length - 1; i++) {
for (var i = 1; i < commandParts.length; i++) {
var commandPart = commandParts[i];
var endToken = commandPart.indexOf(">");
var argName = commandPart.substring(0, endToken + 1);
Expand Down Expand Up @@ -596,7 +597,7 @@ public void startIntent(String command)
}
}

StringBuilder adbCommandBuilder = new StringBuilder("am start " + targetPackage);
StringBuilder adbCommandBuilder = new StringBuilder("am start -n " + targetPackage);
if (action != null) {
adbCommandBuilder.append(" -a ").append(action);
}
Expand All @@ -617,23 +618,28 @@ public void startIntent(String command)
}
if (!extraStrings.isEmpty()) {
adbCommandBuilder.append(extraStrings.entrySet().stream()
.map(entry -> " --es \"" + entry.getKey() + "\" \"" + entry.getValue() + "\""));
.map(entry -> " --es \"" + entry.getKey() + "\" \"" + entry.getValue() + "\"")
.collect(Collectors.joining(" ")));
}
if (!extraBooleans.isEmpty()) {
adbCommandBuilder.append(extraBooleans.entrySet().stream()
.map(entry -> " --ez \"" + entry.getKey() + "\" " + entry.getValue()));
.map(entry -> " --ez \"" + entry.getKey() + "\" " + entry.getValue())
.collect(Collectors.joining(" ")));
}
if (!extraIntegers.isEmpty()) {
adbCommandBuilder.append(extraIntegers.entrySet().stream()
.map(entry -> " --ei \"" + entry.getKey() + "\" " + entry.getValue()));
.map(entry -> " --ei \"" + entry.getKey() + "\" " + entry.getValue())
.collect(Collectors.joining(" ")));
}
if (!extraFloats.isEmpty()) {
adbCommandBuilder.append(extraFloats.entrySet().stream()
.map(entry -> " --ef \"" + entry.getKey() + "\" " + entry.getValue()));
adbCommandBuilder.append(
extraFloats.entrySet().stream().map(entry -> " --ef \"" + entry.getKey() + "\" " + entry.getValue())
.collect(Collectors.joining(" ")));
}
if (!extraLongs.isEmpty()) {
adbCommandBuilder.append(extraLongs.entrySet().stream()
.map(entry -> " --el \"" + entry.getKey() + "\" " + entry.getValue()));
adbCommandBuilder.append(
extraLongs.entrySet().stream().map(entry -> " --el \"" + entry.getKey() + "\" " + entry.getValue())
.collect(Collectors.joining(" ")));
}
runAdbShell(adbCommandBuilder.toString());
}
Expand Down

0 comments on commit 6a6cf3e

Please sign in to comment.