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

Side by Side Diff: appengine/third_party/python-adb/adb/contrib/high.py

Issue 2178833003: Roll python-adb to 72674a1... (Closed) Base URL: https://github.com/luci/luci-py.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « appengine/third_party/python-adb/adb/contrib/adb_commands_safe.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding=utf-8 1 # coding=utf-8
2 # Copyright 2015 Google Inc. All rights reserved. 2 # Copyright 2015 Google Inc. All rights reserved.
3 # 3 #
4 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License. 5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at 6 # You may obtain a copy of the License at
7 # 7 #
8 # http://www.apache.org/licenses/LICENSE-2.0 8 # http://www.apache.org/licenses/LICENSE-2.0
9 # 9 #
10 # Unless required by applicable law or agreed to in writing, software 10 # Unless required by applicable law or agreed to in writing, software
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 425
426 def PullContent(self, *args, **kwargs): 426 def PullContent(self, *args, **kwargs):
427 return self._device.PullContent(*args, **kwargs) 427 return self._device.PullContent(*args, **kwargs)
428 428
429 def Push(self, *args, **kwargs): 429 def Push(self, *args, **kwargs):
430 return self._device.Push(*args, **kwargs) 430 return self._device.Push(*args, **kwargs)
431 431
432 def PushContent(self, *args, **kwargs): 432 def PushContent(self, *args, **kwargs):
433 return self._device.PushContent(*args, **kwargs) 433 return self._device.PushContent(*args, **kwargs)
434 434
435 def Reboot(self): 435 def Reboot(self, wait=True):
436 """Reboots the phone then Waits for the device to come back. 436 """Reboots the phone then Waits for the device to come back.
437 437
438 adbd running on the phone will likely not be in Root(), so the caller should 438 adbd running on the phone will likely not be in Root(), so the caller should
439 call Root() right afterward if desired. 439 call Root() right afterward if desired.
440 """ 440 """
441 if not self._device.Reboot(): 441 if not self._device.Reboot(wait=wait):
442 return False 442 return False
443 return self.WaitUntilFullyBooted() 443 return self.WaitUntilFullyBooted() if wait else True
444
445 def Reset(self, new_endpoint=None):
446 self._device.ResetHandle(new_endpoint=new_endpoint)
444 447
445 def Remount(self): 448 def Remount(self):
446 return self._device.Remount() 449 return self._device.Remount()
447 450
448 def Root(self): 451 def Root(self):
449 return self._device.Root() 452 return self._device.Root()
450 453
451 def Shell(self, cmd, timeout_ms=None): 454 def Shell(self, cmd, timeout_ms=None):
452 """Automatically uses WrappedShell() when necessary.""" 455 """Automatically uses WrappedShell() when necessary."""
453 if self._device.IsShellOk(cmd): 456 if self._device.IsShellOk(cmd):
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 # Then the slowest part of all. 860 # Then the slowest part of all.
858 while True: 861 while True:
859 if (time.time() - start) > timeout: 862 if (time.time() - start) > timeout:
860 _LOG.warning( 863 _LOG.warning(
861 '%s.WaitUntilFullyBooted() didn\'t get Package Manager running in ' 864 '%s.WaitUntilFullyBooted() didn\'t get Package Manager running in '
862 'time', 865 'time',
863 self.port_path) 866 self.port_path)
864 return False 867 return False
865 # pm can be very slow at times. Use a longer timeout to prevent 868 # pm can be very slow at times. Use a longer timeout to prevent
866 # confusing a long-running command with an interrupted connection. 869 # confusing a long-running command with an interrupted connection.
867 out, _ = self.Shell('pm path', timeout_ms=30000) 870 out, exit_code = self.Shell('pm path', timeout_ms=30000)
868 if out == 'Error: no package specified\n': 871 if out == 'Error: no package specified\n':
869 # It's up! 872 # It's up!
870 break 873 break
871 874
872 # Accepts an empty string too, which has been observed only on Android 4.4 875 # Accepts an empty string too, which has been observed only on Android 4.4
873 # (Kitkat) but not on later versions. 876 # (Kitkat) but not on later versions.
874 assert out in ( 877 if out not in (
875 'Error: Could not access the Package Manager. Is the system ' 878 'Error: Could not access the Package Manager. Is the system '
876 'running?\n', 879 'running?\n',
877 ''), out 880 ''):
881 logging.warning(
882 'Unexpected reply from pm path (%d): %r', exit_code, out)
878 time.sleep(0.1) 883 time.sleep(0.1)
879 884
880 return True 885 return True
881 886
882 def PushKeys(self): 887 def PushKeys(self):
883 """Pushes all the keys on the file system to the device. 888 """Pushes all the keys on the file system to the device.
884 889
885 This is necessary when the device just got wiped but still has 890 This is necessary when the device just got wiped but still has
886 authorization, as soon as it reboots it'd lose the authorization. 891 authorization, as soon as it reboots it'd lose the authorization.
887 892
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 return out 978 return out
974 979
975 @classmethod 980 @classmethod
976 def _Connect(cls, constructor, **kwargs): 981 def _Connect(cls, constructor, **kwargs):
977 """Called by either ConnectDevice or Connect.""" 982 """Called by either ConnectDevice or Connect."""
978 if not kwargs.get('rsa_keys'): 983 if not kwargs.get('rsa_keys'):
979 with _ADB_KEYS_LOCK: 984 with _ADB_KEYS_LOCK:
980 kwargs['rsa_keys'] = _ADB_KEYS[:] 985 kwargs['rsa_keys'] = _ADB_KEYS[:]
981 device = constructor(**kwargs) 986 device = constructor(**kwargs)
982 return HighDevice(device, _InitCache(device)) 987 return HighDevice(device, _InitCache(device))
OLDNEW
« no previous file with comments | « appengine/third_party/python-adb/adb/contrib/adb_commands_safe.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698