From cef26938930d5a867f241fc546b0cad9145f203a Mon Sep 17 00:00:00 2001 From: Yash Garg Date: Mon, 19 Dec 2022 16:38:20 +0530 Subject: [PATCH 1/6] init: add basic setup impl. for sentry --- app/build.gradle.kts | 3 ++- app/src/main/AndroidManifest.xml | 25 ++++++++++++++++--- .../features/launcher/LauncherActivity.java | 2 ++ build.gradle.kts | 1 + gradle/libs.versions.toml | 1 + 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 12b6dddea8..6b7eb9ac46 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -8,11 +8,12 @@ plugins { alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.kapt) alias(libs.plugins.refine) + alias(libs.plugins.sentry) } // Manifest version information val versionMajor = 1 -val versionMinor = 7 +val versionMinor = 8 val versionPatch = 0 val localProps = Properties() diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7b491ec950..b41e95f654 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -43,7 +43,7 @@ - + - + + + + + + + + - diff --git a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java index 13fab3b4d5..8e039b3e2e 100755 --- a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java @@ -162,6 +162,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; import io.reactivex.observers.DisposableObserver; import io.reactivex.schedulers.Schedulers; +import io.sentry.Sentry; import me.relex.circleindicator.CircleIndicator; public class LauncherActivity extends AppCompatActivity @@ -277,6 +278,7 @@ public class LauncherActivity extends AppCompatActivity @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + Sentry.captureMessage("Testing SDK setup"); prepareBroadcastReceivers(); WallpaperManagerCompat.Companion.getInstance(this).addOnChangeListener(this); diff --git a/build.gradle.kts b/build.gradle.kts index 8175349999..ae7fc81e58 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,6 +10,7 @@ plugins { alias(libs.plugins.google.services) apply false alias(libs.plugins.refine) apply false alias(libs.plugins.benmanes.versions) apply false + alias(libs.plugins.sentry) apply false id("foundation.e.blisslauncher.spotless") } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4f55f503c9..cba94831ce 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -80,6 +80,7 @@ google-services = "com.google.gms.google-services:4.3.0" refine = { id = "dev.rikka.tools.refine", version.ref = "refine" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } +sentry = "io.sentry.android.gradle:3.3.0" [bundles] testing-unit = ["arch-core", "junit", "robolectric", "mockito-core"] -- GitLab From 9e3b682bd521aefa7cae63602cda49f088241eb2 Mon Sep 17 00:00:00 2001 From: Yash Garg Date: Tue, 20 Dec 2022 11:16:14 +0530 Subject: [PATCH 2/6] sentry: manually initialize and use SENTRY_DSN from env --- .gitlab-ci.yml | 7 +++++-- app/build.gradle.kts | 11 ++++++++++- app/src/main/AndroidManifest.xml | 18 +++--------------- .../e/blisslauncher/BlissLauncher.java | 14 ++++++++++++++ .../e/blisslauncher/core/Preferences.java | 5 +++++ .../features/launcher/LauncherActivity.java | 2 -- 6 files changed, 37 insertions(+), 20 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b8b3e94da2..39612d9921 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,8 @@ image: "registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:latest" +variables: + SENTRY_DSN: "${SENTRY_DSN}" + stages: - check - build @@ -27,13 +30,13 @@ test: stage: build script: - ./gradlew test - needs: ["spotless", "lint"] + needs: [ "spotless", "lint" ] build: stage: build script: - ./gradlew assembleRelease - needs: ["spotless", "lint"] + needs: [ "spotless", "lint" ] artifacts: paths: - app/build/outputs/apk diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 6b7eb9ac46..c9f7a350f0 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -66,6 +66,10 @@ android { matchingFallbacks += listOf("release") isDebuggable = false } + + configureEach { + buildConfigField("String", "SENTRY_DSN", "\"${System.getenv("SENTRY_DSN")}\"") + } } signingConfigs { @@ -111,7 +115,10 @@ android { kotlinOptions { jvmTarget = "1.8" } - buildFeatures { viewBinding = true } + buildFeatures { + viewBinding = true + buildConfig = true + } lint { abortOnError = false @@ -124,6 +131,8 @@ android { } } +sentry { ignoredBuildTypes.set(setOf("benchmark")) } + dependencies { "apiQImplementation"(files("libs/lineage-sdk-q.jar")) "apiRImplementation"(files("libs/lineage-sdk-r.jar")) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b41e95f654..1336f36d71 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -172,22 +172,10 @@ android:name="android.nfc.disable_beam_default" android:value="true" /> + - - - - - - + android:name="io.sentry.auto-init" + android:value="false" /> { + options.setDsn(BuildConfig.SENTRY_DSN); + options.setEnvironment(BuildConfig.BUILD_TYPE); + options.setSampleRate(1.0); + options.setEnableUserInteractionTracing(true); + options.setProfilesSampleRate(1.0); + }); + } + + Sentry.captureMessage("Testing SDK Setup"); } private void onNotificationSettingsChanged() { diff --git a/app/src/main/java/foundation/e/blisslauncher/core/Preferences.java b/app/src/main/java/foundation/e/blisslauncher/core/Preferences.java index 91c17ebece..4b28cd43e5 100644 --- a/app/src/main/java/foundation/e/blisslauncher/core/Preferences.java +++ b/app/src/main/java/foundation/e/blisslauncher/core/Preferences.java @@ -399,4 +399,9 @@ public class Preferences { public static boolean getAddedPrivacyWidget(Context context) { return getPrefs(context).getBoolean(ADDED_PRIVACY_WIDGET, false); } + + // Read from OS developer options + public static boolean isTelemetryEnabled(Context context) { + return true; + } } diff --git a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java index 8e039b3e2e..13fab3b4d5 100755 --- a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java @@ -162,7 +162,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; import io.reactivex.observers.DisposableObserver; import io.reactivex.schedulers.Schedulers; -import io.sentry.Sentry; import me.relex.circleindicator.CircleIndicator; public class LauncherActivity extends AppCompatActivity @@ -278,7 +277,6 @@ public class LauncherActivity extends AppCompatActivity @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - Sentry.captureMessage("Testing SDK setup"); prepareBroadcastReceivers(); WallpaperManagerCompat.Companion.getInstance(this).addOnChangeListener(this); -- GitLab From 310bafbfeefcc99c34ce9a408abdbb1ef6f96287 Mon Sep 17 00:00:00 2001 From: Yash Garg Date: Wed, 21 Dec 2022 19:21:20 +0530 Subject: [PATCH 3/6] feat: get telemtry setting from developer options --- .../foundation/e/blisslauncher/BlissLauncher.java | 3 +-- .../e/blisslauncher/core/Preferences.java | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java b/app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java index ca7e1eee9a..12ae20fe81 100755 --- a/app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java +++ b/app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java @@ -48,7 +48,7 @@ public class BlissLauncher extends Application { }; getContentResolver().registerContentObserver(NOTIFICATION_BADGING_URI, false, notificationSettingsObserver); - if (Preferences.isTelemetryEnabled(this)) { + if (Preferences.isTelemetryEnabled(getContentResolver())) { SentryAndroid.init(this, options -> { options.setDsn(BuildConfig.SENTRY_DSN); options.setEnvironment(BuildConfig.BUILD_TYPE); @@ -57,7 +57,6 @@ public class BlissLauncher extends Application { options.setProfilesSampleRate(1.0); }); } - Sentry.captureMessage("Testing SDK Setup"); } diff --git a/app/src/main/java/foundation/e/blisslauncher/core/Preferences.java b/app/src/main/java/foundation/e/blisslauncher/core/Preferences.java index 4b28cd43e5..c00f0263d5 100644 --- a/app/src/main/java/foundation/e/blisslauncher/core/Preferences.java +++ b/app/src/main/java/foundation/e/blisslauncher/core/Preferences.java @@ -1,8 +1,11 @@ package foundation.e.blisslauncher.core; +import android.content.ContentResolver; import android.content.Context; import android.content.SharedPreferences; import android.graphics.Color; +import android.provider.Settings; + import foundation.e.blisslauncher.core.utils.Constants; import java.util.ArrayList; import java.util.Locale; @@ -401,7 +404,15 @@ public class Preferences { } // Read from OS developer options - public static boolean isTelemetryEnabled(Context context) { - return true; + public static boolean isTelemetryEnabled(ContentResolver contentResolver) { + final int telemetrySetting; + + try { + telemetrySetting = Settings.System.getInt(contentResolver, "e_telemetry"); + } catch (Settings.SettingNotFoundException e) { + return false; + } + + return telemetrySetting == 1; } } -- GitLab From ae5841dc91841002e8404078055b0414df9b35bc Mon Sep 17 00:00:00 2001 From: Yash Garg Date: Thu, 22 Dec 2022 13:12:40 +0000 Subject: [PATCH 4/6] chore: remove test captureMessage event --- app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java b/app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java index 12ae20fe81..0027980eeb 100755 --- a/app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java +++ b/app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java @@ -16,7 +16,6 @@ import foundation.e.blisslauncher.core.blur.BlurWallpaperProvider; import foundation.e.blisslauncher.core.customviews.WidgetHost; import foundation.e.blisslauncher.features.launcher.AppProvider; import foundation.e.blisslauncher.features.notification.NotificationService; -import io.sentry.Sentry; import io.sentry.android.core.SentryAndroid; public class BlissLauncher extends Application { @@ -57,7 +56,6 @@ public class BlissLauncher extends Application { options.setProfilesSampleRate(1.0); }); } - Sentry.captureMessage("Testing SDK Setup"); } private void onNotificationSettingsChanged() { -- GitLab From 92e54244116c1696a248b0c27339ad4fb8c2a3c7 Mon Sep 17 00:00:00 2001 From: Yash Garg Date: Tue, 3 Jan 2023 14:47:33 +0530 Subject: [PATCH 5/6] refactor: use our library for sentry reporting --- app/build.gradle.kts | 4 +--- .../foundation/e/blisslauncher/BlissLauncher.java | 14 +++----------- build.gradle.kts | 1 - gradle/libs.versions.toml | 1 + settings.gradle.kts | 1 + 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c9f7a350f0..49f6562971 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -8,7 +8,6 @@ plugins { alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.kapt) alias(libs.plugins.refine) - alias(libs.plugins.sentry) } // Manifest version information @@ -131,8 +130,6 @@ android { } } -sentry { ignoredBuildTypes.set(setOf("benchmark")) } - dependencies { "apiQImplementation"(files("libs/lineage-sdk-q.jar")) "apiRImplementation"(files("libs/lineage-sdk-r.jar")) @@ -180,4 +177,5 @@ dependencies { // elib implementation(libs.elib) + implementation(libs.telemetry) } diff --git a/app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java b/app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java index 0027980eeb..e569125b94 100755 --- a/app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java +++ b/app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java @@ -11,12 +11,11 @@ import android.provider.Settings; import foundation.e.blisslauncher.core.DeviceProfile; import foundation.e.blisslauncher.core.IconsHandler; -import foundation.e.blisslauncher.core.Preferences; import foundation.e.blisslauncher.core.blur.BlurWallpaperProvider; import foundation.e.blisslauncher.core.customviews.WidgetHost; import foundation.e.blisslauncher.features.launcher.AppProvider; import foundation.e.blisslauncher.features.notification.NotificationService; -import io.sentry.android.core.SentryAndroid; +import foundation.e.lib.telemetry.Telemetry; public class BlissLauncher extends Application { public static final Uri NOTIFICATION_BADGING_URI = Settings.Secure.getUriFor("notification_badging"); @@ -47,15 +46,8 @@ public class BlissLauncher extends Application { }; getContentResolver().registerContentObserver(NOTIFICATION_BADGING_URI, false, notificationSettingsObserver); - if (Preferences.isTelemetryEnabled(getContentResolver())) { - SentryAndroid.init(this, options -> { - options.setDsn(BuildConfig.SENTRY_DSN); - options.setEnvironment(BuildConfig.BUILD_TYPE); - options.setSampleRate(1.0); - options.setEnableUserInteractionTracing(true); - options.setProfilesSampleRate(1.0); - }); - } + Telemetry.INSTANCE.init(BuildConfig.SENTRY_DSN, this); + Telemetry.INSTANCE.reportMessage("Sentry Test Message"); } private void onNotificationSettingsChanged() { diff --git a/build.gradle.kts b/build.gradle.kts index ae7fc81e58..8175349999 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,6 @@ plugins { alias(libs.plugins.google.services) apply false alias(libs.plugins.refine) apply false alias(libs.plugins.benmanes.versions) apply false - alias(libs.plugins.sentry) apply false id("foundation.e.blisslauncher.spotless") } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cba94831ce..7f4b0cc59f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -70,6 +70,7 @@ tools-leakcanary = "com.squareup.leakcanary:leakcanary-android:2.10" timber = "com.jakewharton.timber:timber:4.7.1" restriction-bypass = "com.github.ChickenHook:RestrictionBypass:2.2" elib = "foundation.e:elib:0.0.1-alpha11" +telemetry = "foundation.e.lib:telemetry:0.0.2-alpha" [plugins] android-application = { id = "com.android.application", version.ref = "agp" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 30180ce9c6..91b8088cd0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -17,6 +17,7 @@ dependencyResolutionManagement { mavenCentral() jcenter() maven("https://gitlab.e.foundation/api/v4/groups/9/-/packages/maven") + maven("https://gitlab.e.foundation/api/v4/projects/1391/packages/maven") maven("https://jitpack.io") } } -- GitLab From 938c53d75d8300357430fcbff4485c34141a0121 Mon Sep 17 00:00:00 2001 From: Yash Garg Date: Tue, 3 Jan 2023 15:16:45 +0530 Subject: [PATCH 6/6] remove unneeded settings check function --- app/src/main/AndroidManifest.xml | 5 ----- .../e/blisslauncher/BlissLauncher.java | 1 - .../e/blisslauncher/core/Preferences.java | 16 ---------------- gradle/libs.versions.toml | 3 +-- settings.gradle.kts | 1 - 5 files changed, 1 insertion(+), 25 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1336f36d71..ae712d85e2 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -172,11 +172,6 @@ android:name="android.nfc.disable_beam_default" android:value="true" /> - - -