Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a9549d29 authored by Miranda Kephart's avatar Miranda Kephart
Browse files

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
parent 2438ebe2
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -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<ScreenshotActionChip> 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