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

Commit 7bc900e4 authored by Iván Budnik's avatar Iván Budnik Committed by Automerger Merge Worker
Browse files

Merge "Prevent media button receivers targeting activities" into udc-dev am:...

Merge "Prevent media button receivers targeting activities" into udc-dev am: fe79cdd8 am: 8b3d9dbf

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24444452



Change-Id: I8f87ec2315ca63933f580a9cb77949eb8ea7a80a
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents f8abcc79 8b3d9dbf
Loading
Loading
Loading
Loading
+14 −9
Original line number Original line Diff line number Diff line
@@ -267,17 +267,22 @@ public final class MediaSession {
    }
    }


    /**
    /**
     * Set a pending intent for your media button receiver to allow restarting
     * Set a pending intent for your media button receiver to allow restarting playback after the
     * playback after the session has been stopped. If your app is started in
     * session has been stopped.
     * this way an {@link Intent#ACTION_MEDIA_BUTTON} intent will be sent via
     *
     * the pending intent.
     * <p>If your app is started in this way an {@link Intent#ACTION_MEDIA_BUTTON} intent will be
     * <p>
     * sent via the pending intent.
     * The pending intent is recommended to be explicit to follow the security recommendation of
     *
     * {@link PendingIntent#getActivity}.
     * <p>The provided {@link PendingIntent} must not target an activity. Passing an activity
     * pending intent will cause the call to be ignored. Refer to this <a
     * href="https://developer.android.com/guide/components/activities/background-starts">guide</a>
     * for more information.
     *
     * <p>The pending intent is recommended to be explicit to follow the security recommendation of
     * {@link PendingIntent#getService}.
     *
     *
     * @param mbr The {@link PendingIntent} to send the media button event to.
     * @param mbr The {@link PendingIntent} to send the media button event to.
     * @see PendingIntent#getActivity
     * @see PendingIntent#getActivity
     *
     * @deprecated Use {@link #setMediaButtonBroadcastReceiver(ComponentName)} instead.
     * @deprecated Use {@link #setMediaButtonBroadcastReceiver(ComponentName)} instead.
     */
     */
    @Deprecated
    @Deprecated
@@ -285,7 +290,7 @@ public final class MediaSession {
        try {
        try {
            mBinder.setMediaButtonReceiver(mbr);
            mBinder.setMediaButtonReceiver(mbr);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.wtf(TAG, "Failure in setMediaButtonReceiver.", e);
            e.rethrowFromSystemServer();
        }
        }
    }
    }


+8 −0
Original line number Original line Diff line number Diff line
@@ -1062,6 +1062,14 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR
                        != 0) {
                        != 0) {
                    return;
                    return;
                }
                }

                if (pi != null && pi.isActivity()) {
                    Log.w(
                            TAG,
                            "Ignoring invalid media button receiver targeting an activity: " + pi);
                    return;
                }

                mMediaButtonReceiverHolder =
                mMediaButtonReceiverHolder =
                        MediaButtonReceiverHolder.create(mUserId, pi, mPackageName);
                        MediaButtonReceiverHolder.create(mUserId, pi, mPackageName);
                mService.onMediaButtonReceiverChanged(MediaSessionRecord.this);
                mService.onMediaButtonReceiverChanged(MediaSessionRecord.this);