Merge "Simplify IMMS#setAdditionalInputMethodSubtypes()"

This commit is contained in:
TreeHugger Robot
2022-07-28 21:11:29 +00:00
committed by Android (Google) Code Review

View File

@@ -178,6 +178,7 @@ import com.android.internal.inputmethod.UnbindReason;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.os.TransferPipe;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.ConcurrentUtils;
import com.android.internal.util.DumpUtils;
import com.android.internal.view.IInputMethodManager;
@@ -4190,26 +4191,23 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
Slog.e(TAG, "Failed to get package infos");
return;
}
if (packageInfos != null) {
final int packageNum = packageInfos.length;
for (int i = 0; i < packageNum; ++i) {
if (packageInfos[i].equals(imi.getPackageName())) {
if (subtypes.length > 0) {
mAdditionalSubtypeMap.put(imi.getId(), toBeAdded);
} else {
mAdditionalSubtypeMap.remove(imi.getId());
}
AdditionalSubtypeUtils.save(mAdditionalSubtypeMap, mMethodMap,
mSettings.getCurrentUserId());
final long ident = Binder.clearCallingIdentity();
try {
buildInputMethodListLocked(false /* resetDefaultEnabledIme */);
} finally {
Binder.restoreCallingIdentity(ident);
}
return;
}
}
if (ArrayUtils.find(packageInfos,
packageInfo -> TextUtils.equals(packageInfo, imi.getPackageName())) == null) {
return;
}
if (toBeAdded.isEmpty()) {
mAdditionalSubtypeMap.remove(imi.getId());
} else {
mAdditionalSubtypeMap.put(imi.getId(), toBeAdded);
}
AdditionalSubtypeUtils.save(mAdditionalSubtypeMap, mMethodMap,
mSettings.getCurrentUserId());
final long ident = Binder.clearCallingIdentity();
try {
buildInputMethodListLocked(false /* resetDefaultEnabledIme */);
} finally {
Binder.restoreCallingIdentity(ident);
}
}
}