Make a stupid thing about the glue less stupid.
There is no reason to make the app developer delete the glue. Seriously. Change-Id: Ic6a93ba17b44889783b35a2a0a2b67ffcd647f47
This commit is contained in:
@@ -29,18 +29,6 @@
|
|||||||
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "threaded_app", __VA_ARGS__))
|
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "threaded_app", __VA_ARGS__))
|
||||||
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "threaded_app", __VA_ARGS__))
|
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "threaded_app", __VA_ARGS__))
|
||||||
|
|
||||||
void android_app_destroy(struct android_app* android_app) {
|
|
||||||
LOGI("android_app_destroy!");
|
|
||||||
pthread_mutex_lock(&android_app->mutex);
|
|
||||||
if (android_app->inputQueue != NULL) {
|
|
||||||
AInputQueue_detachLooper(android_app->inputQueue);
|
|
||||||
}
|
|
||||||
android_app->destroyed = 1;
|
|
||||||
pthread_cond_broadcast(&android_app->cond);
|
|
||||||
pthread_mutex_unlock(&android_app->mutex);
|
|
||||||
// Can't touch android_app object after this.
|
|
||||||
}
|
|
||||||
|
|
||||||
int8_t android_app_read_cmd(struct android_app* android_app) {
|
int8_t android_app_read_cmd(struct android_app* android_app) {
|
||||||
int8_t cmd;
|
int8_t cmd;
|
||||||
if (read(android_app->msgread, &cmd, sizeof(cmd)) == sizeof(cmd)) {
|
if (read(android_app->msgread, &cmd, sizeof(cmd)) == sizeof(cmd)) {
|
||||||
@@ -97,6 +85,18 @@ int32_t android_app_exec_cmd(struct android_app* android_app, int8_t cmd) {
|
|||||||
return android_app->destroyRequested ? 0 : 1;
|
return android_app->destroyRequested ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void android_app_destroy(struct android_app* android_app) {
|
||||||
|
LOGI("android_app_destroy!");
|
||||||
|
pthread_mutex_lock(&android_app->mutex);
|
||||||
|
if (android_app->inputQueue != NULL) {
|
||||||
|
AInputQueue_detachLooper(android_app->inputQueue);
|
||||||
|
}
|
||||||
|
android_app->destroyed = 1;
|
||||||
|
pthread_cond_broadcast(&android_app->cond);
|
||||||
|
pthread_mutex_unlock(&android_app->mutex);
|
||||||
|
// Can't touch android_app object after this.
|
||||||
|
}
|
||||||
|
|
||||||
static void* android_app_entry(void* param) {
|
static void* android_app_entry(void* param) {
|
||||||
struct android_app* android_app = (struct android_app*)param;
|
struct android_app* android_app = (struct android_app*)param;
|
||||||
|
|
||||||
@@ -110,6 +110,8 @@ static void* android_app_entry(void* param) {
|
|||||||
pthread_mutex_unlock(&android_app->mutex);
|
pthread_mutex_unlock(&android_app->mutex);
|
||||||
|
|
||||||
android_main(android_app);
|
android_main(android_app);
|
||||||
|
|
||||||
|
android_app_destroy(android_app);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -143,12 +143,6 @@ enum {
|
|||||||
APP_CMD_DESTROY,
|
APP_CMD_DESTROY,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Call if android_app->destroyRequested is non-zero. Upon return, the
|
|
||||||
* android_app structure is no longer valid and must not be touched.
|
|
||||||
*/
|
|
||||||
void android_app_destroy(struct android_app* android_app);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call when ALooper_pollAll() returns LOOPER_ID_MAIN, reading the next
|
* Call when ALooper_pollAll() returns LOOPER_ID_MAIN, reading the next
|
||||||
* app command message.
|
* app command message.
|
||||||
|
|||||||
Reference in New Issue
Block a user