From 9b89a0bdffda13253e0f8c99b40f57c737a8c777 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Tue, 20 Nov 2018 18:45:59 -0800 Subject: [PATCH] Replace HashSet with ArraySet in InputMethodSubtypeSwitchingController There should be no user-visible bahavior change because InputMethodSubtypeSwitchingController relies only on the following three operations: * Collection#add() * Collection#remove() * Collection#contains() There should be no behavior difference between HashSet and ArraySet for those operations. Bug: 119839847 Test: Manually verified as follows: 1. Open Settings. 2. Go to System -> Languages & input -> Languages 3. Tap "Add a language" 4. Select "Afrikaans" -> Suid-Afrika 5. make -j SoftKeyboard 6. adb install -r $OUT/system/app/SoftKeyboard/SoftKeyboard.apk 7. adb shell ime enable com.example.android.softkeyboard/.SoftKeyboard 8. Tap the keyboard icon on the navigation bar. 9. Make sure that items are sorted in the following order: * English (US) - Android Keyboard (AOSP) * Afrikaans - Android Keyboard (AOSP) * English (United States) - Sample Soft Keyboard Change-Id: Ib09826962dacea1f5edfc37012f4794851288f47 --- .../inputmethod/InputMethodSubtypeSwitchingController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java b/services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java index 88e9976dfd3d7..b13c307497d92 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodSubtypeSwitchingController.java @@ -20,6 +20,7 @@ import android.annotation.Nullable; import android.content.Context; import android.content.pm.PackageManager; import android.text.TextUtils; +import android.util.ArraySet; import android.util.Log; import android.util.Printer; import android.util.Slog; @@ -31,7 +32,6 @@ import com.android.server.inputmethod.InputMethodUtils.InputMethodSettings; import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Objects; @@ -199,7 +199,7 @@ final class InputMethodSubtypeSwitchingController { final InputMethodInfo imi = imis.get(i); final List explicitlyOrImplicitlyEnabledSubtypeList = mSettings.getEnabledInputMethodSubtypeListLocked(mContext, imi, true); - HashSet enabledSubtypeSet = new HashSet<>(); + final ArraySet enabledSubtypeSet = new ArraySet<>(); for (InputMethodSubtype subtype : explicitlyOrImplicitlyEnabledSubtypeList) { enabledSubtypeSet.add(String.valueOf(subtype.hashCode())); }