reinstall

This commit is contained in:
Romain Vimont 2022-07-03 00:54:00 +02:00
parent ab7549bc6e
commit dc62c4c61f
6 changed files with 22 additions and 3 deletions

View file

@ -58,6 +58,7 @@
#define OPT_PRINT_FPS 1038
#define OPT_NO_POWER_ON 1039
#define OPT_INSTALL 1040
#define OPT_REINSTALL 1041
struct sc_option {
char shortopt;
@ -385,6 +386,13 @@ static const struct sc_option options[] = {
.argdesc = "format",
.text = "Force recording format (either mp4 or mkv).",
},
{
.longopt_id = OPT_REINSTALL,
.longopt = "reinstall",
.text = "Reinstall the server (via 'adb install'), even if the correct "
"version is already installed.\n"
"Implies --install.",
},
{
.longopt_id = OPT_RENDER_DRIVER,
.longopt = "render-driver",
@ -1620,6 +1628,10 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
case OPT_INSTALL:
opts->install = true;
break;
case OPT_REINSTALL:
opts->install = true;
opts->reinstall = true;
break;
case OPT_OTG:
#ifdef HAVE_USB
opts->otg = true;

View file

@ -66,4 +66,5 @@ const struct scrcpy_options scrcpy_options_default = {
.start_fps_counter = false,
.power_on = true,
.install = false,
.reinstall = false,
};

View file

@ -141,6 +141,7 @@ struct scrcpy_options {
bool start_fps_counter;
bool power_on;
bool install;
bool reinstall;
};
extern const struct scrcpy_options scrcpy_options_default;

View file

@ -326,6 +326,7 @@ scrcpy(struct scrcpy_options *options) {
.cleanup = options->cleanup,
.power_on = options->power_on,
.install = options->install,
.reinstall = options->reinstall,
};
static const struct sc_server_callbacks cbs = {

View file

@ -105,7 +105,10 @@ error:
}
static bool
push_server(struct sc_intr *intr, const char *serial, bool install) {
push_server(struct sc_intr *intr, const char *serial, bool install,
bool reinstall) {
assert(install || !reinstall); // reinstall implies install
char *server_path = get_server_path();
if (!server_path) {
return false;
@ -121,7 +124,7 @@ push_server(struct sc_intr *intr, const char *serial, bool install) {
char *version = sc_adb_get_installed_apk_version(intr, serial, 0);
bool same_version = version && !strcmp(version, SCRCPY_VERSION);
free(version);
if (same_version) {
if (!reinstall && same_version) {
LOGI("Server " SCRCPY_VERSION " already installed");
ok = true;
} else {
@ -818,7 +821,7 @@ run_server(void *data) {
assert(serial);
LOGD("Device serial: %s", serial);
ok = push_server(&server->intr, serial, params->install);
ok = push_server(&server->intr, serial, params->install, params->reinstall);
if (!ok) {
LOGE("Failed to push server");
goto error_connection_failed;

View file

@ -49,6 +49,7 @@ struct sc_server_params {
bool cleanup;
bool power_on;
bool install;
bool reinstall;
};
struct sc_server {