Make LocaleUtils#getLanguageFromLocaleString() work again

This is a follow up CL to our previous CL [1], which aimed to remove
the code duplicate without changing the behavior but ended up
introducing an unexpected behavior change, which is actually caught as
test failures.

In short, the legacy "subtypeLocale" uses a non-standard text format,
which cannot be parsed with

  Locale#forLanguageTag().

Note that subtypes have already accept BCP 47 LanguageTags [2], that's
where

  Locale#forLanguageTag()

should be used.

Anyway, with this commit

  LocaleUtils#getLanguageFromLocaleString()

starts working correctly again.

Futher cleanups will be coming at Bug 321064051.

 [1]: I67ec553f8cfc21b1916a5a32783630ea43f2d407
      d24bd53f88e82f64f8135289de61634aab69e93e
 [2]: I6db107ad2afc7709167f7c4e5d24bd589ac8bd70
      868d19b93b1e20c802a001c7304f8bcac5fe5114

Bug: 303302694
Bug: 321064051
Fix: 320780830
Test: atest FrameworksServicesTests:com.android.server.inputmethod.InputMethodSubtypeSwitchingControllerTest
Test: atest FrameworksServicesTests:com.android.server.inputmethod.InputMethodUtilsTest
Test: atest FrameworksServicesTests:com.android.server.inputmethod.LocaleUtilsTest
Change-Id: Ifdbc565455cd4ff3edf47221949e8c16f3a457c2
2 files changed