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

Commit 19c9518f authored by RoboErik's avatar RoboErik
Browse files

b/15729204 Pipe sessions through to VolumePanel

When remote volume is changed via volume buttons we need to notify
the system UI so it can show the slider. This also passes it the
controller to use so adjustments to the slider are sent back to
the correct session.

Change-Id: If5847bcd5db16c56e0e9904b88c94e5b28954c41
parent 0b16d7d8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -306,6 +306,7 @@ LOCAL_SRC_FILES += \
	media/java/android/media/IRemoteControlDisplay.aidl \
	media/java/android/media/IRemoteDisplayCallback.aidl \
	media/java/android/media/IRemoteDisplayProvider.aidl \
	media/java/android/media/IRemoteVolumeController.aidl \
	media/java/android/media/IRemoteVolumeObserver.aidl \
	media/java/android/media/IRingtonePlayer.aidl \
	media/java/android/media/IVolumeController.aidl \
+5 −2
Original line number Diff line number Diff line
@@ -15751,6 +15751,7 @@ package android.media.session {
  public final class MediaController {
    method public void addCallback(android.media.session.MediaController.Callback);
    method public void addCallback(android.media.session.MediaController.Callback, android.os.Handler);
    method public void adjustVolumeBy(int, int);
    method public boolean dispatchMediaButtonEvent(android.view.KeyEvent);
    method public static android.media.session.MediaController fromToken(android.media.session.MediaSessionToken);
    method public android.media.MediaMetadata getMetadata();
@@ -15760,6 +15761,7 @@ package android.media.session {
    method public android.media.session.MediaController.VolumeInfo getVolumeInfo();
    method public void removeCallback(android.media.session.MediaController.Callback);
    method public void sendControlCommand(java.lang.String, android.os.Bundle, android.os.ResultReceiver);
    method public void setVolumeTo(int, int);
  }
  public static abstract class MediaController.Callback {
@@ -15767,6 +15769,7 @@ package android.media.session {
    method public void onMetadataChanged(android.media.MediaMetadata);
    method public void onPlaybackStateChanged(android.media.session.PlaybackState);
    method public void onSessionEvent(java.lang.String, android.os.Bundle);
    method public void onVolumeInfoChanged(android.media.session.MediaController.VolumeInfo);
  }
  public final class MediaController.TransportControls {
@@ -15809,8 +15812,8 @@ package android.media.session {
    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
    field public static final int VOLUME_TYPE_LOCAL = 1; // 0x1
    field public static final int VOLUME_TYPE_REMOTE = 2; // 0x2
    field public static final int PLAYBACK_TYPE_LOCAL = 1; // 0x1
    field public static final int PLAYBACK_TYPE_REMOTE = 2; // 0x2
  }
  public static abstract class MediaSession.Callback {
+0 −32
Original line number Diff line number Diff line
@@ -2807,38 +2807,6 @@ public class AudioManager {
        }
    }

    /**
     * Only useful for volume controllers.
     * @hide
     */
    public int getRemoteStreamVolume() {
        // TODO STOPSHIP switch callers to use media sessions instead
        Log.e(TAG, "Need to implement new Remote Volume!");
        return 0;
    }

    /**
     * Only useful for volume controllers.
     * @hide
     */
    public int getRemoteStreamMaxVolume() {
        // TODO STOPSHIP switch callers to use media sessions instead
        Log.e(TAG, "Need to implement new Remote Volume!");
        return 0;
    }

    /**
     * Only useful for volume controllers.
     * @hide
     */
    public void setRemoteStreamVolume(int index) {
        try {
            getService().setRemoteStreamVolume(index);
        } catch (RemoteException e) {
            Log.w(TAG, "Error setting remote stream volume", e);
        }
    }

    /**
     * Only useful for volume controllers.
     * @hide
+2 −4
Original line number Diff line number Diff line
@@ -849,10 +849,8 @@ public class AudioService extends IAudioService.Stub {
        }

        if (streamType == STREAM_REMOTE_MUSIC) {
            // don't play sounds for remote
            flags &= ~(AudioManager.FLAG_PLAY_SOUND|AudioManager.FLAG_FIXED_VOLUME);
            //if (DEBUG_VOL) Log.i(TAG, "Need to adjust remote volume: calling adjustRemoteVolume()");
            mMediaFocusControl.adjustRemoteVolume(AudioSystem.STREAM_MUSIC, direction, flags);
            // TODO bounce it to MediaSessionService to find an appropriate
            // session
        } else {
            adjustStreamVolume(streamType, direction, flags, callingPackage);
        }
+32 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 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;

import android.media.session.ISessionController;

/**
 * AIDL for the MediaSessionService to report interesting events on remote playback
 * to a volume control dialog. See also IVolumeController for the AudioService half.
 * TODO add in better support for multiple remote sessions.
 * @hide
 */
oneway interface IRemoteVolumeController {
    void remoteVolumeChanged(ISessionController session, int flags);
    // sets the default session to use with the slider, replaces remoteSliderVisibility
    // on IVolumeController
    void updateRemoteController(ISessionController session);
}
Loading