OnDeviceRefresh::GetSystemServerImagePath support system_ext partition
The /system_ext partition is assumed to be the OEM-specific extension
to the /system partition.
OEM installed SYSTEMSERVERJAR on the system_ext partition does not
require additional execution of dex2oat
Bug: 245383870
Test: atest art_standalone_odrefresh_tests
Change-Id: Ib7b74ef50d50a5203adc8f14efcecf0e7920139a
Signed-off-by: huyuxin <huyuxin@xiaomi.com>
diff --git a/libartbase/base/file_utils.cc b/libartbase/base/file_utils.cc
index 3c3583d..acbcd0e 100644
--- a/libartbase/base/file_utils.cc
+++ b/libartbase/base/file_utils.cc
@@ -685,8 +685,27 @@
#endif
}
+bool LocationIsOnSystemExt(const std::string& location) {
+#ifdef _WIN32
+ UNUSED(location);
+ LOG(FATAL) << "LocationIsOnSystemExt is unsupported on Windows.";
+ return false;
+#else
+ return IsLocationOn(location,
+ kAndroidSystemExtRootEnvVar,
+ kAndroidSystemExtRootDefaultPath) ||
+ // When the 'system_ext' partition is not present, builds will create
+ // '/system/system_ext' instead.
+ IsLocationOn(location,
+ kAndroidRootEnvVar,
+ kAndroidRootDefaultPath,
+ /* subdir= */ "system_ext/");
+#endif
+}
+
bool LocationIsTrusted(const std::string& location, bool trust_art_apex_data_files) {
- if (LocationIsOnSystem(location) || LocationIsOnArtModule(location)) {
+ if (LocationIsOnSystem(location) || LocationIsOnSystemExt(location)
+ || LocationIsOnArtModule(location)) {
return true;
}
return LocationIsOnArtApexData(location) & trust_art_apex_data_files;
diff --git a/libartbase/base/file_utils.h b/libartbase/base/file_utils.h
index b9d999f..45948b4 100644
--- a/libartbase/base/file_utils.h
+++ b/libartbase/base/file_utils.h
@@ -163,6 +163,9 @@
// Return whether the location is on system (i.e. android root).
bool LocationIsOnSystem(const std::string& location);
+// Return whether the location is on system_ext
+bool LocationIsOnSystemExt(const std::string& location);
+
// Return whether the location is on system/framework (i.e. $ANDROID_ROOT/framework).
bool LocationIsOnSystemFramework(std::string_view location);
diff --git a/odrefresh/odrefresh.cc b/odrefresh/odrefresh.cc
index ba32b0a..3994f38 100644
--- a/odrefresh/odrefresh.cc
+++ b/odrefresh/odrefresh.cc
@@ -777,7 +777,7 @@
const std::string image_name = ReplaceFileExtension(jar_name, "art");
const char* isa_str = GetInstructionSetString(config_.GetSystemServerIsa());
// Typically "/system/framework/oat/<isa>/services.art".
- return Concatenate({GetAndroidRoot(), "/framework/oat/", isa_str, "/", image_name});
+ return Concatenate({android::base::Dirname(jar_path), "/oat/", isa_str, "/", image_name});
} else {
// Typically
// "/data/misc/apexdata/.../dalvik-cache/<isa>/system@framework@services.jar@classes.art".