summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Stjernholm <mast@google.com>2024-02-29 16:41:44 +0000
committerMartin Stjernholm <mast@google.com>2024-04-16 16:48:54 +0000
commit02b9d2f137a374f1403e78f1b100b8f71fd26a9a (patch)
treec4b266f8687317cd86c506b2d06214e86a7ee1b5
parent002aca7141e7baf488b02f330b307f059c47a84d (diff)
downloadart-02b9d2f137a374f1403e78f1b100b8f71fd26a9a.tar.gz
Revert "libnativeloader_test: link non-public libs statically" and
remove libnativeloader_test from CTS instead. This reverts commit b2b067192ac047b99c0d03104c5d7dbf79192ef1 which made the CTS test no longer work for API coverage. It also (effectively) reverts commit 996fa745c3ad3e3150363c85816ad2db3a00f5bd which put it in CTS in the first place for that purpose. It's clear libnativeloader_test won't work for API coverage due to the mocking it does, so we'd have to add new tests if there are gaps. However there doesn't seem to be any. Also do a few other cleanups in the Android.bp file. Test: atest libnativeloader_e2e_tests \ libnativeloader_test libnativeloader_lazy_test Bug: 327407752 Bug: 328653757 Change-Id: I488c3d3c5143b7694a8456c3b56edfd511c3c610 (cherry picked from commit 418b58fe9c94a4bc2592d27b45a8e44c70742119) Merged-In: I488c3d3c5143b7694a8456c3b56edfd511c3c610
-rw-r--r--libnativeloader/Android.bp76
-rw-r--r--libnativeloader/open_system_library.cpp55
2 files changed, 34 insertions, 97 deletions
diff --git a/libnativeloader/Android.bp b/libnativeloader/Android.bp
index 96f56775f6..2db1f76ead 100644
--- a/libnativeloader/Android.bp
+++ b/libnativeloader/Android.bp
@@ -9,6 +9,28 @@ package {
default_applicable_licenses: ["art_license"],
}
+cc_library_headers {
+ name: "libnativeloader-headers",
+ defaults: ["art_defaults"],
+ apex_available: [
+ "//apex_available:platform",
+ "com.android.art",
+ "com.android.art.debug",
+ "com.android.media",
+ ],
+ visibility: [
+ "//art:__subpackages__",
+ // TODO(b/133140750): Clean this up.
+ "//frameworks/av/media/libstagefright",
+ "//frameworks/native/libs/graphicsenv",
+ "//frameworks/native/vulkan/libvulkan",
+ ],
+ host_supported: true,
+ export_include_dirs: ["include"],
+ header_libs: ["jni_headers"],
+ export_header_lib_headers: ["jni_headers"],
+}
+
cc_defaults {
name: "libnativeloader-defaults",
defaults: ["art_defaults"],
@@ -75,6 +97,9 @@ art_cc_library {
},
}
+// Wrapper that loads nativeloader.so lazily, to be used to deal with layer
+// inversion in places like in early boot where libnativeloader and/or
+// libnativebridge aren't available.
// TODO(b/124250621) eliminate the need for this library
cc_library {
name: "libnativeloader_lazy",
@@ -95,33 +120,14 @@ cc_library {
shared_libs: ["liblog"],
}
-cc_library_headers {
- name: "libnativeloader-headers",
- defaults: ["art_defaults"],
- apex_available: [
- "//apex_available:platform",
- "com.android.art",
- "com.android.art.debug",
- "com.android.media",
- ],
- visibility: [
- "//art:__subpackages__",
- // TODO(b/133140750): Clean this up.
- "//frameworks/av/media/libstagefright",
- "//frameworks/native/libs/graphicsenv",
- "//frameworks/native/vulkan/libvulkan",
- ],
- host_supported: true,
- export_include_dirs: ["include"],
- header_libs: ["jni_headers"],
- export_header_lib_headers: ["jni_headers"],
-}
-
cc_defaults {
name: "libnativeloader-test-defaults",
defaults: [
"art_module_source_build_defaults",
- "art_test_defaults",
+ // Cannot use art_standalone_gtest_defaults because it makes us link
+ // libnativebridge statically through libart-gtest, but we need to mock
+ // its symbols here.
+ "art_standalone_test_defaults",
],
host_supported: false,
@@ -145,13 +151,16 @@ cc_defaults {
"libbase",
],
+ test_for: [
+ "com.android.art",
+ "com.android.art.debug",
+ ],
test_suites: ["device-tests"],
}
art_cc_test {
name: "libnativeloader_test",
defaults: [
- "art_standalone_test_defaults",
"libnativeloader-test-defaults",
],
tidy_timeout_srcs: [
@@ -160,28 +169,11 @@ art_cc_test {
srcs: [
"native_loader_api_test.c",
"native_loader_test.cpp",
- "open_system_library.cpp",
- ],
- static_libs: [
- "libbase",
- "libnativeloader",
],
shared_libs: [
- "liblog",
+ "libnativeloader",
],
- target: {
- android: {
- static_libs: [
- "libPlatformProperties",
- ],
- },
- },
-
- // Added to CTS for API coverage of libnativeloader which is backed by the
- // ART module.
- test_config_template: ":art-gtests-target-standalone-cts-template",
test_suites: [
- "cts",
"mts-art",
],
}
diff --git a/libnativeloader/open_system_library.cpp b/libnativeloader/open_system_library.cpp
deleted file mode 100644
index 63175aa91f..0000000000
--- a/libnativeloader/open_system_library.cpp
+++ /dev/null
@@ -1,55 +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.
- */
-
-#define LOG_TAG "nativeloader_test"
-
-#include <dlfcn.h>
-#include <log/log.h>
-
-#ifdef ART_TARGET_ANDROID
-#include "nativeloader/dlext_namespaces.h"
-#endif
-
-namespace android {
-
-extern "C" {
-
-// TODO(b/268440756): Find a way to reuse it from libnativebridge.
-void* OpenSystemLibrary(const char* path, int flags) {
-#ifdef ART_TARGET_ANDROID
- // The system namespace is called "default" for binaries in /system and
- // "system" for those in the Runtime APEX. Try "system" first since
- // "default" always exists.
- // TODO(b/185587109): Get rid of this error prone logic.
- android_namespace_t* system_ns = android_get_exported_namespace("system");
- if (system_ns == nullptr) {
- system_ns = android_get_exported_namespace("default");
- const char* message = "Failed to get system namespace for loading %s";
- LOG_ALWAYS_FATAL_IF(system_ns == nullptr, message, path);
- }
- const android_dlextinfo dlextinfo = {
- .flags = ANDROID_DLEXT_USE_NAMESPACE,
- .library_namespace = system_ns,
- };
- return android_dlopen_ext(path, flags, &dlextinfo);
-#else
- return dlopen(path, flags);
-#endif
-}
-
-} // extern "C"
-
-} // namespace android