mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-04-22 04:25:01 +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
|
||||
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
|
||||
.BI "\-\-render\-driver " name
|
||||
Request SDL to use the given render driver (this is just a hint).
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -66,4 +66,5 @@ const struct scrcpy_options scrcpy_options_default = {
|
|||
.start_fps_counter = false,
|
||||
.power_on = true,
|
||||
.install = false,
|
||||
.reinstall = false,
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -49,6 +49,7 @@ struct sc_server_params {
|
|||
bool cleanup;
|
||||
bool power_on;
|
||||
bool install;
|
||||
bool reinstall;
|
||||
};
|
||||
|
||||
struct sc_server {
|
||||
|
|
Loading…
Add table
Reference in a new issue