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

Commit b2eb6b90 authored by Zoltan Szatmary-Ban's avatar Zoltan Szatmary-Ban
Browse files

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
parent b0b3d0bc
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);
    }