Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7a84eaef authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

DnD: Total silence doesn't suppress A11y

When entering Total silence mode, text prompts from a11y were losing
 AppOpsManager.OP_PLAY_AUDIO, causing them to play muted (amplification
 of 0.0f) even though the STREAM_ACCESSIBILITY volume was not.
The fix consists in adding another category of sound suppression
 behavior in AudioAttributes, for usage types that should never be
 suppressed (== muted), and using it for USAGE_ACCESSIBILITY.
 When ZenModeHelper iterates over usages to mute/unmute players,
 consider whether that usage's suppression behavior is SUPPRESSIBLE_NEVER.

Test: turn Talkback on, then enter Total silence and verify Talkback is heard
Bug 62827456

Change-Id: I48cae48797ef9bc6bcaee82484ba078ee445345c
parent 07b93779
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -194,6 +194,12 @@ public final class AudioAttributes implements Parcelable {
     * @see #SUPPRESSIBLE_USAGES
     */
    public final static int SUPPRESSIBLE_CALL = 2;
    /**
     * @hide
     * Denotes a usage that is never going to be muted, even in Total Silence.
     * @see #SUPPRESSIBLE_USAGES
     */
    public final static int SUPPRESSIBLE_NEVER = 3;

    /**
     * @hide
@@ -211,6 +217,7 @@ public final class AudioAttributes implements Parcelable {
        SUPPRESSIBLE_USAGES.put(USAGE_NOTIFICATION_COMMUNICATION_INSTANT,SUPPRESSIBLE_NOTIFICATION);
        SUPPRESSIBLE_USAGES.put(USAGE_NOTIFICATION_COMMUNICATION_DELAYED,SUPPRESSIBLE_NOTIFICATION);
        SUPPRESSIBLE_USAGES.put(USAGE_NOTIFICATION_EVENT,                SUPPRESSIBLE_NOTIFICATION);
        SUPPRESSIBLE_USAGES.put(USAGE_ASSISTANCE_ACCESSIBILITY,          SUPPRESSIBLE_NEVER);
    }

    /**
+3 −1
Original line number Diff line number Diff line
@@ -762,7 +762,9 @@ public class ZenModeHelper {

        for (int usage : AudioAttributes.SDK_USAGES) {
            final int suppressionBehavior = AudioAttributes.SUPPRESSIBLE_USAGES.get(usage);
            if (suppressionBehavior == AudioAttributes.SUPPRESSIBLE_NOTIFICATION) {
            if (suppressionBehavior == AudioAttributes.SUPPRESSIBLE_NEVER) {
                applyRestrictions(false /*mute*/, usage);
            } else if (suppressionBehavior == AudioAttributes.SUPPRESSIBLE_NOTIFICATION) {
                applyRestrictions(muteNotifications || muteEverything, usage);
            } else if (suppressionBehavior == AudioAttributes.SUPPRESSIBLE_CALL) {
                applyRestrictions(muteCalls || muteEverything, usage);