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

Commit 1d038a39 authored by Jin Seok Park's avatar Jin Seok Park
Browse files

Make addOnActiveSessionsChangedListener system API

Bug: 160666400
Test: m update-api; m;
Change-Id: I81607fdac856b783ecc433aa835c3bc1ea47055f
parent e0cb7cce
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ package android.media.session {
  }

  public final class MediaSessionManager {
    method public void addOnActiveSessionsChangedListener(@NonNull android.media.session.MediaSessionManager.OnActiveSessionsChangedListener, @Nullable android.content.ComponentName, int, @Nullable android.os.Handler);
    method public void dispatchMediaKeyEventAsSystemService(@NonNull android.view.KeyEvent);
    method public boolean dispatchMediaKeyEventAsSystemService(@NonNull android.media.session.MediaSession.Token, @NonNull android.view.KeyEvent);
    method public void dispatchVolumeKeyEventAsSystemService(@NonNull android.view.KeyEvent, int);
+1 −1
Original line number Diff line number Diff line
@@ -538,7 +538,7 @@ import java.util.List;
            handler = new Handler(Looper.getMainLooper());
        }
        mSessionManager.addOnActiveSessionsChangedListener(mSessionListener, listenerComponent,
                UserHandle.myUserId(), handler);
                handler);
        mSessionListener.onActiveSessionsChanged(mSessionManager
                .getActiveSessions(listenerComponent));
        if (DEBUG) {
+26 −29
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.compat.annotation.UnsupportedAppUsage;
@@ -259,18 +260,14 @@ public final class MediaSessionManager {
    }

    /**
     * Add a listener to be notified when the list of active sessions
     * changes.This requires the
     * android.Manifest.permission.MEDIA_CONTENT_CONTROL permission be held by
     * the calling app. You may also retrieve this list if your app is an
     * enabled notification listener using the
     * {@link NotificationListenerService} APIs, in which case you must pass the
     * {@link ComponentName} of your enabled listener. Updates will be posted to
     * the thread that registered the listener.
     * Add a listener to be notified when the list of active sessions changes. This requires the
     * {@link android.Manifest.permission#MEDIA_CONTENT_CONTROL} permission be held by the calling
     * app. You may also retrieve this list if your app is an enabled notification listener using
     * the {@link NotificationListenerService} APIs, in which case you must pass the
     * {@link ComponentName} of your enabled listener.
     *
     * @param sessionListener The listener to add.
     * @param notificationListener The enabled notification listener component.
     *            May be null.
     * @param notificationListener The enabled notification listener component. May be null.
     */
    public void addOnActiveSessionsChangedListener(
            @NonNull OnActiveSessionsChangedListener sessionListener,
@@ -279,18 +276,15 @@ public final class MediaSessionManager {
    }

    /**
     * Add a listener to be notified when the list of active sessions
     * changes.This requires the
     * android.Manifest.permission.MEDIA_CONTENT_CONTROL permission be held by
     * the calling app. You may also retrieve this list if your app is an
     * enabled notification listener using the
     * {@link NotificationListenerService} APIs, in which case you must pass the
     * {@link ComponentName} of your enabled listener. Updates will be posted to
     * the handler specified or to the caller's thread if the handler is null.
     * Add a listener to be notified when the list of active sessions changes. This requires the
     * {@link android.Manifest.permission#MEDIA_CONTENT_CONTROL} permission be held by the calling
     * app. You may also retrieve this list if your app is an enabled notification listener using
     * the {@link NotificationListenerService} APIs, in which case you must pass the
     * {@link ComponentName} of your enabled listener. Updates will be posted to the handler
     * specified or to the caller's thread if the handler is null.
     *
     * @param sessionListener The listener to add.
     * @param notificationListener The enabled notification listener component.
     *            May be null.
     * @param notificationListener The enabled notification listener component. May be null.
     * @param handler The handler to post events to.
     */
    public void addOnActiveSessionsChangedListener(
@@ -301,21 +295,24 @@ public final class MediaSessionManager {
    }

    /**
     * Add a listener to be notified when the list of active sessions
     * changes.This requires the
     * android.Manifest.permission.MEDIA_CONTENT_CONTROL permission be held by
     * the calling app. You may also retrieve this list if your app is an
     * enabled notification listener using the
     * {@link NotificationListenerService} APIs, in which case you must pass the
     * {@link ComponentName} of your enabled listener.
     * Add a listener to be notified when the list of active sessions changes for the given user.
     * The calling app must have the {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL}
     * permission if it wants to call this method for a user that is not running the app.
     * <p>
     * This requires the {@link android.Manifest.permission#MEDIA_CONTENT_CONTROL} permission be
     * held by the calling app. You may also retrieve this list if your app is an enabled
     * notification listener using the {@link NotificationListenerService} APIs, in which case you
     * must pass the {@link ComponentName} of your enabled listener. Updates will be posted to the
     * handler specified or to the caller's thread if the handler is null.
     *
     * @param sessionListener The listener to add.
     * @param notificationListener The enabled notification listener component.
     *            May be null.
     * @param notificationListener The enabled notification listener component. May be null.
     * @param userId The userId to listen for changes on.
     * @param handler The handler to post updates on.
     * @hide
     */
    @SuppressLint({"ExecutorRegistration", "SamShouldBeLast"})
    @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
    public void addOnActiveSessionsChangedListener(
            @NonNull OnActiveSessionsChangedListener sessionListener,
            @Nullable ComponentName notificationListener, int userId, @Nullable Handler handler) {
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ package android.media.session {
  }

  public final class MediaSessionManager {
    method public void addOnActiveSessionsChangedListener(@NonNull android.media.session.MediaSessionManager.OnActiveSessionsChangedListener, @Nullable android.content.ComponentName, int, @Nullable android.os.Handler);
    method public void dispatchMediaKeyEventAsSystemService(@NonNull android.view.KeyEvent);
    method public boolean dispatchMediaKeyEventAsSystemService(@NonNull android.media.session.MediaSession.Token, @NonNull android.view.KeyEvent);
    method public void dispatchVolumeKeyEventAsSystemService(@NonNull android.view.KeyEvent, int);