Briefcase crashes if `adb devices` returns incomplete information
Describe the bug
I somehow ended up in a situation where adb devices returned the following:
List of devices attached
emulator-5554 device product:sdk_gphone64_x86_64 model:sdk_gphone64_x86_64 device:emulator64_x86_64_arm64 transport_id:1
emulator-5556 device transport_id:2
Despite emulator-5556 having incomplete information, it still worked perfectly well with other adb commands. However, Briefcase crashed with a KeyError because it expects the "model" field to always be there. I was able to work around this with the following change, which I don't have time right now to make into a fully-unit-tested PR:
diff --git a/src/briefcase/integrations/android_sdk.py b/src/briefcase/integrations/android_sdk.py
index 12c7b20..a3752b1 100644
--- a/src/briefcase/integrations/android_sdk.py
+++ b/src/briefcase/integrations/android_sdk.py
@@ -656,7 +658,10 @@ connection.
details[key] = value
if parts[1] == "device":
- name = details["model"].replace("_", " ")
+ try:
+ name = details["model"].replace("_", " ")
+ except KeyError:
+ name = "Unknown device (no model name)"
authorized = True
elif parts[1] == "offline":
name = "Unknown device (offline)"
Environment:
- Operating System: Windows 10
- Python version: 3.8
- Software versions:
- Briefcase: f000a5f3
Weird... but the proposed fix seems reasonable.
@freakboy3742 I can do this. I have a question should authorized be set to false if there is no model?
@PrestonMclean Based on @mhsmith's report, I think we can say the device should be authorized - his report indicates that a "no model" device was able to run.
Fixed by #876