From 1a9da5d54a776e34f5a2e4aa72fc482dc65384a8 Mon Sep 17 00:00:00 2001 From: androidacy-user Date: Sun, 10 Sep 2023 21:48:22 -0400 Subject: [PATCH] fix ksu detection Signed-off-by: androidacy-user --- .../mmm/installer/InstallerInitializer.kt | 2 +- .../com/fox2code/mmm/utils/sentry/SentryMain.kt | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/fox2code/mmm/installer/InstallerInitializer.kt b/app/src/main/kotlin/com/fox2code/mmm/installer/InstallerInitializer.kt index 5bfbe5d..ee0f6a1 100644 --- a/app/src/main/kotlin/com/fox2code/mmm/installer/InstallerInitializer.kt +++ b/app/src/main/kotlin/com/fox2code/mmm/installer/InstallerInitializer.kt @@ -162,7 +162,7 @@ class InstallerInitializer { if (BuildConfig.DEBUG) { Timber.i("Magisk path 1: %s", mgskPth) } - } else if (Shell.cmd("if [ -f /data/adb/ksu ]; then echo true; else echo false; fi").to( + } else if (Shell.cmd("if [ -d /data/adb/ksu ] && [ -f /data/adb/ksud ]; then echo true; else echo false; fi", "su -V").to( output ).exec().isSuccess && "true" == output[0] ) { diff --git a/app/src/main/kotlin/com/fox2code/mmm/utils/sentry/SentryMain.kt b/app/src/main/kotlin/com/fox2code/mmm/utils/sentry/SentryMain.kt index 34b1fde..86d3465 100644 --- a/app/src/main/kotlin/com/fox2code/mmm/utils/sentry/SentryMain.kt +++ b/app/src/main/kotlin/com/fox2code/mmm/utils/sentry/SentryMain.kt @@ -14,6 +14,7 @@ import com.fox2code.mmm.CrashHandler import com.fox2code.mmm.MainApplication import com.fox2code.mmm.androidacy.AndroidacyUtil.Companion.hideToken import com.fox2code.mmm.androidacy.AndroidacyUtil.Companion.isAndroidacyLink +import com.fox2code.mmm.utils.io.net.HttpException import io.sentry.Breadcrumb import io.sentry.Hint import io.sentry.Sentry @@ -129,16 +130,26 @@ object SentryMain { return@BeforeSendCallback null } crashExceptionId = event?.eventId - // if debug build, log everything, but for release only log warnings and errors + // if debug build, log everything, but for release only log errors if (!BuildConfig.DEBUG) { - if (event?.level == SentryLevel.DEBUG || event?.level == SentryLevel.INFO) { + if (event?.level == SentryLevel.DEBUG || event?.level == SentryLevel.INFO || event?.level == SentryLevel.WARNING) { return@BeforeSendCallback null } } // remove all failed to fetch data messages - if (event?.message?.message?.contains("Failed to fetch") == true) { + if (event?.message?.message?.contains("Failed to fetch") == true || event?.message?.message?.contains("Failed to load") == true) { return@BeforeSendCallback null } + // for httpexception, do not send if error is 401, 403, 404, 429 + // get exception from event + val exception = event?.throwable ?: return@BeforeSendCallback event + // check status code + if (exception is HttpException) { + if (exception.errorCode in intArrayOf(401, 403, 404, 429)) { + return@BeforeSendCallback null + } + } + // if exception is null, return event event } // Filter breadcrumb content from crash report.