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

Commit e89688fc authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Check USB device/accessory perms with sys identity

As checking the permissions might call UsbDevice/UsbAccessory.getSerial
again, we have to make sure that in this code paths we run with the
system's identity so that we can always resolve the serial number.

Test: CtsVerifier UsbAccessory/UsbDevice test
Fixes: 117606509
Change-Id: I777be10b806ab02046f99805806ae1a16ebb0203
parent 3fb12ba4
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -85,9 +85,6 @@ class UsbSerialReader extends IUsbSerialReader.Stub {
                    throw new RemoteException("package " + packageName + " cannot be found");
                }
                packageTargetSdkVersion = pkg.applicationInfo.targetSdkVersion;
            } finally {
                Binder.restoreCallingIdentity(token);
            }

                if (packageTargetSdkVersion >= Build.VERSION_CODES.Q) {
                    if (mContext.checkPermission(android.Manifest.permission.MANAGE_USB, pid, uid)
@@ -102,6 +99,9 @@ class UsbSerialReader extends IUsbSerialReader.Stub {
                        }
                    }
                }
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }

        return mSerialNumber;