From 4f9990471183f5029f57c7a18c02f11b0a2796a9 Mon Sep 17 00:00:00 2001 From: Robert Horvath Date: Tue, 26 Apr 2022 15:16:03 +0200 Subject: [PATCH] Fix re-registering PositionUpdateListener Nulls out `info.mPositionUpdateListener` after unregistering the Listener, allowing a new PositionUpdateListener to be registered later. `addPositionUpdateListener` was only called if `info.mPositionUpdateListener` is non-null. The Listener is first created and registered if the system needs to keep track of the View's bounds (eg. if it is marked as a keep clear area). If the system no longer needs to keep track of the View's bounds, the Listener is unregistered, but wasn't set to `null`. When the system later needs to receive updates about the View's bounds again, the listener failed to be re-registered because it was non-null. Bug: 226583836 Test: Manual, check position updates of View Change-Id: Ia494e84843a9954e368d76a000f5f725e3a58df1 --- core/java/android/view/View.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index cf5727ea1342e..34493924f5e40 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -11752,6 +11752,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, && (info.mHandwritingArea == null || !isAutoHandwritingEnabled())) { if (info.mPositionUpdateListener != null) { mRenderNode.removePositionUpdateListener(info.mPositionUpdateListener); + info.mPositionUpdateListener = null; info.mPositionChangedUpdate = null; } } else {