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

Commit 6526347a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Check if stream exists on volume changed." into oc-dr1-dev

parents 6628e48a b5a2781d
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -913,11 +913,7 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa

        @Override
        public void onRemoteUpdate(Token token, String name, PlaybackInfo pi) {
            if (!mRemoteStreams.containsKey(token)) {
                mRemoteStreams.put(token, mNextStream);
                if (D.BUG) Log.d(TAG, "onRemoteUpdate: " + name + " is stream " + mNextStream);
                mNextStream++;
            }
            addStream(token, "onRemoteUpdate");
            final int stream = mRemoteStreams.get(token);
            boolean changed = mState.states.indexOfKey(stream) < 0;
            final StreamState ss = streamStateW(stream);
@@ -942,6 +938,7 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa

        @Override
        public void onRemoteVolumeChanged(Token token, int flags) {
            addStream(token, "onRemoteVolumeChanged");
            final int stream = mRemoteStreams.get(token);
            final boolean showUI = shouldShowUI(flags);
            boolean changed = updateActiveStreamW(stream);
@@ -958,6 +955,11 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa

        @Override
        public void onRemoteRemoved(Token token) {
            if (!mRemoteStreams.containsKey(token)) {
                if (D.BUG) Log.d(TAG, "onRemoteRemoved: stream doesn't exist, "
                        + "aborting remote removed for token:" +  token.toString());
                return;
            }
            final int stream = mRemoteStreams.get(token);
            mState.states.remove(stream);
            if (mState.activeStream == stream) {
@@ -983,6 +985,15 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
            }
            return null;
        }

        private void addStream(Token token, String triggeringMethod) {
            if (!mRemoteStreams.containsKey(token)) {
                mRemoteStreams.put(token, mNextStream);
                if (D.BUG) Log.d(TAG, triggeringMethod + ": added stream " +  mNextStream
                        + " from token + "+ token.toString());
                mNextStream++;
            }
        }
    }

    public interface UserActivityListener {