History log of /frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
18f730cc00164ff26c1841e60632ea77544b1238 03-May-2018 android-build-team Robot <android-build-team-robot@google.com> Merge "Fix a condition to reset the current spell checker" into pi-dev
4993f4ed1e5d7ce0658fd528de63a02375c61910 02-May-2018 Yohei Yukawa <yukawa@google.com> Fix a condition to reset the current spell checker

TextServicesManagerService has had a logic to reset
Settings.Secure.SELECTED_SPELL_CHECKER when the current spell checker
service is uninstalled, but it had not been working until we fixed a
bug that had prevented that logic from running [1]. However, there
has been another bug in that logic itself that resets
Settings.Secure.SELECTED_SPELL_CHECKER also when the current spell
checker service APK is updated.

With this CL, Settings.Secure.SELECTED_SPELL_CHECKER will be reset
only when the package disappears, not when it is just being replaced
with a new APK.

[1]: I30902a3d94f2ddef33f4a8067799e98322ae3a03
34a04e40bd1f4a2e5aa7f15def0da626137fc64a

Fix: 79110151
Test: Manually verified as follows.
1. adb install -r SampleSpellCheckerService.apk
2. adb shell settings get secure selected_spell_checker
-> com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
3. adb shell "settings put secure selected_spell_checker 'com.example.android.samplespellcheckerservice/.SampleSpellCheckerService'"
4. adb shell settings get secure selected_spell_checker
-> com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
5. adb install -r SampleSpellCheckerService.apk
6. adb shell settings get secure selected_spell_checker
-> com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
Test: Manually verified that Bug 67412078 is still fixed.
Change-Id: Ic07fc2f418f051b2825d993fa959ed36f9b0f3c7
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
73ac947f6ea3cf12f88f48f181e7917d705997eb 01-May-2018 Yohei Yukawa <yukawa@google.com> Fix a race in spell checker session handling

This is a follow up CL to my previous CL [1] that eliminated
synchronous IPCs from TextServicesManagerService (TSMS) to
SpellCheckerService (SCS).

One thing I missed was that even while TSMS is waiting for the
response from SCS pending sessions can be terminated from the client
application side (e.g. SpellCheckerSession#close() is explicitly
called or the client application process gets killed).

With this CL, SpellCheckerBindGroup#removeListener() can work even in
such situations.

[1]: I92e7aa40dc9ea14f67d355f0bfa15325b775d27b
7fa65eef203c4ed3ce00ddef96ccf311d3bfb58c

Fix: 79082580
Test: Manually done as follows.
1. Create a custom spell checker service that can emulate the
scenarios where following methods are blocked
* SpellCheckerService#onCreate()
* SpellCheckerService#createSession()
* SpellCheckerService.Session#onGetSuggestions()
* SpellCheckerService.Session#onGetSentenceSuggestionsMultiple()
2. By using such a test spell checker service, make sure that TSMS
cleans up ISpellCheckerSessionListener and
ITextServicesSessionListener binder proxies when either
SpellCheckerSession#close() is called or the target app process
is killed.
Change-Id: Ie373095f20dd58273c764f1f732631bcfee758d7
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
3f8c568883e5df9dd0c44d19c5c4d23edd3756c3 01-Mar-2018 Yohei Yukawa <yukawa@google.com> Re-enable cross-profile use of spell checker APIs

Recently we successfully removed the restriction that up to one
SpellCheckerService can be active at the same time [1]. This still
makes much sense at high level, but at the ecosystem level there are
still some products / components that depend on the previous behavior
that child profile users can use parent profile's spell checker
service, which was originally introduced as a stopgap solution for
Android N MR1 [2].

Our decision for Android P for now is to revert back to the previous
behavior only when the calling process is running under work
profile.

At the implementation level, we can summarize the new behavior as
follows:
* When TextServicesManager APIs are called from work-profile
processes, those API calls will be evaluated with parent-profile's
user ID to match the previous behavior [2].
* If the currently selected spell checker is not a pre-installed
one, then API calls from work profile will fail to match the
previous behavior [2].
* When TextServicesManager APIs are called from non work-profile
processes, those API calls will continue being evaluated with
calling user ID, as we planned for Android P [1].
* TextServicesData will not be created for child profile users.

[1]: I06c27ef834203a21cc445dc126602c799384527b
06a2624049f09e1ad68f8ab74fdb525aacd5c1e5
[2]: Iae9045ba5baccd04ed68906e7afb9160677ec4a5
095fa371643b1d8e829067ea4ed93c357b39e773

Bug: 63041121
Bug: 64718412
Bug: 70922751
Bug: 73609140
Fix: 73862883
Test: atest FrameworksCoreTests:com.android.internal.textservice.LazyIntToIntMapTest
Test: Manually tested with Test DPC as follows:
* When AOSP Spell Checker is pre-installed and the current spell
checker, both main profile and work profile can use AOSP spell
checker.
* When SampleSpellCheckerService is side-loaded and the current
spell checker, only main profile can use
SampleSpellCheckerService.
Change-Id: Ic046f832f203115106409a53418a5746eb6d4939
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
e46228420b9b5040779f9f828e44db12cd092317 26-Feb-2018 Yohei Yukawa <yukawa@google.com> Remove incorrectly specified @UserIdInt

This is a follow up CL to my previous CL [1], which introduced
TextServicesManagerServicve.SessionRequest for internal state
management.

It turns out that SessionRequest#mUserId was incorrectly marked with
@UserIdInt, even though it actually stores uid, not user ID int.

This CL addresses the confusion by removing @UserIdInt as well as
renaming it to SessionRequest#mUid.

There should be no behavior change actually.

[1]: I92e7aa40dc9ea14f67d355f0bfa15325b775d27b

Bug: 7254002
Test: compile
Change-Id: I94f19d028be3b24fe0f3d848236ea9ca68e537b4
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
02f646e6a0b7353e86fd44b22cb933c9ee2f89c4 25-Jan-2018 Yohei Yukawa <yukawa@google.com> Fix missing textservices dump in 'adb bugreport'

This CL fixes a regression that was introduced when we enabled
multiple users to use spell checker APIs at the same time [1].

It turns out that 'adb bugreport' invokes
adb shell dumpsys textservices
with '-a' option.

With this CL '-a' option is no longer treated as an error in
TextServicesManagerService#dump().

[1]: I06c27ef834203a21cc445dc126602c799384527b
06a2624049f09e1ad68f8ab74fdb525aacd5c1e5

Bug: 63041121
Fix: 72462172
Test: adb shell dumpsys textservices -a
Test: Manually verified that 'adb bugreport report.zip' contains valid
result for TextServicesManagerService.
Change-Id: I0b40845f542b1db816303dabe41083fc76f8aeee
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
83a7330bbe8ee1e8fcaa88ba2fb5e4cb3154c790 18-Aug-2017 Guliz Tuncay <gulizseray@google.com> Update Settings properly when no Spell Checker is available.

Currently, Settings is not being updated properly when the current spell
checker service is removed or disabled and there is no other spell
checker service available. The correct behavior is that Secure.Settings
should be updated with empty string to indicate there is no selected
spell checker service.

Fixes: 64812014
Test: Manually as follows:
0. Make sure AOSP keyboard is installed.
1. adb shell settings put --user 0 secure selected_spell_checker com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
2. tapas SampleSpellCheckerService
3. make -j
4. adb install --user 0 -r out/target/product/generic/system/app/SampleSpellCheckerService/SampleSpellCheckerService.apk
5. adb shell pm disable com.android.inputmethod.latin
6. adb shell settings get --user 0 secure selected_spell_checker
-> com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
7. adb uninstall com.example.android.samplespellcheckerservice
8. adb shell settings get --user 0 secure selected_spell_checker
-> empty
9. adb root
10. adb shell settings get --user 0 secure selected_spell_checker
-> empty
11. adb shell pm enable com.android.inputmethod.latin
12. adb shell settings get --user 0 secure selected_spell_checker
Change-Id: I30902a3d94f2ddef33f4a8067799e98322ae3a03
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
0f0a37ba7def8db2c3e0ff1d7d8a30360e889f3f 16-Aug-2017 Guliz Tuncay <gulizseray@google.com> Select only preinstalled Spell Checker Services

When we are setting a new spell checker as the default one in
Secure.Settings, TSMS#findAvailSpellCheckerLocked can pick up
any available spell checker service. This violates the principle
that user should be warned whenever we are setting an untrusted
spell checker service as the default service, since the warning
dialog is never shown.

