Let blocked InputConnection APIs fail upon IInputMethod.unbindInput()
This is a follow up CL to our previous CL [1], which implemented
fail-fast mode for blocking InputConnection APIs based on
IInputMethod.unbindInput() async signal from IMMS to IMS.
What was not implemented in the previous CL was a mechanism to
immediately unblock a sync InputConnection API call that is already
requested to the IME client process and waiting for its response.
With this CL, any blocking InputConnection API fails immediately when
IInputMethod#onUnbindInput() is delivered to the IME process, without
waiting for the full time-out period (MAX_WAIT_TIME_MILLIS == 2 sec)
to pass.
Implementation Note:
The key idea is to use CountDownLatch to compose multiple wait
conditions.composed wait condition. The CountDownLatch is initialized
with 1 then will be decremented when:
A. received a result from the IME client
B. received IInputMethod.unbindInput()
Hence InputConnectionWrapper can simply wait for the CountDownLatch to
become 0 with an existing timeout (MAX_WAIT_TIME_MILLIS) then returns
failure unless the CountDownLatch became 0 because of A.
[1]: I0f816c6ca4c5c0664962432b913f074605fedd27
1d113d04
Fix: 36897707
Test: atest InputConnectionBlockingMethodTest
Test: InputConnectionBlockingMethodTest#*FailFastAfterUnbindInput()
take shorter time to complete.
Test: Monitor logcat with `adb logcat -s InputConnectionWrapper:*`
while running `atest InputConnectionBlockingMethodTest`
Change-Id: Ic65a95eb5d0fd56f505a02fd9083bcf6694b6734
Loading
Please register or sign in to comment