Don't destroy usb debugging dialog for emulator if usb is not connected.

ACTION_USB_STATE is always false for emulator, which causes the dialog
to appear and then immediately disappear.

Bug: 187862091, 160861855

Test: adb kill-server; rm <adb keys>; adb devices (should popup dialog)
Change-Id: Ia21533d8b8b5d10526f1789abdffe4bbe32d7025
This commit is contained in:
Joshua Duong
2021-06-01 11:00:36 -07:00
parent 3ee3029e96
commit bce1e8db57

View File

@@ -68,7 +68,9 @@ public class UsbDebuggingActivity extends AlertActivity
super.onCreate(icicle);
if (SystemProperties.getInt("service.adb.tcp.port", 0) == 0) {
// Emulator does not support reseating the usb cable to reshow the dialog.
boolean isEmulator = SystemProperties.get("ro.boot.qemu").equals("1");
if (SystemProperties.getInt("service.adb.tcp.port", 0) == 0 && !isEmulator) {
mDisconnectedReceiver = new UsbDisconnectedReceiver(this);
IntentFilter filter = new IntentFilter(UsbManager.ACTION_USB_STATE);
mBroadcastDispatcher.registerReceiver(mDisconnectedReceiver, filter);