Fixes: 64764051
Test: Manually as follows:
0. Make sure AOSP keyboard is pre-installed.
1. adb shell settings put --user 0 secure selected_spell_checker com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
2. tapas SampleSpellCheckerService
3. make -j
4. adb install --user 0 -r out/target/product/generic/system/app/SampleSpellCheckerService/SampleSpellCheckerService.apk
5. adb shell pm disable com.android.inputmethod.latin
6. adb shell settings get --user 0 secure selected_spell_checker
-> com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
7. adb reboot
8. adb shell settings get --user 0 secure selected_spell_checker
-> com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
Change-Id: I298ffbcfa5e32f43753f54fbebc40a414a5c0f9e
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
8e6fa02f46f1df00d3d4bfa4f7fe3d8a98da7ce5 15-Aug-2017 Guliz Tuncay <gulizseray@google.com> Restructure TSMS

Remove TextServicesSettings, methods that deal with Settings and methods
that deal with TextServicesData (dump etc.) into TextServicesData. This
is a purely refactoring CL and it should not introduce any behavior
change.

Bug: 63041121
Test: None
Change-Id: I721fe464157c5850bd15d1d18fddb8c818c82683
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
06a2624049f09e1ad68f8ab74fdb525aacd5c1e5 01-Jul-2017 Guliz Tuncay <gulizseray@google.com> Multi-user aware TSMS

Currently, spell checker component can process requests only from the
foreground user's account and requests from background users are always
ignored. However, in order to fully realize the multi-user nature of
Android, most system services will need to truly support multiple users
simultaneously. With multi-user aware TSMS implemented, apps from
background users (other accounts and their work profiles) can also run
their spell checking jobs in batch, without the external device user
having to switch accounts for the spell checker to be enabled in that
account.

Bug: 63041121
Test: Manually as follows
Setup: Create a work profile and a secondary user
1. adb shell pm create-user --profileOf 0 --managed workprofile (userId 10)
2. adb shell am create-user seconrdaryuser1 (userId 11)
3. Build SampleSpellCheckerService, which is by default
direct-boot unaware.
package name: com.example.android.samplespellcheckerservice
APK name: SampleSpellCheckerService_DBUnaware.apk
4. Also build a custom SampleSpellCheckerService by explicitly
making '.SampleSpellCheckerService' direct-boot aware.
package name: com.example.android.samplespellcheckerservice2
APK name: SampleSpellCheckerService_DBAware.apk
5. adb install --user 0 -r SampleSpellCheckerService_DBUnaware.apk
6. adb install --user 10 -r SampleSpellCheckerService_DBUnaware.apk
7. adb install --user 11 -r SampleSpellCheckerService_DBUnaware.apk
8. adb install --user 0 -r SampleSpellCheckerService_DBAware.apk
9. adb install --user 10 -r SampleSpellCheckerService_DBAware.apk
10. adb install --user 11 -r SampleSpellCheckerService_DBAware.apk
11. make -j ApiDemos
12. adb install --user 0 -r $ANDROID_PRODUCT_OUT/data/app/ApiDemos/ApiDemos.apk
13. adb install --user 10 -r $ANDROID_PRODUCT_OUT/data/app/ApiDemos/ApiDemos.apk
14. adb install --user 11 -r $ANDROID_PRODUCT_OUT/data/app/ApiDemos/ApiDemos.apk
15. Make sure AOSP Keyboard (com.android.inputmethod.latin) is installed
for all users.

Test 1: Settings correctly updated for each user (Work profile's SC is
not bound to account and can be individually updated)
0. Complete Setup
1. adb shell am start-user 0
2. adb shell am start-user 10
3. adb shell am start-user 11
4. adb shell settings put --user 0 secure selected_spell_checker com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
5. adb shell settings put --user 10 secure selected_spell_checker com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
6. adb shell settings put --user 11 secure selected_spell_checker com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
7. adb shell settings get --user 0 secure selected_spell_checker
-> com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
8. adb shell settings get --user 10 secure selected_spell_checker
-> com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
9. adb shell settings get --user 11 secure selected_spell_checker
-> com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
10. adb shell settings put --user 0 secure selected_spell_checker com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
11. adb shell settings get --user 0 secure selected_spell_checker
-> com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
12. Repeat 8 & 9. Results should be the same.
13. adb shell settings put --user 10 secure selected_spell_checker com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
14. adb shell settings get --user 10 secure selected_spell_checker
-> com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
15. adb shell settings get --user 0 secure selected_spell_checker
-> com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
16. adb shell settings get --user 11 secure selected_spell_checker
-> com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
17. adb shell settings put --user 11 secure selected_spell_checker com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
14. adb shell settings get --user 11 secure selected_spell_checker
-> com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
14. adb shell settings get --user 0 secure selected_spell_checker
-> com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
15. adb shell settings get --user 10 secure selected_spell_checker
-> com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
16. adb shell am start-user 0
17. adb shell am start-user 10
18. adb shell am start-user 11
19. adb shell settings put --user 0 secure selected_spell_checker com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
20. adb shell settings put --user 10 secure selected_spell_checker com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
21. adb shell settings put --user 11 secure selected_spell_checker com.example.android.samplespellcheckerservice/.SampleSpellCheckerService

Test 2: Basic functionality works (each user can use SC when they're at
the foreground) & background connections aren't broken
0. Complete Setup
1. Open "Api Demos" app for user 0
2. Go to Views/Text/EditText
3. Focus into the first EditText then type "aaa"
4. Focus into the second EditText then type "aaa"
5. adb shell dumpsys textservices --user 0
-> make sure 'com.example.android.samplespellcheckerservice'
is serving spell checker sessions.
6. adb shell dumpsys textservices --user 10
-> make sure there are no active spell checker sessions.
7. adb shell dumpsys textservices --user 10
-> make sure there are no active spell checker sessions.
8. Repeat 7-10 for the work profile (userId 10)
9. adb shell dumpsys textservices --user 10
-> make sure 'com.example.android.samplespellcheckerservice'
is serving spell checker sessions.
10. adb shell am switch-user 11
11. Repeat 7-10 (userId 11)
12. adb shell dumpsys textservices --user 11
-> make sure 'com.example.android.samplespellcheckerservice'
is serving spell checker sessions.
13. adb shell dumpsys textservices --user 0
-> make sure 'com.example.android.samplespellcheckerservice'
is serving spell checker sessions.
14. adb shell dumpsys textservices --user 10
-> make sure 'com.example.android.samplespellcheckerservice'
is serving spell checker sessions.

Test 3: Background user can also call spell checker APIs
0. Complete Setup
1. adb shell pm install -r TestApp.apk
2. adb shell am switch-user 11
3. adb shell am start --user 11 -n com.example.gulizseray.testapp/com.example.gulizseray.testapp.MainActivity
4. adb logcat | grep spellcheckerclient
-> Periodically calls spell checker APIs and prints results
5. adb shell dumpsys textservices --user 11
-> make sure 'com.example.android.samplespellcheckerservice'
is serving spell checker sessions.
6. Adb shell am switch-user 0
7. adb logcat | grep spellcheckerclient
-> Continues to periodically call SC APIs and print results
8. Open "Api Demos" app for user 0
9. Go to Views/Text/EditText
10. Focus into the first EditText then type "aaa"
11. Focus into the second EditText then type "aaa"
12. adb shell dumpsys textservices --user 0
-> make sure 'com.example.android.samplespellcheckerservice'
is serving spell checker sessions.
13. adb shell dumpsys textservices --user 11
-> make sure 'com.example.android.samplespellcheckerservice'
is serving spell checker sessions.

Test 4: Package updates for all unlocked users (not just foreground user) are tracked properly (New package added/removed from owner, profile, secondary users)
0. Complete Setup
1. adb uninstall --user 0 com.example.android.samplespellcheckerservice
2. adb shell dumpsys textservices --user 0
-> Make sure com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
does not exist in the list
3. adb shell settings get --user 0 secure selected_spell_checker
-> com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
4. adb uninstall --user 10 com.example.android.samplespellcheckerservice
5. adb shell dumpsys textservices --user 10
-> Make sure com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
does not exist in the list
6. adb shell settings get --user 10 secure selected_spell_checker
-> com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
7. adb uninstall --user 11 com.example.android.samplespellcheckerservice
8. adb shell dumpsys textservices --user 11
-> Make sure com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
does not exist in the list
9. adb shell settings get --user 11 secure selected_spell_checker
-> com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
10. adb install --user 0 -r out/target/product/generic/system/app/SampleSpellCheckerService/SampleSpellCheckerService.apk
11. adb shell dumpsys textservices --user 0
-> Make sure com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
is in the list

