Merge "[incremental] respect extractNativeLibs in native lib config" into rvc-dev am: f2a6af4b8a

Change-Id: I55b95eadbff0e92017001f04274266904dba783f
This commit is contained in:
Songchun Fan
2020-05-27 22:31:23 +00:00
committed by Automerger Merge Worker
7 changed files with 32 additions and 10 deletions

View File

@@ -111,9 +111,9 @@ interface IIncrementalService {
void deleteStorage(int storageId); void deleteStorage(int storageId);
/** /**
* Setting up native library directories and extract native libs onto a storage. * Setting up native library directories and extract native libs onto a storage if needed.
*/ */
boolean configureNativeBinaries(int storageId, in @utf8InCpp String apkFullPath, in @utf8InCpp String libDirRelativePath, in @utf8InCpp String abi); boolean configureNativeBinaries(int storageId, in @utf8InCpp String apkFullPath, in @utf8InCpp String libDirRelativePath, in @utf8InCpp String abi, boolean extractNativeLibs);
/** /**
* Waits until all native library extraction is done for the storage * Waits until all native library extraction is done for the storage

View File

@@ -469,12 +469,15 @@ public final class IncrementalStorage {
* @param apkFullPath Source APK to extract native libs from. * @param apkFullPath Source APK to extract native libs from.
* @param libDirRelativePath Target dir to put lib files, e.g., "lib" or "lib/arm". * @param libDirRelativePath Target dir to put lib files, e.g., "lib" or "lib/arm".
* @param abi Target ABI of the native lib files. Only extract native libs of this ABI. * @param abi Target ABI of the native lib files. Only extract native libs of this ABI.
* @param extractNativeLibs If true, extract native libraries; otherwise just setup directories
* without extracting.
* @return Success of not. * @return Success of not.
*/ */
public boolean configureNativeBinaries(String apkFullPath, String libDirRelativePath, public boolean configureNativeBinaries(String apkFullPath, String libDirRelativePath,
String abi) { String abi, boolean extractNativeLibs) {
try { try {
return mService.configureNativeBinaries(mId, apkFullPath, libDirRelativePath, abi); return mService.configureNativeBinaries(mId, apkFullPath, libDirRelativePath, abi,
extractNativeLibs);
} catch (RemoteException e) { } catch (RemoteException e) {
e.rethrowFromSystemServer(); e.rethrowFromSystemServer();
return false; return false;

View File

@@ -506,7 +506,8 @@ public class NativeLibraryHelper {
} }
for (int i = 0; i < apkPaths.length; i++) { for (int i = 0; i < apkPaths.length; i++) {
if (!incrementalStorage.configureNativeBinaries(apkPaths[i], libRelativeDir, abi)) { if (!incrementalStorage.configureNativeBinaries(apkPaths[i], libRelativeDir, abi,
handle.extractNativeLibs)) {
return PackageManager.INSTALL_FAILED_INTERNAL_ERROR; return PackageManager.INSTALL_FAILED_INTERNAL_ERROR;
} }
} }

View File

@@ -280,8 +280,9 @@ binder::Status BinderIncrementalService::startLoading(int32_t storageId, bool* _
binder::Status BinderIncrementalService::configureNativeBinaries( binder::Status BinderIncrementalService::configureNativeBinaries(
int32_t storageId, const std::string& apkFullPath, const std::string& libDirRelativePath, int32_t storageId, const std::string& apkFullPath, const std::string& libDirRelativePath,
const std::string& abi, bool* _aidl_return) { const std::string& abi, bool extractNativeLibs, bool* _aidl_return) {
*_aidl_return = mImpl.configureNativeBinaries(storageId, apkFullPath, libDirRelativePath, abi); *_aidl_return = mImpl.configureNativeBinaries(storageId, apkFullPath, libDirRelativePath, abi,
extractNativeLibs);
return ok(); return ok();
} }

View File

@@ -77,7 +77,8 @@ public:
binder::Status configureNativeBinaries(int32_t storageId, const std::string& apkFullPath, binder::Status configureNativeBinaries(int32_t storageId, const std::string& apkFullPath,
const std::string& libDirRelativePath, 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; binder::Status waitForNativeBinariesExtraction(int storageId, bool* _aidl_return) final;
private: private:

View File

@@ -1379,7 +1379,7 @@ static long elapsedMcs(Duration start, Duration end) {
// Extract lib files from zip, create new files in incfs and write data to them // Extract lib files from zip, create new files in incfs and write data to them
bool IncrementalService::configureNativeBinaries(StorageId storage, std::string_view apkFullPath, bool IncrementalService::configureNativeBinaries(StorageId storage, std::string_view apkFullPath,
std::string_view libDirRelativePath, std::string_view libDirRelativePath,
std::string_view abi) { std::string_view abi, bool extractNativeLibs) {
auto start = Clock::now(); auto start = Clock::now();
const auto ifs = getIfs(storage); const auto ifs = getIfs(storage);
@@ -1423,6 +1423,21 @@ bool IncrementalService::configureNativeBinaries(StorageId storage, std::string_
continue; 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(); auto startFileTs = Clock::now();
const auto libName = path::basename(fileName); const auto libName = path::basename(fileName);

View File

@@ -138,7 +138,8 @@ public:
bool startLoading(StorageId storage) const; bool startLoading(StorageId storage) const;
bool configureNativeBinaries(StorageId storage, std::string_view apkFullPath, 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); bool waitForNativeBinariesExtraction(StorageId storage);
class AppOpsListener : public android::BnAppOpsCallback { class AppOpsListener : public android::BnAppOpsCallback {