diff --git a/core/java/android/inputmethodservice/InkWindow.java b/core/java/android/inputmethodservice/InkWindow.java index 83b053aaa0347..499634ae5bec9 100644 --- a/core/java/android/inputmethodservice/InkWindow.java +++ b/core/java/android/inputmethodservice/InkWindow.java @@ -102,11 +102,4 @@ final class InkWindow extends PhoneWindow { lp.token = token; setAttributes(lp); } - - /** - * Returns {@code true} if Window was created and added to WM. - */ - boolean isInitialized() { - return mIsViewAdded; - } } diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index b6e1b1f1fa3fd..adf2759a8cd8a 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -578,6 +578,7 @@ public class InputMethodService extends AbstractInputMethodService { private boolean mImeSurfaceScheduledForRemoval; private ImsConfigurationTracker mConfigTracker = new ImsConfigurationTracker(); private boolean mDestroyed; + private boolean mOnPreparedStylusHwCalled; /** Stylus handwriting Ink window. */ private InkWindow mInkWindow; @@ -919,9 +920,10 @@ public class InputMethodService extends AbstractInputMethodService { Log.d(TAG, "Input should have started before starting Stylus handwriting."); return; } - if (!mInkWindow.isInitialized()) { + if (!mOnPreparedStylusHwCalled) { // prepare hasn't been called by Stylus HOVER. onPrepareStylusHandwriting(); + mOnPreparedStylusHwCalled = true; } if (onStartStylusHandwriting()) { mPrivOps.onStylusHandwritingReady(requestId); @@ -976,6 +978,7 @@ public class InputMethodService extends AbstractInputMethodService { public void initInkWindow() { mInkWindow.initOnly(); onPrepareStylusHandwriting(); + mOnPreparedStylusHwCalled = true; } /** @@ -2354,7 +2357,7 @@ public class InputMethodService extends AbstractInputMethodService { /** * Called to prepare stylus handwriting. - * The system calls this before the first {@link #onStartStylusHandwriting} request. + * The system calls this before the {@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 @@ -2438,6 +2441,7 @@ public class InputMethodService extends AbstractInputMethodService { mInkWindow.hide(false /* remove */); mPrivOps.finishStylusHandwriting(requestId); + mOnPreparedStylusHwCalled = false; onFinishStylusHandwriting(); }