diff options
author | Songchun Fan <schfan@google.com> | 2020-05-21 18:19:07 -0700 |
---|---|---|
committer | Songchun Fan <schfan@google.com> | 2020-05-27 22:16:57 +0000 |
commit | 14f6c3c735164f8c0f879e96a568168b0c564fa6 (patch) | |
tree | c37f5f157beff7d081684192c70e6a19bbe6b7be /services/incremental | |
parent | 2cdbcea8ba29bbb8d50511a9fa6e5bd2763fb153 (diff) |
[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
Diffstat (limited to 'services/incremental')
-rw-r--r-- | services/incremental/BinderIncrementalService.cpp | 5 | ||||
-rw-r--r-- | services/incremental/BinderIncrementalService.h | 3 | ||||
-rw-r--r-- | services/incremental/IncrementalService.cpp | 17 | ||||
-rw-r--r-- | services/incremental/IncrementalService.h | 3 |
4 files changed, 23 insertions, 5 deletions
diff --git a/services/incremental/BinderIncrementalService.cpp b/services/incremental/BinderIncrementalService.cpp index 847667427593..d99299b5f07c 100644 --- a/services/incremental/BinderIncrementalService.cpp +++ b/services/incremental/BinderIncrementalService.cpp @@ -276,8 +276,9 @@ binder::Status BinderIncrementalService::startLoading(int32_t storageId, bool* _ binder::Status BinderIncrementalService::configureNativeBinaries( int32_t storageId, const std::string& apkFullPath, const std::string& libDirRelativePath, - const std::string& abi, bool* _aidl_return) { - *_aidl_return = mImpl.configureNativeBinaries(storageId, apkFullPath, libDirRelativePath, abi); + const std::string& abi, bool extractNativeLibs, bool* _aidl_return) { + *_aidl_return = mImpl.configureNativeBinaries(storageId, apkFullPath, libDirRelativePath, abi, + extractNativeLibs); return ok(); } diff --git a/services/incremental/BinderIncrementalService.h b/services/incremental/BinderIncrementalService.h index 5a7d5da56f18..659f6afcc03f 100644 --- a/services/incremental/BinderIncrementalService.h +++ b/services/incremental/BinderIncrementalService.h @@ -75,7 +75,8 @@ public: binder::Status configureNativeBinaries(int32_t storageId, const std::string& apkFullPath, const std::string& libDirRelativePath, - const std::string& abi, bool* _aidl_return) final; + const std::string& abi, bool extractNativeLibs, + bool* _aidl_return) final; binder::Status waitForNativeBinariesExtraction(int storageId, bool* _aidl_return) final; private: diff --git a/services/incremental/IncrementalService.cpp b/services/incremental/IncrementalService.cpp index f0dca772adaa..bf859b9b914d 100644 --- a/services/incremental/IncrementalService.cpp +++ b/services/incremental/IncrementalService.cpp @@ -1371,7 +1371,7 @@ static long elapsedMcs(Duration start, Duration end) { // 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 @@ bool IncrementalService::configureNativeBinaries(StorageId storage, std::string_ 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); diff --git a/services/incremental/IncrementalService.h b/services/incremental/IncrementalService.h index f3fde2a413e8..c2a06ae83465 100644 --- a/services/incremental/IncrementalService.h +++ b/services/incremental/IncrementalService.h @@ -128,7 +128,8 @@ public: bool startLoading(StorageId storage) const; bool configureNativeBinaries(StorageId storage, std::string_view apkFullPath, - std::string_view libDirRelativePath, std::string_view abi); + std::string_view libDirRelativePath, std::string_view abi, + bool extractNativeLibs); bool waitForNativeBinariesExtraction(StorageId storage); class AppOpsListener : public android::BnAppOpsCallback { |