Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5269)

Unified Diff: adb/contrib/adb_commands_safe.py

Issue 2177573003: Add option to send reboot command and not wait for device. (Closed) Base URL: https://github.com/luci/python-adb.git@master
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « adb/common.py ('k') | adb/contrib/high.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: adb/contrib/adb_commands_safe.py
diff --git a/adb/contrib/adb_commands_safe.py b/adb/contrib/adb_commands_safe.py
index 78d2c50d966f16241b335cb2a9194d5e0b249e52..b7d23163831e9bf408dd7496c790ed580d2417d5 100644
--- a/adb/contrib/adb_commands_safe.py
+++ b/adb/contrib/adb_commands_safe.py
@@ -327,7 +327,7 @@ class AdbCommandsSafe(object):
break
return False
- def Reboot(self):
+ def Reboot(self, wait=True):
"""Reboots the device. Waits for it to be rebooted but not fully
operational.
@@ -340,6 +340,9 @@ class AdbCommandsSafe(object):
Returns True on success.
"""
if self._adb_cmd:
+ if not wait:
+ return self._Reboot()
+
# Get previous uptime to ensure the phone actually rebooted.
previous_uptime = self.GetUptime()
if not previous_uptime:
@@ -387,6 +390,26 @@ class AdbCommandsSafe(object):
break
return False
+ def ResetHandle(self, new_endpoint=None):
+ """Resets the handle used to communicate to the device.
+
+ For USB connections, it resets the usb device. For TCP connections,
+ it closes and reopens the TCP connection.
+
+ Args:
+ new_endpoint: If a TCP device, this will be used as the new endpoint in
+ the TCP connection.
+ Returns:
+ True on success.
+ """
+ if self._adb_cmd:
+ self._adb_cmd.Close()
+ self._adb_cmd = None
+ if new_endpoint:
+ self._serial = None
+ self._handle.Reset(new_endpoint=new_endpoint)
+ return self._Connect(False)
+
def Shell(self, cmd, timeout_ms=None):
"""Runs a command on an Android device while swallowing exceptions.
« no previous file with comments | « adb/common.py ('k') | adb/contrib/high.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698