diff options
author | Svetoslav <svetoslavganov@google.com> | 2014-04-11 18:22:18 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-04-11 18:22:19 +0000 |
commit | 0f7ed1f4776844f3ee8d3ce9d903f62cace66a06 (patch) | |
tree | f9bc2221ce6459f4d233f6f67db5499248e4c392 /core | |
parent | 624994930adea1158011ff5c8ea1f8bfd700fe0e (diff) | |
parent | 1e0d4af9986c8c2a658769a63bf8b385d25e0435 (diff) | |
download | frameworks_base-0f7ed1f4776844f3ee8d3ce9d903f62cace66a06.zip frameworks_base-0f7ed1f4776844f3ee8d3ce9d903f62cace66a06.tar.gz frameworks_base-0f7ed1f4776844f3ee8d3ce9d903f62cace66a06.tar.bz2 |
Merge "Adding system support for a single accessibility focus."
Diffstat (limited to 'core')
5 files changed, 63 insertions, 5 deletions
diff --git a/core/java/android/accessibilityservice/AccessibilityService.java b/core/java/android/accessibilityservice/AccessibilityService.java index b01d92c..2620c44 100644 --- a/core/java/android/accessibilityservice/AccessibilityService.java +++ b/core/java/android/accessibilityservice/AccessibilityService.java @@ -526,6 +526,31 @@ public abstract class AccessibilityService extends Service { } /** + * Find the view that has the specified focus type. The search is performed + * across all windows. + * <p> + * <strong>Note:</strong> In order to access the windows your service has + * to declare the capability to retrieve window content by setting the + * {@link android.R.styleable#AccessibilityService_canRetrieveWindowContent} + * property in its meta-data. For details refer to {@link #SERVICE_META_DATA}. + * Also the service has to opt-in to retrieve the interactive windows by + * setting the {@link AccessibilityServiceInfo#FLAG_RETRIEVE_INTERACTIVE_WINDOWS} + * flag.Otherwise, the search will be performed only in the active window. + * </p> + * + * @param focus The focus to find. One of {@link AccessibilityNodeInfo#FOCUS_INPUT} or + * {@link AccessibilityNodeInfo#FOCUS_ACCESSIBILITY}. + * @return The node info of the focused view or null. + * + * @see AccessibilityNodeInfo#FOCUS_INPUT + * @see AccessibilityNodeInfo#FOCUS_ACCESSIBILITY + */ + public AccessibilityNodeInfo findFocus(int focus) { + return AccessibilityInteractionClient.getInstance().findFocus(mConnectionId, + AccessibilityNodeInfo.ANY_WINDOW_ID, AccessibilityNodeInfo.ROOT_NODE_ID, focus); + } + + /** * Gets the an {@link AccessibilityServiceInfo} describing this * {@link AccessibilityService}. This method is useful if one wants * to change some of the dynamically configurable properties at diff --git a/core/java/android/app/UiAutomation.java b/core/java/android/app/UiAutomation.java index 8523d0c..9405325 100644 --- a/core/java/android/app/UiAutomation.java +++ b/core/java/android/app/UiAutomation.java @@ -297,6 +297,28 @@ public final class UiAutomation { } /** + * Find the view that has the specified focus type. The search is performed + * across all windows. + * <p> + * <strong>Note:</strong> In order to access the windows you have to opt-in + * to retrieve the interactive windows by setting the + * {@link AccessibilityServiceInfo#FLAG_RETRIEVE_INTERACTIVE_WINDOWS} flag. + * Otherwise, the search will be performed only in the active window. + * </p> + * + * @param focus The focus to find. One of {@link AccessibilityNodeInfo#FOCUS_INPUT} or + * {@link AccessibilityNodeInfo#FOCUS_ACCESSIBILITY}. + * @return The node info of the focused view or null. + * + * @see AccessibilityNodeInfo#FOCUS_INPUT + * @see AccessibilityNodeInfo#FOCUS_ACCESSIBILITY + */ + public AccessibilityNodeInfo findFocus(int focus) { + return AccessibilityInteractionClient.getInstance().findFocus(mConnectionId, + AccessibilityNodeInfo.ANY_WINDOW_ID, AccessibilityNodeInfo.ROOT_NODE_ID, focus); + } + + /** * Gets the an {@link AccessibilityServiceInfo} describing this UiAutomation. * This method is useful if one wants to change some of the dynamically * configurable properties at runtime. diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 9761f1a..320140e 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -8790,11 +8790,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, && !pointInView(event.getX(), event.getY()))) { mSendingHoverAccessibilityEvents = false; sendAccessibilityHoverEvent(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT); - // If the window does not have input focus we take away accessibility - // focus as soon as the user stop hovering over the view. - if (mAttachInfo != null && !mAttachInfo.mHasWindowFocus) { - getViewRootImpl().setAccessibilityFocus(null, null); - } } } diff --git a/core/java/android/view/accessibility/AccessibilityInteractionClient.java b/core/java/android/view/accessibility/AccessibilityInteractionClient.java index 4dd8dcb..5b9372d 100644 --- a/core/java/android/view/accessibility/AccessibilityInteractionClient.java +++ b/core/java/android/view/accessibility/AccessibilityInteractionClient.java @@ -163,6 +163,19 @@ public final class AccessibilityInteractionClient } /** + * Gets the root {@link AccessibilityNodeInfo} in a given window. + * + * @param connectionId The id of a connection for interacting with the system. + * @param windowId The window id. + * @return The root {@link AccessibilityNodeInfo} if found, null otherwise. + */ + public AccessibilityNodeInfo getRootInWindow(int connectionId, int windowId) { + return findAccessibilityNodeInfoByAccessibilityId(connectionId, windowId, + AccessibilityNodeInfo.ROOT_NODE_ID, false, + AccessibilityNodeInfo.FLAG_PREFETCH_DESCENDANTS); + } + + /** * Gets the info for a window. * * @param connectionId The id of a connection for interacting with the system. diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java index a6904f7..9d10930 100644 --- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java +++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java @@ -77,6 +77,9 @@ public class AccessibilityNodeInfo implements Parcelable { public static final int ACTIVE_WINDOW_ID = UNDEFINED_ITEM_ID; /** @hide */ + public static final int ANY_WINDOW_ID = -2; + + /** @hide */ public static final int FLAG_PREFETCH_PREDECESSORS = 0x00000001; /** @hide */ |