History log of /frameworks/base/core/tests/coretests/src/android/view/textservice/SpellCheckerSubtypeTest.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
868d19b93b1e20c802a001c7304f8bcac5fe5114 08-Dec-2015 Yohei Yukawa <yukawa@google.com> Use BCP-47 LanguageTag in IME/Spell-Checker.

The primary goal of this CL is to make it clear that BCP-47 is the
expected format to annotate locale information for each
{InputMethod, SpellCkecker}Subtype. In order to avoid possible
compatibility issues, this CL introduce a new "languageTag" attribute
instead of reusing existing "imeSubtypeMode" and "subtypeLocale"
attributes.

For IME developers, this CL changes nothing unless "languageTag"
attribute is specified. To summarize:

A: If only legacy locale-string is specified
(existing IMEs/Spell-Checkers fall into this category):
-> The system uses locale-string.

B: If only LanguageTag is specified:
-> The system uses LanguageTag.

C: If both locale-string and languageTag are specified:
-> The system uses LanguageTag. Legacy locale-string is ignored.

For application developers, there should be some follow-ups CLs because
even with this CL most likely they would still have to take care of
previous versions of Android where:
- Locale#forLanguageTag() (N/A in API Level 20 and prior)
- Locale#toLanguageTag() (N/A in API Level 20 and prior)
- InputMethodSubtype#getLocale() (Deprecated in N)
- SpellCheckerSubtype#getLocale() (Deprecated in N)
- InputMethodSubtype#getLanguageTag() (N/A in M and prior)
- SpellCheckerSubtype#getLanguageTag() (N/A in M and prior)
One idea would be is in the official support library to provide a utility
method that takes care of above tasks and just returns a Locale object.
If we had a utility method in the support library, probably not
returning a Locale object from #getLanguageTag() would make sense.

From performance point of view both existing legacy locale-string
attribute and new LanguageTag attribute are just String objects that
travel from XML manifest to system services to applications via IPCs.
Hence there are no performance implications except for having one more
String objects.

Bug: 22858221
Change-Id: I6db107ad2afc7709167f7c4e5d24bd589ac8bd70
/frameworks/base/core/tests/coretests/src/android/view/textservice/SpellCheckerSubtypeTest.java
0894319162a2a1f4260805938d4807c4ffcbcb0f 05-Dec-2015 Yohei Yukawa <yukawa@google.com> Add subtypeId for SpellCheckerSubtype.

What this CL actually does is just copying the existing concept
"subtypeId" from InputMethodSubtype to SpellCheckerSubtype.

To recap, the underlying problem is that the system has stored only the
return value of SpellCheckerSubtype#hashCode() to track the set of
enabled subtypes, and SpellCheckerSubtype#hashCode() has been
implemented as Arrays.hashCode(new Object[] {locale, extraValue}), which
is problematic because:
- Spell checker developers cannot change "locale" and/or 'extraValue'
if they want to keep enabled subtypes enabled.
- Android Framework developers cannot change the hash function even
when new fields are added if they want to keep enabled subtypes
enabled.
InputMethodSubtype has had the same issue, and what we did was
introducing a concept "subtypeId", which allows IME developers to
specify the return value of #hashCode().

For instance, suppose that a subtype X has already been used in
production with the following attributes:
- locale: "tl_PH"
- extraValues: "key1=value1,key2=value2"

With "subtypeId", you can change the attributes of subtype X without
losing the enabled state of subtype X on devices as follows.
- locale: "fil_PH"
- extraValues: "key1=value1,key2=value2,key3=value3"
- subtypeId: Arrays.hashCode(new Object[] {
"tl_PH", "key1=value1,key2=value2"})

This CL also deprecates existing public constructor of
SpellCheckerSubtype, which was probably published as a public API by
mistake. Note that the constructor of SpellCheckerInfo class is @hide.
Also there is no public API that receives SpellCheckerSubtype object
instantiated by developers with custom data. Making developers to be
able to instantiate SpellCheckerSubtype does not make sense right now.

