Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device reboot requires explicit sleep even after "adb wait-for-device" #12

Closed
reddypdl opened this issue Nov 5, 2013 · 2 comments
Closed

Comments

@reddypdl
Copy link

reddypdl commented Nov 5, 2013

Code:

self.d.server.adb.raw_cmd("root").communicate()
subprocess.Popen('adb nodaemon wait-for-device'.split(), stdout=subprocess.PIPE).communicate()
self.d.server.adb.raw_cmd("reboot").communicate()
subprocess.Popen('adb nodaemon wait-for-device'.split(), stdout=subprocess.PIPE).communicate()
#time.sleep(10)
self.d(packageName="android").wait.exists(timeout=9000)

Error:

Traceback (most recent call last):
File "test_reboot.py", line 34, in testMultiReboot
self.reboot()
File "test_reboot.py", line 28, in reboot
self.d(packageName="android").wait.exists(timeout=9000)
File "/home/git/work/uiautomator/uiautomator.py", line 397, in call
return AutomatorDeviceObject(self, Selector(**kwargs))
File "/home/git/work/uiautomator/uiautomator.py", line 809, in init
super(AutomatorDeviceObject, self).init(device, selector)
File "/home/git/work/uiautomator/uiautomator.py", line 637, in init
self.jsonrpc = device.server.jsonrpc
File "/home/git/work/uiautomator/uiautomator.py", line 319, in jsonrpc
self.start()
File "/home/git/work/uiautomator/uiautomator.py", line 337, in start
raise IOError("RPC server not started!")
IOError: RPC server not started!

But after un-commenting time.sleep(), i do not see this issue, Does RPC server start after few seconds after reboot?

@xiaocong
Copy link
Owner

xiaocong commented Nov 5, 2013

Likely something wrong during starting rpc server. Maybe the uiautomator service is not yet started even if the adb is ok. I am trying to reproduce it.

Thanks for your issue.

@xiaocong
Copy link
Owner

xiaocong commented Nov 5, 2013

During android device booting, there are dozen of seconds that the adb is ok but android service in android device is not running, so I am afraid I could not fix the issue.
As a workaround, you can write test:

timeout = 15
while not d.server.alive and timeout > 0:
    sleep(1)
    timeout -= 1
    try:
        d.server.start()
    except:
        pass

@xiaocong xiaocong closed this as completed Nov 5, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants