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

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

AudioService: remove compile time options for a11y volume

Remove test code path for the a11y volume and only rely on
  AccessibilityServicesStateChangeListener. Query whether
  any of the running a11y services expose
  FLAG_ENABLE_ACCESSIBILITY_VOLUME

Test: enable a service that exposes FLAG_ENABLE_ACCESSIBILITY_VOLUME
  (Talkback will do this in the future) and change volume
Bug 30448020

Change-Id: Ib5dff31313c0ec65b3e9982e35c00698adf5b7de
parent e8ce181e
Loading
Loading
Loading
Loading
+1 −20
Original line number Diff line number Diff line
@@ -144,7 +144,6 @@ import java.util.Objects;
 */
public class AudioService extends IAudioService.Stub
        implements AccessibilityManager.TouchExplorationStateChangeListener,
            AccessibilityManager.AccessibilityStateChangeListener,
            AccessibilityManager.AccessibilityServicesStateChangeListener {

    private static final String TAG = "AudioService";
@@ -5926,25 +5925,13 @@ public class AudioService extends IAudioService.Stub
    //==========================================================================================
    // Accessibility

    /**
     * Compile-time constant to enable the use of an independent a11y volume:
     * - set to true to listen to a11y services state changes and read
     *   the whether any exposes the FLAG_ENABLE_ACCESSIBILITY_VOLUME flag
     * - set to false to listen to when accessibility services are started (e.g. "TalkBack started")
     */
    private static final boolean USE_FLAG_ENABLE_ACCESSIBILITY_VOLUME = false;

    private void initA11yMonitoring() {
        final AccessibilityManager accessibilityManager =
                (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
        updateDefaultStreamOverrideDelay(accessibilityManager.isTouchExplorationEnabled());
        updateA11yVolumeAlias(accessibilityManager.isEnabled());
        accessibilityManager.addTouchExplorationStateChangeListener(this);
        if (USE_FLAG_ENABLE_ACCESSIBILITY_VOLUME) {
        accessibilityManager.addAccessibilityServicesStateChangeListener(this);
        } else {
            accessibilityManager.addAccessibilityStateChangeListener(this);
        }
    }

    //---------------------------------------------------------------------------------
@@ -5982,12 +5969,6 @@ public class AudioService extends IAudioService.Stub

    private static boolean sIndependentA11yVolume = false;

    // implementation of AccessibilityStateChangeListener
    @Override
    public void onAccessibilityStateChanged(boolean enabled) {
        updateA11yVolumeAlias(enabled);
    }

    // implementation of AccessibilityServicesStateChangeListener
    @Override
    public void onAccessibilityServicesStateChanged() {