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

Commit 76279d41 authored by Kaiqiang Wang's avatar Kaiqiang Wang
Browse files

Create Public API in AccessibilityManager to expose Audio description

enabled status.

1) Move ENABLE_ACCESSIBILITY_AUDIO_DESCRIPTION_BY_DEFAULT from
Settings.Global to Settings.Secure.
2) Add isAudioDescriptionEnabled public API to read the
Settings.Secure.ENABLED_ACCESSIBILITY_AUDIO_DESCRIPTION_BY_DEFAULT.

Test: local test
Test: atest AccessibilityManagerTest
Bug: 160823970
CTS-Coverage-Bug: 197311729
Change-Id: Iecf006bc8a1315414b37b6d644fc607b3d2aa03b
parent 1ab3bdf5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -50832,6 +50832,7 @@ package android.view.accessibility {
    method public int getRecommendedTimeoutMillis(int, int);
    method public void interrupt();
    method public static boolean isAccessibilityButtonSupported();
    method public boolean isAudioDescriptionEnabled();
    method public boolean isEnabled();
    method public boolean isTouchExplorationEnabled();
    method public void removeAccessibilityRequestPreparer(android.view.accessibility.AccessibilityRequestPreparer);
+8 −8
Original line number Diff line number Diff line
@@ -7219,6 +7219,14 @@ public final class Settings {
        public static final String ENABLED_ACCESSIBILITY_SERVICES =
            "enabled_accessibility_services";
        /**
         * Whether select sound track with audio description by default.
         * @hide
         */
        @Readable
        public static final String ENABLE_ACCESSIBILITY_AUDIO_DESCRIPTION_BY_DEFAULT =
                "enable_accessibility_audio_description_by_default";
        /**
         * List of the notified non-accessibility category accessibility services.
         *
@@ -10375,14 +10383,6 @@ public final class Settings {
        public static final String ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED =
                "enable_accessibility_global_gesture_enabled";
        /**
         * Whether select sound track with audio description by default.
         * @hide
         */
        @Readable
        public static final String ENABLE_ACCESSIBILITY_AUDIO_DESCRIPTION_BY_DEFAULT =
                "enable_accessibility_audio_description_by_default";
        /**
         * Whether Airplane Mode is on.
         */
+25 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.annotation.UserIdInt;
import android.app.RemoteAction;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
@@ -54,6 +55,7 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.ArrayMap;
import android.util.Log;
import android.util.SparseArray;
@@ -271,6 +273,8 @@ public final class AccessibilityManager {
     */
    private SparseArray<List<AccessibilityRequestPreparer>> mRequestPreparerLists;

    private ContentResolver mContentResolver;

    /**
     * Listener for the system accessibility state. To listen for changes to the
     * accessibility state on the device, implement this interface and register
@@ -483,6 +487,7 @@ public final class AccessibilityManager {
        mCallback = new MyCallback();
        mHandler = new Handler(context.getMainLooper(), mCallback);
        mUserId = userId;
        mContentResolver = context.getContentResolver();
        synchronized (mLock) {
            initialFocusAppearanceLocked(context.getResources());
            tryConnectToServiceLocked(service);
@@ -507,6 +512,7 @@ public final class AccessibilityManager {
        mCallback = new MyCallback();
        mHandler = handler;
        mUserId = userId;
        mContentResolver = context.getContentResolver();
        synchronized (mLock) {
            initialFocusAppearanceLocked(context.getResources());
            if (serviceConnect) {
@@ -1820,6 +1826,25 @@ public final class AccessibilityManager {
        return res.getBoolean(com.android.internal.R.bool.config_showNavigationBar);
    }

    /**
     * Determines if users want to select sound track with audio description by default.
     *
     * Audio description, also referred to as a video description, described video, or
     * more precisely called a visual description, is a form of narration used to provide
     * information surrounding key visual elements in a media work for the benefit of
     * blind and visually impaired consumers.
     *
     * The method provides the preference value to content provider apps to select the
     * default sound track during playing a video or movie.
     *
     * @return {@code true} if the audio description is enabled, {@code false} otherwise.
     */
    public boolean isAudioDescriptionEnabled() {
        return Settings.Secure.getInt(
                mContentResolver,
                Settings.Secure.ENABLE_ACCESSIBILITY_AUDIO_DESCRIPTION_BY_DEFAULT, 0) == 1;
    }

    private final class MyCallback implements Handler.Callback {
        public static final int MSG_SET_STATE = 1;

+1 −1
Original line number Diff line number Diff line
@@ -272,7 +272,6 @@ public class SettingsBackupTest {
                    Settings.Global.DYNAMIC_POWER_SAVINGS_DISABLE_THRESHOLD,
                    Settings.Global.SMART_REPLIES_IN_NOTIFICATIONS_FLAGS,
                    Settings.Global.SMART_SUGGESTIONS_IN_NOTIFICATIONS_FLAGS,
                    Settings.Global.ENABLE_ACCESSIBILITY_AUDIO_DESCRIPTION_BY_DEFAULT,
                    Settings.Global.ENABLE_ADB_INCREMENTAL_INSTALL_DEFAULT,
                    Settings.Global.ENABLE_MULTI_SLOT_TIMEOUT_MILLIS,
                    Settings.Global.ENHANCED_4G_MODE_ENABLED,
@@ -722,6 +721,7 @@ public class SettingsBackupTest {
                 Settings.Secure.DOCKED_CLOCK_FACE,
                 Settings.Secure.DOZE_PULSE_ON_LONG_PRESS,
                 Settings.Secure.EMERGENCY_ASSISTANCE_APPLICATION,
                 Settings.Secure.ENABLE_ACCESSIBILITY_AUDIO_DESCRIPTION_BY_DEFAULT,
                 Settings.Secure.ENABLED_INPUT_METHODS,  // Intentionally removed in P
                 Settings.Secure.ENABLED_NOTIFICATION_ASSISTANT,
                 Settings.Secure.ENABLED_NOTIFICATION_LISTENERS,