Refactor accessibility button support detection
- Moves logic to detect devices capable of supporting the
accessibility button into AccessibilityManager from
SettingsLib to avoid issues with resource shifting in the
SUW binary
Bug: 37650567
Test: Existing Robolectric / Manual
Merged-In: Ibb2aaa3c2f79570df768cfa796fa890988ef82cc
Change-Id: I83bbecdf7836ae0de32ce7d39155ac0c111a8f15
diff --git a/api/system-current.txt b/api/system-current.txt
index 260780e..608acac 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -50676,6 +50676,7 @@
method public java.util.List<android.accessibilityservice.AccessibilityServiceInfo> getEnabledAccessibilityServiceList(int);
method public java.util.List<android.accessibilityservice.AccessibilityServiceInfo> getInstalledAccessibilityServiceList();
method public void interrupt();
+ method public static boolean isAccessibilityButtonSupported();
method public boolean isEnabled();
method public boolean isTouchExplorationEnabled();
method public boolean removeAccessibilityStateChangeListener(android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener);
diff --git a/core/java/android/view/accessibility/AccessibilityManager.java b/core/java/android/view/accessibility/AccessibilityManager.java
index dfb0095..7eb7bd9 100644
--- a/core/java/android/view/accessibility/AccessibilityManager.java
+++ b/core/java/android/view/accessibility/AccessibilityManager.java
@@ -23,10 +23,12 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
+import android.annotation.SystemApi;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
+import android.content.res.Resources;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
@@ -1059,6 +1061,19 @@
}
}
+ /**
+ * Determines if the accessibility button within the system navigation area is supported.
+ *
+ * @return {@code true} if the accessibility button is supported on this device,
+ * {@code false} otherwise
+ * @hide
+ */
+ @SystemApi
+ public static boolean isAccessibilityButtonSupported() {
+ final Resources res = Resources.getSystem();
+ return res.getBoolean(com.android.internal.R.bool.config_showNavigationBar);
+ }
+
private final class MyCallback implements Handler.Callback {
public static final int MSG_SET_STATE = 1;
diff --git a/packages/SettingsLib/src/com/android/settingslib/accessibility/AccessibilityButtonHelper.java b/packages/SettingsLib/src/com/android/settingslib/accessibility/AccessibilityButtonHelper.java
index 972ea34..d5725e6 100644
--- a/packages/SettingsLib/src/com/android/settingslib/accessibility/AccessibilityButtonHelper.java
+++ b/packages/SettingsLib/src/com/android/settingslib/accessibility/AccessibilityButtonHelper.java
@@ -18,7 +18,6 @@
import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.Context;
-import android.content.res.Resources;
import android.provider.Settings;
import android.view.accessibility.AccessibilityManager;
@@ -55,8 +54,4 @@
public static boolean isRequested(Context ctx) {
return isRequestedByMagnification(ctx) || isRequestedByAccessibilityService(ctx);
}
-
- public static boolean isDeviceSupported(Resources res) {
- return res.getBoolean(com.android.internal.R.bool.config_showNavigationBar);
- }
}