Merge "Passing additional flags to incremental installation." am: f947d50395 am: 7a98a642fd
Change-Id: Icc37b29af0f9a84c740ec115d3fc4334725fc19d
This commit is contained in:
commit
4e901d430f
3 changed files with 10 additions and 14 deletions
|
|
@ -310,7 +310,7 @@ static int install_app_incremental(int argc, const char** argv, bool wait, bool
|
||||||
const auto start = clock::now();
|
const auto start = clock::now();
|
||||||
int first_apk = -1;
|
int first_apk = -1;
|
||||||
int last_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) {
|
for (int i = 0; i < argc; ++i) {
|
||||||
const auto arg = std::string_view(argv[i]);
|
const auto arg = std::string_view(argv[i]);
|
||||||
if (android::base::EndsWithIgnoreCase(arg, ".apk"sv)) {
|
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) {
|
if (first_apk == -1) {
|
||||||
first_apk = i;
|
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
|
// incremental installation command on the device is the same for all its variations in
|
||||||
// the adb, e.g. install-multiple or install-multi-package
|
// the adb, e.g. install-multiple or install-multi-package
|
||||||
args.push_back("install"sv);
|
|
||||||
} else {
|
} 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");
|
printf("Performing Incremental Install\n");
|
||||||
auto server_process = incremental::install(files, silent);
|
auto server_process = incremental::install(files, passthrough_args, silent);
|
||||||
if (!server_process) {
|
if (!server_process) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
// Send install-incremental to the device along with properly configured file descriptors in
|
||||||
// streaming format. Once connection established, send all fs-verity tree bytes.
|
// 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"};
|
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) {
|
for (int i = 0, size = files.size(); i < size; ++i) {
|
||||||
const auto& file = files[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(),
|
auto file_desc = StringPrintf("%s:%lld:%d:%s:1", android::base::Basename(file).c_str(),
|
||||||
(long long)st.st_size, i, signature.c_str());
|
(long long)st.st_size, i, signature.c_str());
|
||||||
command_args.push_back(std::move(file_desc));
|
command_args.push_back(std::move(file_desc));
|
||||||
|
|
||||||
signature_fds.push_back(std::move(signature_fd));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string error;
|
std::string error;
|
||||||
|
|
@ -150,8 +146,8 @@ bool can_install(const Files& files) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Process> install(const Files& files, bool silent) {
|
std::optional<Process> install(const Files& files, const Args& passthrough_args, bool silent) {
|
||||||
auto connection_fd = start_install(files, silent);
|
auto connection_fd = start_install(files, passthrough_args, silent);
|
||||||
if (connection_fd < 0) {
|
if (connection_fd < 0) {
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
fprintf(stderr, "adb: failed to initiate installation on device.\n");
|
fprintf(stderr, "adb: failed to initiate installation on device.\n");
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,10 @@
|
||||||
namespace incremental {
|
namespace incremental {
|
||||||
|
|
||||||
using Files = std::vector<std::string>;
|
using Files = std::vector<std::string>;
|
||||||
|
using Args = std::vector<std::string_view>;
|
||||||
|
|
||||||
bool can_install(const Files& files);
|
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 };
|
enum class Result { Success, Failure, None };
|
||||||
Result wait_for_installation(int read_fd);
|
Result wait_for_installation(int read_fd);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue