From d9f2151ae780456e28d647e42cac4df76b591b7d Mon Sep 17 00:00:00 2001 From: Qasid Sadiq Date: Tue, 21 May 2019 23:51:40 +0000 Subject: [PATCH] Revert "AccessibilityEvents for visibility changes should be subtree events." This reverts commit 518520b8578c1d8ec0a6d04ec8907e66aa51a284. Reason for revert: This change doesn't solve the issue. Change-Id: Iaa473eb2e3698b137c455cb09800179274a28cfb --- core/java/android/view/View.java | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 13da8508d3ffc..b0ba42a6f3695 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -15608,7 +15608,8 @@ 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; @@ -15823,14 +15824,19 @@ 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. - // 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 + if (isAccessibilityPane()) { + changed &= ~VISIBILITY_MASK; + } + if ((changed & FOCUSABLE) != 0 || (changed & VISIBILITY_MASK) != 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); }