Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a2de7fc9 authored by Zoltan Szatmary-Ban's avatar Zoltan Szatmary-Ban Committed by Android (Google) Code Review
Browse files

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

parents 89592760 b2eb6b90
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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);
    }