summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yohei Yukawa <yukawa@google.com> 2024-03-04 13:46:45 -0800
committer Yohei Yukawa <yukawa@google.com> 2024-03-04 13:46:45 -0800
commit87218eb283fa92c0139a2bbe478e12e532914fcc (patch)
treefe50d7956bcd564d6ae73086596671cb1bc45c6b
parent3a9e332a0aef69947e059825f922006a0c41d2d4 (diff)
Make MyPackageMonitor#onPackageDataCleared multi-user aware
This is a follow up CL to our previous CL [1], which aimed to fix Bug 267124364 but forgot to take care of multi-user scenarios (Bug 328098968). With this commit InputMethodManagerService.MyPackageMonitor#onPackageDataCleared becomes fully multi-user aware. The corresponding CTS change [2] ensures that this scenario remains fixed. [1]: I159d9b7a2d1dcc8df478bb45d0be706d615724a2 [2]: Ie54f3674ca0a48cef090e528da9a414935cf74e6 Bug: 267124364 Fix: 328098968 Test: atest CtsInputMethodInstallTestCases:AdditionalSubtypeLifecycleTest Change-Id: If42c518765171ff8cb51af000542671676cd3801
-rw-r--r--services/core/java/com/android/server/inputmethod/InputMethodManagerService.java25
1 files changed, 20 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index 1564b2f86218..1f3c2f30212d 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -1341,20 +1341,35 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
@Override
public void onPackageDataCleared(String packageName, int uid) {
+ final int userId = getChangingUserId();
synchronized (ImfLock.class) {
+ final boolean isCurrentUser = (userId == mSettings.getUserId());
+ final AdditionalSubtypeMap additionalSubtypeMap;
+ final InputMethodSettings settings;
+ if (isCurrentUser) {
+ additionalSubtypeMap = mAdditionalSubtypeMap;
+ settings = mSettings;
+ } else {
+ additionalSubtypeMap = AdditionalSubtypeUtils.load(userId);
+ settings = queryInputMethodServicesInternal(mContext, userId,
+ additionalSubtypeMap, DirectBootAwareness.AUTO);
+ }
+
// Note that one package may implement multiple IMEs.
final ArrayList<String> changedImes = new ArrayList<>();
- for (InputMethodInfo imi : mSettings.getMethodList()) {
+ for (InputMethodInfo imi : settings.getMethodList()) {
if (imi.getPackageName().equals(packageName)) {
changedImes.add(imi.getId());
}
}
final AdditionalSubtypeMap newMap =
- mAdditionalSubtypeMap.cloneWithRemoveOrSelf(changedImes);
- if (newMap != mAdditionalSubtypeMap) {
- mAdditionalSubtypeMap = newMap;
+ additionalSubtypeMap.cloneWithRemoveOrSelf(changedImes);
+ if (newMap != additionalSubtypeMap) {
+ if (isCurrentUser) {
+ mAdditionalSubtypeMap = newMap;
+ }
AdditionalSubtypeUtils.save(
- mAdditionalSubtypeMap, mSettings.getMethodMap(), mSettings.getUserId());
+ newMap, settings.getMethodMap(), settings.getUserId());
}
if (!changedImes.isEmpty()) {
mChangedPackages.add(packageName);