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

Commit 980ed5e0 authored by Harry Cutts's avatar Harry Cutts
Browse files

ViewRootImpl: call requestPointerCapture through InputManager

We're trying to get rid of InputManagerGlobal#getInstance.

Bug: 403531245
Test: check that a test app can still request and release capture, and
      receives events as appropriate in each state
Test: $ atest CtsInputTestCases:android.input.cts.\
              {TouchpadAbsoluteCaptureModeTest,MouseCaptureTest}
Flag: EXEMPT refactor
Change-Id: If3e2b6da5103ed80dc7f5d4d506d951af5806a98
parent ef2ca3a1
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ import android.annotation.SystemService;
import android.annotation.TestApi;
import android.annotation.UserHandleAware;
import android.annotation.UserIdInt;
import android.app.ActivityThread;
import android.compat.annotation.ChangeId;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
@@ -67,7 +66,6 @@ import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Executor;

/**
+1 −1
Original line number Diff line number Diff line
@@ -1728,7 +1728,7 @@ public final class InputManagerGlobal {
    }

    /**
     * @see InputManager#requestPointerCapture(IBinder, boolean)
     * @see android.view.View#requestPointerCapture()
     */
    public void requestPointerCapture(IBinder windowToken, boolean enable) {
        try {
+7 −3
Original line number Diff line number Diff line
@@ -190,6 +190,7 @@ import android.graphics.drawable.GradientDrawable;
import android.hardware.SyncFence;
import android.hardware.display.DisplayManager.DisplayListener;
import android.hardware.display.DisplayManagerGlobal;
import android.hardware.input.InputManager;
import android.hardware.input.InputManagerGlobal;
import android.hardware.input.InputSettings;
import android.media.AudioManager;
@@ -6431,9 +6432,12 @@ public final class ViewRootImpl implements ViewParent,
            Log.e(mTag, "No input channel to request Pointer Capture.");
            return;
        }
        InputManagerGlobal
                .getInstance()
                .requestPointerCapture(inputToken, enabled);
        final InputManager inputManager = mContext.getSystemService(InputManager.class);
        if (inputManager == null) {
            Log.e(mTag, "Missing InputManager; cannot request pointer capture.");
            return;
        }
        inputManager.requestPointerCapture(inputToken, enabled);
    }
    private void handlePointerCaptureChanged(boolean hasCapture) {