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

Commit b725f0dd authored by Sudheer Shanka's avatar Sudheer Shanka Committed by Android (Google) Code Review
Browse files

Merge "Cancel PendingIntents created by apps on force-stopping them." into main

parents b22ed81f d79955cd
Loading
Loading
Loading
Loading
+20 −17
Original line number Diff line number Diff line
@@ -1886,7 +1886,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                    int exitInfoReason = (int) args.arg3;
                    args.recycle();
                    forceStopPackageLocked(pkg, appId, false, false, true, false,
                            false, userId, reason, exitInfoReason);
                            false, false, userId, reason, exitInfoReason);
                }
            } break;
@@ -3914,7 +3914,10 @@ public class ActivityManagerService extends IActivityManager.Stub
                                + packageName + ": " + e);
                    }
                    if (mUserController.isUserRunning(user, userRunningFlags)) {
                        forceStopPackageLocked(packageName, pkgUid,
                        forceStopPackageLocked(packageName, UserHandle.getAppId(pkgUid),
                                false /* callerWillRestart */, false /* purgeCache */,
                                true /* doIt */, false /* evenPersistent */,
                                false /* uninstalling */, true /* packageStateStopped */, user,
                                reason == null ? ("from pid " + callingPid) : reason);
                        finishForceStopPackageLocked(packageName, pkgUid);
                    }
@@ -4163,7 +4166,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    @GuardedBy("this")
    private void forceStopPackageLocked(final String packageName, int uid, String reason) {
        forceStopPackageLocked(packageName, UserHandle.getAppId(uid), false,
                false, true, false, false, UserHandle.getUserId(uid), reason);
                false, true, false, false, false, UserHandle.getUserId(uid), reason);
    }
    @GuardedBy("this")
@@ -4349,20 +4352,20 @@ public class ActivityManagerService extends IActivityManager.Stub
    @GuardedBy("this")
    final boolean forceStopPackageLocked(String packageName, int appId,
            boolean callerWillRestart, boolean purgeCache, boolean doit,
            boolean evenPersistent, boolean uninstalling, int userId, String reasonString) {
            boolean evenPersistent, boolean uninstalling, boolean packageStateStopped,
            int userId, String reasonString) {
        int reason = packageName == null ? ApplicationExitInfo.REASON_USER_STOPPED
                : ApplicationExitInfo.REASON_USER_REQUESTED;
        return forceStopPackageLocked(packageName, appId, callerWillRestart, purgeCache, doit,
                evenPersistent, uninstalling, userId, reasonString, reason);
                evenPersistent, uninstalling, packageStateStopped, userId, reasonString, reason);
    }
    @GuardedBy("this")
    final boolean forceStopPackageLocked(String packageName, int appId,
            boolean callerWillRestart, boolean purgeCache, boolean doit,
            boolean evenPersistent, boolean uninstalling, int userId, String reasonString,
            int reason) {
            boolean evenPersistent, boolean uninstalling, boolean packageStateStopped,
            int userId, String reasonString, int reason) {
        int i;
        if (userId == UserHandle.USER_ALL && packageName == null) {
@@ -4443,7 +4446,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
        }
        if (packageName == null || uninstalling) {
        if (packageName == null || uninstalling || packageStateStopped) {
            didSomething |= mPendingIntentController.removePendingIntentsForPackage(
                    packageName, userId, appId, doit);
        }
@@ -5148,7 +5151,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                    for (String pkg : pkgs) {
                        synchronized (ActivityManagerService.this) {
                            if (forceStopPackageLocked(pkg, -1, false, false, false, false, false,
                                    0, "query restart")) {
                                    false, 0, "query restart")) {
                                setResultCode(Activity.RESULT_OK);
                                return;
                            }
@@ -7342,7 +7345,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                mDebugTransient = !persistent;
                if (packageName != null) {
                    forceStopPackageLocked(packageName, -1, false, false, true, true,
                            false, UserHandle.USER_ALL, "set debug app");
                            false, false, UserHandle.USER_ALL, "set debug app");
                }
            }
        } finally {
@@ -14918,7 +14921,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                            if (list != null && list.length > 0) {
                                for (int i = 0; i < list.length; i++) {
                                    forceStopPackageLocked(list[i], -1, false, true, true,
                                            false, false, userId, "storage unmount");
                                            false, false, false, userId, "storage unmount");
                                }
                                mAtmInternal.cleanupRecentTasksForUser(UserHandle.USER_ALL);
                                sendPackageBroadcastLocked(
@@ -14945,8 +14948,8 @@ public class ActivityManagerService extends IActivityManager.Stub
                                    if (killProcess) {
                                        forceStopPackageLocked(ssp, UserHandle.getAppId(
                                                intent.getIntExtra(Intent.EXTRA_UID, -1)),
                                                false, true, true, false, fullUninstall, userId,
                                                "pkg removed");
                                                false, true, true, false, fullUninstall, false,
                                                userId, "pkg removed");
                                        getPackageManagerInternal()
                                                .onPackageProcessKilledForUninstall(ssp);
                                    } else {
@@ -15864,7 +15867,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                } else {
                    // Instrumentation can kill and relaunch even persistent processes
                    forceStopPackageLocked(ii.targetPackage, -1, true, false, true, true, false,
                            userId, "start instr");
                            false, userId, "start instr");
                    // Inform usage stats to make the target package active
                    if (mUsageStatsService != null) {
                        mUsageStatsService.reportEvent(ii.targetPackage, userId,
@@ -15993,6 +15996,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                        /* doIt= */ true,
                        /* evenPersistent= */ true,
                        /* uninstalling= */ false,
                        /* packageStateStopped= */ false,
                        userId,
                        "start instr");
@@ -16163,8 +16167,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                }
            } else if (!instr.mNoRestart) {
                forceStopPackageLocked(app.info.packageName, -1, false, false, true, true, false,
                        app.userId,
                        "finished inst");
                        false, app.userId, "finished inst");
            }
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
+3 −3
Original line number Diff line number Diff line
@@ -2040,7 +2040,7 @@ public final class ProcessList {
            // the package was initially frozen through KILL_APPLICATION_MSG, so
            // it doesn't hurt to use it again.)
            mService.forceStopPackageLocked(app.info.packageName, UserHandle.getAppId(app.uid),
                    false, false, true, false, false, app.userId, "start failure");
                    false, false, true, false, false, false, app.userId, "start failure");
            return false;
        }
    }
@@ -2115,7 +2115,7 @@ public final class ProcessList {
                        + app.processName, e);
                app.setPendingStart(false);
                mService.forceStopPackageLocked(app.info.packageName, UserHandle.getAppId(app.uid),
                        false, false, true, false, false, app.userId, "start failure");
                        false, false, true, false, false, false, app.userId, "start failure");
            }
            return app.getPid() > 0;
        }
@@ -2148,7 +2148,7 @@ public final class ProcessList {
                    app.setPendingStart(false);
                    mService.forceStopPackageLocked(app.info.packageName,
                            UserHandle.getAppId(app.uid),
                            false, false, true, false, false, app.userId, "start failure");
                            false, false, true, false, false, false, app.userId, "start failure");
                }
            }
        };
+1 −1
Original line number Diff line number Diff line
@@ -3629,7 +3629,7 @@ class UserController implements Handler.Callback {

        void activityManagerForceStopPackage(@UserIdInt int userId, String reason) {
            synchronized (mService) {
                mService.forceStopPackageLocked(null, -1, false, false, true, false, false,
                mService.forceStopPackageLocked(null, -1, false, false, true, false, false, false,
                        userId, reason);
            }
        };