Delay tasks from IMMS constructor to later phase
This is a preparation CL for Bug 32343335. This CL basically addresses the concern raised in a previous CL [1] that added several synchnonized blocks in the constructor of InputMethodManagerService (IMMS). After hours of code reading and investigation, it is concluded to be safe IMMS to behave as if there was no IME available until SystemService.PHASE_ACTIVITY_MANAGER_READY phase. This allows IMMS to register callbacks not in the constructor but in the later phase to addresses the concern that object references to IMMS could be leaked into different threads before IMMS object is properly constructed. As far as performance is concerned, basically the amount of tasks to be done in the main thread remains same, or could be reduced a bit if some unnecessary callback events were skipped. To confirm this, we can check the total number of the following performance metrics. - StartInputMethodManagerLifecycle - StartActivityManagerReadyPhase [1]: I9d4d3d7232c984432185c10c13fb726a6158cac8 8f202f82fd86a3b40bc5e7d62779eddff21096b1 Bug: 32343335 Test: Manual: pre-installed IME on Direct-Boot disabled device Test: Manual: pre-installed IME on Direct-Boot enabled device Test: Manual: user-installed IME on Direct-Boot enabled device Test: Manual: user-installed IME on Direct-Boot disabled device Test: Manual: user switching scenario on Direct-Boot enabled device Test: Manual: user switching scenario on Direct-Boot disabled device Test: Manual: device unlocking scenario on Direct-Boot enabled device Change-Id: I5b37c450db4b25b3e635b6d634293a34eec8b9d4
Loading
Please register or sign in to comment