Loading core/java/android/view/inputmethod/InputMethodManager.java +36 −14 Original line number Diff line number Diff line Loading @@ -265,6 +265,14 @@ public final class InputMethodManager { private static final int NOT_A_SUBTYPE_ID = -1; /** * {@code true} to try to avoid blocking apps' UI thread by sending * {@link StartInputReason#WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION} and * {@link StartInputReason#WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION} in a truly asynchronous * way. {@code false} to go back to the previous synchronous semantics. */ private static final boolean USE_REPORT_WINDOW_GAINED_FOCUS_ASYNC = false; /** * A constant that represents Voice IME. * Loading Loading @@ -689,10 +697,18 @@ public final class InputMethodManager { Log.v(TAG, "Reporting focus gain, without startInput" + ", nextFocusIsServedView=" + nextFocusHasConnection); } final int startInputReason = nextFocusHasConnection ? WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION if (USE_REPORT_WINDOW_GAINED_FOCUS_ASYNC) { mService.reportWindowGainedFocusAsync( nextFocusHasConnection, mClient, focusedView.getWindowToken(), startInputFlags, softInputMode, windowFlags, mCurRootView.mContext.getApplicationInfo().targetSdkVersion); } else { final int startInputReason = nextFocusHasConnection ? WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION : WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION; final Completable.InputBindResult value = Completable.createInputBindResult(); final Completable.InputBindResult value = Completable.createInputBindResult(); mService.startInputOrWindowGainedFocus( startInputReason, mClient, focusedView.getWindowToken(), startInputFlags, softInputMode, Loading @@ -703,6 +719,7 @@ public final class InputMethodManager { mCurRootView.mContext.getApplicationInfo().targetSdkVersion, ResultCallbacks.of(value)); Completable.getResult(value); // ignore the result } } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -1087,6 +1104,11 @@ public final class InputMethodManager { public void setImeTraceEnabled(boolean enabled) { ImeTracing.getInstance().setEnabled(enabled); } @Override public void throwExceptionFromSystem(String message) { throw new RuntimeException(message); } }; final InputConnection mDummyInputConnection = new BaseInputConnection(this, false); Loading core/java/com/android/internal/view/IInputMethodClient.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -30,4 +30,5 @@ oneway interface IInputMethodClient { void reportFullscreenMode(boolean fullscreen); void updateActivityViewToScreenMatrix(int bindSequence, in float[] matrixValues); void setImeTraceEnabled(boolean enabled); void throwExceptionFromSystem(String message); } core/java/com/android/internal/view/IInputMethodManager.aidl +6 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,12 @@ interface IInputMethodManager { int unverifiedTargetSdkVersion, in IInputBindResultResultCallback inputBindResult); oneway void reportWindowGainedFocusAsync( boolean nextFocusHasConnection, in IInputMethodClient client, in IBinder windowToken, /* @StartInputFlags */ int startInputFlags, /* @android.view.WindowManager.LayoutParams.SoftInputModeFlags */ int softInputMode, int windowFlags, int unverifiedTargetSdkVersion); oneway void showInputMethodPickerFromClient(in IInputMethodClient client, int auxiliarySubtypeMode, in IVoidResultCallback resultCallback); oneway void showInputMethodPickerFromSystem(in IInputMethodClient client, Loading services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +85 −53 Original line number Diff line number Diff line Loading @@ -3353,6 +3353,28 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return res; } @NonNull @Override public void reportWindowGainedFocusAsync( boolean nextFocusHasConnection, IInputMethodClient client, IBinder windowToken, @StartInputFlags int startInputFlags, @SoftInputModeFlags int softInputMode, int windowFlags, int unverifiedTargetSdkVersion) { final int startInputReason = nextFocusHasConnection ? StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION : StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION; try { startInputOrWindowGainedFocusInternal(startInputReason, client, windowToken, startInputFlags, softInputMode, windowFlags, null /* attribute */, null /* inputContext */, 0 /* missingMethods */, unverifiedTargetSdkVersion); } catch (Throwable t) { if (client != null) { try { client.throwExceptionFromSystem(t.getMessage()); } catch (RemoteException ignore) { } } } } @NonNull @Override public void startInputOrWindowGainedFocus( Loading @@ -3361,7 +3383,18 @@ public class InputMethodManagerService extends IInputMethodManager.Stub int windowFlags, @Nullable EditorInfo attribute, IInputContext inputContext, @MissingMethodFlags int missingMethods, int unverifiedTargetSdkVersion, IInputBindResultResultCallback resultCallback) { CallbackUtils.onResult(resultCallback, (Supplier<InputBindResult>) () -> { CallbackUtils.onResult(resultCallback, (Supplier<InputBindResult>) () -> startInputOrWindowGainedFocusInternal(startInputReason, client, windowToken, startInputFlags, softInputMode, windowFlags, attribute, inputContext, missingMethods, unverifiedTargetSdkVersion)); } @NonNull private InputBindResult startInputOrWindowGainedFocusInternal( @StartInputReason int startInputReason, IInputMethodClient client, IBinder windowToken, @StartInputFlags int startInputFlags, @SoftInputModeFlags int softInputMode, int windowFlags, @Nullable EditorInfo attribute, @Nullable IInputContext inputContext, @MissingMethodFlags int missingMethods, int unverifiedTargetSdkVersion) { if (windowToken == null) { Slog.e(TAG, "windowToken cannot be null."); return InputBindResult.NULL; Loading Loading @@ -3416,7 +3449,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } finally { Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); } }); } @NonNull Loading services/core/java/com/android/server/inputmethod/MultiClientInputMethodManagerService.java +29 −2 Original line number Diff line number Diff line Loading @@ -1625,6 +1625,33 @@ public final class MultiClientInputMethodManagerService { } } @BinderThread @Override public void reportWindowGainedFocusAsync( boolean nextFocusHasConnection, @Nullable IInputMethodClient client, @Nullable IBinder windowToken, @StartInputFlags int startInputFlags, @SoftInputModeFlags int softInputMode, int windowFlags, int unverifiedTargetSdkVersion) { final int startInputReason = nextFocusHasConnection ? StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION : StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION; try { startInputOrWindowGainedFocusInternal(startInputReason, client, windowToken, startInputFlags, softInputMode, windowFlags, null /* editorInfo */, null /* inputContext */, 0 /* missingMethods */, unverifiedTargetSdkVersion); } catch (Throwable t) { if (client != null) { try { client.throwExceptionFromSystem(t.getMessage()); } catch (RemoteException ignore) { } } } } @BinderThread @Override public void startInputOrWindowGainedFocus( Loading Loading
core/java/android/view/inputmethod/InputMethodManager.java +36 −14 Original line number Diff line number Diff line Loading @@ -265,6 +265,14 @@ public final class InputMethodManager { private static final int NOT_A_SUBTYPE_ID = -1; /** * {@code true} to try to avoid blocking apps' UI thread by sending * {@link StartInputReason#WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION} and * {@link StartInputReason#WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION} in a truly asynchronous * way. {@code false} to go back to the previous synchronous semantics. */ private static final boolean USE_REPORT_WINDOW_GAINED_FOCUS_ASYNC = false; /** * A constant that represents Voice IME. * Loading Loading @@ -689,10 +697,18 @@ public final class InputMethodManager { Log.v(TAG, "Reporting focus gain, without startInput" + ", nextFocusIsServedView=" + nextFocusHasConnection); } final int startInputReason = nextFocusHasConnection ? WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION if (USE_REPORT_WINDOW_GAINED_FOCUS_ASYNC) { mService.reportWindowGainedFocusAsync( nextFocusHasConnection, mClient, focusedView.getWindowToken(), startInputFlags, softInputMode, windowFlags, mCurRootView.mContext.getApplicationInfo().targetSdkVersion); } else { final int startInputReason = nextFocusHasConnection ? WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION : WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION; final Completable.InputBindResult value = Completable.createInputBindResult(); final Completable.InputBindResult value = Completable.createInputBindResult(); mService.startInputOrWindowGainedFocus( startInputReason, mClient, focusedView.getWindowToken(), startInputFlags, softInputMode, Loading @@ -703,6 +719,7 @@ public final class InputMethodManager { mCurRootView.mContext.getApplicationInfo().targetSdkVersion, ResultCallbacks.of(value)); Completable.getResult(value); // ignore the result } } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -1087,6 +1104,11 @@ public final class InputMethodManager { public void setImeTraceEnabled(boolean enabled) { ImeTracing.getInstance().setEnabled(enabled); } @Override public void throwExceptionFromSystem(String message) { throw new RuntimeException(message); } }; final InputConnection mDummyInputConnection = new BaseInputConnection(this, false); Loading
core/java/com/android/internal/view/IInputMethodClient.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -30,4 +30,5 @@ oneway interface IInputMethodClient { void reportFullscreenMode(boolean fullscreen); void updateActivityViewToScreenMatrix(int bindSequence, in float[] matrixValues); void setImeTraceEnabled(boolean enabled); void throwExceptionFromSystem(String message); }
core/java/com/android/internal/view/IInputMethodManager.aidl +6 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,12 @@ interface IInputMethodManager { int unverifiedTargetSdkVersion, in IInputBindResultResultCallback inputBindResult); oneway void reportWindowGainedFocusAsync( boolean nextFocusHasConnection, in IInputMethodClient client, in IBinder windowToken, /* @StartInputFlags */ int startInputFlags, /* @android.view.WindowManager.LayoutParams.SoftInputModeFlags */ int softInputMode, int windowFlags, int unverifiedTargetSdkVersion); oneway void showInputMethodPickerFromClient(in IInputMethodClient client, int auxiliarySubtypeMode, in IVoidResultCallback resultCallback); oneway void showInputMethodPickerFromSystem(in IInputMethodClient client, Loading
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +85 −53 Original line number Diff line number Diff line Loading @@ -3353,6 +3353,28 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return res; } @NonNull @Override public void reportWindowGainedFocusAsync( boolean nextFocusHasConnection, IInputMethodClient client, IBinder windowToken, @StartInputFlags int startInputFlags, @SoftInputModeFlags int softInputMode, int windowFlags, int unverifiedTargetSdkVersion) { final int startInputReason = nextFocusHasConnection ? StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION : StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION; try { startInputOrWindowGainedFocusInternal(startInputReason, client, windowToken, startInputFlags, softInputMode, windowFlags, null /* attribute */, null /* inputContext */, 0 /* missingMethods */, unverifiedTargetSdkVersion); } catch (Throwable t) { if (client != null) { try { client.throwExceptionFromSystem(t.getMessage()); } catch (RemoteException ignore) { } } } } @NonNull @Override public void startInputOrWindowGainedFocus( Loading @@ -3361,7 +3383,18 @@ public class InputMethodManagerService extends IInputMethodManager.Stub int windowFlags, @Nullable EditorInfo attribute, IInputContext inputContext, @MissingMethodFlags int missingMethods, int unverifiedTargetSdkVersion, IInputBindResultResultCallback resultCallback) { CallbackUtils.onResult(resultCallback, (Supplier<InputBindResult>) () -> { CallbackUtils.onResult(resultCallback, (Supplier<InputBindResult>) () -> startInputOrWindowGainedFocusInternal(startInputReason, client, windowToken, startInputFlags, softInputMode, windowFlags, attribute, inputContext, missingMethods, unverifiedTargetSdkVersion)); } @NonNull private InputBindResult startInputOrWindowGainedFocusInternal( @StartInputReason int startInputReason, IInputMethodClient client, IBinder windowToken, @StartInputFlags int startInputFlags, @SoftInputModeFlags int softInputMode, int windowFlags, @Nullable EditorInfo attribute, @Nullable IInputContext inputContext, @MissingMethodFlags int missingMethods, int unverifiedTargetSdkVersion) { if (windowToken == null) { Slog.e(TAG, "windowToken cannot be null."); return InputBindResult.NULL; Loading Loading @@ -3416,7 +3449,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } finally { Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); } }); } @NonNull Loading
services/core/java/com/android/server/inputmethod/MultiClientInputMethodManagerService.java +29 −2 Original line number Diff line number Diff line Loading @@ -1625,6 +1625,33 @@ public final class MultiClientInputMethodManagerService { } } @BinderThread @Override public void reportWindowGainedFocusAsync( boolean nextFocusHasConnection, @Nullable IInputMethodClient client, @Nullable IBinder windowToken, @StartInputFlags int startInputFlags, @SoftInputModeFlags int softInputMode, int windowFlags, int unverifiedTargetSdkVersion) { final int startInputReason = nextFocusHasConnection ? StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION : StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION; try { startInputOrWindowGainedFocusInternal(startInputReason, client, windowToken, startInputFlags, softInputMode, windowFlags, null /* editorInfo */, null /* inputContext */, 0 /* missingMethods */, unverifiedTargetSdkVersion); } catch (Throwable t) { if (client != null) { try { client.throwExceptionFromSystem(t.getMessage()); } catch (RemoteException ignore) { } } } } @BinderThread @Override public void startInputOrWindowGainedFocus( Loading