Work on Sentry, fix some crashing

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/263/head
androidacy-user 1 year ago
parent e2e4b952f9
commit dbf0d6d35c

@ -31,8 +31,8 @@ android {
applicationId "com.fox2code.mmm"
minSdk 23
targetSdk 33
versionCode 63
versionName "1.0.3"
versionCode 64
versionName "1.1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.release
archivesBaseName = "FoxMMM-v$versionName"
@ -251,7 +251,6 @@ dependencies {
implementation 'androidx.work:work-runtime:2.7.1'
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.10'
implementation 'com.squareup.okhttp3:okhttp-dnsoverhttps:5.0.0-alpha.10'
implementation 'com.squareup.okhttp3:okhttp-brotli:5.0.0-alpha.10'
// Chromium cronet from androidacy
implementation 'com.androidacy:cronet-common:108.0.5359.125'
implementation 'com.androidacy:cronet-native:108.0.5359.125'
@ -292,25 +291,7 @@ if (hasSentryConfig) {
}
}
final String sentrySrc = hasSentryConfig ? 'src/sentry/java' : 'src/sentryless/java'
final String sentryManifestSrc = hasSentryConfig ? 'src/sentry/AndroidManifest.xml' : 'src/sentryless/AndroidManifest.xml'
android {
sourceSets {
main {
java.srcDirs += sentrySrc
// manifest.srcFile += sentryManifestSrc // Not supported
}
// Workaround useless gradle restriction
"default" {
manifest.srcFile sentryManifestSrc
}
fdroid {
manifest.srcFile sentryManifestSrc
}
}
ndkVersion '25.1.8937393'
dependenciesInfo {
includeInApk false

@ -3,6 +3,8 @@
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="QueryAllPackagesPermission">
<uses-sdk tools:overrideLibrary="io.sentry.android" />
<queries>
<intent>
<action android:name="com.fox2code.mmm.utils.intent.action.OPEN_EXTERNAL" />
@ -122,5 +124,36 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/shared_file_paths" />
</provider>
<meta-data
android:name="io.sentry.auto-init"
android:value="false" />
<meta-data
android:name="io.sentry.dsn"
android:value="https://198c68516cb0412b9832204631a3fac8@o993586.ingest.sentry.io/4504069942804480" />
<!-- Sane value, but feel free to lower it -->
<meta-data
android:name="io.sentry.traces.sample-rate"
android:value="0.5" />
<!-- Doesn't actually monitor anything, just used to get the activities the user went through -->
<meta-data
android:name="io.sentry.traces.user-interaction.enable"
android:value="true" />
<!-- Just a screenshot of ONLY the current activity at the time of the crash -->
<meta-data
android:name="io.sentry.attach-screenshot"
android:value="true" />
<!-- Just the current activity at the time of the crash -->
<meta-data
android:name="io.sentry.attach-stacktrace"
android:value="true" />
<!-- Don't send PII, this is actually default but let's be explicit -->
<meta-data
android:name="io.sentry.sendDefaultPii"
android:value="false" />
<meta-data
android:name="io.sentry.traces.profiling.sample-rate"
android:value="0.25" />
</application>
</manifest>

@ -25,9 +25,9 @@ import com.fox2code.foxcompat.FoxApplication;
import com.fox2code.foxcompat.FoxThemeWrapper;
import com.fox2code.foxcompat.internal.FoxProcessExt;
import com.fox2code.mmm.installer.InstallerInitializer;
import com.fox2code.mmm.sentry.SentryMain;
import com.fox2code.mmm.utils.GMSProviderInstaller;
import com.fox2code.mmm.utils.Http;
import com.fox2code.mmm.utils.SentryMain;
import com.fox2code.rosettax.LanguageSwitcher;
import com.topjohnwu.superuser.Shell;
@ -138,7 +138,7 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
}
public static boolean isBlurEnabled() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && getSharedPreferences().getBoolean("pref_enable_blur", false);
return getSharedPreferences().getBoolean("pref_enable_blur", false);
}
public static boolean isDeveloper() {
@ -313,13 +313,14 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
}
SentryMain.initialize(this);
if (Objects.equals(BuildConfig.ANDROIDACY_CLIENT_ID, "")) {
Log.w("MainApplication", "Androidacy client id is empty! Please set it in androidacy" + ".properties. Will not enable Androidacy.");
Log.w("MainApplication", "Androidacy client id is empty! Please set it in androidacy.properties. Will not enable Androidacy.");
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean("pref_androidacy_repo_enabled", false);
editor.apply();
}
}
@SuppressWarnings("unused")
private Intent getIntent() {
return this.getPackageManager().getLaunchIntentForPackage(this.getPackageName());
}
@ -363,7 +364,9 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
for (String s : children) {
if (BuildConfig.DEBUG) Log.w("MainApplication", "Deleting " + s);
if (!s.equals("lib")) {
new File(cacheDir, s).delete();
if (!new File(cacheDir, s).delete()) {
if (BuildConfig.DEBUG) Log.w("MainApplication", "Failed to delete " + s);
}
}
}
}

