Skip to content

Commit e5b839b

Browse files
fix a crash or two
can't catch em all Signed-off-by: androidacy-user <opensource@androidacy.com>
1 parent 69abdf8 commit e5b839b

8 files changed

Lines changed: 68 additions & 53 deletions

File tree

app/build.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ android {
5353
applicationId = "com.fox2code.mmm"
5454
minSdk = 24
5555
targetSdk = 33
56-
versionCode = 78
57-
versionName = "2.2.1"
56+
versionCode = 79
57+
versionName = "2.2.2"
5858
vectorDrawables {
5959
useSupportLibrary = true
6060
}
@@ -118,6 +118,7 @@ android {
118118
)
119119
renderscriptOptimLevel = 3
120120
signingConfig = signingConfigs.getByName("release")
121+
multiDexEnabled = true
121122
}
122123
getByName("debug") {
123124
applicationIdSuffix = ".debug"

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

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
1717
import com.google.android.material.textview.MaterialTextView
1818
import io.sentry.Sentry
1919
import io.sentry.UserFeedback
20+
import io.sentry.protocol.SentryId
2021
import timber.log.Timber
2122
import java.io.PrintWriter
2223
import java.io.StringWriter
@@ -84,20 +85,18 @@ class CrashHandler : FoxActivity() {
8485
val emailString =
8586
arrayOf(if (email.text.toString() == "") "Anonymous" else email.text.toString())
8687
// get sentryException passed in intent
87-
val sentryException = intent.getSerializableExtra("sentryException") as Throwable?
88+
@Suppress("NAME_SHADOWING") val lastEventId = Sentry.getLastEventId()
8889
Thread {
8990
try {
90-
val userFeedback: UserFeedback
91-
if (sentryException != null) {
92-
userFeedback = UserFeedback(Sentry.captureException(sentryException))
93-
// Setups the JSON body
94-
if (nameString[0] == "") nameString[0] = "Anonymous"
95-
if (emailString[0] == "") emailString[0] = "Anonymous"
96-
userFeedback.name = nameString[0]
97-
userFeedback.email = emailString[0]
98-
userFeedback.comments = description.text.toString()
99-
Sentry.captureUserFeedback(userFeedback)
100-
}
91+
val userFeedback =
92+
UserFeedback(SentryId(lastEventId.toString()))
93+
// Setups the JSON body
94+
if (nameString[0] == "") nameString[0] = "Anonymous"
95+
if (emailString[0] == "") emailString[0] = "Anonymous"
96+
userFeedback.name = nameString[0]
97+
userFeedback.email = emailString[0]
98+
userFeedback.comments = description.text.toString()
99+
Sentry.captureUserFeedback(userFeedback)
101100
Timber.i(
102101
"Submitted user feedback: name %s email %s comment %s",
103102
nameString[0],
@@ -106,9 +105,7 @@ class CrashHandler : FoxActivity() {
106105
)
107106
runOnUiThread {
108107
Toast.makeText(
109-
this,
110-
R.string.sentry_dialogue_success,
111-
Toast.LENGTH_LONG
108+
this, R.string.sentry_dialogue_success, Toast.LENGTH_LONG
112109
).show()
113110
}
114111
// Close the activity
@@ -120,9 +117,7 @@ class CrashHandler : FoxActivity() {
120117
// Show a toast if the user feedback could not be submitted
121118
runOnUiThread {
122119
Toast.makeText(
123-
this,
124-
R.string.sentry_dialogue_failed_toast,
125-
Toast.LENGTH_LONG
120+
this, R.string.sentry_dialogue_failed_toast, Toast.LENGTH_LONG
126121
).show()
127122
}
128123
}
@@ -151,9 +146,7 @@ class CrashHandler : FoxActivity() {
151146
(findViewById<View>(R.id.feedback_text) as MaterialTextView).setText(R.string.sentry_enable_nag)
152147
findViewById<View>(R.id.feedback_submit).setOnClickListener { _: View? ->
153148
Toast.makeText(
154-
this,
155-
R.string.sentry_dialogue_disabled,
156-
Toast.LENGTH_LONG
149+
this, R.string.sentry_dialogue_disabled, Toast.LENGTH_LONG
157150
).show()
158151
}
159152
// handle restart button

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class InstallerInitializer : Shell.Initializer() {
6868
/**
6969
* Note: Used to detect which modules are currently loaded.
7070
*
71-
*
7271
* For read/write only "/data/adb/modules" should be used
7372
*/
7473
fun peekModulesPath(): String? {
@@ -161,8 +160,14 @@ class InstallerInitializer : Shell.Initializer() {
161160
Companion.mgskVerCode = mgskVerCode
162161
return mgskPth
163162
} catch (ignored: Exception) {
164-
return if (tries < 5) {
163+
return if (tries <= 5) {
165164
tries++
165+
// sleep tries * 25ms
166+
try {
167+
Thread.sleep(tries * 25L)
168+
} catch (e: InterruptedException) {
169+
Timber.e(e)
170+
}
166171
tryGetMagiskPath(true)
167172
} else {
168173
null

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

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,25 +51,44 @@ enum class ActionButtonType {
5151
TrackHelper.track().event("view_notes", name).with(INSTANCE!!.getTracker())
5252
val notesUrl = moduleHolder.repoModule?.notesUrl
5353
if (isAndroidacyLink(notesUrl)) {
54-
openUrlAndroidacy(
55-
button.context,
56-
notesUrl,
57-
false,
58-
moduleHolder.repoModule?.moduleInfo?.name,
59-
moduleHolder.mainModuleConfig
60-
)
54+
try {
55+
openUrlAndroidacy(
56+
button.context,
57+
notesUrl,
58+
false,
59+
moduleHolder.repoModule?.moduleInfo?.name,
60+
moduleHolder.mainModuleConfig
61+
)
62+
} catch (e: Exception) {
63+
Timber.e(e)
64+
Timber.e("Error opening notes - androidacy link. This should never happen.")
65+
Toast.makeText(
66+
button.context,
67+
R.string.error_opening_notes,
68+
Toast.LENGTH_SHORT
69+
).show()
70+
}
6171
} else {
62-
openMarkdown(
63-
button.context,
64-
notesUrl,
65-
moduleHolder.repoModule?.moduleInfo?.name,
66-
moduleHolder.mainModuleConfig,
67-
moduleHolder.repoModule?.moduleInfo?.changeBoot,
68-
moduleHolder.repoModule?.moduleInfo?.needRamdisk,
69-
moduleHolder.repoModule?.moduleInfo?.minMagisk ?: 0,
70-
moduleHolder.repoModule?.moduleInfo?.minApi ?: 0,
71-
moduleHolder.repoModule?.moduleInfo?.maxApi ?: 9999
72-
)
72+
try {
73+
openMarkdown(
74+
button.context,
75+
notesUrl,
76+
moduleHolder.repoModule?.moduleInfo?.name,
77+
moduleHolder.mainModuleConfig,
78+
moduleHolder.repoModule?.moduleInfo?.changeBoot,
79+
moduleHolder.repoModule?.moduleInfo?.needRamdisk,
80+
moduleHolder.repoModule?.moduleInfo?.minMagisk ?: 0,
81+
moduleHolder.repoModule?.moduleInfo?.minApi ?: 0,
82+
moduleHolder.repoModule?.moduleInfo?.maxApi ?: 9999
83+
)
84+
} catch (e: Exception) {
85+
Timber.e(e)
86+
Toast.makeText(
87+
button.context,
88+
R.string.error_opening_notes,
89+
Toast.LENGTH_SHORT
90+
).show()
91+
}
7392
}
7493
}
7594

app/src/main/kotlin/com/fox2code/mmm/repo/RepoManager.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class RepoManager private constructor(mainApplication: MainApplication) : SyncMa
7070
for (repoData in repoData.values) {
7171
if (repoData === androidacyRepoData) {
7272
if (x) {
73-
Timber.e("Multiple Androidacy repo detected")
73+
//
7474
} else {
7575
x = true
7676
}
@@ -229,7 +229,7 @@ class RepoManager private constructor(mainApplication: MainApplication) : SyncMa
229229
for (i in repoDatas.indices) {
230230
// If repo is not enabled, skip
231231
if (!repoDatas[i].isEnabled) {
232-
if (BuildConfig.DEBUG) Timber.d("Skipping " + repoDatas[i].name + " because it's disabled")
232+
if (BuildConfig.DEBUG) Timber.d("Skipping ${repoDatas[i].name} because it's disabled")
233233
continue
234234
}
235235
if (BuildConfig.DEBUG) Timber.d("Finishing: %s", repoUpdaters[i]!!.repoData.name)

app/src/main/kotlin/com/fox2code/mmm/utils/sentry/SentryMain.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ object SentryMain {
115115
options.addInAppInclude("com.fox2code.mmm.debug")
116116
options.addInAppInclude("com.fox2code.mmm.fdroid")
117117
options.addInAppExclude("com.fox2code.mmm.utils.sentry.SentryMain")
118+
options.addInAppInclude("com.fox2code.mmm.utils")
118119
// Respect user preference for sending PII. default is true on non fdroid builds, false on fdroid builds
119120
options.isSendDefaultPii = crashReportingPii
120121
options.enableAllAutoBreadcrumbs(true)
@@ -123,7 +124,7 @@ object SentryMain {
123124
// It just tell if sentry should ping the sentry dsn to tell the app is running. Useful for performance and profiling.
124125
options.isEnableAutoSessionTracking = true
125126
// disable crash tracking - we handle that ourselves
126-
options.isEnableUncaughtExceptionHandler = false
127+
options.isEnableUncaughtExceptionHandler = true
127128
// Add a callback that will be used before the event is sent to Sentry.
128129
// With this callback, you can modify the event or, when returning null, also discard the event.
129130
options.beforeSend = BeforeSendCallback { event: SentryEvent?, _: Hint? ->

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,4 +384,5 @@
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>
386386
<string name="logs_saved">Saved logs successfully</string>
387+
<string name="error_opening_notes">Error in opening module notes. Logs may have the reason.</string>
387388
</resources>

build.gradle.kts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,15 @@ buildscript {
1212
}
1313
gradlePluginPortal()
1414
}
15-
extra.apply {
16-
set("sentryConfigFile", rootProject.file("sentry.properties"))
17-
set("hasSentryConfig", false)
18-
set("sentryVersion", "6.18.1")
19-
}
2015
dependencies {
2116
classpath("com.android.tools.build:gradle:8.1.0-rc01")
2217
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.22")
23-
classpath("com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:10.6.2")
18+
classpath("com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:10.8.0")
2419

2520
// NOTE: Do not place your application dependencies here; they belong
2621
// in the individual module build.gradle files
2722
classpath("io.sentry:sentry-android-gradle-plugin:3.11.0")
28-
classpath("org.gradle.android.cache-fix:org.gradle.android.cache-fix.gradle.plugin:2.7.1")
23+
classpath("org.gradle.android.cache-fix:org.gradle.android.cache-fix.gradle.plugin:2.7.2")
2924
}
3025
}
3126

0 commit comments

Comments
 (0)