12. adb shell settings get --user 0 secure selected_spell_checker
-> com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
13. adb install --user 10 -r out/target/product/generic/system/app/SampleSpellCheckerService/SampleSpellCheckerService.apk
14. adb shell dumpsys textservices --user 10
-> Make sure com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
is in the list
15. adb shell settings get --user 10 secure selected_spell_checker
-> com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
16. adb install --user 11 -r out/target/product/generic/system/app/SampleSpellCheckerService/SampleSpellCheckerService.apk
17. adb shell dumpsys textservices --user 11
-> Make sure com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
is in the list
18. adb shell settings get --user 11 secure selected_spell_checker
-> com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService

Test 5: SpellCheckerBindGroups will be cleared when the corresponding
app is killed.
0. Complete Setup
1. Open "Api Demos" app for user 0
2. Go to Views/Text/EditText
3. Focus into the first EditText then type "aaa"
4. Focus into the second EditText then type "aaa"
5. adb shell dumpsys textservices --user 0
-> make sure 'com.example.android.samplespellcheckerservice'
is serving spell checker sessions.
6. Kill Api Demos
7. adb shell dumpsys textservices --user 0
-> make sure there are no active spell checker sessions.
8. Repeat 1-7 for work profile (user 10)
9. adb shell am switch-user 11
10. Repeat 1-7 for secondary user (user 11)
12. adb shell pm install -r TestApp.apk
13. adb shell am start --user 11 -n com.example.gulizseray.testapp/com.example.gulizseray.testapp.MainActivity
14. adb shell dumpsys textservices --user 11
-> make sure 'com.example.android.samplespellcheckerservice'
is serving spell checker sessions.
15. adb shell am switch-user 0
16. adb shell am force-stop com.example.gulizseray.testapp
17. adb shell dumpsys textservices --user 11
-> make sure there are no active spell checker sessions.
Change-Id: I06c27ef834203a21cc445dc126602c799384527b
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
5f4dddfdf6c5d014d5fe2d9880c9ab036caf3859 09-Aug-2017 Guliz Tuncay <gulizseray@google.com> Merge "Track update count of TSMS#mSpellCheckerMap"
0c2806f2d25474ebb6fdf94c33c431a35b09f9e2 09-Aug-2017 Yohei Yukawa <yukawa@google.com> Merge changes I6de5ac05,I5f8c112d into oc-mr1-dev am: 8c009ebf4a
am: f23a2f95d2

Change-Id: I74d11c6178449fa7463508c73f554e261d02ec03
8c009ebf4a8b4b6ec23cd6662334b1f498ec12ad 08-Aug-2017 Yohei Yukawa <yukawa@google.com> Merge changes I6de5ac05,I5f8c112d into oc-mr1-dev

* changes:
Fix system restart due to race in TSMS
Remove redundant synchonized blocks from TSMS
674b1cfc7a1c89cac80793d81ff35a46a3494c38 08-Aug-2017 Guliz Tuncay <gulizseray@google.com> Track update count of TSMS#mSpellCheckerMap

TextServicesManagerService#buildSpellCheckerMapLocked() is known be
one of the biggest contributors to CPU and I/O bandwidth consumed
by TextServicesManagerService (TSMS). To check when it gets called
and to see how a CL would affect its call count, it would be useful
if we can easily get the call count of that method.

With this CL, how many times TSMS#mSpellCheckerMap was rebuilt will be
included in the dumpsys.

Bug: 64449660
Test: adb shell dumpsys textservices | grep "mSpellCheckerMapUpdateCount="
to make sure the count is increasing with each switch between
users.
Change-Id: Ia1f50c756c332b3329b6e28e8edb7673cf9124f2
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
846f7ffeb6871b0ec03d7e6ac3179cf453430264 08-Aug-2017 Yohei Yukawa <yukawa@google.com> Merge "Bind SpellCheckerService as IMPORTANT_BACKGROUND" into oc-mr1-dev am: cb921c1efc
am: 5778e85c6d

Change-Id: I6a1ffc12c4a066075828e7d4555f4df9d5f764e5
4163a96fa21d83d236e27d4a7150aa229a6dfeff 07-Aug-2017 Yohei Yukawa <yukawa@google.com> Fix system restart due to race in TSMS

This is a follow up CL to my previous CL [1], which aimed to get rid of
sync IPCs from TextServicesManagerService (TSMS) to
SpellCheckerService (SCS).

What was overlooked is that mSomeArrayList.forEach(action) throws
ConcurrentModificationException when the specified action adds or
removes items to/from mSomeArrayList. This can happen in my previous CL
when

1. An app requests a new spell checker service.
2. TSMS puts the request to mPendingSessionRequests and launchs the
current SCS by binding to it.
3. SCS#onCreate() succeeds.
4. TSMS receives onServiceConnected() callback.
4. SCS crashes.
5. TSMS tries to dispatch pending requests to the SCS as follows
mPendingSessionRequests.forEach(this::getISpellCheckerSessionLocked)
6. In getISpellCheckerSessionLocked() the IPC to the SCS fails because
the target SCS process is already dead. This triggeres removeAll(),
which clears mPendingSessionRequests.
7. ConcurrentModificationException is thrown, which will never be
caught and results in system restart.

Essentially this is a timing issue, but you can most likely reproduce
the issue by manually adding a certain delay in
SpellCheckerBindGroup#onServiceConnected() as follows.

public void onServiceConnectedLocked(ISpellCheckerService spellChecker) {
if (DBG) {
Slog.d(TAG, "onServiceConnected");
}

+ try {
+ Thread.sleep(100 /* msec */);
+ } catch (InterruptedException e) {
+ }
mSpellChecker = spellChecker;
mConnected = true;
// Dispatch pending getISpellCheckerSession requests.
mPendingSessionRequests.forEach(this::getISpellCheckerSessionLocked);
mPendingSessionRequests.clear();
}

Then you can also emulate the SCS crash as follows.

public class CrashingSpellCheckerService extends SpellCheckerService {
@Override
public void onCreate() {
super.onCreate();
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(10 /* msec */);
} catch (InterruptedException e) {
}
Process.killProcess(Process.myPid());
}
}).start();
}

...
}

This CL addresses the above issue by simply inlining
getISpellCheckerSessionLocked() to each call site to make it clear what
will happen in RemoteException is thrown.

[1]: I92e7aa40dc9ea14f67d355f0bfa15325b775d27b
7fa65eef203c4ed3ce00ddef96ccf311d3bfb58c

Test: Manually made sure that without this CL the system can restart
with the above technique.
Test: Manually made sure that AOSP spell checker service still works
as expected.
Fixes: 63452807
Change-Id: I6de5ac0507574f28a9859b50d081378112f1f7df
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
1854cb5aedaef2b3e6bbec0c69d148b148b3ecae 07-Aug-2017 Yohei Yukawa <yukawa@google.com> Remove redundant synchonized blocks from TSMS

As a preparation to fix Bug 63452807, this CL cleans up some redundant
synchonized blocks in TextServicesManagerService (TSMS).

This is purely a code clean-up that has no behavior change.

Bug: 63452807
Test: compile
Change-Id: I5f8c112d72dad46297b59da623f066fa944c1a27
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
ad78a615b7d3715c63f25c123c52f0ddbec853ea 04-Aug-2017 Yohei Yukawa <yukawa@google.com> Bind SpellCheckerService as IMPORTANT_BACKGROUND

If both InputMethodService (IME) and SpellCheckerService (SCS) are
implemented in the same package and used at the same time, typing
something on an EditText can easily create an active spell checker
connection, which is likely to be kept alive even after the software
keyboard gets dismissed by the user. Since currently
TextServicesManagerService (TSMS) binds SCS with
BIND_FOREGROUND_SERVICE_WHILE_AWAKE flag, the IME process continues to
be PROCESS_STATE_BOUND_FOREGROUND_SERVICE even after software keyboard
gets dismissed and InputMethodManagerService no longer binds IME with
BIND_FOREGROUND_SERVICE [1]. As a result, the IME process less
frequently receives UI_HIDDEN, with which HWUI heavily relies on to
purge its internal caches.

