summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Hiroki Sato <hirokisato@google.com> 2024-01-16 23:41:43 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-01-16 23:41:43 +0000
commit0d2ed528c3997ee3e48c22ecdd917c4f3d0d634a (patch)
tree00d4a3228d119922102957ddc3e70eeaff36abef
parent91367a7db89db5239ea69d4fb5a70d3652a2c1a7 (diff)
parent331300d50819d389db7dd726e1c5b611ce1ecf78 (diff)
Merge "Improve window content change events merging from multiple views" into main
-rw-r--r--core/java/android/view/View.java1
-rw-r--r--core/java/android/view/ViewRootImpl.java41
-rw-r--r--core/java/android/view/accessibility/flags/accessibility_flags.aconfig7
3 files changed, 41 insertions, 8 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 257ecc565c87..c98d1d7ecaea 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -15015,6 +15015,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
}
/** @hide */
+ @Nullable
View getSelfOrParentImportantForA11y() {
if (isImportantForAccessibility()) return this;
ViewParent parent = getParentForAccessibility();
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index c66f3c8032fd..34b467008232 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -87,6 +87,7 @@ import static android.view.WindowManager.PROPERTY_COMPAT_ALLOW_SANDBOXING_VIEW_B
import static android.view.WindowManagerGlobal.RELAYOUT_RES_CANCEL_AND_REDRAW;
import static android.view.WindowManagerGlobal.RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS;
import static android.view.WindowManagerGlobal.RELAYOUT_RES_SURFACE_CHANGED;
+import static android.view.accessibility.Flags.fixMergedContentChangeEvent;
import static android.view.accessibility.Flags.forceInvertColor;
import static android.view.accessibility.Flags.reduceWindowContentChangedEventThrottle;
import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceProto.ClientSideProto.IME_FOCUS_CONTROLLER;
@@ -11509,6 +11510,15 @@ public final class ViewRootImpl implements ViewParent,
event.setContentChangeTypes(mChangeTypes);
if (mAction.isPresent()) event.setAction(mAction.getAsInt());
if (AccessibilityEvent.DEBUG_ORIGIN) event.originStackTrace = mOrigin;
+
+ if (fixMergedContentChangeEvent()) {
+ if ((mChangeTypes & AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE) != 0) {
+ final View importantParent = source.getSelfOrParentImportantForA11y();
+ if (importantParent != null) {
+ source = importantParent;
+ }
+ }
+ }
source.sendAccessibilityEventUnchecked(event);
} else {
mLastEventTimeMillis = 0;
@@ -11543,14 +11553,29 @@ public final class ViewRootImpl implements ViewParent,
}
if (mSource != null) {
- // If there is no common predecessor, then mSource points to
- // a removed view, hence in this case always prefer the source.
- View predecessor = getCommonPredecessor(mSource, source);
- if (predecessor != null) {
- predecessor = predecessor.getSelfOrParentImportantForA11y();
- }
- mSource = (predecessor != null) ? predecessor : source;
- mChangeTypes |= changeType;
+ if (fixMergedContentChangeEvent()) {
+ View newSource = getCommonPredecessor(mSource, source);
+ if (newSource == null) {
+ // If there is no common predecessor, then mSource points to
+ // a removed view, hence in this case always prefer the source.
+ newSource = source;
+ }
+
+ mChangeTypes |= changeType;
+ if (mSource != newSource) {
+ mChangeTypes |= AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE;
+ mSource = newSource;
+ }
+ } else {
+ // If there is no common predecessor, then mSource points to
+ // a removed view, hence in this case always prefer the source.
+ View predecessor = getCommonPredecessor(mSource, source);
+ if (predecessor != null) {
+ predecessor = predecessor.getSelfOrParentImportantForA11y();
+ }
+ mSource = (predecessor != null) ? predecessor : source;
+ mChangeTypes |= changeType;
+ }
final int performingAction = mAccessibilityManager.getPerformingAction();
if (performingAction != 0) {
diff --git a/core/java/android/view/accessibility/flags/accessibility_flags.aconfig b/core/java/android/view/accessibility/flags/accessibility_flags.aconfig
index c7355c144c5f..efae57c9946c 100644
--- a/core/java/android/view/accessibility/flags/accessibility_flags.aconfig
+++ b/core/java/android/view/accessibility/flags/accessibility_flags.aconfig
@@ -53,6 +53,13 @@ flag {
flag {
namespace: "accessibility"
+ name: "fix_merged_content_change_event"
+ description: "Fixes event type and source of content change event merged in ViewRootImpl"
+ bug: "277305460"
+}
+
+flag {
+ namespace: "accessibility"
name: "flash_notification_system_api"
description: "Makes flash notification APIs as system APIs for calling from mainline module"
bug: "303131332"