From cc4b63ec4c3d3622f778c647eb584c68a3c00615 Mon Sep 17 00:00:00 2001
From: Alan Viverette <alanv@google.com>
Date: Thu, 21 Jul 2011 10:49:16 -0700
Subject: [PATCH] Updated check for touch exploration enabled state

Bug: 5061704
Change-Id: Id2c0cce953f7bdb2b4c18b68f9e318d95eabc1b8
---
 .../accessibility/AccessibilityUtils.java       |  5 +----
 .../compat/AccessibilityEventCompatUtils.java   | 17 -----------------
 .../AccessibilityManagerCompatWrapper.java      | 14 ++++----------
 3 files changed, 5 insertions(+), 31 deletions(-)

diff --git a/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java b/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java
index ae614b7e07..7e71b5f36a 100644
--- a/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java
+++ b/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java
@@ -16,7 +16,6 @@
 
 package com.android.inputmethod.accessibility;
 
-import android.accessibilityservice.AccessibilityServiceInfo;
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.inputmethodservice.InputMethodService;
@@ -82,10 +81,8 @@ public class AccessibilityUtils {
      */
     public boolean isTouchExplorationEnabled() {
         return ENABLE_ACCESSIBILITY
-                && AccessibilityEventCompatUtils.supportsTouchExploration()
                 && mAccessibilityManager.isEnabled()
-                && !mCompatManager.getEnabledAccessibilityServiceList(
-                        AccessibilityServiceInfo.FEEDBACK_SPOKEN).isEmpty();
+                && mCompatManager.isTouchExplorationEnabled();
     }
 
     /**
diff --git a/java/src/com/android/inputmethod/compat/AccessibilityEventCompatUtils.java b/java/src/com/android/inputmethod/compat/AccessibilityEventCompatUtils.java
index 50057727a8..2fa9d87d8d 100644
--- a/java/src/com/android/inputmethod/compat/AccessibilityEventCompatUtils.java
+++ b/java/src/com/android/inputmethod/compat/AccessibilityEventCompatUtils.java
@@ -16,24 +16,7 @@
 
 package com.android.inputmethod.compat;
 
-import android.view.accessibility.AccessibilityEvent;
-
-import java.lang.reflect.Field;
-
 public class AccessibilityEventCompatUtils {
     public static final int TYPE_VIEW_HOVER_ENTER = 0x80;
     public static final int TYPE_VIEW_HOVER_EXIT = 0x100;
-
-    private static final Field FIELD_TYPE_VIEW_HOVER_ENTER = CompatUtils.getField(
-            AccessibilityEvent.class, "TYPE_VIEW_HOVER_ENTER");
-    private static final Field FIELD_TYPE_VIEW_HOVER_EXIT = CompatUtils.getField(
-            AccessibilityEvent.class, "TYPE_VIEW_HOVER_EXIT");
-    private static final Integer OBJ_TYPE_VIEW_HOVER_ENTER = (Integer) CompatUtils
-            .getFieldValue(null, null, FIELD_TYPE_VIEW_HOVER_ENTER);
-    private static final Integer OBJ_TYPE_VIEW_HOVER_EXIT = (Integer) CompatUtils
-            .getFieldValue(null, null, FIELD_TYPE_VIEW_HOVER_EXIT);
-
-    public static boolean supportsTouchExploration() {
-        return OBJ_TYPE_VIEW_HOVER_ENTER != null && OBJ_TYPE_VIEW_HOVER_EXIT != null;
-    }
 }
diff --git a/java/src/com/android/inputmethod/compat/AccessibilityManagerCompatWrapper.java b/java/src/com/android/inputmethod/compat/AccessibilityManagerCompatWrapper.java
index 4db1c7a245..a30af0faf9 100644
--- a/java/src/com/android/inputmethod/compat/AccessibilityManagerCompatWrapper.java
+++ b/java/src/com/android/inputmethod/compat/AccessibilityManagerCompatWrapper.java
@@ -16,16 +16,13 @@
 
 package com.android.inputmethod.compat;
 
-import android.accessibilityservice.AccessibilityServiceInfo;
 import android.view.accessibility.AccessibilityManager;
 
 import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.List;
 
 public class AccessibilityManagerCompatWrapper {
-    private static final Method METHOD_getEnabledAccessibilityServiceList = CompatUtils.getMethod(
-            AccessibilityManager.class, "getEnabledAccessibilityServiceList", int.class);
+    private static final Method METHOD_isTouchExplorationEnabled = CompatUtils.getMethod(
+            AccessibilityManager.class, "isTouchExplorationEnabled");
 
     private final AccessibilityManager mManager;
 
@@ -33,10 +30,7 @@ public class AccessibilityManagerCompatWrapper {
         mManager = manager;
     }
 
-    @SuppressWarnings("unchecked")
-    public List<AccessibilityServiceInfo> getEnabledAccessibilityServiceList(int feedbackType) {
-        return (List<AccessibilityServiceInfo>) CompatUtils.invoke(mManager,
-                Collections.<AccessibilityServiceInfo>emptyList(),
-                METHOD_getEnabledAccessibilityServiceList, feedbackType);
+    public boolean isTouchExplorationEnabled() {
+        return (Boolean) CompatUtils.invoke(mManager, false, METHOD_isTouchExplorationEnabled);
     }
 }
-- 
GitLab