OSDN Git Service

Eliminate the inconsistency between the states of AMS and TSMS
authorGuliz Tuncay <gulizseray@google.com>
Tue, 20 Jun 2017 00:15:40 +0000 (17:15 -0700)
committerGuliz Tuncay <gulizseray@google.com>
Wed, 21 Jun 2017 21:50:30 +0000 (21:50 +0000)
commit787aa8c0db993e8f624769382c7395dd2f369ac4
treea055907660af903b92713f9a7c19866f54ab26df
parent984bc9cb52ae52ec9d6eb9bb22dd3a737ffa471c
Eliminate the inconsistency between the states of AMS and TSMS

If spell checker service (SCS) is killed for some reason, TSMS
accidentally clears the internal bindings to SCS even though it does not
programmatically unbind them. When SCS is restarted, the seemingly-dead
connections are re-established but TSMS’s internal bind groups
structures do not keep track of them anymore. This results in
inconsistency between the internal data structures of activity manager
services (AMS) and TSMS. TSMS shows no bindings anymore, whereas AMS
shows there is active spell checker service connections. The fix is to
not remove a bind group at onServiceDisconnect and only set the bind
group's connected state to false.

Fixes: 37434113
Test: Manual as follows.
      1. Build and flash an OS image.
      2. Complete the setup wizard (if any).
      3. Make sure AOSP Keyboard (com.android.inputmethod.latin)
       is installed.
      4. adb shell settings put secure selected_spell_checker com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
      5. Observe that there are no bindings to spell
       checker service (SCS) by running
       adb shell dumpsys textservices
      6. Observe that there is no connection to SCS by running
       adb shell dumpsys activity services com.android.inputmethod.latin
       There should be no ConnectionRecord for
       AndroidSpellCheckerService
      7. Run a test program that has TextView and tap on one of the
       TextViews and type some text.
      8. Repeat steps 5 and 6 to observe there are now bindings and
       connection to SCS.
      9. Kill SCS
        adb shell ps -A | grep com.android.inputmethod.latin | awk '{print $2}' | xargs adb shell kill -KILL
      10. Repeat steps 5 and 6 to observe that the bindings are the
       same as of Step 8 and there is still a connection to SCS.
Change-Id: I66de244f184ab0618944c129db4062d09f72e6d1
services/core/java/com/android/server/TextServicesManagerService.java