audio:Suppress device volume to safe volume

If the device supports safe volume,
should lower the volume to a safe volume

Test: make
Bug: 181634607
Signed-off-by: liuxiaoyu7 <liuxiaoyu7@xiaomi.com>
Change-Id: Ib27aa56e5ecc9875f7515494a32571c30e178ef6
Merged-In: Ib27aa56e5ecc9875f7515494a32571c30e178ef6
This commit is contained in:
liuxiaoyu7
2021-02-24 11:26:15 +08:00
committed by Eric Laurent
parent e7283b94bc
commit 8a901154e6

View File

@@ -6958,7 +6958,10 @@ public class AudioService extends IAudioService.Stub
private void onSetVolumeIndexOnDevice(@NonNull DeviceVolumeUpdate update) {
final VolumeStreamState streamState = mStreamStates[update.mStreamType];
if (update.hasVolumeIndex()) {
final int index = update.getVolumeIndex();
int index = update.getVolumeIndex();
if (!checkSafeMediaVolume(update.mStreamType, index, update.mDevice)) {
index = safeMediaVolumeIndex(update.mDevice);
}
streamState.setIndex(index, update.mDevice, update.mCaller,
// trusted as index is always validated before message is posted
true /*hasModifyAudioSettings*/);