From 6276bb899e810655fab9083393c7f4d2a494b7d7 Mon Sep 17 00:00:00 2001 From: Badhri Jagan Sridharan Date: Tue, 11 Jul 2017 16:34:41 -0700 Subject: Clear mCurrentAccessory if accessory function is no longer enabled Accessory mode implements debounce timeout ACCESSORY_REQUEST_TIMEOUT within which when a disconnect is seen, the accessory function would be removed from the usb configuration but mCurrentAccessory would not be set to NULL until the timeout expires. Also, setEnabledFunctions(null, false, false) does not force an additional disconnect when accessory function has already been removed from usb configuration. BUG: 62241238 Change-Id: I25973475fb02d613e11396bcad5e88656ad8940a --- services/usb/java/com/android/server/usb/UsbDeviceManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'services/usb/java') diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java index a7180c989a6e..a5797c01691f 100644 --- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java +++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java @@ -1032,7 +1032,9 @@ public class UsbDeviceManager { if (DEBUG) { Slog.v(TAG, "Accessory mode enter timeout: " + mConnected); } - if (!mConnected) { + if (!mConnected || !UsbManager.containsFunction( + mCurrentFunctions, + UsbManager.USB_FUNCTION_ACCESSORY)) { notifyAccessoryModeExit(); } break; -- cgit v1.2.3-59-g8ed1b