diff options
author | 2024-10-02 00:36:39 +0000 | |
---|---|---|
committer | 2024-10-04 23:07:43 +0000 | |
commit | 00db5b25da2d2ff8005476c7c735eb4f921d3a56 (patch) | |
tree | 07c53f69b24307110c069720186a65fe3f06737d | |
parent | 12e3c233150301584241e07337f173bfe588aad2 (diff) |
Search in /system_ext for apex systemserver dexpreopt files
With https://r.android.com/3288083, the dexpreopt files of apex system
server jars will be installed in the same pratition as the parent apex.
This CL updates `GetSystemOdexFilenameForApex` to look for these files
in /system, followed by /system_ext
Since file existence is now checked and unit tests do not set up a mock
filesystem, an existing unit test has been updated to expect the
filepath to be in /system_ext
(There is also a long term discussion of moving them to system_other)
Test: Verified that "Could not check odex file" does not appear for
service-compos (a system_ext apex systemserver jar)
Test: m test-art-host-gtest
Bug: 369678122
Bug: 349083274
Change-Id: I2c0f3394a1c5ab4900bd96798ba7ea348d9c9b80
-rw-r--r-- | libartbase/base/file_utils.cc | 11 | ||||
-rw-r--r-- | libartbase/base/file_utils_test.cc | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/libartbase/base/file_utils.cc b/libartbase/base/file_utils.cc index 1be8327b13..b784754313 100644 --- a/libartbase/base/file_utils.cc +++ b/libartbase/base/file_utils.cc @@ -720,6 +720,7 @@ std::string GetDmFilename(const std::string& dex_location) { return ReplaceFileExtension(dex_location, "dm"); } +// check for the file in /system, followed by /system_ext std::string GetSystemOdexFilenameForApex(std::string_view location, InstructionSet isa) { DCHECK(LocationIsOnApex(location)); std::string dir = GetAndroidRoot() + "/framework/oat/" + GetInstructionSetString(isa); @@ -728,6 +729,16 @@ std::string GetSystemOdexFilenameForApex(std::string_view location, InstructionS // This should never fail. The function fails only if the location is not absolute, and a location // on /apex is always absolute. DCHECK(ret) << error_msg; + std::string path = ReplaceFileExtension(result, "odex"); + if (OS::FileExists(path.c_str(), /*check_file_type=*/true)) { + return path; + } + // check in /system_ext + dir = GetSystemExtRoot() + "/framework/oat/" + GetInstructionSetString(isa); + ret = GetLocationEncodedFilename(location, dir, &result, &error_msg); + // This should never fail. The function fails only if the location is not absolute, and a location + // on /apex is always absolute. + DCHECK(ret) << error_msg; return ReplaceFileExtension(result, "odex"); } diff --git a/libartbase/base/file_utils_test.cc b/libartbase/base/file_utils_test.cc index e660f35d94..6032555928 100644 --- a/libartbase/base/file_utils_test.cc +++ b/libartbase/base/file_utils_test.cc @@ -323,7 +323,7 @@ TEST_F(FileUtilsTest, GetSystemOdexFilenameForApex) { const std::string apex_jar = std::string {kAndroidArtApexDefaultPath} + "/javalib/some.jar"; EXPECT_EQ( - GetAndroidRoot() + "/framework/oat/arm/apex@com.android.art@javalib@some.jar@classes.odex", + GetSystemExtRoot() + "/framework/oat/arm/apex@com.android.art@javalib@some.jar@classes.odex", GetSystemOdexFilenameForApex(apex_jar, InstructionSet::kArm)); } |