google / mobly

E2E test framework for tests with complex environment requirements.
https://github.com/google/mobly
Apache License 2.0
621 stars 174 forks source link

Use self.is_adb_detectable() to prevent build_info from None #923

Closed minghsikang closed 4 weeks ago

minghsikang commented 1 month ago

The logic now is trying to use build_info when it is not in bootloader, but if the device isn't detectable in neither adb nor fastboot, the exception occurs.


This change is Reviewable

xpconanfan commented 1 month ago

The logic is still trying to access build_info right? What's the difference?

minghsikang commented 1 month ago

The logic is still trying to access build_info right? What's the difference?

The difference is that we can only use build_info when the device is detectable. Otherwise, the build_info is None.

Here is the context: when I tried to init android device, is_rootable could raise exception if the device is not found.

return not self.is_bootloader and self.build_info['debuggable'] == '1'

That's why it is not in bootloader but still trying to access build_info

Hence, I come up with two solutions

  1. change not is_bootloader to is_adb_detectable to make sure we won't access build_info when it is None. (current change)
  2. add a parameter to not use root_adb in init method.

WDYT?

mhaoli commented 1 month ago

when I tried to init android device, is_rootable could raise exception if the device is not found.

Are you meaning you are initializing an AndroidDevice object while there is no corresponding Android device?

We assume each AndroidDevice object corresponds to one Android device. What are you going to do if there's no Android device?

minghsikang commented 1 month ago

Are you meaning you are initializing an AndroidDevice object while there is no corresponding Android device?

Partially correct. There is the android device, but it is not detectable by adb or fastboot (even not in rom recovery mode and need ftdi commands to bring it back).

We assume each AndroidDevice object corresponds to one Android device. What are you going to do if there's no Android device?

We will use some other recover scripts/tools to bring it back to fastboot or android and then use Android device.

mhaoli commented 1 month ago

Are you meaning you are initializing an AndroidDevice object while there is no corresponding Android device?

Partially correct. There is the android device, but it is not detectable by adb or fastboot (even not in rom recovery mode and need ftdi commands to bring it back).

We assume each AndroidDevice object corresponds to one Android device. What are you going to do if there's no Android device?

We will use some other recover scripts/tools to bring it back to fastboot or android and then use Android device.

I see.

I think in Mobly repo this change makes sense to prevent using a None as a dict.

But for your usage, sounds like it would make more sense to first recover the device and then initialize AndroidDevice object?

minghsikang commented 1 month ago

But for your usage, sounds like it would make more sense to first recover the device and then initialize AndroidDevice object?

Totally agree.

minghsikang commented 4 weeks ago

It seems need your help to resolve the comment.