manager: brought back isOverlayAvailable()

This commit is contained in:
Rifat Azad
2024-12-24 22:50:50 +06:00
parent f9db51bfb9
commit 5baa8237ed
5 changed files with 41 additions and 0 deletions

View File

@@ -428,6 +428,20 @@ private fun ModuleList(
},
) {
when {
!viewModel.isOverlayAvailable -> {
item {
Box(
modifier = Modifier.fillParentMaxSize(),
contentAlignment = Alignment.Center
) {
Text(
stringResource(R.string.module_overlay_fs_not_available),
textAlign = TextAlign.Center
)
}
}
}
viewModel.moduleList.isEmpty() -> {
item {
Box(
@@ -537,6 +551,19 @@ fun ModuleItem(
Column(
modifier = Modifier
.run {
if (module.hasWebUi) {
toggleable(
value = isChecked,
interactionSource = interactionSource,
role = Role.Button,
indication = indication,
onValueChange = { onClick(module) }
)
} else {
this
}
}
.padding(22.dp, 18.dp, 22.dp, 12.dp)
) {
Row(

View File

@@ -403,6 +403,12 @@ suspend fun getSupportedKmis(): List<String> = withContext(Dispatchers.IO) {
out.filter { it.isNotBlank() }.map { it.trim() }
}
fun overlayFsAvailable(): Boolean {
val shell = getRootShell()
// check /proc/filesystems
return ShellUtils.fastCmdResult(shell, "cat /proc/filesystems | grep overlay")
}
fun hasMagisk(): Boolean {
val shell = getRootShell(true)
val result = shell.newJob().add("which magisk").exec()

View File

@@ -11,6 +11,7 @@ import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import com.rifsxd.ksunext.ui.util.listModules
import com.rifsxd.ksunext.ui.util.overlayFsAvailable
import org.json.JSONArray
import org.json.JSONObject
import java.text.Collator
@@ -45,6 +46,9 @@ class ModuleViewModel : ViewModel() {
val changelog: String,
)
var isOverlayAvailable by mutableStateOf(overlayFsAvailable())
private set
var isRefreshing by mutableStateOf(false)
private set
@@ -71,6 +75,8 @@ class ModuleViewModel : ViewModel() {
val start = SystemClock.elapsedRealtime()
kotlin.runCatching {
isOverlayAvailable = overlayFsAvailable()
val result = listModules()
Log.i(TAG, "result: $result")

View File

@@ -55,6 +55,7 @@
<string name="module_restore_failed">恢复失败: %s</string>
<string name="module_version">版本</string>
<string name="module_author">作者</string>
<string name="module_overlay_fs_not_available">OverlayFS被内核禁用模块不可用。</string>
<string name="refresh">刷新</string>
<string name="show_system_apps">显示系统应用</string>
<string name="hide_system_apps">隐藏系统应用</string>

View File

@@ -56,6 +56,7 @@
<string name="module_restore_failed">Failed to restore: %s</string>
<string name="module_version">Version</string>
<string name="module_author">Author</string>
<string name="module_overlay_fs_not_available">Modules are unavailable as OverlayFS is disabled by the kernel.</string>
<string name="refresh">Refresh</string>
<string name="show_system_apps">Show system apps</string>
<string name="hide_system_apps">Hide system apps</string>