Fix inconsitency in aAccessibilityNodeInfo cache.
1. Fixed errors in the accessibility node cache.
A. The cache was not catching the case when the current window changes as a
result the user touch exploring it. As a result the cache had nodes from
more that one window but the node ids are not unique thus causing a mess.
B. The node info tree was prefetched regardless if a prefetched node is root
name space (i.e. view ids - not accessibility ids - are namespaced) while
the prefetched nodes were taking this into account. As a result there can
get disconnected subtrees in the cache.
C. When an event for a property change such as focus was received the cache
we were removing the source node. As a result there may be disconnected nodes.
D. When a node was added to the cache and an older version exists there was
no check if it will point to the same children and parent. As a result if
the state of the node has fewer children the subtrees rooted at the no
longer present children will stay disconnected in the cache.
E. When a node got accessibility or input focus the old one in the cache was
not removed. As a result you may have a state with more than one access
or input focus.
2. Added integrity check enabled only on user builds when a specific flag is set
for the cache which checks whether:
A. All nodes are from the same window.
B. All nodes are connected.
C. There are no duplicates.
D. There is only one input focus.
E. There is only one accessibility focus.
3. The reported accessibility node info tree was stopping at the root namespace
boundary which is not correct. The reported tree has to reflect everything
on the screen that the user can see such a workspace with widgets. The root
namespace is added to avoid clash of view id but the accessibility ids are
unique no matter if the view is inflated from a remote view.
4. Added calls to notify the accessibility layer when a preoprty that is interesting
for accessibiliy has changed.
bug:6471710
Change-Id: I069470d91f209ba16313fa6539787a55efa3512e
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index bf7d037..85fd8fe 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -4723,11 +4723,9 @@
getBoundsOnScreen(bounds);
info.setBoundsInScreen(bounds);
- if ((mPrivateFlags & IS_ROOT_NAMESPACE) == 0) {
- ViewParent parent = getParentForAccessibility();
- if (parent instanceof View) {
- info.setParent((View) parent);
- }
+ ViewParent parent = getParentForAccessibility();
+ if (parent instanceof View) {
+ info.setParent((View) parent);
}
info.setVisibleToUser(isVisibleToUser());
@@ -6503,6 +6501,9 @@
* that is interesting for accessilility purposes.
*/
public void notifyAccessibilityStateChanged() {
+ if (!AccessibilityManager.getInstance(mContext).isEnabled()) {
+ return;
+ }
if ((mPrivateFlags2 & ACCESSIBILITY_STATE_CHANGED) == 0) {
mPrivateFlags2 |= ACCESSIBILITY_STATE_CHANGED;
if (mParent != null) {