Skip to content

Commit 46f0a91

Browse files
committed
refactor: add initializeAcraCrashReporter() top-level function
Extract CrashReportService.initialize() and isProperServiceProcess() into top-level functions.
1 parent 75247c1 commit 46f0a91

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

AnkiDroid/src/main/java/com/ichi2/anki/AnkiDroidApp.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ open class AnkiDroidApp :
134134
// Ensures any change is propagated to widgets
135135
ChangeManager.subscribe(this)
136136

137-
CrashReportService.initialize(this)
137+
initializeAcraCrashReporter()
138138
val logType = LogType.value
139139
when (logType) {
140140
LogType.DEBUG -> Timber.plant(DebugTree())
@@ -165,7 +165,7 @@ open class AnkiDroidApp :
165165
}
166166

167167
// Stop after analytics and logging are initialised.
168-
if (CrashReportService.isProperServiceProcess()) {
168+
if (isAcraSenderProcess()) {
169169
Timber.d("Skipping AnkiDroidApp.onCreate from ACRA sender process")
170170
return
171171
}

AnkiDroid/src/main/java/com/ichi2/anki/CrashReportService.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,3 +417,13 @@ fun <T> runCatchingWithReport(
417417
if (e is Error) throw e
418418
Result.failure(e)
419419
}
420+
421+
/**
422+
* Initializes ACRA crash reporting.
423+
*/
424+
context(application: Application)
425+
fun initializeAcraCrashReporter() {
426+
CrashReportService.initialize(application)
427+
}
428+
429+
fun isAcraSenderProcess(): Boolean = CrashReportService.isProperServiceProcess()

0 commit comments

Comments
 (0)