Loading services/core/java/com/android/server/inputmethod/AdditionalSubtypeUtils.java +2 −2 Original line number Diff line number Diff line Loading @@ -114,7 +114,7 @@ final class AdditionalSubtypeUtils { * @param userId The user ID to be associated with. */ static void save(ArrayMap<String, List<InputMethodSubtype>> allSubtypes, ArrayMap<String, InputMethodInfo> methodMap, @UserIdInt int userId) { InputMethodMap methodMap, @UserIdInt int userId) { final File inputMethodDir = getInputMethodDir(userId); if (allSubtypes.isEmpty()) { Loading Loading @@ -143,7 +143,7 @@ final class AdditionalSubtypeUtils { @VisibleForTesting static void saveToFile(ArrayMap<String, List<InputMethodSubtype>> allSubtypes, ArrayMap<String, InputMethodInfo> methodMap, AtomicFile subtypesFile) { InputMethodMap methodMap, AtomicFile subtypesFile) { // Safety net for the case that this function is called before methodMap is set. final boolean isSetMethodMap = methodMap != null && methodMap.size() > 0; FileOutputStream fos = null; Loading services/core/java/com/android/server/inputmethod/HardwareKeyboardShortcutController.java +3 −5 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.annotation.AnyThread; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.util.ArrayMap; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodSubtype; Loading @@ -44,16 +43,15 @@ final class HardwareKeyboardShortcutController { return mUserId; } HardwareKeyboardShortcutController( @NonNull ArrayMap<String, InputMethodInfo> methodMap, @UserIdInt int userId) { HardwareKeyboardShortcutController(@NonNull InputMethodMap methodMap, @UserIdInt int userId) { mUserId = userId; reset(methodMap); } @GuardedBy("ImfLock.class") void reset(@NonNull ArrayMap<String, InputMethodInfo> methodMap) { void reset(@NonNull InputMethodMap methodMap) { mSubtypeHandles.clear(); final InputMethodSettings settings = new InputMethodSettings(methodMap, mUserId); final InputMethodSettings settings = InputMethodSettings.create(methodMap, mUserId); final List<InputMethodInfo> inputMethods = settings.getEnabledInputMethodListLocked(); for (int i = 0; i < inputMethods.size(); ++i) { final InputMethodInfo imi = inputMethods.get(i); Loading services/core/java/com/android/server/inputmethod/InputMethodInfoUtils.java +1 −2 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Slog; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodSubtype; Loading Loading @@ -204,7 +203,7 @@ final class InputMethodInfoUtils { */ @Nullable static InputMethodInfo chooseSystemVoiceIme( @NonNull ArrayMap<String, InputMethodInfo> methodMap, @NonNull InputMethodMap methodMap, @Nullable String systemSpeechRecognizerPackageName, @Nullable String currentDefaultVoiceImeId) { if (TextUtils.isEmpty(systemSpeechRecognizerPackageName)) { Loading services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +114 −134 File changed.Preview size limit exceeded, changes collapsed. Show changes services/core/java/com/android/server/inputmethod/InputMethodMap.java 0 → 100644 +78 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.inputmethod; import android.annotation.AnyThread; import android.annotation.IntRange; import android.annotation.NonNull; import android.annotation.Nullable; import android.util.ArrayMap; import android.view.inputmethod.InputMethodInfo; import java.util.List; /** * A map from IME ID to {@link InputMethodInfo}, which is guaranteed to be immutable thus * thread-safe. */ final class InputMethodMap { private static final ArrayMap<String, InputMethodInfo> EMPTY_MAP = new ArrayMap<>(); private final ArrayMap<String, InputMethodInfo> mMap; static InputMethodMap emptyMap() { return new InputMethodMap(EMPTY_MAP); } static InputMethodMap of(@NonNull ArrayMap<String, InputMethodInfo> map) { return new InputMethodMap(map); } private InputMethodMap(@NonNull ArrayMap<String, InputMethodInfo> map) { mMap = map.isEmpty() ? EMPTY_MAP : new ArrayMap<>(map); } @AnyThread @Nullable InputMethodInfo get(@Nullable String imeId) { return mMap.get(imeId); } @AnyThread @NonNull List<InputMethodInfo> values() { return List.copyOf(mMap.values()); } @AnyThread @Nullable InputMethodInfo valueAt(int index) { return mMap.valueAt(index); } @AnyThread boolean containsKey(@Nullable String imeId) { return mMap.containsKey(imeId); } @AnyThread @IntRange(from = 0) int size() { return mMap.size(); } } Loading
services/core/java/com/android/server/inputmethod/AdditionalSubtypeUtils.java +2 −2 Original line number Diff line number Diff line Loading @@ -114,7 +114,7 @@ final class AdditionalSubtypeUtils { * @param userId The user ID to be associated with. */ static void save(ArrayMap<String, List<InputMethodSubtype>> allSubtypes, ArrayMap<String, InputMethodInfo> methodMap, @UserIdInt int userId) { InputMethodMap methodMap, @UserIdInt int userId) { final File inputMethodDir = getInputMethodDir(userId); if (allSubtypes.isEmpty()) { Loading Loading @@ -143,7 +143,7 @@ final class AdditionalSubtypeUtils { @VisibleForTesting static void saveToFile(ArrayMap<String, List<InputMethodSubtype>> allSubtypes, ArrayMap<String, InputMethodInfo> methodMap, AtomicFile subtypesFile) { InputMethodMap methodMap, AtomicFile subtypesFile) { // Safety net for the case that this function is called before methodMap is set. final boolean isSetMethodMap = methodMap != null && methodMap.size() > 0; FileOutputStream fos = null; Loading
services/core/java/com/android/server/inputmethod/HardwareKeyboardShortcutController.java +3 −5 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.annotation.AnyThread; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.util.ArrayMap; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodSubtype; Loading @@ -44,16 +43,15 @@ final class HardwareKeyboardShortcutController { return mUserId; } HardwareKeyboardShortcutController( @NonNull ArrayMap<String, InputMethodInfo> methodMap, @UserIdInt int userId) { HardwareKeyboardShortcutController(@NonNull InputMethodMap methodMap, @UserIdInt int userId) { mUserId = userId; reset(methodMap); } @GuardedBy("ImfLock.class") void reset(@NonNull ArrayMap<String, InputMethodInfo> methodMap) { void reset(@NonNull InputMethodMap methodMap) { mSubtypeHandles.clear(); final InputMethodSettings settings = new InputMethodSettings(methodMap, mUserId); final InputMethodSettings settings = InputMethodSettings.create(methodMap, mUserId); final List<InputMethodInfo> inputMethods = settings.getEnabledInputMethodListLocked(); for (int i = 0; i < inputMethods.size(); ++i) { final InputMethodInfo imi = inputMethods.get(i); Loading
services/core/java/com/android/server/inputmethod/InputMethodInfoUtils.java +1 −2 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Slog; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodSubtype; Loading Loading @@ -204,7 +203,7 @@ final class InputMethodInfoUtils { */ @Nullable static InputMethodInfo chooseSystemVoiceIme( @NonNull ArrayMap<String, InputMethodInfo> methodMap, @NonNull InputMethodMap methodMap, @Nullable String systemSpeechRecognizerPackageName, @Nullable String currentDefaultVoiceImeId) { if (TextUtils.isEmpty(systemSpeechRecognizerPackageName)) { Loading
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +114 −134 File changed.Preview size limit exceeded, changes collapsed. Show changes
services/core/java/com/android/server/inputmethod/InputMethodMap.java 0 → 100644 +78 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.inputmethod; import android.annotation.AnyThread; import android.annotation.IntRange; import android.annotation.NonNull; import android.annotation.Nullable; import android.util.ArrayMap; import android.view.inputmethod.InputMethodInfo; import java.util.List; /** * A map from IME ID to {@link InputMethodInfo}, which is guaranteed to be immutable thus * thread-safe. */ final class InputMethodMap { private static final ArrayMap<String, InputMethodInfo> EMPTY_MAP = new ArrayMap<>(); private final ArrayMap<String, InputMethodInfo> mMap; static InputMethodMap emptyMap() { return new InputMethodMap(EMPTY_MAP); } static InputMethodMap of(@NonNull ArrayMap<String, InputMethodInfo> map) { return new InputMethodMap(map); } private InputMethodMap(@NonNull ArrayMap<String, InputMethodInfo> map) { mMap = map.isEmpty() ? EMPTY_MAP : new ArrayMap<>(map); } @AnyThread @Nullable InputMethodInfo get(@Nullable String imeId) { return mMap.get(imeId); } @AnyThread @NonNull List<InputMethodInfo> values() { return List.copyOf(mMap.values()); } @AnyThread @Nullable InputMethodInfo valueAt(int index) { return mMap.valueAt(index); } @AnyThread boolean containsKey(@Nullable String imeId) { return mMap.containsKey(imeId); } @AnyThread @IntRange(from = 0) int size() { return mMap.size(); } }