AudioService: suppress superfluous volume changed intents

Do not broadcast VOLUME_CHANGED_ACTION intent if the externally visible
volume index does not change: this can happen on aliased streams when
the internal volume index changes but the externally visible index
(divided by 10) does not change due to rounding.

Bug: 156835211
Test: verify intent broacasts in activity manager manually.
Change-Id: I98f25d175ada39fe1d2bc4f7d008f20a5d29ef16
This commit is contained in:
Eric Laurent
2020-07-31 11:59:25 -07:00
parent 4fc108418a
commit a8728c993e

View File

@@ -5855,11 +5855,13 @@ public class AudioService extends IAudioService.Stub
caller);
}
// fire changed intents for all streams
mVolumeChanged.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, index);
mVolumeChanged.putExtra(AudioManager.EXTRA_PREV_VOLUME_STREAM_VALUE, oldIndex);
mVolumeChanged.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE_ALIAS,
mStreamVolumeAlias[mStreamType]);
sendBroadcastToAll(mVolumeChanged);
if (index != oldIndex) {
mVolumeChanged.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, index);
mVolumeChanged.putExtra(AudioManager.EXTRA_PREV_VOLUME_STREAM_VALUE, oldIndex);
mVolumeChanged.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE_ALIAS,
mStreamVolumeAlias[mStreamType]);
sendBroadcastToAll(mVolumeChanged);
}
}
return changed;
}