From ec478cbb1bc0a80c18957169cbcc13505d46f37d Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 1 Jan 2024 09:53:21 -0500 Subject: [PATCH] Defer ACRA reporting until device is idle/not low battery/on unmetered network --- app/build.gradle.kts | 2 +- app/src/main/java/eu/kanade/tachiyomi/App.kt | 13 ++++++++++++- gradle/libs.versions.toml | 5 ++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index b3b735dd1..96c7ac385 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -246,7 +246,7 @@ dependencies { implementation(libs.logcat) // Crash reports/analytics - implementation(libs.acra.http) + implementation(libs.bundles.acra) "standardImplementation"(libs.firebase.analytics) // Shizuku diff --git a/app/src/main/java/eu/kanade/tachiyomi/App.kt b/app/src/main/java/eu/kanade/tachiyomi/App.kt index 27235ba64..f155c5bb9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/App.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/App.kt @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi import android.annotation.SuppressLint import android.app.Application import android.app.PendingIntent +import android.app.job.JobInfo import android.content.BroadcastReceiver import android.content.Context import android.content.Intent @@ -51,10 +52,12 @@ import logcat.AndroidLogcatLogger import logcat.LogPriority import logcat.LogcatLogger import org.acra.config.httpSender +import org.acra.config.scheduler import org.acra.ktx.initAcra import org.acra.sender.HttpSender import org.conscrypt.Conscrypt import tachiyomi.core.i18n.stringResource +import tachiyomi.core.preference.Preference import tachiyomi.core.util.system.logcat import tachiyomi.i18n.MR import tachiyomi.presentation.widget.WidgetManager @@ -199,12 +202,20 @@ class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory { if (isPreviewBuildType || isReleaseBuildType) { initAcra { buildConfigClass = BuildConfig::class.java - excludeMatchingSharedPreferencesKeys = listOf(".*username.*", ".*password.*", ".*token.*") + excludeMatchingSharedPreferencesKeys = listOf( + Preference.privateKey(".*"), ".*username.*", ".*password.*", ".*token.*", + ) httpSender { uri = BuildConfig.ACRA_URI httpMethod = HttpSender.Method.PUT } + + scheduler { + requiresBatteryNotLow = true + requiresDeviceIdle = true + requiresNetworkType = JobInfo.NETWORK_TYPE_UNMETERED + } } } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d95133a4d..b04b8cd4b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,6 @@ [versions] aboutlib_version = "10.10.0" +acra = "5.11.3" leakcanary = "2.12" moko = "0.23.0" okhttp_version = "5.0.0-alpha.12" @@ -67,7 +68,8 @@ moko-gradle = { module = "dev.icerock.moko:resources-generator", version.ref = " logcat = "com.squareup.logcat:logcat:0.1" -acra-http = "ch.acra:acra-http:5.11.3" +acra-http = { module = "ch.acra:acra-http", version.ref = "acra" } +acra-scheduler = { module = "ch.acra:acra-advanced-scheduler", version.ref = "acra" } firebase-analytics = "com.google.firebase:firebase-analytics-ktx:21.5.0" aboutLibraries-gradle = { module = "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin", version.ref = "aboutlib_version" } @@ -97,6 +99,7 @@ voyager-transitions = { module = "cafe.adriel.voyager:voyager-transitions", vers ktlint = "org.jlleitschuh.gradle:ktlint-gradle:12.0.3" [bundles] +acra = ["acra-http", "acra-scheduler"] okhttp = ["okhttp-core", "okhttp-logging", "okhttp-brotli", "okhttp-dnsoverhttps"] js-engine = ["quickjs-android"] sqlite = ["sqlite-framework", "sqlite-ktx", "sqlite-android"]