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

Commit d66babf9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix inconsistent behavior of killPackageDependents." into main

parents e717267a a9b535f8
Loading
Loading
Loading
Loading
+25 −16
Original line number Diff line number Diff line
@@ -18398,27 +18398,36 @@ public class ActivityManagerService extends IActivityManager.Stub
                    "Cannot kill the dependents of a package without its name.");
        }
        userId = mUserController.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
                userId, true, ALLOW_FULL_ONLY, "killPackageDependents", null);
        final int[] userIds = mUserController.expandUserId(userId);
        final long callingId = Binder.clearCallingIdentity();
        IPackageManager pm = AppGlobals.getPackageManager();
        try {
            for (int targetUserId : userIds) {
                int pkgUid = -1;
                try {
            pkgUid = pm.getPackageUid(packageName, MATCH_DEBUG_TRIAGED_MISSING, userId);
                    pkgUid = pm.getPackageUid(packageName, MATCH_DEBUG_TRIAGED_MISSING,
                            targetUserId);
                } catch (RemoteException e) {
                }
                if (userId != UserHandle.USER_ALL && pkgUid == -1) {
                    throw new IllegalArgumentException(
                            "Cannot kill dependents of non-existing package " + packageName);
                }
        try {
                synchronized (this) {
                    synchronized (mProcLock) {
                    mProcessList.killPackageProcessesLSP(packageName, UserHandle.getAppId(pkgUid),
                            userId, ProcessList.FOREGROUND_APP_ADJ,
                        mProcessList.killPackageProcessesLSP(packageName,
                                UserHandle.getAppId(pkgUid),
                                targetUserId,
                                ProcessList.FOREGROUND_APP_ADJ,
                                ApplicationExitInfo.REASON_DEPENDENCY_DIED,
                                ApplicationExitInfo.SUBREASON_UNKNOWN,
                                "dep: " + packageName);
                    }
                }
            }
        } finally {
            Binder.restoreCallingIdentity(callingId);
        }