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

Commit 9db9bf70 authored by RoboErik's avatar RoboErik Committed by Erik Pasternak
Browse files

Switch Session APIs over to AudioAttributes

The session apis were using audioStream in several places. This
updates them to use AudioAttributes instead.

bug:16403289
Change-Id: Ic4da9ca5fbea2536e80c71503bd9a9bf7f346997
parent 4bd39ec4
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -16596,7 +16596,7 @@ package android.media.session {
  }
  }
  public static final class MediaController.VolumeInfo {
  public static final class MediaController.VolumeInfo {
    method public int getAudioStream();
    method public android.media.AudioAttributes getAudioAttributes();
    method public int getCurrentVolume();
    method public int getCurrentVolume();
    method public int getMaxVolume();
    method public int getMaxVolume();
    method public int getVolumeControl();
    method public int getVolumeControl();
@@ -16621,7 +16621,7 @@ package android.media.session {
    method public void setMediaRouter(android.media.routing.MediaRouter);
    method public void setMediaRouter(android.media.routing.MediaRouter);
    method public void setMetadata(android.media.MediaMetadata);
    method public void setMetadata(android.media.MediaMetadata);
    method public void setPlaybackState(android.media.session.PlaybackState);
    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);
    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_MEDIA_BUTTONS = 1; // 0x1
    field public static final int FLAG_HANDLES_TRANSPORT_CONTROLS = 2; // 0x2
    field public static final int FLAG_HANDLES_TRANSPORT_CONTROLS = 2; // 0x2
+18 −0
Original line number Original line 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 Original line Diff line number Diff line
@@ -2220,7 +2220,9 @@ public class MediaRouter {
                }
                }
            } else {
            } else {
                // We only know how to handle local and remote, fall back to local if not remote.
                // 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;
                mSvp = null;
            }
            }
        }
        }
+3 −1
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@
package android.media.session;
package android.media.session;


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


    // These commands relate to volume handling
    // 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);
    void setCurrentVolume(int currentVolume);
}
}
+17 −15
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package android.media.session;


import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.AudioManager;
import android.media.MediaMetadata;
import android.media.MediaMetadata;
import android.media.Rating;
import android.media.Rating;
@@ -206,7 +207,7 @@ public final class MediaController {
    public @Nullable VolumeInfo getVolumeInfo() {
    public @Nullable VolumeInfo getVolumeInfo() {
        try {
        try {
            ParcelableVolumeInfo result = mSessionBinder.getVolumeAttributes();
            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);
                    result.maxVolume, result.currentVolume);


        } catch (RemoteException e) {
        } 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
     * Set the volume of the output this session is playing on. The command will
     * command will be ignored if it does not support
     * be ignored if it does not support
     * {@link VolumeProvider#VOLUME_CONTROL_ABSOLUTE}. The flags in
     * {@link VolumeProvider#VOLUME_CONTROL_ABSOLUTE}. The flags in
     * {@link AudioManager} may be used to affect the handling.
     * {@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
     * Adjust the volume of the output this session is playing on. The direction
     * direction must be one of {@link AudioManager#ADJUST_LOWER},
     * must be one of {@link AudioManager#ADJUST_LOWER},
     * {@link AudioManager#ADJUST_RAISE}, or {@link AudioManager#ADJUST_SAME}.
     * {@link AudioManager#ADJUST_RAISE}, or {@link AudioManager#ADJUST_SAME}.
     * The command will be ignored if the session does not support
     * The command will be ignored if the session does not support
     * {@link VolumeProvider#VOLUME_CONTROL_RELATIVE} or
     * {@link VolumeProvider#VOLUME_CONTROL_RELATIVE} or
@@ -570,17 +571,17 @@ public final class MediaController {
     */
     */
    public static final class VolumeInfo {
    public static final class VolumeInfo {
        private final int mVolumeType;
        private final int mVolumeType;
        private final int mAudioStream;
        private final int mVolumeControl;
        private final int mVolumeControl;
        private final int mMaxVolume;
        private final int mMaxVolume;
        private final int mCurrentVolume;
        private final int mCurrentVolume;
        private final AudioAttributes mAudioAttrs;


        /**
        /**
         * @hide
         * @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;
            mVolumeType = type;
            mAudioStream = stream;
            mAudioAttrs = attrs;
            mVolumeControl = control;
            mVolumeControl = control;
            mMaxVolume = max;
            mMaxVolume = max;
            mCurrentVolume = current;
            mCurrentVolume = current;
@@ -600,14 +601,15 @@ public final class MediaController {
        }
        }


        /**
        /**
         * Get the stream this is currently controlling volume on. When the volume
         * Get the audio attributes for this session. The attributes will affect
         * type is {@link MediaSession#PLAYBACK_TYPE_REMOTE} this value does not
         * volume handling for the session. When the volume type is
         * have meaning and should be ignored.
         * {@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() {
        public AudioAttributes getAudioAttributes() {
            return mAudioStream;
            return mAudioAttrs;
        }
        }


        /**
        /**
@@ -679,7 +681,7 @@ public final class MediaController {
        public void onVolumeInfoChanged(ParcelableVolumeInfo pvi) {
        public void onVolumeInfoChanged(ParcelableVolumeInfo pvi) {
            MediaController controller = mController.get();
            MediaController controller = mController.get();
            if (controller != null) {
            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);
                        pvi.maxVolume, pvi.currentVolume);
                controller.postMessage(MSG_UPDATE_VOLUME, info, null);
                controller.postMessage(MSG_UPDATE_VOLUME, info, null);
            }
            }
Loading