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

Commit bacb5422 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by Android (Google) Code Review
Browse files

Merge "Also rely on enabled notification listeners for RemoteController registration" into klp-dev

parents d5102f19 f108cdd9
Loading
Loading
Loading
Loading
+13 −18
Original line number Diff line number Diff line
@@ -13359,34 +13359,29 @@ package android.media {
  }
  public final class RemoteController {
    ctor public RemoteController(android.content.Context) throws java.lang.IllegalArgumentException;
    ctor public RemoteController(android.content.Context, android.os.Looper) throws java.lang.IllegalArgumentException;
    method public int clearArtworkConfiguration();
    ctor public RemoteController(android.content.Context, android.media.RemoteController.OnClientUpdateListener) throws java.lang.IllegalArgumentException;
    ctor public RemoteController(android.content.Context, android.media.RemoteController.OnClientUpdateListener, android.os.Looper) throws java.lang.IllegalArgumentException;
    method public boolean clearArtworkConfiguration();
    method public android.media.RemoteController.MetadataEditor editMetadata();
    method public long getEstimatedMediaPosition();
    method public int seekTo(long);
    method public int sendMediaKeyEvent(android.view.KeyEvent);
    method public int setArtworkConfiguration(int, int);
    method public void setOnClientUpdateListener(android.media.RemoteController.OnClientUpdateListener);
    method public int setSynchronizationMode(int);
    field public static final int ERROR = -1; // 0xffffffff
    field public static final int ERROR_BAD_VALUE = -2; // 0xfffffffe
    method public boolean seekTo(long) throws java.lang.IllegalArgumentException;
    method public boolean sendMediaKeyEvent(android.view.KeyEvent) throws java.lang.IllegalArgumentException;
    method public boolean setArtworkConfiguration(int, int) throws java.lang.IllegalArgumentException;
    method public boolean setSynchronizationMode(int) throws java.lang.IllegalArgumentException;
    field public static final int POSITION_SYNCHRONIZATION_CHECK = 1; // 0x1
    field public static final int POSITION_SYNCHRONIZATION_NONE = 0; // 0x0
    field public static final int SUCCESS = 0; // 0x0
  }
  public class RemoteController.MetadataEditor extends android.media.MediaMetadataEditor {
    method public synchronized void apply();
  }
  public static abstract class RemoteController.OnClientUpdateListener {
    ctor public RemoteController.OnClientUpdateListener();
    method public void onClientChange(boolean);
    method public void onClientMetadataUpdate(android.media.RemoteController.MetadataEditor);
    method public void onClientPlaybackStateUpdate(int);
    method public void onClientPlaybackStateUpdate(int, long, long, float);
    method public void onClientTransportControlUpdate(int);
  public static abstract interface RemoteController.OnClientUpdateListener {
    method public abstract void onClientChange(boolean);
    method public abstract void onClientMetadataUpdate(android.media.RemoteController.MetadataEditor);
    method public abstract void onClientPlaybackStateUpdate(int);
    method public abstract void onClientPlaybackStateUpdate(int, long, long, float);
    method public abstract void onClientTransportControlUpdate(int);
  }
  public final class ResourceBusyException extends android.media.MediaDrmException {
+5 −0
Original line number Diff line number Diff line
@@ -139,6 +139,11 @@ public class Media extends BaseCommand {
                    + " intent=" + clientMediaIntent + " clearing=" + clearing);
        }

        @Override
        public void setEnabled(boolean enabled) {
            System.out.println("New enable state= " + (enabled ? "enabled" : "disabled"));
        }

        @Override
        public void setPlaybackState(int generationId, int state, long stateChangeTimeMs,
                long currentPosMs, float speed) {
+12 −4
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.bluetooth.BluetoothDevice;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.media.RemoteController.OnClientUpdateListener;
import android.os.Binder;
import android.os.Build;
import android.os.Handler;
@@ -2270,7 +2271,9 @@ public class AudioManager {
     * Registers a {@link RemoteController} instance for it to receive media metadata updates
     * and playback state information from applications using {@link RemoteControlClient}, and
     * control their playback.
     * <p>Registration requires the {@link Manifest.permission#MEDIA_CONTENT_CONTROL} permission.
     * <p>Registration requires the {@link OnClientUpdateListener} listener to be one of the
     * enabled notification listeners (see
     * {@link android.service.notification.NotificationListenerService}).
     * @param rctlr the object to register.
     * @return true if the {@link RemoteController} was successfully registered, false if an
     *     error occurred, due to an internal system error, or insufficient permissions.
@@ -2280,14 +2283,17 @@ public class AudioManager {
            return false;
        }
        IAudioService service = getService();
        final RemoteController.OnClientUpdateListener l = rctlr.getUpdateListener();
        final ComponentName listenerComponent = new ComponentName(mContext, l.getClass());
        try {
            int[] artworkDimensions = rctlr.getArtworkSize();
            boolean reg = service.registerRemoteControlDisplay(rctlr.getRcDisplay(),
                    artworkDimensions[0]/*w*/, artworkDimensions[1]/*h*/);
            boolean reg = service.registerRemoteController(rctlr.getRcDisplay(),
                    artworkDimensions[0]/*w*/, artworkDimensions[1]/*h*/,
                    listenerComponent);
            rctlr.setIsRegistered(reg);
            return reg;
        } catch (RemoteException e) {
            Log.e(TAG, "Dead object in registerRemoteControlDisplay " + e);
            Log.e(TAG, "Dead object in registerRemoteController " + e);
            return false;
        }
    }
@@ -2318,6 +2324,7 @@ public class AudioManager {
     * artwork size directly, or
     * {@link #remoteControlDisplayUsesBitmapSize(IRemoteControlDisplay, int, int)} later if artwork
     * is not yet needed.
     * <p>Registration requires the {@link Manifest.permission#MEDIA_CONTENT_CONTROL} permission.
     * @param rcd the IRemoteControlDisplay
     */
    public void registerRemoteControlDisplay(IRemoteControlDisplay rcd) {
@@ -2328,6 +2335,7 @@ public class AudioManager {
    /**
     * @hide
     * Registers a remote control display that will be sent information by remote control clients.
     * <p>Registration requires the {@link Manifest.permission#MEDIA_CONTENT_CONTROL} permission.
     * @param rcd
     * @param w the maximum width of the expected bitmap. Negative values indicate it is
     *   useless to send artwork.
+8 −10
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import android.content.res.XmlResourceParser;
import android.database.ContentObserver;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnErrorListener;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
@@ -87,6 +88,7 @@ import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -4162,17 +4164,13 @@ public class AudioService extends IAudioService.Stub {
    //==========================================================================================
    // RemoteControlDisplay / RemoteControlClient / Remote info
    //==========================================================================================
    public boolean registerRemoteControlDisplay(IRemoteControlDisplay rcd, int w, int h) {
        if (PackageManager.PERMISSION_GRANTED == mContext.checkCallingOrSelfPermission(
                android.Manifest.permission.MEDIA_CONTENT_CONTROL)) {
            mMediaFocusControl.registerRemoteControlDisplay(rcd, w, h);
            return true;
        } else {
            Log.w(TAG, "Access denied to process: " + Binder.getCallingPid() +
                    ", must have permission " + android.Manifest.permission.MEDIA_CONTENT_CONTROL +
                    " to register IRemoteControlDisplay");
            return false;
    public boolean registerRemoteController(IRemoteControlDisplay rcd, int w, int h,
            ComponentName listenerComp) {
        return mMediaFocusControl.registerRemoteController(rcd, w, h, listenerComp);
    }

    public boolean registerRemoteControlDisplay(IRemoteControlDisplay rcd, int w, int h) {
        return mMediaFocusControl.registerRemoteControlDisplay(rcd, w, h);
    }

    public void unregisterRemoteControlDisplay(IRemoteControlDisplay rcd) {
+12 −0
Original line number Diff line number Diff line
@@ -133,6 +133,8 @@ interface IAudioService {

    /**
     * Register an IRemoteControlDisplay.
     * Success of registration is subject to a check on
     *   the android.Manifest.permission.MEDIA_CONTENT_CONTROL permission.
     * Notify all IRemoteControlClient of the new display and cause the RemoteControlClient
     * at the top of the stack to update the new display with its information.
     * @param rcd the IRemoteControlDisplay to register. No effect if null.
@@ -142,6 +144,16 @@ interface IAudioService {
     *   display doesn't need to receive artwork.
     */
    boolean registerRemoteControlDisplay(in IRemoteControlDisplay rcd, int w, int h);

    /**
     * Like registerRemoteControlDisplay, but with success being subject to a check on
     *   the android.Manifest.permission.MEDIA_CONTENT_CONTROL permission, and if it fails,
     *   success is subject to listenerComp being one of the ENABLED_NOTIFICATION_LISTENERS
     *   components.
     */
    boolean registerRemoteController(in IRemoteControlDisplay rcd, int w, int h,
            in ComponentName listenerComp);

    /**
     * Unregister an IRemoteControlDisplay.
     * No effect if the IRemoteControlDisplay hasn't been successfully registered.
Loading