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

Commit 39251491 authored by Michal Karpinski's avatar Michal Karpinski Committed by android-build-merger
Browse files

Merge "Make sure Notification#deleteIntent cannot be used to start activities...

Merge "Make sure Notification#deleteIntent cannot be used to start activities from background" into qt-dev
am: 2aeac8ce

Change-Id: I6fcb7616500da414ea85eab8676b963985b5c510
parents 74cee4a6 2aeac8ce
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -79,6 +79,13 @@ public abstract class ActivityManagerInternal {
    public abstract void setPendingIntentAllowBgActivityStarts(
            IIntentSender target, IBinder whitelistToken, int flags);

    /**
     * Voids {@link PendingIntent}'s privilege to be whitelisted to start activities from
     * background.
     */
    public abstract void clearPendingIntentAllowBgActivityStarts(IIntentSender target,
            IBinder whitelistToken);

    /**
     * Allow DeviceIdleController to tell us about what apps are whitelisted.
     */
+13 −0
Original line number Diff line number Diff line
@@ -17580,6 +17580,19 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
        }
        @Override
        public void clearPendingIntentAllowBgActivityStarts(IIntentSender target,
                IBinder whitelistToken) {
            if (!(target instanceof PendingIntentRecord)) {
                Slog.w(TAG, "clearPendingIntentAllowBgActivityStarts():"
                        + " not a PendingIntentRecord: " + target);
                return;
            }
            synchronized (ActivityManagerService.this) {
                ((PendingIntentRecord) target).clearAllowBgActivityStarts(whitelistToken);
            }
        }
        @Override
        public void setDeviceIdleWhitelist(int[] allAppids, int[] exceptIdleAppids) {
            synchronized (ActivityManagerService.this) {
+7 −0
Original line number Diff line number Diff line
@@ -236,6 +236,13 @@ public final class PendingIntentRecord extends IIntentSender.Stub {
        }
    }

    void clearAllowBgActivityStarts(IBinder token) {
        if (token == null) return;
        mAllowBgActivityStartsForActivitySender.remove(token);
        mAllowBgActivityStartsForBroadcastSender.remove(token);
        mAllowBgActivityStartsForServiceSender.remove(token);
    }

    public void registerCancelListenerLocked(IResultReceiver receiver) {
        if (mCancelCallbacks == null) {
            mCancelCallbacks = new RemoteCallbackList<>();
+7 −2
Original line number Diff line number Diff line
@@ -6346,9 +6346,14 @@ public class NotificationManagerService extends SystemService {

        // tell the app
        if (sendDelete) {
            if (r.getNotification().deleteIntent != null) {
            final PendingIntent deleteIntent = r.getNotification().deleteIntent;
            if (deleteIntent != null) {
                try {
                    r.getNotification().deleteIntent.send();
                    // make sure deleteIntent cannot be used to start activities from background
                    LocalServices.getService(ActivityManagerInternal.class)
                            .clearPendingIntentAllowBgActivityStarts(deleteIntent.getTarget(),
                            WHITELIST_TOKEN);
                    deleteIntent.send();
                } catch (PendingIntent.CanceledException ex) {
                    // do nothing - there's no relevant way to recover, and
                    //     no reason to let this propagate