From 342509f09402284912fb894175ad414b977a81b8 Mon Sep 17 00:00:00 2001 From: Taran Singh Date: Wed, 24 Nov 2021 03:33:15 +0000 Subject: Scribe in IMF: Early InkWindow preparation 6/N Allow stylus hover events for: 1. send early signal to IME onPrepareStylusHandwriting() 2. Prepare InkWindow internally. Test: atest StylusHandwritingTest Bug: 210039666 Bug: 203086136 Change-Id: Iebbd62659cb98b3c61edfa35d5a84a1c6837eb23 --- .../inputmethodservice/InputMethodService.java | 32 +++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'core/java/android/inputmethodservice/InputMethodService.java') diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 80da3617d4a4..4fd375177d6f 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -742,6 +742,10 @@ public class InputMethodService extends AbstractInputMethodService { onUnbindInput(); mInputBinding = null; mInputConnection = null; + // free-up cached InkWindow surface on detaching from current client. + if (mInkWindow != null) { + mInkWindow.hide(true /* remove */); + } } /** @@ -902,6 +906,10 @@ public class InputMethodService extends AbstractInputMethodService { Log.d(TAG, "Input should have started before starting Stylus handwriting."); return; } + if (!mInkWindow.isInitialized()) { + // prepare hasn't been called by Stylus HOVER. + onPrepareStylusHandwriting(); + } if (onStartStylusHandwriting()) { mPrivOps.onStylusHandwritingReady(requestId); } else { @@ -947,6 +955,16 @@ public class InputMethodService extends AbstractInputMethodService { } + /** + * {@inheritDoc} + * @hide + */ + @Override + public void initInkWindow() { + mInkWindow.initOnly(); + onPrepareStylusHandwriting(); + } + /** * {@inheritDoc} */ @@ -2318,7 +2336,19 @@ public class InputMethodService extends AbstractInputMethodService { } } } - + + /** + * Called to prepare stylus handwriting. + * The system calls this before the first {@link #onStartStylusHandwriting} request. + * + *

Note: The system tries to call this as early as possible, when it detects that + * handwriting stylus input is imminent. However, that a subsequent call to + * {@link #onStartStylusHandwriting} actually happens is not guaranteed.

+ */ + public void onPrepareStylusHandwriting() { + // Intentionally empty + } + /** * Called when an app requests stylus handwriting * {@link InputMethodManager#startStylusHandwriting(View)}. -- cgit v1.2.3