diff options
Diffstat (limited to 'src/com/android/tradefed/device/FastbootHelper.java')
-rw-r--r-- | src/com/android/tradefed/device/FastbootHelper.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/com/android/tradefed/device/FastbootHelper.java b/src/com/android/tradefed/device/FastbootHelper.java index 276207521..fe251fd03 100644 --- a/src/com/android/tradefed/device/FastbootHelper.java +++ b/src/com/android/tradefed/device/FastbootHelper.java @@ -25,6 +25,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -125,6 +126,38 @@ public class FastbootHelper { } /** + * Returns a map of device serials and whether they are in fastbootd mode or not. + * + * @param serials a map of devices serial number and fastboot mode serial number. + * @return a Map of serial in bootloader or fastbootd, the boolean is true if in fastbootd + */ + public Map<String, Boolean> getBootloaderAndFastbootdTcpDevices(Map<String, String> serials) { + HashMap<String, Boolean> devices = new LinkedHashMap<>(); + long TIMEOUT = 1500; + + for (Entry<String, String> entry : serials.entrySet()) { + CLog.v("Run 'fastboot -s %s getvar is-userspace' command", entry.getValue()); + CommandResult fastbootResult = + mRunUtil.runTimedCmdSilently( + TIMEOUT, + mFastbootPath, + "-s", + entry.getValue(), + "getvar", + "is-userspace"); + if (fastbootResult.getStatus().equals(CommandStatus.SUCCESS)) { + if (fastbootResult.getStderr().contains("yes")) { + devices.put(entry.getKey(), true); + } else { + devices.put(entry.getKey(), false); + } + } + } + + return devices; + } + + /** * Parses the output of "fastboot devices" command. Exposed for unit testing. * * @param fastbootOutput the output of fastboot command. |