diff options
author | Mike Lockwood <lockwood@android.com> | 2011-07-10 11:48:18 -0400 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2011-07-11 18:23:44 -0400 |
commit | c264afeb5528733a215a472e761b51cc59bba454 (patch) | |
tree | 9ae0e1faec3c123d8437e4cecd7a87b2fb19d435 /services/java/com/android/server/usb/UsbDeviceManager.java | |
parent | d44e1b6033eed29718f2e7e3540e4884929941a5 (diff) |
UsbDeviceManager: Initialize state based on persist.sys.usb.config rather than current kernel state
This makes it more robust when recovering from runtime restarts
Bug: 4986841
Change-Id: I54b94213447130ca881c66da2d0ce490242f0c96
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'services/java/com/android/server/usb/UsbDeviceManager.java')
-rw-r--r-- | services/java/com/android/server/usb/UsbDeviceManager.java | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/services/java/com/android/server/usb/UsbDeviceManager.java b/services/java/com/android/server/usb/UsbDeviceManager.java index 1ab570a7a7f7..77e6eef70656 100644 --- a/services/java/com/android/server/usb/UsbDeviceManager.java +++ b/services/java/com/android/server/usb/UsbDeviceManager.java @@ -251,19 +251,18 @@ public class UsbDeviceManager { public UsbHandler() { try { + // persist.sys.usb.config should never be unset. But if it is, set it to "adb" + // so we have a chance of debugging what happened. + mDefaultFunctions = SystemProperties.get("persist.sys.usb.config", "adb"); // sanity check the sys.usb.config system property // this may be necessary if we crashed while switching USB configurations String config = SystemProperties.get("sys.usb.config", "none"); - if (config.equals("none")) { - String persistConfig = SystemProperties.get("persist.sys.usb.config", "none"); - Slog.w(TAG, "resetting config to persistent property: " + persistConfig); - SystemProperties.set("sys.usb.config", persistConfig); + if (!config.equals(mDefaultFunctions)) { + Slog.w(TAG, "resetting config to persistent property: " + mDefaultFunctions); + SystemProperties.set("sys.usb.config", mDefaultFunctions); } - // Read initial USB state - mCurrentFunctions = FileUtils.readTextFile( - new File(FUNCTIONS_PATH), 0, null).trim(); - mDefaultFunctions = mCurrentFunctions; + mCurrentFunctions = mDefaultFunctions; String state = FileUtils.readTextFile(new File(STATE_PATH), 0, null).trim(); updateState(state); mAdbEnabled = containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_ADB); |