Merge pull request #66 from vector-im/feature/bma/sonar
Sonar / Kover / Codecov
This commit is contained in:
commit
a4f9354e8a
14 changed files with 156 additions and 16 deletions
|
|
@ -32,6 +32,7 @@ dependencies {
|
|||
implementation(projects.libraries.designsystem)
|
||||
implementation(projects.libraries.architecture)
|
||||
implementation(projects.libraries.testtags)
|
||||
implementation(projects.libraries.androidutils)
|
||||
implementation(libs.accompanist.pager)
|
||||
implementation(libs.accompanist.pagerindicator)
|
||||
testImplementation(libs.test.junit)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@ package io.element.android.features.rageshake.logs
|
|||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import io.element.android.libraries.androidutils.file.safeDelete
|
||||
import io.element.android.libraries.core.data.tryOrNull
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
|
|
@ -37,6 +39,7 @@ import java.util.logging.Logger
|
|||
class VectorFileLogger(
|
||||
context: Context,
|
||||
// private val vectorPreferences: VectorPreferences
|
||||
private val dispatcher: CoroutineDispatcher = Dispatchers.IO,
|
||||
) : Timber.Tree() {
|
||||
|
||||
companion object {
|
||||
|
|
@ -82,7 +85,7 @@ class VectorFileLogger(
|
|||
|
||||
for (i in 0..15) {
|
||||
val file = File(cacheDirectory, "elementLogs.${i}.txt")
|
||||
tryOrNull { file.delete() }
|
||||
file.safeDelete()
|
||||
}
|
||||
|
||||
fileHandler = tryOrNull(
|
||||
|
|
@ -101,14 +104,14 @@ class VectorFileLogger(
|
|||
fun reset() {
|
||||
// Delete all files
|
||||
getLogFiles().map {
|
||||
tryOrNull { it.delete() }
|
||||
it.safeDelete()
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
|
||||
fileHandler ?: return
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
GlobalScope.launch(dispatcher) {
|
||||
if (skipLog(priority)) return@launch
|
||||
if (t != null) {
|
||||
logToFile(t)
|
||||
|
|
|
|||
|
|
@ -23,11 +23,12 @@ import io.element.android.features.rageshake.crash.CrashDataStore
|
|||
import io.element.android.features.rageshake.logs.VectorFileLogger
|
||||
import io.element.android.features.rageshake.screenshot.ScreenshotHolder
|
||||
import io.element.android.libraries.androidutils.file.compressFile
|
||||
import io.element.android.libraries.androidutils.file.safeDelete
|
||||
import io.element.android.libraries.core.coroutine.CoroutineDispatchers
|
||||
import io.element.android.libraries.core.extensions.toOnOff
|
||||
import io.element.android.libraries.core.mimetype.MimeTypes
|
||||
import io.element.android.libraries.di.ApplicationContext
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
|
@ -54,6 +55,7 @@ class BugReporter @Inject constructor(
|
|||
@ApplicationContext private val context: Context,
|
||||
private val screenshotHolder: ScreenshotHolder,
|
||||
private val crashDataStore: CrashDataStore,
|
||||
private val coroutineDispatchers: CoroutineDispatchers,
|
||||
/*
|
||||
private val activeSessionHolder: ActiveSessionHolder,
|
||||
private val versionProvider: VersionProvider,
|
||||
|
|
@ -168,7 +170,7 @@ class BugReporter @Inject constructor(
|
|||
coroutineScope.launch {
|
||||
var serverError: String? = null
|
||||
var reportURL: String? = null
|
||||
withContext(Dispatchers.IO) {
|
||||
withContext(coroutineDispatchers.io) {
|
||||
var bugDescription = theBugDescription
|
||||
val crashCallStack = crashDataStore.crashInfo().first()
|
||||
|
||||
|
|
@ -418,12 +420,12 @@ class BugReporter @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
withContext(coroutineDispatchers.main) {
|
||||
mBugReportCall = null
|
||||
|
||||
// delete when the bug report has been successfully sent
|
||||
for (file in mBugReportFiles) {
|
||||
file.delete()
|
||||
file.safeDelete()
|
||||
}
|
||||
|
||||
if (null != listener) {
|
||||
|
|
@ -498,7 +500,7 @@ class BugReporter @Inject constructor(
|
|||
val logCatErrFile = File(context.cacheDir.absolutePath, if (isErrorLogcat) LOG_CAT_ERROR_FILENAME else LOG_CAT_FILENAME)
|
||||
|
||||
if (logCatErrFile.exists()) {
|
||||
logCatErrFile.delete()
|
||||
logCatErrFile.safeDelete()
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package io.element.android.features.rageshake.screenshot
|
|||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import io.element.android.libraries.androidutils.bitmap.writeBitmap
|
||||
import io.element.android.libraries.androidutils.file.safeDelete
|
||||
import io.element.android.libraries.di.AppScope
|
||||
import io.element.android.libraries.di.ApplicationContext
|
||||
import io.element.android.libraries.di.SingleIn
|
||||
|
|
@ -38,6 +39,6 @@ class ScreenshotHolder @Inject constructor(
|
|||
fun getFile() = file.takeIf { it.exists() && it.length() > 0 }
|
||||
|
||||
fun reset() {
|
||||
file.delete()
|
||||
file.safeDelete()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue