Avoid resource I/O when holding ImfLock
Loading InputMethodInfo from APK resources is full of disk I/O, which can result in ANR as seen in Bug 340221861. This CL aims to avoid such disk I/O when holding ImfLock. With this CL MyPackageMonitor#onFinishPackageChangesInternal() updates IME list as follows. 1. Create List<InputMethodInfo> without additional subtypes 2. Acquire ImfLock.class 3. Finalize additional subtypes 4. Finalize List<InputMethodInfo> 5. Release ImfLock.class The key idea is the fact that List<InputMethodInfo> can be instantiated without ImfLock as long as we can ignore additional subtypes at the step 1. Creating the final List<InputMethodInfo> at the step 4 is a pure computatoin, which does not require any disk I/O. There must be no user observable behavior change. Fix: 340221861 Test: presubmit Change-Id: I263cd49dd4d64b64136acc3dad469f83a862ce97
Loading
Please register or sign in to comment