Skip to content

Commit 2b62e4d

Browse files
code cleanup
Signed-off-by: androidacy-user <opensource@androidacy.com>
1 parent 7fdbac1 commit 2b62e4d

6 files changed

Lines changed: 75 additions & 22 deletions

File tree

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ android {
4848
applicationId = "com.fox2code.mmm"
4949
minSdk = 26
5050
targetSdk = 34
51-
versionCode = 86
52-
versionName = "2.3.2"
51+
versionCode = 87
52+
versionName = "2.3.3"
5353
vectorDrawables {
5454
useSupportLibrary = true
5555
}

app/src/main/kotlin/com/fox2code/mmm/MainActivity.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,13 @@ class MainActivity : AppCompatActivity(), OnRefreshListener, OverScrollHelper {
163163
Toast.makeText(
164164
this@MainActivity, R.string.file_picker_not_zip, Toast.LENGTH_SHORT
165165
).show()
166-
Timber.e("File is not a zip! Expected 0x504B0304, got %02X%02X%02X%02X", bytes[0], bytes[1], bytes[2], bytes[3])
166+
Timber.e(
167+
"File is not a zip! Expected 0x504B0304, got %02X%02X%02X%02X",
168+
bytes[0],
169+
bytes[1],
170+
bytes[2],
171+
bytes[3]
172+
)
167173
callback?.onReceived(
168174
destination,
169175
uri,

app/src/main/kotlin/com/fox2code/mmm/MainApplication.kt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,10 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
258258
if (forceDebugLogging) Timber.d("Root access granted")
259259
setHasGottenRootAccess(true)
260260
} else {
261-
if (forceDebugLogging) Timber.d("Root access or we're not uid 0. Current uid: %s", output)
261+
if (forceDebugLogging) Timber.d(
262+
"Root access or we're not uid 0. Current uid: %s",
263+
output
264+
)
262265
setHasGottenRootAccess(false)
263266
}
264267
}
@@ -478,7 +481,7 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
478481
}
479482
if (forceDebugLogging) {
480483
if (priority >= Log.DEBUG) {
481-
when(priority) {
484+
when (priority) {
482485
Log.DEBUG -> Log.d(tag, message, t)
483486
Log.INFO -> Log.i(tag, message, t)
484487
Log.WARN -> Log.w(tag, message, t)
@@ -497,7 +500,11 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
497500

498501
companion object {
499502

500-
var forceDebugLogging: Boolean = BuildConfig.DEBUG || getSharedPreferences("mmm")?.getBoolean("pref_force_debug_logging", false) ?: false
503+
var forceDebugLogging: Boolean =
504+
BuildConfig.DEBUG || getSharedPreferences("mmm")?.getBoolean(
505+
"pref_force_debug_logging",
506+
false
507+
) ?: false
501508

502509
// Warning! Locales that don't exist will crash the app
503510
// 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
606613
}
607614
try {
608615
val masterKey =
609-
MasterKey.Builder(mContext!!).setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
616+
MasterKey.Builder(mContext!!)
617+
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
610618
.build()
611619
val sharedPreferences = EncryptedSharedPreferences.create(
612620
mContext,
@@ -730,7 +738,11 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
730738
// should not have been shown in 14 days and only 1 in 5 chance
731739
val randChance = Random().nextInt(5)
732740
val lastShown = getSharedPreferences("mmm")!!.getLong("last_feedback", 0)
733-
if (forceDebugLogging) Timber.d("Last feedback shown: %d, randChance: %d", lastShown, randChance)
741+
if (forceDebugLogging) Timber.d(
742+
"Last feedback shown: %d, randChance: %d",
743+
lastShown,
744+
randChance
745+
)
734746
return System.currentTimeMillis() - lastShown > 1209600000 && randChance == 0
735747
}
736748
}

app/src/main/kotlin/com/fox2code/mmm/installer/InstallerInitializer.kt

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,26 +146,38 @@ class InstallerInitializer {
146146
}
147147
if (MainApplication.forceDebugLogging) {
148148
Timber.i("Found ramdisk: %s", output[0])
149-
if (MainApplication.forceDebugLogging) Timber.i("Searching for Magisk path. Current path: %s", mgskPth)
149+
if (MainApplication.forceDebugLogging) Timber.i(
150+
"Searching for Magisk path. Current path: %s",
151+
mgskPth
152+
)
150153
}
151154
// reset output
152155
output.clear()
153156
// try to use magisk --path. if that fails, check for /data/adb/ksu for kernelsu support
154-
if (Shell.cmd("magisk --path", "su -V").to(output).exec().isSuccess && output[0].isNotEmpty() && !output[0].contains(
157+
if (Shell.cmd("magisk --path", "su -V").to(output)
158+
.exec().isSuccess && output[0].isNotEmpty() && !output[0].contains(
155159
"not found"
156-
)) {
160+
)
161+
) {
157162
mgskPth = output[0]
158163
if (MainApplication.forceDebugLogging) {
159164
Timber.i("Magisk path 1: %s", mgskPth)
160165
}
161-
} else if (Shell.cmd("if [ -d /data/adb/ksu ]; then echo true; else echo false; fi", "su -V").to(
166+
} else if (Shell.cmd(
167+
"if [ -d /data/adb/ksu ]; then echo true; else echo false; fi",
168+
"su -V"
169+
).to(
162170
output
163171
).exec().isSuccess && "true" == output[0]
164172
) {
165173
// check su -v for kernelsu
166174
val suVer: ArrayList<String> = ArrayList()
167175
Shell.cmd("su -v").to(suVer).exec()
168-
if (suVer.size > 0 && suVer[0].contains("ksu") || suVer[0].contains("Kernelsu", true)) {
176+
if (suVer.size > 0 && suVer[0].contains("ksu") || suVer[0].contains(
177+
"Kernelsu",
178+
true
179+
)
180+
) {
169181
if (MainApplication.forceDebugLogging) {
170182
Timber.i("Kernelsu detected")
171183
}
@@ -176,18 +188,23 @@ class InstallerInitializer {
176188
Countly.sharedInstance().crashes().addCrashBreadcrumb("ksu detected")
177189
}
178190
} else {
179-
if (MainApplication.forceDebugLogging) { Timber.e("[ANOMALY] Kernelsu not detected but /data/adb/ksu exists")
191+
if (MainApplication.forceDebugLogging) {
192+
Timber.e("[ANOMALY] Kernelsu not detected but /data/adb/ksu exists")
180193
}
181194
return null
182195
}
183196
} else {
184-
if (MainApplication.forceDebugLogging) { Timber.e("Failed to get Magisk path")
197+
if (MainApplication.forceDebugLogging) {
198+
Timber.e("Failed to get Magisk path")
185199
}
186200
return null
187201
}
188202
if (MainApplication.forceDebugLogging) Timber.i("Magisk runtime path: %s", mgskPth)
189203
mgskVerCode = output[1].toInt()
190-
if (MainApplication.forceDebugLogging) Timber.i("Magisk version code: %s", mgskVerCode)
204+
if (MainApplication.forceDebugLogging) Timber.i(
205+
"Magisk version code: %s",
206+
mgskVerCode
207+
)
191208
if (mgskVerCode >= Constants.MAGISK_VER_CODE_FLAT_MODULES && mgskVerCode < Constants.MAGISK_VER_CODE_PATH_SUPPORT && (mgskPth.isEmpty() || !File(
192209
mgskPth
193210
).exists())

app/src/main/kotlin/com/fox2code/mmm/module/ModuleViewListBuilder.kt

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ class ModuleViewListBuilder(private val activity: Activity) {
4040
Timber.w("addNotification(null) called!")
4141
return
4242
} else {
43-
if (MainApplication.forceDebugLogging) Timber.i("addNotification(%s) called", notificationType)
43+
if (MainApplication.forceDebugLogging) Timber.i(
44+
"addNotification(%s) called",
45+
notificationType
46+
)
4447
}
4548
synchronized(updateLock) { notifications.add(notificationType) }
4649
}
@@ -49,13 +52,22 @@ class ModuleViewListBuilder(private val activity: Activity) {
4952
if (MainApplication.forceDebugLogging) Timber.i("appendInstalledModules() called")
5053
synchronized(updateLock) {
5154
for (moduleHolder in mappedModuleHolders.values) {
52-
if (MainApplication.forceDebugLogging) Timber.i("zeroing module %s", moduleHolder.moduleInfo?.id)
55+
if (MainApplication.forceDebugLogging) Timber.i(
56+
"zeroing module %s",
57+
moduleHolder.moduleInfo?.id
58+
)
5359
moduleHolder.moduleInfo = null
5460
}
5561
val moduleManager = instance
5662
moduleManager?.runAfterScan {
57-
if (MainApplication.forceDebugLogging) Timber.i("A0: runAfterScan %s", moduleManager.modules.size)
58-
if (MainApplication.forceDebugLogging) Timber.i("A1: %s", moduleManager.modules.size)
63+
if (MainApplication.forceDebugLogging) Timber.i(
64+
"A0: runAfterScan %s",
65+
moduleManager.modules.size
66+
)
67+
if (MainApplication.forceDebugLogging) Timber.i(
68+
"A1: %s",
69+
moduleManager.modules.size
70+
)
5971
for (moduleInfo in moduleManager.modules.values) {
6072
// add the local module to the list in MainActivity
6173
MainActivity.localModuleInfoList += moduleInfo
@@ -129,7 +141,10 @@ class ModuleViewListBuilder(private val activity: Activity) {
129141
// retry up to five times, waiting i * 100ms between each try
130142
if (tries < 5) {
131143
tries++
132-
if (MainApplication.forceDebugLogging) Timber.i("appendRemoteModules() retrying in %dms", tries * 100)
144+
if (MainApplication.forceDebugLogging) Timber.i(
145+
"appendRemoteModules() retrying in %dms",
146+
tries * 100
147+
)
133148
Handler(Looper.getMainLooper()).postDelayed({
134149
appendRemoteModules()
135150
}, tries * 100.toLong())

app/src/main/kotlin/com/fox2code/mmm/utils/RuntimeUtils.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ class RuntimeUtils {
9898
val granted = ContextCompat.checkSelfPermission(
9999
context, Manifest.permission.POST_NOTIFICATIONS
100100
) == PackageManager.PERMISSION_GRANTED
101-
if (MainApplication.forceDebugLogging) Timber.i("Request Notification Permission Done. Result: %s", granted)
101+
if (MainApplication.forceDebugLogging) Timber.i(
102+
"Request Notification Permission Done. Result: %s",
103+
granted
104+
)
102105
}
103106
MainActivity.doSetupNowRunning = false
104107
}

0 commit comments

Comments
 (0)