Prevent custom IME back callbacks from "leaking" in app process

This CL ensures that no custom IME back callback can remain registered
in the app process when the default (system) IME callback is not
registered. ImeOnBackInvokedDispatcher does not send any registration
requests to the app process while there is no system back callback
registered by the IME process. Additionally, it unregisters any
remaining non-system IME back callbacks when the system callback is
unregistered.

Furthermore, whenever the target ImeOnBackInvokedDispatcher changes,
any registered non-system back callbacks are transferred to the new
dispatcher.

Bug: 420870283
Test: KeyboardVisibilityControlTest
Flag: com.android.window.flags.ime_back_callback_leak_prevention
Change-Id: I610463ccd87621b2e850a93a0a64849f4f403ad4
3 files changed