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

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

Merge "Remote control display API and implementation"

parents 3f76ca47 8f619182
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -183,6 +183,7 @@ LOCAL_SRC_FILES += \
	media/java/android/media/IAudioFocusDispatcher.aidl \
	media/java/android/media/IMediaScannerListener.aidl \
	media/java/android/media/IMediaScannerService.aidl \
	media/java/android/media/IRemoteControlClient.aidl \
	telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \
	telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \
	telephony/java/com/android/internal/telephony/ITelephony.aidl \
+128 −2
Original line number Diff line number Diff line
@@ -1646,7 +1646,8 @@ public class AudioManager {
        IAudioService service = getService();
        try {
            status = service.requestAudioFocus(streamType, durationHint, mICallBack,
                    mAudioFocusDispatcher, getIdForAudioFocusListener(l));
                    mAudioFocusDispatcher, getIdForAudioFocusListener(l),
                    mContext.getPackageName() /* package name */);
        } catch (RemoteException e) {
            Log.e(TAG, "Can't call requestAudioFocus() from AudioService due to "+e);
        }
@@ -1682,7 +1683,9 @@ public class AudioManager {
     *      in the application manifest.
     */
    public void registerMediaButtonEventReceiver(ComponentName eventReceiver) {
        //TODO enforce the rule about the receiver being declared in the manifest
        if (eventReceiver == null) {
            return;
        }
        IAudioService service = getService();
        try {
            service.registerMediaButtonEventReceiver(eventReceiver);
@@ -1697,6 +1700,9 @@ public class AudioManager {
     *      that was registered with {@link #registerMediaButtonEventReceiver(ComponentName)}.
     */
    public void unregisterMediaButtonEventReceiver(ComponentName eventReceiver) {
        if (eventReceiver == null) {
            return;
        }
        IAudioService service = getService();
        try {
            service.unregisterMediaButtonEventReceiver(eventReceiver);
@@ -1705,6 +1711,126 @@ public class AudioManager {
        }
    }

    /**
     * @hide
     * Registers the remote control client for providing information to display on the remotes.
     * @param eventReceiver identifier of a {@link android.content.BroadcastReceiver}
     *      that will receive the media button intent, and associated with the remote control
     *      client. This method has no effect if
     *      {@link #registerMediaButtonEventReceiver(ComponentName)} hasn't been called
     *      with the same eventReceiver, or if
     *      {@link #unregisterMediaButtonEventReceiver(ComponentName)} has been called.
     * @param rcClient the client associated with the event receiver, responsible for providing
     *      the information to display on the remote control.
     */
    public void registerRemoteControlClient(ComponentName eventReceiver,
            IRemoteControlClient rcClient) {
        if (eventReceiver == null) {
            return;
        }
        IAudioService service = getService();
        try {
            service.registerRemoteControlClient(eventReceiver, rcClient,
                    // used to match media button event receiver and audio focus
                    mContext.getPackageName());
        } catch (RemoteException e) {
            Log.e(TAG, "Dead object in registerRemoteControlClient"+e);
        }
    }

    /**
     * @hide
     * @param eventReceiver
     */
    public void unregisterRemoteControlClient(ComponentName eventReceiver) {
        if (eventReceiver == null) {
            return;
        }
        IAudioService service = getService();
        try {
            // unregistering a IRemoteControlClient is equivalent to setting it to null
            service.registerRemoteControlClient(eventReceiver, null, mContext.getPackageName());
        } catch (RemoteException e) {
            Log.e(TAG, "Dead object in unregisterRemoteControlClient"+e);
        }
    }

    /**
     * @hide
     * Definitions of constants to be used in {@link android.media.IRemoteControlClient}.
     */
    public final class RemoteControlParameters {
        public final static int PLAYSTATE_STOPPED            = 1;
        public final static int PLAYSTATE_PAUSED             = 2;
        public final static int PLAYSTATE_PLAYING            = 3;
        public final static int PLAYSTATE_FAST_FORWARDING    = 4;
        public final static int PLAYSTATE_REWINDING          = 5;
        public final static int PLAYSTATE_SKIPPING_FORWARDS  = 6;
        public final static int PLAYSTATE_SKIPPING_BACKWARDS = 7;
        public final static int PLAYSTATE_BUFFERING          = 8;

        public final static int FLAG_KEY_MEDIA_PREVIOUS = 1 << 0;
        public final static int FLAG_KEY_MEDIA_REWIND = 1 << 1;
        public final static int FLAG_KEY_MEDIA_PLAY = 1 << 2;
        public final static int FLAG_KEY_MEDIA_PLAY_PAUSE = 1 << 3;
        public final static int FLAG_KEY_MEDIA_PAUSE = 1 << 4;
        public final static int FLAG_KEY_MEDIA_STOP = 1 << 5;
        public final static int FLAG_KEY_MEDIA_FAST_FORWARD = 1 << 6;
        public final static int FLAG_KEY_MEDIA_NEXT = 1 << 7;
    }

    /**
     * @hide
     * Broadcast intent action indicating that the displays on the remote controls
     * should be updated because a new remote control client is now active. If there is no
     * {@link #EXTRA_REMOTE_CONTROL_CLIENT}, the remote control display should be cleared
     * because there is no valid client to supply it with information.
     *
     * @see #EXTRA_REMOTE_CONTROL_CLIENT
     */
    public static final String REMOTE_CONTROL_CLIENT_CHANGED =
            "android.media.REMOTE_CONTROL_CLIENT_CHANGED";

    /**
     * @hide
     * The IRemoteControlClient monotonically increasing generation counter.
     *
     * @see #REMOTE_CONTROL_CLIENT_CHANGED_ACTION
     */
    public static final String EXTRA_REMOTE_CONTROL_CLIENT =
            "android.media.EXTRA_REMOTE_CONTROL_CLIENT";

    /**
     * @hide
     * FIXME to be changed to address Neel's comments
     * Force a refresh of the remote control client associated with the event receiver.
     * @param eventReceiver
     */
    public void refreshRemoteControlDisplay(ComponentName eventReceiver) {
        IAudioService service = getService();
        try {
            service.refreshRemoteControlDisplay(eventReceiver);
        } catch (RemoteException e) {
            Log.e(TAG, "Dead object in refreshRemoteControlDisplay"+e);
        }
    }

    /**
     * @hide
     * FIXME API to be used by implementors of remote controls, not a candidate for SDK
     */
    public void registerRemoteControlObserver() {

    }

    /**
     * @hide
     * FIXME API to be used by implementors of remote controls, not a candidate for SDK
     */
    public void unregisterRemoteControlObserver() {

    }

    /**
     *  @hide
     *  Reload audio settings. This method is called by Settings backup
+303 −23

File changed.

Preview size limit exceeded, changes collapsed.

+9 −1
Original line number Diff line number Diff line
@@ -18,6 +18,9 @@ package android.media;

import android.content.ComponentName;
import android.media.IAudioFocusDispatcher;
import android.media.IRemoteControlClient;
import android.net.Uri;
import android.os.Bundle;

/**
 * {@hide}
@@ -77,7 +80,7 @@ interface IAudioService {
    boolean isBluetoothScoOn();

    int requestAudioFocus(int mainStreamType, int durationHint, IBinder cb, IAudioFocusDispatcher l,
            String clientId);
            String clientId, String callingPackageName);

    int abandonAudioFocus(IAudioFocusDispatcher l, String clientId);
    
@@ -87,6 +90,11 @@ interface IAudioService {

    void unregisterMediaButtonEventReceiver(in ComponentName eventReceiver);

    void registerRemoteControlClient(in ComponentName eventReceiver,
           in IRemoteControlClient rcClient, in String callingPackageName);

    void refreshRemoteControlDisplay(in ComponentName eventReceiver);

    void startBluetoothSco(IBinder cb);

    void stopBluetoothSco(IBinder cb);
+76 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.media;

import android.graphics.Bitmap;

/**
 * {@hide}
 */
interface IRemoteControlClient
{
    /**
     * Called by a remote control to retrieve a String of information to display.
     * @param field the identifier for a metadata field to retrieve. Valid values are
     *      {@link android.media.MediaMetadataRetriever#METADATA_KEY_ALBUM},
     *      {@link android.media.MediaMetadataRetriever#METADATA_KEY_ALBUMARTIST},
     *      {@link android.media.MediaMetadataRetriever#METADATA_KEY_TITLE},
     *      {@link android.media.MediaMetadataRetriever#METADATA_KEY_ARTIST},
     *      {@link android.media.MediaMetadataRetriever#METADATA_KEY_AUTHOR},
     *      {@link android.media.MediaMetadataRetriever#METADATA_KEY_CD_TRACK_NUMBER},
     *      {@link android.media.MediaMetadataRetriever#METADATA_KEY_COMPILATION},
     *      {@link android.media.MediaMetadataRetriever#METADATA_KEY_COMPOSER},
     *      {@link android.media.MediaMetadataRetriever#METADATA_KEY_DATE},
     *      {@link android.media.MediaMetadataRetriever#METADATA_KEY_DISC_NUMBER},
     *      {@link android.media.MediaMetadataRetriever#METADATA_KEY_DURATION},
     *      {@link android.media.MediaMetadataRetriever#METADATA_KEY_GENRE},
     *      {@link android.media.MediaMetadataRetriever#METADATA_KEY_TITLE},
     *      {@link android.media.MediaMetadataRetriever#METADATA_KEY_WRITER},
     *      {@link android.media.MediaMetadataRetriever#METADATA_KEY_YEAR}.
     * @return null if the given field is not supported, or the String matching the metadata field.
     */
    String getMetadataString(int field);

    /**
     * Returns the current playback state.
     * @return one of the following values:
     *       {@link android.media.AudioManager.RemoteControl#PLAYSTATE_STOPPED},
     *       {@link android.media.AudioManager.RemoteControl#PLAYSTATE_PAUSED},
     *       {@link android.media.AudioManager.RemoteControl#PLAYSTATE_PLAYING},
     *       {@link android.media.AudioManager.RemoteControl#PLAYSTATE_FAST_FORWARDING},
     *       {@link android.media.AudioManager.RemoteControl#PLAYSTATE_REWINDING},
     *       {@link android.media.AudioManager.RemoteControl#PLAYSTATE_SKIPPING_FORWARDS},
     *       {@link android.media.AudioManager.RemoteControl#PLAYSTATE_SKIPPING_BACKWARDS},
     *       {@link android.media.AudioManager.RemoteControl#PLAYSTATE_BUFFERING}.
     */
    int getPlaybackState();

    /**
     * Returns the flags for the media transport control buttons this client supports.
     * @see {@link android.media.AudioManager.RemoteControl#FLAG_KEY_MEDIA_PREVIOUS},
     *      {@link android.media.AudioManager.RemoteControl#FLAG_KEY_MEDIA_REWIND},
     *      {@link android.media.AudioManager.RemoteControl#FLAG_KEY_MEDIA_PLAY},
     *      {@link android.media.AudioManager.RemoteControl#FLAG_KEY_MEDIA_PLAY_PAUSE},
     *      {@link android.media.AudioManager.RemoteControl#FLAG_KEY_MEDIA_PAUSE},
     *      {@link android.media.AudioManager.RemoteControl#FLAG_KEY_MEDIA_STOP},
     *      {@link android.media.AudioManager.RemoteControl#FLAG_KEY_MEDIA_FAST_FORWARD},
     *      {@link android.media.AudioManager.RemoteControl#FLAG_KEY_MEDIA_NEXT}
     */
    int getTransportControlFlags();

    Bitmap getAlbumArt(int width, int height);
}