-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround Go issue causing the app to crash on older Android versions
* Fix app crashes when using Go > 1.23 and Android < 12 * See golang/go#70508
- Loading branch information
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include <android/log.h> | ||
#include <jni.h> | ||
|
||
#include <csignal> | ||
|
||
#define ST_LIB_LOG_TAG "SyncthingLibrary" | ||
#define ST_LIB_LOG_INF(...) __android_log_print(ANDROID_LOG_INFO, ST_LIB_LOG_TAG, __VA_ARGS__) | ||
|
||
static void handleSigsys(int signum, siginfo_t *info, void *context) | ||
{ | ||
// ignore the signal to prevent the app from crashing | ||
ST_LIB_LOG_INF("SIGSYS signal received and ignored"); | ||
} | ||
|
||
static void initSigsysHandler() | ||
{ | ||
struct sigaction sa; | ||
sa.sa_flags = SA_SIGINFO; | ||
sa.sa_sigaction = handleSigsys; | ||
sigemptyset(&sa.sa_mask); | ||
if (sigaction(SIGSYS, &sa, nullptr) == -1) { | ||
ST_LIB_LOG_INF("Failed to set up SIGSYS handler"); | ||
} else { | ||
ST_LIB_LOG_INF("SIGSYS handler set up successfully"); | ||
} | ||
} | ||
|
||
extern "C" { | ||
|
||
JNIEXPORT void JNICALL | ||
Java_io_github_martchus_syncthingtray_Activity_initSigsysHandler(JNIEnv *env, jobject thiz) | ||
{ | ||
initSigsysHandler(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters