make adb install --incremental work
With a simple Java apk (flipboard.app).
BUG: 133435829
Test: manual
Change-Id: If702afffc0e01cbb03f88560c0569fd23dda2350
diff --git a/services/incremental/IncrementalService.cpp b/services/incremental/IncrementalService.cpp
index 414c66c..e4a37dde 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 @@
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::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;
}