The idea of this CL is to reduce the process state bonus from TSMS to
SCS so that it can match with what IMMS does to IME when software
keyboard is not shown. Hopefully this would not cause priority
inversion provlems between the focused application and SCS because
IMEs with hardware keyborad with no software keyboard have already
running on this process state.

This CL also makes sure that IME starts receiving UI_HIDDEN only
after it shows the software keyboard, like IME gains
BIND_TREAT_LIKE_ACTIVITY characteristics [2] only after it shows the
software keyboard.

[1]: Id1f73de66dc93d63212183958a72119ad174318b
2c84cfc001fb92a71811bf7384b7f865ff31ff9d
[2]: Ie5793fd9b40d980fa18f80246326511ed6ae0597
f0f94d129b6eb3c48624e915898d86d4f2de59ff

Fixes: 64378148
Test: Manually tested as follows
1. make -j ApiDemos
2. adb install -r $ANDROID_PRODUCT_OUT/data/app/ApiDemos/ApiDemos.apk
3. tapas LatinIME
4. adb install -r $ANDROID_PRODUCT_OUT/system/app/LatinIME/LatinIME.apk
5. adb shell ime enable com.android.inputmethod.latin/.LatinIME
6. adb shell ime set com.android.inputmethod.latin/.LatinIME
7. adb shell "settings put secure selected_spell_checker 'com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService'"
8. adb shell dumpsys activity processes com.android.inputmethod.latin
-> make sure curProcState=7
-> make sure there is no "pendingUiClean" entry.
9. adb shell dumpsys activity services com.android.inputmethod.latin
-> Make sure there is only one connection to "com.android.inputmethod.latin/.LatinIME"
-> It should have following flags: "CR !FG IMPB !VIS"
10. Open "Api Demos" app
11. Go to Views/Text/EditText
-> make sure software keyboard shows up
12. adb shell dumpsys activity processes com.android.inputmethod.latin
-> make sure curProcState=3
-> make sure pendingUiClean=true
13. adb shell dumpsys activity services com.android.inputmethod.latin
-> Make sure there are two connections to "com.android.inputmethod.latin/.LatinIME"
-> They should have following flags: "CR !FG IMPB !VIS" and "CR FGS LACT UI"
14. In the first EditText type "aaa" then hit the space key.
15. adb shell dumpsys activity processes com.android.inputmethod.latin
-> make sure curProcState=3
-> make sure pendingUiClean=true
16. adb shell dumpsys activity services com.android.inputmethod.latin
-> Make sure there are two connections to "com.android.inputmethod.latin/.LatinIME"
-> They should have following flags: "CR !FG IMPB !VIS" and "CR FGS LACT UI"
-> Make sure there is a connection to "com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService"
-> It should have following flags: "CR IMPB"
17. Tap the down button on the NavBar to dismiss the keyboard
18. adb shell dumpsys activity processes com.android.inputmethod.latin
-> make sure curProcState=7
-> make sure pendingUiClean=false
19. adb shell dumpsys activity services com.android.inputmethod.latin
-> Make sure there is only one connection to "com.android.inputmethod.latin/.LatinIME"
-> It should have following flags: "CR !FG IMPB !VIS"
-> Make sure there is a connection to "com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService"
-> It should have following flags: "CR IMPB"
Change-Id: I91bc58675ce2e257af11efce5572bd9ecd4a37ac
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
5e1d5d65f85bf6df783836ddc696c2df669809ed 26-Jul-2017 Guliz Tuncay <gulizseray@google.com> Remove direct boot awareness support for TSMS

Remove onCopyWrite hashmap from TSMS to stop support for direct boot
aware spell checkers, as there is currently no apparent use case for
spell checker use before the device is unlocked. Additionally, we also
remove mCurrentId and mCurrentProfileId out of TextServicesSettings
(TSS) as these are not specific to TSS class itself. The aim here is to
simply TSMS code by removing support for unused cases.
This is a preparation CL for Bug 63041121.

Fixes: 64127156
Test: Manually tested as follows
Test precondition:
1. Have two users: User Owner (userId 0), User A (userId 10)
2. Set up a password "aaaa" for both users.
3. Build SampleSpellCheckerService, which is by default
direct-boot unaware.
package name: com.example.android.samplespellcheckerservice
APK name: SampleSpellCheckerService_DBUnaware.apk
4. Also build a custom SampleSpellCheckerService by explicitly
making '.SampleSpellCheckerService' direct-boot aware.
package name: com.example.android.samplespellcheckerservice2
APK name: SampleSpellCheckerService_DBAware.apk
5. adb install --user 0 -r SampleSpellCheckerService_DBUnaware.apk
6. adb install --user 10 -r SampleSpellCheckerService_DBUnaware.apk
7. adb install --user 0 -r SampleSpellCheckerService_DBAware.apk
8. adb install --user 10 -r SampleSpellCheckerService_DBAware.apk
9. make -j ApiDemos
10. adb install --user 0 -r $ANDROID_PRODUCT_OUT/data/app/ApiDemos/ApiDemos.apk
11. adb install --user 10 -r $ANDROID_PRODUCT_OUT/data/app/ApiDemos/ApiDemos.apk
Test: Test direct boot unaware spell checker services on a direct boot
enabled device as follows.
1. On a direct-boot enabled device, complete the above steps to
set up the device.
2. adb shell settings put --user 0 secure selected_spell_checker 'com.example.android.samplespellcheckerservice/.SampleSpellCheckerService'
3. adb shell settings put --user 10 secure selected_spell_checker 'com.example.android.samplespellcheckerservice/.SampleSpellCheckerService'
4. adb reboot
5. adb shell dumpsys textservices
-> make sure 'isCurrentUserUnlockingOrUnlocked' is false.
-> make sure no spell checker service appears.
6. adb shell settings get --user 0 secure selected_spell_checker
-> com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
7. Enter password to unlock the user
8. adb shell dumpsys textservices
-> make sure 'isCurrentUserUnlockingOrUnlocked' is true.
-> make sure all spell checker services for user 0 appear.
9. adb shell settings get --user 0 secure selected_spell_checker
-> com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
10. Open "Api Demos" app
11. Go to Views/Text/EditText
12. Focus into the first EditText then type "aaa"
13. Focus into the second EditText then type "aaa"
14. adb shell dumpsys textservices
-> make sure 'com.example.android.samplespellcheckerservice'
is serving spell checker sessions.
15. Switch to User A (userId 10)
16. adb shell dumpsys textservices
-> make sure 'isCurrentUserUnlockingOrUnlocked' is false.
-> make sure no spell checker service appears.
17. adb shell settings get --user 10 secure selected_spell_checker
-> com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
18. Enter password to unlock the user
19. adb shell dumpsys textservices
-> make sure 'isCurrentUserUnlockingOrUnlocked' is true.
-> make sure all spell checker services for user 10 appear.
20. adb shell settings get --user 0 secure selected_spell_checker
-> com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
21. Open "Api Demos" app
22. Go to Views/Text/EditText
23. Focus into the first EditText then type "aaa"
24. Focus into the second EditText then type "aaa"
25. adb shell dumpsys textservices
-> make sure 'com.example.android.samplespellcheckerservice'
is serving spell checker sessions.
26. Switch back to Owner (userId 0)
27. adb shell dumpsys textservices
-> make sure 'isCurrentUserUnlockingOrUnlocked' is true.
-> make sure all spell checker services for user 0 appear.
28. Switch to User A (userId 10)
29. adb shell dumpsys textservices
-> make sure 'isCurrentUserUnlockingOrUnlocked' is true.
-> make sure all spell checker services for user 10 appear.
Test: Test direct boot aware spell checker services on a direct boot
enabled device as follows.
1. On a direct-boot enabled device, complete the above steps to
set up the device.
2. adb shell settings put --user 0 secure selected_spell_checker 'com.example.android.samplespellcheckerservice2/.SampleSpellCheckerService'
3. adb shell settings put --user 10 secure selected_spell_checker 'com.example.android.samplespellcheckerservice2/.SampleSpellCheckerService'
4. adb reboot
5. adb shell dumpsys textservices
-> make sure 'isCurrentUserUnlockingOrUnlocked' is false.
-> make sure no spell checker service appears.
6. adb shell settings get --user 0 secure selected_spell_checker
-> com.example.android.samplespellcheckerservice2/.SampleSpellCheckerService
7. Enter password to unlock the user
8. adb shell dumpsys textservices
-> make sure 'isCurrentUserUnlockingOrUnlocked' is true.
-> make sure all spell checker services for user 0 appear.
9. adb shell settings get --user 0 secure selected_spell_checker
-> com.example.android.samplespellcheckerservice2/.SampleSpellCheckerService
10. Open "Api Demos" app
11. Go to Views/Text/EditText
12. Focus into the first EditText then type "aaa"
13. Focus into the second EditText then type "aaa"
14. adb shell dumpsys textservices
-> make sure 'com.example.android.samplespellcheckerservice2'
is serving spell checker sessions.
15. Switch to User A (userId 10)
16. adb shell dumpsys textservices
-> make sure 'isCurrentUserUnlockingOrUnlocked' is false.
-> make sure no spell checker service appears.
17. adb shell settings get --user 10 secure selected_spell_checker
-> com.example.android.samplespellcheckerservice2/.SampleSpellCheckerService
18. Enter password to unlock the user
19. adb shell dumpsys textservices
-> make sure 'isCurrentUserUnlockingOrUnlocked' is true.
-> make sure all spell checker services for user 10 appear.
20. adb shell settings get --user 0 secure selected_spell_checker
-> com.example.android.samplespellcheckerservice2/.SampleSpellCheckerService
21. Open "Api Demos" app
22. Go to Views/Text/EditText
23. Focus into the first EditText then type "aaa"
24. Focus into the second EditText then type "aaa"
25. adb shell dumpsys textservices
-> make sure 'com.example.android.samplespellcheckerservice2'
is serving spell checker sessions.
26. Switch back to Owner (userId 0)
27. adb shell dumpsys textservices
-> make sure 'isCurrentUserUnlockingOrUnlocked' is true.
-> make sure all spell checker services for user 0 appear.
28. Switch to User A (userId 10)
29. adb shell dumpsys textservices
-> make sure 'isCurrentUserUnlockingOrUnlocked' is true.
-> make sure all spell checker services for user 10 appear.
Test: Test direct boot unaware spell checker services on a direct boot
disabled device as follows.
1. On a direct-boot disabled device, complete the above steps to
set up the device.
2. adb shell settings put --user 0 secure selected_spell_checker 'com.example.android.samplespellcheckerservice/.SampleSpellCheckerService'
3. adb shell settings put --user 10 secure selected_spell_checker 'com.example.android.samplespellcheckerservice/.SampleSpellCheckerService'
4. adb reboot
5. adb shell dumpsys textservices
-> make sure isCurrentUserUnlockingOrUnlocked is true.
Enabling spell checker services in CryptKeeperBounce mode is
currently working as intended but does not make much sense.
Bug 64178633 aims to address this.
6. Enter password to finish CryptKeeperBounce.
7. adb shell dumpsys textservices
-> make sure 'isCurrentUserUnlockingOrUnlocked' is true.
-> make sure all spell checker services for user 0 appear.
8. adb shell settings get --user 0 secure selected_spell_checker
-> com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
9. Open "Api Demos" app
10. Go to Views/Text/EditText
11. Focus into the first EditText then type "aaa"
12. Focus into the second EditText then type "aaa"
13. adb shell dumpsys textservices
-> make sure 'com.example.android.samplespellcheckerservice'
is serving spell checker sessions.
14. Switch to User A (userId 10)
15. adb shell dumpsys textservices
-> make sure 'isCurrentUserUnlockingOrUnlocked' is true.
-> make sure all spell checker services for user 10 appear.
16. adb shell settings get --user 10 secure selected_spell_checker
-> com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
17. Enter password to unlock the lock screen
18. adb shell dumpsys textservices
-> make sure 'isCurrentUserUnlockingOrUnlocked' is true.
-> make sure all spell checker services for user 10 appear.
19. adb shell settings get --user 0 secure selected_spell_checker
-> com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
20. Open "Api Demos" app
21. Go to Views/Text/EditText
22. Focus into the first EditText then type "aaa"
23. Focus into the second EditText then type "aaa"
24. adb shell dumpsys textservices
-> make sure 'com.example.android.samplespellcheckerservice'
is serving spell checker sessions.
25. Switch back to Owner (userId 0)
26. adb shell dumpsys textservices
-> make sure 'isCurrentUserUnlockingOrUnlocked' is true.
-> make sure all spell checker services for user 0 appear.
27. Switch to User A (userId 10)
28. adb shell dumpsys textservices
-> make sure 'isCurrentUserUnlockingOrUnlocked' is true.
-> make sure all spell checker services for user 10 appear.
Change-Id: Ied29a47b6e32e83a9893111c9df291bee355077c
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
e7bca94d811e59bbcb93cbc0bde5087bbb067cb7 25-Jul-2017 Guliz Tuncay <gulizseray@google.com> Rename resetInternalState to resetInternalStateLocked

resetInternalState method is almost always called within a synchronized
block (except in the constructor of TSMS ) and it also calls several
methods that require a lock. Hence, to keep consistency, we rename this
method to resetInternalStateLocked.
This is a preparation CL for Bug 63041121.

Bug: 63041121
Test: None
Change-Id: I92a81adb10da58ab81cfef8a995cfd9e37020825
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
1a6f4c79f2a74d2c895650c4cb06e1c00b4cc477 14-Jul-2017 Guliz Tuncay <gulizseray@google.com> removeAll unregisters callbacks in the wrong order, causing exception

If we switch from a user with active SpellCheckerBindGroups to another
user, an exception is thrown and the system reports that the user switch
was not successful. The source of this exception is removeAll() method
used in unbindServiceLocked(). It seems that removeAll() retrieves the
number of callbacks of mListeners object and removes the registered
callbacks of this object one by one in a loop. However, this causes the
size of the mListeners change along the way and each element's index
decreases by one at each iteration, causing the loop to eventually try
to operate on a null object. This error was introduced by
I38942765ed6bec6713757b1d5f325e7a633c2ba7

Fixes: 63703656
Test: Manually tested as follows
1. Flash a new OS image with this change
2. Complete the setup wizard (if any)
3. make ApiDemos -j
4. adb install -r out/target/product/marlin/data/app/ApiDemos/ApiDemos.apk
5. Open "Api Demos" app
6. Go to Views/Text/EditText
7. Focus in to the first EditText then type "aaa"
8. Focus in to the second EditText then type "aaa"
9. Run `adb shell dumpsys textservices` to confirm that there are multiple
listener in one of the items in "Spell Checker Bind Groups" section.
10. Switch to the Guest user.
11. Run `adb logcat -s SystemServiceManager:E` to confirm that there is no
NullPointerException
Change-Id: Ibfdb07266a5a9127425b7ecffa9afbb8718eca62
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
aaa0e43dd4ffa63bf3e043b645df416fedc1a55c 11-Jul-2017 Guliz Tuncay <gulizseray@google.com> 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
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
1c94b8ccafc1aa66d458972b6ac1a709428a818f 10-Jul-2017 Guliz Tuncay <gulizseray@google.com> Clean up TSMS#setCurrentSpellCheckerLocked.

Remove the unnecessary calls to getCurrentSpellChecker and containsKey
in TSMS#setCurrentSpellCheckerLocked. We do not change visible
user/developer behavior in this CL.

Fixes: 63540846
Test: Manually as follows:
Test 1:
1. Make sure you have two users such as this:
User Owner (userId 0), User A (userId 11)
2. Clear A's SC settings on the command line by
adb shell "settings --user 11 put secure selected_spell_checker ''"
4. Check SC value in settings, should be null
5. Switch to Owner
6. Switch back to A (so that TSMS#resetInternalState is called)
7. Make sure SC value in settings is not empty by
adb shell settings --user 11 get secure selected_spell_checker
Test 2:
1. 2 versions of SampleSpellCheckerService:
one with a single SCS (v1), one with 2 SCSs (v2)
2. Install v2 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. Install v1
5. adb shell settings get secure selected_spell_checker
Should return
com.example.android.samplespellcheckerservice/.SampleSpellCheckerService2
This is buggy behavior, see bug#63542224. We aim to keep the
user/developer behavior as is.
Change-Id: Idaa5b738d0d8c01c12a8d9cd7ac2a6b27c7ae4ad
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
10ae385e29a0cc49e59b6ce53f803c938c1ec277 07-Jul-2017 Guliz Tuncay <gulizseray@google.com> Use a separate lock object instead of mSpellCheckerMap

In order to make TSMS multi-user aware, the first step is to get rid of
the use of user-specific mSpellCheckerMap (since there will be one for
each user) in the synchronized blocks, and instead use a separate
object lock.

Bug: 63041121
Test: Manually tested 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 the selected spell
checker service (SCS) by running
adb shell dumpsys textservices
6. Observe that there is no connection to selected 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 the selected SCS.
9. Kill the app manually. Repeat steps 5 and 6 to see bindings
and connections are removed again.
10. adb shell settings put secure selected_spell_checker com.google.android.inputmethod.latin/com.android.inputmethod.latin.spellcheck.AndroidSpellCheckerService
11. Repeat 7, 8, 9.
12. Switch to a secondary user account. Repeat 3-11.
Change-Id: Ic8772accb4c6225a1e662fd2fa371b2f4c87e445
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
46a54e8be637c0e7922bcbec0bf5bc308dcdf69d 23-Jun-2017 Guliz Tuncay <gulizseray@google.com> Remove the internal APIs of TSM to change spell checker settings

Previously, TextServicesManager was exposing APIs to system services to
modify spell checker settings. However, Settings application is the only
client of these APIs and there is no need to expose it to all the other
services. Settings app already has the WRITE_SECURE_SETTINGS permission
and can directly update the spell checker settings. Hence, we can remove
these APIs from TSM.

Fixes: 62950392
Test: Manually 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. Install SampleSpellCheckerService
4.1 tapas SampleSpellCheckerService
4.2. make -j
4.3. adb install -r out/target/product/generic/system/app/SampleSpellCheckerService/SampleSpellCheckerService.apk
5. Set the current spell checker service to be AOSP SCS by
adb shell settings put secure selected_spell_checker com.android.inputmethod.latin/.spellcheck.AndroidSpellCheckerService
6. Run a test program that has TextView and tap on one of the
TextViews and type some text.
7. Observe that there is a connection to AOSP SCS by
adb shell dumpsys textservices
8. Set the current spell checker service to be
SampleSpellCheckerService SCS by
adb shell settings put secure selected_spell_checker com.example.android.samplespellcheckerservice/.SampleSpellCheckerService
9. Observe that there is a connection to SampleSpellCheckerService
SCS by
adb shell dumpsys textservices
Change-Id: I4513ca661788f00785f684c21d7244c233b6e33e
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
f14fe14a3bd09ac60d70e33248eae88c4da08a66 23-Jun-2017 Yohei Yukawa <yukawa@google.com> Remove a redundant synchronized block

This CL removes a redundant synchronized block, which was accidentally
added in the previous CL [1] that simplified
TextServicesManagerService (TSMS) by using RemoteCallbackList<E>.

Since SpellCheckerBindGroup#removeListener() internally acquires the
lock on TSMS#mSpellCheckerMap, there is no need to acquire the same
lock in the caller.

This CL is just a mechanical clean-up. No behavior change is intended.

[1]: I38942765ed6bec6713757b1d5f325e7a633c2ba7
f982e75a262db16e60fd3565638d399315dba761

Bug: 35102403
Test: compile
Change-Id: I6d47e8cb6e301286bcb26922b74ee7cac2c5c1c5
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
f982e75a262db16e60fd3565638d399315dba761 14-Jun-2017 Guliz Tuncay <gulizseray@google.com> Use RemoteCallbackList to implement TSMS#mListeners

Previously, TSMS extends IBinder.DeathRecipient to implement its own
death recipient class to keep track of disconnected service listeners.
Using RemoteCallbackList simplifies the implementation.

Fixes: 35102403
Test: Manually tested 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 the app manually. Repeat steps 5 and 6 to see bindings
and connections are removed again.
10. Repeat 7 and 8.
11. Kill SCS
adb shell ps -A | grep com.android.inputmethod.latin | awk '{print $2}' | xargs adb shell kill -KILL
12. Repeat steps 5 and 6 to observe that the bindings and the
connection to SCS are preserved.
Change-Id: I38942765ed6bec6713757b1d5f325e7a633c2ba7
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
787aa8c0db993e8f624769382c7395dd2f369ac4 20-Jun-2017 Guliz Tuncay <gulizseray@google.com> 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
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
fe9a53bc45fd0124a876dc0a49680aaf86641d3e 31-Mar-2017 Jeff Sharkey <jsharkey@android.com> Consistent dump() permission checking.

This change introduces new methods on DumpUtils that can check if the
caller has DUMP and/or PACKAGE_USAGE_STATS access. It then moves all
existing dump() methods to use these checks so that we emit
consistent error messages.

Test: cts-tradefed run commandAndExit cts-dev -m CtsSecurityTestCases -t android.security.cts.ServicePermissionsTest
Bug: 32806790
Change-Id: Iaff6b9506818ee082b1e169c89ebe1001b3bfeca
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
7fa65eef203c4ed3ce00ddef96ccf311d3bfb58c 08-Feb-2017 Yohei Yukawa <yukawa@google.com> Avoid sync IPCs from TSMS to SpellCheckerService

Currently, TextServicesManagerServices uses an AIDL interface called
ISpellCheckerService when binding to a spell-checking service.
However, this interface uses synchronous (blocking) binder calls
rather than asynchronous (oneway) calls. As a result, there are
situations where the system process has made a blocking binder call
into untrusted application code from its main looper thread.

As general policy, the system process must never allow its looper
threads to block on application code.

This CL addresses the above issue by converting ISpellCheckerService
into oneway interface, which instead takes a result receiver
ISpellCheckerServiceCallback so that spell-checking services can
return results asynchronously.

Note that the above protocol issue was also the root cause of
Bug 5471520. Hence we can also logically revert the previous CL [1]
for Bug 5471520.

[1]: Iedf2c2cdd8d4834545d06d72ade3ce211b104b1d
4e713f14419a37f385cf1509b011982bdcf67edc

Test: Ran `adb shell dumpsys textservices` to check the
"Spell Checker Bind Groups:" section in the following three
steps.
1. Before apps start requesting spell checker sessions.
2. While apps are owning active spell checker sessions.
3. After all the apps that owned spell checker sessions are
gone.
Made sure that spell checker service is not running when
there is not spell checker bind group.
Bug: 7254002
Change-Id: I92e7aa40dc9ea14f67d355f0bfa15325b775d27b
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
06b4be771cc59bcc64e86d5763eee41431a03523 29-Jan-2017 Yohei Yukawa <yukawa@google.com> Minor code clean-ups with no behavior change

As another preparation CL to work on Bug 7254002, this CL cleans up
miscellaneous minor coding style issues that do not cause any
user-visible problems.

- Add final keyboard to classes that are not intended to be extended.
- Add static keyboard to nested classes if possible.
- Fix a typo in log message.
- Remove a redundant synchronized keyword in method signature.
- Remove unused class fields.

Test: checkbuild
Bug: 7254002
Change-Id: I3b54179116a74cafc99a3dfd3f2a429a7111c12e
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
dc589ac82b5fe2063f4cfd94c8ae26d43d5420a0 11-Nov-2016 Sudheer Shanka <sudheersai@google.com> Update usage of ActivityManagerNative.

- Remove references to ActivityManagerProxy.
- Add isSystemReady to ActivityManager.

Bug: 30977067
Test: cts/hostsidetests/services/activityandwindowmanager/util/run-test android.server.cts
adb shell am instrument -e class com.android.server.am.ActivityManagerTest,com.android.server.am.TaskStackChangedListenerTest \
-w com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Change-Id: I07390b6124fb1515821f5c0b37baf6ae74adc8fa
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
e3e31a880169a5d685ea4bf7efae81430a62b4fe 20-Sep-2016 Yohei Yukawa <yukawa@google.com> Fix another deadlock between IMMS and TSMS

Bug 31247871 and Bug 31273203 are the same in terms of that both can be
triggered by calling TSM##getCurrentSpellCheckerSubtype() but different
in terms of what lock objects are involved.

To summarize

Bug 31273203: between IMMS#mMethodMap and IMM#H
A. OnClickListener.onClick() running in the IMMS locks IMMS#mMethodMap
then does some View operations, which can be blocked until
IMM#H is unlocked (e.g. IMM#onViewDetachedFromWindow()).
B. TSMS#getCurrentSpellCheckerSubtype() internally calls
IMM#getCurrentInputMethodSubtype(), which locks IMM#H then can be
blocked until IMMS#mMethodMap is unlocked.
The tricky point here is that IMMS and TSMS are running in the same
process hence IMM#H are actually shared between them.

Bug 31247871: between IMMS#mMethodMap and TSMS#mSpellCheckerMap
C. IMMS locks IMMS#mMethodMap then calls
InputMethodUtils#setNonSelectedSystemImesDisabledUntilUsed(), which
can be blocked until TSMS#mSpellCheckerMap is unlocked.
D. TSMS#getCurrentSpellCheckerSubtype() locks TSMS#mSpellCheckerMap
then may call IMM#getCurrentInputMethodSubtype(), which can be
blocked until IMMS#mMethodMap is released.

This CL aims to remove the layered lock in D to close Bug 31247871,
while the previous CL [1] took care of B to close Bug 31273203.

Note that A and C are still concerning and should also be taken care of
as a part of Bug 31273203.

[1]: I20cf2c20f49b1b02c0f7a18257b49d4bcc081b5d
fa1886feea55785f413f5efcd86bccca92f26759

Bug: 31247871
Bug: 31273203
Change-Id: I26479e7aa306e0df91d9911891d5625dd5f99678
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
ce18c8167766f92856f94a8e88e19de4698960e6 28-Apr-2016 Jeff Sharkey <jsharkey@android.com> Introduce "unlocking" vs "unlocked" nuance.

There is a narrow window of time during user unlock where we're
reconciling user storage and dispatching the "unlock" status to
various internal system services. While in this "unlocking" state,
apps need to be told that the user still isn't actually "unlocked"
so they don't try making calls to AccountManager, etc.

The majority of internal services are interested in merging together
both the "unlocking" and "unlocked" state, so update them.

Clarify naming in AccountManagerService to make it clear that a local
list is being used, which mirrors the naming in MountService.

To match UX/PM requested behavior, move PRE_BOOT_COMPLETED dispatch
after the user is unlocked, but block BOOT_COMPLETED dispatch until
after all PRE_BOOT receivers are finished to avoid ANRs.

Bug: 28040947, 28164677
Change-Id: I57af2351633d9159f4483f19657ce0b62118d1ce
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
a09b4d2a611a7606e8fc8c73a24bd941b6fc173f 15-Apr-2016 Narayan Kamath <narayan@google.com> Remove unnecessary allocation+unboxing of objects.

Transforming String->int can be done with 0 allocations
using Integer.parseInt.

bug: 28078871
Change-Id: I8d9f322d7154728849dde61ef282046032858d60
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
7f98aa4aa93497692f200c553d2d6fff402e3de2 07-Apr-2016 Fyodor Kupolov <fkupolov@google.com> Added getProfileIds method returning array of userIds

Previously many usages of UserManager.getProfiles and getEnabledProfiles
were only using ids of returned users. Given that the list of users needs
to be parceled and unparceled for Binder calls, returning array of ids
minimizes memory usage and serialization time.

A new method getProfileIds was introduced which returns an array of userIds.
Existing method calls were updated where appropriate.

Bug: 27705805
Change-Id: Ic5d5decd77567ba0f749e48837a2c6fa10e812c0
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
08ce18728cbdadbf376d2d1014daa06cf05c295a 17-Mar-2016 Yohei Yukawa <yukawa@google.com> Add more @NonNull/@Nullable to TextServicesSettings.

We need to fix TextServicesSettings as well as InputMethodSettings,
because regarding Bug 27687531 the same issue was copied from
InputMethodSettings to TextServicesSettings by my CL [1].

This is basically a mirror of the fix for InputMethodSettings [2].

[1]: Ie3d61458648df469abe149b7aaad8087c531a675
49ed14017697f8f19b8d49d55462713396a0588e
[2]: I169ad4957e68b65c64251b0849056195b8ca4911

Bug: 27687531
Change-Id: I068f8821a32d2e199fbf6239bbe833da8c5a4e5e
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
ad150ee271d9a0d27289407bd023924e23ec2b26 17-Mar-2016 Yohei Yukawa <yukawa@google.com> Remove an unnecessary int to String conversion.

This is a safe refactoring to remove an unnecessary int to String
conversion in TextServicesSettings.

Settings.Secure.SELECTED_SPELL_CHECKER_SUBTYPE is a integer value that
indicates subtype ID (or SpellCheckerSubtype#hashCode() if the subtype
ID is not specified), and we can just rely on
Settings.Secure#putIntForUser() rather than converting int to String
by ourselves then pass it to Settings.Secure#putStringForUser().

Note that this change is still OK for existing users because
Settings.Secure#putIntForUser() has been internally doing exactly the
same thing.

Bug: 27687531
Change-Id: Ibcf12746f1295c12bec095300ea7f6ced0a51d09
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
f0f168066335ac1ec103e575d693a957da714c4e 09-Mar-2016 Yohei Yukawa <yukawa@google.com> Reset TSMS when the device is unlocked.

This ports my previous CL for InputMethodManagerService [1] to
TextServicesSettings (TSMS).

With File-Based Encryption (FBE), now we have yet another runteime event
to reset TSMS state in order to keep the list of available spell
checkers updated.

See my previous commit message [1] for details about the idea.

Rebuild spell checker list when the system becomes ready.

[1]: Ifa2225070bf8223f8964cf063c86889e312c5e9a
0e367d08aab2c1cb2d0fb9cbf1e8a6d09d1ac523

Bug: 27456430
Change-Id: I2b5a6989a99fd18b3bf109f5cda6270ccadaaf6d
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
49ed14017697f8f19b8d49d55462713396a0588e 08-Mar-2016 Yohei Yukawa <yukawa@google.com> Add copy-on-write mode to TextServicesSettings.

This ports my previous CL for InputMethodManagerService [1] to
TextServicesSettings (TSMS).

This is a preparation for File-Based Encryption (FBE) support in TSMS.

With this CL, we start switching TextServicesSettings from copy-on-write
mode to real mode and start rebuilding the list of available spell
checkers when the system becomes ready. Anything else should be the
same. See the previous commit message [1] for details.

[1]: I9c6f9bb3d51174198e5f73588637f87ea0d90e11
68645a638ad1bfb734b2b0f56b17fe206bb891c5

Bug: 27456430
Change-Id: Ie3d61458648df469abe149b7aaad8087c531a675
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
85df698df50262602ee2ac622d5c46f630c18f02 09-Mar-2016 Yohei Yukawa <yukawa@google.com> Dump spell checker service info from TSMS.

This is a preparation CL to make TextServicesManagerService (TSMS)
encryption-aware.

This CL changes nothing except for the output of TSMS#dump().

To diagnose File-Based Encryption (FBE) related issues, it would be
useful if we can see if each spell checker service is encryption-aware
or not. To do that this CL updates TSMS#dump() so that it can include
the result of ResolveInfo#dump() as we have done in
InputMethodManagerService.

This CL also updates TSMS#dump() so that its output can be more
consistent with IMMS#dump().

Bug: 27456430
Change-Id: Ie2321278f1d52533a3cd74d98f1f84c950a8f6d0
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
f0ed48d18d51021f0c7b6d771d4f8048d21fd5bd 08-Mar-2016 Yohei Yukawa <yukawa@google.com> Have unified setter/getter for TSMS Settings.

This ports my previous CL for InputMethodManagerService [1] to
TextServicesManagerService (TSMS).

In order to make TSMS encryption-aware, we are going to introduce a new
state where any read/write access to Secure Settings from TSMS is
virtualized so that we can temporarily enable only encryption-aware
spell checkers until the user unlocks the device then revert
any changes made before the device enters into an unlocked state.

See my previous commit message [1] for details.

This is still a preparation code. Behavior change is not intended yet
in this CL.

[1]: I0f79243e5cc1556764da37fa38078e075a27d42b
8752367042cb690f78953557433c16ac77eeea45

Bug: 27456430
Change-Id: I97a1e2f75bdecb0aa88fb35dfe56732c08fcbbd5
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
d1f7c4bad186b64d4d3f3cb56ac610afc2e81b86 07-Mar-2016 Yohei Yukawa <yukawa@google.com> Merge changes I2d6f9932,Ib3cc799d into nyc-dev

* changes:
Rely on SystemService#onSwitchUser() in TSMS.
Switch to SystemService lifecycle in TSMS.
9faa2aeb8a0d40bd834b7a4bf6343fbae3a302e3 07-Mar-2016 Yohei Yukawa <yukawa@google.com> Rely on SystemService#onSwitchUser() in TSMS.

SystemService class has already provided SystemService#onSwitchUser()
callback event. We do not need to set up SynchronousUserSwitchObserver
separately in TextServicesManagerService.

Bug: 25816558
Bug: 27456430
Change-Id: I2d6f9932f30b72cf4ae4bc0c41810f75e2667478
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
a6a152e7de2b6db73474620c1eccda1ebe2eee9b 07-Mar-2016 Yohei Yukawa <yukawa@google.com> Switch to SystemService lifecycle in TSMS.

Like we did this for InputMethodManagerService [1],
TextServicesManagerService (TSMS) needs to be recognized by
SystemServiceManager with SystemService lifecycle mechanism so that we
can receive SystemService#onUnlockUser() event, which is necessary to
make TSMS encryption-aware.

As a preparation, with this CL we only does mechcanical migration to
SystemService lifecycle mechanism in TSMS. Hence no user-visible
behavior change should occur.

[1]: Ic17667df60b30e5355b61a3601ad27a000cab3a3
1e33dc8fdf3f722ecd32cc586b2a9515de24a242

Bug: 27456430
Change-Id: Ib3cc799d384f259b4fa3f5295f2da198df015eb8
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
074637f1626a56031bcb98b8a88345c8f57cbb77 06-Mar-2016 Yohei Yukawa <yukawa@google.com> Use Java7 diamond operator in TSMS.

This CL changes nothing except for deleting redundant type parameters by
using diamond operator in TextServicesManagerService (TSMS).

No behavior change is intended.

Bug: 27456430
Change-Id: I18708fe44d2d9edfef8c1cf7cffef1bb0b5c003a
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
6005b3f87b063ee7ab7e8877a6a8c90b480f3341 24-Nov-2015 Fyodor Kupolov <fkupolov@google.com> Added SynchronousUserSwitchObserver

This class provides a synchronous version of onUserSwitching, which does not
require notifying a callback.

Bug: 25816558
Change-Id: Id31bb79bf10b5afd72dfca28cf4bea817e726f6f
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
777ef95ebf18c61ff09e7567a06058d351c530ca 26-Nov-2015 Yohei Yukawa <yukawa@google.com> Use Context.getSystemService(Class<T>) for InputMethodManager.

This is a mechanical replacement of Context.getSystemService(String)
with Context.getSystemService(Class<T>) when retrieving
InputMethodManager. Note those are bundled code. Hence we don't need
to make sure Build.VERSION.SDK_INT >= 23.

Change-Id: Icc64942ad8f11e44bf84f8d4fe476b2fdd1257f3
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
7c69636c9a406265e1da368f3edfd8fb9651132c 16-Sep-2015 Xiaohui Chen <xiaohuic@google.com> Cleanup USER_OWNER in various services

Bug: 19913735
Change-Id: I980370bab18e1b9ccf4043eed2b9fd721a940f72
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
174843afb629c57af19e14ee3ec4a91358061dd9 27-Jun-2015 Yohei Yukawa <yukawa@google.com> Check system locale when picking up an initial SpellChecker.

Since Ia25e7b4f308778891929e31b8cbd741f6848cce4, the TSMS has
picked up the first found spell checker no matter regardless of
the system locale.

The primary goal of this CL is to introduce a low-risk fix for
the situation where two or more spell checker services are
pre-installed but they are well different from each other in
terms of supported languages. Solving the problem in more
ambiguous and complicated situation is beyond the goal of
this CL.

With this CL, we still pick up the first found spell checker
but also require the spell checker supports a certain locale.
We will try several locales starting with the system locale
to some fallback locales until we find one appropriate spell
checker. If no spell checker is picked up in this process,
we simply pick up the first one as we have done.

Examples about what locales will be checked are:

A. System locale: en_US
1. en_US
2. en_GB
3. en

B. System locale: en
1. en
2. en_US
3. en_GB

C. System locale: en_IN
1. en_IN
2. en_US
3. en_GB
4. en

D. System locale: ja_JP
1. ja_JP
2. ja
3. en_US
4. en_GB
5. en

E. System locale: fil_PH
1. fil_PH
2. fil
3. en_US
4. en_GB
5. en

F. System locale: th_TH_TH
1. th_TH_TH
2. th_TH
3. th
4. en_US
5. en_GB
6. en

Bug: 22042994
Change-Id: I094f1c33430f7904a1dac6167431d6df64a07212
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
d69e4c1460017062e7c36be55801cb434ad19d97 24-Apr-2015 Dianne Hackborn <hackbod@google.com> Update use of procstate for services.

Now that we have a separate foreground service proc state
(above a sleeping top app), update various system services
to put their bindings into this state when appropriate.

There are two new bind flags for this -- one that just always
makes it a foreground service, another that only does it when
the device is awake (useful for things like the wallpaper).

And with all of that, tweak network policy manager to only
include apps that are at least foreground service state when
in power save and device idle modes. This will allow us to
further reduce the set of apps that have network access
(in particular not giving access to the current top app when
the screen is off), hopefully leading to even better battery
life.

Change-Id: I91d85a5c5ed64e856149e9a5d94a634a7925ec7f
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
429796226a8831af63a6303a58329f6b68f7b100 13-Apr-2015 Kenny Guy <kennyguy@google.com> Add foreground profile changed to user switch observer.

Called when the focused activity changes from one profile
to another to allow sys ui to vary display based on the
current profile.
This reverts commit 735a3f90598be31bca5d551d781280a205a5f27f.
Resubmitting with fix for build break in another package.

Bug: 19531782
Change-Id: I98cd2968ade3b1d23feb90d98057f306695d569e
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
735a3f90598be31bca5d551d781280a205a5f27f 13-Apr-2015 Kenny Guy <kennyguy@google.com> Revert "Add foreground profile changed to user switch observer."

This reverts commit 99b9030a3ececd9b88e5011c98be0a5b9499c776.

Change-Id: If152904f298ecd9e6fd5d038797d061a5c85eec8
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
99b9030a3ececd9b88e5011c98be0a5b9499c776 01-Apr-2015 Kenny Guy <kennyguy@google.com> Add foreground profile changed to user switch observer.

Called when the focused activity changes from one profile
to another to allow sys ui to vary display based on the
current profile.

Bug: 19531782
Change-Id: I1f98398f4b37ce77077394546906ef4dff06cd47
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
095fa371643b1d8e829067ea4ed93c357b39e773 27-Oct-2014 Yohei Yukawa <yukawa@google.com> Conditionally allow non-primay profiles to use TextServices

With this CL, non-primary profiles become able to use
TextServices (spelling correction services) if and only if
the active spell checker service is the system's one.

Basically this CL just copies the same logic from
InputMethodManagerService that were implemented as
I3bd87b32aec69c3f8d and Id5d4f29017b7ca6844632 with adding
a condition to see if the spell checker is system's one
or not.

Note that this is a tentative solution and can be removed
once TSMS fully supports multiuser.

Also note that this CL heavily relies on the fact that
setting apps isonly running in the current user. This is
because that some risky operations that are exposed from
TSMS are non-public APIs an accessible only from @hide
methods in TextServicesManager, and those @hide methods
are actually used only by the settings app so far.

BUG: 16285536
Change-Id: Iae9045ba5baccd04ed68906e7afb9160677ec4a5
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java
49782e46c0eb85a25ae2abcf80880c48dbab5aea 20-Dec-2013 Amith Yamasani <yamasani@google.com> am 9158825f: Move some system services to separate directories

* commit '9158825f9c41869689d6b1786d7c7aa8bdd524ce':
Move some system services to separate directories
9158825f9c41869689d6b1786d7c7aa8bdd524ce 22-Nov-2013 Amith Yamasani <yamasani@google.com> Move some system services to separate directories

Refactored the directory structure so that services can be optionally
excluded. This is step 1. Will be followed by another change that makes
it possible to remove services from the build.

Change-Id: Ideacedfd34b5e213217ad3ff4ebb21c4a8e73f85
/frameworks/base/services/core/java/com/android/server/TextServicesManagerService.java