wait-for-disconnect and then wait-for-device#984
wait-for-disconnect and then wait-for-device#984jiyongp wants to merge 1 commit intogoogle:masterfrom
Conversation
Previously, right after we do `adb reboot`, we immediately executed `adb wait-for-device`. This is problematic because the device may still be in the process of shutting down (shutdown itself is taking some time), in which case `adb wait-for-device` would immediately return, giving a false signal that the reboot was finished. Fixing this issue by firstly waiting for the adb connection to be lost (via adb wait-for-disconnect) and when executing adb-wait-for-device. Note that other test hardness like tradefed already has had this. ex: https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/main/src/com/android/tradefed/device/NativeDevice.java#4023 Test: tox passed
|
Please note that this isn't specific to virtual devices though this time it was manifested in cf_wear. For any Android device, we shouldn't assume that |
|
Since the problem is related to timing, what if the device immediately disconnected before the cmd |
No. It returns immediately if the device is already disconnected. |
| try: | ||
| yield | ||
| finally: | ||
| # If we execute `wait-for-device` right after `reboot`, adbd in the device |
There was a problem hiding this comment.
I don't think this logic belongs in the context handler here.
There's no guarantee that the custom logic's last step is to immediately cause the device to go offline.
Or, in other words, the user logic in the handler context should ensure the device has gone offline before proceeding.
So this cmd can be easily done in the user logic.
Previously, right after we do
adb reboot, we immediately executedadb wait-for-device. This is problematic because the device may still be inthe process of shutting down (shutdown itself is taking some time), in
which case
adb wait-for-devicewould immediately return, giving afalse signal that the reboot was finished.
Fixing this issue by firstly waiting for the adb connection to be lost
(via adb wait-for-disconnect) and when executing adb-wait-for-device.
Note that other test hardness like tradefed already has had this. ex:
https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/main/src/com/android/tradefed/device/NativeDevice.java#4023
Test: tox passed
This change is