From 7fdbac197d6cc1c75ef3a5375e9d8a977d3a49d7 Mon Sep 17 00:00:00 2001 From: androidacy-user Date: Wed, 20 Sep 2023 18:57:20 -0400 Subject: [PATCH] replace debug log checks Signed-off-by: androidacy-user --- .../kotlin/com/fox2code/mmm/MainActivity.kt | 1 - .../mmm/installer/InstallerInitializer.kt | 23 ++++++++----------- .../mmm/module/ModuleViewListBuilder.kt | 5 ++-- .../com/fox2code/mmm/utils/RuntimeUtils.kt | 4 ++-- .../com/fox2code/mmm/utils/ZipFileOpener.kt | 4 ++-- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/app/src/main/kotlin/com/fox2code/mmm/MainActivity.kt b/app/src/main/kotlin/com/fox2code/mmm/MainActivity.kt index c2355f0..42d090f 100644 --- a/app/src/main/kotlin/com/fox2code/mmm/MainActivity.kt +++ b/app/src/main/kotlin/com/fox2code/mmm/MainActivity.kt @@ -620,7 +620,6 @@ class MainActivity : AppCompatActivity(), OnRefreshListener, OverScrollHelper { fun commonNext() { if (BuildConfig.DEBUG) { - if (MainApplication.forceDebugLogging) Timber.d("Common next") moduleViewListBuilder.addNotification(NotificationType.DEBUG) } NotificationType.NO_INTERNET.autoAdd(moduleViewListBuilderOnline) 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 392e20e..5ac908e 100644 --- a/app/src/main/kotlin/com/fox2code/mmm/installer/InstallerInitializer.kt +++ b/app/src/main/kotlin/com/fox2code/mmm/installer/InstallerInitializer.kt @@ -4,7 +4,6 @@ package com.fox2code.mmm.installer -import com.fox2code.mmm.BuildConfig import com.fox2code.mmm.Constants import com.fox2code.mmm.MainApplication import com.fox2code.mmm.NotificationType @@ -134,8 +133,8 @@ class InstallerInitializer { "su -V", ).to(output).exec().isSuccess ) { - if (BuildConfig.DEBUG) { - if (MainApplication.forceDebugLogging) Timber.i("Failed to search for ramdisk") + if (MainApplication.forceDebugLogging) { + Timber.i("Failed to search for ramdisk") } if (output.size != 0) { hsRmdsk = "false" == output[0] || "true".equals( @@ -145,8 +144,8 @@ class InstallerInitializer { Companion.hsRmdsk = hsRmdsk return null } - if (BuildConfig.DEBUG) { - if (MainApplication.forceDebugLogging) Timber.i("Found ramdisk: %s", output[0]) + if (MainApplication.forceDebugLogging) { + Timber.i("Found ramdisk: %s", output[0]) if (MainApplication.forceDebugLogging) Timber.i("Searching for Magisk path. Current path: %s", mgskPth) } // reset output @@ -156,8 +155,8 @@ class InstallerInitializer { "not found" )) { mgskPth = output[0] - if (BuildConfig.DEBUG) { - if (MainApplication.forceDebugLogging) Timber.i("Magisk path 1: %s", mgskPth) + if (MainApplication.forceDebugLogging) { + Timber.i("Magisk path 1: %s", mgskPth) } } else if (Shell.cmd("if [ -d /data/adb/ksu ]; then echo true; else echo false; fi", "su -V").to( output @@ -167,8 +166,8 @@ class InstallerInitializer { val suVer: ArrayList = ArrayList() Shell.cmd("su -v").to(suVer).exec() if (suVer.size > 0 && suVer[0].contains("ksu") || suVer[0].contains("Kernelsu", true)) { - if (BuildConfig.DEBUG) { - if (MainApplication.forceDebugLogging) Timber.i("Kernelsu detected") + if (MainApplication.forceDebugLogging) { + Timber.i("Kernelsu detected") } mgskPth = "/data/adb" isKsu = true @@ -177,14 +176,12 @@ class InstallerInitializer { Countly.sharedInstance().crashes().addCrashBreadcrumb("ksu detected") } } else { - if (BuildConfig.DEBUG) { - Timber.e("[ANOMALY] Kernelsu not detected but /data/adb/ksu exists") + if (MainApplication.forceDebugLogging) { Timber.e("[ANOMALY] Kernelsu not detected but /data/adb/ksu exists") } return null } } else { - if (BuildConfig.DEBUG) { - Timber.e("Failed to get Magisk path") + if (MainApplication.forceDebugLogging) { Timber.e("Failed to get Magisk path") } return null } diff --git a/app/src/main/kotlin/com/fox2code/mmm/module/ModuleViewListBuilder.kt b/app/src/main/kotlin/com/fox2code/mmm/module/ModuleViewListBuilder.kt index 25596af..76ae39d 100644 --- a/app/src/main/kotlin/com/fox2code/mmm/module/ModuleViewListBuilder.kt +++ b/app/src/main/kotlin/com/fox2code/mmm/module/ModuleViewListBuilder.kt @@ -11,7 +11,6 @@ import android.os.Looper import android.view.View import androidx.recyclerview.widget.RecyclerView import com.fox2code.mmm.AppUpdateManager -import com.fox2code.mmm.BuildConfig import com.fox2code.mmm.MainActivity import com.fox2code.mmm.MainApplication import com.fox2code.mmm.NotificationType @@ -73,8 +72,8 @@ class ModuleViewListBuilder(private val activity: Activity) { } fun appendRemoteModules() { - if (BuildConfig.DEBUG) { - if (MainApplication.forceDebugLogging) Timber.i("appendRemoteModules() called") + if (MainApplication.forceDebugLogging) { + Timber.i("appendRemoteModules() called") } synchronized(updateLock) { if (MainApplication.forceDebugLogging) Timber.i("appendRemoteModules() started") diff --git a/app/src/main/kotlin/com/fox2code/mmm/utils/RuntimeUtils.kt b/app/src/main/kotlin/com/fox2code/mmm/utils/RuntimeUtils.kt index 84871fd..2bbb3b2 100644 --- a/app/src/main/kotlin/com/fox2code/mmm/utils/RuntimeUtils.kt +++ b/app/src/main/kotlin/com/fox2code/mmm/utils/RuntimeUtils.kt @@ -166,8 +166,8 @@ class RuntimeUtils { // Restarting setup firstLaunch = false } - if (BuildConfig.DEBUG) { - if (MainApplication.forceDebugLogging) Timber.i( + if (MainApplication.forceDebugLogging) { + Timber.i( "First launch: %s, pref value: %s", firstLaunch, prefs.getString("last_shown_setup", null) diff --git a/app/src/main/kotlin/com/fox2code/mmm/utils/ZipFileOpener.kt b/app/src/main/kotlin/com/fox2code/mmm/utils/ZipFileOpener.kt index ec118fd..79cc840 100644 --- a/app/src/main/kotlin/com/fox2code/mmm/utils/ZipFileOpener.kt +++ b/app/src/main/kotlin/com/fox2code/mmm/utils/ZipFileOpener.kt @@ -120,8 +120,8 @@ class ZipFileOpener : AppCompatActivity() { zip = ZipFile(zipFile) if (zip.getEntry("module.prop").also { entry = it } == null) { Timber.e("onCreate: Zip file is not a valid magisk module") - if (BuildConfig.DEBUG) { - if (MainApplication.forceDebugLogging) Timber.d( + if (MainApplication.forceDebugLogging) { + Timber.d( "onCreate: Zip file contents: %s", zip.stream().map { obj: ZipEntry -> obj.name } .reduce { a: String, b: String -> "$a, $b" }.orElse("empty")