Clean up persistent usb state on boot. am: dfacad026d
am: b15490ac4d
Change-Id: I2fd38cd6b27685206f6aa5f11daecbc7654749d1
This commit is contained in:
@@ -342,6 +342,16 @@ public class UsbDeviceManager {
|
|||||||
mAdbEnabled = UsbManager.containsFunction(getDefaultFunctions(),
|
mAdbEnabled = UsbManager.containsFunction(getDefaultFunctions(),
|
||||||
UsbManager.USB_FUNCTION_ADB);
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
setEnabledFunctions(null, false, false);
|
setEnabledFunctions(null, false, false);
|
||||||
|
|
||||||
String state = FileUtils.readTextFile(new File(STATE_PATH), 0, null).trim();
|
String state = FileUtils.readTextFile(new File(STATE_PATH), 0, null).trim();
|
||||||
@@ -457,17 +467,13 @@ public class UsbDeviceManager {
|
|||||||
USB_PERSISTENT_CONFIG_PROPERTY, UsbManager.USB_FUNCTION_NONE));
|
USB_PERSISTENT_CONFIG_PROPERTY, UsbManager.USB_FUNCTION_NONE));
|
||||||
SystemProperties.set(USB_PERSISTENT_CONFIG_PROPERTY, newFunction);
|
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
|
// Remove mtp from the config if file transfer is not enabled
|
||||||
if (oldFunctions.equals(UsbManager.USB_FUNCTION_MTP) &&
|
if (oldFunctions.equals(UsbManager.USB_FUNCTION_MTP) &&
|
||||||
!mUsbDataUnlocked && enable) {
|
!mUsbDataUnlocked && enable) {
|
||||||
oldFunctions = UsbManager.USB_FUNCTION_NONE;
|
oldFunctions = UsbManager.USB_FUNCTION_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
setEnabledFunctions(oldFunctions, false, mUsbDataUnlocked);
|
setEnabledFunctions(oldFunctions, true, mUsbDataUnlocked);
|
||||||
updateAdbNotification();
|
updateAdbNotification();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user