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

Commit b4e04acd authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

Pointer Icon Refactor: Use new setPointerIcon API for stylus handwriting

Bug: 293587049
Test: manual
Change-Id: I7239adba7def64297e32ab65dfa2064dbd9921f4
parent 660ad30b
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -23,7 +23,9 @@ import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.UiThread;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManagerInternal;
import android.hardware.input.InputManager;
import android.hardware.input.InputManagerGlobal;
import android.os.Handler;
import android.os.IBinder;
@@ -64,6 +66,7 @@ final class HandwritingModeController {
    private static final int LONG_EVENT_BUFFER_SIZE = EVENT_BUFFER_SIZE * 20;
    private static final long HANDWRITING_DELEGATION_IDLE_TIMEOUT_MS = 3000;

    private final Context mContext;
    // This must be the looper for the UiThread.
    private final Looper mLooper;
    private final InputManagerInternal mInputManagerInternal;
@@ -87,7 +90,9 @@ final class HandwritingModeController {
    private int mCurrentRequestId;

    @AnyThread
    HandwritingModeController(Looper uiThreadLooper, Runnable inkWindowInitRunnable) {
    HandwritingModeController(Context context, Looper uiThreadLooper,
            Runnable inkWindowInitRunnable) {
        mContext = context;
        mLooper = uiThreadLooper;
        mCurrentDisplayId = Display.INVALID_DISPLAY;
        mInputManagerInternal = LocalServices.getService(InputManagerInternal.class);
@@ -285,7 +290,14 @@ final class HandwritingModeController {
        mHandwritingSurface.startIntercepting(imePid, imeUid);

        // Unset the pointer icon for the stylus in case the app had set it.
        if (com.android.input.flags.Flags.enablePointerChoreographer()) {
            Objects.requireNonNull(mContext.getSystemService(InputManager.class)).setPointerIcon(
                    PointerIcon.getSystemIcon(mContext, PointerIcon.TYPE_NOT_SPECIFIED),
                    downEvent.getDisplayId(), downEvent.getDeviceId(), downEvent.getPointerId(0),
                    mHandwritingSurface.getInputChannel().getToken());
        } else {
            InputManagerGlobal.getInstance().setPointerIconType(PointerIcon.TYPE_NOT_SPECIFIED);
        }

        return new HandwritingSession(mCurrentRequestId, mHandwritingSurface.getInputChannel(),
                mHandwritingBuffer);
+1 −1
Original line number Diff line number Diff line
@@ -1713,7 +1713,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                com.android.internal.R.bool.config_preventImeStartupUnlessTextEditor);
        mNonPreemptibleInputMethods = mRes.getStringArray(
                com.android.internal.R.array.config_nonPreemptibleInputMethods);
        mHwController = new HandwritingModeController(thread.getLooper(),
        mHwController = new HandwritingModeController(mContext, thread.getLooper(),
                new InkWindowInitializer());
        registerDeviceListenerAndCheckStylusSupport();
    }