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

Commit 06a06db5 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix issue #11536426: Permission denied when trying to launch...

...an activity from a notification

We don't remove pending intents when updating an app, which is necessary
to keep app widgets and other things working.  However, when uninstalling
an app, we should clear out all of its pending intents.

Change-Id: I4b2980f407dbae6c2f4700ca8bc08f299f0a6dca
parent dca4e9ab
Loading
Loading
Loading
Loading
+14 −11
Original line number Diff line number Diff line
@@ -1326,7 +1326,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                    String pkg = bundle.getString("pkg");
                    String reason = bundle.getString("reason");
                    forceStopPackageLocked(pkg, appid, restart, false, true, false,
                            UserHandle.USER_ALL, reason);
                            false, UserHandle.USER_ALL, reason);
                }
            } break;
            case FINALIZE_PENDING_INTENT_MSG: {
@@ -4487,7 +4487,7 @@ public final class ActivityManagerService extends ActivityManagerNative
    private void forceStopPackageLocked(final String packageName, int uid, String reason) {
        forceStopPackageLocked(packageName, UserHandle.getAppId(uid), false,
                false, true, false, UserHandle.getUserId(uid), reason);
                false, true, false, false, UserHandle.getUserId(uid), reason);
        Intent intent = new Intent(Intent.ACTION_PACKAGE_RESTARTED,
                Uri.fromParts("package", packageName, null));
        if (!mProcessesReady) {
@@ -4503,7 +4503,7 @@ public final class ActivityManagerService extends ActivityManagerNative
    }
    private void forceStopUserLocked(int userId, String reason) {
        forceStopPackageLocked(null, -1, false, false, true, false, userId, reason);
        forceStopPackageLocked(null, -1, false, false, true, false, false, userId, reason);
        Intent intent = new Intent(Intent.ACTION_USER_STOPPED);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY
                | Intent.FLAG_RECEIVER_FOREGROUND);
@@ -4588,7 +4588,7 @@ public final class ActivityManagerService extends ActivityManagerNative
    private final boolean forceStopPackageLocked(String name, int appId,
            boolean callerWillRestart, boolean purgeCache, boolean doit,
            boolean evenPersistent, int userId, String reason) {
            boolean evenPersistent, boolean uninstalling, int userId, String reason) {
        int i;
        int N;
@@ -4680,7 +4680,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        // Remove transient permissions granted from/to this package/user
        removeUriPermissionsForPackageLocked(name, userId, false);
        if (name == null) {
        if (name == null || uninstalling) {
            // Remove pending intents.  For now we only do this when force
            // stopping users, because we have some problems when doing this
            // for packages -- app widgets are not currently cleaned up for
@@ -5125,7 +5125,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                if (pkgs != null) {
                    for (String pkg : pkgs) {
                        synchronized (ActivityManagerService.this) {
                            if (forceStopPackageLocked(pkg, -1, false, false, false, false, 0,
                            if (forceStopPackageLocked(pkg, -1, false, false, false, false, false, 0,
                                    "finished booting")) {
                                setResultCode(Activity.RESULT_OK);
                                return;
@@ -8438,7 +8438,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                mDebugTransient = !persistent;
                if (packageName != null) {
                    forceStopPackageLocked(packageName, -1, false, false, true, true,
                            UserHandle.USER_ALL, "set debug app");
                            false, UserHandle.USER_ALL, "set debug app");
                }
            }
        } finally {
@@ -13363,7 +13363,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                        String list[] = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
                        if (list != null && (list.length > 0)) {
                            for (String pkg : list) {
                                forceStopPackageLocked(pkg, -1, false, true, true, false, userId,
                                forceStopPackageLocked(pkg, -1, false, true, true, false, false, userId,
                                        "storage unmount");
                            }
                            sendPackageBroadcastLocked(
@@ -13375,10 +13375,13 @@ public final class ActivityManagerService extends ActivityManagerNative
                        if (data != null && (ssp=data.getSchemeSpecificPart()) != null) {
                            boolean removed = Intent.ACTION_PACKAGE_REMOVED.equals(
                                    intent.getAction());
                            boolean fullUninstall = removed &&
                                    !intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);
                            if (!intent.getBooleanExtra(Intent.EXTRA_DONT_KILL_APP, false)) {
                                forceStopPackageLocked(ssp, UserHandle.getAppId(
                                        intent.getIntExtra(Intent.EXTRA_UID, -1)), false, true, true,
                                        false, userId, removed ? "pkg removed" : "pkg changed");
                                        false, fullUninstall, userId,
                                        removed ? "pkg removed" : "pkg changed");
                            }
                            if (removed) {
                                sendPackageBroadcastLocked(IApplicationThread.PACKAGE_REMOVED,
@@ -13856,7 +13859,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            final long origId = Binder.clearCallingIdentity();
            // Instrumentation can kill and relaunch even persistent processes
            forceStopPackageLocked(ii.targetPackage, -1, true, false, true, true, userId,
            forceStopPackageLocked(ii.targetPackage, -1, true, false, true, true, false, userId,
                    "start instr");
            ProcessRecord app = addAppLocked(ai, false);
            app.instrumentationClass = className;
@@ -13924,7 +13927,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        app.instrumentationProfileFile = null;
        app.instrumentationArguments = null;
        forceStopPackageLocked(app.info.packageName, -1, false, false, true, true, app.userId,
        forceStopPackageLocked(app.info.packageName, -1, false, false, true, true, false, app.userId,
                "finished inst");
    }