aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJooyung Han <jooyung@google.com>2023-04-17 13:28:39 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-04-17 13:28:39 +0000
commit88acfa3d4936786858f3e338c457f71389e3d5d3 (patch)
tree2be4f3ce9c85cef1fc8ca12de71d19361098a44e
parent751b93331510f419113b9809bddfa62c78dccf9f (diff)
parent875c866390b5bf65ee7de824aa560f713ef86165 (diff)
downloadlinkerconfig-88acfa3d4936786858f3e338c457f71389e3d5d3.tar.gz
Handle APEX original paths when linked under /system am: 875c866390
Original change: https://android-review.googlesource.com/c/platform/system/linkerconfig/+/2539970 Change-Id: Iae52b561b67c7cb90c6d42899cc11fb37d9268bb Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--modules/apex.cc46
-rw-r--r--modules/tests/apex_test.cc15
2 files changed, 51 insertions, 10 deletions
diff --git a/modules/apex.cc b/modules/apex.cc
index bb7756e..873fe32 100644
--- a/modules/apex.cc
+++ b/modules/apex.cc
@@ -260,22 +260,48 @@ Result<std::map<std::string, ApexInfo>> ScanActiveApexes(const std::string& root
}
bool ApexInfo::InSystem() const {
- return StartsWith(original_path, "/system/apex/") ||
- StartsWith(original_path, "/system_ext/apex/") ||
- (!IsProductVndkVersionDefined() &&
- StartsWith(original_path, "/product/apex/")) ||
- // Guest mode Android may have system APEXes from host via block APEXes
- StartsWith(original_path, "/dev/block/vd");
+ // /system partition
+ if (StartsWith(original_path, "/system/apex/")) {
+ return true;
+ }
+ // /system_ext partition
+ if (StartsWith(original_path, "/system_ext/apex/") ||
+ StartsWith(original_path, "/system/system_ext/apex/")) {
+ return true;
+ }
+ // /product partition if it's not separated from "system"
+ if (!IsProductVndkVersionDefined()) {
+ if (StartsWith(original_path, "/product/apex/") ||
+ StartsWith(original_path, "/system/product/apex/")) {
+ return true;
+ }
+ }
+ // Guest mode Android may have system APEXes from host via block APEXes
+ if (StartsWith(original_path, "/dev/block/vd")) {
+ return true;
+ }
+ return false;
}
bool ApexInfo::InProduct() const {
- return IsProductVndkVersionDefined() &&
- StartsWith(original_path, "/product/apex/");
+ // /product partition if it's separated from "system"
+ if (IsProductVndkVersionDefined()) {
+ if (StartsWith(original_path, "/product/apex/") ||
+ StartsWith(original_path, "/system/product/apex/")) {
+ return true;
+ }
+ }
+ return false;
}
bool ApexInfo::InVendor() const {
- return StartsWith(original_path, "/vendor/apex/") ||
- StartsWith(original_path, "/odm/apex/");
+ // /vendor partition
+ if (StartsWith(original_path, "/vendor/apex/") ||
+ StartsWith(original_path, "/system/vendor/apex/")) {
+ return true;
+ }
+ // /odm/apex is not supported yet.
+ return false;
}
} // namespace modules
diff --git a/modules/tests/apex_test.cc b/modules/tests/apex_test.cc
index 59e5970..f6502d4 100644
--- a/modules/tests/apex_test.cc
+++ b/modules/tests/apex_test.cc
@@ -306,3 +306,18 @@ TEST_F(ApexTest, public_libs_should_be_system_apex) {
ASSERT_TRUE(apexes.ok()) << apexes.error();
ASSERT_EQ(apexes->at("foo").public_libs, std::vector<std::string>{});
}
+
+TEST_F(ApexTest, system_ext_can_be_linked_to_system_system_ext) {
+ PrepareApex("foo", /*provide_libs=*/{"libfoo.so"}, {}, {});
+ WriteFile("/apex/apex-info-list.xml", R"(<apex-info-list>
+ <apex-info moduleName="foo"
+ preinstalledModulePath="/system/system_ext/apex/foo.apex"
+ modulePath="/data/apex/active/foo.apex"
+ isActive="true" />
+ </apex-info-list>)");
+ WriteFile("/system/etc/public.libraries.txt", "libfoo.so");
+ auto apexes = ScanActiveApexes(root);
+ ASSERT_TRUE(apexes.ok()) << apexes.error();
+ ASSERT_EQ(apexes->at("foo").public_libs,
+ std::vector<std::string>{"libfoo.so"});
+}