Bug: 11736916
Bug: 22858221
Change-Id: I98f05c1e9421c47a93769bc4a6fe11b678bc2509
/frameworks/base/core/tests/coretests/src/android/view/textservice/SpellCheckerSubtypeTest.java
eae60ba5a4a39d59940e9749a4ad26281d016d03 04-Dec-2015 Yohei Yukawa <yukawa@google.com> Rewrite a fake language code "tl" in SpellChecker.

With following CLs, we already have a special rewrite rule of "tl" to
"fil" for IMEs that are targeting older versions of Android earlier than
Lollipop that did not support three letter language codes and used
"tl" (Tagalog) as the language string for "fil" (Filipino).
- 92280cd309b0f5967dd253280962d8581844db89 [1]
- ed65bc0c62ca99a118057db7ad54c4ccc14d52d0 [2]

[1]: I94f203bddceb9c87710cb187cc3cc0ee6d9092a5
[2]: Ica9cd2baac002c406f92331aadd7725d7424046a

With this CL, we have the same rewrite rule for spell checker services.

Bug: 20696126
Change-Id: I0af0f520a15337e33973391c9965364e3ae1ee4c
/frameworks/base/core/tests/coretests/src/android/view/textservice/SpellCheckerSubtypeTest.java
658c29e86ef7c2d4c3a3fa8ebad5726d692e7c68 04-Dec-2015 Yohei Yukawa <yukawa@google.com> retry: Add @hide SpellCheckerSubtype#getLocaleObject().

This is the 2nd try of I39dc0c310158ad23ba6c987efce07deaf30ce693.

This is a mechanical refactoring with no behavior change.

With this CL, InputMethodSubtype and SpellCheckerSubtype have the same
getLocaleObject() hidden API, which makes it easy to share the logic in
subsequent CLs.

No behavior change is intended.

Bug: 11736916
Bug: 20696126
Bug: 22858221
Change-Id: I51be014c752b736a808e2b0d56e664941a218a2f
/frameworks/base/core/tests/coretests/src/android/view/textservice/SpellCheckerSubtypeTest.java
80a918c3bd2de754027b7e7dffdd38ed138b69ce 04-Dec-2015 Yohei Yukawa <yukawa@google.com> Revert "Add @hide SpellCheckerSubtype#getLocaleObject()."

This reverts commit e3c761c87efdee7c28461559015fa76602d4605a.

Previous CL unintentionaly contained behavior change.

Change-Id: I1e350f224df815e991d9f42ac4145ecfc5c1c8b0
/frameworks/base/core/tests/coretests/src/android/view/textservice/SpellCheckerSubtypeTest.java
e3c761c87efdee7c28461559015fa76602d4605a 04-Dec-2015 Yohei Yukawa <yukawa@google.com> Add @hide SpellCheckerSubtype#getLocaleObject().

This is a mechanical refactoring with no behavior change.

With this CL, InputMethodSubtype and SpellCheckerSubtype have the same
getLocaleObject() hidden API, which makes it easy to share the logic in
subsequent CLs.

Bug: 11736916
Bug: 20696126
Bug: 22858221
Change-Id: I39dc0c310158ad23ba6c987efce07deaf30ce693
/frameworks/base/core/tests/coretests/src/android/view/textservice/SpellCheckerSubtypeTest.java
9534ae185809b69e153736287acbf9c8e52e7492 04-Dec-2015 Yohei Yukawa <yukawa@google.com> Add SpellCheckerSubtypeTest.

Before introducing behavior changes, this CL adds
SpellCheckerSubtypeTest to make the current behavior clear.

Bug: 11736916
Bug: 20696126
Bug: 22858221
Change-Id: Ied18580f31497156510e1b785adfc248683ba94d
/frameworks/base/core/tests/coretests/src/android/view/textservice/SpellCheckerSubtypeTest.java