OSDN Git Service

Deprecate private AsciiCapable protocol
authorYohei Yukawa <yukawa@google.com>
Wed, 25 Apr 2018 01:36:23 +0000 (18:36 -0700)
committerYohei Yukawa <yukawa@google.com>
Wed, 25 Apr 2018 01:36:23 +0000 (18:36 -0700)
The concept "AsciiCapable InputMethodSubtype" was initially introduced
as a private protocol based on a magic keyword "AsciiCapable"
specified in "imeSubtypeExtraValue" attribute in API level 15 [1],
then became a public API "isAsciiCapable" attribute in API 19 [2].

However, it turns out that there remains one place in InputMethodUtils
where the previous private protocol is still used.

With this CL, InputMethodUtils stop relying on the previous private
AsciiCapable.

 [1]: I1a83b227498073c47567f73566043c273809adc9
      c36905673a7bcafe9ec74e82e6c4977f2aca6a50
 [2]: Ic3ace4b6e0432d56696bcbc0be336aec1dc744a5
      dc8abf6cee0bcf44e2cad8155f0c151105d46471

Fix: 78537996
Test: make doc-comment-check-docs -j
Test: atest InputMethodPreferenceTest InputMethodUtilsTest
Change-Id: I56c0c19878657a41882c2d784e1ac96a52ab33f6

core/java/com/android/internal/inputmethod/InputMethodUtils.java
core/res/res/values/attrs.xml
core/tests/coretests/src/com/android/internal/inputmethod/InputMethodUtilsTest.java

index 7f289d0..1e5b5c8 100644 (file)
@@ -67,7 +67,6 @@ public class InputMethodUtils {
     private static final String NOT_A_SUBTYPE_ID_STR = String.valueOf(NOT_A_SUBTYPE_ID);
     private static final String TAG_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE =
             "EnabledWhenDefaultIsNotAsciiCapable";
-    private static final String TAG_ASCII_CAPABLE = "AsciiCapable";
 
     // The string for enabled input method is saved as follows:
     // example: ("ime0;subtype0;subtype1;subtype2:ime1:ime2;subtype0")
@@ -539,7 +538,7 @@ public class InputMethodUtils {
             final int numApplicationSubtypes = applicableSubtypes.size();
             for (int i = 0; i < numApplicationSubtypes; ++i) {
                 final InputMethodSubtype subtype = applicableSubtypes.get(i);
-                if (subtype.containsExtraValueKey(TAG_ASCII_CAPABLE)) {
+                if (subtype.isAsciiCapable()) {
                     hasAsciiCapableKeyboard = true;
                     break;
                 }
index 21c10ce..158d4e5 100644 (file)
              constructor or 0. Arrays.hashCode(new Object[] {locale, mode, extraValue,
              isAuxiliary, overridesImplicitlyEnabledSubtype}) will be used instead. -->
         <attr name="subtypeId" format="integer"/>
-        <!-- Set to true if this subtype is ASCII capable. If the subtype is ASCII
+        <!-- Set to {@code true} if this subtype is ASCII capable. If the subtype is ASCII
              capable, it should guarantee that the user can input ASCII characters with
              this subtype. This is important because many password fields only allow
-             ASCII-characters. -->
+             ASCII-characters.
+
+             <p>Note: In order to avoid some known system issues on
+             {@link android.os.Build.VERSION_CODES#P} and prior OSes, you may want to include
+             {@code "AsciiCapable"} in
+             {@link android.R.styleable#InputMethod_Subtype_imeSubtypeExtraValue} when you specify
+             {@code true} to this attribute.-->
         <attr name="isAsciiCapable" format="boolean" />
         <!-- The BCP-47 Language Tag of the subtype.  This replaces
         {@link android.R.styleable#InputMethod_Subtype_imeSubtypeLocale}.  -->
index 863cf05..a49e203 100644 (file)
@@ -87,7 +87,6 @@ public class InputMethodUtilsTest {
     private static final String SUBTYPE_MODE_HANDWRITING = "handwriting";
     private static final String SUBTYPE_MODE_ANY = null;
     private static final String EXTRA_VALUE_PAIR_SEPARATOR = ",";
-    private static final String EXTRA_VALUE_ASCII_CAPABLE = "AsciiCapable";
     private static final String EXTRA_VALUE_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE =
             "EnabledWhenDefaultIsNotAsciiCapable";
 
@@ -910,13 +909,6 @@ public class InputMethodUtilsTest {
             subtypeExtraValue.append(EXTRA_VALUE_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE);
         }
 
-        // TODO: Remove following code. InputMethodSubtype#isAsciiCapable() has been publicly
-        // available since API level 19 (KitKat). We no longer need to rely on extra value.
-        if (isAsciiCapable) {
-            subtypeExtraValue.append(EXTRA_VALUE_PAIR_SEPARATOR);
-            subtypeExtraValue.append(EXTRA_VALUE_ASCII_CAPABLE);
-        }
-
         return new InputMethodSubtypeBuilder()
                 .setSubtypeNameResId(0)
                 .setSubtypeIconResId(0)