Skip to content
Commit aaa0e43d authored by Guliz Tuncay's avatar Guliz Tuncay
Browse files

TSMS updates settings properly in case of package changes

TextServicesManagerService#onSomePackagesChanged means to update the
spell checker settings when there is a change in packages; however, it 
fails to do so. If the app whose spell checker service is set as the
used service in settings gets updated, onSomePackagesChanged method
checks if the current service implemented by the app is removed by the
update. If this is the case, it intends to give priority to this app if
it's implementing another spell checker service and tries to set that as
the current spell checker in the settings.In order to do that, upon
package change, first a new spell checker map is constructed, then the
method checks to see if the current spell checker is null and if this is
the case it concludes the user did not set a spell checker. However,
since the new map is built before this null check is performed, it could
be the case that the user actually set a spell checker service before
but this was removed by the package update. In this case, we should
still be updating the settings, rather than simply returning. The order
of retrieving the current spell checker and building the map should be
changed to fix this issue.

Fixes: 63542224
Test: Manually as follows
   1. Make 2 versions of SampleSpellCheckerService:
     one with a single SCS (v1), one with 2 SCSs (v2)
   2. Install v2 first by
   adb install -r out/target/product/generic/system/app/SampleSpellCheckerService/SampleSpellCheckerService.apk
   3. adb shell settings put secure selected_spell_checker com.example.android.samplespellcheckerservice/.SampleSpellCheckerService2
   4. adb shell settings get secure selected_spell_checker
    Should return
    com.example.android.samplespellcheckerservice/.SampleSpellCheckerService2
   5. Install v1
   6. adb shell settings get secure selected_spell_checker
    Should return (note that the current SCS changed)
    com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
Change-Id: Ia9d75e10c5642a49d8145b0a6ed6f726e546f964
parent 1c94b8cc
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment