Move ICU.getDisplay* API into external/icu
Bug: 138994281
Test: m droid
Change-Id: I20c116224535400416d62f28a866ee95ebf959f1
diff --git a/luni/src/main/java/libcore/icu/ICU.java b/luni/src/main/java/libcore/icu/ICU.java
index a5337e2..b128c1a 100644
--- a/luni/src/main/java/libcore/icu/ICU.java
+++ b/luni/src/main/java/libcore/icu/ICU.java
@@ -354,30 +354,6 @@
public static native String getCurrencyCode(String countryCode);
- public static String getDisplayCountry(Locale targetLocale, Locale locale) {
- return getDisplayCountryNative(targetLocale.toLanguageTag(), locale.toLanguageTag());
- }
-
- private static native String getDisplayCountryNative(String targetLanguageTag, String languageTag);
-
- public static String getDisplayLanguage(Locale targetLocale, Locale locale) {
- return getDisplayLanguageNative(targetLocale.toLanguageTag(), locale.toLanguageTag());
- }
-
- private static native String getDisplayLanguageNative(String targetLanguageTag, String languageTag);
-
- public static String getDisplayVariant(Locale targetLocale, Locale locale) {
- return getDisplayVariantNative(targetLocale.toLanguageTag(), locale.toLanguageTag());
- }
-
- private static native String getDisplayVariantNative(String targetLanguageTag, String languageTag);
-
- public static String getDisplayScript(Locale targetLocale, Locale locale) {
- return getDisplayScriptNative(targetLocale.toLanguageTag(), locale.toLanguageTag());
- }
-
- private static native String getDisplayScriptNative(String targetLanguageTag, String languageTag);
-
public static native String getISO3Country(String languageTag);
public static native String getISO3Language(String languageTag);
diff --git a/luni/src/main/native/libcore_icu_ICU.cpp b/luni/src/main/native/libcore_icu_ICU.cpp
index 9f3e5df..e8f5c02 100644
--- a/luni/src/main/native/libcore_icu_ICU.cpp
+++ b/luni/src/main/native/libcore_icu_ICU.cpp
@@ -186,66 +186,6 @@
return (charCount == 0) ? NULL : jniCreateString(env, chars, charCount);
}
-static jstring ICU_getDisplayCountryNative(JNIEnv* env, jclass, jstring javaTargetLanguageTag, jstring javaLanguageTag) {
- ScopedIcuLocale icuLocale(env, javaLanguageTag);
- if (!icuLocale.valid()) {
- return NULL;
- }
- ScopedIcuLocale icuTargetLocale(env, javaTargetLanguageTag);
- if (!icuTargetLocale.valid()) {
- return NULL;
- }
-
- icu::UnicodeString str;
- icuTargetLocale.locale().getDisplayCountry(icuLocale.locale(), str);
- return jniCreateString(env, str.getBuffer(), str.length());
-}
-
-static jstring ICU_getDisplayLanguageNative(JNIEnv* env, jclass, jstring javaTargetLanguageTag, jstring javaLanguageTag) {
- ScopedIcuLocale icuLocale(env, javaLanguageTag);
- if (!icuLocale.valid()) {
- return NULL;
- }
- ScopedIcuLocale icuTargetLocale(env, javaTargetLanguageTag);
- if (!icuTargetLocale.valid()) {
- return NULL;
- }
-
- icu::UnicodeString str;
- icuTargetLocale.locale().getDisplayLanguage(icuLocale.locale(), str);
- return jniCreateString(env, str.getBuffer(), str.length());
-}
-
-static jstring ICU_getDisplayScriptNative(JNIEnv* env, jclass, jstring javaTargetLanguageTag, jstring javaLanguageTag) {
- ScopedIcuLocale icuLocale(env, javaLanguageTag);
- if (!icuLocale.valid()) {
- return NULL;
- }
- ScopedIcuLocale icuTargetLocale(env, javaTargetLanguageTag);
- if (!icuTargetLocale.valid()) {
- return NULL;
- }
-
- icu::UnicodeString str;
- icuTargetLocale.locale().getDisplayScript(icuLocale.locale(), str);
- return jniCreateString(env, str.getBuffer(), str.length());
-}
-
-static jstring ICU_getDisplayVariantNative(JNIEnv* env, jclass, jstring javaTargetLanguageTag, jstring javaLanguageTag) {
- ScopedIcuLocale icuLocale(env, javaLanguageTag);
- if (!icuLocale.valid()) {
- return NULL;
- }
- ScopedIcuLocale icuTargetLocale(env, javaTargetLanguageTag);
- if (!icuTargetLocale.valid()) {
- return NULL;
- }
-
- icu::UnicodeString str;
- icuTargetLocale.locale().getDisplayVariant(icuLocale.locale(), str);
- return jniCreateString(env, str.getBuffer(), str.length());
-}
-
static jstring ICU_getISO3Country(JNIEnv* env, jclass, jstring javaLanguageTag) {
ScopedIcuLocale icuLocale(env, javaLanguageTag);
if (!icuLocale.valid()) {
@@ -726,10 +666,6 @@
NATIVE_METHOD(ICU, getBestDateTimePatternNative, "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"),
NATIVE_METHOD(ICU, getCurrencyCode, "(Ljava/lang/String;)Ljava/lang/String;"),
NATIVE_METHOD(ICU, getDefaultLocale, "()Ljava/lang/String;"),
- NATIVE_METHOD(ICU, getDisplayCountryNative, "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"),
- NATIVE_METHOD(ICU, getDisplayLanguageNative, "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"),
- NATIVE_METHOD(ICU, getDisplayScriptNative, "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"),
- NATIVE_METHOD(ICU, getDisplayVariantNative, "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"),
NATIVE_METHOD(ICU, getISO3Country, "(Ljava/lang/String;)Ljava/lang/String;"),
NATIVE_METHOD(ICU, getISO3Language, "(Ljava/lang/String;)Ljava/lang/String;"),
NATIVE_METHOD(ICU, getISOCountriesNative, "()[Ljava/lang/String;"),
diff --git a/ojluni/src/main/java/java/util/Locale.java b/ojluni/src/main/java/java/util/Locale.java
index c66559a..60bb4fc 100644
--- a/ojluni/src/main/java/java/util/Locale.java
+++ b/ojluni/src/main/java/java/util/Locale.java
@@ -41,6 +41,7 @@
package java.util;
+import com.android.icu.util.LocaleNative;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -1874,9 +1875,9 @@
// TODO: We need a new hack or a complete fix for http://b/8049507 --- We would
// cover the frameworks' tracks when they were using "tl" instead of "fil".
- String result = ICU.getDisplayLanguage(this, locale);
+ String result = LocaleNative.getDisplayLanguage(this, locale);
if (result == null) { // TODO: do we need to do this, or does ICU do it for us?
- result = ICU.getDisplayLanguage(this, Locale.getDefault());
+ result = LocaleNative.getDisplayLanguage(this, Locale.getDefault());
}
return result;
}
@@ -1949,9 +1950,9 @@
return "";
}
- String result = ICU.getDisplayScript(this, inLocale);
+ String result = LocaleNative.getDisplayScript(this, inLocale);
if (result == null) { // TODO: do we need to do this, or does ICU do it for us?
- result = ICU.getDisplayScript(this, Locale.getDefault(Category.DISPLAY));
+ result = LocaleNative.getDisplayScript(this, Locale.getDefault(Category.DISPLAY));
}
return result;
@@ -2043,9 +2044,9 @@
return countryCode;
}
- String result = ICU.getDisplayCountry(this, locale);
+ String result = LocaleNative.getDisplayCountry(this, locale);
if (result == null) { // TODO: do we need to do this, or does ICU do it for us?
- result = ICU.getDisplayCountry(this, Locale.getDefault());
+ result = LocaleNative.getDisplayCountry(this, Locale.getDefault());
}
return result;
}
@@ -2154,9 +2155,9 @@
return variantCode;
}
- String result = ICU.getDisplayVariant(this, inLocale);
+ String result = LocaleNative.getDisplayVariant(this, inLocale);
if (result == null) { // TODO: do we need to do this, or does ICU do it for us?
- result = ICU.getDisplayVariant(this, Locale.getDefault());
+ result = LocaleNative.getDisplayVariant(this, Locale.getDefault());
}
// The "old style" locale constructors allow us to pass in variants that aren't