mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-04-20 03:25:03 +00:00
try to terminate adb install command properly
This commit is contained in:
parent
ec95645950
commit
43cbb9e786
2 changed files with 20 additions and 7 deletions
|
@ -5,6 +5,7 @@
|
|||
#include "command.h"
|
||||
#include "string.h"
|
||||
|
||||
|
||||
// NOTE(adopi) this can be more generic:
|
||||
// it could be used with a command queue instead of a filename queue
|
||||
// then we would have a generic invoker (useful if we want to handle more async commands)
|
||||
|
@ -83,6 +84,7 @@ void installer_destroy(struct installer *installer) {
|
|||
SDL_free((void *) installer->serial);
|
||||
installer->initialized = SDL_FALSE;
|
||||
installer->stopped = SDL_FALSE;
|
||||
installer->current_process = PROCESS_NONE;
|
||||
}
|
||||
|
||||
SDL_bool installer_push_apk(struct installer *installer, const char* apk) {
|
||||
|
@ -100,6 +102,7 @@ SDL_bool installer_push_apk(struct installer *installer, const char* apk) {
|
|||
static SDL_bool process_install(struct installer *installer, const char* filename) {
|
||||
LOGI("%s will be installed",filename);
|
||||
process_t process = adb_install(installer->serial, filename);
|
||||
installer->current_process = process;
|
||||
return process_check_success(process, "adb install");
|
||||
}
|
||||
|
||||
|
@ -143,6 +146,13 @@ void installer_stop(struct installer *installer) {
|
|||
mutex_lock(installer->mutex);
|
||||
installer->stopped = SDL_TRUE;
|
||||
cond_signal(installer->event_cond);
|
||||
if (installer->current_process == PROCESS_NONE) {
|
||||
if (!cmd_terminate(installer->current_process)) {
|
||||
LOGW("Cannot terminate install process");
|
||||
}
|
||||
cmd_simple_wait(installer->current_process, NULL);
|
||||
installer->current_process = PROCESS_NONE;
|
||||
}
|
||||
mutex_unlock(installer->mutex);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <SDL2/SDL_mutex.h>
|
||||
#include <SDL2/SDL_stdinc.h>
|
||||
#include <SDL2/SDL_thread.h>
|
||||
#include "command.h"
|
||||
|
||||
// NOTE(AdoPi) apk_queue and control_event can use a generic queue
|
||||
|
||||
|
@ -26,16 +27,18 @@ struct installer {
|
|||
SDL_cond *event_cond;
|
||||
SDL_bool stopped;
|
||||
SDL_bool initialized;
|
||||
process_t current_process;
|
||||
struct apk_queue queue;
|
||||
};
|
||||
|
||||
#define INSTALLER_INITIALIZER { \
|
||||
.serial = NULL, \
|
||||
.thread = NULL, \
|
||||
.mutex = NULL, \
|
||||
.event_cond = NULL, \
|
||||
.stopped = SDL_FALSE, \
|
||||
.initialized = SDL_FALSE \
|
||||
#define INSTALLER_INITIALIZER { \
|
||||
.serial = NULL, \
|
||||
.thread = NULL, \
|
||||
.mutex = NULL, \
|
||||
.event_cond = NULL, \
|
||||
.stopped = SDL_FALSE, \
|
||||
.initialized = SDL_FALSE, \
|
||||
.current_process = PROCESS_NONE \
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue