use 'cmd' command for install-multiple
adb install-multiple makes a minimum of 3 calls to the 'pm' command. This causes at least 3 separate "pm" processes to be spun up. Instead, use the 'cmd' command which runs in the existing system_server process. Bug: 27483932 Bug: 30273584 Change-Id: Ia1bed405c3d7e675a1a56ff82c692aaa94388a5c
This commit is contained in:
parent
d211558788
commit
62083939df
1 changed files with 28 additions and 26 deletions
|
|
@ -1480,6 +1480,16 @@ static bool _is_valid_ack_reply_fd(const int ack_reply_fd) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool _use_legacy_install() {
|
||||||
|
FeatureSet features;
|
||||||
|
std::string error;
|
||||||
|
if (!adb_get_feature_set(&features, &error)) {
|
||||||
|
fprintf(stderr, "error: %s\n", error.c_str());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return !CanUseFeature(features, kFeatureCmd);
|
||||||
|
}
|
||||||
|
|
||||||
int adb_commandline(int argc, const char **argv) {
|
int adb_commandline(int argc, const char **argv) {
|
||||||
int no_daemon = 0;
|
int no_daemon = 0;
|
||||||
int is_daemon = 0;
|
int is_daemon = 0;
|
||||||
|
|
@ -1846,17 +1856,10 @@ int adb_commandline(int argc, const char **argv) {
|
||||||
}
|
}
|
||||||
else if (!strcmp(argv[0], "install")) {
|
else if (!strcmp(argv[0], "install")) {
|
||||||
if (argc < 2) return usage();
|
if (argc < 2) return usage();
|
||||||
FeatureSet features;
|
if (_use_legacy_install()) {
|
||||||
std::string error;
|
return install_app_legacy(transport_type, serial, argc, argv);
|
||||||
if (!adb_get_feature_set(&features, &error)) {
|
|
||||||
fprintf(stderr, "error: %s\n", error.c_str());
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
return install_app(transport_type, serial, argc, argv);
|
||||||
if (CanUseFeature(features, kFeatureCmd)) {
|
|
||||||
return install_app(transport_type, serial, argc, argv);
|
|
||||||
}
|
|
||||||
return install_app_legacy(transport_type, serial, argc, argv);
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(argv[0], "install-multiple")) {
|
else if (!strcmp(argv[0], "install-multiple")) {
|
||||||
if (argc < 2) return usage();
|
if (argc < 2) return usage();
|
||||||
|
|
@ -1864,17 +1867,10 @@ int adb_commandline(int argc, const char **argv) {
|
||||||
}
|
}
|
||||||
else if (!strcmp(argv[0], "uninstall")) {
|
else if (!strcmp(argv[0], "uninstall")) {
|
||||||
if (argc < 2) return usage();
|
if (argc < 2) return usage();
|
||||||
FeatureSet features;
|
if (_use_legacy_install()) {
|
||||||
std::string error;
|
return uninstall_app_legacy(transport_type, serial, argc, argv);
|
||||||
if (!adb_get_feature_set(&features, &error)) {
|
|
||||||
fprintf(stderr, "error: %s\n", error.c_str());
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
return uninstall_app(transport_type, serial, argc, argv);
|
||||||
if (CanUseFeature(features, kFeatureCmd)) {
|
|
||||||
return uninstall_app(transport_type, serial, argc, argv);
|
|
||||||
}
|
|
||||||
return uninstall_app_legacy(transport_type, serial, argc, argv);
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(argv[0], "sync")) {
|
else if (!strcmp(argv[0], "sync")) {
|
||||||
std::string src;
|
std::string src;
|
||||||
|
|
@ -2080,7 +2076,6 @@ static int install_multiple_app(TransportType transport, const char* serial, int
|
||||||
int i;
|
int i;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
uint64_t total_size = 0;
|
uint64_t total_size = 0;
|
||||||
|
|
||||||
// Find all APK arguments starting at end.
|
// Find all APK arguments starting at end.
|
||||||
// All other arguments passed through verbatim.
|
// All other arguments passed through verbatim.
|
||||||
int first_apk = -1;
|
int first_apk = -1;
|
||||||
|
|
@ -2105,7 +2100,14 @@ static int install_multiple_app(TransportType transport, const char* serial, int
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmd = android::base::StringPrintf("exec:pm install-create -S %" PRIu64, total_size);
|
std::string install_cmd;
|
||||||
|
if (_use_legacy_install()) {
|
||||||
|
install_cmd = "exec:pm";
|
||||||
|
} else {
|
||||||
|
install_cmd = "exec:cmd package";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string cmd = android::base::StringPrintf("%s install-create -S %" PRIu64, install_cmd.c_str(), total_size);
|
||||||
for (i = 1; i < first_apk; i++) {
|
for (i = 1; i < first_apk; i++) {
|
||||||
cmd += " " + escape_arg(argv[i]);
|
cmd += " " + escape_arg(argv[i]);
|
||||||
}
|
}
|
||||||
|
|
@ -2147,8 +2149,8 @@ static int install_multiple_app(TransportType transport, const char* serial, int
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmd = android::base::StringPrintf(
|
std::string cmd = android::base::StringPrintf(
|
||||||
"exec:pm install-write -S %" PRIu64 " %d %d_%s -",
|
"%s install-write -S %" PRIu64 " %d %d_%s -",
|
||||||
static_cast<uint64_t>(sb.st_size), session_id, i, adb_basename(file).c_str());
|
install_cmd.c_str(), static_cast<uint64_t>(sb.st_size), session_id, i, adb_basename(file).c_str());
|
||||||
|
|
||||||
int localFd = adb_open(file, O_RDONLY);
|
int localFd = adb_open(file, O_RDONLY);
|
||||||
if (localFd < 0) {
|
if (localFd < 0) {
|
||||||
|
|
@ -2183,8 +2185,8 @@ static int install_multiple_app(TransportType transport, const char* serial, int
|
||||||
finalize_session:
|
finalize_session:
|
||||||
// Commit session if we streamed everything okay; otherwise abandon
|
// Commit session if we streamed everything okay; otherwise abandon
|
||||||
std::string service =
|
std::string service =
|
||||||
android::base::StringPrintf("exec:pm install-%s %d",
|
android::base::StringPrintf("%s install-%s %d",
|
||||||
success ? "commit" : "abandon", session_id);
|
install_cmd.c_str(), success ? "commit" : "abandon", session_id);
|
||||||
fd = adb_connect(service, &error);
|
fd = adb_connect(service, &error);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
fprintf(stderr, "Connect error for finalize: %s\n", error.c_str());
|
fprintf(stderr, "Connect error for finalize: %s\n", error.c_str());
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue