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" applicationId = "com.fox2code.mmm"
minSdk = 26 minSdk = 26
targetSdk = 34 targetSdk = 34
versionCode = 86 versionCode = 87
versionName = "2.3.2" versionName = "2.3.3"
vectorDrawables { vectorDrawables {
useSupportLibrary = true useSupportLibrary = true
} }

@ -163,7 +163,13 @@ class MainActivity : AppCompatActivity(), OnRefreshListener, OverScrollHelper {
Toast.makeText( Toast.makeText(
this@MainActivity, R.string.file_picker_not_zip, Toast.LENGTH_SHORT this@MainActivity, R.string.file_picker_not_zip, Toast.LENGTH_SHORT
).show() ).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( callback?.onReceived(
destination, destination,
uri, uri,

@ -258,7 +258,10 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
if (forceDebugLogging) Timber.d("Root access granted") if (forceDebugLogging) Timber.d("Root access granted")
setHasGottenRootAccess(true) setHasGottenRootAccess(true)
} else { } 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) setHasGottenRootAccess(false)
} }
} }
@ -478,7 +481,7 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
} }
if (forceDebugLogging) { if (forceDebugLogging) {
if (priority >= Log.DEBUG) { if (priority >= Log.DEBUG) {
when(priority) { when (priority) {
Log.DEBUG -> Log.d(tag, message, t) Log.DEBUG -> Log.d(tag, message, t)
Log.INFO -> Log.i(tag, message, t) Log.INFO -> Log.i(tag, message, t)
Log.WARN -> Log.w(tag, message, t) Log.WARN -> Log.w(tag, message, t)
@ -497,7 +500,11 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
companion object { 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 // 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% // 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 { try {
val masterKey = val masterKey =
MasterKey.Builder(mContext!!).setKeyScheme(MasterKey.KeyScheme.AES256_GCM) MasterKey.Builder(mContext!!)
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
.build() .build()
val sharedPreferences = EncryptedSharedPreferences.create( val sharedPreferences = EncryptedSharedPreferences.create(
mContext, 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 // should not have been shown in 14 days and only 1 in 5 chance
val randChance = Random().nextInt(5) val randChance = Random().nextInt(5)
val lastShown = getSharedPreferences("mmm")!!.getLong("last_feedback", 0) 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 return System.currentTimeMillis() - lastShown > 1209600000 && randChance == 0
} }
} }

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

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

@ -98,7 +98,10 @@ class RuntimeUtils {
val granted = ContextCompat.checkSelfPermission( val granted = ContextCompat.checkSelfPermission(
context, Manifest.permission.POST_NOTIFICATIONS context, Manifest.permission.POST_NOTIFICATIONS
) == PackageManager.PERMISSION_GRANTED ) == 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 MainActivity.doSetupNowRunning = false
} }

Loading…
Cancel
Save