Loading core/java/android/inputmethodservice/InputMethodService.java +11 −16 Original line number Diff line number Diff line Loading @@ -58,8 +58,6 @@ import static android.view.inputmethod.Flags.FLAG_CONNECTIONLESS_HANDWRITING; import static android.view.inputmethod.Flags.FLAG_VERIFY_KEY_EVENT; import static android.view.inputmethod.Flags.ctrlShiftShortcut; import static com.android.window.flags.Flags.imeBackCallbackLeakPrevention; import android.annotation.CallSuper; import android.annotation.DrawableRes; import android.annotation.DurationMillisLong; Loading Loading @@ -152,7 +150,7 @@ import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.TextView; import android.window.CompatOnBackInvokedCallback; import android.window.ImeOnBackInvokedDispatcher; import android.window.ImeBackCallbackSender; import android.window.OnBackInvokedCallback; import android.window.OnBackInvokedDispatcher; import android.window.WindowMetricsHelper; Loading Loading @@ -371,7 +369,7 @@ public class InputMethodService extends AbstractInputMethodService { * A circular buffer of size MAX_EVENTS_BUFFER in case IME is taking too long to add ink view. **/ private RingBuffer<MotionEvent> mPendingEvents; private ImeOnBackInvokedDispatcher mImeDispatcher; private ImeBackCallbackSender mImeBackCallbackSender; private boolean mBackCallbackRegistered = false; private final CompatOnBackInvokedCallback mCompatBackCallback = this::compatHandleBack; private Runnable mImeSurfaceRemoverRunnable; Loading Loading @@ -839,14 +837,11 @@ public class InputMethodService extends AbstractInputMethodService { // (if any) can be unregistered using the old dispatcher if {@link #doFinishInput()} // is called from {@link #startInput(InputConnection, EditorInfo)} or // {@link #restartInput(InputConnection, EditorInfo)}. final ImeOnBackInvokedDispatcher oldDispatcher = mImeDispatcher; mImeDispatcher = params.imeDispatcher; if (imeBackCallbackLeakPrevention() && oldDispatcher != null && mImeDispatcher != null && oldDispatcher != mImeDispatcher) { mImeDispatcher.transferNonSystemCallbacksFrom(oldDispatcher); } mImeBackCallbackSender.setTargetAppPackageName(params.editorInfo.packageName); mImeBackCallbackSender.setResultReceiver(params.imeBackCallbackReceiver); if (mWindow != null) { mWindow.getOnBackInvokedDispatcher().setImeOnBackInvokedDispatcher(mImeDispatcher); mWindow.getOnBackInvokedDispatcher().setImeBackCallbackSender( mImeBackCallbackSender); if (mDecorViewVisible && mShowInputRequested) { // Back callback is typically registered in {@link #showWindow()}, but it's // possible for {@link #doStartInput()} to be called without Loading Loading @@ -1725,10 +1720,9 @@ public class InputMethodService extends AbstractInputMethodService { Context.LAYOUT_INFLATER_SERVICE); Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMS.initSoftInputWindow"); mWindow = new SoftInputWindow(this, mTheme, mDispatcherState); if (mImeDispatcher != null) { mWindow.getOnBackInvokedDispatcher() .setImeOnBackInvokedDispatcher(mImeDispatcher); } mImeBackCallbackSender = new ImeBackCallbackSender(); mWindow.getOnBackInvokedDispatcher().setImeBackCallbackSender(mImeBackCallbackSender); mNavigationBarController.onSoftInputWindowCreated(mWindow); { final Window window = mWindow.getWindow(); Loading Loading @@ -1871,7 +1865,8 @@ public class InputMethodService extends AbstractInputMethodService { // when IME developers are doing something unsupported. InputMethodPrivilegedOperationsRegistry.remove(mToken); } mImeDispatcher = null; mImeBackCallbackSender.clear(); mImeBackCallbackSender = null; } /** Loading core/java/android/view/ImeBackAnimationController.java +1 −1 Original line number Diff line number Diff line Loading @@ -152,7 +152,7 @@ public class ImeBackAnimationController implements OnBackAnimationCallback { } // Unregister all IME back callbacks so that back events are sent to the next callback // even while the hide animation is playing mInsetsController.getHost().getInputMethodManager().getImeOnBackInvokedDispatcher() mInsetsController.getHost().getInputMethodManager().getImeBackCallbackProxy() .preliminaryClear(); } Loading core/java/android/view/InsetsController.java +2 −2 Original line number Diff line number Diff line Loading @@ -1375,7 +1375,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation if (!fromPredictiveBack && !visible && (types & ime()) != 0 && (mRequestedVisibleTypes & ime()) != 0) { // Clear IME back callbacks if a IME hide animation is requested mHost.getInputMethodManager().getImeOnBackInvokedDispatcher().preliminaryClear(); mHost.getInputMethodManager().getImeBackCallbackProxy().preliminaryClear(); } // Basically, we accept the requested visibilities from the upstream callers... setRequestedVisibleTypes(visible ? types : 0, types); Loading Loading @@ -1834,7 +1834,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation // In case the IME back callbacks have been preliminarily cleared before, let's // reregister them. This can happen if an IME hide animation was interrupted and the // IME is requested to be shown again. getHost().getInputMethodManager().getImeOnBackInvokedDispatcher() getHost().getInputMethodManager().getImeBackCallbackProxy() .undoPreliminaryClear(); } ProtoLog.d(IME_INSETS_CONTROLLER, "Setting requestedVisibleTypes to %d (was %d)", Loading core/java/android/view/ViewRootImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -12949,7 +12949,7 @@ public final class ViewRootImpl implements ViewParent, mCompatOnBackInvokedCallback = () -> { injectBackKeyEvents(/* preImeOnly */ false); }; if (mOnBackInvokedDispatcher.hasImeOnBackInvokedDispatcher()) { if (mOnBackInvokedDispatcher.hasImeBackCallbackSender()) { Log.d(TAG, "Skip registering CompatOnBackInvokedCallback on IME dispatcher"); return; } core/java/android/view/inputmethod/IInputMethodManagerGlobalInvoker.java +4 −3 Original line number Diff line number Diff line Loading @@ -29,10 +29,10 @@ import android.annotation.UserIdInt; import android.content.Context; import android.os.IBinder; import android.os.RemoteException; import android.os.ResultReceiver; import android.os.ServiceManager; import android.util.ExceptionUtils; import android.view.WindowManager; import android.window.ImeOnBackInvokedDispatcher; import com.android.internal.infra.AndroidFuture; import com.android.internal.inputmethod.DirectBootAwareness; Loading Loading @@ -299,7 +299,7 @@ final class IInputMethodManagerGlobalInvoker { @Nullable IRemoteInputConnection remoteInputConnection, @Nullable IRemoteAccessibilityInputConnection remoteAccessibilityInputConnection, int unverifiedTargetSdkVersion, @UserIdInt int userId, @NonNull ImeOnBackInvokedDispatcher imeDispatcher, boolean imeRequestedVisible) { @NonNull ResultReceiver imeBackCallbackReceiver, boolean imeRequestedVisible) { final IInputMethodManager service = getService(); if (service == null) { return -1; Loading @@ -308,7 +308,8 @@ final class IInputMethodManagerGlobalInvoker { service.startInputOrWindowGainedFocus(startInputReason, client, windowToken, startInputFlags, softInputMode, windowFlags, editorInfo, remoteInputConnection, remoteAccessibilityInputConnection, unverifiedTargetSdkVersion, userId, imeDispatcher, imeRequestedVisible, advanceAngGetStartInputSequenceNumber()); imeBackCallbackReceiver, imeRequestedVisible, advanceAngGetStartInputSequenceNumber()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading
core/java/android/inputmethodservice/InputMethodService.java +11 −16 Original line number Diff line number Diff line Loading @@ -58,8 +58,6 @@ import static android.view.inputmethod.Flags.FLAG_CONNECTIONLESS_HANDWRITING; import static android.view.inputmethod.Flags.FLAG_VERIFY_KEY_EVENT; import static android.view.inputmethod.Flags.ctrlShiftShortcut; import static com.android.window.flags.Flags.imeBackCallbackLeakPrevention; import android.annotation.CallSuper; import android.annotation.DrawableRes; import android.annotation.DurationMillisLong; Loading Loading @@ -152,7 +150,7 @@ import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.TextView; import android.window.CompatOnBackInvokedCallback; import android.window.ImeOnBackInvokedDispatcher; import android.window.ImeBackCallbackSender; import android.window.OnBackInvokedCallback; import android.window.OnBackInvokedDispatcher; import android.window.WindowMetricsHelper; Loading Loading @@ -371,7 +369,7 @@ public class InputMethodService extends AbstractInputMethodService { * A circular buffer of size MAX_EVENTS_BUFFER in case IME is taking too long to add ink view. **/ private RingBuffer<MotionEvent> mPendingEvents; private ImeOnBackInvokedDispatcher mImeDispatcher; private ImeBackCallbackSender mImeBackCallbackSender; private boolean mBackCallbackRegistered = false; private final CompatOnBackInvokedCallback mCompatBackCallback = this::compatHandleBack; private Runnable mImeSurfaceRemoverRunnable; Loading Loading @@ -839,14 +837,11 @@ public class InputMethodService extends AbstractInputMethodService { // (if any) can be unregistered using the old dispatcher if {@link #doFinishInput()} // is called from {@link #startInput(InputConnection, EditorInfo)} or // {@link #restartInput(InputConnection, EditorInfo)}. final ImeOnBackInvokedDispatcher oldDispatcher = mImeDispatcher; mImeDispatcher = params.imeDispatcher; if (imeBackCallbackLeakPrevention() && oldDispatcher != null && mImeDispatcher != null && oldDispatcher != mImeDispatcher) { mImeDispatcher.transferNonSystemCallbacksFrom(oldDispatcher); } mImeBackCallbackSender.setTargetAppPackageName(params.editorInfo.packageName); mImeBackCallbackSender.setResultReceiver(params.imeBackCallbackReceiver); if (mWindow != null) { mWindow.getOnBackInvokedDispatcher().setImeOnBackInvokedDispatcher(mImeDispatcher); mWindow.getOnBackInvokedDispatcher().setImeBackCallbackSender( mImeBackCallbackSender); if (mDecorViewVisible && mShowInputRequested) { // Back callback is typically registered in {@link #showWindow()}, but it's // possible for {@link #doStartInput()} to be called without Loading Loading @@ -1725,10 +1720,9 @@ public class InputMethodService extends AbstractInputMethodService { Context.LAYOUT_INFLATER_SERVICE); Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMS.initSoftInputWindow"); mWindow = new SoftInputWindow(this, mTheme, mDispatcherState); if (mImeDispatcher != null) { mWindow.getOnBackInvokedDispatcher() .setImeOnBackInvokedDispatcher(mImeDispatcher); } mImeBackCallbackSender = new ImeBackCallbackSender(); mWindow.getOnBackInvokedDispatcher().setImeBackCallbackSender(mImeBackCallbackSender); mNavigationBarController.onSoftInputWindowCreated(mWindow); { final Window window = mWindow.getWindow(); Loading Loading @@ -1871,7 +1865,8 @@ public class InputMethodService extends AbstractInputMethodService { // when IME developers are doing something unsupported. InputMethodPrivilegedOperationsRegistry.remove(mToken); } mImeDispatcher = null; mImeBackCallbackSender.clear(); mImeBackCallbackSender = null; } /** Loading
core/java/android/view/ImeBackAnimationController.java +1 −1 Original line number Diff line number Diff line Loading @@ -152,7 +152,7 @@ public class ImeBackAnimationController implements OnBackAnimationCallback { } // Unregister all IME back callbacks so that back events are sent to the next callback // even while the hide animation is playing mInsetsController.getHost().getInputMethodManager().getImeOnBackInvokedDispatcher() mInsetsController.getHost().getInputMethodManager().getImeBackCallbackProxy() .preliminaryClear(); } Loading
core/java/android/view/InsetsController.java +2 −2 Original line number Diff line number Diff line Loading @@ -1375,7 +1375,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation if (!fromPredictiveBack && !visible && (types & ime()) != 0 && (mRequestedVisibleTypes & ime()) != 0) { // Clear IME back callbacks if a IME hide animation is requested mHost.getInputMethodManager().getImeOnBackInvokedDispatcher().preliminaryClear(); mHost.getInputMethodManager().getImeBackCallbackProxy().preliminaryClear(); } // Basically, we accept the requested visibilities from the upstream callers... setRequestedVisibleTypes(visible ? types : 0, types); Loading Loading @@ -1834,7 +1834,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation // In case the IME back callbacks have been preliminarily cleared before, let's // reregister them. This can happen if an IME hide animation was interrupted and the // IME is requested to be shown again. getHost().getInputMethodManager().getImeOnBackInvokedDispatcher() getHost().getInputMethodManager().getImeBackCallbackProxy() .undoPreliminaryClear(); } ProtoLog.d(IME_INSETS_CONTROLLER, "Setting requestedVisibleTypes to %d (was %d)", Loading
core/java/android/view/ViewRootImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -12949,7 +12949,7 @@ public final class ViewRootImpl implements ViewParent, mCompatOnBackInvokedCallback = () -> { injectBackKeyEvents(/* preImeOnly */ false); }; if (mOnBackInvokedDispatcher.hasImeOnBackInvokedDispatcher()) { if (mOnBackInvokedDispatcher.hasImeBackCallbackSender()) { Log.d(TAG, "Skip registering CompatOnBackInvokedCallback on IME dispatcher"); return; }
core/java/android/view/inputmethod/IInputMethodManagerGlobalInvoker.java +4 −3 Original line number Diff line number Diff line Loading @@ -29,10 +29,10 @@ import android.annotation.UserIdInt; import android.content.Context; import android.os.IBinder; import android.os.RemoteException; import android.os.ResultReceiver; import android.os.ServiceManager; import android.util.ExceptionUtils; import android.view.WindowManager; import android.window.ImeOnBackInvokedDispatcher; import com.android.internal.infra.AndroidFuture; import com.android.internal.inputmethod.DirectBootAwareness; Loading Loading @@ -299,7 +299,7 @@ final class IInputMethodManagerGlobalInvoker { @Nullable IRemoteInputConnection remoteInputConnection, @Nullable IRemoteAccessibilityInputConnection remoteAccessibilityInputConnection, int unverifiedTargetSdkVersion, @UserIdInt int userId, @NonNull ImeOnBackInvokedDispatcher imeDispatcher, boolean imeRequestedVisible) { @NonNull ResultReceiver imeBackCallbackReceiver, boolean imeRequestedVisible) { final IInputMethodManager service = getService(); if (service == null) { return -1; Loading @@ -308,7 +308,8 @@ final class IInputMethodManagerGlobalInvoker { service.startInputOrWindowGainedFocus(startInputReason, client, windowToken, startInputFlags, softInputMode, windowFlags, editorInfo, remoteInputConnection, remoteAccessibilityInputConnection, unverifiedTargetSdkVersion, userId, imeDispatcher, imeRequestedVisible, advanceAngGetStartInputSequenceNumber()); imeBackCallbackReceiver, imeRequestedVisible, advanceAngGetStartInputSequenceNumber()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading