summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKiyoung Kim <kiyoungkim@google.com>2023-09-22 13:52:47 +0900
committerKiyoung Kim <kiyoungkim@google.com>2024-03-06 14:48:01 +0000
commit96d09a108d67d8cc07fed6c499e7fa3901c57446 (patch)
treea76d878e061537c0dc09d9639340f1ef67bb96bc
parentf701823d2bc4911fc5eaa2d94799118751e8c637 (diff)
downloadart-96d09a108d67d8cc07fed6c499e7fa3901c57446.tar.gz
Use product vndk version to check if product vndk is deprecated
There are some logic in libnativeloader to check if product is treblelized by checking ro.product.vndk.version. However, this property is no longer valid to check if product is treblelized, because of vndk deprecation. This makes libnativeloader to consider as product is not treblelized when the property is empty from the VNDK deprecation. This causes unexpected error from libnativeloader which allows product apps to use system / system_ext libraries when the product partition is VNDK deprecated. Product is force-treblelized from R, so it is safe to assume that product partition is always treblelized as long as the device is treblelized. This change removes existing check of ro.product.vndk.version, and use this check only to confirm if product VNDK is deprecated. Bug: 290159430 Bug: 325710867 Test: Cuttlefish build and run succeeded Test: libnativeloader_e2e_tests passed Change-Id: Ieee3ff2dde4244e7c46420ad8dde5f8e5cf249e4 Merged-In: Ieee3ff2dde4244e7c46420ad8dde5f8e5cf249e4 (cherry picked from commit c8c2953cffe8ff9d2204f4efdff9100eb9fa6df0)
-rw-r--r--libnativeloader/library_namespaces.cpp8
-rw-r--r--libnativeloader/native_loader_test.cpp17
-rw-r--r--libnativeloader/public_libraries.cpp28
-rw-r--r--libnativeloader/public_libraries.h4
-rwxr-xr-xtools/buildbot-build.sh3
5 files changed, 20 insertions, 40 deletions
diff --git a/libnativeloader/library_namespaces.cpp b/libnativeloader/library_namespaces.cpp
index 9aeebf38ad..dc92a88cb3 100644
--- a/libnativeloader/library_namespaces.cpp
+++ b/libnativeloader/library_namespaces.cpp
@@ -255,7 +255,7 @@ Result<NativeLoaderNamespace*> LibraryNamespaces::Create(JNIEnv* env, uint32_t t
// Different name is useful for debugging
namespace_name = kVendorClassloaderNamespaceName;
- } else if (apk_origin == APK_ORIGIN_PRODUCT && is_product_vndk_version_defined()) {
+ } else if (apk_origin == APK_ORIGIN_PRODUCT) {
unbundled_app_origin = APK_ORIGIN_PRODUCT;
apk_origin_msg = "unbundled product apk";
@@ -405,11 +405,7 @@ Result<NativeLoaderNamespace*> LibraryNamespaces::Create(JNIEnv* env, uint32_t t
auto product_libs = filter_public_libraries(target_sdk_version, uses_libraries,
product_public_libraries());
if (!product_libs.empty()) {
- auto target_ns = system_ns;
- if (is_product_vndk_version_defined()) {
- // If ro.product.vndk.version is defined, product namespace provides the product libraries.
- target_ns = NativeLoaderNamespace::GetExportedNamespace(kProductNamespaceName, is_bridged);
- }
+ auto target_ns = NativeLoaderNamespace::GetExportedNamespace(kProductNamespaceName, is_bridged);
if (target_ns.ok()) {
linked = app_ns->Link(&target_ns.value(), product_libs);
if (!linked.ok()) {
diff --git a/libnativeloader/native_loader_test.cpp b/libnativeloader/native_loader_test.cpp
index 6c0c8b17a7..62fb1eef2b 100644
--- a/libnativeloader/native_loader_test.cpp
+++ b/libnativeloader/native_loader_test.cpp
@@ -378,15 +378,14 @@ TEST_P(NativeLoaderTest_Create, UnbundledProductApp) {
dex_path = "/product/app/foo/foo.apk";
is_shared = false;
- if (is_product_vndk_version_defined()) {
- expected_namespace_prefix = "product-clns";
- expected_library_path = expected_library_path + ":/product/" LIB_DIR ":/system/product/" LIB_DIR;
- expected_permitted_path =
- expected_permitted_path + ":/product/" LIB_DIR ":/system/product/" LIB_DIR;
- expected_shared_libs_to_platform_ns =
- append_extended_libraries(default_public_libraries() + ":" + llndk_libraries_product());
- expected_link_with_vndk_product_ns = true;
- }
+ expected_namespace_prefix = "product-clns";
+ expected_library_path = expected_library_path + ":/product/" LIB_DIR ":/system/product/" LIB_DIR;
+ expected_permitted_path =
+ expected_permitted_path + ":/product/" LIB_DIR ":/system/product/" LIB_DIR;
+ expected_shared_libs_to_platform_ns =
+ append_extended_libraries(default_public_libraries() + ":" + llndk_libraries_product());
+ expected_link_with_vndk_product_ns = true;
+
SetExpectations();
RunTest();
}
diff --git a/libnativeloader/public_libraries.cpp b/libnativeloader/public_libraries.cpp
index de8639d602..66572e7d36 100644
--- a/libnativeloader/public_libraries.cpp
+++ b/libnativeloader/public_libraries.cpp
@@ -201,9 +201,7 @@ static std::string InitVendorPublicLibraries() {
// contains the extended public libraries that are loaded from the system namespace.
static std::string InitProductPublicLibraries() {
std::vector<std::string> sonames;
- if (is_product_vndk_version_defined()) {
- ReadExtensionLibraries("/product/etc", &sonames);
- }
+ ReadExtensionLibraries("/product/etc", &sonames);
std::string libs = android::base::Join(sonames, ':');
ALOGD("InitProductPublicLibraries: %s", libs.c_str());
return libs;
@@ -218,9 +216,6 @@ static std::string InitExtendedPublicLibraries() {
std::vector<std::string> sonames;
ReadExtensionLibraries("/system/etc", &sonames);
ReadExtensionLibraries("/system_ext/etc", &sonames);
- if (!is_product_vndk_version_defined()) {
- ReadExtensionLibraries("/product/etc", &sonames);
- }
std::string libs = android::base::Join(sonames, ':');
ALOGD("InitExtendedPublicLibraries: %s", libs.c_str());
return libs;
@@ -261,10 +256,6 @@ static std::string InitLlndkLibrariesVendor() {
}
static std::string InitLlndkLibrariesProduct() {
- if (!is_product_vndk_version_defined()) {
- ALOGD("InitLlndkLibrariesProduct: No product VNDK version defined");
- return "";
- }
std::string config_file;
if (IsProductVndkEnabled()) {
config_file = kLlndkLibrariesFile;
@@ -283,6 +274,11 @@ static std::string InitLlndkLibrariesProduct() {
}
static std::string InitVndkspLibrariesVendor() {
+ if (!IsVendorVndkEnabled()) {
+ ALOGD("InitVndkspLibrariesVendor: VNDK is deprecated with vendor");
+ return "";
+ }
+
std::string config_file = kVndkLibrariesFile;
InsertVndkVersionStr(&config_file, false);
auto sonames = ReadConfig(config_file, always_true);
@@ -296,8 +292,8 @@ static std::string InitVndkspLibrariesVendor() {
}
static std::string InitVndkspLibrariesProduct() {
- if (!is_product_vndk_version_defined()) {
- ALOGD("InitVndkspLibrariesProduct: No product VNDK version defined");
+ if (!IsProductVndkEnabled()) {
+ ALOGD("InitVndkspLibrariesProduct: VNDK is deprecated with product");
return "";
}
std::string config_file = kVndkLibrariesFile;
@@ -420,14 +416,6 @@ const std::map<std::string, std::string>& apex_public_libraries() {
return public_libraries;
}
-bool is_product_vndk_version_defined() {
-#if defined(ART_TARGET_ANDROID)
- return android::sysprop::VndkProperties::product_vndk_version().has_value();
-#else
- return false;
-#endif
-}
-
std::string get_vndk_version(bool is_product_vndk) {
#if defined(ART_TARGET_ANDROID)
if (is_product_vndk) {
diff --git a/libnativeloader/public_libraries.h b/libnativeloader/public_libraries.h
index 6f5a13c9b3..760388635a 100644
--- a/libnativeloader/public_libraries.h
+++ b/libnativeloader/public_libraries.h
@@ -47,10 +47,6 @@ const std::string& apex_jni_libraries(const std::string& apex_name);
// but provided by com.android.foo APEX.
const std::map<std::string, std::string>& apex_public_libraries();
-// Returns true if libnativeloader is running on devices and the device has
-// ro.product.vndk.version property. It returns false for host.
-bool is_product_vndk_version_defined();
-
std::string get_vndk_version(bool is_product_vndk);
// These are exported for testing
diff --git a/tools/buildbot-build.sh b/tools/buildbot-build.sh
index cac98cb131..1467037149 100755
--- a/tools/buildbot-build.sh
+++ b/tools/buildbot-build.sh
@@ -411,6 +411,7 @@ EOF
msginfo "Generating linkerconfig" "in $linkerconfig_out"
rm -rf $linkerconfig_out
mkdir -p $linkerconfig_out
- $ANDROID_HOST_OUT/bin/linkerconfig --target $linkerconfig_out --root $linkerconfig_root --vndk $platform_version
+ # TODO(b/300291157): Remove VNDK versions and enable Treble once VNDK deprecation is set as default
+ $ANDROID_HOST_OUT/bin/linkerconfig --target $linkerconfig_out --root $linkerconfig_root --vndk $platform_version --product_vndk $platform_version
msgnote "Don't be scared by \"Unable to access VNDK APEX\" message, it's not fatal"
fi