mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Potential fix for crash loops (#608)
This commit is contained in:
parent
6957a8f95d
commit
24977a8d62
2 changed files with 22 additions and 4 deletions
|
@ -1092,15 +1092,19 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
|||
updateTv()
|
||||
|
||||
// backup when we update the app, I don't trust myself to not boot lock users, might want to make this a setting?
|
||||
try {
|
||||
normalSafeApiCall {
|
||||
val appVer = BuildConfig.VERSION_NAME
|
||||
val lastAppAutoBackup: String = getKey("VERSION_NAME") ?: ""
|
||||
if (appVer != lastAppAutoBackup) {
|
||||
setKey("VERSION_NAME", BuildConfig.VERSION_NAME)
|
||||
normalSafeApiCall {
|
||||
backup()
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
logError(t)
|
||||
normalSafeApiCall {
|
||||
// Recompile oat on new version
|
||||
PluginManager.deleteAllOatFiles(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// just in case, MAIN SHOULD *NEVER* BOOT LOOP CRASH
|
||||
|
|
|
@ -137,6 +137,20 @@ object PluginManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all generated oat files which will force Android to recompile the dex extensions.
|
||||
* This might fix unrecoverable SIGSEGV exceptions when old oat files are loaded in a new app update.
|
||||
*/
|
||||
fun deleteAllOatFiles(context: Context) {
|
||||
File("${context.filesDir}/${ONLINE_PLUGINS_FOLDER}").listFiles()?.forEach { repo ->
|
||||
repo.listFiles { file -> file.name == "oat" && file.isDirectory }?.forEach { file ->
|
||||
val success = file.deleteRecursively()
|
||||
Log.i(TAG, "Deleted oat directory: ${file.absolutePath} Success=$success")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun getPluginsOnline(): Array<PluginData> {
|
||||
return getKey(PLUGINS_KEY) ?: emptyArray()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue