summaryrefslogtreecommitdiff
path: root/services/incremental
diff options
context:
space:
mode:
author Songchun Fan <schfan@google.com> 2020-01-31 16:52:41 -0800
committer Songchun Fan <schfan@google.com> 2020-01-31 19:48:35 -0800
commit54c6aed58d3030ad4ecd5a22fcf702f0f1256604 (patch)
tree3bf81bd6559adb5ecd89bab82823bc61070243fd /services/incremental
parente0fb3e2dcd6c4a54e8cf1696fbeb174b0985c22d (diff)
make adb install --incremental work
With a simple Java apk (flipboard.app). BUG: 133435829 Test: manual Change-Id: If702afffc0e01cbb03f88560c0569fd23dda2350
Diffstat (limited to 'services/incremental')
-rw-r--r--services/incremental/BinderIncrementalService.cpp9
-rw-r--r--services/incremental/IncrementalService.cpp23
2 files changed, 24 insertions, 8 deletions
diff --git a/services/incremental/BinderIncrementalService.cpp b/services/incremental/BinderIncrementalService.cpp
index f1b637f516ea..91d05723a605 100644
--- a/services/incremental/BinderIncrementalService.cpp
+++ b/services/incremental/BinderIncrementalService.cpp
@@ -111,10 +111,9 @@ binder::Status BinderIncrementalService::openStorage(const std::string& path,
binder::Status BinderIncrementalService::createStorage(const std::string& path,
const DataLoaderParamsParcel& params,
int32_t createMode, int32_t* _aidl_return) {
- *_aidl_return =
- mImpl.createStorage(path, const_cast<DataLoaderParamsParcel&&>(params),
- android::incremental::IncrementalService::CreateOptions(
- createMode));
+ *_aidl_return = mImpl.createStorage(path, const_cast<DataLoaderParamsParcel&&>(params),
+ android::incremental::IncrementalService::CreateOptions(
+ createMode));
return ok();
}
@@ -195,7 +194,7 @@ binder::Status BinderIncrementalService::makeFile(
return ok();
}
- *_aidl_return = mImpl.makeFile(storageId, path, 0555, fileId, nfp);
+ *_aidl_return = mImpl.makeFile(storageId, path, 0777, fileId, nfp);
return ok();
}
binder::Status BinderIncrementalService::makeFileFromRange(int32_t storageId,
diff --git a/services/incremental/IncrementalService.cpp b/services/incremental/IncrementalService.cpp
index 414c66c866db..e4a37dde7758 100644
--- a/services/incremental/IncrementalService.cpp
+++ b/services/incremental/IncrementalService.cpp
@@ -30,7 +30,6 @@
#include <binder/BinderService.h>
#include <binder/ParcelFileDescriptor.h>
#include <binder/Status.h>
-
#include <openssl/sha.h>
#include <sys/stat.h>
#include <uuid/uuid.h>
@@ -612,13 +611,18 @@ int IncrementalService::bind(StorageId storage, std::string_view source, std::st
if (!ifs) {
return -EINVAL;
}
- auto normSource = path::normalize(source);
std::unique_lock l(ifs->lock);
const auto storageInfo = ifs->storages.find(storage);
if (storageInfo == ifs->storages.end()) {
return -EINVAL;
}
+ std::string normSource;
+ if (path::isAbsolute(source)) {
+ normSource = path::normalize(source);
+ } else {
+ normSource = path::normalize(path::join(storageInfo->second.name, source));
+ }
if (!path::startsWith(normSource, storageInfo->second.name)) {
return -EINVAL;
}
@@ -673,7 +677,20 @@ int IncrementalService::unbind(StorageId storage, std::string_view target) {
int IncrementalService::makeFile(StorageId storage, std::string_view path, int mode, FileId id,
incfs::NewFileParams params) {
if (auto ifs = getIfs(storage)) {
- auto err = mIncFs->makeFile(ifs->control, path, mode, id, params);
+ const auto storageInfo = ifs->storages.find(storage);
+ if (storageInfo == ifs->storages.end()) {
+ return -EINVAL;
+ }
+ std::string normPath;
+ if (path::isAbsolute(path)) {
+ normPath = path::normalize(path);
+ } else {
+ normPath = path::normalize(path::join(storageInfo->second.name, path));
+ }
+ if (!path::startsWith(normPath, storageInfo->second.name)) {
+ return -EINVAL;
+ }
+ auto err = mIncFs->makeFile(ifs->control, normPath, mode, id, params);
if (err) {
return err;
}