[incremental] respect extractNativeLibs in native lib config
Makes sure the behavior is consistent with legacy installs:
When the flag is on, the native libs will be extracted to subdirs under
lib/.
When the flag is off, the lib/ subdirs will be created but the native
libs are not extracted.
When the flag is off, check if the native libs are uncompressed and well
aligned.
Test: atest android.extractnativelibs.cts.CtsExtractNativeLibsHostTest
BUG: 157173358
Change-Id: Idb57fd7ca1115f787faf5cde3056c32ff3f60890
diff --git a/services/incremental/IncrementalService.cpp b/services/incremental/IncrementalService.cpp
index f0dca77..bf859b9 100644
--- a/services/incremental/IncrementalService.cpp
+++ b/services/incremental/IncrementalService.cpp
@@ -1371,7 +1371,7 @@
// Extract lib files from zip, create new files in incfs and write data to them
bool IncrementalService::configureNativeBinaries(StorageId storage, std::string_view apkFullPath,
std::string_view libDirRelativePath,
- std::string_view abi) {
+ std::string_view abi, bool extractNativeLibs) {
auto start = Clock::now();
const auto ifs = getIfs(storage);
@@ -1415,6 +1415,21 @@
continue;
}
+ if (!extractNativeLibs) {
+ // ensure the file is properly aligned and unpacked
+ if (entry.method != kCompressStored) {
+ LOG(WARNING) << "Library " << fileName << " must be uncompressed to mmap it";
+ return false;
+ }
+ if ((entry.offset & (constants().blockSize - 1)) != 0) {
+ LOG(WARNING) << "Library " << fileName
+ << " must be page-aligned to mmap it, offset = 0x" << std::hex
+ << entry.offset;
+ return false;
+ }
+ continue;
+ }
+
auto startFileTs = Clock::now();
const auto libName = path::basename(fileName);