mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Add UI for prompting about crashes.
This commit is contained in:
committed by
Alex Hart
parent
0a6c3baf24
commit
f959543c19
@@ -115,6 +115,7 @@ public final class FeatureFlags {
|
||||
public static final String USERNAMES = "android.usernames";
|
||||
public static final String INSTANT_VIDEO_PLAYBACK = "android.instantVideoPlayback";
|
||||
private static final String CONVERSATION_ITEM_V2_TEXT = "android.conversationItemV2.text.2";
|
||||
public static final String CRASH_PROMPT_CONFIG = "android.crashPromptConfig";
|
||||
|
||||
/**
|
||||
* We will only store remote values for flags in this set. If you want a flag to be controllable
|
||||
@@ -181,7 +182,8 @@ public final class FeatureFlags {
|
||||
PROMPT_BATTERY_SAVER,
|
||||
USERNAMES,
|
||||
INSTANT_VIDEO_PLAYBACK,
|
||||
CONVERSATION_ITEM_V2_TEXT
|
||||
CONVERSATION_ITEM_V2_TEXT,
|
||||
CRASH_PROMPT_CONFIG
|
||||
);
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -252,7 +254,8 @@ public final class FeatureFlags {
|
||||
PROMPT_FOR_NOTIFICATION_LOGS,
|
||||
PROMPT_FOR_NOTIFICATION_CONFIG,
|
||||
PROMPT_BATTERY_SAVER,
|
||||
USERNAMES
|
||||
USERNAMES,
|
||||
CRASH_PROMPT_CONFIG
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -662,6 +665,11 @@ public final class FeatureFlags {
|
||||
return getString(PROMPT_BATTERY_SAVER, "*");
|
||||
}
|
||||
|
||||
/** Config object for what crashes to prompt about. */
|
||||
public static String crashPromptConfig() {
|
||||
return getString(CRASH_PROMPT_CONFIG, "");
|
||||
}
|
||||
|
||||
|
||||
/** Only for rendering debug info. */
|
||||
public static synchronized @NonNull Map<String, Object> getMemoryValues() {
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.util;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.type.TypeFactory;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
@@ -10,6 +11,7 @@ import org.json.JSONObject;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -40,6 +42,11 @@ public class JsonUtils {
|
||||
return objectMapper.readValue(serialized, clazz);
|
||||
}
|
||||
|
||||
public static <T> List<T> fromJsonArray(String serialized, Class<T> clazz) throws IOException {
|
||||
TypeFactory typeFactory = objectMapper.getTypeFactory();
|
||||
return objectMapper.readValue(serialized, typeFactory.constructCollectionType(List.class, clazz));
|
||||
}
|
||||
|
||||
public static String toJson(Object object) throws IOException {
|
||||
return objectMapper.writeValueAsString(object);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import org.signal.core.util.ExceptionUtil;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.database.LogDatabase;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
|
||||
@@ -39,7 +40,13 @@ public class SignalUncaughtExceptionHandler implements Thread.UncaughtExceptionH
|
||||
e = e.getCause();
|
||||
}
|
||||
|
||||
String exceptionName = e.getClass().getCanonicalName();
|
||||
if (exceptionName == null) {
|
||||
exceptionName = e.getClass().getName();
|
||||
}
|
||||
|
||||
Log.e(TAG, "", e, true);
|
||||
LogDatabase.getInstance(ApplicationDependencies.getApplication()).crashes().saveCrash(System.currentTimeMillis(), exceptionName, e.getMessage(), ExceptionUtil.convertThrowableToString(e));
|
||||
SignalStore.blockUntilAllWritesFinished();
|
||||
Log.blockUntilAllWritesFinished();
|
||||
ApplicationDependencies.getJobManager().flush();
|
||||
|
||||
Reference in New Issue
Block a user