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

Commit 70cb293d authored by Rhed Jao's avatar Rhed Jao Committed by Android (Google) Code Review
Browse files

Merge changes from topic "A11yShortcut_NeedWithUi"

* changes:
  Accessibility shortcut improvement (10/n)
  Accessibility shortcut improvement (9/n)
  Accessibility shortcut improvement (8/n)
parents a737ad30 f526c999
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -6419,6 +6419,15 @@ public final class Settings {
        public static final String ACCESSIBILITY_BUTTON_TARGET_COMPONENT =
                "accessibility_button_target_component";
        /**
         * The system class name of magnification controller which is a target to be toggled via
         * accessibility shortcut or accessibility button.
         *
         * @hide
         */
        public static final String ACCESSIBILITY_SHORTCUT_TARGET_MAGNIFICATION_CONTROLLER =
                "com.android.server.accessibility.MagnificationController";
        /**
         * If touch exploration is enabled.
         */
+30 −2
Original line number Diff line number Diff line
@@ -1195,6 +1195,19 @@ public final class AccessibilityManager {
    @TestApi
    @RequiresPermission(Manifest.permission.MANAGE_ACCESSIBILITY)
    public void performAccessibilityShortcut() {
        performAccessibilityShortcut(null);
    }

    /**
     * Perform the accessibility shortcut for the given target which is assigned to the shortcut.
     *
     * @param targetName The flattened {@link ComponentName} string or the class name of a system
     *        class implementing a supported accessibility feature, or {@code null} if there's no
     *        specified target.
     * @hide
     */
    @RequiresPermission(Manifest.permission.MANAGE_ACCESSIBILITY)
    public void performAccessibilityShortcut(@Nullable String targetName) {
        final IAccessibilityManager service;
        synchronized (mLock) {
            service = getServiceLocked();
@@ -1203,7 +1216,7 @@ public final class AccessibilityManager {
            }
        }
        try {
            service.performAccessibilityShortcut();
            service.performAccessibilityShortcut(targetName);
        } catch (RemoteException re) {
            Log.e(LOG_TAG, "Error performing accessibility shortcut. ", re);
        }
@@ -1270,7 +1283,22 @@ public final class AccessibilityManager {
     * @param displayId The logical display id.
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.STATUS_BAR_SERVICE)
    public void notifyAccessibilityButtonClicked(int displayId) {
        notifyAccessibilityButtonClicked(displayId, null);
    }

    /**
     * Perform the accessibility button for the given target which is assigned to the button.
     *
     * @param displayId displayId The logical display id.
     * @param targetName The flattened {@link ComponentName} string or the class name of a system
     *        class implementing a supported accessibility feature, or {@code null} if there's no
     *        specified target.
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.STATUS_BAR_SERVICE)
    public void notifyAccessibilityButtonClicked(int displayId, @Nullable String targetName) {
        final IAccessibilityManager service;
        synchronized (mLock) {
            service = getServiceLocked();
@@ -1279,7 +1307,7 @@ public final class AccessibilityManager {
            }
        }
        try {
            service.notifyAccessibilityButtonClicked(displayId);
            service.notifyAccessibilityButtonClicked(displayId, targetName);
        } catch (RemoteException re) {
            Log.e(LOG_TAG, "Error while dispatching accessibility button click", re);
        }
+2 −2
Original line number Diff line number Diff line
@@ -66,12 +66,12 @@ interface IAccessibilityManager {
    // Used by UiAutomation
    IBinder getWindowToken(int windowId, int userId);

    void notifyAccessibilityButtonClicked(int displayId);
    void notifyAccessibilityButtonClicked(int displayId, String targetName);

    void notifyAccessibilityButtonVisibilityChanged(boolean available);

    // Requires Manifest.permission.MANAGE_ACCESSIBILITY
    void performAccessibilityShortcut();
    void performAccessibilityShortcut(String targetName);

    // Requires Manifest.permission.MANAGE_ACCESSIBILITY
    List<String> getAccessibilityShortcutTargets(int shortcutType);
+6 −6
Original line number Diff line number Diff line
@@ -348,7 +348,7 @@ public class AccessibilityShortcutControllerTest {
        verify(mAlertDialog).show();
        verify(mAccessibilityManagerService, atLeastOnce()).getInstalledAccessibilityServiceList(
                anyInt());
        verify(mAccessibilityManagerService, times(0)).performAccessibilityShortcut();
        verify(mAccessibilityManagerService, times(0)).performAccessibilityShortcut(null);
        verify(mFrameworkObjectProvider, times(0)).getTextToSpeech(any(), any());
    }

@@ -365,7 +365,7 @@ public class AccessibilityShortcutControllerTest {
        assertEquals(WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS,
                mLayoutParams.privateFlags
                        & WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS);
        verify(mAccessibilityManagerService, times(1)).performAccessibilityShortcut();
        verify(mAccessibilityManagerService, times(1)).performAccessibilityShortcut(null);
    }

    @Test
@@ -433,7 +433,7 @@ public class AccessibilityShortcutControllerTest {

        verifyZeroInteractions(mAlertDialogBuilder, mAlertDialog);
        verify(mToast).show();
        verify(mAccessibilityManagerService).performAccessibilityShortcut();
        verify(mAccessibilityManagerService).performAccessibilityShortcut(null);
    }

    @Test
@@ -459,7 +459,7 @@ public class AccessibilityShortcutControllerTest {
        when(mServiceInfo.loadSummary(any())).thenReturn(null);
        Settings.Secure.putInt(mContentResolver, ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, 1);
        getController().performAccessibilityShortcut();
        verify(mAccessibilityManagerService).performAccessibilityShortcut();
        verify(mAccessibilityManagerService).performAccessibilityShortcut(null);
    }

    @Test
@@ -471,7 +471,7 @@ public class AccessibilityShortcutControllerTest {
        getController().performAccessibilityShortcut();

        verifyZeroInteractions(mToast);
        verify(mAccessibilityManagerService).performAccessibilityShortcut();
        verify(mAccessibilityManagerService).performAccessibilityShortcut(null);
    }

    @Test
@@ -485,7 +485,7 @@ public class AccessibilityShortcutControllerTest {
        getController().performAccessibilityShortcut();

        verifyZeroInteractions(mToast);
        verify(mAccessibilityManagerService).performAccessibilityShortcut();
        verify(mAccessibilityManagerService).performAccessibilityShortcut(null);
    }

    @Test
+28 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.os.Process.INVALID_UID;
import static android.os.Process.ROOT_UID;
import static android.os.Process.SHELL_UID;
import static android.os.Process.SYSTEM_UID;
import static android.provider.Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_MAGNIFICATION_CONTROLLER;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVERLAY;

import android.Manifest;
@@ -3304,7 +3305,7 @@ public class SettingsProvider extends ContentProvider {
        }

        private final class UpgradeController {
            private static final int SETTINGS_VERSION = 185;
            private static final int SETTINGS_VERSION = 186;

            private final int mUserId;

@@ -4547,6 +4548,32 @@ public class SettingsProvider extends ContentProvider {
                    currentVersion = 185;
                }

                if (currentVersion == 185) {
                    // Deprecate ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, and migrate it
                    // to ACCESSIBILITY_BUTTON_TARGET_COMPONENT.
                    final SettingsState secureSettings = getSecureSettingsLocked(userId);
                    final Setting magnifyNavbarEnabled = secureSettings.getSettingLocked(
                            Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED);
                    if ("1".equals(magnifyNavbarEnabled.getValue())) {
                        secureSettings.insertSettingLocked(
                                Secure.ACCESSIBILITY_BUTTON_TARGET_COMPONENT,
                                ACCESSIBILITY_SHORTCUT_TARGET_MAGNIFICATION_CONTROLLER,
                                null /* tag */, false /* makeDefault */,
                                SettingsState.SYSTEM_PACKAGE_NAME);
                    } else {
                        // Clear a11y button targets list setting. A11yManagerService will end up
                        // adding all legacy enabled services that want the button to the list, so
                        // there's no need to keep tracking them.
                        secureSettings.insertSettingLocked(
                                Secure.ACCESSIBILITY_BUTTON_TARGET_COMPONENT,
                                null, null /* tag */, false /* makeDefault */,
                                SettingsState.SYSTEM_PACKAGE_NAME);
                    }
                    secureSettings.deleteSettingLocked(
                            Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED);
                    currentVersion = 186;
                }

                // vXXX: Add new settings above this point.

                if (currentVersion != newVersion) {
Loading