Skip to content

EventReceiver: use Unix domain sockets with socketpair() instead of mkfifo()#580

Open
Frenzie wants to merge 2 commits intokoreader:masterfrom
Frenzie:unix-domain-sockets
Open

EventReceiver: use Unix domain sockets with socketpair() instead of mkfifo()#580
Frenzie wants to merge 2 commits intokoreader:masterfrom
Frenzie:unix-domain-sockets

Conversation

@Frenzie
Copy link
Member

@Frenzie Frenzie commented Feb 11, 2026

mkfifo seems to suffer from SELinux restrictions with unsafe_app, so it can't be used normally. Given that the code is the way it is, it must've been different on older Android versions. As far as I can find, you can't get around it without compiling a custom Android kernel.

This is extremely similar to the approach described in koreader/koreader#14358 (reply in thread), but it seems slightly cleaner.

Without this change events like android.intent.action.ACTION_POWER_CONNECTED don't reach the frontend, but I'm primarily interested in TEXT_INPUT from the IME/onscreen-keyboard.


This change is Reviewable

…kfifo()

mkfifo seems to suffer from SELinux restrictions with unsafe_app, so it can't be used normally. Given that the code is the way it is, it must've been different on older Android versions. As far as I can find, you can't get around it without compiling a custom Android kernel.

This is extremely similar to the approach described in <koreader/koreader#14358 (reply in thread)>, but it seems slightly cleaner.

Without this change events like android.intent.action.ACTION_POWER_CONNECTED don't reach the frontend, but I'm primarily interested in TEXT_INPUT from the IME/onscreen-keyboard.
Comment on lines 515 to 520
JNIEXPORT jint JNICALL
Java_org_koreader_launcher_EventReceiver_nativeGetEventSocketFd(JNIEnv* env, jclass clazz) {
(void)env;
(void)clazz;
return g_event_write_fd;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff looks quite large, but conceptually the only real change is this here, with the associated System.loadLibrary("luajit-launcher") and private external fun nativeGetEventSocketFd(): Int.

@Frenzie
Copy link
Member Author

Frenzie commented Feb 13, 2026

@pazos @hugleo Any thoughts? Since those events don't currently arrive anyway it's a clear improvement in the actually working department, but I'm mildly worried I might be missing something obvious to more Android-attuned people.

@hugleo
Copy link
Contributor

hugleo commented Feb 13, 2026

Did you check the native code to see if it's safer to close the FD so the native code doesn't keep a old reference?

@Frenzie
Copy link
Member Author

Frenzie commented Feb 13, 2026

I'm not sure if I quite understand what you mean. Some potential issue when the program is shutting down?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants