Chromium Code Reviews| 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 """Waits for targeted device's package manager to be up. | 311 """Waits for targeted device's package manager to be up. |
| 312 | 312 |
| 313 Args: | 313 Args: |
| 314 wait_time: time in seconds to wait | 314 wait_time: time in seconds to wait |
| 315 | 315 |
| 316 Raises: | 316 Raises: |
| 317 WaitForResponseTimedOutError if wait_time elapses and pm still does not | 317 WaitForResponseTimedOutError if wait_time elapses and pm still does not |
| 318 respond. | 318 respond. |
| 319 """ | 319 """ |
| 320 logger.Log("Waiting for device package manager...") | 320 logger.Log("Waiting for device package manager...") |
| 321 self.SendCommand("wait-for-device") | 321 self.SendCommand("wait-for-device") |
|
jbudorick
2014/07/08 20:00:45
I think we should pass the wait time in here, too,
tonyg
2014/07/08 20:17:10
Done.
| |
| 322 # Now the device is there, but may not be running. | 322 # Now the device is there, but may not be running. |
| 323 # Query the package manager with a basic command | 323 # Query the package manager with a basic command |
| 324 try: | 324 try: |
| 325 self._WaitForShellCommandContents("pm path android", "package:", | 325 self._WaitForShellCommandContents("pm path android", "package:", |
| 326 wait_time) | 326 wait_time) |
| 327 except errors.WaitForResponseTimedOutError: | 327 except errors.WaitForResponseTimedOutError: |
| 328 raise errors.WaitForResponseTimedOutError( | 328 raise errors.WaitForResponseTimedOutError( |
| 329 "Package manager did not respond after %s seconds" % wait_time) | 329 "Package manager did not respond after %s seconds" % wait_time) |
| 330 | 330 |
| 331 def WaitForInstrumentation(self, package_name, runner_name, wait_time=120): | 331 def WaitForInstrumentation(self, package_name, runner_name, wait_time=120): |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 WaitForResponseTimedOutError: If wait_time elapses and the command has not | 402 WaitForResponseTimedOutError: If wait_time elapses and the command has not |
| 403 returned an output containing expected yet. | 403 returned an output containing expected yet. |
| 404 """ | 404 """ |
| 405 # Query the device with the command | 405 # Query the device with the command |
| 406 success = False | 406 success = False |
| 407 attempts = 0 | 407 attempts = 0 |
| 408 wait_period = 5 | 408 wait_period = 5 |
| 409 while not success and (attempts*wait_period) < wait_time: | 409 while not success and (attempts*wait_period) < wait_time: |
| 410 # assume the command will always contain expected in the success case | 410 # assume the command will always contain expected in the success case |
| 411 try: | 411 try: |
| 412 output = self.SendShellCommand(command, retry_count=1) | 412 output = self.SendShellCommand(command, retry_count=1, |
| 413 timeout_time=wait_time/2) | |
|
jbudorick
2014/07/08 20:00:45
Why wait_time/2?
tonyg
2014/07/08 20:17:10
Since we'll run this twice (1 retry), I initially
| |
| 413 if ((not invert and expected in output) | 414 if ((not invert and expected in output) |
| 414 or (invert and expected not in output)): | 415 or (invert and expected not in output)): |
| 415 success = True | 416 success = True |
| 416 except errors.AbortError, e: | 417 except errors.AbortError, e: |
| 417 if raise_abort: | 418 if raise_abort: |
| 418 raise | 419 raise |
| 419 # ignore otherwise | 420 # ignore otherwise |
| 420 | 421 |
| 421 if not success: | 422 if not success: |
| 422 time.sleep(wait_period) | 423 time.sleep(wait_period) |
| (...skipping 81 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 | 505 # press the MENU key, this will disable key guard if runtime is started |
| 505 # with ro.monkey set to 1 | 506 # with ro.monkey set to 1 |
| 506 self.SendShellCommand("input keyevent 82", retry_count=retry_count) | 507 self.SendShellCommand("input keyevent 82", retry_count=retry_count) |
| 507 else: | 508 else: |
| 508 self.WaitForDevicePm() | 509 self.WaitForDevicePm() |
| 509 return output | 510 return output |
| 510 | 511 |
| 511 def GetSerialNumber(self): | 512 def GetSerialNumber(self): |
| 512 """Returns the serial number of the targeted device.""" | 513 """Returns the serial number of the targeted device.""" |
| 513 return self.SendCommand("get-serialno").strip() | 514 return self.SendCommand("get-serialno").strip() |
| OLD | NEW |