mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-09 08:07:42 +00:00
gather crash information more aggressively
especially for crashes while device is locked might help with #801
This commit is contained in:
parent
e4e99a7e5d
commit
3fcea486be
4 changed files with 21 additions and 13 deletions
|
@ -45,8 +45,8 @@ import java.util.EnumMap
|
||||||
class App : Application() {
|
class App : Application() {
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
Settings.init(this)
|
|
||||||
DebugFlags.init(this)
|
DebugFlags.init(this)
|
||||||
|
Settings.init(this)
|
||||||
SubtypeSettings.init(this)
|
SubtypeSettings.init(this)
|
||||||
RichInputMethodManager.init(this)
|
RichInputMethodManager.init(this)
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ object DebugFlags {
|
||||||
|
|
||||||
fun init(context: Context) {
|
fun init(context: Context) {
|
||||||
DEBUG_ENABLED = context.prefs().getBoolean(DebugSettings.PREF_DEBUG_MODE, Defaults.PREF_DEBUG_MODE)
|
DEBUG_ENABLED = context.prefs().getBoolean(DebugSettings.PREF_DEBUG_MODE, Defaults.PREF_DEBUG_MODE)
|
||||||
if (DEBUG_ENABLED || BuildConfig.DEBUG)
|
|
||||||
CrashReportExceptionHandler(context.applicationContext).install()
|
CrashReportExceptionHandler(context.applicationContext).install()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,10 +52,18 @@ public final class JniUtils {
|
||||||
.getMethod("currentApplication").invoke(null, (Object[]) null);
|
.getMethod("currentApplication").invoke(null, (Object[]) null);
|
||||||
} catch (Exception ignored) { }
|
} catch (Exception ignored) { }
|
||||||
}
|
}
|
||||||
if (app != null) // use the actual path if possible
|
if (app != null && app.getFilesDir() != null) // use the actual path if possible
|
||||||
filesDir = app.getFilesDir().getAbsolutePath();
|
filesDir = app.getFilesDir().getAbsolutePath();
|
||||||
final File userSuppliedLibrary = new File(filesDir + File.separator + JNI_LIB_IMPORT_FILE_NAME);
|
|
||||||
if (!BuildConfig.BUILD_TYPE.equals("nouserlib") && userSuppliedLibrary.exists()) {
|
File userSuppliedLibrary;
|
||||||
|
try {
|
||||||
|
userSuppliedLibrary = new File(filesDir + File.separator + JNI_LIB_IMPORT_FILE_NAME);
|
||||||
|
if (!userSuppliedLibrary.isFile())
|
||||||
|
userSuppliedLibrary = null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
userSuppliedLibrary = null;
|
||||||
|
}
|
||||||
|
if (!BuildConfig.BUILD_TYPE.equals("nouserlib") && userSuppliedLibrary != null) {
|
||||||
String wantedChecksum = expectedDefaultChecksum();
|
String wantedChecksum = expectedDefaultChecksum();
|
||||||
try {
|
try {
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
|
|
|
@ -76,8 +76,7 @@ class SettingsActivity : ComponentActivity(), SharedPreferences.OnSharedPreferen
|
||||||
Settings.getInstance().loadSettings(this, resources.configuration.locale(), inputAttributes)
|
Settings.getInstance().loadSettings(this, resources.configuration.locale(), inputAttributes)
|
||||||
}
|
}
|
||||||
ExecutorUtils.getBackgroundExecutor(ExecutorUtils.KEYBOARD).execute { cleanUnusedMainDicts(this) }
|
ExecutorUtils.getBackgroundExecutor(ExecutorUtils.KEYBOARD).execute { cleanUnusedMainDicts(this) }
|
||||||
if (BuildConfig.DEBUG || DebugFlags.DEBUG_ENABLED)
|
crashReportFiles.value = findCrashReports(!BuildConfig.DEBUG && !DebugFlags.DEBUG_ENABLED)
|
||||||
crashReportFiles.value = findCrashReports()
|
|
||||||
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
|
||||||
settingsContainer = SettingsContainer(this)
|
settingsContainer = SettingsContainer(this)
|
||||||
|
@ -191,16 +190,18 @@ class SettingsActivity : ComponentActivity(), SharedPreferences.OnSharedPreferen
|
||||||
KeyboardSwitcher.getInstance().setThemeNeedsReload()
|
KeyboardSwitcher.getInstance().setThemeNeedsReload()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findCrashReports(): List<File> {
|
private fun findCrashReports(onlyUnprotected: Boolean): List<File> {
|
||||||
// find crash report files
|
val unprotected = DeviceProtectedUtils.getFilesDir(this)?.listFiles().orEmpty()
|
||||||
|
if (onlyUnprotected)
|
||||||
|
return unprotected.filter { it.name.startsWith("crash_report") }
|
||||||
|
|
||||||
val dir = getExternalFilesDir(null)
|
val dir = getExternalFilesDir(null)
|
||||||
val unprotectedDir = DeviceProtectedUtils.getFilesDir(this)
|
val allFiles = dir?.listFiles()?.toList().orEmpty() + unprotected
|
||||||
val allFiles = dir?.listFiles()?.toList().orEmpty() + unprotectedDir?.listFiles().orEmpty()
|
|
||||||
return allFiles.filter { it.name.startsWith("crash_report") }
|
return allFiles.filter { it.name.startsWith("crash_report") }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveCrashReports(uri: Uri) {
|
private fun saveCrashReports(uri: Uri) {
|
||||||
val files = findCrashReports()
|
val files = findCrashReports(false)
|
||||||
if (files.isEmpty()) return
|
if (files.isEmpty()) return
|
||||||
try {
|
try {
|
||||||
contentResolver.openOutputStream(uri)?.use {
|
contentResolver.openOutputStream(uri)?.use {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue