diff options
| author | Qasid Ahmad Sadiq <qasid@google.com> | 2019-04-23 16:03:08 -0700 |
|---|---|---|
| committer | Qasid Ahmad Sadiq <qasid@google.com> | 2019-05-08 15:56:24 -0700 |
| commit | 518520b8578c1d8ec0a6d04ec8907e66aa51a284 (patch) | |
| tree | ed3ffffc85f2a9bb9c07e5e7fa9037571212a67c /core/java/android | |
| parent | ed16de4cdb722800978c0442697488ec13b7e0ea (diff) | |
AccessibilityEvents for visibility changes should be subtree events.
We don't report hidden views to the AccessibilityService (see ViewGroup.java).
Therefore changes to visibility are changes to the Accessibility Tree, and should be treated as such.
Because AccessibilityEvents aren't sent for hidden views, previously, hiding of views wouldn't be reported to the accessibility service, which is a pretty bad bug.
Test: Added CTS Test in another CL. Played around with this build for a while.
Bug: 130273130
Change-Id: Ie2021f1926bfe9e67e9aaa25a12c2e7cbfc74500
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/view/View.java | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index b0ba42a6f369..13da8508d3ff 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -15608,8 +15608,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) void setFlags(int flags, int mask) { - final boolean accessibilityEnabled = - AccessibilityManager.getInstance(mContext).isEnabled(); + final boolean accessibilityEnabled = AccessibilityManager.getInstance(mContext).isEnabled(); final boolean oldIncludeForAccessibility = accessibilityEnabled && includeForAccessibility(); int old = mViewFlags; @@ -15824,19 +15823,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (accessibilityEnabled) { // If we're an accessibility pane and the visibility changed, we already have sent // a state change, so we really don't need to report other changes. - if (isAccessibilityPane()) { - changed &= ~VISIBILITY_MASK; - } - if ((changed & FOCUSABLE) != 0 || (changed & VISIBILITY_MASK) != 0 + // Accessibility Services aren't concerned with changes between GONE and INVISIBLE. + boolean visibilityChanged = !isAccessibilityPane() && ((changed & VISIBILITY_MASK) != 0) + && ((old & VISIBILITY_MASK) == VISIBLE || newVisibility == VISIBLE); + if (oldIncludeForAccessibility != includeForAccessibility() || visibilityChanged) { + notifySubtreeAccessibilityStateChangedIfNeeded(); + } else if ((changed & ENABLED_MASK) != 0 || (changed & FOCUSABLE) != 0 || (changed & CLICKABLE) != 0 || (changed & LONG_CLICKABLE) != 0 || (changed & CONTEXT_CLICKABLE) != 0) { - if (oldIncludeForAccessibility != includeForAccessibility()) { - notifySubtreeAccessibilityStateChangedIfNeeded(); - } else { - notifyViewAccessibilityStateChangedIfNeeded( - AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED); - } - } else if ((changed & ENABLED_MASK) != 0) { notifyViewAccessibilityStateChangedIfNeeded( AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED); } |
