Loosen the user id check for master mute on automotive
For automotive,
- the car service is always running as system user
- foreground users are non-system users
Car service is in charge of dispatching the key event include master
mute to Android. Therefore, the getCurrentUser() is always different to
the foreground user.
See also go/aae-multi-user
Bug: 113268803
Test: adb shell input keyevent 164
Change-Id: I65d4a4bc1b96eec7dc61ed04c5acc425f37a9061
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 507f398..7f2ef07 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -2628,7 +2628,13 @@
// The isPlatformAutomotive check is added for safety but may not be necessary.
return;
}
- if (getCurrentUserId() == userId) {
+ // For automotive,
+ // - the car service is always running as system user
+ // - foreground users are non-system users
+ // Car service is in charge of dispatching the key event include master mute to Android.
+ // Therefore, the getCurrentUser() is always different to the foreground user.
+ if ((isPlatformAutomotive() && userId == UserHandle.USER_SYSTEM)
+ || (getCurrentUserId() == userId)) {
if (mute != AudioSystem.getMasterMute()) {
setSystemAudioMute(mute);
AudioSystem.setMasterMute(mute);