summaryrefslogtreecommitdiff
path: root/core/java/android/view/View.java
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2021-05-25 23:04:21 -0700
committerWinson Chung <winsonc@google.com>2021-05-26 16:57:49 +0000
commit36f8ff7f8534936de0eb7c8609a9442514baede2 (patch)
tree8efe2645b1c42a65f431a5af93fc28d2b63b75e9 /core/java/android/view/View.java
parent5eef4114802da5e5386f8092098551b2a2f52db3 (diff)
Always copy provided gesture exclusion rects
- Disallow callers from concurrently modifying the exclusion rects list after it's set by making a copy. Bug: 166594759 Test: atest android.view.cts.SystemGestureExclusionRectsTest Change-Id: I80183cf85d16ac669320cfda9ec9deed9e348e33
Diffstat (limited to 'core/java/android/view/View.java')
-rw-r--r--core/java/android/view/View.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index acc0fc178d6e..ed4ef87df804 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -4721,9 +4721,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
WindowInsetsAnimation.Callback mWindowInsetsAnimationCallback;
/**
- * This lives here since it's only valid for interactive views.
+ * This lives here since it's only valid for interactive views. This list is null until the
+ * first use.
*/
- private List<Rect> mSystemGestureExclusionRects;
+ private List<Rect> mSystemGestureExclusionRects = null;
/**
* Used to track {@link #mSystemGestureExclusionRects}
@@ -11581,8 +11582,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* a precision touch gesture in a small area in either the X or Y dimension, such as
* an edge swipe or dragging a <code>SeekBar</code> thumb.</p>
*
- * <p>Do not modify the provided list after this method is called.</p>
- *
* <p>Note: the system will put a limit of <code>200dp</code> on the vertical extent of the
* exclusions it takes into account. The limit does not apply while the navigation
* bar is {@link #SYSTEM_UI_FLAG_IMMERSIVE_STICKY stickily} hidden, nor to the
@@ -11596,13 +11595,17 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
if (rects.isEmpty() && mListenerInfo == null) return;
final ListenerInfo info = getListenerInfo();
+ if (info.mSystemGestureExclusionRects != null) {
+ info.mSystemGestureExclusionRects.clear();
+ info.mSystemGestureExclusionRects.addAll(rects);
+ } else {
+ info.mSystemGestureExclusionRects = new ArrayList<>(rects);
+ }
if (rects.isEmpty()) {
- info.mSystemGestureExclusionRects = null;
if (info.mPositionUpdateListener != null) {
mRenderNode.removePositionUpdateListener(info.mPositionUpdateListener);
}
} else {
- info.mSystemGestureExclusionRects = rects;
if (info.mPositionUpdateListener == null) {
info.mPositionUpdateListener = new RenderNode.PositionUpdateListener() {
@Override