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

Commit 93ac0dad authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Add flag for remote streams

Test: manual, with remote stream active
Bug: 191356254
Change-Id: I59947b8d04ba717eac0e5a501965de97d200cc9c
parent 3d44d6ed
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1890,6 +1890,9 @@
         STREAM_MUSIC as if it's on TV platform. -->
    <bool name="config_single_volume">false</bool>

    <!-- Flag indicating whether the volume panel should show remote sessions. -->
    <bool name="config_volumeShowRemoteSessions">true</bool>

    <!-- Flag indicating that an outbound call must have a call capable phone account
         that has declared it can process the call's handle. -->
    <bool name="config_requireCallCapableAccountForHandle">false</bool>
+2 −0
Original line number Diff line number Diff line
@@ -4400,4 +4400,6 @@
  <java-symbol type="bool" name="config_assistTouchGestureEnabledDefault" />

  <java-symbol type="dimen" name="config_wallpaperDimAmount" />

  <java-symbol type="bool" name="config_volumeShowRemoteSessions" />
</resources>
+74 −58
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
    private final MediaSessions mMediaSessions;
    protected C mCallbacks = new C();
    private final State mState = new State();
    protected final MediaSessionsCallbacks mMediaSessionsCallbacksW = new MediaSessionsCallbacks();
    protected final MediaSessionsCallbacks mMediaSessionsCallbacksW;
    private final Optional<Vibrator> mVibrator;
    private final boolean mHasVibrator;
    private boolean mShowA11yStream;
@@ -179,6 +179,7 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
        mWorkerLooper = theadFactory.buildLooperOnNewThread(
                VolumeDialogControllerImpl.class.getSimpleName());
        mWorker = new W(mWorkerLooper);
        mMediaSessionsCallbacksW = new MediaSessionsCallbacks(mContext);
        mMediaSessions = createMediaSessions(mContext, mWorkerLooper, mMediaSessionsCallbacksW);
        mAudio = audioManager;
        mNoMan = notificationManager;
@@ -1148,16 +1149,24 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
        private final HashMap<Token, Integer> mRemoteStreams = new HashMap<>();

        private int mNextStream = DYNAMIC_STREAM_START_INDEX;
        private final boolean mShowRemoteSessions;

        public MediaSessionsCallbacks(Context context) {
            mShowRemoteSessions = context.getResources().getBoolean(
                    com.android.internal.R.bool.config_volumeShowRemoteSessions);
        }

        @Override
        public void onRemoteUpdate(Token token, String name, PlaybackInfo pi) {
            if (mShowRemoteSessions) {
                addStream(token, "onRemoteUpdate");

                int stream = 0;
                synchronized (mRemoteStreams) {
                    stream = mRemoteStreams.get(token);
                }
            Slog.d(TAG, "onRemoteUpdate: stream: " + stream + " volume: " + pi.getCurrentVolume());
                Slog.d(TAG,
                        "onRemoteUpdate: stream: " + stream + " volume: " + pi.getCurrentVolume());
                boolean changed = mState.states.indexOfKey(stream) < 0;
                final StreamState ss = streamStateW(stream);
                ss.dynamic = true;
@@ -1177,9 +1186,11 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
                    mCallbacks.onStateChanged(mState);
                }
            }
        }

        @Override
        public void onRemoteVolumeChanged(Token token, int flags) {
            if (mShowRemoteSessions) {
                addStream(token, "onRemoteVolumeChanged");
                int stream = 0;
                synchronized (mRemoteStreams) {
@@ -1199,9 +1210,11 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
                    mCallbacks.onShowRequested(Events.SHOW_REASON_REMOTE_VOLUME_CHANGED);
                }
            }
        }

        @Override
        public void onRemoteRemoved(Token token) {
            if (mShowRemoteSessions) {
                int stream = 0;
                synchronized (mRemoteStreams) {
                    if (!mRemoteStreams.containsKey(token)) {
@@ -1217,8 +1230,10 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
                }
                mCallbacks.onStateChanged(mState);
            }
        }

        public void setStreamVolume(int stream, int level) {
            if (mShowRemoteSessions) {
                final Token t = findToken(stream);
                if (t == null) {
                    Log.w(TAG, "setStreamVolume: No token found for stream: " + stream);
@@ -1226,6 +1241,7 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
                }
                mMediaSessions.setVolume(t, level);
            }
        }

        private Token findToken(int stream) {
            synchronized (mRemoteStreams) {