From daba12467466b115fcbb50e609785591c24a6cbb Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Tue, 29 May 2018 14:36:16 -0700 Subject: Master mute is valid when running fixed volume for automotive In Automotive case, we set fixed volume to suggest no volume control inside AudioFlinger and master mute is a mapping to the physical mute button in a car, which toggles the global mute state. Bug: 80474559 Test: adb shell input keyevent 164 Change-Id: I1d4fd143a98ee96f11850811c90e6d9932cab948 --- services/core/java/com/android/server/audio/AudioService.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 28665e3c3942..bfa38a045938 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -215,6 +215,10 @@ public class AudioService extends IAudioService.Stub return mPlatformType == AudioSystem.PLATFORM_TELEVISION; } + private boolean isPlatformAutomotive() { + return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE); + } + /** The controller for the volume UI. */ private final VolumeController mVolumeController = new VolumeController(); @@ -2367,8 +2371,11 @@ public class AudioService extends IAudioService.Stub if (DEBUG_VOL) { Log.d(TAG, String.format("Master mute %s, %d, user=%d", mute, flags, userId)); } - if (mUseFixedVolume) { - return; // If using fixed volume, we don't mute. + if (!isPlatformAutomotive() && mUseFixedVolume) { + // If using fixed volume, we don't mute. + // TODO: remove the isPlatformAutomotive check here. + // The isPlatformAutomotive check is added for safety but may not be necessary. + return; } if (getCurrentUserId() == userId) { if (mute != AudioSystem.getMasterMute()) { -- cgit v1.2.3-59-g8ed1b