diff options
| author | 2019-11-28 22:47:18 +0800 | |
|---|---|---|
| committer | 2020-01-14 11:59:47 +0800 | |
| commit | 59a40df716a8271defc264ff42c4aa44c1113f5d (patch) | |
| tree | a9629ef5bf468feb137ab18f99aebf086944f6b0 | |
| parent | 129d419b085ebafbf0c64f97cab1fe50628f1ce0 (diff) | |
Accessibility shortcut improvement (9/n)
The setting key of navigation bar magnification state already
deprecated. Sysui need to use accessibility manager api to get
a11y button state.
Bug: 136293963
Test: atest NavigationBarFragmentTest
Change-Id: I52d19c16b3eb3b7168890f8c27cf3500a401779a
| -rw-r--r-- | packages/SystemUI/AndroidManifest.xml | 1 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java | 37 |
2 files changed, 5 insertions, 33 deletions
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index 2a1e74e18fb7..df77b5bfb895 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -211,6 +211,7 @@ <!-- accessibility --> <uses-permission android:name="android.permission.MODIFY_ACCESSIBILITY_DATA" /> + <uses-permission android:name="android.permission.MANAGE_ACCESSIBILITY" /> <!-- to control accessibility volume --> <uses-permission android:name="android.permission.CHANGE_ACCESSIBILITY_VOLUME" /> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java index a6842badc153..4f56f56735a5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java @@ -157,7 +157,6 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback private int mNavigationIconHints = 0; private @TransitionMode int mNavigationBarMode; private AccessibilityManager mAccessibilityManager; - private MagnificationContentObserver mMagnificationObserver; private ContentResolver mContentResolver; private boolean mAssistantAvailable; @@ -303,11 +302,6 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback mWindowManager = getContext().getSystemService(WindowManager.class); mAccessibilityManager = getContext().getSystemService(AccessibilityManager.class); mContentResolver = getContext().getContentResolver(); - mMagnificationObserver = new MagnificationContentObserver( - getContext().getMainThreadHandler()); - mContentResolver.registerContentObserver(Settings.Secure.getUriFor( - Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED), false, - mMagnificationObserver, UserHandle.USER_ALL); mContentResolver.registerContentObserver( Settings.Secure.getUriFor(Settings.Secure.ASSISTANT), false /* notifyForDescendants */, mAssistContentObserver, UserHandle.USER_ALL); @@ -329,7 +323,6 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback super.onDestroy(); mNavigationModeController.removeListener(this); mAccessibilityManagerWrapper.removeCallback(mAccessibilityListener); - mContentResolver.unregisterContentObserver(mMagnificationObserver); mContentResolver.unregisterContentObserver(mAssistContentObserver); } @@ -969,28 +962,18 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback * @param outFeedbackEnabled if non-null, sets it to true if accessibility feedback is enabled. */ public int getA11yButtonState(@Nullable boolean[] outFeedbackEnabled) { - int requestingServices = 0; - try { - if (Settings.Secure.getIntForUser(mContentResolver, - Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, - UserHandle.USER_CURRENT) == 1) { - requestingServices++; - } - } catch (Settings.SettingNotFoundException e) { - } - boolean feedbackEnabled = false; // AccessibilityManagerService resolves services for the current user since the local // AccessibilityManager is created from a Context with the INTERACT_ACROSS_USERS permission final List<AccessibilityServiceInfo> services = mAccessibilityManager.getEnabledAccessibilityServiceList( AccessibilityServiceInfo.FEEDBACK_ALL_MASK); + final List<String> a11yButtonTargets = + mAccessibilityManager.getAccessibilityShortcutTargets( + AccessibilityManager.ACCESSIBILITY_BUTTON); + final int requestingServices = a11yButtonTargets.size(); for (int i = services.size() - 1; i >= 0; --i) { AccessibilityServiceInfo info = services.get(i); - if ((info.flags & AccessibilityServiceInfo.FLAG_REQUEST_ACCESSIBILITY_BUTTON) != 0) { - requestingServices++; - } - if (info.feedbackType != 0 && info.feedbackType != AccessibilityServiceInfo.FEEDBACK_GENERIC) { feedbackEnabled = true; @@ -1114,18 +1097,6 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback private final AccessibilityServicesStateChangeListener mAccessibilityListener = this::updateAccessibilityServicesState; - private class MagnificationContentObserver extends ContentObserver { - - public MagnificationContentObserver(Handler handler) { - super(handler); - } - - @Override - public void onChange(boolean selfChange) { - NavigationBarFragment.this.updateAccessibilityServicesState(mAccessibilityManager); - } - } - private final Consumer<Integer> mRotationWatcher = rotation -> { if (mNavigationBarView != null && mNavigationBarView.needsReorient(rotation)) { |