Move DebugInformationDumper from :app to :base
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package de.mm20.launcher2.fragment
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
@@ -12,7 +11,7 @@ import androidx.preference.PreferenceFragmentCompat
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import de.mm20.launcher2.R
|
||||
import de.mm20.launcher2.crashreporter.CrashReporter
|
||||
import de.mm20.launcher2.helper.DebugInformationDumper
|
||||
import de.mm20.launcher2.debug.DebugInformationDumper
|
||||
import de.mm20.launcher2.licenses.AppLicense
|
||||
import de.mm20.launcher2.licenses.OpenSourceLicenses
|
||||
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package de.mm20.launcher2.helper
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
class DebugInformationDumper {
|
||||
|
||||
fun dump(context: Context): String {
|
||||
val df = SimpleDateFormat("yyyy-MM-dd-HHmmss")
|
||||
val file = File(context.getExternalFilesDir(null), "kvaesitso-log-${df.format(Date(System.currentTimeMillis()))}")
|
||||
val fos = file.outputStream().writer()
|
||||
fos.write("Device: ${Build.DEVICE}\n")
|
||||
fos.write("SDK version: ${Build.VERSION.SDK_INT}\n")
|
||||
fos.write("====================================\n")
|
||||
Thread {
|
||||
val input = Runtime.getRuntime().exec("/system/bin/sh -c logcat").inputStream.bufferedReader()
|
||||
var line = input.readLine()
|
||||
while (line != null) {
|
||||
line = input.readLine()
|
||||
fos.write("$line\n")
|
||||
}
|
||||
fos.close()
|
||||
}.start()
|
||||
return file.absolutePath
|
||||
}
|
||||
|
||||
fun exportDatabases(context: Context): String {
|
||||
val df = SimpleDateFormat("yyyy-MM-dd-HHmmss")
|
||||
val exportFile = File(context.getExternalFilesDir(null), "room-${df.format(Date(System.currentTimeMillis()))}.db")
|
||||
GlobalScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
context.getDatabasePath("room").copyTo(exportFile)
|
||||
}
|
||||
}
|
||||
return exportFile.absolutePath
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user