USB: Don't add adb function when usb disconnected
When USB is disconnected, "adb" functions will be added even in
"charging" mode. This breaks "charging" mode's design.
Change-Id: I7ab62194a0acb97620e33da4839e0f6c87f60917
diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
index 04fd0cc..93b25ea 100644
--- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java
+++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
@@ -475,7 +475,8 @@
// with OEM specific mode.
if (functions != null && makeDefault && !needsOemUsbOverride()) {
- if (mAdbEnabled) {
+ if (!UsbManager.USB_FUNCTION_CHARGING.equals(functions)
+ && mAdbEnabled) {
functions = addFunction(functions, UsbManager.USB_FUNCTION_ADB);
} else {
functions = removeFunction(functions, UsbManager.USB_FUNCTION_ADB);
@@ -507,7 +508,8 @@
// Override with bootmode specific usb mode if needed
functions = processOemUsbOverride(functions);
- if (mAdbEnabled) {
+ if (!UsbManager.USB_FUNCTION_CHARGING.equals(functions)
+ && mAdbEnabled) {
functions = addFunction(functions, UsbManager.USB_FUNCTION_ADB);
} else {
functions = removeFunction(functions, UsbManager.USB_FUNCTION_ADB);