From 44e3e57f2e12d26b6d32fa42fc41cb96c857a704 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 25 Sep 2024 12:32:00 +0100 Subject: [PATCH] Template #3 --- .../org/lsposed/lspd/service/LogcatService.java | 11 ++++++----- daemon/src/main/jni/logcat.cpp | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/daemon/src/main/java/org/lsposed/lspd/service/LogcatService.java b/daemon/src/main/java/org/lsposed/lspd/service/LogcatService.java index 05fd25ebbc1..4bdbf66c6cc 100644 --- a/daemon/src/main/java/org/lsposed/lspd/service/LogcatService.java +++ b/daemon/src/main/java/org/lsposed/lspd/service/LogcatService.java @@ -27,6 +27,8 @@ public class LogcatService implements Runnable { private int modulesFd = -1; private int verboseFd = -1; private Thread thread = null; + private native void nativeEnableLogs(); + private native void nativeDisableLogs(); static class LogLRU extends LinkedHashMap { private static final int MAX_ENTRIES = 10; @@ -96,9 +98,6 @@ private static void dmesg() { @Override public void run() { - // if (ConfigManager.getInstance().isDisableLogsEnabled()) { - // return; // Skip logcat if logging is disabled - // } Log.i(TAG, "start running"); runLogcat(); Log.i(TAG, "stopped"); @@ -194,11 +193,13 @@ public void disableWatchdog() { } public void disableLogs() { - ConfigManager.getInstance().setDisableLogs(true); // Disable logging in config + ConfigManager.getInstance().setDisableLogs(true); + nativeDisableLogs(); } public void enableLogs() { - ConfigManager.getInstance().setDisableLogs(false); // Enable logging in config + ConfigManager.getInstance().setDisableLogs(false); + nativeEnableLogs(); } public void refresh(boolean isVerboseLog) { diff --git a/daemon/src/main/jni/logcat.cpp b/daemon/src/main/jni/logcat.cpp index 3a893e66d04..486a4840644 100644 --- a/daemon/src/main/jni/logcat.cpp +++ b/daemon/src/main/jni/logcat.cpp @@ -343,3 +343,17 @@ Java_org_lsposed_lspd_service_LogcatService_runLogcat(JNIEnv *env, jobject thiz) Logcat logcat(env, thiz, method); logcat.Run(); } + +extern "C" +JNIEXPORT void JNICALL +// NOLINTNEXTLINE +Java_org_lsposed_lspd_service_LogcatService_nativeDisableLogs(JNIEnv *env, jobject thiz) { + disable_logs.store(true); // Set atomic to true to disable logs +} + +extern "C" +JNIEXPORT void JNICALL +// NOLINTNEXTLINE +Java_org_lsposed_lspd_service_LogcatService_nativeEnableLogs(JNIEnv *env, jobject thiz) { + disable_logs.store(false); // Set atomic to false to enable logs +}