Bug 1019425 - Activate accessibility when both accessibilty and explore by touch are enabled. r=mfinkle

This simplifies some old code. We get rid of a whitelist of services, and rely on the face that accessibility and explore by touch is enabled to enter our internal accessibility mode.

The whitelist methode held 2 assumptions that are not true anymore:

1. There are some non-accessibility accessibility service apps in the wild that read notifications.
In later Android versions this has been made into a non-a11y use case with NotificationListenerService. So the cases of non-a11y accessibility services has shrunk.

2. Not all screen readers (Gingerbread TalkBack, for example) supported explore by touch. Today, we
exclusively support accessibility services that use explore by touch, and we should not activate our
accessibility mode in any other case.

MozReview-Commit-ID: LMeCedoIGbb
This commit is contained in:
Eitan Isaacson 2016-05-02 14:02:16 -07:00
Родитель faffe478f6
Коммит 700d8864c8
2 изменённых файлов: 18 добавлений и 35 удалений

Просмотреть файл

@ -5,10 +5,6 @@
package org.mozilla.gecko;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@ -17,8 +13,6 @@ import org.mozilla.gecko.gfx.LayerView;
import org.mozilla.gecko.util.ThreadUtils;
import org.mozilla.gecko.util.UIAsyncTask;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
import android.content.Context;
import android.graphics.Rect;
import android.os.Bundle;
@ -48,14 +42,6 @@ public class GeckoAccessibility {
private static final int BRAILLE_CLICK_BASE_INDEX = -275000000;
private static SelfBrailleClient sSelfBrailleClient;
private static final HashSet<String> sServiceWhitelist =
new HashSet<String>(Arrays.asList(new String[] {
"com.google.android.marvin.talkback.TalkBackService", // Google Talkback screen reader
"com.mot.readout.ScreenReader", // Motorola screen reader
"info.spielproject.spiel.SpielService", // Spiel screen reader
"es.codefactory.android.app.ma.MAAccessibilityService" // Codefactory Mobile Accessibility screen reader
}));
public static void updateAccessibilitySettings (final Context context) {
new UIAsyncTask.WithoutParams<Void>(ThreadUtils.getBackgroundHandler()) {
@Override
@ -64,19 +50,9 @@ public class GeckoAccessibility {
sEnabled = false;
AccessibilityManager accessibilityManager =
(AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
if (accessibilityManager.isEnabled()) {
ActivityManager activityManager =
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningServiceInfo> runningServices = activityManager.getRunningServices(Integer.MAX_VALUE);
for (RunningServiceInfo runningServiceInfo : runningServices) {
sEnabled = sServiceWhitelist.contains(runningServiceInfo.service.getClassName());
if (sEnabled)
break;
}
if (Versions.feature16Plus && sEnabled && sSelfBrailleClient == null) {
sSelfBrailleClient = new SelfBrailleClient(GeckoAppShell.getContext(), false);
}
sEnabled = accessibilityManager.isEnabled() && accessibilityManager.isTouchExplorationEnabled();
if (Versions.feature16Plus && sEnabled && sSelfBrailleClient == null) {
sSelfBrailleClient = new SelfBrailleClient(GeckoAppShell.getContext(), false);
}
try {
@ -268,14 +244,21 @@ public class GeckoAccessibility {
}
}
public static void setAccessibilityStateChangeListener(final Context context) {
// The state change listener is only supported on API14+
if (Versions.feature14Plus) {
AccessibilityManager accessibilityManager =
(AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
accessibilityManager.addAccessibilityStateChangeListener(new AccessibilityManager.AccessibilityStateChangeListener() {
public static void setAccessibilityManagerListeners(final Context context) {
AccessibilityManager accessibilityManager =
(AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
accessibilityManager.addAccessibilityStateChangeListener(new AccessibilityManager.AccessibilityStateChangeListener() {
@Override
public void onAccessibilityStateChanged(boolean enabled) {
updateAccessibilitySettings(context);
}
});
if (Versions.feature19Plus) {
accessibilityManager.addTouchExplorationStateChangeListener(new AccessibilityManager.TouchExplorationStateChangeListener() {
@Override
public void onAccessibilityStateChanged(boolean enabled) {
public void onTouchExplorationStateChanged(boolean enabled) {
updateAccessibilitySettings(context);
}
});

Просмотреть файл

@ -132,7 +132,7 @@ public class LayerView extends ScrollView implements Tabs.OnTabsChangedListener
setFocusableInTouchMode(true);
GeckoAccessibility.setDelegate(this);
GeckoAccessibility.setAccessibilityStateChangeListener(getContext());
GeckoAccessibility.setAccessibilityManagerListeners(getContext());
}
/**