Loading core/api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -3145,6 +3145,7 @@ package android.view.inputmethod { method @NonNull @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) public java.util.List<android.view.inputmethod.InputMethodInfo> getInputMethodListAsUser(int); method public boolean hasActiveInputConnection(@Nullable android.view.View); method public boolean isInputMethodPickerShown(); method @RequiresPermission("android.permission.TEST_INPUT_METHOD") public void setStylusWindowIdleTimeoutForTest(long); field public static final long CLEAR_SHOW_FORCED_FLAG_WHEN_LEAVING = 214016041L; // 0xcc1a029L } Loading core/java/android/inputmethodservice/IInputMethodWrapper.java +17 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.inputmethodservice; import android.annotation.BinderThread; import android.annotation.DurationMillisLong; import android.annotation.MainThread; import android.annotation.NonNull; import android.annotation.Nullable; Loading Loading @@ -82,6 +83,7 @@ class IInputMethodWrapper extends IInputMethod.Stub private static final int DO_FINISH_STYLUS_HANDWRITING = 130; private static final int DO_UPDATE_TOOL_TYPE = 140; private static final int DO_REMOVE_STYLUS_HANDWRITING_WINDOW = 150; private static final int DO_SET_STYLUS_WINDOW_IDLE_TIMEOUT = 160; final WeakReference<InputMethodServiceInternal> mTarget; final Context mContext; Loading Loading @@ -287,6 +289,10 @@ class IInputMethodWrapper extends IInputMethod.Stub } return; } case DO_SET_STYLUS_WINDOW_IDLE_TIMEOUT: { inputMethod.setStylusWindowIdleTimeoutForTest((long) msg.obj); return; } } Log.w(TAG, "Unhandled message code: " + msg.what); } Loading Loading @@ -473,6 +479,13 @@ class IInputMethodWrapper extends IInputMethod.Stub mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_REMOVE_STYLUS_HANDWRITING_WINDOW)); } @BinderThread @Override public void setStylusWindowIdleTimeoutForTest(@DurationMillisLong long timeout) { mCaller.executeOrSendMessage( mCaller.obtainMessageO(DO_SET_STYLUS_WINDOW_IDLE_TIMEOUT, timeout)); } private static boolean isValid(InputMethod inputMethod, InputMethodServiceInternal target, String msg) { if (inputMethod != null && target != null && !target.isServiceDestroyed()) { Loading core/java/android/inputmethodservice/InputMethodService.java +57 −5 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ import static java.lang.annotation.RetentionPolicy.SOURCE; import android.annotation.AnyThread; import android.annotation.CallSuper; import android.annotation.DrawableRes; import android.annotation.DurationMillisLong; import android.annotation.IntDef; import android.annotation.MainThread; import android.annotation.NonNull; Loading Loading @@ -363,6 +364,11 @@ public class InputMethodService extends AbstractInputMethodService { private static final long STYLUS_HANDWRITING_IDLE_TIMEOUT_MAX_MS = STYLUS_HANDWRITING_IDLE_TIMEOUT_MS * 3; /** * Stylus idle-timeout after which stylus {@code InkWindow} will be removed. */ private static final long STYLUS_WINDOW_IDLE_TIMEOUT_MILLIS = 5 * 60 * 1000; // 5 minutes. /** * A circular buffer of size MAX_EVENTS_BUFFER in case IME is taking too long to add ink view. **/ Loading @@ -373,6 +379,8 @@ public class InputMethodService extends AbstractInputMethodService { private Runnable mImeSurfaceRemoverRunnable; private Runnable mFinishHwRunnable; private long mStylusHwSessionsTimeout = STYLUS_HANDWRITING_IDLE_TIMEOUT_MS; private Runnable mStylusWindowIdleTimeoutRunnable; private long mStylusWindowIdleTimeoutForTest; /** * Returns whether {@link InputMethodService} is responsible for rendering the back button and Loading Loading @@ -1050,7 +1058,6 @@ public class InputMethodService extends AbstractInputMethodService { mInkWindow = new InkWindow(mWindow.getContext()); mInkWindow.setToken(mToken); } // TODO(b/243571274): set an idle-timeout after which InkWindow is removed. mInkWindow.initOnly(); } Loading @@ -1072,6 +1079,15 @@ public class InputMethodService extends AbstractInputMethodService { InputMethodService.this.removeStylusHandwritingWindow(); } /** * {@inheritDoc} * @hide */ @Override public void setStylusWindowIdleTimeoutForTest(@DurationMillisLong long timeout) { mStylusWindowIdleTimeoutForTest = timeout; } /** * {@inheritDoc} */ Loading Loading @@ -2508,6 +2524,11 @@ public class InputMethodService extends AbstractInputMethodService { }); } } // Create a stylus window idle-timeout after which InkWindow is removed. if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { scheduleStylusWindowIdleTimeout(); } } /** Loading Loading @@ -2568,7 +2589,6 @@ public class InputMethodService extends AbstractInputMethodService { mHandwritingEventReceiver.dispose(); mHandwritingEventReceiver = null; // TODO(b/243571274): set an idle-timeout after which InkWindow is removed. mInkWindow.hide(false /* remove */); mPrivOps.resetStylusHandwriting(requestId); Loading @@ -2592,10 +2612,42 @@ public class InputMethodService extends AbstractInputMethodService { } private void removeHandwritingInkWindow() { cancelStylusWindowIdleTimeout(); mOnPreparedStylusHwCalled = false; mStylusWindowIdleTimeoutRunnable = null; if (mInkWindow != null) { mInkWindow.hide(true /* remove */); mInkWindow.destroy(); mInkWindow = null; } } private void cancelStylusWindowIdleTimeout() { if (mStylusWindowIdleTimeoutRunnable != null && mHandler != null) { mHandler.removeCallbacks(mStylusWindowIdleTimeoutRunnable); } } private void scheduleStylusWindowIdleTimeout() { if (mHandler == null) { return; } cancelStylusWindowIdleTimeout(); long timeout = (mStylusWindowIdleTimeoutForTest > 0) ? mStylusWindowIdleTimeoutForTest : STYLUS_WINDOW_IDLE_TIMEOUT_MILLIS; mHandler.postDelayed(getStylusWindowIdleTimeoutRunnable(), timeout); } private Runnable getStylusWindowIdleTimeoutRunnable() { if (mStylusWindowIdleTimeoutRunnable == null) { mStylusWindowIdleTimeoutRunnable = () -> { removeHandwritingInkWindow(); mStylusWindowIdleTimeoutRunnable = null; }; } return mStylusWindowIdleTimeoutRunnable; } /** * Sets the duration after which an ongoing stylus handwriting session that hasn't received new Loading core/java/android/view/inputmethod/IInputMethodManagerInvoker.java +11 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.view.inputmethod; import android.annotation.AnyThread; import android.annotation.DurationMillisLong; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UserIdInt; Loading Loading @@ -274,4 +275,14 @@ final class IInputMethodManagerInvoker { throw e.rethrowFromSystemServer(); } } @AnyThread void setStylusWindowIdleTimeoutForTest( IInputMethodClient client, @DurationMillisLong long timeout) { try { mTarget.setStylusWindowIdleTimeoutForTest(client, timeout); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } core/java/android/view/inputmethod/InputMethod.java +9 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.view.inputmethod; import android.annotation.DurationMillisLong; import android.annotation.MainThread; import android.annotation.NonNull; import android.annotation.Nullable; Loading Loading @@ -417,4 +418,12 @@ public interface InputMethod { default void removeStylusHandwritingWindow() { // intentionally empty } /** * Set a stylus idle-timeout after which handwriting {@code InkWindow} will be removed. * @hide */ default void setStylusWindowIdleTimeoutForTest(@DurationMillisLong long timeout) { // intentionally empty } } Loading
core/api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -3145,6 +3145,7 @@ package android.view.inputmethod { method @NonNull @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) public java.util.List<android.view.inputmethod.InputMethodInfo> getInputMethodListAsUser(int); method public boolean hasActiveInputConnection(@Nullable android.view.View); method public boolean isInputMethodPickerShown(); method @RequiresPermission("android.permission.TEST_INPUT_METHOD") public void setStylusWindowIdleTimeoutForTest(long); field public static final long CLEAR_SHOW_FORCED_FLAG_WHEN_LEAVING = 214016041L; // 0xcc1a029L } Loading
core/java/android/inputmethodservice/IInputMethodWrapper.java +17 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.inputmethodservice; import android.annotation.BinderThread; import android.annotation.DurationMillisLong; import android.annotation.MainThread; import android.annotation.NonNull; import android.annotation.Nullable; Loading Loading @@ -82,6 +83,7 @@ class IInputMethodWrapper extends IInputMethod.Stub private static final int DO_FINISH_STYLUS_HANDWRITING = 130; private static final int DO_UPDATE_TOOL_TYPE = 140; private static final int DO_REMOVE_STYLUS_HANDWRITING_WINDOW = 150; private static final int DO_SET_STYLUS_WINDOW_IDLE_TIMEOUT = 160; final WeakReference<InputMethodServiceInternal> mTarget; final Context mContext; Loading Loading @@ -287,6 +289,10 @@ class IInputMethodWrapper extends IInputMethod.Stub } return; } case DO_SET_STYLUS_WINDOW_IDLE_TIMEOUT: { inputMethod.setStylusWindowIdleTimeoutForTest((long) msg.obj); return; } } Log.w(TAG, "Unhandled message code: " + msg.what); } Loading Loading @@ -473,6 +479,13 @@ class IInputMethodWrapper extends IInputMethod.Stub mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_REMOVE_STYLUS_HANDWRITING_WINDOW)); } @BinderThread @Override public void setStylusWindowIdleTimeoutForTest(@DurationMillisLong long timeout) { mCaller.executeOrSendMessage( mCaller.obtainMessageO(DO_SET_STYLUS_WINDOW_IDLE_TIMEOUT, timeout)); } private static boolean isValid(InputMethod inputMethod, InputMethodServiceInternal target, String msg) { if (inputMethod != null && target != null && !target.isServiceDestroyed()) { Loading
core/java/android/inputmethodservice/InputMethodService.java +57 −5 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ import static java.lang.annotation.RetentionPolicy.SOURCE; import android.annotation.AnyThread; import android.annotation.CallSuper; import android.annotation.DrawableRes; import android.annotation.DurationMillisLong; import android.annotation.IntDef; import android.annotation.MainThread; import android.annotation.NonNull; Loading Loading @@ -363,6 +364,11 @@ public class InputMethodService extends AbstractInputMethodService { private static final long STYLUS_HANDWRITING_IDLE_TIMEOUT_MAX_MS = STYLUS_HANDWRITING_IDLE_TIMEOUT_MS * 3; /** * Stylus idle-timeout after which stylus {@code InkWindow} will be removed. */ private static final long STYLUS_WINDOW_IDLE_TIMEOUT_MILLIS = 5 * 60 * 1000; // 5 minutes. /** * A circular buffer of size MAX_EVENTS_BUFFER in case IME is taking too long to add ink view. **/ Loading @@ -373,6 +379,8 @@ public class InputMethodService extends AbstractInputMethodService { private Runnable mImeSurfaceRemoverRunnable; private Runnable mFinishHwRunnable; private long mStylusHwSessionsTimeout = STYLUS_HANDWRITING_IDLE_TIMEOUT_MS; private Runnable mStylusWindowIdleTimeoutRunnable; private long mStylusWindowIdleTimeoutForTest; /** * Returns whether {@link InputMethodService} is responsible for rendering the back button and Loading Loading @@ -1050,7 +1058,6 @@ public class InputMethodService extends AbstractInputMethodService { mInkWindow = new InkWindow(mWindow.getContext()); mInkWindow.setToken(mToken); } // TODO(b/243571274): set an idle-timeout after which InkWindow is removed. mInkWindow.initOnly(); } Loading @@ -1072,6 +1079,15 @@ public class InputMethodService extends AbstractInputMethodService { InputMethodService.this.removeStylusHandwritingWindow(); } /** * {@inheritDoc} * @hide */ @Override public void setStylusWindowIdleTimeoutForTest(@DurationMillisLong long timeout) { mStylusWindowIdleTimeoutForTest = timeout; } /** * {@inheritDoc} */ Loading Loading @@ -2508,6 +2524,11 @@ public class InputMethodService extends AbstractInputMethodService { }); } } // Create a stylus window idle-timeout after which InkWindow is removed. if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { scheduleStylusWindowIdleTimeout(); } } /** Loading Loading @@ -2568,7 +2589,6 @@ public class InputMethodService extends AbstractInputMethodService { mHandwritingEventReceiver.dispose(); mHandwritingEventReceiver = null; // TODO(b/243571274): set an idle-timeout after which InkWindow is removed. mInkWindow.hide(false /* remove */); mPrivOps.resetStylusHandwriting(requestId); Loading @@ -2592,10 +2612,42 @@ public class InputMethodService extends AbstractInputMethodService { } private void removeHandwritingInkWindow() { cancelStylusWindowIdleTimeout(); mOnPreparedStylusHwCalled = false; mStylusWindowIdleTimeoutRunnable = null; if (mInkWindow != null) { mInkWindow.hide(true /* remove */); mInkWindow.destroy(); mInkWindow = null; } } private void cancelStylusWindowIdleTimeout() { if (mStylusWindowIdleTimeoutRunnable != null && mHandler != null) { mHandler.removeCallbacks(mStylusWindowIdleTimeoutRunnable); } } private void scheduleStylusWindowIdleTimeout() { if (mHandler == null) { return; } cancelStylusWindowIdleTimeout(); long timeout = (mStylusWindowIdleTimeoutForTest > 0) ? mStylusWindowIdleTimeoutForTest : STYLUS_WINDOW_IDLE_TIMEOUT_MILLIS; mHandler.postDelayed(getStylusWindowIdleTimeoutRunnable(), timeout); } private Runnable getStylusWindowIdleTimeoutRunnable() { if (mStylusWindowIdleTimeoutRunnable == null) { mStylusWindowIdleTimeoutRunnable = () -> { removeHandwritingInkWindow(); mStylusWindowIdleTimeoutRunnable = null; }; } return mStylusWindowIdleTimeoutRunnable; } /** * Sets the duration after which an ongoing stylus handwriting session that hasn't received new Loading
core/java/android/view/inputmethod/IInputMethodManagerInvoker.java +11 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.view.inputmethod; import android.annotation.AnyThread; import android.annotation.DurationMillisLong; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UserIdInt; Loading Loading @@ -274,4 +275,14 @@ final class IInputMethodManagerInvoker { throw e.rethrowFromSystemServer(); } } @AnyThread void setStylusWindowIdleTimeoutForTest( IInputMethodClient client, @DurationMillisLong long timeout) { try { mTarget.setStylusWindowIdleTimeoutForTest(client, timeout); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } }
core/java/android/view/inputmethod/InputMethod.java +9 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.view.inputmethod; import android.annotation.DurationMillisLong; import android.annotation.MainThread; import android.annotation.NonNull; import android.annotation.Nullable; Loading Loading @@ -417,4 +418,12 @@ public interface InputMethod { default void removeStylusHandwritingWindow() { // intentionally empty } /** * Set a stylus idle-timeout after which handwriting {@code InkWindow} will be removed. * @hide */ default void setStylusWindowIdleTimeoutForTest(@DurationMillisLong long timeout) { // intentionally empty } }