summaryrefslogtreecommitdiff
path: root/runtime/hidden_api_test.cc
diff options
context:
space:
mode:
author Chris Gross <chrisgross@google.com> 2020-04-24 09:36:45 -0700
committer Chris Gross <chrisgross@google.com> 2020-05-05 21:12:37 +0000
commit5477b8e55f01a58fac188f272818b38a19c50d4e (patch)
treee6e345925412d7bd3f6f1e46d9c47833c23bdb40 /runtime/hidden_api_test.cc
parented2895678203365b2024c742f51d34791729900b (diff)
Allow bootjars in system_ext.
Bug: 148385042 Test: Built and booted Pixel 3a both with and without a boot jar in system_ext. Test: m test-art-host-gtest-hidden_api_test32 Test: m test-art-host-gtest-hidden_api_test64 Change-Id: I10ef0340b92aa60579ff39f888cb556dc2953f2a
Diffstat (limited to 'runtime/hidden_api_test.cc')
-rw-r--r--runtime/hidden_api_test.cc104
1 files changed, 104 insertions, 0 deletions
diff --git a/runtime/hidden_api_test.cc b/runtime/hidden_api_test.cc
index b9214ffb54..5a948d1398 100644
--- a/runtime/hidden_api_test.cc
+++ b/runtime/hidden_api_test.cc
@@ -586,6 +586,29 @@ TEST_F(HiddenApiTest, DexDomain_SystemDir) {
ASSERT_EQ(0, remove(system_location_path.c_str()));
}
+TEST_F(HiddenApiTest, DexDomain_SystemExtDir) {
+ // Load file from a system_ext, non-framework directory and check that it is not flagged as framework.
+ std::string system_ext_location_path = android_system_ext_ + "/foo.jar";
+ ASSERT_FALSE(LocationIsOnSystemExtFramework(system_ext_location_path.c_str()));
+
+ ScopedObjectAccess soa(Thread::Current());
+ std::vector<std::unique_ptr<const DexFile>> dex_files;
+ std::string error_msg;
+ ObjPtr<mirror::ClassLoader> class_loader;
+
+ ASSERT_TRUE(Copy(GetTestDexFileName("Main"), system_ext_location_path, &error_msg)) << error_msg;
+ ASSERT_TRUE(LoadDexFiles(system_ext_location_path, soa, &dex_files, &class_loader, &error_msg))
+ << error_msg;
+ ASSERT_GE(dex_files.size(), 1u);
+ ASSERT_TRUE(CheckAllDexFilesInDomain(class_loader,
+ dex_files,
+ hiddenapi::Domain::kApplication,
+ &error_msg)) << error_msg;
+
+ dex_files.clear();
+ ASSERT_EQ(0, remove(system_ext_location_path.c_str()));
+}
+
TEST_F(HiddenApiTest, DexDomain_SystemFrameworkDir) {
// Load file from a system/framework directory and check that it is flagged as a framework dex.
std::string system_framework_location_path = GetAndroidRoot() + "/framework/foo.jar";
@@ -613,6 +636,33 @@ TEST_F(HiddenApiTest, DexDomain_SystemFrameworkDir) {
ASSERT_EQ(0, remove(system_framework_location_path.c_str()));
}
+TEST_F(HiddenApiTest, DexDomain_SystemExtFrameworkDir) {
+ // Load file from a system_ext/framework directory and check that it is flagged as a framework dex.
+ std::string system_ext_framework_location_path = android_system_ext_ + "/framework/foo.jar";
+ ASSERT_TRUE(LocationIsOnSystemExtFramework(system_ext_framework_location_path.c_str()));
+
+ ScopedObjectAccess soa(Thread::Current());
+ std::vector<std::unique_ptr<const DexFile>> dex_files;
+ std::string error_msg;
+ ObjPtr<mirror::ClassLoader> class_loader;
+
+ ASSERT_TRUE(Copy(GetTestDexFileName("Main"), system_ext_framework_location_path, &error_msg))
+ << error_msg;
+ ASSERT_TRUE(LoadDexFiles(system_ext_framework_location_path,
+ soa,
+ &dex_files,
+ &class_loader,
+ &error_msg)) << error_msg;
+ ASSERT_GE(dex_files.size(), 1u);
+ ASSERT_TRUE(CheckAllDexFilesInDomain(class_loader,
+ dex_files,
+ hiddenapi::Domain::kPlatform,
+ &error_msg)) << error_msg;
+
+ dex_files.clear();
+ ASSERT_EQ(0, remove(system_ext_framework_location_path.c_str()));
+}
+
TEST_F(HiddenApiTest, DexDomain_DataDir_MultiDex) {
// Load multidex file from a non-system directory and check that it is not flagged as framework.
std::string data_multi_location_path = android_data_ + "/multifoo.jar";
@@ -662,6 +712,31 @@ TEST_F(HiddenApiTest, DexDomain_SystemDir_MultiDex) {
ASSERT_EQ(0, remove(system_multi_location_path.c_str()));
}
+TEST_F(HiddenApiTest, DexDomain_SystemExtDir_MultiDex) {
+ // Load multidex file from a system_ext, non-framework directory and check that it is not flagged
+ // as framework.
+ std::string system_ext_multi_location_path = android_system_ext_ + "/multifoo.jar";
+ ASSERT_FALSE(LocationIsOnSystemExtFramework(system_ext_multi_location_path.c_str()));
+
+ ScopedObjectAccess soa(Thread::Current());
+ std::vector<std::unique_ptr<const DexFile>> dex_files;
+ std::string error_msg;
+ ObjPtr<mirror::ClassLoader> class_loader;
+
+ ASSERT_TRUE(Copy(GetTestDexFileName("MultiDex"), system_ext_multi_location_path, &error_msg))
+ << error_msg;
+ ASSERT_TRUE(LoadDexFiles(system_ext_multi_location_path, soa, &dex_files, &class_loader, &error_msg))
+ << error_msg;
+ ASSERT_GT(dex_files.size(), 1u);
+ ASSERT_TRUE(CheckAllDexFilesInDomain(class_loader,
+ dex_files,
+ hiddenapi::Domain::kApplication,
+ &error_msg)) << error_msg;
+
+ dex_files.clear();
+ ASSERT_EQ(0, remove(system_ext_multi_location_path.c_str()));
+}
+
TEST_F(HiddenApiTest, DexDomain_SystemFrameworkDir_MultiDex) {
// Load multidex file from a system/framework directory and check that it is flagged as a
// framework dex.
@@ -691,4 +766,33 @@ TEST_F(HiddenApiTest, DexDomain_SystemFrameworkDir_MultiDex) {
ASSERT_EQ(0, remove(system_framework_multi_location_path.c_str()));
}
+TEST_F(HiddenApiTest, DexDomain_SystemExtFrameworkDir_MultiDex) {
+ // Load multidex file from a system_ext/framework directory and check that it is flagged as a
+ // framework dex.
+ std::string system_ext_framework_multi_location_path = android_system_ext_ + "/framework/multifoo.jar";
+ ASSERT_TRUE(LocationIsOnSystemExtFramework(system_ext_framework_multi_location_path.c_str()));
+
+ ScopedObjectAccess soa(Thread::Current());
+ std::vector<std::unique_ptr<const DexFile>> dex_files;
+ std::string error_msg;
+ ObjPtr<mirror::ClassLoader> class_loader;
+
+ ASSERT_TRUE(Copy(GetTestDexFileName("MultiDex"),
+ system_ext_framework_multi_location_path,
+ &error_msg)) << error_msg;
+ ASSERT_TRUE(LoadDexFiles(system_ext_framework_multi_location_path,
+ soa,
+ &dex_files,
+ &class_loader,
+ &error_msg)) << error_msg;
+ ASSERT_GT(dex_files.size(), 1u);
+ ASSERT_TRUE(CheckAllDexFilesInDomain(class_loader,
+ dex_files,
+ hiddenapi::Domain::kPlatform,
+ &error_msg)) << error_msg;
+
+ dex_files.clear();
+ ASSERT_EQ(0, remove(system_ext_framework_multi_location_path.c_str()));
+}
+
} // namespace art