diff --git a/app/src/main/java/com/fox2code/mmm/MainActivity.java b/app/src/main/java/com/fox2code/mmm/MainActivity.java
index 0b0f1bd..57bcc17 100644
--- a/app/src/main/java/com/fox2code/mmm/MainActivity.java
+++ b/app/src/main/java/com/fox2code/mmm/MainActivity.java
@@ -50,7 +50,6 @@ import com.fox2code.mmm.utils.BlurUtils;
import com.fox2code.mmm.utils.ExternalHelper;
import com.fox2code.mmm.utils.Http;
import com.fox2code.mmm.utils.IntentHelper;
-import com.fox2code.mmm.utils.NoodleDebug;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.progressindicator.LinearProgressIndicator;
@@ -71,7 +70,6 @@ import io.sentry.Sentry;
public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRefreshListener, SearchView.OnQueryTextListener, SearchView.OnCloseListener, OverScrollManager.OverScrollHelper {
private static final String TAG = "MainActivity";
private static final int PRECISION = 10000;
- public static boolean noodleDebugState = BuildConfig.DEBUG;
public final ModuleViewListBuilder moduleViewListBuilder;
public LinearProgressIndicator progressIndicator;
private ModuleViewAdapter moduleViewAdapter;
@@ -87,7 +85,6 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
private RecyclerView moduleList;
private CardView searchCard;
private SearchView searchView;
- private NoodleDebug noodleDebug;
private boolean initMode;
public MainActivity() {
@@ -104,7 +101,8 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
@Override
protected void onCreate(Bundle savedInstanceState) {
this.initMode = true;
- noodleDebugState = MainApplication.isDeveloper();
+ // Ensure HTTP Cache directories are created
+ Http.ensureCacheDirs(this);
BackgroundUpdateChecker.onMainActivityCreate(this);
super.onCreate(savedInstanceState);
this.setActionBarExtraMenuButton(R.drawable.ic_baseline_settings_24, v -> {
@@ -132,7 +130,6 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
this.moduleList = findViewById(R.id.module_list);
this.searchCard = findViewById(R.id.search_card);
this.searchView = findViewById(R.id.search_bar);
- this.noodleDebug = new NoodleDebug(this, R.id.noodle_debug);
this.moduleViewAdapter = new ModuleViewAdapter();
this.moduleList.setAdapter(this.moduleViewAdapter);
this.moduleList.setLayoutManager(new LinearLayoutManager(this));
@@ -290,6 +287,7 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
dialog.cancel();
}
preferences.edit().remove("lastEventId").apply();
+ preferences.edit().putString("lastExitReason", "").apply();
// Prevent strict mode violation
new Thread(() -> {
try {
@@ -439,8 +437,6 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
@Override
public void onFailure(int error) {
moduleViewListBuilder.addNotification(InstallerInitializer.getErrorNotification());
- noodleDebug.setEnabled(noodleDebugState);
- noodleDebug.bind();
this.commonNext();
}
diff --git a/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyActivity.java b/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyActivity.java
index 7a16cb6..bab4ffe 100644
--- a/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyActivity.java
+++ b/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyActivity.java
@@ -258,7 +258,7 @@ public final class AndroidacyActivity extends FoxActivity {
break;
}
}
- return super.onConsoleMessage(consoleMessage);
+ return true;
}
@Override
diff --git a/app/src/main/java/com/fox2code/mmm/background/BackgroundBootListener.java b/app/src/main/java/com/fox2code/mmm/background/BackgroundBootListener.java
index dd2a703..4a69990 100644
--- a/app/src/main/java/com/fox2code/mmm/background/BackgroundBootListener.java
+++ b/app/src/main/java/com/fox2code/mmm/background/BackgroundBootListener.java
@@ -13,10 +13,12 @@ public class BackgroundBootListener extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
if (!BOOT_COMPLETED.equals(intent.getAction())) return;
synchronized (BackgroundUpdateChecker.lock) {
- BackgroundUpdateChecker.onMainActivityCreate(context);
- if (MainApplication.isBackgroundUpdateCheckEnabled()) {
- BackgroundUpdateChecker.doCheck(context);
- }
+ new Thread(() -> {
+ BackgroundUpdateChecker.onMainActivityCreate(context);
+ if (MainApplication.isBackgroundUpdateCheckEnabled()) {
+ BackgroundUpdateChecker.doCheck(context);
+ }
+ }).start();
}
}
}
diff --git a/app/src/main/java/com/fox2code/mmm/background/BackgroundUpdateChecker.java b/app/src/main/java/com/fox2code/mmm/background/BackgroundUpdateChecker.java
index d99ffb7..5f79d11 100644
--- a/app/src/main/java/com/fox2code/mmm/background/BackgroundUpdateChecker.java
+++ b/app/src/main/java/com/fox2code/mmm/background/BackgroundUpdateChecker.java
@@ -4,7 +4,6 @@ import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
-import android.os.StrictMode;
import androidx.annotation.NonNull;
import androidx.core.app.NotificationChannelCompat;
@@ -54,10 +53,7 @@ public class BackgroundUpdateChecker extends Worker {
}
static void doCheck(Context context) {
- // This is actually not recommended but it's the only way to do it
- StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
- StrictMode.setThreadPolicy(policy);
- Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
+ Thread.currentThread().setPriority(2);
ModuleManager.getINSTANCE().scanAsync();
RepoManager.getINSTANCE().update(null);
ModuleManager.getINSTANCE().runAfterScan(() -> {
diff --git a/app/src/main/java/com/fox2code/mmm/manager/ModuleManager.java b/app/src/main/java/com/fox2code/mmm/manager/ModuleManager.java
index dedb516..df4f53e 100644
--- a/app/src/main/java/com/fox2code/mmm/manager/ModuleManager.java
+++ b/app/src/main/java/com/fox2code/mmm/manager/ModuleManager.java
@@ -8,8 +8,6 @@ import androidx.annotation.NonNull;
import com.fox2code.mmm.BuildConfig;
import com.fox2code.mmm.MainApplication;
import com.fox2code.mmm.installer.InstallerInitializer;
-import com.fox2code.mmm.utils.Http;
-import com.fox2code.mmm.utils.NoodleDebug;
import com.fox2code.mmm.utils.PropUtils;
import com.fox2code.mmm.utils.SyncManager;
import com.topjohnwu.superuser.Shell;
@@ -24,33 +22,34 @@ import java.util.HashMap;
import java.util.Iterator;
public final class ModuleManager extends SyncManager {
- private static final String TAG = "ModuleManager";
-
// New method is not really effective, this flag force app to use old method
public static final boolean FORCE_NEED_FALLBACK = true;
+ private static final String TAG = "ModuleManager";
private static final int FLAG_MM_INVALID = ModuleInfo.FLAG_METADATA_INVALID;
private static final int FLAG_MM_UNPROCESSED = ModuleInfo.FLAG_CUSTOM_INTERNAL;
private static final int FLAGS_KEEP_INIT = FLAG_MM_UNPROCESSED |
ModuleInfo.FLAGS_MODULE_ACTIVE | ModuleInfo.FLAG_MODULE_UPDATING_ONLY;
private static final int FLAGS_RESET_UPDATE = FLAG_MM_INVALID | FLAG_MM_UNPROCESSED;
+ private static final ModuleManager INSTANCE = new ModuleManager();
private final HashMap moduleInfos;
private final SharedPreferences bootPrefs;
private int updatableModuleCount = 0;
- private static final ModuleManager INSTANCE = new ModuleManager();
+ private ModuleManager() {
+ this.moduleInfos = new HashMap<>();
+ this.bootPrefs = MainApplication.getBootSharedPreferences();
+ }
public static ModuleManager getINSTANCE() {
return INSTANCE;
}
- private ModuleManager() {
- this.moduleInfos = new HashMap<>();
- this.bootPrefs = MainApplication.getBootSharedPreferences();
+ public static boolean isModuleActive(String moduleId) {
+ ModuleInfo moduleInfo = ModuleManager.getINSTANCE().getModules().get(moduleId);
+ return moduleInfo != null && (moduleInfo.flags & ModuleInfo.FLAGS_MODULE_ACTIVE) != 0;
}
protected void scanInternal(@NonNull UpdateListener updateListener) {
- NoodleDebug noodleDebug = NoodleDebug.getNoodleDebug();
- noodleDebug.push("Initialize scan");
boolean firstScan = this.bootPrefs.getBoolean("mm_first_scan", true);
SharedPreferences.Editor editor = firstScan ? this.bootPrefs.edit() : null;
for (ModuleInfo v : this.moduleInfos.values()) {
@@ -73,7 +72,6 @@ public final class ModuleManager extends SyncManager {
}
if (BuildConfig.DEBUG) Log.d("NoodleDebug", "Scan");
if (modules != null) {
- noodleDebug.push("");
for (String module : modules) {
if (!new SuFile("/data/adb/modules/" + module).isDirectory())
continue; // Ignore non directory files inside modules folder
@@ -123,7 +121,6 @@ public final class ModuleManager extends SyncManager {
if (BuildConfig.DEBUG) Log.d("NoodleDebug", "Scan update");
String[] modules_update = new SuFile("/data/adb/modules_update").list();
if (modules_update != null) {
- noodleDebug.push("");
for (String module : modules_update) {
if (!new SuFile("/data/adb/modules_update/" + module).isDirectory())
continue; // Ignore non directory files inside modules folder
@@ -148,7 +145,6 @@ public final class ModuleManager extends SyncManager {
this.updatableModuleCount = 0;
Iterator moduleInfoIterator =
this.moduleInfos.values().iterator();
- noodleDebug.push("");
while (moduleInfoIterator.hasNext()) {
LocalModuleInfo moduleInfo = moduleInfoIterator.next();
if (BuildConfig.DEBUG) Log.d("NoodleDebug", moduleInfo.id);
@@ -232,7 +228,7 @@ public final class ModuleManager extends SyncManager {
try { // Check for module that declare having file outside their own folder.
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(
SuFileInputStream.open("/data/adb/modules/." + moduleInfo.id + "-files"),
- StandardCharsets.UTF_8))) {
+ StandardCharsets.UTF_8))) {
String line;
while ((line = bufferedReader.readLine()) != null) {
line = line.trim().replace(' ', '.');
@@ -245,16 +241,12 @@ public final class ModuleManager extends SyncManager {
Shell.cmd("rm -rf \"" + line + "\"").exec();
}
}
- } catch (IOException ignored) {}
+ } catch (IOException ignored) {
+ }
Shell.cmd("rm -rf /data/adb/modules/" + escapedId + "/").exec();
Shell.cmd("rm -f /data/adb/modules/." + escapedId + "-files").exec();
Shell.cmd("rm -rf /data/adb/modules_update/" + escapedId + "/").exec();
moduleInfo.flags = ModuleInfo.FLAG_METADATA_INVALID;
return true;
}
-
- public static boolean isModuleActive(String moduleId) {
- ModuleInfo moduleInfo = ModuleManager.getINSTANCE().getModules().get(moduleId);
- return moduleInfo != null && (moduleInfo.flags & ModuleInfo.FLAGS_MODULE_ACTIVE) != 0;
- }
}
diff --git a/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java b/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java
index 2e27722..2fcba7f 100644
--- a/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java
+++ b/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java
@@ -537,6 +537,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
// Use MaterialAlertDialogBuilder
new MaterialAlertDialogBuilder(this.requireContext())
.setTitle(R.string.warning)
+ .setCancelable(false)
.setMessage(R.string.androidacy_test_mode_warning)
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
// User clicked OK button
@@ -575,6 +576,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
// Show dialog to restart app with ok button
new MaterialAlertDialogBuilder(this.requireContext())
.setTitle(R.string.warning)
+ .setCancelable(false)
.setMessage(R.string.androidacy_test_mode_disable_warning)
.setNeutralButton(android.R.string.ok, (dialog, which) -> {
// User clicked OK button
@@ -609,6 +611,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
androidacyRepoEnabled.setOnPreferenceClickListener(preference -> {
new MaterialAlertDialogBuilder(this.requireContext())
.setTitle(R.string.androidacy_repo_disabled)
+ .setCancelable(false)
.setMessage(R.string.androidacy_repo_disabled_message)
.setPositiveButton(R.string.download_full_app, (dialog, which) -> {
// User clicked OK button. Open GitHub releases page
@@ -664,6 +667,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
// Show dialog to restart app with ok button
new MaterialAlertDialogBuilder(this.requireContext())
.setTitle(R.string.restart)
+ .setCancelable(false)
.setMessage(R.string.api_key_restart)
.setNeutralButton(android.R.string.ok, (dialog, which) -> {
// User clicked OK button
@@ -721,6 +725,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
// Show dialog to restart app with ok button
new MaterialAlertDialogBuilder(this.requireContext())
.setTitle(R.string.restart)
+ .setCancelable(false)
.setMessage(R.string.api_key_restart)
.setNeutralButton(android.R.string.ok, (dialog, which) -> {
// User clicked OK button
diff --git a/app/src/main/java/com/fox2code/mmm/utils/Http.java b/app/src/main/java/com/fox2code/mmm/utils/Http.java
index f8a22d1..6affed8 100644
--- a/app/src/main/java/com/fox2code/mmm/utils/Http.java
+++ b/app/src/main/java/com/fox2code/mmm/utils/Http.java
@@ -15,6 +15,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.fox2code.mmm.BuildConfig;
+import com.fox2code.mmm.MainActivity;
import com.fox2code.mmm.MainApplication;
import com.fox2code.mmm.androidacy.AndroidacyUtil;
import com.fox2code.mmm.installer.InstallerInitializer;
@@ -341,6 +342,29 @@ public class Http {
return hasWebView;
}
+ public static void ensureCacheDirs(MainActivity mainActivity) {
+ File cacheDir = mainActivity.getCacheDir();
+ File cacheDir2 = new File(cacheDir, "HTTP Cache");
+ if (!cacheDir2.exists()) {
+ if (!cacheDir2.mkdirs()) {
+ Log.e(TAG, "Failed to create cache dir");
+ }
+ }
+ // Ensure js and wasm cache dirs
+ File jsCacheDir = new File(cacheDir2, "js");
+ if (!jsCacheDir.exists()) {
+ if (!jsCacheDir.mkdirs()) {
+ Log.e(TAG, "Failed to create js cache dir");
+ }
+ }
+ File wasmCacheDir = new File(cacheDir2, "wasm");
+ if (!wasmCacheDir.exists()) {
+ if (!wasmCacheDir.mkdirs()) {
+ Log.e(TAG, "Failed to create wasm cache dir");
+ }
+ }
+ }
+
public interface ProgressListener {
void onUpdate(int downloaded, int total, boolean done);
}
diff --git a/app/src/main/java/com/fox2code/mmm/utils/NoodleDebug.java b/app/src/main/java/com/fox2code/mmm/utils/NoodleDebug.java
deleted file mode 100644
index 7ca52b4..0000000
--- a/app/src/main/java/com/fox2code/mmm/utils/NoodleDebug.java
+++ /dev/null
@@ -1,171 +0,0 @@
-package com.fox2code.mmm.utils;
-
-import android.annotation.SuppressLint;
-import android.app.Activity;
-import android.util.Log;
-import android.widget.TextView;
-
-import androidx.annotation.IdRes;
-import androidx.annotation.NonNull;
-
-import java.lang.ref.WeakReference;
-import java.util.LinkedList;
-import java.util.Objects;
-
-public class NoodleDebug {
- private static final String TAG = "NoodleDebug";
- private static final WeakReference NULL_THREAD_REF = new WeakReference<>(null);
- private static final ThreadLocal THREAD_NOODLE = new ThreadLocal<>();
- @SuppressLint("StaticFieldLeak") // <- Null initialized
- private static final NoodleDebug NULL = new NoodleDebug() {
- @Override
- public NoodleDebug bind() {
- getNoodleDebug().unbind();
- THREAD_NOODLE.remove();
- return this;
- }
-
- @Override
- public void setEnabled(boolean enabled) {}
-
- @Override
- protected void markDirty() {}
- };
- private final Activity activity;
- private final TextView textView;
- private final LinkedList tokens;
- private final StringBuilder debug;
- private WeakReference thread;
- private boolean enabled, updating;
-
- private NoodleDebug() {
- this.activity = null;
- this.textView = null;
- this.tokens = new LinkedList<>();
- this.debug = new StringBuilder(0);
- this.thread = NULL_THREAD_REF;
- }
-
- public NoodleDebug(Activity activity,@IdRes int textViewId) {
- this(activity, activity.findViewById(textViewId));
- }
-
- public NoodleDebug(Activity activity, TextView textView) {
- this.activity = Objects.requireNonNull(activity);
- this.textView = Objects.requireNonNull(textView);
- this.tokens = new LinkedList<>();
- this.debug = new StringBuilder(64);
- this.thread = NULL_THREAD_REF;
- }
-
- public NoodleDebug bind() {
- synchronized (this.tokens) {
- Thread thread;
- if ((thread = this.thread.get()) != null) {
- Log.e(TAG, "Trying to bind to thread \"" + Thread.currentThread().getName() +
- "\" while already bound to \"" + thread.getName() + "\"");
- return NULL;
- }
- this.tokens.clear();
- }
- if (this.enabled) {
- this.thread = new WeakReference<>(Thread.currentThread());
- THREAD_NOODLE.set(this);
- } else {
- this.thread = NULL_THREAD_REF;
- THREAD_NOODLE.remove();
- }
- return this;
- }
-
- public void unbind() {
- this.thread = NULL_THREAD_REF;
- boolean markDirty;
- synchronized (this.tokens) {
- markDirty = !this.tokens.isEmpty();
- this.tokens.clear();
- }
- if (markDirty) this.markDirty();
- }
-
- public boolean isBound() {
- return this.thread.get() != null;
- }
-
- public void push(String token) {
- if (!this.enabled) return;
- synchronized (this.tokens) {
- this.tokens.add(token);
- }
- if (!token.isEmpty())
- this.markDirty();
- }
-
- public void pop() {
- if (!this.enabled) return;
- String last;
- synchronized (this.tokens) {
- last = this.tokens.removeLast();
- }
- if (!last.isEmpty())
- this.markDirty();
- }
-
- public void replace(String token) {
- if (!this.enabled) return;
- String last;
- synchronized (this.tokens) {
- last = this.tokens.removeLast();
- this.tokens.add(token);
- }
- if (!last.equals(token))
- this.markDirty();
- }
-
- public void setEnabled(boolean enabled) {
- if (this.enabled && !enabled) {
- this.thread = NULL_THREAD_REF;
- synchronized (this.tokens) {
- this.tokens.clear();
- }
- this.markDirty();
- }
- this.enabled = enabled;
- }
-
- protected void markDirty() {
- assert this.activity != null;
- assert this.textView != null;
- if (this.updating) return;
- this.updating = true;
- this.activity.runOnUiThread(() -> {
- String debugText;
- synchronized (this.tokens) {
- StringBuilder debug = this.debug;
- debug.setLength(0);
- boolean first = true;
- for (String text : this.tokens) {
- if (text.isEmpty()) continue;
- if (first) first = false;
- else debug.append(" > ");
- debug.append(text);
- }
- debugText = debug.toString();
- }
- this.updating = false;
- this.textView.setText(debugText);
- });
- }
-
- @NonNull
- public static NoodleDebug getNoodleDebug() {
- NoodleDebug noodleDebug = THREAD_NOODLE.get();
- if (noodleDebug == null) return NULL;
- if (noodleDebug.thread.get() != Thread.currentThread() ||
- noodleDebug.activity.isDestroyed()) {
- THREAD_NOODLE.remove();
- return NULL;
- }
- return noodleDebug;
- }
-}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index b6d0647..4d8ccd0 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -15,12 +15,13 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent" >
+ app:layout_constraintTop_toTopOf="parent">
+
+
-
+ app:layout_constraintTop_toBottomOf="@+id/action_bar_blur" />-->
+
Transparent themes may have some inconsistencies and may not work on all ROMs. In additon, monet and blur will be disabled. You can change back at any time.
Custom repos are always on until you remove them.
We encountered an error! Please help us improve the app
- by adding some information about the error below. Name and email are optional.
- Oops! Something went wrong.
+ by adding some information about the error below.\nName and email are optional but will
+ allow us to contact you if needed for more information.
+ Oops! Looks like the app closed unexpectedly.
Name
Email
Tell us what happened
Submit
- Could not submit feedback
- Submitted feedback
- Please provide a description/comment for the issue
+ Could not submit feedback due to an error
+ Submitted feedback successfully. We\'ll review it
+ shortly
+ Could not submit feedback as no
+ description was provided
diff --git a/app/src/main/res/xml/network_security_config.xml b/app/src/main/res/xml/network_security_config.xml
index 466080a..dbc7e47 100644
--- a/app/src/main/res/xml/network_security_config.xml
+++ b/app/src/main/res/xml/network_security_config.xml
@@ -6,4 +6,22 @@
+
+ github.com
+
+
+
+
+
+ githubusercontent.com
+
+
+
+
+
+ gstatic.com
+
+
+
+
\ No newline at end of file
diff --git a/app/src/sentry/java/com/fox2code/mmm/sentry/SentryMain.java b/app/src/sentry/java/com/fox2code/mmm/sentry/SentryMain.java
index 46ae270..90fc3b9 100644
--- a/app/src/sentry/java/com/fox2code/mmm/sentry/SentryMain.java
+++ b/app/src/sentry/java/com/fox2code/mmm/sentry/SentryMain.java
@@ -3,16 +3,12 @@ package com.fox2code.mmm.sentry;
import static io.sentry.TypeCheckHint.SENTRY_TYPE_CHECK_HINT;
import android.annotation.SuppressLint;
-import android.app.AlarmManager;
-import android.app.PendingIntent;
import android.content.Context;
-import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.util.Log;
import com.fox2code.mmm.BuildConfig;
-import com.fox2code.mmm.MainActivity;
import com.fox2code.mmm.MainApplication;
import com.fox2code.mmm.androidacy.AndroidacyUtil;
@@ -121,31 +117,10 @@ public class SentryMain {
// On uncaught exception, set the lastEventId in private sentry preferences
Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> {
SentryId lastEventId = Sentry.captureException(throwable);
- SharedPreferences.Editor editor = mainApplication.getSharedPreferences("sentry", 0).edit();
+ SharedPreferences.Editor editor = mainApplication.getSharedPreferences(
+ "sentry", Context.MODE_PRIVATE).edit();
editor.putString("lastExitReason", "crash");
editor.apply();
- // Start a new instance of the main activity
- // The intent flags ensure that the activity is started as a new task
- // and that any existing task is cleared before the activity is started
- // This ensures that the activity stack is cleared and the app is restarted
- // from the root activity
- Intent intent = new Intent(mainApplication, MainActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
- // Set an alarm to restart the app one second after it is killed
- // This is necessary because the app is killed before the intent is started
- // and the intent is ignored if the app is not running
- PendingIntent pendingIntent;
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
- pendingIntent = PendingIntent.getActivity(mainApplication, 0,
- intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
- } else {
- pendingIntent = PendingIntent.getActivity(mainApplication, 0,
- intent, PendingIntent.FLAG_CANCEL_CURRENT);
- }
- AlarmManager alarmManager = (AlarmManager) mainApplication.getSystemService(Context.ALARM_SERVICE);
- if (alarmManager != null) {
- alarmManager.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, pendingIntent);
- }
// Kill the app
System.exit(2);
});