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

Commit 9321e8c9 authored by JW Wang's avatar JW Wang
Browse files

getDeviceOwnerDeletedPackageMsg() should call clearCallingIdentity()

DevicePolicyResourcesManager should be called in the context of
system_server instead of the calling app to avoid UID and package
name mismatch.

Bug: 246487618
Test: atest SessionCommitBroadcastTest
Change-Id: I1d27c7cd879d440abcf834830563368e50f521f2
parent 833fb8b8
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -1344,9 +1344,14 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
        }

        private String getDeviceOwnerDeletedPackageMsg() {
            final long ident = Binder.clearCallingIdentity();
            try {
                DevicePolicyManager dpm = mContext.getSystemService(DevicePolicyManager.class);
                return dpm.getResources().getString(PACKAGE_DELETED_BY_DO,
                        () -> mContext.getString(R.string.package_deleted_device_owner));
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
        }

        @Override