From bce1e8db57c9ef4124c70bcda8ac686d7be05a22 Mon Sep 17 00:00:00 2001 From: Joshua Duong Date: Tue, 1 Jun 2021 11:00:36 -0700 Subject: [PATCH] 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 devices (should popup dialog) Change-Id: Ia21533d8b8b5d10526f1789abdffe4bbe32d7025 --- .../src/com/android/systemui/usb/UsbDebuggingActivity.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java b/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java index b1241b160d70b..941cd7783ed00 100644 --- a/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java +++ b/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java @@ -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);