(misc) fix race condition

Signed-off-by: androidacy-user <opensource@androidacy.com>
master
androidacy-user 1 year ago
parent 777ab751c9
commit 702048e6c8

@ -11,6 +11,7 @@ import com.fox2code.foxcompat.app.FoxActivity;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.textview.MaterialTextView;
import java.io.PrintWriter;
import java.io.StringWriter;
import io.sentry.Sentry;
@ -27,6 +28,7 @@ public class CrashHandler extends FoxActivity {
Timber.d("CrashHandler.onCreate: intent=%s", getIntent());
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_crash_handler);
// unlock webview
// set crash_details MaterialTextView to the exception passed in the intent or unknown if null
// convert stacktrace from array to string, and pretty print it (first line is the exception, the rest is the stacktrace, with each line indented by 4 spaces)
MaterialTextView crashDetails = findViewById(R.id.crash_details);
@ -42,7 +44,7 @@ public class CrashHandler extends FoxActivity {
// if the exception is not null, set the crash details to the exception and stacktrace
// stacktrace is an StacktraceElement, so convert it to a string and replace the commas with newlines
StringWriter stringWriter = new StringWriter();
exception.printStackTrace(new java.io.PrintWriter(stringWriter));
exception.printStackTrace(new PrintWriter(stringWriter));
String stacktrace = stringWriter.toString();
stacktrace = stacktrace.replace(",", "\n ");
crashDetails.setText(getString(R.string.crash_full_stacktrace, stacktrace));

@ -124,6 +124,7 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
private byte[] existingKey;
private Tracker tracker;
private boolean makingNewKey = false;
private boolean isCrashHandler;
public MainApplication() {
if (INSTANCE != null && INSTANCE != this)
@ -291,6 +292,7 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
}
public Markwon getMarkwon() {
if (isCrashHandler) return null;
if (this.markwon != null) return this.markwon;
FoxThemeWrapper contextThemeWrapper = this.markwonThemeContext;
if (contextThemeWrapper == null) {
@ -389,8 +391,18 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
Timber.i("Starting FoxMMM version %s (%d) - commit %s", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, BuildConfig.COMMIT_HASH);
// Update SSL Ciphers if update is possible
GMSProviderInstaller.installIfNeeded(this);
Http.ensureCacheDirs();
Http.ensureURLHandler(getApplicationContext());
// detect if we're launching the crashhandler
// get intent that started the crashhandler
Intent intent = getIntent();
if (intent != null) {
if (intent.getClass().getName().equals("com.fox2code.mmm.CrashHandler")) {
isCrashHandler = true;
}
}
if (!isCrashHandler) {
Http.ensureCacheDirs();
Http.ensureURLHandler(getApplicationContext());
}
Timber.d("Initializing FoxMMM");
Timber.d("Started from background: %s", !isInForeground());
Timber.d("FoxMMM is running in debug mode");

Loading…
Cancel
Save