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
This commit is contained in:
Yohei Yukawa
2018-11-20 18:45:59 -08:00
parent 7eee18151a
commit 9b89a0bdff

View File

@@ -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<InputMethodSubtype> explicitlyOrImplicitlyEnabledSubtypeList =
mSettings.getEnabledInputMethodSubtypeListLocked(mContext, imi, true);
HashSet<String> enabledSubtypeSet = new HashSet<>();
final ArraySet<String> enabledSubtypeSet = new ArraySet<>();
for (InputMethodSubtype subtype : explicitlyOrImplicitlyEnabledSubtypeList) {
enabledSubtypeSet.add(String.valueOf(subtype.hashCode()));
}