Commit 281a63fd authored by MozLando's avatar MozLando
Browse files

Merge #6739 #6782



6739: Issue #1705: Assign UUID to every crash object. r=rocketsroger a=pocmo

Assigning every crash a unique ID so that we can later reference this crash when saving some metadata about it to disk.

6782: Upgrade to Glean 28.0.0 r=mdboom a=mdboom
Co-authored-by: default avatarSebastian Kaspari <s.kaspari@gmail.com>
Co-authored-by: default avatarMichael Droettboom <mdboom@gmail.com>
......@@ -29,7 +29,7 @@ object Versions {
const val mozilla_appservices = "0.57.0"
const val mozilla_glean = "27.1.0"
const val mozilla_glean = "28.0.0"
const val material = "1.1.0"
const val nearby = "17.0.0"
......
......@@ -7,6 +7,7 @@ package mozilla.components.lib.crash
import android.content.Intent
import android.os.Bundle
import java.io.Serializable
import java.util.UUID
// Intent extra used to store crash data under when passing crashes in Intent objects
private const val INTENT_CRASH = "mozilla.components.lib.crash.CRASH"
......@@ -18,6 +19,7 @@ private const val INTENT_EXCEPTION = "exception"
private const val INTENT_BREADCRUMBS = "breadcrumbs"
// Native code crash intent extras (Mirroring GeckoView values)
private const val INTENT_UUID = "uuid"
private const val INTENT_MINIDUMP_PATH = "minidumpPath"
private const val INTENT_EXTRAS_PATH = "extrasPath"
private const val INTENT_MINIDUMP_SUCCESS = "minidumpSuccess"
......@@ -27,6 +29,11 @@ private const val INTENT_FATAL = "fatal"
* Crash types that are handled by this library.
*/
sealed class Crash {
/**
* Unique ID identifying this crash.
*/
abstract val uuid: String
/**
* A crash caused by an uncaught exception.
*
......@@ -35,17 +42,20 @@ sealed class Crash {
*/
data class UncaughtExceptionCrash(
val throwable: Throwable,
val breadcrumbs: ArrayList<Breadcrumb>
val breadcrumbs: ArrayList<Breadcrumb>,
override val uuid: String = UUID.randomUUID().toString()
) : Crash() {
override fun toBundle() = Bundle().apply {
putString(INTENT_UUID, uuid)
putSerializable(INTENT_EXCEPTION, throwable as Serializable)
putParcelableArrayList(INTENT_BREADCRUMBS, breadcrumbs)
}
companion object {
internal fun fromBundle(bundle: Bundle) = UncaughtExceptionCrash(
bundle.getSerializable(INTENT_EXCEPTION) as Throwable,
bundle.getParcelableArrayList(INTENT_BREADCRUMBS) ?: arrayListOf()
uuid = bundle.getString(INTENT_UUID) as String,
throwable = bundle.getSerializable(INTENT_EXCEPTION) as Throwable,
breadcrumbs = bundle.getParcelableArrayList(INTENT_BREADCRUMBS) ?: arrayListOf()
)
}
}
......@@ -69,9 +79,11 @@ sealed class Crash {
val minidumpSuccess: Boolean,
val extrasPath: String?,
val isFatal: Boolean,
val breadcrumbs: ArrayList<Breadcrumb>
val breadcrumbs: ArrayList<Breadcrumb>,
override val uuid: String = UUID.randomUUID().toString()
) : Crash() {
override fun toBundle() = Bundle().apply {
putString(INTENT_UUID, uuid)
putString(INTENT_MINIDUMP_PATH, minidumpPath)
putBoolean(INTENT_MINIDUMP_SUCCESS, minidumpSuccess)
putString(INTENT_EXTRAS_PATH, extrasPath)
......@@ -81,11 +93,12 @@ sealed class Crash {
companion object {
internal fun fromBundle(bundle: Bundle) = NativeCodeCrash(
bundle.getString(INTENT_MINIDUMP_PATH, null),
bundle.getBoolean(INTENT_MINIDUMP_SUCCESS, false),
bundle.getString(INTENT_EXTRAS_PATH, null),
bundle.getBoolean(INTENT_FATAL, false),
bundle.getParcelableArrayList(INTENT_BREADCRUMBS) ?: arrayListOf()
uuid = bundle.getString(INTENT_UUID) ?: UUID.randomUUID().toString(),
minidumpPath = bundle.getString(INTENT_MINIDUMP_PATH, null),
minidumpSuccess = bundle.getBoolean(INTENT_MINIDUMP_SUCCESS, false),
extrasPath = bundle.getString(INTENT_EXTRAS_PATH, null),
isFatal = bundle.getBoolean(INTENT_FATAL, false),
breadcrumbs = bundle.getParcelableArrayList(INTENT_BREADCRUMBS) ?: arrayListOf()
)
}
}
......
......@@ -20,6 +20,7 @@ class NativeCodeCrashTest {
intent.component = ComponentName(
"org.mozilla.samples.browser",
"mozilla.components.lib.crash.handler.CrashHandlerService")
intent.putExtra("uuid", "afc91225-93d7-4328-b3eb-d26ad5af4d86")
intent.putExtra("minidumpPath",
"/data/data/org.mozilla.samples.browser/files/mozilla/Crash Reports/pending/3ba5f665-8422-dc8e-a88e-fc65c081d304.dmp")
intent.putExtra("fatal", false)
......@@ -29,6 +30,10 @@ class NativeCodeCrashTest {
val crash = Crash.NativeCodeCrash.fromBundle(intent.extras!!)
assertEquals(
"afc91225-93d7-4328-b3eb-d26ad5af4d86",
crash.uuid
)
assertEquals(crash.minidumpSuccess, true)
assertEquals(crash.isFatal, false)
assertEquals(
......@@ -40,4 +45,20 @@ class NativeCodeCrashTest {
crash.extrasPath
)
}
@Test
fun `to and from bundle`() {
val crash = Crash.NativeCodeCrash(
"minidumpPath",
true,
"extrasPath",
true,
arrayListOf()
)
val bundle = crash.toBundle()
val otherCrash = Crash.NativeCodeCrash.fromBundle(bundle)
assertEquals(crash, otherCrash)
}
}
......@@ -20,4 +20,15 @@ class UncaughtExceptionCrashTest {
assertEquals(exception, crash.throwable)
}
@Test
fun `to and from bundle`() {
val exception = RuntimeException("Kaput")
val crash = Crash.UncaughtExceptionCrash(exception, arrayListOf())
val bundle = crash.toBundle()
val otherCrash = Crash.UncaughtExceptionCrash.fromBundle(bundle)
assertEquals(crash, otherCrash)
}
}
......@@ -51,6 +51,10 @@ class CrashHandlerServiceTest {
"org.mozilla.samples.browser",
"mozilla.components.lib.crash.handler.CrashHandlerService"
)
intent?.putExtra(
"uuid",
"94f66ed7-50c7-41d1-96a7-299139a8c2af"
)
intent?.putExtra(
"minidumpPath",
"/data/data/org.mozilla.samples.browser/files/mozilla/Crash Reports/pending/3ba5f665-8422-dc8e-a88e-fc65c081d304.dmp"
......
......@@ -52,6 +52,10 @@ permalink: /changelog/
* **browser-tabstray**
* The iconView is no longer required in the template.
* The URL text for items may be styled.
* **service-glean**
* Glean was updated to v28.0.0
* The baseline ping is now sent when the application goes to foreground, in addition to background and dirty-startup.
* **Developer ergonomics**
* Improved autoPublication workflow. See https://mozac.org/contributing/testing-components-inside-app for updated documentation.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment