summaryrefslogtreecommitdiffstats
path: root/services/usb
diff options
context:
space:
mode:
authorZoltan Szatmary-Ban <szatmz@google.com>2015-07-07 13:24:59 +0100
committerZoltan Szatmary-Ban <szatmz@google.com>2015-07-07 13:24:59 +0100
commitb2eb6b9049567c134d7654f6cd79b4a47de643af (patch)
tree1e1f4afc41ff17dcbc7d83bd5640ec0f4675475e /services/usb
parentb0b3d0bcfb0af678d4c85bec63722f976ffb01cf (diff)
downloadframeworks_base-b2eb6b9049567c134d7654f6cd79b4a47de643af.zip
frameworks_base-b2eb6b9049567c134d7654f6cd79b4a47de643af.tar.gz
frameworks_base-b2eb6b9049567c134d7654f6cd79b4a47de643af.tar.bz2
Prevent accidental unlocking of USB data transfer.
When DISALLOW_USB_FILE_TRANSFER is in effect, there must be no chance to unlock data transfer over USB. Bug: 22291579 Change-Id: I990fedbfeecd90e7dd26981034d0352b83dc694e
Diffstat (limited to 'services/usb')
-rw-r--r--services/usb/java/com/android/server/usb/UsbService.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/services/usb/java/com/android/server/usb/UsbService.java b/services/usb/java/com/android/server/usb/UsbService.java
index 7a3426c..987a79f 100644
--- a/services/usb/java/com/android/server/usb/UsbService.java
+++ b/services/usb/java/com/android/server/usb/UsbService.java
@@ -273,6 +273,13 @@ public class UsbService extends IUsbManager.Stub {
@Override
public void setUsbDataUnlocked(boolean unlocked) {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USB, null);
+ // If attempt to change USB function while file transfer is restricted, ensure that
+ // usb data is always locked, and return.
+ UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
+ if (userManager.hasUserRestriction(UserManager.DISALLOW_USB_FILE_TRANSFER)) {
+ if (mDeviceManager != null) mDeviceManager.setUsbDataUnlocked(false);
+ return;
+ }
mDeviceManager.setUsbDataUnlocked(unlocked);
}