[Android] Add the app version to the logs for the crash reporter
Nicolas Pomepuy
git at videolan.org
Tue Jul 20 12:17:06 UTC 2021
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Jul 19 11:51:09 2021 +0200| [1f00d66de3647baab4e65e716395ae889b2732f8] | committer: Nicolas Pomepuy
Add the app version to the logs for the crash reporter
> https://code.videolan.org/videolan/vlc-android/commit/1f00d66de3647baab4e65e716395ae889b2732f8
---
.../main/java/org/videolan/resources/util/VLCCrashHandler.kt | 10 ++++++++++
.../vlc-android/src/org/videolan/vlc/DebugLogService.kt | 1 +
2 files changed, 11 insertions(+)
diff --git a/application/resources/src/main/java/org/videolan/resources/util/VLCCrashHandler.kt b/application/resources/src/main/java/org/videolan/resources/util/VLCCrashHandler.kt
index 5de6cb017..05f016ca6 100644
--- a/application/resources/src/main/java/org/videolan/resources/util/VLCCrashHandler.kt
+++ b/application/resources/src/main/java/org/videolan/resources/util/VLCCrashHandler.kt
@@ -20,6 +20,8 @@
package org.videolan.resources.util
+import android.content.pm.PackageInfo
+import android.content.pm.PackageManager
import android.os.Environment
import android.text.format.DateFormat
import android.util.Log
@@ -79,7 +81,15 @@ class VLCCrashHandler : UncaughtExceptionHandler {
val output = OutputStreamWriter(stream)
val bw = BufferedWriter(output)
+ val version = try {
+ val pInfo: PackageInfo = AppContextProvider.appContext.packageManager.getPackageInfo(AppContextProvider.appContext.getPackageName(), 0)
+ pInfo.versionName
+ } catch (e: PackageManager.NameNotFoundException) {
+ e.printStackTrace()
+ }
+
try {
+ bw.write("App version: $version\r\n")
bw.write(log)
bw.newLine()
} catch (e: IOException) {
diff --git a/application/vlc-android/src/org/videolan/vlc/DebugLogService.kt b/application/vlc-android/src/org/videolan/vlc/DebugLogService.kt
index b754651c9..dd6bfc651 100644
--- a/application/vlc-android/src/org/videolan/vlc/DebugLogService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/DebugLogService.kt
@@ -176,6 +176,7 @@ class DebugLogService : Service(), Logcat.Callback, Runnable {
output = OutputStreamWriter(fos)
bw = BufferedWriter(output)
synchronized(this) {
+ bw.write("App version: ${BuildConfig.VLC_VERSION_CODE} / ${BuildConfig.VLC_VERSION_NAME}\r\n")
for (line in logList) {
bw.write(line)
bw.newLine()
More information about the Android
mailing list