Muting ring volume slider disables notification
With volume_separate_notification flag enbaled, muting ring volume slice will cause notification volume slice to gray out. There used to be a bug in which notification slice would not get updated in response to a change in ring volume mute/unmute broadcast. The resulting erroneous behavior was notification slider would get to zero but not get grayed out. To fix that bug, VolumeSliceHelper listens to ring stream mute/unmute broadcasts and forwards them to notification slice. Bug: b/266072907 Test: make DEBUG_ROBOLECTRIC=1 ROBOTEST_FILTER="NotificationVolumePreferenceControllerTest|VolumeSliceHelperTest" RunSettingsRoboTests -j40 Change-Id: I2ab51f1272bf99a0c3d9ca285354052d00910c90
This commit is contained in:
@@ -93,8 +93,9 @@ public class VolumeSliceHelper {
|
||||
|
||||
if (AudioManager.VOLUME_CHANGED_ACTION.equals(action)) {
|
||||
handleVolumeChanged(context, intent);
|
||||
} else if (AudioManager.STREAM_MUTE_CHANGED_ACTION.equals(action)
|
||||
|| AudioManager.STREAM_DEVICES_CHANGED_ACTION.equals(action)) {
|
||||
} else if (AudioManager.STREAM_MUTE_CHANGED_ACTION.equals(action)) {
|
||||
handleMuteChanged(context, intent);
|
||||
} else if (AudioManager.STREAM_DEVICES_CHANGED_ACTION.equals(action)) {
|
||||
handleStreamChanged(context, intent);
|
||||
} else {
|
||||
notifyAllStreamsChanged(context);
|
||||
@@ -109,8 +110,29 @@ public class VolumeSliceHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When mute is changed, notifyChange on relevant Volume Slice ContentResolvers to mark them
|
||||
* as needing update.
|
||||
*
|
||||
* In addition to the matching stream, we always notifyChange for the Notification stream
|
||||
* when Ring events are issued. This is to make sure that Notification always gets updated
|
||||
* for RingerMode changes, even if Notification's volume is zero and therefore it would not
|
||||
* get its own AudioManager.VOLUME_CHANGED_ACTION.
|
||||
*/
|
||||
private static void handleMuteChanged(Context context, Intent intent) {
|
||||
final int inputType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1);
|
||||
handleStreamChanged(context, inputType);
|
||||
if (inputType == AudioManager.STREAM_RING) {
|
||||
handleStreamChanged(context, AudioManager.STREAM_NOTIFICATION);
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleStreamChanged(Context context, Intent intent) {
|
||||
final int inputType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1);
|
||||
handleStreamChanged(context, inputType);
|
||||
}
|
||||
|
||||
private static void handleStreamChanged(Context context, int inputType) {
|
||||
synchronized (sRegisteredUri) {
|
||||
for (Map.Entry<Uri, Integer> entry : sRegisteredUri.entrySet()) {
|
||||
if (entry.getValue() == inputType) {
|
||||
|
||||
Reference in New Issue
Block a user