Skip to content

Commit

Permalink
Save device info always to logcat when creating a bug report
Browse files Browse the repository at this point in the history
Related #2040
  • Loading branch information
tuomas2 committed Jan 7, 2023
1 parent 6593e6d commit ecb0e44
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
13 changes: 2 additions & 11 deletions app/src/main/java/net/bible/android/BibleApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ open class BibleApplication : Application() {
val defaultExceptionHandler = Thread.getDefaultUncaughtExceptionHandler()
Thread.setDefaultUncaughtExceptionHandler { t, e ->
BugReport.saveScreenshot()
logBasicInfo()
BugReport.saveLogcat()
CommonUtils.realSharedPreferences.edit().putBoolean("app-crashed", true).commit()
defaultExceptionHandler.uncaughtException(t, e)
Expand All @@ -112,7 +111,8 @@ open class BibleApplication : Application() {

LocaleProviderManager.setLocaleProvider(MyLocaleProvider)

logBasicInfo()
logSqliteVersion()

// This must be done before accessing JSword to prevent default folders being used
SwordEnvironmentInitialisation.initialiseJSwordFolders()

Expand All @@ -133,15 +133,6 @@ open class BibleApplication : Application() {
localeOverrideAtStartUp = LocaleHelper.getOverrideLanguage(this)
}

private fun logBasicInfo() {
Log.i(TAG, "OS:" + System.getProperty("os.name") + " ver " + System.getProperty("os.version"))
Log.i(TAG, "Java:" + System.getProperty("java.vendor") + " ver " + System.getProperty("java.version"))
Log.i(TAG, "Java home:" + System.getProperty("java.home")!!)
Log.i(TAG, "User dir:" + System.getProperty("user.dir") + " Timezone:" + System.getProperty("user.timezone"))
logSqliteVersion()
Log.i(TAG, BugReport.createErrorText())
}

var sqliteVersion = ""

private fun logSqliteVersion() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ object ErrorReportControl {
const val SCREENSHOT_FILE = "screenshot.webp"

object BugReport {
fun createErrorText(exception: Throwable? = null) = try {
private fun createErrorText(exception: Throwable? = null) = try {
StringBuilder().run {
append("Version: ").append(applicationVersionName).append("\n")
append("Android version: ").append(Build.VERSION.RELEASE).append("\n")
Expand Down Expand Up @@ -169,8 +169,18 @@ object BugReport {

private val logDir get() = File(application.filesDir, "/log")

private fun logBasicInfo() {
Log.i(TAG, "logBasicInfo")
Log.i(TAG, "OS:" + System.getProperty("os.name") + " ver " + System.getProperty("os.version"))
Log.i(TAG, "Java:" + System.getProperty("java.vendor") + " ver " + System.getProperty("java.version"))
Log.i(TAG, "Java home:" + System.getProperty("java.home")!!)
Log.i(TAG, "User dir:" + System.getProperty("user.dir") + " Timezone:" + System.getProperty("user.timezone"))
Log.i(TAG, createErrorText())
}

fun saveLogcat() {
Log.i(TAG, "Trying to save logcat")
logBasicInfo()
val f = File(logDir, "logcat.txt.gz")
val log = StringBuilder()
try {
Expand Down

0 comments on commit ecb0e44

Please sign in to comment.