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

Commit a362f7b7 authored by Vlad Popa's avatar Vlad Popa
Browse files

Improve dumpsys logging of volume change events

Squashed the aliased stream volume changes to be displayed within the
same line together with their alias.

Test: manual
Bug: 332410019
Change-Id: I84958cfc9526f09678782c7c093e2508fb5402bb
parent 5f6600c4
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -8855,6 +8855,7 @@ public class AudioService extends IAudioService.Stub
            boolean changed;
            int oldIndex;
            final boolean isCurrentDevice;
            final StringBuilder aliasStreamIndexes = new StringBuilder();
            synchronized (mSettingsLock) {
                synchronized (VolumeStreamState.class) {
                    oldIndex = getIndex(device);
@@ -8881,13 +8882,17 @@ public class AudioService extends IAudioService.Stub
                                (changed || !aliasStreamState.hasIndexForDevice(device))) {
                            final int scaledIndex =
                                    rescaleIndex(aliasIndex, mStreamType, streamType);
                            aliasStreamState.setIndex(scaledIndex, device, caller,
                                    hasModifyAudioSettings);
                            boolean changedAlias = aliasStreamState.setIndex(scaledIndex, device,
                                    caller, hasModifyAudioSettings);
                            if (isCurrentDevice) {
                                aliasStreamState.setIndex(scaledIndex,
                                changedAlias |= aliasStreamState.setIndex(scaledIndex,
                                        getDeviceForStream(streamType), caller,
                                        hasModifyAudioSettings);
                            }
                            if (changedAlias) {
                                aliasStreamIndexes.append(AudioSystem.streamToString(streamType))
                                        .append(":").append((scaledIndex + 5) / 10).append(" ");
                            }
                        }
                    }
                    // Mirror changes in SPEAKER ringtone volume on SCO when
@@ -8927,8 +8932,15 @@ public class AudioService extends IAudioService.Stub
                                oldIndex);
                        mVolumeChanged.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE_ALIAS,
                                mStreamVolumeAlias[mStreamType]);
                        if (mStreamType == mStreamVolumeAlias[mStreamType]) {
                            String aliasStreamIndexesString = "";
                            if (!aliasStreamIndexes.isEmpty()) {
                                aliasStreamIndexesString =
                                        " aliased streams: " + aliasStreamIndexes;
                            }
                            AudioService.sVolumeLogger.enqueue(new VolChangedBroadcastEvent(
                                mStreamType, mStreamVolumeAlias[mStreamType], index, oldIndex));
                                    mStreamType, aliasStreamIndexesString, index, oldIndex));
                        }
                        sendBroadcastToAll(mVolumeChanged, mVolumeChangedOptions);
                    }
                }
+5 −5
Original line number Diff line number Diff line
@@ -151,13 +151,13 @@ public class AudioServiceEvents {

    static final class VolChangedBroadcastEvent extends EventLogger.Event {
        final int mStreamType;
        final int mAliasStreamType;
        final String mAliasStreamIndexes;
        final int mIndex;
        final int mOldIndex;

        VolChangedBroadcastEvent(int stream, int alias, int index, int oldIndex) {
        VolChangedBroadcastEvent(int stream, String aliasIndexes, int index, int oldIndex) {
            mStreamType = stream;
            mAliasStreamType = alias;
            mAliasStreamIndexes = aliasIndexes;
            mIndex = index;
            mOldIndex = oldIndex;
        }
@@ -167,8 +167,8 @@ public class AudioServiceEvents {
            return new StringBuilder("sending VOLUME_CHANGED stream:")
                    .append(AudioSystem.streamToString(mStreamType))
                    .append(" index:").append(mIndex)
                    .append(" (was:").append(mOldIndex)
                    .append(") alias:").append(AudioSystem.streamToString(mAliasStreamType))
                    .append(" (was:").append(mOldIndex).append(")")
                    .append(mAliasStreamIndexes)
                    .toString();
        }
    }