summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jerry Zhang <zhangjerry@google.com> 2016-10-18 01:00:06 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2016-10-18 01:00:09 +0000
commitee18f66977e8d2965a1443a9831739b3d4cc1c84 (patch)
treeaa7ef10564752ad0a5ebe6ce1849544788ea14ff
parent860297b91a1f2bb7acd36c943cbdb93d4547fc65 (diff)
parent2d2346e0948f5abfc502b90997ee377e0f261863 (diff)
Merge changes from topics 'usb_bugfixes', 'usb_bugfixes2'
* changes: Revert: Remove the kick from config switches in UsbDeviceManager Clean up persistent usb state on boot.
-rw-r--r--services/usb/java/com/android/server/usb/UsbDeviceManager.java19
1 files changed, 14 insertions, 5 deletions
diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
index a0c6e0ee5b28..af8c314d3b87 100644
--- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java
+++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
@@ -352,6 +352,16 @@ public class UsbDeviceManager {
mAdbEnabled = UsbManager.containsFunction(getDefaultFunctions(),
UsbManager.USB_FUNCTION_ADB);
+ /**
+ * Remove MTP from persistent config, to bring usb to a good state
+ * after fixes to b/31814300. This block can be removed after the update
+ */
+ String persisted = SystemProperties.get(USB_PERSISTENT_CONFIG_PROPERTY);
+ if (UsbManager.containsFunction(persisted, UsbManager.USB_FUNCTION_MTP)) {
+ SystemProperties.set(USB_PERSISTENT_CONFIG_PROPERTY,
+ UsbManager.removeFunction(persisted, UsbManager.USB_FUNCTION_MTP));
+ }
+
String buildType = SystemProperties.get(BUILD_TYPE_PROPERTY);
if (buildType.equals(BUILD_TYPE_USERDEBUG) || buildType.equals(BUILD_TYPE_ENG)) {
setAdbEnabled(true);
@@ -472,17 +482,13 @@ public class UsbDeviceManager {
USB_PERSISTENT_CONFIG_PROPERTY, UsbManager.USB_FUNCTION_NONE));
SystemProperties.set(USB_PERSISTENT_CONFIG_PROPERTY, newFunction);
- // Changing the persistent config also changes the normal
- // config. Wait for this to happen before changing again.
- waitForState(newFunction);
-
// Remove mtp from the config if file transfer is not enabled
if (oldFunctions.equals(UsbManager.USB_FUNCTION_MTP) &&
!mUsbDataUnlocked && enable) {
oldFunctions = UsbManager.USB_FUNCTION_NONE;
}
- setEnabledFunctions(oldFunctions, false, mUsbDataUnlocked);
+ setEnabledFunctions(oldFunctions, true, mUsbDataUnlocked);
updateAdbNotification();
}
@@ -554,6 +560,9 @@ public class UsbDeviceManager {
mCurrentFunctions = functions;
mCurrentFunctionsApplied = false;
+ // Kick the USB stack to close existing connections.
+ setUsbConfig(UsbManager.USB_FUNCTION_NONE);
+
// Set the new USB configuration.
if (!setUsbConfig(functions)) {
Slog.e(TAG, "Failed to switch USB config to " + functions);