OSDN Git Service

Add subtypeId for SpellCheckerSubtype.
authorYohei Yukawa <yukawa@google.com>
Sat, 5 Dec 2015 00:16:47 +0000 (16:16 -0800)
committerYohei Yukawa <yukawa@google.com>
Sat, 5 Dec 2015 00:16:47 +0000 (16:16 -0800)
commit0894319162a2a1f4260805938d4807c4ffcbcb0f
tree9d0a4db51db7619c8ffe2da97420decedfaa0a3a
parentbd2b4aa3f6eb2c699f46cc80001d05dd2ce8b353
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
api/current.txt
api/system-current.txt
api/test-current.txt
core/java/android/view/textservice/SpellCheckerInfo.java
core/java/android/view/textservice/SpellCheckerSubtype.java
core/res/res/values/attrs.xml
core/tests/coretests/src/android/view/textservice/SpellCheckerSubtypeTest.java