mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-05 07:39:23 +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 "command.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
|
|
||||||
// NOTE(adopi) this can be more generic:
|
// NOTE(adopi) this can be more generic:
|
||||||
// it could be used with a command queue instead of a filename queue
|
// 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)
|
// 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);
|
SDL_free((void *) installer->serial);
|
||||||
installer->initialized = SDL_FALSE;
|
installer->initialized = SDL_FALSE;
|
||||||
installer->stopped = SDL_FALSE;
|
installer->stopped = SDL_FALSE;
|
||||||
|
installer->current_process = PROCESS_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool installer_push_apk(struct installer *installer, const char* apk) {
|
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) {
|
static SDL_bool process_install(struct installer *installer, const char* filename) {
|
||||||
LOGI("%s will be installed",filename);
|
LOGI("%s will be installed",filename);
|
||||||
process_t process = adb_install(installer->serial, filename);
|
process_t process = adb_install(installer->serial, filename);
|
||||||
|
installer->current_process = process;
|
||||||
return process_check_success(process, "adb install");
|
return process_check_success(process, "adb install");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,6 +146,13 @@ void installer_stop(struct installer *installer) {
|
||||||
mutex_lock(installer->mutex);
|
mutex_lock(installer->mutex);
|
||||||
installer->stopped = SDL_TRUE;
|
installer->stopped = SDL_TRUE;
|
||||||
cond_signal(installer->event_cond);
|
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);
|
mutex_unlock(installer->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <SDL2/SDL_mutex.h>
|
#include <SDL2/SDL_mutex.h>
|
||||||
#include <SDL2/SDL_stdinc.h>
|
#include <SDL2/SDL_stdinc.h>
|
||||||
#include <SDL2/SDL_thread.h>
|
#include <SDL2/SDL_thread.h>
|
||||||
|
#include "command.h"
|
||||||
|
|
||||||
// NOTE(AdoPi) apk_queue and control_event can use a generic queue
|
// NOTE(AdoPi) apk_queue and control_event can use a generic queue
|
||||||
|
|
||||||
|
@ -26,6 +27,7 @@ struct installer {
|
||||||
SDL_cond *event_cond;
|
SDL_cond *event_cond;
|
||||||
SDL_bool stopped;
|
SDL_bool stopped;
|
||||||
SDL_bool initialized;
|
SDL_bool initialized;
|
||||||
|
process_t current_process;
|
||||||
struct apk_queue queue;
|
struct apk_queue queue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,7 +37,8 @@ struct installer {
|
||||||
.mutex = NULL, \
|
.mutex = NULL, \
|
||||||
.event_cond = NULL, \
|
.event_cond = NULL, \
|
||||||
.stopped = SDL_FALSE, \
|
.stopped = SDL_FALSE, \
|
||||||
.initialized = SDL_FALSE \
|
.initialized = SDL_FALSE, \
|
||||||
|
.current_process = PROCESS_NONE \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue