Merge "Updated check for touch exploration enabled state"
commit
f9051733b7
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
package com.android.inputmethod.accessibility;
|
package com.android.inputmethod.accessibility;
|
||||||
|
|
||||||
import android.accessibilityservice.AccessibilityServiceInfo;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.inputmethodservice.InputMethodService;
|
import android.inputmethodservice.InputMethodService;
|
||||||
|
@ -82,10 +81,8 @@ public class AccessibilityUtils {
|
||||||
*/
|
*/
|
||||||
public boolean isTouchExplorationEnabled() {
|
public boolean isTouchExplorationEnabled() {
|
||||||
return ENABLE_ACCESSIBILITY
|
return ENABLE_ACCESSIBILITY
|
||||||
&& AccessibilityEventCompatUtils.supportsTouchExploration()
|
|
||||||
&& mAccessibilityManager.isEnabled()
|
&& mAccessibilityManager.isEnabled()
|
||||||
&& !mCompatManager.getEnabledAccessibilityServiceList(
|
&& mCompatManager.isTouchExplorationEnabled();
|
||||||
AccessibilityServiceInfo.FEEDBACK_SPOKEN).isEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,24 +16,7 @@
|
||||||
|
|
||||||
package com.android.inputmethod.compat;
|
package com.android.inputmethod.compat;
|
||||||
|
|
||||||
import android.view.accessibility.AccessibilityEvent;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
public class AccessibilityEventCompatUtils {
|
public class AccessibilityEventCompatUtils {
|
||||||
public static final int TYPE_VIEW_HOVER_ENTER = 0x80;
|
public static final int TYPE_VIEW_HOVER_ENTER = 0x80;
|
||||||
public static final int TYPE_VIEW_HOVER_EXIT = 0x100;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,16 +16,13 @@
|
||||||
|
|
||||||
package com.android.inputmethod.compat;
|
package com.android.inputmethod.compat;
|
||||||
|
|
||||||
import android.accessibilityservice.AccessibilityServiceInfo;
|
|
||||||
import android.view.accessibility.AccessibilityManager;
|
import android.view.accessibility.AccessibilityManager;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class AccessibilityManagerCompatWrapper {
|
public class AccessibilityManagerCompatWrapper {
|
||||||
private static final Method METHOD_getEnabledAccessibilityServiceList = CompatUtils.getMethod(
|
private static final Method METHOD_isTouchExplorationEnabled = CompatUtils.getMethod(
|
||||||
AccessibilityManager.class, "getEnabledAccessibilityServiceList", int.class);
|
AccessibilityManager.class, "isTouchExplorationEnabled");
|
||||||
|
|
||||||
private final AccessibilityManager mManager;
|
private final AccessibilityManager mManager;
|
||||||
|
|
||||||
|
@ -33,10 +30,7 @@ public class AccessibilityManagerCompatWrapper {
|
||||||
mManager = manager;
|
mManager = manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
public boolean isTouchExplorationEnabled() {
|
||||||
public List<AccessibilityServiceInfo> getEnabledAccessibilityServiceList(int feedbackType) {
|
return (Boolean) CompatUtils.invoke(mManager, false, METHOD_isTouchExplorationEnabled);
|
||||||
return (List<AccessibilityServiceInfo>) CompatUtils.invoke(mManager,
|
|
||||||
Collections.<AccessibilityServiceInfo>emptyList(),
|
|
||||||
METHOD_getEnabledAccessibilityServiceList, feedbackType);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue