2023-01-26 11:12:44 -08:00
|
|
|
package co.electriccoin.zcash.crash.android.internal.local
|
2022-05-31 09:38:02 -07:00
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import android.media.MediaScannerConnection
|
|
|
|
import co.electriccoin.zcash.crash.ExceptionPath
|
|
|
|
import co.electriccoin.zcash.crash.ReportableException
|
|
|
|
import co.electriccoin.zcash.crash.android.getExceptionPath
|
|
|
|
import co.electriccoin.zcash.crash.write
|
|
|
|
|
2023-01-26 11:12:44 -08:00
|
|
|
internal object AndroidExceptionReporter {
|
2022-05-31 09:38:02 -07:00
|
|
|
internal suspend fun reportException(context: Context, reportableException: ReportableException) {
|
|
|
|
val exceptionPath = ExceptionPath.getExceptionPath(context, reportableException)
|
|
|
|
?: return
|
|
|
|
|
|
|
|
reportableException.write(exceptionPath)
|
|
|
|
|
|
|
|
// Media Scan necessary for files to immediately show up as visible
|
|
|
|
// Note: must break out of BroadcastReceiver context in order to start media
|
|
|
|
// scanner service.
|
|
|
|
MediaScannerConnection.scanFile(
|
|
|
|
context.applicationContext,
|
|
|
|
arrayOf(exceptionPath.absolutePath),
|
|
|
|
null,
|
|
|
|
null
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|