diff --git a/app/src/command.c b/app/src/command.c index 246d1515..c555c0e1 100644 --- a/app/src/command.c +++ b/app/src/command.c @@ -73,6 +73,11 @@ process_t adb_push(const char *serial, const char *local, const char *remote) { return adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd)); } +process_t adb_install(const char *serial, const char *local, const char *remote) { + const char *const adb_cmd[] = {"install", local, remote}; + return adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd)); +} + process_t adb_remove_path(const char *serial, const char *path) { const char *const adb_cmd[] = {"shell", "rm", path}; return adb_execute(serial, adb_cmd, ARRAY_LEN(adb_cmd)); diff --git a/app/src/command.h b/app/src/command.h index 24ddd21d..4c218060 100644 --- a/app/src/command.h +++ b/app/src/command.h @@ -42,6 +42,7 @@ process_t adb_forward_remove(const char *serial, uint16_t local_port); process_t adb_reverse(const char *serial, const char *device_socket_name, uint16_t local_port); process_t adb_reverse_remove(const char *serial, const char *device_socket_name); process_t adb_push(const char *serial, const char *local, const char *remote); +process_t adb_install(const char *serial, const char *local, const char *remote); process_t adb_remove_path(const char *serial, const char *path); // convenience function to wait for a successful process execution diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index 204cad4f..2effa26a 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -102,6 +102,9 @@ static void event_loop(void) { case SDL_MOUSEBUTTONUP: input_manager_process_mouse_button(&input_manager, &event.button); break; + case SDL_DROPFILE: + server_install(&server, event.drop.file); + break; } } } diff --git a/app/src/server.c b/app/src/server.c index 745a785d..416d6082 100644 --- a/app/src/server.c +++ b/app/src/server.c @@ -145,6 +145,11 @@ void server_init(struct server *server) { *server = (struct server) SERVER_INITIALIZER; } +SDL_bool server_install(struct server *server, const char* apk_path) { + process_t process = adb_install(server->serial, apk_path, DEVICE_SERVER_PATH); + return process_check_success(process, "adb install"); +} + SDL_bool server_start(struct server *server, const char *serial, Uint16 local_port, Uint16 max_size, Uint32 bit_rate) { server->local_port = local_port; diff --git a/app/src/server.h b/app/src/server.h index 13541457..796820fc 100644 --- a/app/src/server.h +++ b/app/src/server.h @@ -33,6 +33,9 @@ void server_init(struct server *server); SDL_bool server_start(struct server *server, const char *serial, Uint16 local_port, Uint16 max_size, Uint32 bit_rate); +// install an apk file located to apk_path +SDL_bool server_install(struct server *server, const char* apk_path); + // block until the communication with the server is established socket_t server_connect_to(struct server *server);