Skip to content

Commit be34fc0

Browse files
final tweaks in prep for release
Signed-off-by: androidacy-user <[email protected]>
1 parent 1484195 commit be34fc0

File tree

6 files changed

+82
-74
lines changed

6 files changed

+82
-74
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ android {
5353
applicationId = "com.fox2code.mmm"
5454
minSdk = 24
5555
targetSdk = 33
56-
versionCode = 77
56+
versionCode = 78
5757
versionName = "2.2.1"
5858
vectorDrawables {
5959
useSupportLibrary = true

app/proguard-rules.pro

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,21 @@
196196
-keepclassmembers class org.apache.commons.compress.archivers.zip.* { *; }
197197
#-keep class com.fox2code.mmm.installer.InstallerInitializer { *; }
198198

199+
# Strip out debugging stuffs
200+
-assumenosideeffects class com.topjohnwu.superuser.internal.Utils {
201+
public static void log(...);
202+
public static void ex(...);
203+
public static boolean vLog() return false;
204+
public static boolean hasStartupAgents(android.content.Context) return false;
205+
}
206+
207+
# Keep classes referenced by reflection
208+
-keep,allowobfuscation class * extends com.topjohnwu.superuser.Shell$Initializer { *; }
209+
-keep,allowobfuscation class * extends com.topjohnwu.superuser.ipc.RootService { *; }
210+
-keep class com.topjohnwu.superuser.Shell$Job
211+
-keep class com.topjohnwu.superuser.Shell$Result
212+
-keep class com.topjohnwu.superuser.Shell
213+
199214
# dontwarn
200215
-dontwarn android.os.SystemProperties
201216
-dontwarn android.view.ThreadedRenderer

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

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class InstallerInitializer : Shell.Initializer() {
3030
private val MAGISK_SBIN = File("/sbin/magisk")
3131
private val MAGISK_SYSTEM = File("/system/bin/magisk")
3232
private val MAGISK_SYSTEM_EX = File("/system/xbin/magisk")
33-
private val HAS_MAGISK = MAGISK_SBIN.exists() ||
34-
MAGISK_SYSTEM.exists() || MAGISK_SYSTEM_EX.exists()
33+
private val HAS_MAGISK =
34+
MAGISK_SBIN.exists() || MAGISK_SYSTEM.exists() || MAGISK_SYSTEM_EX.exists()
3535
private var mgskPth: String? = null
3636
private var mgskVerCode = 0
3737
private var hsRmdsk = false
@@ -43,9 +43,7 @@ class InstallerInitializer : Shell.Initializer() {
4343
val errorNotification: NotificationType?
4444
get() {
4545
val hasRoot = Shell.isAppGrantedRoot()
46-
if (mgskPth != null &&
47-
hasRoot !== java.lang.Boolean.FALSE
48-
) {
46+
if (mgskPth != null && hasRoot !== java.lang.Boolean.FALSE) {
4947
return null
5048
}
5149
if (!HAS_MAGISK) {
@@ -130,47 +128,46 @@ class InstallerInitializer : Shell.Initializer() {
130128
if (mgskPth != null && !forceCheck) return mgskPth
131129
val output = ArrayList<String>()
132130
try {
133-
if (!Shell.cmd(
134-
"if grep ' / ' /proc/mounts | grep -q '/dev/root' &> /dev/null; " +
135-
"then echo true; else echo false; fi", "magisk -V", "magisk --path"
136-
)
137-
.to(output).exec().isSuccess
138-
) {
139-
if (output.size != 0) {
140-
hsRmdsk = "false" == output[0] ||
141-
"true".equals(
142-
System.getProperty("ro.build.ab_update"),
143-
ignoreCase = true
144-
)
131+
if (!Shell.cmd(
132+
"if grep ' / ' /proc/mounts | grep -q '/dev/root' &> /dev/null; " + "then echo true; else echo false; fi",
133+
"magisk -V",
134+
"magisk --path"
135+
).to(output).exec().isSuccess
136+
) {
137+
if (output.size != 0) {
138+
hsRmdsk = "false" == output[0] || "true".equals(
139+
System.getProperty("ro.build.ab_update"), ignoreCase = true
140+
)
141+
}
142+
Companion.hsRmdsk = hsRmdsk
143+
return null
145144
}
146-
Companion.hsRmdsk = hsRmdsk
147-
return null
148-
}
149-
mgskPth = if (output.size < 3) "" else output[2]
150-
Timber.i("Magisk runtime path: %s", mgskPth)
151-
mgskVerCode = output[1].toInt()
152-
Timber.i("Magisk version code: %s", mgskVerCode)
153-
if (mgskVerCode >= Constants.MAGISK_VER_CODE_FLAT_MODULES && mgskVerCode < Constants.MAGISK_VER_CODE_PATH_SUPPORT &&
154-
(mgskPth.isEmpty() || !File(mgskPth).exists())
155-
) {
156-
mgskPth = "/sbin"
157-
}
158-
if (mgskPth.isNotEmpty() && existsSU(File(mgskPth))) {
159-
Companion.mgskPth = mgskPth
160-
} else {
161-
Timber.e("Failed to get Magisk path (Got $mgskPth)")
162-
mgskPth = null
163-
}
164-
Companion.mgskVerCode = mgskVerCode
165-
return mgskPth
145+
mgskPth = if (output.size < 3) "" else output[2]
146+
Timber.i("Magisk runtime path: %s", mgskPth)
147+
mgskVerCode = output[1].toInt()
148+
Timber.i("Magisk version code: %s", mgskVerCode)
149+
if (mgskVerCode >= Constants.MAGISK_VER_CODE_FLAT_MODULES && mgskVerCode < Constants.MAGISK_VER_CODE_PATH_SUPPORT && (mgskPth.isEmpty() || !File(
150+
mgskPth
151+
).exists())
152+
) {
153+
mgskPth = "/sbin"
154+
}
155+
if (mgskPth.isNotEmpty() && existsSU(File(mgskPth))) {
156+
Companion.mgskPth = mgskPth
157+
} else {
158+
Timber.e("Failed to get Magisk path (Got $mgskPth)")
159+
mgskPth = null
160+
}
161+
Companion.mgskVerCode = mgskVerCode
162+
return mgskPth
166163
} catch (ignored: Exception) {
167-
if (tries < 5) {
164+
return if (tries < 5) {
168165
tries++
169-
return tryGetMagiskPath(true)
166+
tryGetMagiskPath(true)
170167
} else {
171-
return null
168+
null
172169
}
173-
}
170+
}
174171
}
175172
}
176173
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,9 @@ class ModuleHolder : Comparable<ModuleHolder?> {
189189
INSTANCE!!.modulesHaveUpdates,
190190
INSTANCE!!.updateModuleCount
191191
)
192-
Timber.d("Module %s has update", moduleId)
193192
Type.UPDATABLE
194193
}
195194
} else {
196-
Timber.i("Module %s is installed", moduleId)
197195
Type.INSTALLED
198196
}
199197

app/src/main/kotlin/com/fox2code/mmm/settings/SettingsActivity.kt

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,40 +1014,37 @@ class SettingsActivity : FoxActivity(), LanguageActivity {
10141014
try {
10151015
logsFile.createNewFile()
10161016
fileOutputStream = FileOutputStream(logsFile)
1017-
// first, write some info about the device
1017+
// first, some device and app info: namely device oem and model, android version and build, app version and build
10181018
fileOutputStream.write(
1019-
"""FoxMagiskModuleManager version: ${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})
1020-
""".toByteArray()
1019+
String.format(
1020+
"Device: %s %s\nAndroid Version: %s\nROM: %s\nApp Version: %s (%s)\n\n",
1021+
Build.MANUFACTURER,
1022+
Build.MODEL,
1023+
Build.VERSION.RELEASE,
1024+
Build.FINGERPRINT,
1025+
BuildConfig.VERSION_NAME,
1026+
BuildConfig.VERSION_CODE
1027+
).toByteArray()
10211028
)
1022-
fileOutputStream.write(
1023-
"""Android version: ${Build.VERSION.RELEASE} (${Build.VERSION.SDK_INT})
1024-
""".toByteArray()
1025-
)
1026-
fileOutputStream.write(
1027-
"""Device: ${Build.MANUFACTURER} ${Build.MODEL} (${Build.DEVICE})
1028-
""".toByteArray()
1029-
)
1030-
fileOutputStream.write(
1031-
"""Magisk version: ${peekMagiskVersion()}
1032-
""".toByteArray()
1033-
)
1034-
fileOutputStream.write(
1035-
("Has internet: " + (if (getINSTANCE()!!
1036-
.hasConnectivity()
1037-
) "Yes" else "No") + "\n").toByteArray()
1029+
// next, the logs
1030+
// get our logs from logcat
1031+
val process = Runtime.getRuntime().exec("logcat -d")
1032+
val bufferedReader = BufferedReader(
1033+
InputStreamReader(process.inputStream)
10381034
)
1039-
fileOutputStream.write("Beginning of logs:\n".toByteArray())
1040-
1041-
// read our logcat but format the output to be more readable
1042-
val process = Runtime.getRuntime().exec("logcat -d -v tag")
1043-
val bufferedReader = BufferedReader(InputStreamReader(process.inputStream))
1044-
var line: String
1045-
while (bufferedReader.readLine().also { line = it } != null) {
1046-
fileOutputStream.write(
1047-
"""$line
1048-
""".toByteArray()
1049-
)
1035+
var line: String?
1036+
val iterator: Iterator<String> = bufferedReader.lines().iterator()
1037+
while (iterator.hasNext()) {
1038+
line = iterator.next()
1039+
fileOutputStream.write(line.toByteArray())
1040+
fileOutputStream.write("\n".toByteArray())
10501041
}
1042+
fileOutputStream.flush()
1043+
Toast.makeText(
1044+
requireContext(),
1045+
R.string.logs_saved,
1046+
Toast.LENGTH_SHORT
1047+
).show()
10511048
} catch (e: IOException) {
10521049
e.printStackTrace()
10531050
Toast.makeText(

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,4 +383,5 @@
383383
<string name="expired">This build has expired!</string>
384384
<string name="expired_message">The build you are using is expired and will no longer run. Please update to the latest stable build.</string>
385385
<string name="download_latest">Download latest</string>
386+
<string name="logs_saved">Saved logs successfully</string>
386387
</resources>

0 commit comments

Comments
 (0)