@ -26,14 +26,14 @@ import com.fox2code.mmm.R;
import com.fox2code.mmm.XHooks;
import com.fox2code.mmm.androidacy.AndroidacyUtil;
import com.fox2code.mmm.module.ActionButtonType;
import com.fox2code.mmm.sentry.SentryBreadcrumb;
import com.fox2code.mmm.sentry.SentryMain;
import com.fox2code.mmm.utils.FastException;
import com.fox2code.mmm.utils.Files;
import com.fox2code.mmm.utils.Hashes;
import com.fox2code.mmm.utils.Http;
import com.fox2code.mmm.utils.IntentHelper;
import com.fox2code.mmm.utils.PropUtils;
import com.fox2code.mmm.utils.SentryBreadcrumb;
import com.fox2code.mmm.utils.SentryMain;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
import com.google.android.material.progressindicator.LinearProgressIndicator;

@ -59,11 +59,11 @@ import com.fox2code.mmm.repo.CustomRepoData;
import com.fox2code.mmm.repo.CustomRepoManager;
import com.fox2code.mmm.repo.RepoData;
import com.fox2code.mmm.repo.RepoManager;
import com.fox2code.mmm.sentry.SentryMain;
import com.fox2code.mmm.utils.ExternalHelper;
import com.fox2code.mmm.utils.Http;
import com.fox2code.mmm.utils.IntentHelper;
import com.fox2code.mmm.utils.ProcessHelper;
import com.fox2code.mmm.utils.SentryMain;
import com.fox2code.rosettax.LanguageActivity;
import com.fox2code.rosettax.LanguageSwitcher;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;

@ -1,4 +1,4 @@
package com.fox2code.mmm.sentry;
package com.fox2code.mmm.utils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -9,7 +9,7 @@ import io.sentry.Breadcrumb;
import io.sentry.SentryLevel;
public class SentryBreadcrumb {
final Breadcrumb breadcrumb;
public final Breadcrumb breadcrumb;
public SentryBreadcrumb() {
breadcrumb = new Breadcrumb();

@ -1,4 +1,4 @@
package com.fox2code.mmm.sentry;
package com.fox2code.mmm.utils;
import android.annotation.SuppressLint;
import android.content.Context;
@ -25,6 +25,11 @@ public class SentryMain {
*/
@SuppressLint({"RestrictedApi", "UnspecifiedImmutableFlag"})
public static void initialize(final MainApplication mainApplication) {
// If first_launch pref is not false, refuse to initialize Sentry
SharedPreferences sharedPreferences = MainApplication.getSharedPreferences();
if (sharedPreferences.getBoolean("first_launch", true)) {
return;
}
Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> {
SharedPreferences.Editor editor = mainApplication.getSharedPreferences("sentry", Context.MODE_PRIVATE).edit();
editor.putString("lastExitReason", "crash");
@ -58,9 +63,9 @@ public class SentryMain {
// With this callback, you can modify the event or, when returning null, also discard the event.
options.setBeforeSend((event, hint) -> {
// Save lastEventId to private shared preferences
SharedPreferences sharedPreferences = MainApplication.getINSTANCE().getSharedPreferences("sentry", Context.MODE_PRIVATE);
SharedPreferences sentryPrefs = MainApplication.getINSTANCE().getSharedPreferences("sentry", Context.MODE_PRIVATE);
String lastEventId = Objects.requireNonNull(event.getEventId()).toString();
SharedPreferences.Editor editor = sharedPreferences.edit();
SharedPreferences.Editor editor = sentryPrefs.edit();
editor.putString("lastEventId", lastEventId);
editor.apply();
return event;
@ -79,7 +84,7 @@ public class SentryMain {
});
}
public static void addSentryBreadcrumb(SentryBreadcrumb sentryBreadcrumb) {
public static void addSentryBreadcrumb(com.fox2code.mmm.utils.SentryBreadcrumb sentryBreadcrumb) {
if (MainApplication.isCrashReportingEnabled()) {
Sentry.addBreadcrumb(sentryBreadcrumb.breadcrumb);
}

@ -69,6 +69,7 @@
android:layout_marginRight="12dp"
android:layout_marginBottom="8dp"
android:gravity="right"
android:filterTouchesWhenObscured="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_fitsSystemWindowsInsets="bottom"

@ -1,16 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:gravity="center_vertical"
android:orientation="vertical"
tools:ignore="RtlHardcoded,RtlSymmetry">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="2dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="2dp"
android:filterTouchesWhenObscured="true"
android:gravity="center_vertical"
android:orientation="vertical"
tools:ignore="RtlHardcoded,RtlSymmetry">
<com.google.android.material.card.MaterialCardView
android:id="@+id/card_view"

Loading…
Cancel
Save