Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b89a0bd authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

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
parent 7eee1815
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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()));
                }