summaryrefslogtreecommitdiff
path: root/core/java/android/inputmethodservice/InputMethodService.java
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2022-01-27 10:32:06 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2022-01-27 10:32:06 +0000
commit4c4cd6f67089eee76f7cb961b34417386d630fc4 (patch)
treed1ffc2def547cd961d509a6bb29acbc95c840eb1 /core/java/android/inputmethodservice/InputMethodService.java
parent89048f95028c78b9d7928e01ffb602ca894f0913 (diff)
parent7fbcbf27c79dc7203236c13e1daee48bbb970fd5 (diff)
Merge changes from topics "CAI-filters", "onPrepareStylusHandwriting"
* changes: Scribe in IMF: Introduce filters in CursoAnchorInfo API 7/N Scribe in IMF: Early InkWindow preparation 6/N
Diffstat (limited to 'core/java/android/inputmethodservice/InputMethodService.java')
-rw-r--r--core/java/android/inputmethodservice/InputMethodService.java32
1 files changed, 31 insertions, 1 deletions
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 {
@@ -949,6 +957,16 @@ public class InputMethodService extends AbstractInputMethodService {
/**
* {@inheritDoc}
+ * @hide
+ */
+ @Override
+ public void initInkWindow() {
+ mInkWindow.initOnly();
+ onPrepareStylusHandwriting();
+ }
+
+ /**
+ * {@inheritDoc}
*/
@MainThread
@Override
@@ -2318,7 +2336,19 @@ public class InputMethodService extends AbstractInputMethodService {
}
}
}
-
+
+ /**
+ * Called to prepare stylus handwriting.
+ * The system calls this before the first {@link #onStartStylusHandwriting} request.
+ *
+ * <p>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.</p>
+ */
+ public void onPrepareStylusHandwriting() {
+ // Intentionally empty
+ }
+
/**
* Called when an app requests stylus handwriting
* {@link InputMethodManager#startStylusHandwriting(View)}.