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

Commit 068713f6 authored by Pavel Maltsev's avatar Pavel Maltsev
Browse files

Fix UsbSerialReder for multi-user

When UsbSerialReader checks for package it needs to request package for
the calling user, because UsbSerialReader runs in system_proccess under
u0 and the calling package may not be installed for that user.

Fixes: 146079090
Test: flash and verify that UsbDevice#getSerial() returns correct string
(used to return null before the fix)

Change-Id: I637673165dd364f4728e587a59897184ea5b5620
parent 05bc7cc4
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -75,12 +75,14 @@ class UsbSerialReader extends IUsbSerialReader.Stub {
        if (uid != Process.SYSTEM_UID) {
            enforcePackageBelongsToUid(uid, packageName);

            UserHandle user = Binder.getCallingUserHandle();
            int packageTargetSdkVersion;
            long token = Binder.clearCallingIdentity();
            try {
                PackageInfo pkg;
                try {
                    pkg = mContext.getPackageManager().getPackageInfo(packageName, 0);
                    pkg = mContext.getPackageManager()
                            .getPackageInfoAsUser(packageName, 0, user.getIdentifier());
                } catch (PackageManager.NameNotFoundException e) {
                    throw new RemoteException("package " + packageName + " cannot be found");
                }