mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-07-15 05:21:45 +00:00
Add option --reinstall
With --install, the server is installed only if the current version is not already installed. Passing --reinstall force reinstallation is all cases.
This commit is contained in:
parent
bef5b11e45
commit
2bc1f59b5b
7 changed files with 26 additions and 3 deletions
|
@ -246,6 +246,10 @@ option if set, or by the file extension (.mp4 or .mkv).
|
||||||
.BI "\-\-record\-format " format
|
.BI "\-\-record\-format " format
|
||||||
Force recording format (either mp4 or mkv).
|
Force recording format (either mp4 or mkv).
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B \-\-reinstall
|
||||||
|
Reinstall the server (via "adb install"), even if the correct version is already installed. Implies \fB\-\-install\fR.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BI "\-\-render\-driver " name
|
.BI "\-\-render\-driver " name
|
||||||
Request SDL to use the given render driver (this is just a hint).
|
Request SDL to use the given render driver (this is just a hint).
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
#define OPT_PRINT_FPS 1038
|
#define OPT_PRINT_FPS 1038
|
||||||
#define OPT_NO_POWER_ON 1039
|
#define OPT_NO_POWER_ON 1039
|
||||||
#define OPT_INSTALL 1040
|
#define OPT_INSTALL 1040
|
||||||
|
#define OPT_REINSTALL 1041
|
||||||
|
|
||||||
struct sc_option {
|
struct sc_option {
|
||||||
char shortopt;
|
char shortopt;
|
||||||
|
@ -385,6 +386,13 @@ static const struct sc_option options[] = {
|
||||||
.argdesc = "format",
|
.argdesc = "format",
|
||||||
.text = "Force recording format (either mp4 or mkv).",
|
.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_id = OPT_RENDER_DRIVER,
|
||||||
.longopt = "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:
|
case OPT_INSTALL:
|
||||||
opts->install = true;
|
opts->install = true;
|
||||||
break;
|
break;
|
||||||
|
case OPT_REINSTALL:
|
||||||
|
opts->install = true;
|
||||||
|
opts->reinstall = true;
|
||||||
|
break;
|
||||||
case OPT_OTG:
|
case OPT_OTG:
|
||||||
#ifdef HAVE_USB
|
#ifdef HAVE_USB
|
||||||
opts->otg = true;
|
opts->otg = true;
|
||||||
|
|
|
@ -66,4 +66,5 @@ const struct scrcpy_options scrcpy_options_default = {
|
||||||
.start_fps_counter = false,
|
.start_fps_counter = false,
|
||||||
.power_on = true,
|
.power_on = true,
|
||||||
.install = false,
|
.install = false,
|
||||||
|
.reinstall = false,
|
||||||
};
|
};
|
||||||
|
|
|
@ -141,6 +141,7 @@ struct scrcpy_options {
|
||||||
bool start_fps_counter;
|
bool start_fps_counter;
|
||||||
bool power_on;
|
bool power_on;
|
||||||
bool install;
|
bool install;
|
||||||
|
bool reinstall;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const struct scrcpy_options scrcpy_options_default;
|
extern const struct scrcpy_options scrcpy_options_default;
|
||||||
|
|
|
@ -326,6 +326,7 @@ scrcpy(struct scrcpy_options *options) {
|
||||||
.cleanup = options->cleanup,
|
.cleanup = options->cleanup,
|
||||||
.power_on = options->power_on,
|
.power_on = options->power_on,
|
||||||
.install = options->install,
|
.install = options->install,
|
||||||
|
.reinstall = options->reinstall,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct sc_server_callbacks cbs = {
|
static const struct sc_server_callbacks cbs = {
|
||||||
|
|
|
@ -105,7 +105,10 @@ error:
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
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();
|
char *server_path = get_server_path();
|
||||||
if (!server_path) {
|
if (!server_path) {
|
||||||
return false;
|
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);
|
char *version = sc_adb_get_installed_apk_version(intr, serial, 0);
|
||||||
bool same_version = version && !strcmp(version, SCRCPY_VERSION);
|
bool same_version = version && !strcmp(version, SCRCPY_VERSION);
|
||||||
free(version);
|
free(version);
|
||||||
if (same_version) {
|
if (!reinstall && same_version) {
|
||||||
LOGI("Server " SCRCPY_VERSION " already installed");
|
LOGI("Server " SCRCPY_VERSION " already installed");
|
||||||
ok = true;
|
ok = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -818,7 +821,7 @@ run_server(void *data) {
|
||||||
assert(serial);
|
assert(serial);
|
||||||
LOGD("Device serial: %s", 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) {
|
if (!ok) {
|
||||||
LOGE("Failed to push server");
|
LOGE("Failed to push server");
|
||||||
goto error_connection_failed;
|
goto error_connection_failed;
|
||||||
|
|
|
@ -49,6 +49,7 @@ struct sc_server_params {
|
||||||
bool cleanup;
|
bool cleanup;
|
||||||
bool power_on;
|
bool power_on;
|
||||||
bool install;
|
bool install;
|
||||||
|
bool reinstall;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sc_server {
|
struct sc_server {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue