summaryrefslogtreecommitdiffstats
path: root/services/usb
diff options
context:
space:
mode:
authorAjay Dudani <adudani@codeaurora.org>2015-06-22 15:46:41 -0700
committerVineeta Srivastava <vsrivastava@google.com>2015-07-07 11:51:15 -0700
commit84dce3c9a8f217e8dbc038ebb85fd96d2d66c5f6 (patch)
treed8a928585cdb9724941852de7550e9e034cecb5f /services/usb
parentf3a910b88dbb5235552752d0f3492410bca0ef59 (diff)
downloadframeworks_base-84dce3c9a8f217e8dbc038ebb85fd96d2d66c5f6.zip
frameworks_base-84dce3c9a8f217e8dbc038ebb85fd96d2d66c5f6.tar.gz
frameworks_base-84dce3c9a8f217e8dbc038ebb85fd96d2d66c5f6.tar.bz2
UsbDeviceManager: Add back support for persistent property
Take into account the value of persist.sys.usb.config when updating sys.usb.config. The persistent prop can hold information regarding additional enumerations required for the device. Bug: 21929369 Change-Id: Ic11ebf62ce114f2d0a097ad4405de71173b23139
Diffstat (limited to 'services/usb')
-rw-r--r--services/usb/java/com/android/server/usb/UsbDeviceManager.java24
1 files changed, 18 insertions, 6 deletions
diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
index 934ff52..e7716c2 100644
--- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java
+++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
@@ -319,6 +319,7 @@ public class UsbDeviceManager {
private String mCurrentFunctions;
private UsbAccessory mCurrentAccessory;
private int mUsbNotificationId;
+ private String mDefaultFunctions;
private boolean mAdbNotificationShown;
private int mCurrentUser = UserHandle.USER_NULL;
@@ -341,12 +342,18 @@ public class UsbDeviceManager {
public UsbHandler(Looper looper) {
super(looper);
try {
- // Special note about persist.sys.usb.config: We only ever look at the adb value
- // from that property. Other values are ignored. persist.sys.usb.config is now
- // only used to determine if adb is enabled or not.
// TODO: rename persist.sys.usb.config to something more descriptive.
// 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(mDefaultFunctions)) {
+ Slog.w(TAG, "resetting config to persistent property: " + mDefaultFunctions);
+ SystemProperties.set("sys.usb.config", mDefaultFunctions);
+ }
mAdbEnabled = containsFunction(
SystemProperties.get(UsbManager.ADB_PERSISTENT_PROPERTY, "adb"),
@@ -414,11 +421,11 @@ public class UsbDeviceManager {
}
private void updatePersistentProperty() {
- String newValue = mAdbEnabled ? "adb" : "none";
+ String newValue = getDefaultFunctions();
String value = SystemProperties.get(UsbManager.ADB_PERSISTENT_PROPERTY);
if (DEBUG) { Slog.d(TAG, "updatePersistentProperty newValue=" + newValue + " value=" + value); }
if (!newValue.equals(value)) {
- SystemProperties.set(UsbManager.ADB_PERSISTENT_PROPERTY, mAdbEnabled ? "adb" : "none");
+ SystemProperties.set(UsbManager.ADB_PERSISTENT_PROPERTY, getDefaultFunctions());
}
waitForState(newValue);
}
@@ -797,7 +804,12 @@ public class UsbDeviceManager {
}
private String getDefaultFunctions() {
- return mAdbEnabled ? UsbManager.USB_FUNCTION_ADB : UsbManager.USB_FUNCTION_MTP;
+ UserManager userManager = (UserManager)mContext.getSystemService(Context.USER_SERVICE);
+ if(userManager.hasUserRestriction(UserManager.DISALLOW_USB_FILE_TRANSFER,
+ new UserHandle(mCurrentUser))) {
+ return "none";
+ }
+ return mDefaultFunctions;
}
public void dump(FileDescriptor fd, PrintWriter pw) {