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

Commit db03730b authored by Song Chun Fan's avatar Song Chun Fan Committed by Android (Google) Code Review
Browse files

Merge "[pm] fix a deadlock" into main

parents de5f1bae cef1aed9
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -5753,17 +5753,22 @@ public class PackageManagerService implements PackageSender, TestUtilityService
        @Override
        public void setApplicationCategoryHint(String packageName, int categoryHint,
                String callerPackageName) {
            final int callingUid = Binder.getCallingUid();
            final int userId = UserHandle.getCallingUserId();
            final FunctionalUtils.ThrowingBiFunction<PackageStateMutator.InitialState, Computer,
                    PackageStateMutator.Result> implementation = (initialState, computer) -> {
                if (computer.getInstantAppPackageName(Binder.getCallingUid()) != null) {
                if (computer.getInstantAppPackageName(callingUid) != null) {
                    throw new SecurityException(
                            "Instant applications don't have access to this method");
                }
                mInjector.getSystemService(AppOpsManager.class)
                        .checkPackage(Binder.getCallingUid(), callerPackageName);
                final int callerPackageUid = computer.getPackageUid(callerPackageName, 0, userId);
                if (callerPackageUid != callingUid) {
                    throw new SecurityException(
                            "Package " + callerPackageName + " does not belong to " + callingUid);
                }

                PackageStateInternal packageState = computer.getPackageStateForInstalledAndFiltered(
                        packageName, Binder.getCallingUid(), UserHandle.getCallingUserId());
                        packageName, callingUid, userId);
                if (packageState == null) {
                    throw new IllegalArgumentException("Unknown target package " + packageName);
                }