Merge "Passing additional flags to incremental installation." am: f947d50395

Change-Id: I0d4bdaabfa252bba51e9df6ce56b65909a445197
This commit is contained in:
Treehugger Robot 2020-05-15 06:06:46 +00:00 committed by Automerger Merge Worker
commit 7a98a642fd
3 changed files with 10 additions and 14 deletions

View file

@ -310,7 +310,7 @@ static int install_app_incremental(int argc, const char** argv, bool wait, bool
const auto start = clock::now();
int first_apk = -1;
int last_apk = -1;
std::vector<std::string_view> args = {"package"sv};
incremental::Args passthrough_args = {};
for (int i = 0; i < argc; ++i) {
const auto arg = std::string_view(argv[i]);
if (android::base::EndsWithIgnoreCase(arg, ".apk"sv)) {
@ -318,12 +318,11 @@ static int install_app_incremental(int argc, const char** argv, bool wait, bool
if (first_apk == -1) {
first_apk = i;
}
} else if (arg.starts_with("install-"sv)) {
} else if (arg.starts_with("install"sv)) {
// incremental installation command on the device is the same for all its variations in
// the adb, e.g. install-multiple or install-multi-package
args.push_back("install"sv);
} else {
args.push_back(arg);
passthrough_args.push_back(arg);
}
}
@ -344,7 +343,7 @@ static int install_app_incremental(int argc, const char** argv, bool wait, bool
}
printf("Performing Incremental Install\n");
auto server_process = incremental::install(files, silent);
auto server_process = incremental::install(files, passthrough_args, silent);
if (!server_process) {
return -1;
}

View file

@ -93,12 +93,10 @@ static std::pair<unique_fd, std::string> read_and_encode_signature(Size file_siz
// Send install-incremental to the device along with properly configured file descriptors in
// streaming format. Once connection established, send all fs-verity tree bytes.
static unique_fd start_install(const Files& files, bool silent) {
static unique_fd start_install(const Files& files, const Args& passthrough_args, bool silent) {
std::vector<std::string> command_args{"package", "install-incremental"};
command_args.insert(command_args.end(), passthrough_args.begin(), passthrough_args.end());
// fd's with positions at the beginning of fs-verity
std::vector<unique_fd> signature_fds;
signature_fds.reserve(files.size());
for (int i = 0, size = files.size(); i < size; ++i) {
const auto& file = files[i];
@ -118,8 +116,6 @@ static unique_fd start_install(const Files& files, bool silent) {
auto file_desc = StringPrintf("%s:%lld:%d:%s:1", android::base::Basename(file).c_str(),
(long long)st.st_size, i, signature.c_str());
command_args.push_back(std::move(file_desc));
signature_fds.push_back(std::move(signature_fd));
}
std::string error;
@ -150,8 +146,8 @@ bool can_install(const Files& files) {
return true;
}
std::optional<Process> install(const Files& files, bool silent) {
auto connection_fd = start_install(files, silent);
std::optional<Process> install(const Files& files, const Args& passthrough_args, bool silent) {
auto connection_fd = start_install(files, passthrough_args, silent);
if (connection_fd < 0) {
if (!silent) {
fprintf(stderr, "adb: failed to initiate installation on device.\n");

View file

@ -26,9 +26,10 @@
namespace incremental {
using Files = std::vector<std::string>;
using Args = std::vector<std::string_view>;
bool can_install(const Files& files);
std::optional<Process> install(const Files& files, bool silent);
std::optional<Process> install(const Files& files, const Args& passthrough_args, bool silent);
enum class Result { Success, Failure, None };
Result wait_for_installation(int read_fd);