diff --git a/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java b/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java index ae614b7e0..7e71b5f36 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 50057727a..2fa9d87d8 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 4db1c7a24..a30af0faf 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 getEnabledAccessibilityServiceList(int feedbackType) { - return (List) CompatUtils.invoke(mManager, - Collections.emptyList(), - METHOD_getEnabledAccessibilityServiceList, feedbackType); + public boolean isTouchExplorationEnabled() { + return (Boolean) CompatUtils.invoke(mManager, false, METHOD_isTouchExplorationEnabled); } }