| OLD | NEW |
| 1 #!/usr/bin/python2.4 | 1 #!/usr/bin/python2.4 |
| 2 # | 2 # |
| 3 # | 3 # |
| 4 # Copyright 2008, The Android Open Source Project | 4 # Copyright 2008, The Android Open Source Project |
| 5 # | 5 # |
| 6 # Licensed under the Apache License, Version 2.0 (the "License"); | 6 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 # you may not use this file except in compliance with the License. | 7 # you may not use this file except in compliance with the License. |
| 8 # You may obtain a copy of the License at | 8 # You may obtain a copy of the License at |
| 9 # | 9 # |
| 10 # http://www.apache.org/licenses/LICENSE-2.0 | 10 # http://www.apache.org/licenses/LICENSE-2.0 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 self._target_arg = "-e" | 44 self._target_arg = "-e" |
| 45 | 45 |
| 46 def SetDeviceTarget(self): | 46 def SetDeviceTarget(self): |
| 47 """Direct all future commands to the only connected USB device.""" | 47 """Direct all future commands to the only connected USB device.""" |
| 48 self._target_arg = "-d" | 48 self._target_arg = "-d" |
| 49 | 49 |
| 50 def SetTargetSerial(self, serial): | 50 def SetTargetSerial(self, serial): |
| 51 """Direct all future commands to Android target with the given serial.""" | 51 """Direct all future commands to Android target with the given serial.""" |
| 52 self._target_arg = "-s %s" % serial | 52 self._target_arg = "-s %s" % serial |
| 53 | 53 |
| 54 def SendCommand(self, command_string, timeout_time=20, retry_count=3): | 54 def SendCommand(self, command_string, timeout_time=20, retry_count=0): |
| 55 """Send a command via adb. | 55 """Send a command via adb. |
| 56 | 56 |
| 57 Args: | 57 Args: |
| 58 command_string: adb command to run | 58 command_string: adb command to run |
| 59 timeout_time: number of seconds to wait for command to respond before | 59 timeout_time: number of seconds to wait for command to respond before |
| 60 retrying | 60 retrying |
| 61 retry_count: number of times to retry command before raising | 61 retry_count: number of times to retry command before raising |
| 62 WaitForResponseTimedOutError | 62 WaitForResponseTimedOutError |
| 63 Returns: | 63 Returns: |
| 64 string output of command | 64 string output of command |
| 65 | 65 |
| 66 Raises: | 66 Raises: |
| 67 WaitForResponseTimedOutError if device does not respond to command within
time | 67 WaitForResponseTimedOutError if device does not respond to command within
time |
| 68 """ | 68 """ |
| 69 adb_cmd = "adb %s %s" % (self._target_arg, command_string) | 69 adb_cmd = "adb %s %s" % (self._target_arg, command_string) |
| 70 logger.SilentLog("about to run %s" % adb_cmd) | 70 logger.SilentLog("about to run %s" % adb_cmd) |
| 71 return run_command.RunCommand(adb_cmd, timeout_time=timeout_time, | 71 return run_command.RunCommand(adb_cmd, timeout_time=timeout_time, |
| 72 retry_count=retry_count) | 72 retry_count=retry_count) |
| 73 | 73 |
| 74 def SendShellCommand(self, cmd, timeout_time=20, retry_count=3): | 74 def SendShellCommand(self, cmd, timeout_time=20, retry_count=0): |
| 75 """Send a adb shell command. | 75 """Send a adb shell command. |
| 76 | 76 |
| 77 Args: | 77 Args: |
| 78 cmd: adb shell command to run | 78 cmd: adb shell command to run |
| 79 timeout_time: number of seconds to wait for command to respond before | 79 timeout_time: number of seconds to wait for command to respond before |
| 80 retrying | 80 retrying |
| 81 retry_count: number of times to retry command before raising | 81 retry_count: number of times to retry command before raising |
| 82 WaitForResponseTimedOutError | 82 WaitForResponseTimedOutError |
| 83 | 83 |
| 84 Returns: | 84 Returns: |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 # press the MENU key, this will disable key guard if runtime is started | 504 # press the MENU key, this will disable key guard if runtime is started |
| 505 # with ro.monkey set to 1 | 505 # with ro.monkey set to 1 |
| 506 self.SendShellCommand("input keyevent 82", retry_count=retry_count) | 506 self.SendShellCommand("input keyevent 82", retry_count=retry_count) |
| 507 else: | 507 else: |
| 508 self.WaitForDevicePm() | 508 self.WaitForDevicePm() |
| 509 return output | 509 return output |
| 510 | 510 |
| 511 def GetSerialNumber(self): | 511 def GetSerialNumber(self): |
| 512 """Returns the serial number of the targeted device.""" | 512 """Returns the serial number of the targeted device.""" |
| 513 return self.SendCommand("get-serialno").strip() | 513 return self.SendCommand("get-serialno").strip() |
| OLD | NEW |