2023-08-19 19:48:10 +00:00
|
|
|
package com.lagradost.cloudstream3
|
|
|
|
|
|
|
|
import com.lagradost.cloudstream3.MainActivity.Companion.lastError
|
|
|
|
import com.lagradost.cloudstream3.mvvm.logError
|
|
|
|
import com.lagradost.cloudstream3.plugins.PluginManager.checkSafeModeFile
|
|
|
|
import kotlinx.coroutines.CoroutineScope
|
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
|
import kotlinx.coroutines.delay
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
|
|
|
|
object NativeCrashHandler {
|
|
|
|
// external fun triggerNativeCrash()
|
2023-08-25 21:16:34 +00:00
|
|
|
/*private external fun initNativeCrashHandler()
|
2023-08-19 19:48:10 +00:00
|
|
|
private external fun getSignalStatus(): Int
|
|
|
|
|
|
|
|
private fun initSignalPolling() = CoroutineScope(Dispatchers.IO).launch {
|
2023-08-23 21:57:54 +00:00
|
|
|
|
|
|
|
//launch {
|
|
|
|
// delay(10000)
|
|
|
|
// triggerNativeCrash()
|
|
|
|
//}
|
|
|
|
|
2023-08-19 19:48:10 +00:00
|
|
|
while (true) {
|
|
|
|
delay(10_000)
|
|
|
|
val signal = getSignalStatus()
|
|
|
|
// Signal is initialized to zero
|
|
|
|
if (signal == 0) continue
|
|
|
|
|
|
|
|
// Do not crash in safe mode!
|
|
|
|
if (lastError != null) continue
|
|
|
|
if (checkSafeModeFile()) continue
|
|
|
|
|
2023-08-23 21:57:54 +00:00
|
|
|
AcraApplication.exceptionHandler?.uncaughtException(
|
|
|
|
Thread.currentThread(),
|
|
|
|
RuntimeException("Native crash with code: $signal. Try uninstalling extensions.\n")
|
|
|
|
)
|
2023-08-19 19:48:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fun initCrashHandler() {
|
|
|
|
try {
|
|
|
|
System.loadLibrary("native-lib")
|
|
|
|
initNativeCrashHandler()
|
|
|
|
} catch (t: Throwable) {
|
|
|
|
// Make debug crash.
|
|
|
|
if (BuildConfig.DEBUG) throw t
|
|
|
|
logError(t)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
initSignalPolling()
|
2023-08-25 21:16:34 +00:00
|
|
|
}*/
|
2023-08-19 19:48:10 +00:00
|
|
|
}
|