android_native_app_glue: expose helpers for attaching input queue to looper

This commit is contained in:
Robert Bragg
2022-07-06 15:17:33 +01:00
parent eda89d0e15
commit 1ca5f13874
6 changed files with 45 additions and 5 deletions
@@ -86,20 +86,33 @@ static void print_cur_config(struct android_app* android_app) {
AConfiguration_getUiModeNight(android_app->config));
}
void android_app_attach_input_queue_looper(struct android_app* android_app) {
if (android_app->inputQueue != NULL) {
LOGV("Attaching input queue to looper");
AInputQueue_attachLooper(android_app->inputQueue,
android_app->looper, LOOPER_ID_INPUT, NULL,
&android_app->inputPollSource);
}
}
void android_app_detach_input_queue_looper(struct android_app* android_app) {
if (android_app->inputQueue != NULL) {
LOGV("Detaching input queue from looper");
AInputQueue_detachLooper(android_app->inputQueue);
}
}
void android_app_pre_exec_cmd(struct android_app* android_app, int8_t cmd) {
switch (cmd) {
case APP_CMD_INPUT_CHANGED:
LOGV("APP_CMD_INPUT_CHANGED\n");
pthread_mutex_lock(&android_app->mutex);
if (android_app->inputQueue != NULL) {
//AInputQueue_detachLooper(android_app->inputQueue);
android_app_detach_input_queue_looper(android_app);
}
android_app->inputQueue = android_app->pendingInputQueue;
if (android_app->inputQueue != NULL) {
//LOGV("Attaching input queue to looper");
//AInputQueue_attachLooper(android_app->inputQueue,
// android_app->looper, LOOPER_ID_INPUT, NULL,
// &android_app->inputPollSource);
android_app_attach_input_queue_looper(android_app);
}
pthread_cond_broadcast(&android_app->cond);
pthread_mutex_unlock(&android_app->mutex);
@@ -331,6 +331,9 @@ void android_app_pre_exec_cmd(struct android_app* android_app, int8_t cmd);
*/
void android_app_post_exec_cmd(struct android_app* android_app, int8_t cmd);
void android_app_attach_input_queue_looper(struct android_app* android_app);
void android_app_detach_input_queue_looper(struct android_app* android_app);
/**
* Dummy function that used to be used to prevent the linker from stripping app
* glue code. No longer necessary, since __attribute__((visibility("default")))
@@ -7148,6 +7148,12 @@ extern "C" {
#[doc = " actions for the command before calling this function."]
pub fn android_app_post_exec_cmd(android_app: *mut android_app, cmd: i8);
}
extern "C" {
pub fn android_app_attach_input_queue_looper(android_app: *mut android_app);
}
extern "C" {
pub fn android_app_detach_input_queue_looper(android_app: *mut android_app);
}
extern "C" {
#[doc = " Dummy function that used to be used to prevent the linker from stripping app"]
#[doc = " glue code. No longer necessary, since __attribute__((visibility(\"default\")))"]
@@ -7617,6 +7617,12 @@ extern "C" {
#[doc = " actions for the command before calling this function."]
pub fn android_app_post_exec_cmd(android_app: *mut android_app, cmd: i8);
}
extern "C" {
pub fn android_app_attach_input_queue_looper(android_app: *mut android_app);
}
extern "C" {
pub fn android_app_detach_input_queue_looper(android_app: *mut android_app);
}
extern "C" {
#[doc = " Dummy function that used to be used to prevent the linker from stripping app"]
#[doc = " glue code. No longer necessary, since __attribute__((visibility(\"default\")))"]
@@ -9362,6 +9362,12 @@ extern "C" {
#[doc = " actions for the command before calling this function."]
pub fn android_app_post_exec_cmd(android_app: *mut android_app, cmd: i8);
}
extern "C" {
pub fn android_app_attach_input_queue_looper(android_app: *mut android_app);
}
extern "C" {
pub fn android_app_detach_input_queue_looper(android_app: *mut android_app);
}
extern "C" {
#[doc = " Dummy function that used to be used to prevent the linker from stripping app"]
#[doc = " glue code. No longer necessary, since __attribute__((visibility(\"default\")))"]
@@ -9391,6 +9391,12 @@ extern "C" {
#[doc = " actions for the command before calling this function."]
pub fn android_app_post_exec_cmd(android_app: *mut android_app, cmd: i8);
}
extern "C" {
pub fn android_app_attach_input_queue_looper(android_app: *mut android_app);
}
extern "C" {
pub fn android_app_detach_input_queue_looper(android_app: *mut android_app);
}
extern "C" {
#[doc = " Dummy function that used to be used to prevent the linker from stripping app"]
#[doc = " glue code. No longer necessary, since __attribute__((visibility(\"default\")))"]