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

Commit 506d42e2 authored by Zixuan Qu's avatar Zixuan Qu
Browse files

Remove country subtag validation in VirtualKeyboardConfig .

This is to allow valid language tags such as "ru" and "de-Latn".

Bug: 270716410
Test: atest VirtualInputDeviceConfigTest
Change-Id: Ia0bd634f1a5ebfe6a7677301a7d2e96d92e1a307
parent 58197e43
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -110,10 +110,7 @@ public final class VirtualKeyboardConfig extends VirtualInputDeviceConfig implem

        /**
         * Sets the preferred input language of the virtual keyboard using an IETF
         * <a href="https://tools.ietf.org/html/bcp47">BCP-47</a>
         * conformant tag. See {@code keyboardLocale} attribute in
         * frameworks/base/packages/InputDevices/res/xml/keyboard_layouts.xml for a list of
         * supported language tags.
         * <a href="https://tools.ietf.org/html/bcp47">BCP-47</a>  conformant tag.
         *
         * The passed in {@code languageTag} will be canonized using {@link
         * ULocale} and used by the system as a hint to configure the keyboard layout.
@@ -135,7 +132,7 @@ public final class VirtualKeyboardConfig extends VirtualInputDeviceConfig implem
        public Builder setLanguageTag(@NonNull String languageTag) {
            Objects.requireNonNull(languageTag, "languageTag cannot be null");
            ULocale locale = ULocale.forLanguageTag(languageTag);
            if (locale.getLanguage().isEmpty() || locale.getCountry().isEmpty()) {
            if (locale.getLanguage().isEmpty()) {
                throw new IllegalArgumentException("The language tag is not valid.");
            }
            mLanguageTag = ULocale.createCanonical(locale).toLanguageTag();
@@ -144,8 +141,8 @@ public final class VirtualKeyboardConfig extends VirtualInputDeviceConfig implem

        /**
         * Sets the preferred layout type of the virtual keyboard. See {@code keyboardLayoutType}
         * attribute in frameworks/base/packages/InputDevices/res/xml/keyboard_layouts.xml for a
         * list of supported layout types.
         * attribute in frameworks/base/core/res/res/values/attrs.xml for a list of supported
         * layout types.
         *
         * Note that the preferred layout is not guaranteed. If the specified layout type is
         * well-formed but not supported, the keyboard will be using English US QWERTY layout.