Skip to content

Commit

Permalink
Template JingMatrix#3
Browse files Browse the repository at this point in the history
  • Loading branch information
privacyguy123 committed Sep 25, 2024
1 parent 9d6368c commit 44e3e57
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
11 changes: 6 additions & 5 deletions daemon/src/main/java/org/lsposed/lspd/service/LogcatService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<File, Object> {
private static final int MAX_ENTRIES = 10;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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) {
Expand Down
14 changes: 14 additions & 0 deletions daemon/src/main/jni/logcat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 44e3e57

Please sign in to comment.