Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Integrate activity for showing past crashes.
Browse files Browse the repository at this point in the history
  • Loading branch information
pocmo committed May 12, 2020
1 parent b2b89bf commit d58c022
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@
android:exported="false">
</activity>

<activity
android:name=".crashes.CrashListActivity"
android:exported="false" />

<activity android:name=".widget.VoiceSearchActivity" />

<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class Analytics(
)

CrashReporter(
context = context,
services = services,
telemetryServices = listOf(GleanCrashReporterService(context)),
shouldPrompt = CrashReporter.Prompt.ALWAYS,
Expand Down
26 changes: 26 additions & 0 deletions app/src/main/java/org/mozilla/fenix/crashes/CrashListActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.mozilla.fenix.crashes

import android.content.Intent
import android.net.Uri
import mozilla.components.lib.crash.CrashReporter
import mozilla.components.lib.crash.ui.AbstractCrashListActivity
import org.mozilla.fenix.ext.components

/**
* Activity showing the list of past crashes.
*/
class CrashListActivity : AbstractCrashListActivity() {
override val crashReporter: CrashReporter by lazy { components.analytics.crashReporter }

override fun onCrashServiceSelected(url: String) {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(url)
intent.`package` = packageName
startActivity(intent)
finish()
}
}
10 changes: 10 additions & 0 deletions app/src/main/java/org/mozilla/fenix/search/SearchController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.mozilla.fenix.search

import android.content.Context
import android.content.Intent
import androidx.navigation.NavController
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.delay
Expand All @@ -22,6 +23,7 @@ import org.mozilla.fenix.components.metrics.Event.PerformedSearch.SearchAccessPo
import org.mozilla.fenix.components.metrics.Event.PerformedSearch.SearchAccessPoint.SUGGESTION
import org.mozilla.fenix.components.metrics.MetricsUtils
import org.mozilla.fenix.components.searchengine.CustomSearchEngineStore
import org.mozilla.fenix.crashes.CrashListActivity
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.metrics
import org.mozilla.fenix.ext.navigateSafe
Expand Down Expand Up @@ -52,6 +54,14 @@ class DefaultSearchController(
) : SearchController {

override fun handleUrlCommitted(url: String) {
if (url == "about:crashes") {
// The list of past crashes can be accessed via "settings > about", but desktop and
// fennec users may be used to navigating to "about:crashes". So we intercept this here
// and open the crash list activity instead.
context.startActivity(Intent(context, CrashListActivity::class.java))
return
}

if (url.isNotBlank()) {
(context as HomeActivity).openToBrowserAndLoad(
searchTermOrURL = url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.crashes.CrashListActivity
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.utils.Do
Expand Down Expand Up @@ -152,6 +153,10 @@ class AboutFragment : Fragment(), AboutPageListener {
SupportUtils.getSumoURLForTopic(context, SupportUtils.SumoTopic.HELP)
), getString(R.string.about_support)
),
AboutPageItem.Item(
AboutItem.Crashes,
getString(R.string.about_crashes)
),
AboutPageItem.Item(
AboutItem.ExternalLink(
PRIVACY_NOTICE,
Expand Down Expand Up @@ -215,6 +220,9 @@ class AboutFragment : Fragment(), AboutPageListener {
requireComponents.analytics.metrics.track(Event.LibrariesThatWeUseTapped)
openLibrariesPage()
}
is AboutItem.Crashes -> {
startActivity(Intent(requireContext(), CrashListActivity::class.java))
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package org.mozilla.fenix.settings.about
sealed class AboutItem {
data class ExternalLink(val type: AboutItemType, val url: String) : AboutItem()
object Libraries : AboutItem()
object Crashes : AboutItem()
}

enum class AboutItemType {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,8 @@

<!-- About page link text to open support link -->
<string name="about_support">Support</string>
<!-- About page link text to list of past crashes (like about:crashes on desktop) -->
<string name="about_crashes">Crashes</string>
<!-- About page link text to open privacy notice link -->
<string name="about_privacy_notice">Privacy notice</string>
<!-- About page link text to open know your rights link -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ internal class BreadcrumbRecorderTest {
@Test
fun `ensure crash reporter recordCrashBreadcrumb is called`() {
val service = object : CrashReporterService {
override val id: String = "test"
override val name: String = "Test"
override fun createCrashReportUrl(identifier: String): String? = null
override fun report(throwable: Throwable, breadcrumbs: ArrayList<Breadcrumb>): String? = ""
override fun report(crash: Crash.NativeCodeCrash): String? = ""
override fun report(crash: Crash.UncaughtExceptionCrash): String? = ""
}

val reporter = spy(
CrashReporter(
context = mock(),
services = listOf(service),
shouldPrompt = CrashReporter.Prompt.NEVER
)
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/AndroidComponents.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

object AndroidComponents {
const val VERSION = "41.0.20200510130109"
const val VERSION = "41.0.20200511120152"
}

0 comments on commit d58c022

Please sign in to comment.