From a9549d29f644592a79acb7ffc793ec2564d453c6 Mon Sep 17 00:00:00 2001 From: Miranda Kephart Date: Wed, 17 Nov 2021 13:32:42 -0500 Subject: [PATCH] Dispose of input event reciever along with monitor Explicitly store a reference to the input event receiver so that we can dispose of it at the same time as the input monitor. Bug: 206809961 Fix: 206809961 Test: manual Change-Id: Id201891ffd546119b18b18b692dd87008f6735c2 --- .../android/systemui/screenshot/ScreenshotView.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java index 3314c75b5a867..85725464ad72b 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java @@ -86,6 +86,7 @@ import androidx.constraintlayout.widget.ConstraintLayout; import com.android.internal.logging.UiEventLogger; import com.android.systemui.R; import com.android.systemui.screenshot.ScreenshotController.SavedImageData.ActionTransition; +import com.android.systemui.shared.system.InputChannelCompat; import com.android.systemui.shared.system.InputMonitorCompat; import com.android.systemui.shared.system.QuickStepContract; @@ -162,6 +163,7 @@ public class ScreenshotView extends FrameLayout implements private GestureDetector mSwipeDetector; private SwipeDismissHandler mSwipeDismissHandler; private InputMonitorCompat mInputMonitor; + private InputChannelCompat.InputEventReceiver mInputEventReceiver; private boolean mShowScrollablePreview; private final ArrayList mSmartChips = new ArrayList<>(); @@ -301,8 +303,8 @@ public class ScreenshotView extends FrameLayout implements private void startInputListening() { stopInputListening(); mInputMonitor = new InputMonitorCompat("Screenshot", Display.DEFAULT_DISPLAY); - mInputMonitor.getInputReceiver(Looper.getMainLooper(), Choreographer.getInstance(), - ev -> { + mInputEventReceiver = mInputMonitor.getInputReceiver( + Looper.getMainLooper(), Choreographer.getInstance(), ev -> { if (ev instanceof MotionEvent) { MotionEvent event = (MotionEvent) ev; if (event.getActionMasked() == MotionEvent.ACTION_DOWN @@ -319,6 +321,10 @@ public class ScreenshotView extends FrameLayout implements mInputMonitor.dispose(); mInputMonitor = null; } + if (mInputEventReceiver != null) { + mInputEventReceiver.dispose(); + mInputEventReceiver = null; + } } @Override // ViewGroup