From fba56a99273a29b6c17811f3edc09f08e515c665 Mon Sep 17 00:00:00 2001 From: JingMatrix Date: Tue, 24 Dec 2024 01:45:19 +0100 Subject: [PATCH] Adjust debugging settings 1. Set log buffer size for system 2. Increase buffer size to 128 Kb 3. Record also logs for APatch, KernelSU and SELinux 4. Add installation tasks for APatch --- daemon/src/main/jni/logcat.cpp | 37 ++++++++++++++++++++-------------- magisk-loader/build.gradle.kts | 13 ++++++++++++ 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/daemon/src/main/jni/logcat.cpp b/daemon/src/main/jni/logcat.cpp index b5a5b715617..32f4d69c8cd 100644 --- a/daemon/src/main/jni/logcat.cpp +++ b/daemon/src/main/jni/logcat.cpp @@ -15,7 +15,7 @@ using namespace std::string_view_literals; using namespace std::chrono_literals; constexpr size_t kMaxLogSize = 4 * 1024 * 1024; -constexpr long kLogBufferSize = 64 * 1024; +constexpr long kLogBufferSize = 128 * 1024; namespace { constexpr std::array kLogChar = { @@ -225,10 +225,11 @@ void Logcat::ProcessBuffer(struct log_msg *buf) { modules_print_count_ += PrintLogLine(entry, modules_file_.get()); shortcut = true; } - if (verbose_ && - (shortcut || buf->id() == log_id::LOG_ID_CRASH || entry.pid == my_pid_ || - tag == "Dobby"sv || tag == "Magisk"sv || tag == "LSPlant"sv || tag == "LSPlt"sv || - tag.starts_with("LSPosed"sv) || tag.starts_with("zygisk"sv))) [[unlikely]] { + if (verbose_ && (shortcut || buf->id() == log_id::LOG_ID_CRASH || entry.pid == my_pid_ || + tag == "APatchD"sv || tag == "Dobby"sv || tag == "KernelSU"sv || + tag == "LSPlant"sv || tag == "LSPlt"sv || tag.starts_with("LSPosed"sv) || + tag == "Magisk"sv || tag == "SELinux"sv || tag.starts_with("zygisk"sv))) + [[unlikely]] { verbose_print_count_ += PrintLogLine(entry, verbose_file_.get()); } if (entry.pid == my_pid_ && tag == "LSPosedLogcat"sv) [[unlikely]] { @@ -250,8 +251,9 @@ void Logcat::ProcessBuffer(struct log_msg *buf) { enable_watchdog = false; enable_watchdog.notify_one(); std::system("resetprop -p --delete persist.logd.size"); - std::system("resetprop -p --delete persist.logd.size.main"); std::system("resetprop -p --delete persist.logd.size.crash"); + std::system("resetprop -p --delete persist.logd.size.main"); + std::system("resetprop -p --delete persist.logd.size.system"); // Terminate the watchdog thread by exiting __system_property_wait firs firstt std::system("setprop persist.log.tag V"); @@ -263,8 +265,9 @@ void Logcat::ProcessBuffer(struct log_msg *buf) { void Logcat::StartLogWatchDog() { constexpr static auto kLogdSizeProp = "persist.logd.size"sv; constexpr static auto kLogdTagProp = "persist.log.tag"sv; - constexpr static auto kLogdMainSizeProp = "persist.logd.size.main"sv; constexpr static auto kLogdCrashSizeProp = "persist.logd.size.crash"sv; + constexpr static auto kLogdMainSizeProp = "persist.logd.size.main"sv; + constexpr static auto kLogdSystemSizeProp = "persist.logd.size.system"sv; constexpr static long kErr = -1; std::thread watchdog([this] { Log("[LogWatchDog started]\n"); @@ -272,19 +275,23 @@ void Logcat::StartLogWatchDog() { enable_watchdog.wait(false); // Blocking current thread until enable_watchdog is true; auto logd_size = GetByteProp(kLogdSizeProp); auto logd_tag = GetStrProp(kLogdTagProp); - auto logd_main_size = GetByteProp(kLogdMainSizeProp); auto logd_crash_size = GetByteProp(kLogdCrashSizeProp); + auto logd_main_size = GetByteProp(kLogdMainSizeProp); + auto logd_system_size = GetByteProp(kLogdSystemSizeProp); Log("[LogWatchDog running] log.tag: " + logd_tag + - "; logd.[default, main, crash].size: [" + std::to_string(logd_size) + "," + - std::to_string(logd_main_size) + "," + std::to_string(logd_crash_size) + "]\n"); + "; logd.[default, crash, main, system].size: [" + std::to_string(logd_size) + "," + + std::to_string(logd_crash_size) + "," + std::to_string(logd_main_size) + "," + + std::to_string(logd_system_size) + "]\n"); if (!logd_tag.empty() || - !((logd_main_size == kErr && logd_crash_size == kErr && logd_size != kErr && - logd_size >= kLogBufferSize) || - (logd_main_size != kErr && logd_main_size >= kLogBufferSize && - logd_crash_size != kErr && logd_crash_size >= kLogBufferSize))) { + !((logd_crash_size == kErr && logd_main_size == kErr && logd_system_size == kErr && + logd_size != kErr && logd_size >= kLogBufferSize) || + (logd_crash_size != kErr && logd_crash_size >= kLogBufferSize && + logd_main_size != kErr && logd_main_size >= kLogBufferSize && + logd_system_size != kErr && logd_system_size >= kLogBufferSize))) { SetIntProp(kLogdSizeProp, std::max(kLogBufferSize, logd_size)); - SetIntProp(kLogdMainSizeProp, std::max(kLogBufferSize, logd_main_size)); SetIntProp(kLogdCrashSizeProp, std::max(kLogBufferSize, logd_crash_size)); + SetIntProp(kLogdMainSizeProp, std::max(kLogBufferSize, logd_main_size)); + SetIntProp(kLogdSystemSizeProp, std::max(kLogBufferSize, logd_system_size)); SetStrProp(kLogdTagProp, ""); SetStrProp("ctl.start", "logd-reinit"); } diff --git a/magisk-loader/build.gradle.kts b/magisk-loader/build.gradle.kts index 940c30c598d..cf3d0570782 100644 --- a/magisk-loader/build.gradle.kts +++ b/magisk-loader/build.gradle.kts @@ -296,6 +296,19 @@ fun afterEval() = android.applicationVariants.forEach { variant -> dependsOn(flashKsuTask) commandLine(adb, "shell", "su", "-c", "/system/bin/svc", "power", "reboot") } + val flashAPatchTask = task("flashAPatch${variantCapped}") { + group = "LSPosed" + dependsOn(pushTask) + commandLine( + adb, "shell", "su", "-c", + "apd module install /data/local/tmp/${zipFileName}" + ) + } + task("flashAPatchAndReboot${variantCapped}") { + group = "LSPosed" + dependsOn(flashAPatchTask) + commandLine(adb, "shell", "su", "-c", "/system/bin/svc", "power", "reboot") + } } afterEvaluate {