Skip to content

Commit

Permalink
feat: Remove tracking and use ACRA for crash logs
Browse files Browse the repository at this point in the history
  • Loading branch information
jmir1 committed Sep 4, 2023
1 parent 4fc7b41 commit 798a22a
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.gradle
/local.properties
/acra.properties
/.idea/workspace.xml
.DS_Store
.idea/
Expand Down
29 changes: 14 additions & 15 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jmailen.gradle.kotlinter.tasks.LintTask
import java.io.FileInputStream
import java.util.Properties

plugins {
id("com.android.application")
Expand All @@ -9,11 +11,6 @@ plugins {
id("com.github.zellius.shortcut-helper")
}

if (gradle.startParameter.taskRequests.toString().contains("Standard")) {
apply<com.google.gms.googleservices.GoogleServicesPlugin>()
apply<com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsPlugin>()
}

shortcutHelper.setFilePath("./shortcuts.xml")

val SUPPORTED_ABIS = setOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
Expand All @@ -33,8 +30,17 @@ android {
buildConfigField("boolean", "INCLUDE_UPDATER", "false")
buildConfigField("boolean", "PREVIEW", "false")

// Please disable ACRA or use your own instance in forked versions of the project
//buildConfigField("String", "ACRA_URI", "\"https://acra.jmir.xyz/report\"")
// Put these fields in acra.properties
val acraProperties = Properties()
rootProject.file("acra.properties")
.takeIf { it.exists() }
?.let { acraProperties.load(FileInputStream(it)) }
val acraUri = acraProperties.getProperty("ACRA_URI", "")
val acraLogin = acraProperties.getProperty("ACRA_LOGIN", "")
val acraPassword = acraProperties.getProperty("ACRA_PASSWORD", "")
buildConfigField("String", "ACRA_URI", "\"$acraUri\"")
buildConfigField("String", "ACRA_LOGIN", "\"$acraLogin\"")
buildConfigField("String", "ACRA_PASSWORD", "\"$acraPassword\"")

ndk {
abiFilters += SUPPORTED_ABIS
Expand Down Expand Up @@ -246,15 +252,8 @@ dependencies {
// Logging
implementation(libs.logcat)

// Crash reports/analytics
// Crash reports
implementation(libs.acra.http)
implementation(libs.firebase.analytics)
implementation(libs.firebase.crashlytics)

// Add the dependencies for the Crashlytics and Analytics libraries
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation("com.google.firebase:firebase-crashlytics-ktx")
implementation("com.google.firebase:firebase-analytics-ktx")

// Shizuku
implementation(libs.bundles.shizuku)
Expand Down
4 changes: 0 additions & 4 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,3 @@

# XmlUtil
-keep public enum nl.adaptivity.xmlutil.EventType { *; }

# Firebase
-keep class com.google.firebase.installations.** { *; }
-keep interface com.google.firebase.installations.** { *; }
9 changes: 0 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
<uses-permission android:name="android.permission.READ_APP_SPECIFIC_LOCALES"
tools:ignore="ProtectedPermissions" />

<!-- Remove permission from Firebase dependency -->
<uses-permission android:name="com.google.android.gms.permission.AD_ID"
tools:node="remove" />

<application
android:name=".App"
android:allowBackup="false"
Expand Down Expand Up @@ -320,11 +316,6 @@
android:name="android.webkit.WebView.MetricsOptOut"
android:value="true" />

<!-- Disable advertising ID collection for Firebase -->
<meta-data
android:name="google_analytics_adid_collection_enabled"
android:value="false" />

</application>

</manifest>
5 changes: 3 additions & 2 deletions app/src/main/java/eu/kanade/domain/base/BasePreferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import android.content.Context
import android.content.pm.PackageManager
import android.os.Build
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.system.isPreviewBuildType
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
import tachiyomi.core.preference.PreferenceStore

class BasePreferences(
Expand All @@ -19,8 +21,7 @@ class BasePreferences(

fun extensionInstaller() = ExtensionInstallerPreference(context, preferenceStore)

// acra is disabled
fun acraEnabled() = preferenceStore.getBoolean("acra.enable", false)
fun acraEnabled() = preferenceStore.getBoolean("acra.enable", isPreviewBuildType || isReleaseBuildType)

fun deviceHasPip() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && context.packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ import eu.kanade.tachiyomi.network.PREF_DOH_QUAD101
import eu.kanade.tachiyomi.network.PREF_DOH_QUAD9
import eu.kanade.tachiyomi.network.PREF_DOH_SHECAN
import eu.kanade.tachiyomi.util.CrashLogUtil
import eu.kanade.tachiyomi.util.system.isPreviewBuildType
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
import eu.kanade.tachiyomi.util.system.isShizukuInstalled
import eu.kanade.tachiyomi.util.system.powerManager
import eu.kanade.tachiyomi.util.system.setDefaultSettings
Expand Down Expand Up @@ -89,7 +91,7 @@ object SettingsAdvancedScreen : SearchableSettings {
pref = basePreferences.acraEnabled(),
title = stringResource(R.string.pref_enable_acra),
subtitle = stringResource(R.string.pref_acra_summary),
enabled = false, // acra is disabled
enabled = isPreviewBuildType || isReleaseBuildType,
),
Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.pref_dump_crash_logs),
Expand Down
26 changes: 23 additions & 3 deletions app/src/main/java/eu/kanade/tachiyomi/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,20 @@ import eu.kanade.tachiyomi.ui.base.delegate.SecureActivityDelegate
import eu.kanade.tachiyomi.util.system.WebViewUtil
import eu.kanade.tachiyomi.util.system.animatorDurationScale
import eu.kanade.tachiyomi.util.system.cancelNotification
import eu.kanade.tachiyomi.util.system.isPreviewBuildType
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
import eu.kanade.tachiyomi.util.system.notify
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import logcat.AndroidLogcatLogger
import logcat.LogPriority
import logcat.LogcatLogger
import org.acra.ACRA
import org.acra.config.httpSender
import org.acra.data.StringFormat
import org.acra.ktx.initAcra
import org.acra.sender.HttpSender
import org.conscrypt.Conscrypt
import tachiyomi.core.util.system.logcat
import tachiyomi.presentation.widget.entries.anime.TachiyomiAnimeWidgetManager
Expand All @@ -70,6 +77,7 @@ class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory {
override fun onCreate() {
super<Application>.onCreate()

setupAcra()
GlobalExceptionHandler.initialize(applicationContext, CrashActivity::class.java)

// TLS 1.3 support for Android < 10
Expand All @@ -90,7 +98,6 @@ class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory {
Injekt.importModule(SYDomainModule())
// SY <--

setupAcra()
setupNotificationChannels()

ProcessLifecycleOwner.get().lifecycle.addObserver(this)
Expand Down Expand Up @@ -203,8 +210,21 @@ class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory {
return super.getPackageName()
}

protected open fun setupAcra() {
// removed acra
private fun setupAcra() {
if (BuildConfig.ACRA_URI.isNotEmpty() && isPreviewBuildType || isReleaseBuildType) {
initAcra {
buildConfigClass = BuildConfig::class.java
excludeMatchingSharedPreferencesKeys = listOf(".*username.*", ".*password.*", ".*token.*")

reportFormat = StringFormat.JSON
httpSender {
uri = BuildConfig.ACRA_URI
basicAuthLogin = BuildConfig.ACRA_LOGIN
basicAuthPassword = BuildConfig.ACRA_PASSWORD
httpMethod = HttpSender.Method.POST
}
}
}
}

private fun setupNotificationChannels() {
Expand Down
2 changes: 0 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
buildscript {
dependencies {
classpath(libs.android.shortcut.gradle)
classpath(libs.google.services.gradle)
classpath(libs.google.crashlytics.gradle)
classpath(libs.aboutLibraries.gradle)
classpath(libs.sqldelight.gradle)
}
Expand Down
4 changes: 0 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ richtext = "0.16.0"
[libraries]
desugar = "com.android.tools:desugar_jdk_libs:2.0.3"
android-shortcut-gradle = "com.github.zellius:android-shortcut-gradle-plugin:0.1.2"
google-services-gradle = "com.google.gms:google-services:4.3.15"
google-crashlytics-gradle = "com.google.firebase:firebase-crashlytics-gradle:2.8.0"

rxandroid = "io.reactivex:rxandroid:1.2.1"
rxjava = "io.reactivex:rxjava:1.3.8"
Expand Down Expand Up @@ -68,8 +66,6 @@ compose-simpleicons = "br.com.devsrsouza.compose.icons.android:simple-icons:1.0.
logcat = "com.squareup.logcat:logcat:0.1"

acra-http = "ch.acra:acra-http:5.9.7"
firebase-analytics = "com.google.firebase:firebase-analytics-ktx:21.2.2"
firebase-crashlytics = "com.google.firebase:firebase-crashlytics-ktx:18.3.1"

aboutLibraries-core = { module = "com.mikepenz:aboutlibraries-core", version.ref = "aboutlib_version" }
aboutLibraries-gradle = { module = "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin", version.ref = "aboutlib_version" }
Expand Down

0 comments on commit 798a22a

Please sign in to comment.