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

Commit f82d14a2 authored by RoboErik's avatar RoboErik Committed by Android Git Automerger
Browse files

am 80380f82: Switch Session APIs over to AudioAttributes

* commit '80380f827a2147d436494b66193b7d59763de25b':
  Switch Session APIs over to AudioAttributes
parents 65130b70 9db9bf70
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -16596,7 +16596,7 @@ package android.media.session {
  }
  public static final class MediaController.VolumeInfo {
    method public int getAudioStream();
    method public android.media.AudioAttributes getAudioAttributes();
    method public int getCurrentVolume();
    method public int getMaxVolume();
    method public int getVolumeControl();
@@ -16621,7 +16621,7 @@ package android.media.session {
    method public void setMediaRouter(android.media.routing.MediaRouter);
    method public void setMetadata(android.media.MediaMetadata);
    method public void setPlaybackState(android.media.session.PlaybackState);
    method public void setPlaybackToLocal(int);
    method public void setPlaybackToLocal(android.media.AudioAttributes);
    method public void setPlaybackToRemote(android.media.VolumeProvider);
    field public static final int FLAG_HANDLES_MEDIA_BUTTONS = 1; // 0x1
    field public static final int FLAG_HANDLES_TRANSPORT_CONTROLS = 2; // 0x2
+18 −0
Original line number Diff line number Diff line
/* Copyright 2014, 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;

parcelable AudioAttributes;
+3 −1
Original line number Diff line number Diff line
@@ -2220,7 +2220,9 @@ public class MediaRouter {
                }
            } else {
                // We only know how to handle local and remote, fall back to local if not remote.
                session.setPlaybackToLocal(mPlaybackStream);
                AudioAttributes.Builder bob = new AudioAttributes.Builder();
                bob.setLegacyStreamType(mPlaybackStream);
                session.setPlaybackToLocal(bob.build());
                mSvp = null;
            }
        }
+3 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package android.media.session;

import android.content.ComponentName;
import android.media.AudioAttributes;
import android.media.MediaMetadata;
import android.media.routing.IMediaRouter;
import android.media.session.ISessionController;
@@ -42,6 +43,7 @@ interface ISession {
    void setRatingType(int type);

    // These commands relate to volume handling
    void configureVolumeHandling(int type, int arg1, int arg2);
    void setPlaybackToLocal(in AudioAttributes attributes);
    void setPlaybackToRemote(int control, int max);
    void setCurrentVolume(int currentVolume);
}
+17 −15
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.media.session;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.MediaMetadata;
import android.media.Rating;
@@ -206,7 +207,7 @@ public final class MediaController {
    public @Nullable VolumeInfo getVolumeInfo() {
        try {
            ParcelableVolumeInfo result = mSessionBinder.getVolumeAttributes();
            return new VolumeInfo(result.volumeType, result.audioStream, result.controlType,
            return new VolumeInfo(result.volumeType, result.audioAttrs, result.controlType,
                    result.maxVolume, result.currentVolume);

        } catch (RemoteException e) {
@@ -216,8 +217,8 @@ public final class MediaController {
    }

    /**
     * Set the volume of the stream or output this session is playing on. The
     * command will be ignored if it does not support
     * Set the volume of the output this session is playing on. The command will
     * be ignored if it does not support
     * {@link VolumeProvider#VOLUME_CONTROL_ABSOLUTE}. The flags in
     * {@link AudioManager} may be used to affect the handling.
     *
@@ -234,8 +235,8 @@ public final class MediaController {
    }

    /**
     * Adjust the volume of the stream or output this session is playing on. The
     * direction must be one of {@link AudioManager#ADJUST_LOWER},
     * Adjust the volume of the output this session is playing on. The direction
     * must be one of {@link AudioManager#ADJUST_LOWER},
     * {@link AudioManager#ADJUST_RAISE}, or {@link AudioManager#ADJUST_SAME}.
     * The command will be ignored if the session does not support
     * {@link VolumeProvider#VOLUME_CONTROL_RELATIVE} or
@@ -570,17 +571,17 @@ public final class MediaController {
     */
    public static final class VolumeInfo {
        private final int mVolumeType;
        private final int mAudioStream;
        private final int mVolumeControl;
        private final int mMaxVolume;
        private final int mCurrentVolume;
        private final AudioAttributes mAudioAttrs;

        /**
         * @hide
         */
        public VolumeInfo(int type, int stream, int control, int max, int current) {
        public VolumeInfo(int type, AudioAttributes attrs, int control, int max, int current) {
            mVolumeType = type;
            mAudioStream = stream;
            mAudioAttrs = attrs;
            mVolumeControl = control;
            mMaxVolume = max;
            mCurrentVolume = current;
@@ -600,14 +601,15 @@ public final class MediaController {
        }

        /**
         * Get the stream this is currently controlling volume on. When the volume
         * type is {@link MediaSession#PLAYBACK_TYPE_REMOTE} this value does not
         * have meaning and should be ignored.
         * Get the audio attributes for this session. The attributes will affect
         * volume handling for the session. When the volume type is
         * {@link MediaSession#PLAYBACK_TYPE_REMOTE} these may be ignored by the
         * remote volume handler.
         *
         * @return The stream this session is playing on.
         * @return The attributes for this session.
         */
        public int getAudioStream() {
            return mAudioStream;
        public AudioAttributes getAudioAttributes() {
            return mAudioAttrs;
        }

        /**
@@ -679,7 +681,7 @@ public final class MediaController {
        public void onVolumeInfoChanged(ParcelableVolumeInfo pvi) {
            MediaController controller = mController.get();
            if (controller != null) {
                VolumeInfo info = new VolumeInfo(pvi.volumeType, pvi.audioStream, pvi.controlType,
                VolumeInfo info = new VolumeInfo(pvi.volumeType, pvi.audioAttrs, pvi.controlType,
                        pvi.maxVolume, pvi.currentVolume);
                controller.postMessage(MSG_UPDATE_VOLUME, info, null);
            }
Loading