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

Commit b3ebbe58 authored by Taran Singh's avatar Taran Singh
Browse files

Clear handwriting delegation once its started

Handwriting delegation can fail to start if stylus stroke on delegate is
short. This happens because IMMS.startStylusHandwriting clears delegation early
and an immediate ACTION_UP can stop recording gesture before
HandwritingModeController gets startHandwriting signal.

We should clear delegation once handwriting has started.

Bug: 293305048
Test: StylusHandwritingTest
Change-Id: I37b90ff0a236aa8670972f5d8d77fbecbe65a5f2
parent 7951f5d1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -235,6 +235,7 @@ final class HandwritingModeController {
    @Nullable
    HandwritingSession startHandwritingSession(
            int requestId, int imePid, int imeUid, IBinder focusedWindowToken) {
        clearPendingHandwritingDelegation();
        if (mHandwritingSurface == null) {
            Slog.e(TAG, "Cannot start handwriting session: Handwriting was not initialized.");
            return null;
+8 −2
Original line number Diff line number Diff line
@@ -3432,13 +3432,19 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
    @BinderThread
    @Override
    public void startStylusHandwriting(IInputMethodClient client) {
        startStylusHandwriting(client, false /* usesDelegation */);
    }

    private void startStylusHandwriting(IInputMethodClient client, boolean usesDelegation) {
        Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.startStylusHandwriting");
        try {
            ImeTracing.getInstance().triggerManagerServiceDump(
                    "InputMethodManagerService#startStylusHandwriting");
            int uid = Binder.getCallingUid();
            synchronized (ImfLock.class) {
                if (!usesDelegation) {
                    mHwController.clearPendingHandwritingDelegation();
                }
                if (!canInteractWithImeLocked(uid, client, "startStylusHandwriting",
                        null /* statsToken */)) {
                    return;
@@ -3520,7 +3526,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
            return false;
        }

        startStylusHandwriting(client);
        startStylusHandwriting(client, true /* usesDelegation */);
        return true;
    }