History log of /frameworks/base/core/java/com/android/internal/inputmethod/LocaleUtils.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
dce7df3ec23788d002a8696229483f71b19b9d6b 05-May-2017 Yohei Yukawa <yukawa@google.com> Avoid unnecessary ULocale.addLikelySubtags()

This CL gets rid of unnecessary operations from
LocaleUtils.filterByLanguage() to speed it up, especially for the case
where there is an IME that has many subtypes.

ULocale.addLikelySubtags(ULocale) is known to be slow. Given an IME
that has N IME subtypes, LocaleUtils.filterByLanguage() calls it no
less than N times even when the only one system language is selected.
This has contributed to device boot time (Bug 32343335) time and user
switching time (Bug 28750507) since Android N where IME support
started taking multi-locale into account.

With this CL, LocaleUtils.filterByLanguage() no longer calls it
for a subtype unless its language part of the locale matches one of
user-selected system locales.

The only assumption we made here is

for any Locale objects l1 and l2
TextUtils.equals(l1.getLanguage(), l2.getLanguage())
and
TextUtils.equals(ul1.getLanguage(), ul2.getLanguage())
are equivalent, where
ul1 = ULocale.addLikelySubtags(ULocale.forLocale(l1)) and
ul2 = ULocale.addLikelySubtags(ULocale.forLocale(l2))

This should be reasonable assumption, at least for locales we want to
care about for IMEs. Under this assumption there is no behavior
change at all.

Test: bit FrameworksCoreTests:com.android.internal.inputmethod.LocaleUtilsTest
Bug: 37647204
Change-Id: Ic96900fcaf3db8b7046a50b3fe6ad65aceada369
/frameworks/base/core/java/com/android/internal/inputmethod/LocaleUtils.java
23cbe85610f780134cc77dd4a54732a22ed6e86e 18-May-2016 Yohei Yukawa <yukawa@google.com> Move LocaleList to avoid layering violation.

Since LocaleList needs to depend on android.os.Parcelable, we cannot let
that class belong to "android.util" package, which causes layering
violation.

Bug: 28819696
Change-Id: Ia8de2ee9df3dd0a42b1fe84574439519b680fe18
/frameworks/base/core/java/com/android/internal/inputmethod/LocaleUtils.java
072a95a3094af2ced4f009ad62c4553c28e3f830 05-Mar-2016 Seigo Nonaka <nona@google.com> Introduce script matching for enabling default IME subtypes.

This is 2nd attempt of I5bb1bd8cdb9096d516d60beb9936e55bf2b757ae

The motivation of this CL is enhance the default IME subtype enabling
algorithm. The new approach is done by score based algorithm. The
design of the matching score is determined as follows:
- The matching score for the each two locale is up to 3 and determined
as follows:
- Score of 3 : matches all language, script and country.
- Score of 2 : matches the language and script.
- Score of 1 : matches the language regardless of country.
- Score of 0 : doesn't match the language regardless of script and
country.
- All locales are fully expanded before matching by addLikelySubtags in
ICU.

Bug: 27129703
Bug: 27348943
Change-Id: I8fc774154f5175abff2f16e8f12a4847bf5f5b7c
/frameworks/base/core/java/com/android/internal/inputmethod/LocaleUtils.java
77dd59fc2a0db94f0c58e17097fd6f07c1b5db8c 06-Mar-2016 Yohei Yukawa <yukawa@google.com> Revert "Introduce script matching for enabling default IME subtypes."

This reverts commit 9e7a1c9824cffca32fd7d58bb13bd3416ab32091.

Seems that that CL causes ArrayIndexOutOfBoundsException when
initializing InputMethodManagerService, which results in an infinite
boot animation.

Bug: 27129703
Bug: 27348943
Change-Id: I474a87876670ac018c675ac7b4608e90fbb2434b
/frameworks/base/core/java/com/android/internal/inputmethod/LocaleUtils.java
9e7a1c9824cffca32fd7d58bb13bd3416ab32091 05-Mar-2016 Seigo Nonaka <nona@google.com> Introduce script matching for enabling default IME subtypes.

The motivation of this CL is enhance the default IME subtype enabling
algorithm. The new approach is done by score based algorithm. The
design of the matching score is determined as follows:
- The matching score for the each two locale is up to 3 and determined
as follows:
- Score of 3 : matches all language, script and country.
- Score of 2 : matches the language and script.
- Score of 1 : matches the language regardless of country.
- Score of 0 : doesn't match the language regardless of script and
country.
- All locales are fully expanded before matching by addLikelySubtags in
ICU.

Bug: 27129703
Change-Id: I5bb1bd8cdb9096d516d60beb9936e55bf2b757ae
/frameworks/base/core/java/com/android/internal/inputmethod/LocaleUtils.java
102ff0726dad764df741e41766d78fcfb829184a 25-Feb-2016 Yohei Yukawa <yukawa@google.com> Add a utility method to filter locales.

This is a preparation CL to take secondary system locales into
account in InputMethodUtils#getImplicitlyApplicableSubtypesLocked().

Suppose the following situation:

available subtypes:
en-US, en-IN, and en-GB, fr, fr-CA, fr-CH, fr (QWERTZ)
system locales:
en-GB, en-US, fr-MC

Basically we want to have at most one subtype for each language appears
in system locales. Hence the goal of this utility method is to filter
the above available subtypes into en-GB and fr. In other word, we do
not want to enable both en-GB and en-US subtypes in this scenario.

This CL introduces LocaleUtils#filterByLanguage() for this purpose, with
some unit tests. Note that that method is not used in production yet.

Bug: 27129703
Change-Id: I315cf3722a06e00bdbfac284c4949578da8fe78d
/frameworks/base/core/java/com/android/internal/inputmethod/LocaleUtils.java