From b12fdf9b3755329f3b555f50979180579c365aff Mon Sep 17 00:00:00 2001 From: Antonio Kantek Date: Mon, 11 Jul 2022 18:35:58 +0000 Subject: [PATCH] Minor clean ups on InputMethodUtils and SubtypeUtils Fixes: 238470908 Test: atest CtsInputMethodTestCases InputMethodUtilTests Change-Id: I975779a6866b59765afa401fb06e34872fb63c3e --- .../server/inputmethod/InputMethodUtils.java | 2 +- .../server/inputmethod/SubtypeUtils.java | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/services/core/java/com/android/server/inputmethod/InputMethodUtils.java b/services/core/java/com/android/server/inputmethod/InputMethodUtils.java index 70132670e68ea..3373f0c436f98 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodUtils.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodUtils.java @@ -142,7 +142,7 @@ final class InputMethodUtils { } continue; } - ApplicationInfo ai = null; + ApplicationInfo ai; try { ai = packageManagerForUser.getApplicationInfo(packageName, PackageManager.ApplicationInfoFlags.of( diff --git a/services/core/java/com/android/server/inputmethod/SubtypeUtils.java b/services/core/java/com/android/server/inputmethod/SubtypeUtils.java index eb85dd0112888..7085868e4f611 100644 --- a/services/core/java/com/android/server/inputmethod/SubtypeUtils.java +++ b/services/core/java/com/android/server/inputmethod/SubtypeUtils.java @@ -85,8 +85,8 @@ final class SubtypeUtils { continue; } } - if (mode == SUBTYPE_MODE_ANY || TextUtils.isEmpty(mode) || - mode.equalsIgnoreCase(subtype.getMode())) { + if (mode == SUBTYPE_MODE_ANY || TextUtils.isEmpty(mode) + || mode.equalsIgnoreCase(subtype.getMode())) { return true; } } @@ -237,17 +237,20 @@ final class SubtypeUtils { /** * If there are no selected subtypes, tries finding the most applicable one according to the * given locale. - * @param subtypes this function will search the most applicable subtype in subtypes - * @param mode subtypes will be filtered by mode - * @param locale subtypes will be filtered by locale - * @param canIgnoreLocaleAsLastResort if this function can't find the most applicable subtype, - * it will return the first subtype matched with mode + * + * @param subtypes a list of {@link InputMethodSubtype} to search + * @param mode the mode used for filtering subtypes + * @param locale the locale used for filtering subtypes + * @param canIgnoreLocaleAsLastResort when set to {@code true}, if this function can't find the + * most applicable subtype, it will return the first subtype + * matched with mode + * * @return the most applicable subtypeId */ static InputMethodSubtype findLastResortApplicableSubtypeLocked( Resources res, List subtypes, String mode, String locale, boolean canIgnoreLocaleAsLastResort) { - if (subtypes == null || subtypes.size() == 0) { + if (subtypes == null || subtypes.isEmpty()) { return null; } if (TextUtils.isEmpty(locale)) {