From 8d6630b87c93f569bbf5fc5b426fe2a1c2ff2ceb Mon Sep 17 00:00:00 2001 From: Michael Kwan Date: Mon, 16 Nov 2015 12:59:37 -0800 Subject: [PATCH] DO NOT MERGE ANYWHERE - Hack to disable MTP mode on Clockwork devices. Android currently forces USB into MTP mode if there was no modes specified. This causes issues on Clockwork devices as they do not support MTP. The hack stops this behaviour, and also sets MTP mode back to none. Bug: 25547826 Bug: 25582050 Bug: 25244201 Change-Id: I772e35d0a5db51b17e9d71c59e6a157dabb1d296 --- .../com/android/server/usb/UsbDeviceManager.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java index 81ca6a362bd56..089a0d0c1082d 100644 --- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java +++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java @@ -332,9 +332,11 @@ public class UsbDeviceManager { // Restore default functions. mCurrentFunctions = SystemProperties.get(USB_CONFIG_PROPERTY, UsbManager.USB_FUNCTION_NONE); - if (UsbManager.USB_FUNCTION_NONE.equals(mCurrentFunctions)) { - mCurrentFunctions = UsbManager.USB_FUNCTION_MTP; + // HACK START FOR DEVICES WITHOUT SUPPORT MTP, WATCH ONLY, DO NOT MERGE BACK TO AOSP + if (UsbManager.USB_FUNCTION_MTP.equals(mCurrentFunctions)) { + mCurrentFunctions = UsbManager.USB_FUNCTION_NONE; } + // HACK ENDS (mkwan@ added 2015-11-16) mCurrentFunctionsApplied = mCurrentFunctions.equals( SystemProperties.get(USB_STATE_PROPERTY)); mAdbEnabled = UsbManager.containsFunction(getDefaultFunctions(), @@ -838,9 +840,11 @@ public class UsbDeviceManager { private String getDefaultFunctions() { String func = SystemProperties.get(USB_PERSISTENT_CONFIG_PROPERTY, UsbManager.USB_FUNCTION_NONE); - if (UsbManager.USB_FUNCTION_NONE.equals(func)) { - func = UsbManager.USB_FUNCTION_MTP; + // HACK START FOR DEVICES WITHOUT SUPPORT MTP, WATCH ONLY, DO NOT MERGE BACK TO AOSP + if (UsbManager.USB_FUNCTION_MTP.equals(func)) { + func = UsbManager.USB_FUNCTION_NONE; } + // HACK ENDS (mkwan@ added 2015-11-16) return func; }