summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--media/java/android/media/AudioManager.java17
-rw-r--r--media/java/android/media/IAudioService.aidl2
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioRepository.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/VolumeDialogControllerImpl.java2
-rw-r--r--services/core/java/com/android/server/audio/AudioService.java21
5 files changed, 41 insertions, 3 deletions
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index e134c23dfbca..124f1f0ddd43 100644
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -7007,6 +7007,23 @@ public class AudioManager {
}
/**
+ * Check whether a user can mute this stream type from a given UI element.
+ *
+ * <p>Only useful for volume controllers.
+ *
+ * @param streamType type of stream to check if it's mutable from UI
+ *
+ * @hide
+ */
+ public boolean isStreamMutableByUi(int streamType) {
+ try {
+ return getService().isStreamMutableByUi(streamType);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Only useful for volume controllers.
* @hide
*/
diff --git a/media/java/android/media/IAudioService.aidl b/media/java/android/media/IAudioService.aidl
index c8b9da50b082..08cc126fb1a8 100644
--- a/media/java/android/media/IAudioService.aidl
+++ b/media/java/android/media/IAudioService.aidl
@@ -305,6 +305,8 @@ interface IAudioService {
boolean isStreamAffectedByMute(int streamType);
+ boolean isStreamMutableByUi(int streamType);
+
void disableSafeMediaVolume(String callingPackage);
oneway void lowerVolumeToRs1(String callingPackage);
diff --git a/packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioRepository.kt b/packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioRepository.kt
index 8ec5ba193dba..8e072e632f3d 100644
--- a/packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioRepository.kt
+++ b/packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioRepository.kt
@@ -179,7 +179,7 @@ class AudioRepositoryImpl(
minVolume = getMinVolume(audioStream),
maxVolume = audioManager.getStreamMaxVolume(audioStream.value),
volume = audioManager.getStreamVolume(audioStream.value),
- isAffectedByMute = audioManager.isStreamAffectedByMute(audioStream.value),
+ isAffectedByMute = audioManager.isStreamMutableByUi(audioStream.value),
isAffectedByRingerMode = audioManager.isStreamAffectedByRingerMode(audioStream.value),
isMuted = audioManager.isStreamMute(audioStream.value),
)
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogControllerImpl.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogControllerImpl.java
index aee441a13a5d..c45f98e5f4f5 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogControllerImpl.java
@@ -567,7 +567,7 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
streamStateW(stream).levelMax = Math.max(1, getAudioManagerStreamMaxVolume(stream));
updateStreamMuteW(stream, mAudio.isStreamMute(stream));
final StreamState ss = streamStateW(stream);
- ss.muteSupported = mAudio.isStreamAffectedByMute(stream);
+ ss.muteSupported = mAudio.isStreamMutableByUi(stream);
ss.name = STREAMS.get(stream);
checkRoutedToBluetoothW(stream);
}
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 6d1983e75388..9b1c94535934 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -707,10 +707,14 @@ public class AudioService extends IAudioService.Stub
// Streams currently muted by ringer mode and dnd
protected static volatile int sRingerAndZenModeMutedStreams;
- /** Streams that can be muted. Do not resolve to aliases when checking.
+ /** Streams that can be muted by system. Do not resolve to aliases when checking.
* @see System#MUTE_STREAMS_AFFECTED */
private int mMuteAffectedStreams;
+ /** Streams that can be muted by user. Do not resolve to aliases when checking.
+ * @see System#MUTE_STREAMS_AFFECTED */
+ private int mUserMutableStreams;
+
@NonNull
private SoundEffectsHelper mSfxHelper;
@@ -2345,6 +2349,7 @@ public class AudioService extends IAudioService.Stub
mMuteAffectedStreams &= ~(1 << vss.mStreamType);
}
}
+ updateUserMutableStreams();
}
private void createStreamStates() {
@@ -2414,6 +2419,8 @@ public class AudioService extends IAudioService.Stub
}
pw.print("\n- mute affected streams = 0x");
pw.println(Integer.toHexString(mMuteAffectedStreams));
+ pw.print("\n- user mutable streams = 0x");
+ pw.println(Integer.toHexString(mUserMutableStreams));
}
private void updateStreamVolumeAlias(boolean updateVolumes, String caller) {
@@ -2908,6 +2915,7 @@ public class AudioService extends IAudioService.Stub
mMuteAffectedStreams = mSettings.getSystemIntForUser(cr,
System.MUTE_STREAMS_AFFECTED, AudioSystem.DEFAULT_MUTE_STREAMS_AFFECTED,
UserHandle.USER_CURRENT);
+ updateUserMutableStreams();
updateMasterMono(cr);
@@ -2927,6 +2935,12 @@ public class AudioService extends IAudioService.Stub
mVolumeController.loadSettings(cr);
}
+ private void updateUserMutableStreams() {
+ mUserMutableStreams = mMuteAffectedStreams;
+ mUserMutableStreams &= ~(1 << AudioSystem.STREAM_VOICE_CALL);
+ mUserMutableStreams &= ~(1 << AudioSystem.STREAM_BLUETOOTH_SCO);
+ }
+
@GuardedBy("mSettingsLock")
private void resetActiveAssistantUidsLocked() {
mActiveAssistantServiceUids = NO_ACTIVE_ASSISTANT_SERVICE_UIDS;
@@ -7125,6 +7139,11 @@ public class AudioService extends IAudioService.Stub
return (mMuteAffectedStreams & (1 << streamType)) != 0;
}
+ @Override
+ public boolean isStreamMutableByUi(int streamType) {
+ return (mUserMutableStreams & (1 << streamType)) != 0;
+ }
+
private void ensureValidDirection(int direction) {
switch (direction) {
case AudioManager.ADJUST_LOWER: