fix: shizuku and root shell wifi command

closes #900
This commit is contained in:
Zane Schepke
2025-09-19 02:41:55 -04:00
parent 274e6aec0f
commit 41cfa8fcec
2 changed files with 17 additions and 12 deletions
@@ -164,29 +164,35 @@ constructor(
fun setWifiDetectionMethod(method: WifiDetectionMethod) = intent {
when (method) {
WifiDetectionMethod.ROOT -> if (!requestRoot()) return@intent
WifiDetectionMethod.SHIZUKU -> return@intent requestShizuku()
WifiDetectionMethod.SHIZUKU -> {
requestShizuku()
return@intent
}
else -> Unit
}
settingsRepository.save(state.settings.copy(wifiDetectionMethod = method))
}
private fun requestShizuku() {
private fun requestShizuku() = intent {
Shizuku.addRequestPermissionResultListener(
Shizuku.OnRequestPermissionResultListener { requestCode: Int, grantResult: Int ->
if (grantResult != PERMISSION_GRANTED) return@OnRequestPermissionResultListener
setWifiDetectionMethod(WifiDetectionMethod.SHIZUKU)
intent {
settingsRepository.save(
state.settings.copy(wifiDetectionMethod = WifiDetectionMethod.SHIZUKU)
)
}
}
)
try {
if (Shizuku.checkSelfPermission() != PERMISSION_GRANTED) Shizuku.requestPermission(123)
settingsRepository.save(
state.settings.copy(wifiDetectionMethod = WifiDetectionMethod.SHIZUKU)
)
} catch (_: Exception) {
intent {
postSideEffect(
GlobalSideEffect.Snackbar(
StringValue.StringResource(R.string.shizuku_not_detected)
)
)
}
postSideEffect(
GlobalSideEffect.Snackbar(StringValue.StringResource(R.string.shizuku_not_detected))
)
}
}
@@ -11,8 +11,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import timber.log.Timber
const val WIFI_SSID_SHELL_COMMAND =
"dumpsys wifi | grep 'Supplicant state: COMPLETED' | grep -o 'SSID: \"[^\"]*\"' | cut -d '\"' -f2"
const val WIFI_SSID_SHELL_COMMAND = "cmd wifi status | grep -i 'connected to' | cut -d'\"' -f2"
fun RootShell.getCurrentWifiName(): String {
val response = mutableListOf<String>()