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

Commit e563ad0c authored by Bishoy Gendy's avatar Bishoy Gendy Committed by Automerger Merge Worker
Browse files

Merge "Fix volume slider not showing when casting in the background" into...

Merge "Fix volume slider not showing when casting in the background" into udc-dev am: f96e49ed am: 456d2dc8

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23726250



Change-Id: If238a76d52f54c8c8ae99d085283f560c61f4b18
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 6d0fc0de 456d2dc8
Loading
Loading
Loading
Loading
+30 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.media;

import static android.media.MediaRoute2Info.PLAYBACK_VOLUME_FIXED;
import static android.media.VolumeProvider.VOLUME_CONTROL_ABSOLUTE;
import static android.media.VolumeProvider.VOLUME_CONTROL_FIXED;
import static android.media.VolumeProvider.VOLUME_CONTROL_RELATIVE;
@@ -44,7 +45,9 @@ import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.AudioSystem;
import android.media.MediaMetadata;
import android.media.MediaRouter2Manager;
import android.media.Rating;
import android.media.RoutingSessionInfo;
import android.media.VolumeProvider;
import android.media.session.ISession;
import android.media.session.ISessionCallback;
@@ -510,7 +513,33 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR

    @Override
    public boolean canHandleVolumeKey() {
        return mVolumeControlType != VOLUME_CONTROL_FIXED;
        if (isPlaybackTypeLocal()) {
            return true;
        }
        if (mVolumeControlType == VOLUME_CONTROL_FIXED) {
            return false;
        }
        if (mVolumeAdjustmentForRemoteGroupSessions) {
            return true;
        }
        // See b/228021646 for details.
        MediaRouter2Manager mRouter2Manager = MediaRouter2Manager.getInstance(mContext);
        List<RoutingSessionInfo> sessions = mRouter2Manager.getRoutingSessions(mPackageName);
        boolean foundNonSystemSession = false;
        boolean remoteSessionAllowVolumeAdjustment = true;
        for (RoutingSessionInfo session : sessions) {
            if (!session.isSystemSession()) {
                foundNonSystemSession = true;
                if (session.getVolumeHandling() == PLAYBACK_VOLUME_FIXED) {
                    remoteSessionAllowVolumeAdjustment = false;
                }
            }
        }
        if (!foundNonSystemSession) {
            Log.d(TAG, "Package " + mPackageName
                    + " has a remote media session but no associated routing session");
        }
        return foundNonSystemSession && remoteSessionAllowVolumeAdjustment;
    }

    @Override