Loading
Register IME back callback in doStartInput
Normally the IME back callback is registered at the end of showWindow. However, we can get a doStartInput call without a subsequent showWindow call, and doStartInput will first doFinishInput, which will unregister the callback. If showWindow was previously called, we should try to register the callback again, so that back navigation while the IME is shown will be processed by the IME first, before the activity underneath. This lead to the callback being left unregistered due to a race condition, with the failing case order being: * ImeInsetsSourceProvider#invokeOnImeRequestedChangedListener * IMM#startInputInner * DefaultImeVisibilityApplier#performShowIme (from ImeChangedListener) * IMMS#attachNewInputLocked (from startInputInner) * IME#showSoftInput (from performShowIme) * IME#registerDefaultOnBackInvokedCallback (from showSoftInput) * IME#dispatchStartInput (from attachNewInputLocked) * IME#unregisterDefaultOnBackInvokedCallback (from dispatchStartInput) and the passing case (expected) order being: * ImeInsetsSourceProvider#invokeOnImeRequestedChangedListener * IMM#startInputInner * IMMS#attachNewInputLocked (from startInputInner) * IME#dispatchStartInput (from attachNewInputLocked) * IME#unregisterDefaultOnBackInvokedCallback (from dispatchStartInput) * DefaultImeVisibilityApplier#performShowIme (from ImeChangedListener) * IME#showSoftInput (from performShowIme) * IME#registerDefaultOnBackInvokedCallback (from showSoftInput) Flag: EXEMPT bugfix: Test: atest KeyboardVisibilityControlTest#testIMEVisibleInSplitScreenWithWindowInsetsApi Bug: 402671709 Change-Id: I0d0f823a2998a08b8dfc2b0d6e39a0a9de521b14