Merge "ndk: Fix potential event handling issue in android_native_app_glue"
This commit is contained in:
@@ -186,15 +186,18 @@ static void android_app_destroy(struct android_app* android_app) {
|
|||||||
|
|
||||||
static void process_input(struct android_app* app, struct android_poll_source* source) {
|
static void process_input(struct android_app* app, struct android_poll_source* source) {
|
||||||
AInputEvent* event = NULL;
|
AInputEvent* event = NULL;
|
||||||
if (AInputQueue_getEvent(app->inputQueue, &event) >= 0) {
|
int processed = 0;
|
||||||
|
while (AInputQueue_getEvent(app->inputQueue, &event) >= 0) {
|
||||||
LOGV("New input event: type=%d\n", AInputEvent_getType(event));
|
LOGV("New input event: type=%d\n", AInputEvent_getType(event));
|
||||||
if (AInputQueue_preDispatchEvent(app->inputQueue, event)) {
|
if (AInputQueue_preDispatchEvent(app->inputQueue, event)) {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
int32_t handled = 0;
|
int32_t handled = 0;
|
||||||
if (app->onInputEvent != NULL) handled = app->onInputEvent(app, event);
|
if (app->onInputEvent != NULL) handled = app->onInputEvent(app, event);
|
||||||
AInputQueue_finishEvent(app->inputQueue, event, handled);
|
AInputQueue_finishEvent(app->inputQueue, event, handled);
|
||||||
} else {
|
processed = 1;
|
||||||
|
}
|
||||||
|
if (processed == 0) {
|
||||||
LOGE("Failure reading next input event: %s\n", strerror(errno));
|
LOGE("Failure reading next input event: %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user