summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2012-04-09 17:39:00 -0700
committerSvetoslav Ganov <svetoslavganov@google.com>2012-04-12 12:51:27 -0700
commitaa6f3de253db6c0702de0cc40028750c1fcfb22c (patch)
tree7a05c61637d95bbaa2544892c9e8bcc267851924
parenta379eeca242beb86591ba349784336aa65c8592b (diff)
downloadframeworks_base-aa6f3de253db6c0702de0cc40028750c1fcfb22c.zip
frameworks_base-aa6f3de253db6c0702de0cc40028750c1fcfb22c.tar.gz
frameworks_base-aa6f3de253db6c0702de0cc40028750c1fcfb22c.tar.bz2
Some view not shown on the screen are reported for accessibility.
1. Some applications are keeping around visible views off screen to improve responsiveness by drawing them in layers, etc. While such a view is not visible on the screen the accessibility layer was reporting it since it was visible. Now the check is improved to verify whether the view is attached, is in visible window, is visible, and has a rectangle that is not clipped by its predecessors. 2. AccessibilityNodeInfo bounds in screen were not properly set since only the top left point was offset appropriately to take into account any predecessor's transformation matrix and the not transformed width and height were used. Now the bounds are properly offset. bug:6291855 Change-Id: I244d1d9af81391676c1c9e0fe86cf4574ff37225
-rw-r--r--core/java/android/view/View.java6
-rw-r--r--core/java/android/view/ViewRootImpl.java27
2 files changed, 22 insertions, 11 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index d62e32f..53e8934 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -4483,10 +4483,8 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
getDrawingRect(bounds);
info.setBoundsInParent(bounds);
- int[] locationOnScreen = mAttachInfo.mInvalidateChildLocation;
- getLocationOnScreen(locationOnScreen);
- bounds.offsetTo(0, 0);
- bounds.offset(locationOnScreen[0], locationOnScreen[1]);
+ getGlobalVisibleRect(bounds);
+ bounds.offset(mAttachInfo.mWindowLeft, mAttachInfo.mWindowTop);
info.setBoundsInScreen(bounds);
if ((mPrivateFlags & IS_ROOT_NAMESPACE) == 0) {
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 899fb32..2e3ff38 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -5065,6 +5065,19 @@ public final class ViewRootImpl implements ViewParent,
}
/**
+ * Computes whether a view is visible on the screen.
+ *
+ * @param view The view to check.
+ * @return Whether the view is visible on the screen.
+ */
+ private boolean isDisplayedOnScreen(View view) {
+ return (view.mAttachInfo != null
+ && view.mAttachInfo.mWindowVisibility == View.VISIBLE
+ && view.getVisibility() == View.VISIBLE
+ && view.getGlobalVisibleRect(mTempRect));
+ }
+
+ /**
* Class for managing accessibility interactions initiated from the system
* and targeting the view hierarchy. A *ClientThread method is to be
* called from the interaction connection this ViewAncestor gives the
@@ -5175,7 +5188,7 @@ public final class ViewRootImpl implements ViewParent,
} else {
target = findViewByAccessibilityId(accessibilityViewId);
}
- if (target != null && target.getVisibility() == View.VISIBLE) {
+ if (target != null && isDisplayedOnScreen(target)) {
getAccessibilityNodePrefetcher().prefetchAccessibilityNodeInfos(target,
virtualDescendantId, prefetchFlags, infos);
}
@@ -5231,7 +5244,7 @@ public final class ViewRootImpl implements ViewParent,
}
if (root != null) {
View target = root.findViewById(viewId);
- if (target != null && target.getVisibility() == View.VISIBLE) {
+ if (target != null && isDisplayedOnScreen(target)) {
info = target.createAccessibilityNodeInfo();
}
}
@@ -5287,7 +5300,7 @@ public final class ViewRootImpl implements ViewParent,
} else {
target = ViewRootImpl.this.mView;
}
- if (target != null && target.getVisibility() == View.VISIBLE) {
+ if (target != null && isDisplayedOnScreen(target)) {
AccessibilityNodeProvider provider = target.getAccessibilityNodeProvider();
if (provider != null) {
infos = provider.findAccessibilityNodeInfosByText(text,
@@ -5304,7 +5317,7 @@ public final class ViewRootImpl implements ViewParent,
final int viewCount = foundViews.size();
for (int i = 0; i < viewCount; i++) {
View foundView = foundViews.get(i);
- if (foundView.getVisibility() == View.VISIBLE) {
+ if (isDisplayedOnScreen(foundView)) {
provider = foundView.getAccessibilityNodeProvider();
if (provider != null) {
List<AccessibilityNodeInfo> infosFromProvider =
@@ -5367,7 +5380,7 @@ public final class ViewRootImpl implements ViewParent,
boolean succeeded = false;
try {
View target = findViewByAccessibilityId(accessibilityViewId);
- if (target != null && target.getVisibility() == View.VISIBLE) {
+ if (target != null && isDisplayedOnScreen(target)) {
AccessibilityNodeProvider provider = target.getAccessibilityNodeProvider();
if (provider != null) {
succeeded = provider.performAccessibilityAction(action,
@@ -5505,7 +5518,7 @@ public final class ViewRootImpl implements ViewParent,
View child = parentGroup.getChildAt(i);
if (outInfos.size() < MAX_ACCESSIBILITY_NODE_INFO_BATCH_SIZE
&& child.getAccessibilityViewId() != current.getAccessibilityViewId()
- && child.getVisibility() == View.VISIBLE) {
+ && isDisplayedOnScreen(child)) {
final long childNodeId = AccessibilityNodeInfo.makeNodeId(
child.getAccessibilityViewId(), AccessibilityNodeInfo.UNDEFINED);
AccessibilityNodeInfo info = null;
@@ -5533,7 +5546,7 @@ public final class ViewRootImpl implements ViewParent,
final int childCount = rootGroup.getChildCount();
for (int i = 0; i < childCount; i++) {
View child = rootGroup.getChildAt(i);
- if (child.getVisibility() == View.VISIBLE
+ if (isDisplayedOnScreen(child)
&& outInfos.size() < MAX_ACCESSIBILITY_NODE_INFO_BATCH_SIZE) {
final long childNodeId = AccessibilityNodeInfo.makeNodeId(
child.getAccessibilityViewId(), AccessibilityNodeInfo.UNDEFINED);