code cleanup

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/89/head
androidacy-user 2 years ago
parent 7fdbac197d
commit 2b62e4dfb3

@ -48,8 +48,8 @@ android {
applicationId = "com.fox2code.mmm"
minSdk = 26
targetSdk = 34
versionCode = 86
versionName = "2.3.2"
versionCode = 87
versionName = "2.3.3"
vectorDrawables {
useSupportLibrary = true
}

@ -163,7 +163,13 @@ class MainActivity : AppCompatActivity(), OnRefreshListener, OverScrollHelper {
Toast.makeText(
this@MainActivity, R.string.file_picker_not_zip, Toast.LENGTH_SHORT
).show()
Timber.e("File is not a zip! Expected 0x504B0304, got %02X%02X%02X%02X", bytes[0], bytes[1], bytes[2], bytes[3])
Timber.e(
"File is not a zip! Expected 0x504B0304, got %02X%02X%02X%02X",
bytes[0],
bytes[1],
bytes[2],
bytes[3]
)
callback?.onReceived(
destination,
uri,

@ -258,7 +258,10 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
if (forceDebugLogging) Timber.d("Root access granted")
setHasGottenRootAccess(true)
} else {
if (forceDebugLogging) Timber.d("Root access or we're not uid 0. Current uid: %s", output)
if (forceDebugLogging) Timber.d(
"Root access or we're not uid 0. Current uid: %s",
output
)
setHasGottenRootAccess(false)
}
}
@ -478,7 +481,7 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
}
if (forceDebugLogging) {
if (priority >= Log.DEBUG) {
when(priority) {
when (priority) {
Log.DEBUG -> Log.d(tag, message, t)
Log.INFO -> Log.i(tag, message, t)
Log.WARN -> Log.w(tag, message, t)
@ -497,7 +500,11 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
companion object {
var forceDebugLogging: Boolean = BuildConfig.DEBUG || getSharedPreferences("mmm")?.getBoolean("pref_force_debug_logging", false) ?: false
var forceDebugLogging: Boolean =
BuildConfig.DEBUG || getSharedPreferences("mmm")?.getBoolean(
"pref_force_debug_logging",
false
) ?: false
// Warning! Locales that don't exist will crash the app
// Anything that is commented out is supported but the translation is not complete to at least 60%
@ -606,7 +613,8 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
}
try {
val masterKey =
MasterKey.Builder(mContext!!).setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
MasterKey.Builder(mContext!!)
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
.build()
val sharedPreferences = EncryptedSharedPreferences.create(
mContext,
@ -730,7 +738,11 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
// should not have been shown in 14 days and only 1 in 5 chance
val randChance = Random().nextInt(5)
val lastShown = getSharedPreferences("mmm")!!.getLong("last_feedback", 0)
if (forceDebugLogging) Timber.d("Last feedback shown: %d, randChance: %d", lastShown, randChance)
if (forceDebugLogging) Timber.d(
"Last feedback shown: %d, randChance: %d",
lastShown,
randChance
)
return System.currentTimeMillis() - lastShown > 1209600000 && randChance == 0
}
}

@ -146,26 +146,38 @@ class InstallerInitializer {
}
if (MainApplication.forceDebugLogging) {
Timber.i("Found ramdisk: %s", output[0])
if (MainApplication.forceDebugLogging) Timber.i("Searching for Magisk path. Current path: %s", mgskPth)
if (MainApplication.forceDebugLogging) Timber.i(
"Searching for Magisk path. Current path: %s",
mgskPth
)
}
// reset output
output.clear()
// try to use magisk --path. if that fails, check for /data/adb/ksu for kernelsu support
if (Shell.cmd("magisk --path", "su -V").to(output).exec().isSuccess && output[0].isNotEmpty() && !output[0].contains(
if (Shell.cmd("magisk --path", "su -V").to(output)
.exec().isSuccess && output[0].isNotEmpty() && !output[0].contains(
"not found"
)) {
)
) {
mgskPth = output[0]
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(
} else if (Shell.cmd(
"if [ -d /data/adb/ksu ]; then echo true; else echo false; fi",
"su -V"
).to(
output
).exec().isSuccess && "true" == output[0]
) {
// check su -v for kernelsu
val suVer: ArrayList<String> = ArrayList()
Shell.cmd("su -v").to(suVer).exec()
if (suVer.size > 0 && suVer[0].contains("ksu") || suVer[0].contains("Kernelsu", true)) {
if (suVer.size > 0 && suVer[0].contains("ksu") || suVer[0].contains(
"Kernelsu",
true
)
) {
if (MainApplication.forceDebugLogging) {
Timber.i("Kernelsu detected")
}
@ -176,18 +188,23 @@ class InstallerInitializer {
Countly.sharedInstance().crashes().addCrashBreadcrumb("ksu detected")
}
} else {
if (MainApplication.forceDebugLogging) { 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 (MainApplication.forceDebugLogging) { Timber.e("Failed to get Magisk path")
if (MainApplication.forceDebugLogging) {
Timber.e("Failed to get Magisk path")
}
return null
}
if (MainApplication.forceDebugLogging) Timber.i("Magisk runtime path: %s", mgskPth)
mgskVerCode = output[1].toInt()
if (MainApplication.forceDebugLogging) Timber.i("Magisk version code: %s", mgskVerCode)
if (MainApplication.forceDebugLogging) Timber.i(
"Magisk version code: %s",
mgskVerCode
)
if (mgskVerCode >= Constants.MAGISK_VER_CODE_FLAT_MODULES && mgskVerCode < Constants.MAGISK_VER_CODE_PATH_SUPPORT && (mgskPth.isEmpty() || !File(
mgskPth
).exists())

@ -40,7 +40,10 @@ class ModuleViewListBuilder(private val activity: Activity) {
Timber.w("addNotification(null) called!")
return
} else {
if (MainApplication.forceDebugLogging) Timber.i("addNotification(%s) called", notificationType)
if (MainApplication.forceDebugLogging) Timber.i(
"addNotification(%s) called",
notificationType
)
}
synchronized(updateLock) { notifications.add(notificationType) }
}
@ -49,13 +52,22 @@ class ModuleViewListBuilder(private val activity: Activity) {
if (MainApplication.forceDebugLogging) Timber.i("appendInstalledModules() called")
synchronized(updateLock) {
for (moduleHolder in mappedModuleHolders.values) {
if (MainApplication.forceDebugLogging) Timber.i("zeroing module %s", moduleHolder.moduleInfo?.id)
if (MainApplication.forceDebugLogging) Timber.i(
"zeroing module %s",
moduleHolder.moduleInfo?.id
)
moduleHolder.moduleInfo = null
}
val moduleManager = instance
moduleManager?.runAfterScan {
if (MainApplication.forceDebugLogging) Timber.i("A0: runAfterScan %s", moduleManager.modules.size)
if (MainApplication.forceDebugLogging) Timber.i("A1: %s", moduleManager.modules.size)
if (MainApplication.forceDebugLogging) Timber.i(
"A0: runAfterScan %s",
moduleManager.modules.size
)
if (MainApplication.forceDebugLogging) Timber.i(
"A1: %s",
moduleManager.modules.size
)
for (moduleInfo in moduleManager.modules.values) {
// add the local module to the list in MainActivity
MainActivity.localModuleInfoList += moduleInfo
@ -129,7 +141,10 @@ class ModuleViewListBuilder(private val activity: Activity) {
// retry up to five times, waiting i * 100ms between each try
if (tries < 5) {
tries++
if (MainApplication.forceDebugLogging) Timber.i("appendRemoteModules() retrying in %dms", tries * 100)
if (MainApplication.forceDebugLogging) Timber.i(
"appendRemoteModules() retrying in %dms",
tries * 100
)
Handler(Looper.getMainLooper()).postDelayed({
appendRemoteModules()
}, tries * 100.toLong())

@ -98,7 +98,10 @@ class RuntimeUtils {
val granted = ContextCompat.checkSelfPermission(
context, Manifest.permission.POST_NOTIFICATIONS
) == PackageManager.PERMISSION_GRANTED
if (MainApplication.forceDebugLogging) Timber.i("Request Notification Permission Done. Result: %s", granted)
if (MainApplication.forceDebugLogging) Timber.i(
"Request Notification Permission Done. Result: %s",
granted
)
}
MainActivity.doSetupNowRunning = false
}

Loading…
Cancel
Save