Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b1845f31 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Deprecate private AsciiCapable protocol

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
      c3690567
 [2]: Ic3ace4b6e0432d56696bcbc0be336aec1dc744a5
      dc8abf6c

Fix: 78537996
Test: make doc-comment-check-docs -j
Test: atest InputMethodPreferenceTest InputMethodUtilsTest
Change-Id: I56c0c19878657a41882c2d784e1ac96a52ab33f6
parent 88363dfc
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -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 NOT_A_SUBTYPE_ID_STR = String.valueOf(NOT_A_SUBTYPE_ID);
    private static final String TAG_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE =
    private static final String TAG_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE =
            "EnabledWhenDefaultIsNotAsciiCapable";
            "EnabledWhenDefaultIsNotAsciiCapable";
    private static final String TAG_ASCII_CAPABLE = "AsciiCapable";


    // The string for enabled input method is saved as follows:
    // The string for enabled input method is saved as follows:
    // example: ("ime0;subtype0;subtype1;subtype2:ime1:ime2;subtype0")
    // example: ("ime0;subtype0;subtype1;subtype2:ime1:ime2;subtype0")
@@ -539,7 +538,7 @@ public class InputMethodUtils {
            final int numApplicationSubtypes = applicableSubtypes.size();
            final int numApplicationSubtypes = applicableSubtypes.size();
            for (int i = 0; i < numApplicationSubtypes; ++i) {
            for (int i = 0; i < numApplicationSubtypes; ++i) {
                final InputMethodSubtype subtype = applicableSubtypes.get(i);
                final InputMethodSubtype subtype = applicableSubtypes.get(i);
                if (subtype.containsExtraValueKey(TAG_ASCII_CAPABLE)) {
                if (subtype.isAsciiCapable()) {
                    hasAsciiCapableKeyboard = true;
                    hasAsciiCapableKeyboard = true;
                    break;
                    break;
                }
                }
+8 −2
Original line number Original line Diff line number Diff line
@@ -3419,10 +3419,16 @@
             constructor or 0. Arrays.hashCode(new Object[] {locale, mode, extraValue,
             constructor or 0. Arrays.hashCode(new Object[] {locale, mode, extraValue,
             isAuxiliary, overridesImplicitlyEnabledSubtype}) will be used instead. -->
             isAuxiliary, overridesImplicitlyEnabledSubtype}) will be used instead. -->
        <attr name="subtypeId" format="integer"/>
        <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
             capable, it should guarantee that the user can input ASCII characters with
             this subtype. This is important because many password fields only allow
             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" />
        <attr name="isAsciiCapable" format="boolean" />
        <!-- The BCP-47 Language Tag of the subtype.  This replaces
        <!-- The BCP-47 Language Tag of the subtype.  This replaces
        {@link android.R.styleable#InputMethod_Subtype_imeSubtypeLocale}.  -->
        {@link android.R.styleable#InputMethod_Subtype_imeSubtypeLocale}.  -->
+0 −8
Original line number Original line Diff line number Diff line
@@ -87,7 +87,6 @@ public class InputMethodUtilsTest {
    private static final String SUBTYPE_MODE_HANDWRITING = "handwriting";
    private static final String SUBTYPE_MODE_HANDWRITING = "handwriting";
    private static final String SUBTYPE_MODE_ANY = null;
    private static final String SUBTYPE_MODE_ANY = null;
    private static final String EXTRA_VALUE_PAIR_SEPARATOR = ",";
    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 =
    private static final String EXTRA_VALUE_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE =
            "EnabledWhenDefaultIsNotAsciiCapable";
            "EnabledWhenDefaultIsNotAsciiCapable";


@@ -910,13 +909,6 @@ public class InputMethodUtilsTest {
            subtypeExtraValue.append(EXTRA_VALUE_ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE);
            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()
        return new InputMethodSubtypeBuilder()
                .setSubtypeNameResId(0)
                .setSubtypeNameResId(0)
                .setSubtypeIconResId(0)
                .setSubtypeIconResId(0)