From 834b5336d6c627ad47722a3eb56a4045d7f97de2 Mon Sep 17 00:00:00 2001 From: liuxiaoyu7 Date: Wed, 24 Feb 2021 11:26:15 +0800 Subject: [PATCH] audio:Suppress device volume to safe volume If the device supports safe volume, should lower the volume to a safe volume Signed-off-by: liuxiaoyu7 Change-Id: Ib27aa56e5ecc9875f7515494a32571c30e178ef6 --- .../core/java/com/android/server/audio/AudioService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 5a8396ff5886c..e783229152292 100755 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -6554,7 +6554,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*/);