From 3a8b8858c371c3a1cf7476e5369cb576170d3bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E5=88=BA=E8=9E=88?= Date: Tue, 12 Nov 2024 15:06:42 +0800 Subject: [PATCH] perf: switchA11yService --- app/src/main/kotlin/li/songe/gkd/service/GkdTileService.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/li/songe/gkd/service/GkdTileService.kt b/app/src/main/kotlin/li/songe/gkd/service/GkdTileService.kt index 97cb125..c3b5203 100644 --- a/app/src/main/kotlin/li/songe/gkd/service/GkdTileService.kt +++ b/app/src/main/kotlin/li/songe/gkd/service/GkdTileService.kt @@ -105,10 +105,10 @@ private fun enableA11yService() { ) } -fun switchA11yService(): Boolean { +fun switchA11yService() = appScope.launchTry(Dispatchers.IO) { if (!writeSecureSettingsState.updateAndGet()) { toast("请先授予[写入安全设置权限]") - return false + return@launchTry } val names = getServiceNames() storeFlow.update { it.copy(enableService = !A11yService.isRunning.value) } @@ -121,12 +121,12 @@ fun switchA11yService(): Boolean { if (names.contains(a11yClsName)) { // 当前无障碍异常, 重启服务 names.remove(a11yClsName) updateServiceNames(names) + delay(500) } names.add(a11yClsName) updateServiceNames(names) toast("开启无障碍") } - return true } fun fixRestartService() = appScope.launchTry(Dispatchers.IO) {