Fix toLanguageTag() after upgrading ICU to 64.2

ICU has been upgraded to version 64.2 which introduced test failure when
creating locales. There was a behaviour change in uloc_canonicalize()
method which previously preserved languages "und" and "root" but now it
collapses them to an empty string. So basically, after some discussion
ICU folks agreed that "root", "und" and "" locales should mean pretty
much the same thing and behaviour of some methods has been changed to
make things consistent. See more at
https://unicode-org.atlassian.net/browse/ICU-20273.

Bug: 125283072
Test: mmm -j frameworks/minikin/tests/unittest && \
      adb sync data && \
      adb shell /data/nativetest/minikin_tests/minikin_tests

Change-Id: I5a8f84f0cfa8d55fe2b29ff5a8592db8b487944f
diff --git a/libs/minikin/LocaleListCache.cpp b/libs/minikin/LocaleListCache.cpp
index c191ea6..15156cd 100644
--- a/libs/minikin/LocaleListCache.cpp
+++ b/libs/minikin/LocaleListCache.cpp
@@ -49,10 +49,13 @@
         return 0;
     }
 
-    // Preserve "und" and "und-****" since uloc_addLikelySubtags changes "und" to "en-Latn-US".
-    if (strncmp(output, "und", 3) == 0 &&
-        (outLength == 3 || (outLength == 8 && output[3] == '_'))) {
-        output[3] = '-';  // to be language tag.
+    // Preserve "" and "_****" since uloc_addLikelySubtags changes "" to "en_Latn_US".
+    if (outLength == 0 || (outLength == 5 && output[0] == '_')) {
+        if (output[0] == '_') {
+            output[0] = '-';
+        }
+        std::string buf(output, outLength);
+        outLength = (size_t)snprintf(output, outSize, "und%s", buf.c_str());
         return outLength;
     }