diff options
author | 2024-10-01 19:32:25 +0000 | |
---|---|---|
committer | 2024-10-02 10:48:22 +0000 | |
commit | c026d1b30085b4cbf430d41801d4eb8a30631214 (patch) | |
tree | 8cc434ff37a8e5185f9fd9c5a437292575987597 | |
parent | 08946f9d05a94832ed03adcff9473b5e72c27b34 (diff) |
Clean up group volume adjustment disablement flag
Test: m && presubmit
Flag: EXEMPT Dead code removal
Bug: 334877803
Change-Id: Ica5c0e8f9b5efa2c11216c0582a0c8145f7b5f1a
7 files changed, 19 insertions, 169 deletions
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 5c0dca2104af..71ae22f6e100 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -2309,10 +2309,6 @@ spatial audio is enabled for a newly connected audio device --> <bool name="config_spatial_audio_head_tracking_enabled_default">false</bool> - <!-- Flag indicating whether platform level volume adjustments are enabled for remote sessions - on grouped devices. --> - <bool name="config_volumeAdjustmentForRemoteGroupSessions">true</bool> - <!-- Flag indicating current media Output Switcher version. --> <integer name="config_mediaOutputSwitchDialogVersion">1</integer> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 807df1be7fb5..0ccef9123e10 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -5102,8 +5102,6 @@ <java-symbol type="dimen" name="config_wallpaperDimAmount" /> - <java-symbol type="bool" name="config_volumeAdjustmentForRemoteGroupSessions" /> - <java-symbol type="integer" name="config_mediaOutputSwitchDialogVersion" /> <!-- List of shared library packages that should be loaded by the classloader after the diff --git a/media/java/android/media/RoutingSessionInfo.java b/media/java/android/media/RoutingSessionInfo.java index 9899e4ec388d..83a4dd5a682a 100644 --- a/media/java/android/media/RoutingSessionInfo.java +++ b/media/java/android/media/RoutingSessionInfo.java @@ -22,7 +22,6 @@ import android.annotation.FlaggedApi; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; -import android.content.res.Resources; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; @@ -57,8 +56,6 @@ public final class RoutingSessionInfo implements Parcelable { } }; - private static final String TAG = "RoutingSessionInfo"; - private static final String KEY_GROUP_ROUTE = "androidx.mediarouter.media.KEY_GROUP_ROUTE"; private static final String KEY_VOLUME_HANDLING = "volumeHandling"; @@ -142,15 +139,7 @@ public final class RoutingSessionInfo implements Parcelable { mVolume = builder.mVolume; mIsSystemSession = builder.mIsSystemSession; - - boolean volumeAdjustmentForRemoteGroupSessions = Resources.getSystem().getBoolean( - com.android.internal.R.bool.config_volumeAdjustmentForRemoteGroupSessions); - mVolumeHandling = - defineVolumeHandling( - mIsSystemSession, - builder.mVolumeHandling, - mSelectedRoutes, - volumeAdjustmentForRemoteGroupSessions); + mVolumeHandling = builder.mVolumeHandling; mControlHints = updateVolumeHandlingInHints(builder.mControlHints, mVolumeHandling); mTransferReason = builder.mTransferReason; @@ -207,20 +196,6 @@ public final class RoutingSessionInfo implements Parcelable { return controlHints; } - @MediaRoute2Info.PlaybackVolume - private static int defineVolumeHandling( - boolean isSystemSession, - @MediaRoute2Info.PlaybackVolume int volumeHandling, - List<String> selectedRoutes, - boolean volumeAdjustmentForRemoteGroupSessions) { - if (!isSystemSession - && !volumeAdjustmentForRemoteGroupSessions - && selectedRoutes.size() > 1) { - return MediaRoute2Info.PLAYBACK_VOLUME_FIXED; - } - return volumeHandling; - } - @NonNull private static String ensureString(@Nullable String str) { return str != null ? str : ""; diff --git a/media/tests/MediaRouter/src/com/android/mediaroutertest/RoutingSessionInfoTest.java b/media/tests/MediaRouter/src/com/android/mediaroutertest/RoutingSessionInfoTest.java index 3955ff068d94..5f5058d79545 100644 --- a/media/tests/MediaRouter/src/com/android/mediaroutertest/RoutingSessionInfoTest.java +++ b/media/tests/MediaRouter/src/com/android/mediaroutertest/RoutingSessionInfoTest.java @@ -18,8 +18,6 @@ package com.android.mediaroutertest; import static com.google.common.truth.Truth.assertThat; -import android.content.res.Resources; -import android.media.MediaRoute2Info; import android.media.RoutingSessionInfo; import androidx.test.ext.junit.runners.AndroidJUnit4; @@ -95,24 +93,4 @@ public class RoutingSessionInfoTest { assertThat(sessionInfoWithProviderId2.getTransferableRoutes()) .isEqualTo(sessionInfoWithProviderId.getTransferableRoutes()); } - - @Test - public void testGetVolumeHandlingGroupSession() { - RoutingSessionInfo sessionInfo = new RoutingSessionInfo.Builder( - TEST_ID, TEST_CLIENT_PACKAGE_NAME) - .setName(TEST_NAME) - .addSelectedRoute(TEST_ROUTE_ID_0) - .addSelectedRoute(TEST_ROUTE_ID_2) - .setVolumeHandling(MediaRoute2Info.PLAYBACK_VOLUME_VARIABLE) - .build(); - - boolean volumeAdjustmentForRemoteGroupSessions = Resources.getSystem().getBoolean( - com.android.internal.R.bool.config_volumeAdjustmentForRemoteGroupSessions); - - int expectedResult = volumeAdjustmentForRemoteGroupSessions - ? MediaRoute2Info.PLAYBACK_VOLUME_VARIABLE : - MediaRoute2Info.PLAYBACK_VOLUME_FIXED; - - assertThat(sessionInfo.getVolumeHandling()).isEqualTo(expectedResult); - } } diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogControllerImpl.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogControllerImpl.java index 079c72f049a6..1f92bc1df9c8 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogControllerImpl.java @@ -37,11 +37,8 @@ import android.media.AudioManager; import android.media.AudioSystem; import android.media.IAudioService; import android.media.IVolumeController; -import android.media.MediaRoute2Info; import android.media.MediaRouter2Manager; -import android.media.RoutingSessionInfo; import android.media.VolumePolicy; -import android.media.session.MediaController; import android.media.session.MediaController.PlaybackInfo; import android.media.session.MediaSession.Token; import android.net.Uri; @@ -88,7 +85,6 @@ import dalvik.annotation.optimization.NeverCompile; import java.io.PrintWriter; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; @@ -217,7 +213,7 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa VolumeDialogControllerImpl.class.getSimpleName()); mWorker = new W(mWorkerLooper); mRouter2Manager = MediaRouter2Manager.getInstance(mContext); - mMediaSessionsCallbacksW = new MediaSessionsCallbacks(mContext); + mMediaSessionsCallbacksW = new MediaSessionsCallbacks(); mMediaSessions = createMediaSessions(mContext, mWorkerLooper, mMediaSessionsCallbacksW); mAudioSharingInteractor = audioSharingInteractor; mJavaAdapter = javaAdapter; @@ -1360,16 +1356,9 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa private final HashMap<Token, Integer> mRemoteStreams = new HashMap<>(); private int mNextStream = DYNAMIC_STREAM_REMOTE_START_INDEX; - private final boolean mVolumeAdjustmentForRemoteGroupSessions; - - public MediaSessionsCallbacks(Context context) { - mVolumeAdjustmentForRemoteGroupSessions = context.getResources().getBoolean( - com.android.internal.R.bool.config_volumeAdjustmentForRemoteGroupSessions); - } @Override public void onRemoteUpdate(Token token, String name, PlaybackInfo pi) { - if (showForSession(token)) { addStream(token, "onRemoteUpdate"); int stream = 0; @@ -1396,12 +1385,10 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa Log.d(TAG, "onRemoteUpdate: " + name + ": " + ss.level + " of " + ss.levelMax); mCallbacks.onStateChanged(mState); } - } } @Override public void onRemoteVolumeChanged(Token token, int flags) { - if (showForSession(token)) { addStream(token, "onRemoteVolumeChanged"); int stream = 0; synchronized (mRemoteStreams) { @@ -1420,27 +1407,27 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa if (showUI) { onShowRequestedW(Events.SHOW_REASON_REMOTE_VOLUME_CHANGED); } - } } @Override public void onRemoteRemoved(Token token) { - if (showForSession(token)) { - int stream = 0; - synchronized (mRemoteStreams) { - if (!mRemoteStreams.containsKey(token)) { - Log.d(TAG, "onRemoteRemoved: stream doesn't exist, " - + "aborting remote removed for token:" + token.toString()); - return; - } - stream = mRemoteStreams.get(token); - } - mState.states.remove(stream); - if (mState.activeStream == stream) { - updateActiveStreamW(-1); + int stream; + synchronized (mRemoteStreams) { + if (!mRemoteStreams.containsKey(token)) { + Log.d( + TAG, + "onRemoteRemoved: stream doesn't exist, " + + "aborting remote removed for token:" + + token.toString()); + return; } - mCallbacks.onStateChanged(mState); + stream = mRemoteStreams.get(token); + } + mState.states.remove(stream); + if (mState.activeStream == stream) { + updateActiveStreamW(-1); } + mCallbacks.onStateChanged(mState); } public void setStreamVolume(int stream, int level) { @@ -1449,39 +1436,7 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa Log.w(TAG, "setStreamVolume: No token found for stream: " + stream); return; } - if (showForSession(token)) { - mMediaSessions.setVolume(token, level); - } - } - - private boolean showForSession(Token token) { - if (mVolumeAdjustmentForRemoteGroupSessions) { - if (DEBUG) { - Log.d(TAG, "Volume adjustment for remote group sessions allowed," - + " showForSession: true"); - } - return true; - } - MediaController ctr = new MediaController(mContext, token); - String packageName = ctr.getPackageName(); - List<RoutingSessionInfo> sessions = - mRouter2Manager.getRoutingSessions(packageName); - if (DEBUG) { - Log.d(TAG, "Found " + sessions.size() + " routing sessions for package name " - + packageName); - } - for (RoutingSessionInfo session : sessions) { - if (DEBUG) { - Log.d(TAG, "Found routingSessionInfo: " + session); - } - if (!session.isSystemSession() - && session.getVolumeHandling() != MediaRoute2Info.PLAYBACK_VOLUME_FIXED) { - return true; - } - } - - Log.d(TAG, "No routing session for " + packageName); - return false; + mMediaSessions.setVolume(token, level); } private Token findToken(int stream) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogControllerImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogControllerImplTest.java index f62beeb16ae5..beba0f0c6286 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogControllerImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogControllerImplTest.java @@ -133,10 +133,6 @@ public class VolumeDialogControllerImplTest extends SysuiTestCase { when(mRingerModeInternalLiveData.getValue()).thenReturn(-1); when(mUserTracker.getUserId()).thenReturn(ActivityManager.getCurrentUser()); when(mUserTracker.getUserContext()).thenReturn(mContext); - // Enable group volume adjustments - mContext.getOrCreateTestableResources().addOverride( - com.android.internal.R.bool.config_volumeAdjustmentForRemoteGroupSessions, - true); mCallback = mock(VolumeDialogControllerImpl.C.class); mThreadFactory.setLooper(TestableLooper.get(this).getLooper()); diff --git a/services/core/java/com/android/server/media/MediaSessionRecord.java b/services/core/java/com/android/server/media/MediaSessionRecord.java index 0a9109b3e98c..d752429e64f7 100644 --- a/services/core/java/com/android/server/media/MediaSessionRecord.java +++ b/services/core/java/com/android/server/media/MediaSessionRecord.java @@ -16,7 +16,6 @@ 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; @@ -48,9 +47,7 @@ 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; @@ -186,7 +183,6 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde private final MediaSessionService mService; private final UriGrantsManagerInternal mUgmInternal; private final Context mContext; - private final boolean mVolumeAdjustmentForRemoteGroupSessions; private final ForegroundServiceDelegationOptions mForegroundServiceDelegationOptions; @@ -311,8 +307,6 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde mAudioAttrs = DEFAULT_ATTRIBUTES; mPolicies = policies; mUgmInternal = LocalServices.getService(UriGrantsManagerInternal.class); - mVolumeAdjustmentForRemoteGroupSessions = mContext.getResources().getBoolean( - com.android.internal.R.bool.config_volumeAdjustmentForRemoteGroupSessions); mForegroundServiceDelegationOptions = createForegroundServiceDelegationOptions(); @@ -659,49 +653,7 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde } return false; } - if (mVolumeAdjustmentForRemoteGroupSessions) { - if (DEBUG) { - Slog.d( - TAG, - "Volume adjustment for remote group sessions allowed so MediaSessionRecord" - + " can handle volume key"); - } - return true; - } - // See b/228021646 for details. - MediaRouter2Manager mRouter2Manager = MediaRouter2Manager.getInstance(mContext); - List<RoutingSessionInfo> sessions = mRouter2Manager.getRoutingSessions(mPackageName); - boolean foundNonSystemSession = false; - boolean remoteSessionAllowVolumeAdjustment = true; - if (DEBUG) { - Slog.d( - TAG, - "Found " - + sessions.size() - + " routing sessions for package name " - + mPackageName); - } - for (RoutingSessionInfo session : sessions) { - if (DEBUG) { - Slog.d(TAG, "Found routingSessionInfo: " + session); - } - if (!session.isSystemSession()) { - foundNonSystemSession = true; - if (session.getVolumeHandling() == PLAYBACK_VOLUME_FIXED) { - remoteSessionAllowVolumeAdjustment = false; - } - } - } - if (!foundNonSystemSession) { - if (DEBUG) { - Slog.d( - TAG, - "Package " + mPackageName - + " has a remote media session but no associated routing session"); - } - } - - return foundNonSystemSession && remoteSessionAllowVolumeAdjustment; + return true; } @Override |