[Android] Crash reporter: include the crash logs caught by the UncaughtExceptionHandler

Nicolas Pomepuy git at videolan.org
Thu Jul 15 11:23:53 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Jul 15 11:13:18 2021 +0200| [465688b86c1e99e3d5190ac830018a425ed06e0f] | committer: Nicolas Pomepuy

Crash reporter: include the crash logs caught by the UncaughtExceptionHandler

> https://code.videolan.org/videolan/vlc-android/commit/465688b86c1e99e3d5190ac830018a425ed06e0f
---

 .../src/org/videolan/vlc/gui/SendCrashActivity.kt  | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/SendCrashActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/SendCrashActivity.kt
index 3a1a09381..bc1d8b333 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/SendCrashActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/SendCrashActivity.kt
@@ -55,6 +55,7 @@ import org.videolan.vlc.gui.helpers.hf.StoragePermissionsDelegate.Companion.getS
 import org.videolan.vlc.util.FileUtils
 import org.videolan.vlc.util.Permissions
 import java.io.File
+import java.io.IOException
 import java.lang.Runnable
 
 @ObsoleteCoroutinesApi
@@ -91,10 +92,25 @@ class SendCrashActivity : AppCompatActivity(), DebugLogService.Client.Callback {
                 client.stop()
                 if (!::logcatZipPath.isInitialized) {
                     val path = AppContextProvider.appContext.getExternalFilesDir(null)?.absolutePath
-                            ?: return at withContext null
-                    logcatZipPath =  "$path/logcat.zip"
+                        ?: return at withContext null
+                    logcatZipPath = "$path/logcat.zip"
+                }
+                val filesToAdd = mutableListOf(path)
+                //add previous crash logs
+                try {
+                    val folder = AppContextProvider.appContext.getExternalFilesDir(null)?.absolutePath
+                    File(folder).listFiles().forEach {
+                        if (it.isFile && it.name.contains("crash")) filesToAdd.add(it.path)
+                    }
+                } catch (exception: IOException) {
+
+                }
+
+                FileUtils.zip(filesToAdd.toTypedArray(), logcatZipPath)
+                try {
+                    filesToAdd.forEach { FileUtils.deleteFile(it) }
+                } catch (exception: IOException) {
                 }
-                FileUtils.zip(arrayOf(path), logcatZipPath)
 
                 val emailIntent = Intent(Intent.ACTION_SEND_MULTIPLE)
                 emailIntent.type = "message/rfc822"



More information about the Android mailing list