summaryrefslogtreecommitdiff
path: root/libnativeloader
diff options
context:
space:
mode:
authorVictor Chang <vichang@google.com>2020-05-05 16:01:19 +0100
committervichang <vichang@google.com>2020-05-07 09:34:47 +0000
commitd20e51dcd0fc4b2b229c5b6a5e9b500ae042bc61 (patch)
tree2ef7925b2e89c77cee31144a25932a198cd4b65e /libnativeloader
parenta6653d304faa3bbd981507570a4ac1107760c6a7 (diff)
"Move ICU from ART APEX to i18n APEX" Attempt 2
The change was previously submitted in https://r.android.com/1283897 "Calling @IntraCoreApi from core-icu4j should not cause Core platform API violation" https://r.android.com/1299494 Bug: 138994281 Test: m checkbuild on aosp_x86-userdebug Test: device boots Change-Id: Idb3e2450fca5d8300aef353fc1e4e99e24f04372
Diffstat (limited to 'libnativeloader')
-rw-r--r--libnativeloader/README.md2
-rw-r--r--libnativeloader/library_namespaces.cpp10
-rw-r--r--libnativeloader/native_loader_test.cpp9
-rw-r--r--libnativeloader/public_libraries.cpp24
-rw-r--r--libnativeloader/public_libraries.h1
5 files changed, 39 insertions, 7 deletions
diff --git a/libnativeloader/README.md b/libnativeloader/README.md
index 57b90019e3..c5ace61ba5 100644
--- a/libnativeloader/README.md
+++ b/libnativeloader/README.md
@@ -34,7 +34,7 @@ libraries. As the platform is getting modularized with
[APEX](https://android.googlesource.com/platform/system/apex/+/refs/heads/master/docs/README.md),
some libraries are no longer provided from platform, but from the APEXes which
have their own linker namespaces. For example, ICU libraries `libicuuc.so` and
-`libicui18n.so` are from the runtime APEX.
+`libicui18n.so` are from the I18n APEX.
The list of public native libraries is not static. The default set of libraries
are defined in AOSP, but partners can extend it to include their own libraries.
diff --git a/libnativeloader/library_namespaces.cpp b/libnativeloader/library_namespaces.cpp
index d42a4b55ed..14ba721420 100644
--- a/libnativeloader/library_namespaces.cpp
+++ b/libnativeloader/library_namespaces.cpp
@@ -51,6 +51,7 @@ constexpr const char* kVendorNamespaceName = "sphal";
constexpr const char* kVndkNamespaceName = "vndk";
constexpr const char* kVndkProductNamespaceName = "vndk_product";
constexpr const char* kArtNamespaceName = "com_android_art";
+constexpr const char* kI18nNamespaceName = "com_android_i18n";
constexpr const char* kNeuralNetworksNamespaceName = "com_android_neuralnetworks";
constexpr const char* kStatsdNamespaceName = "com_android_os_statsd";
@@ -272,6 +273,15 @@ Result<NativeLoaderNamespace*> LibraryNamespaces::Create(JNIEnv* env, uint32_t t
}
}
+ auto i18n_ns = NativeLoaderNamespace::GetExportedNamespace(kI18nNamespaceName, is_bridged);
+ // i18n APEX does not exist on host, and under certain build conditions.
+ if (i18n_ns.ok()) {
+ linked = app_ns->Link(*i18n_ns, i18n_public_libraries());
+ if (!linked.ok()) {
+ return linked.error();
+ }
+ }
+
// Give access to NNAPI libraries (apex-updated LLNDK library).
auto nnapi_ns =
NativeLoaderNamespace::GetExportedNamespace(kNeuralNetworksNamespaceName, is_bridged);
diff --git a/libnativeloader/native_loader_test.cpp b/libnativeloader/native_loader_test.cpp
index 66d7531b35..e64e1a518c 100644
--- a/libnativeloader/native_loader_test.cpp
+++ b/libnativeloader/native_loader_test.cpp
@@ -97,7 +97,7 @@ class Platform {
static std::unordered_map<std::string, Platform::mock_namespace_handle> namespaces = {
{"system", TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE("system"))},
{"default", TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE("default"))},
- {"com_android_art", TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE("com_android_art"))},
+ {"com_android_i18n", TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE("com_android_i18n"))},
{"sphal", TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE("sphal"))},
{"vndk", TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE("vndk"))},
{"vndk_product", TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE("vndk_product"))},
@@ -355,6 +355,7 @@ class NativeLoaderTest_Create : public NativeLoaderTest {
std::string expected_parent_namespace = "system";
bool expected_link_with_platform_ns = true;
bool expected_link_with_art_ns = true;
+ bool expected_link_with_i18n_ns = true;
bool expected_link_with_sphal_ns = !vendor_public_libraries().empty();
bool expected_link_with_vndk_ns = false;
bool expected_link_with_vndk_product_ns = false;
@@ -363,6 +364,7 @@ class NativeLoaderTest_Create : public NativeLoaderTest {
bool expected_link_with_statsd_ns = true;
std::string expected_shared_libs_to_platform_ns = default_public_libraries();
std::string expected_shared_libs_to_art_ns = art_public_libraries();
+ std::string expected_shared_libs_to_i18n_ns = i18n_public_libraries();
std::string expected_shared_libs_to_sphal_ns = vendor_public_libraries();
std::string expected_shared_libs_to_vndk_ns = vndksp_libraries_vendor();
std::string expected_shared_libs_to_vndk_product_ns = vndksp_libraries_product();
@@ -393,6 +395,11 @@ class NativeLoaderTest_Create : public NativeLoaderTest {
StrEq(expected_shared_libs_to_art_ns)))
.WillOnce(Return(true));
}
+ if (expected_link_with_i18n_ns) {
+ EXPECT_CALL(*mock, mock_link_namespaces(Eq(IsBridged()), _, NsEq("com_android_i18n"),
+ StrEq(expected_shared_libs_to_i18n_ns)))
+ .WillOnce(Return(true));
+ }
if (expected_link_with_sphal_ns) {
EXPECT_CALL(*mock, mock_link_namespaces(Eq(IsBridged()), _, NsEq("sphal"),
StrEq(expected_shared_libs_to_sphal_ns)))
diff --git a/libnativeloader/public_libraries.cpp b/libnativeloader/public_libraries.cpp
index 7bb5a1fde2..575ce2d3ac 100644
--- a/libnativeloader/public_libraries.cpp
+++ b/libnativeloader/public_libraries.cpp
@@ -57,12 +57,15 @@ constexpr const char* kLlndkLibrariesFile = "/apex/com.android.vndk.v{}/etc/llnd
constexpr const char* kVndkLibrariesFile = "/apex/com.android.vndk.v{}/etc/vndksp.libraries.{}.txt";
const std::vector<const std::string> kArtApexPublicLibraries = {
+ "libnativehelper.so",
+};
+
+const std::vector<const std::string> ki18nApexPublicLibraries = {
"libicuuc.so",
"libicui18n.so",
- "libnativehelper.so",
};
-constexpr const char* kArtApexLibPath = "/apex/com.android.art/" LIB;
+constexpr const char* kI18nApexLibPath = "/apex/com.android.i18n/" LIB;
constexpr const char* kNeuralNetworksApexPublicLibrary = "libneuralnetworks.so";
@@ -195,14 +198,14 @@ static std::string InitDefaultPublicLibraries(bool for_preload) {
return android::base::Join(*sonames, ':');
}
- // Remove the public libs in the art namespace.
+ // Remove the public libs in the i18n namespace.
// These libs are listed in public.android.txt, but we don't want the rest of android
// in default namespace to dlopen the libs.
// For example, libicuuc.so is exposed to classloader namespace from art namespace.
// Unfortunately, it does not have stable C symbols, and default namespace should only use
// stable symbols in libandroidicu.so. http://b/120786417
- for (const std::string& lib_name : kArtApexPublicLibraries) {
- std::string path(kArtApexLibPath);
+ for (const std::string& lib_name : ki18nApexPublicLibraries) {
+ std::string path(kI18nApexLibPath);
path.append("/").append(lib_name);
struct stat s;
@@ -237,6 +240,12 @@ static std::string InitArtPublicLibraries() {
return list;
}
+static std::string InitI18nPublicLibraries() {
+ static_assert(sizeof(ki18nApexPublicLibraries) > 0, "ki18nApexPublicLibraries is empty");
+ std::string list = android::base::Join(ki18nApexPublicLibraries, ":");
+ return list;
+}
+
static std::string InitVendorPublicLibraries() {
// This file is optional, quietly ignore if the file does not exist.
auto sonames = ReadConfig(kVendorPublicLibrariesFile, always_true);
@@ -349,6 +358,11 @@ const std::string& art_public_libraries() {
return list;
}
+const std::string& i18n_public_libraries() {
+ static std::string list = InitI18nPublicLibraries();
+ return list;
+}
+
const std::string& vendor_public_libraries() {
static std::string list = InitVendorPublicLibraries();
return list;
diff --git a/libnativeloader/public_libraries.h b/libnativeloader/public_libraries.h
index 9b8b2a4705..b60a2ef399 100644
--- a/libnativeloader/public_libraries.h
+++ b/libnativeloader/public_libraries.h
@@ -36,6 +36,7 @@ const std::string& art_public_libraries();
const std::string& statsd_public_libraries();
const std::string& vendor_public_libraries();
const std::string& extended_public_libraries();
+const std::string& i18n_public_libraries();
const std::string& neuralnetworks_public_libraries();
const std::string& llndk_libraries_product();
const std::string& llndk_libraries_vendor();