Skip to content

Commit 1ca5f13

Browse files
committed
android_native_app_glue: expose helpers for attaching input queue to looper
1 parent eda89d0 commit 1ca5f13

File tree

6 files changed

+45
-5
lines changed

6 files changed

+45
-5
lines changed

android-activity/native-activity-csrc/native-activity/native_app_glue/android_native_app_glue.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,33 @@ static void print_cur_config(struct android_app* android_app) {
8686
AConfiguration_getUiModeNight(android_app->config));
8787
}
8888

89+
void android_app_attach_input_queue_looper(struct android_app* android_app) {
90+
if (android_app->inputQueue != NULL) {
91+
LOGV("Attaching input queue to looper");
92+
AInputQueue_attachLooper(android_app->inputQueue,
93+
android_app->looper, LOOPER_ID_INPUT, NULL,
94+
&android_app->inputPollSource);
95+
}
96+
}
97+
98+
void android_app_detach_input_queue_looper(struct android_app* android_app) {
99+
if (android_app->inputQueue != NULL) {
100+
LOGV("Detaching input queue from looper");
101+
AInputQueue_detachLooper(android_app->inputQueue);
102+
}
103+
}
104+
89105
void android_app_pre_exec_cmd(struct android_app* android_app, int8_t cmd) {
90106
switch (cmd) {
91107
case APP_CMD_INPUT_CHANGED:
92108
LOGV("APP_CMD_INPUT_CHANGED\n");
93109
pthread_mutex_lock(&android_app->mutex);
94110
if (android_app->inputQueue != NULL) {
95-
//AInputQueue_detachLooper(android_app->inputQueue);
111+
android_app_detach_input_queue_looper(android_app);
96112
}
97113
android_app->inputQueue = android_app->pendingInputQueue;
98114
if (android_app->inputQueue != NULL) {
99-
//LOGV("Attaching input queue to looper");
100-
//AInputQueue_attachLooper(android_app->inputQueue,
101-
// android_app->looper, LOOPER_ID_INPUT, NULL,
102-
// &android_app->inputPollSource);
115+
android_app_attach_input_queue_looper(android_app);
103116
}
104117
pthread_cond_broadcast(&android_app->cond);
105118
pthread_mutex_unlock(&android_app->mutex);

android-activity/native-activity-csrc/native-activity/native_app_glue/android_native_app_glue.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,9 @@ void android_app_pre_exec_cmd(struct android_app* android_app, int8_t cmd);
331331
*/
332332
void android_app_post_exec_cmd(struct android_app* android_app, int8_t cmd);
333333

334+
void android_app_attach_input_queue_looper(struct android_app* android_app);
335+
void android_app_detach_input_queue_looper(struct android_app* android_app);
336+
334337
/**
335338
* Dummy function that used to be used to prevent the linker from stripping app
336339
* glue code. No longer necessary, since __attribute__((visibility("default")))

android-activity/src/native_activity/ffi_aarch64.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7148,6 +7148,12 @@ extern "C" {
71487148
#[doc = " actions for the command before calling this function."]
71497149
pub fn android_app_post_exec_cmd(android_app: *mut android_app, cmd: i8);
71507150
}
7151+
extern "C" {
7152+
pub fn android_app_attach_input_queue_looper(android_app: *mut android_app);
7153+
}
7154+
extern "C" {
7155+
pub fn android_app_detach_input_queue_looper(android_app: *mut android_app);
7156+
}
71517157
extern "C" {
71527158
#[doc = " Dummy function that used to be used to prevent the linker from stripping app"]
71537159
#[doc = " glue code. No longer necessary, since __attribute__((visibility(\"default\")))"]

android-activity/src/native_activity/ffi_arm.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7617,6 +7617,12 @@ extern "C" {
76177617
#[doc = " actions for the command before calling this function."]
76187618
pub fn android_app_post_exec_cmd(android_app: *mut android_app, cmd: i8);
76197619
}
7620+
extern "C" {
7621+
pub fn android_app_attach_input_queue_looper(android_app: *mut android_app);
7622+
}
7623+
extern "C" {
7624+
pub fn android_app_detach_input_queue_looper(android_app: *mut android_app);
7625+
}
76207626
extern "C" {
76217627
#[doc = " Dummy function that used to be used to prevent the linker from stripping app"]
76227628
#[doc = " glue code. No longer necessary, since __attribute__((visibility(\"default\")))"]

android-activity/src/native_activity/ffi_i686.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9362,6 +9362,12 @@ extern "C" {
93629362
#[doc = " actions for the command before calling this function."]
93639363
pub fn android_app_post_exec_cmd(android_app: *mut android_app, cmd: i8);
93649364
}
9365+
extern "C" {
9366+
pub fn android_app_attach_input_queue_looper(android_app: *mut android_app);
9367+
}
9368+
extern "C" {
9369+
pub fn android_app_detach_input_queue_looper(android_app: *mut android_app);
9370+
}
93659371
extern "C" {
93669372
#[doc = " Dummy function that used to be used to prevent the linker from stripping app"]
93679373
#[doc = " glue code. No longer necessary, since __attribute__((visibility(\"default\")))"]

android-activity/src/native_activity/ffi_x86_64.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9391,6 +9391,12 @@ extern "C" {
93919391
#[doc = " actions for the command before calling this function."]
93929392
pub fn android_app_post_exec_cmd(android_app: *mut android_app, cmd: i8);
93939393
}
9394+
extern "C" {
9395+
pub fn android_app_attach_input_queue_looper(android_app: *mut android_app);
9396+
}
9397+
extern "C" {
9398+
pub fn android_app_detach_input_queue_looper(android_app: *mut android_app);
9399+
}
93949400
extern "C" {
93959401
#[doc = " Dummy function that used to be used to prevent the linker from stripping app"]
93969402
#[doc = " glue code. No longer necessary, since __attribute__((visibility(\"default\")))"]

0 commit comments

Comments
 (0)