Skip to content

Commit

Permalink
removed email catcher on crashes due to abuse
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Kalderstam <[email protected]>
  • Loading branch information
spacecowboy committed Jan 22, 2025
1 parent 30b678e commit 2fbd336
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 138 deletions.
Original file line number Diff line number Diff line change
@@ -1,54 +1,16 @@
package com.nononsenseapps.feeder.util

import android.content.Intent.ACTION_SENDTO
import android.content.Intent.ACTION_VIEW
import android.content.Intent.EXTRA_EMAIL
import android.content.Intent.EXTRA_SUBJECT
import android.content.Intent.EXTRA_TEXT
import android.net.Uri
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import org.junit.Test
import org.junit.runner.RunWith
import kotlin.test.assertEquals
import kotlin.test.assertTrue

@RunWith(AndroidJUnit4::class)
@MediumTest
class BugReportKTest {
@Test
fun bugIntentIsCorrect() {
val intent = emailBugReportIntent()

assertEquals(ACTION_SENDTO, intent.action)
assertEquals(Uri.parse("mailto:[email protected]"), intent.data)
assertEquals("Bug report for Feeder", intent.getStringExtra(EXTRA_SUBJECT))
assertEquals("[email protected]", intent.getStringExtra(EXTRA_EMAIL))

assertTrue(intent.getStringExtra(EXTRA_TEXT)) {
"Application: " in intent.getStringExtra(EXTRA_TEXT)!!
}
}

@Test
fun crashIntentIsCorrect() {
try {
@Suppress("DIVISION_BY_ZERO")
1 / 0
} catch (e: Exception) {
val intent = emailCrashReportIntent(e)

assertEquals(ACTION_SENDTO, intent.action)
assertEquals(Uri.parse("mailto:[email protected]"), intent.data)
assertEquals("Crash report for Feeder", intent.getStringExtra(EXTRA_SUBJECT))
assertEquals("[email protected]", intent.getStringExtra(EXTRA_EMAIL))

assertTrue(intent.getStringExtra(EXTRA_TEXT)) {
"java.lang.ArithmeticException: divide by zero" in intent.getStringExtra(EXTRA_TEXT)!!
}
}
}

@Test
fun issuesIntentIsCorrect() {
val intent = openGithubIssues()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.app.Activity
import android.content.Intent
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.core.view.WindowCompat
Expand All @@ -22,12 +21,9 @@ import com.nononsenseapps.feeder.ui.compose.utils.withAllProviders
* This activity should only be started via a Send (share) or Open URL/Text intent.
*/
class AddFeedFromShareActivity : DIAwareComponentActivity() {
@OptIn(ExperimentalAnimationApi::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

installExceptionHandler()

WindowCompat.setDecorFitsSystemWindows(window, false)

val initialFeedUrl =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.nononsenseapps.feeder.ui
import android.content.Intent
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.core.net.toUri
Expand All @@ -22,12 +21,9 @@ import com.nononsenseapps.feeder.util.logDebug
* This activity should only be started via a Open File Intent.
*/
class ImportOMPLFileActivity : DIAwareComponentActivity() {
@OptIn(ExperimentalAnimationApi::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

installExceptionHandler()

WindowCompat.setDecorFitsSystemWindows(window, false)

val uri = intent.data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.activity.compose.setContent
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
Expand Down Expand Up @@ -65,8 +64,6 @@ class MainActivity : DIAwareComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

installExceptionHandler()

mainActivityViewModel.ensurePeriodicSyncConfigured()

WindowCompat.setDecorFitsSystemWindows(window, false)
Expand All @@ -78,7 +75,6 @@ class MainActivity : DIAwareComponentActivity() {
}
}

@OptIn(ExperimentalAnimationApi::class)
@Composable
fun AppContent() {
val navController = rememberNavController()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ class ManageSettingsActivity : DIAwareComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

installExceptionHandler()

WindowCompat.setDecorFitsSystemWindows(window, false)

setContent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class OpenLinkInDefaultActivity : DIAwareComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

installExceptionHandler()

intent?.let { intent ->
val uri = intent.data

Expand Down
52 changes: 0 additions & 52 deletions app/src/main/java/com/nononsenseapps/feeder/util/BugReport.kt
Original file line number Diff line number Diff line change
@@ -1,60 +1,8 @@
package com.nononsenseapps.feeder.util

import android.content.Intent
import android.content.Intent.ACTION_SENDTO
import android.content.Intent.ACTION_VIEW
import android.content.Intent.EXTRA_EMAIL
import android.content.Intent.EXTRA_SUBJECT
import android.net.Uri
import android.os.Build
import com.nononsenseapps.feeder.BuildConfig

private fun deviceInfoBlock(): String =
"""
Application: ${BuildConfig.APPLICATION_ID} (flavor ${BuildConfig.BUILD_TYPE.ifBlank { "None" }})
Version: ${BuildConfig.VERSION_NAME} (code ${BuildConfig.VERSION_CODE})
Android: ${Build.VERSION.RELEASE} (SDK ${Build.VERSION.SDK_INT})
Device: ${Build.MANUFACTURER} ${Build.MODEL}
""".trimIndent()

private fun bugBody(): String =
"""
${deviceInfoBlock()}
Hello.
I'd like to report an issue:
""".trimIndent()

private const val EMAIL_REPORT_ADDRESS: String = "[email protected]"

fun emailBugReportIntent(): Intent =
Intent(ACTION_SENDTO).apply {
data = Uri.parse("mailto:$EMAIL_REPORT_ADDRESS")
putExtra(EXTRA_SUBJECT, "Bug report for Feeder")
putExtra(EXTRA_EMAIL, EMAIL_REPORT_ADDRESS)
putExtra(Intent.EXTRA_TEXT, bugBody())
}

private const val CRASH_REPORT_ADDRESS: String = "[email protected]"

private fun crashBody(throwable: Throwable): String =
"""
${deviceInfoBlock()}
Unhandled exception:
${throwable.stackTraceToString()}
""".trimIndent()

fun emailCrashReportIntent(throwable: Throwable): Intent =
Intent(ACTION_SENDTO).apply {
data = Uri.parse("mailto:$CRASH_REPORT_ADDRESS")
putExtra(EXTRA_SUBJECT, "Crash report for Feeder")
putExtra(EXTRA_EMAIL, CRASH_REPORT_ADDRESS)
putExtra(Intent.EXTRA_TEXT, crashBody(throwable))
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}

fun openGithubIssues(): Intent =
Intent(ACTION_VIEW).also {
Expand Down

0 comments on commit 2fbd336

Please sign in to comment.