Merge "Prevent accidental unlocking of USB data transfer." into mnc-dev

This commit is contained in:
Zoltan Szatmary-Ban
2015-07-08 11:44:32 +00:00
committed by Android (Google) Code Review

View File

@@ -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);
}