Compile libjavacore and libopenjdk against libandroidicu
Note:
1. Replace ICU registration with a new C wrapper
2. char16ptr.h is not a new dependency, but included indirectly
previously.
Bug: 138994281
Test: m droid
Change-Id: I9b55f7f8ce6d10ad8fe227d65f0f53e420fbe9fd
diff --git a/NativeCode.bp b/NativeCode.bp
index 2041a92..c489d1a 100644
--- a/NativeCode.bp
+++ b/NativeCode.bp
@@ -67,22 +67,23 @@
"libbase",
"libcrypto",
"libexpat",
- "libicuuc",
- "libicui18n",
"libnativehelper",
"libz",
],
static_libs: [
- "libandroidicuinit",
"libziparchive",
],
target: {
android: {
- cflags: [
- // -DANDROID_LINK_SHARED_ICU4C to enable access to the full ICU4C.
- // See external/icu/android_icu4c/include/uconfig_local.h
- // for more information.
- "-DANDROID_LINK_SHARED_ICU4C",
+ shared_libs: ["libandroidicu"],
+ },
+ host: {
+ shared_libs: [
+ "libicuuc",
+ "libicui18n",
+ ],
+ static_libs: [
+ "libandroidicuinit",
],
},
},
@@ -142,7 +143,6 @@
shared_libs: [
"libandroidio",
"libcrypto",
- "libicuuc",
"libnativehelper",
"libz",
],
@@ -158,16 +158,16 @@
],
},
android: {
- cflags: [
- // -DANDROID_LINK_SHARED_ICU4C to enable access to the full ICU4C.
- // See external/icu/android_icu4c/include/uconfig_local.h
- // for more information.
- "-DANDROID_LINK_SHARED_ICU4C",
- ],
shared_libs: [
+ "libandroidicu",
"libdl_android",
],
},
+ host: {
+ shared_libs: [
+ "libicuuc",
+ ],
+ },
},
notice: "ojluni/NOTICE",
diff --git a/luni/src/main/native/ScopedIcuLocale.h b/luni/src/main/native/ScopedIcuLocale.h
deleted file mode 100644
index 851de76..0000000
--- a/luni/src/main/native/ScopedIcuLocale.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef SCOPED_ICU_LOCALE_H_included
-#define SCOPED_ICU_LOCALE_H_included
-
-#include <nativehelper/JNIHelp.h>
-#include <nativehelper/ScopedUtfChars.h>
-#include "unicode/locid.h"
-
-class ScopedIcuLocale {
- public:
- ScopedIcuLocale(JNIEnv* env, jstring javaLocaleName) : mEnv(env) {
- mLocale.setToBogus();
-
- if (javaLocaleName == NULL) {
- jniThrowNullPointerException(mEnv, "javaLocaleName == null");
- return;
- }
-
- const ScopedUtfChars localeName(env, javaLocaleName);
- if (localeName.c_str() == NULL) {
- return;
- }
-
- mLocale = icu::Locale::createFromName(localeName.c_str());
- }
-
- ~ScopedIcuLocale() {
- }
-
- bool valid() const {
- return !mLocale.isBogus();
- }
-
- icu::Locale& locale() {
- return mLocale;
- }
-
- private:
- JNIEnv* const mEnv;
- icu::Locale mLocale;
-
- // Disallow copy and assignment.
- ScopedIcuLocale(const ScopedIcuLocale&);
- void operator=(const ScopedIcuLocale&);
-};
-
-#endif // SCOPED_ICU_LOCALE_H_included
diff --git a/luni/src/main/native/libcore_icu_ICU.cpp b/luni/src/main/native/libcore_icu_ICU.cpp
index aa3d5004..4b379cd 100644
--- a/luni/src/main/native/libcore_icu_ICU.cpp
+++ b/luni/src/main/native/libcore_icu_ICU.cpp
@@ -20,7 +20,14 @@
#include <memory>
#include <vector>
-#include <androidicuinit/IcuRegistration.h>
+
+
+#ifdef __ANDROID__
+ #include <aicu/AIcu.h>
+#else
+ #include <androidicuinit/android_icu_reg.h>
+#endif
+
#include <log/log.h>
#include <nativehelper/JNIHelp.h>
#include <nativehelper/ScopedStringChars.h>
@@ -31,11 +38,13 @@
#include "IcuUtilities.h"
#include "JniException.h"
#include "ScopedIcuULoc.h"
+#include "unicode/char16ptr.h"
#include "unicode/udatpg.h"
#include "unicode/uloc.h"
#include "unicode/ures.h"
#include "unicode/ustring.h"
-#include "ureslocs.h"
+
+#define U_ICUDATA_CURR U_ICUDATA_NAME "-" "curr"
class ScopedResourceBundle {
public:
@@ -235,7 +244,11 @@
// Init ICU, configuring it and loading the data files.
void register_libcore_icu_ICU(JNIEnv* env) {
- androidicuinit::IcuRegistration::Register();
+#ifdef __ANDROID__
+ AIcu_register();
+#else
+ android_icu_register();
+#endif
jniRegisterNativeMethods(env, "libcore/icu/ICU", gMethods, NELEM(gMethods));
}
@@ -244,6 +257,9 @@
void unregister_libcore_icu_ICU() {
// Skip unregistering JNI methods explicitly, class unloading takes care of
// it.
-
- androidicuinit::IcuRegistration::Deregister();
+#ifdef __ANDROID__
+ AIcu_deregister();
+#else
+ android_icu_deregister();
+#endif
}