Skip to content
Commit 08943191 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

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
parent bd2b4aa3
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment