summaryrefslogtreecommitdiff
path: root/core/java/android/view/AccessibilityInteractionController.java
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2012-05-07 11:54:39 -0700
committerSvetoslav Ganov <svetoslavganov@google.com>2012-05-07 18:22:59 -0700
commit0a1bb6dffc358c01e10555c5c833edb7dba69659 (patch)
treed8dc9055172cf06c76dc75f3e7931201819df726 /core/java/android/view/AccessibilityInteractionController.java
parent2551e5a1d9990514d8116e352b8e5c2f10a9d303 (diff)
AccessibilityNodeInfo for visible views should reported.
1. AccessibilityNodeInfos for visible views should always be reported and the clients should be able to check whether that node info is shown to the user. For example, focus search may return a node that is not on the screen and the accessibility layer may decide to give it focus which scroll the source view in the screen. bug:6421991 Change-Id: Idc1fd8512dda767abe802aacedb0c69582e6fc2a
Diffstat (limited to 'core/java/android/view/AccessibilityInteractionController.java')
-rw-r--r--core/java/android/view/AccessibilityInteractionController.java32
1 files changed, 21 insertions, 11 deletions
diff --git a/core/java/android/view/AccessibilityInteractionController.java b/core/java/android/view/AccessibilityInteractionController.java
index 63871486ade6..881594da0a1a 100644
--- a/core/java/android/view/AccessibilityInteractionController.java
+++ b/core/java/android/view/AccessibilityInteractionController.java
@@ -126,6 +126,16 @@ final class AccessibilityInteractionController {
}
}
+ private boolean isShown(View view) {
+ // The first two checks are made also made by isShown() which
+ // however traverses the tree up to the parent to catch that.
+ // Therefore, we do some fail fast check to minimize the up
+ // tree traversal.
+ return (view.mAttachInfo != null
+ && view.mAttachInfo.mWindowVisibility == View.VISIBLE
+ && view.isShown());
+ }
+
public void findAccessibilityNodeInfoByAccessibilityIdClientThread(
long accessibilityNodeId, int interactionId,
IAccessibilityInteractionConnectionCallback callback, int flags, int interrogatingPid,
@@ -174,7 +184,7 @@ final class AccessibilityInteractionController {
} else {
root = findViewByAccessibilityId(accessibilityViewId);
}
- if (root != null && root.isDisplayedOnScreen()) {
+ if (root != null && isShown(root)) {
mPrefetcher.prefetchAccessibilityNodeInfos(root, virtualDescendantId, flags, infos);
}
} finally {
@@ -236,7 +246,7 @@ final class AccessibilityInteractionController {
}
if (root != null) {
View target = root.findViewById(viewId);
- if (target != null && target.isDisplayedOnScreen()) {
+ if (target != null && isShown(target)) {
info = target.createAccessibilityNodeInfo();
}
}
@@ -298,7 +308,7 @@ final class AccessibilityInteractionController {
} else {
root = mViewRootImpl.mView;
}
- if (root != null && root.isDisplayedOnScreen()) {
+ if (root != null && isShown(root)) {
AccessibilityNodeProvider provider = root.getAccessibilityNodeProvider();
if (provider != null) {
infos = provider.findAccessibilityNodeInfosByText(text,
@@ -315,7 +325,7 @@ final class AccessibilityInteractionController {
final int viewCount = foundViews.size();
for (int i = 0; i < viewCount; i++) {
View foundView = foundViews.get(i);
- if (foundView.isDisplayedOnScreen()) {
+ if (isShown(foundView)) {
provider = foundView.getAccessibilityNodeProvider();
if (provider != null) {
List<AccessibilityNodeInfo> infosFromProvider =
@@ -390,7 +400,7 @@ final class AccessibilityInteractionController {
} else {
root = mViewRootImpl.mView;
}
- if (root != null && root.isDisplayedOnScreen()) {
+ if (root != null && isShown(root)) {
switch (focusType) {
case AccessibilityNodeInfo.FOCUS_ACCESSIBILITY: {
View host = mViewRootImpl.mAccessibilityFocusedHost;
@@ -411,7 +421,7 @@ final class AccessibilityInteractionController {
case AccessibilityNodeInfo.FOCUS_INPUT: {
// Input focus cannot go to virtual views.
View target = root.findFocus();
- if (target != null && target.isDisplayedOnScreen()) {
+ if (target != null && isShown(target)) {
focused = target.createAccessibilityNodeInfo();
}
} break;
@@ -477,7 +487,7 @@ final class AccessibilityInteractionController {
} else {
root = mViewRootImpl.mView;
}
- if (root != null && root.isDisplayedOnScreen()) {
+ if (root != null && isShown(root)) {
if ((direction & View.FOCUS_ACCESSIBILITY) == View.FOCUS_ACCESSIBILITY) {
AccessibilityNodeProvider provider = root.getAccessibilityNodeProvider();
if (provider != null) {
@@ -565,7 +575,7 @@ final class AccessibilityInteractionController {
} else {
target = mViewRootImpl.mView;
}
- if (target != null && target.isDisplayedOnScreen()) {
+ if (target != null && isShown(target)) {
AccessibilityNodeProvider provider = target.getAccessibilityNodeProvider();
if (provider != null) {
succeeded = provider.performAction(virtualDescendantId, action,
@@ -590,7 +600,7 @@ final class AccessibilityInteractionController {
return null;
}
View foundView = root.findViewByAccessibilityId(accessibilityId);
- if (foundView != null && !foundView.isDisplayedOnScreen()) {
+ if (foundView != null && !isShown(foundView)) {
return null;
}
return foundView;
@@ -670,7 +680,7 @@ final class AccessibilityInteractionController {
}
View child = children.getChildAt(i);
if (child.getAccessibilityViewId() != current.getAccessibilityViewId()
- && child.isDisplayedOnScreen()) {
+ && isShown(child)) {
AccessibilityNodeInfo info = null;
AccessibilityNodeProvider provider = child.getAccessibilityNodeProvider();
if (provider == null) {
@@ -706,7 +716,7 @@ final class AccessibilityInteractionController {
return;
}
View child = children.getChildAt(i);
- if (child.isDisplayedOnScreen()) {
+ if (isShown(child)) {
AccessibilityNodeProvider provider = child.getAccessibilityNodeProvider();
if (provider == null) {
AccessibilityNodeInfo info = child.createAccessibilityNodeInfo();