Eliminate out-of-sync IMM#mFullscreenMode error
As explained in the commit message of my previous CL [1], we have had a design issue in how to notify the full-screen mode change from the IME to InputMethodManager running in the target application. Histrically we have done this by using hooking the following IPC from the IME to the target application. InputConnection#reportFullscreenMode() However, since we also want InputConnection to be deactivated in some situations such as the when the target application is no longer focused. In other words, InputConnection is not a reliable way to notify something. As a result, we have suffered from many stale state issues. Bug 21455064 and Bug 28157836 are such examples. In Android N, we introduced yet another hack to work around those issues, but it is really time to fix the protocol design instead. The new strategy is to rely on internal IPCs provided by InputMethodManager to deliver such critical notifications from one process to the other. This is actually more natural because our goal is to make sure that InputMethodManager#isFullscreenMode() always returns the latest value as long as the caller is the focused application. For backword compatibility, applications that are monitoring this callback should continue working, as InputMethodManager emulates the previous behavior. However, as updated in JavaDoc, IMEs are no longer allowed to invoke InputConnection#reportFullscreenMode(), which should be OK because even on previous releases IMEs should rely on InputMethodService#updateFullscreenMode() instead. [1]: Iba184245a01a3b340f006bc4e415d304de3c2696 1544def0 Fixes: 28406127 Test: Make sure Bug 21455064 is still fixed. 1. Input some words in extract mode. 2. Select a word. 3. Perform copy. 4. Select a word. 5. Rotate the device. 6. Try to select a word. 7. Make sure he word is selected and action mode starts. Test: Make sure Bug 28157836 is still fixed. 1. Rotate device to landscape mode. 2. Tap on EditText and start full screen extracted mode. 3. Rotate device to portrait mode. 4. Long press to start action mode. 5. Make sure Action mode gets started. Test: `adb shell dumpsys input_method` to make sure that fullscreen state is synchronized across the app, IMMS, and the IME. Change-Id: If23e7c7c265ab3dfb48c2fb6fdb361b17d22c594
Loading
Please register or sign in to comment