diff options
author | Nick Kralevich <nnk@google.com> | 2015-07-20 15:36:21 -0700 |
---|---|---|
committer | Nick Kralevich <nnk@google.com> | 2015-07-20 15:40:54 -0700 |
commit | 2fedc4df5127d1a2eaf178e835d9f5398ce8f879 (patch) | |
tree | caebc7a1cc8aacaebc12b7c8d30b98073120b6e4 /services/usb | |
parent | 072e04a7f1a167dc653b5bcca4876fecfdb4f6be (diff) | |
download | frameworks_base-2fedc4df5127d1a2eaf178e835d9f5398ce8f879.zip frameworks_base-2fedc4df5127d1a2eaf178e835d9f5398ce8f879.tar.gz frameworks_base-2fedc4df5127d1a2eaf178e835d9f5398ce8f879.tar.bz2 |
UsbDeviceManager: add back support for USB overlays
Commit fcf10f7c12cb3107bdfedce6f76a8c866d154f3c removed support for USB
overlays. Add it back in, as some devices depend on it.
Bug: 22062484
Bug: 21195124
Change-Id: I74d12699201355b07475744c641e31fdc4bb5a4a
Diffstat (limited to 'services/usb')
-rw-r--r-- | services/usb/java/com/android/server/usb/UsbDeviceManager.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java index 653cbd8..1787b91 100644 --- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java +++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java @@ -122,6 +122,8 @@ public class UsbDeviceManager { // Request is cancelled if host does not configure device within 10 seconds. private static final int ACCESSORY_REQUEST_TIMEOUT = 10 * 1000; + private static final String BOOT_MODE_PROPERTY = "ro.bootmode"; + private UsbHandler mHandler; private boolean mBootCompleted; @@ -468,6 +470,7 @@ public class UsbDeviceManager { functions = getDefaultFunctions(); } functions = applyAdbFunction(functions); + functions = applyOemOverrideFunction(functions); functions = applyUserRestrictions(functions); if (!mCurrentFunctions.equals(functions) || !mCurrentFunctionsApplied @@ -888,6 +891,24 @@ public class UsbDeviceManager { } } + private String applyOemOverrideFunction(String usbFunctions) { + if ((usbFunctions == null) || (mOemModeMap == null)) return usbFunctions; + + String bootMode = SystemProperties.get(BOOT_MODE_PROPERTY, "unknown"); + + List<Pair<String, String>> overrides = mOemModeMap.get(bootMode); + if (overrides != null) { + for (Pair<String, String> pair: overrides) { + if (pair.first.equals(usbFunctions)) { + Slog.d(TAG, "OEM USB override: " + pair.first + " ==> " + pair.second); + return pair.second; + } + } + } + // return passed in functions as is. + return usbFunctions; + } + public void allowUsbDebugging(boolean alwaysAllow, String publicKey) { if (mDebuggingManager != null) { mDebuggingManager.allowUsbDebugging(alwaysAllow, publicKey); |