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

Commit defa4d7c authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Fix crash on dump()"

parents 08c51ea6 1833da45
Loading
Loading
Loading
Loading
+33 −17
Original line number Diff line number Diff line
@@ -243,8 +243,11 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
        pw.print("  mState: "); pw.println(mState.toString(4));
        pw.print("  mShowDndTile: "); pw.println(mShowDndTile);
        pw.print("  mHasVibrator: "); pw.println(mHasVibrator);
        pw.print("  mRemoteStreams: "); pw.println(mMediaSessionsCallbacksW.mRemoteStreams
        synchronized (mMediaSessionsCallbacksW.mRemoteStreams) {
            pw.print("  mRemoteStreams: ");
            pw.println(mMediaSessionsCallbacksW.mRemoteStreams
                    .values());
        }
        pw.print("  mShowA11yStream: "); pw.println(mShowA11yStream);
        pw.println();
        mMediaSessions.dump(pw);
@@ -1075,7 +1078,10 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
        @Override
        public void onRemoteUpdate(Token token, String name, PlaybackInfo pi) {
            addStream(token, "onRemoteUpdate");
            final int stream = mRemoteStreams.get(token);
            int stream = 0;
            synchronized (mRemoteStreams) {
                 stream = mRemoteStreams.get(token);
            }
            boolean changed = mState.states.indexOfKey(stream) < 0;
            final StreamState ss = streamStateW(stream);
            ss.dynamic = true;
@@ -1100,7 +1106,10 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
        @Override
        public void onRemoteVolumeChanged(Token token, int flags) {
            addStream(token, "onRemoteVolumeChanged");
            final int stream = mRemoteStreams.get(token);
            int stream = 0;
            synchronized (mRemoteStreams) {
                stream = mRemoteStreams.get(token);
            }
            final boolean showUI = shouldShowUI(flags);
            boolean changed = updateActiveStreamW(stream);
            if (showUI) {
@@ -1116,12 +1125,15 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa

        @Override
        public void onRemoteRemoved(Token token) {
            int stream = 0;
            synchronized (mRemoteStreams) {
                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);
                stream = mRemoteStreams.get(token);
            }
            mState.states.remove(stream);
            if (mState.activeStream == stream) {
                updateActiveStreamW(-1);
@@ -1139,15 +1151,18 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
        }

        private Token findToken(int stream) {
            synchronized (mRemoteStreams) {
                for (Map.Entry<Token, Integer> entry : mRemoteStreams.entrySet()) {
                    if (entry.getValue().equals(stream)) {
                        return entry.getKey();
                    }
                }
            }
            return null;
        }

        private void addStream(Token token, String triggeringMethod) {
            synchronized (mRemoteStreams) {
                if (!mRemoteStreams.containsKey(token)) {
                    mRemoteStreams.put(token, mNextStream);
                    if (D.BUG) Log.d(TAG, triggeringMethod + ": added stream " + mNextStream
@@ -1156,6 +1171,7 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
                }
            }
        }
    }

    public interface UserActivityListener {
        void onUserActivity();