[incfs] Use MountRegistry to import existing mounts on start
This is a big cleanup in IncrementalService that makes it behave
nicely on runtime restart, and more:
- fixed a bunch of threading issues in createStorage/bind
- made public functions correctly accept any path in any
bind mount and translate it to the proper root mount
- got rid of "using namespace" in headers, cleaned includes
- removed all unused functions
- set CLOEXEC bit on all duped FDs
Bug: 151241369
Test: atest PackageManagerShellCommandTest \
PackageManagerShellCommandIncrementalTest \
IncrementalServiceTest
Change-Id: Ided4415aabfbfca3925b5e71c91896055886ac4a
diff --git a/services/incremental/BinderIncrementalService.cpp b/services/incremental/BinderIncrementalService.cpp
index fc8c6fe..8476674 100644
--- a/services/incremental/BinderIncrementalService.cpp
+++ b/services/incremental/BinderIncrementalService.cpp
@@ -18,6 +18,7 @@
#include <android-base/logging.h>
#include <android-base/no_destructor.h>
+#include <android/os/IVold.h>
#include <binder/IResultReceiver.h>
#include <binder/PermissionCache.h>
#include <incfs.h>
@@ -117,11 +118,12 @@
}
binder::Status BinderIncrementalService::createStorage(
- const std::string& path, const DataLoaderParamsParcel& params,
+ const std::string& path, const content::pm::DataLoaderParamsParcel& params,
const ::android::sp<::android::content::pm::IDataLoaderStatusListener>& listener,
int32_t createMode, int32_t* _aidl_return) {
*_aidl_return =
- mImpl.createStorage(path, const_cast<DataLoaderParamsParcel&&>(params), listener,
+ mImpl.createStorage(path, const_cast<content::pm::DataLoaderParamsParcel&&>(params),
+ listener,
android::incremental::IncrementalService::CreateOptions(
createMode));
return ok();
@@ -238,11 +240,8 @@
binder::Status BinderIncrementalService::getMetadataByPath(int32_t storageId,
const std::string& path,
std::vector<uint8_t>* _aidl_return) {
- auto fid = mImpl.nodeFor(storageId, path);
- if (fid != kIncFsInvalidFileId) {
- auto metadata = mImpl.getMetadata(storageId, fid);
- _aidl_return->assign(metadata.begin(), metadata.end());
- }
+ auto metadata = mImpl.getMetadata(storageId, path);
+ _aidl_return->assign(metadata.begin(), metadata.end());
return ok();
}