INNER CODE UNIT · Kotlin
InitPreferences
Mahmud0808/Iconify · app/src/main/java/com/drdisagree/iconify/app/BaseMainActivity.kt:143
private fun InitPreferences(onLoaded: (AppState.Ready) -> Unit) {
val prefController = LocalPreferenceController.current
LaunchedEffect(Unit) {
val shellReady = withContext(Dispatchers.IO) {
try {
withTimeout(15_000L.milliseconds) {
suspendCancellableCoroutine { cont ->
Shell.getShell { shell ->
if (cont.isActive) cont.resume(shell.isRoot)
}
}
}
} catch (_: TimeoutCancellationException) {
Log.w(TAG, "Shell timed out — continuing without root")
false
} catch (e: Exception) {
Log.e(TAG, "Shell error", e)