Updated check for touch exploration enabled state

Bug: 5061704
Change-Id: Id2c0cce953f7bdb2b4c18b68f9e318d95eabc1b8
main
Alan Viverette 2011-07-21 10:49:16 -07:00
parent 81ff3ba343
commit cc4b63ec4c
3 changed files with 5 additions and 31 deletions

View File

@ -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();
}
/**

View File

@ -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;
}
}

View File

@ -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);
}
}