Skip to content

Commit

Permalink
feat: remove last_restart_a11y_service_time
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Nov 30, 2024
1 parent 2e8e53c commit 708eda1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
8 changes: 2 additions & 6 deletions app/src/main/kotlin/li/songe/gkd/service/GkdTileService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import li.songe.gkd.util.OnChangeListen
import li.songe.gkd.util.OnDestroy
import li.songe.gkd.util.OnTileClick
import li.songe.gkd.util.componentName
import li.songe.gkd.util.lastRestartA11yServiceTimeFlow
import li.songe.gkd.util.launchTry
import li.songe.gkd.util.storeFlow
import li.songe.gkd.util.toast
Expand Down Expand Up @@ -131,7 +130,7 @@ fun switchA11yService() = appScope.launchTry(Dispatchers.IO) {
}
names.add(a11yClsName)
updateServiceNames(names)
delay(300)
delay(500)
if (!A11yService.isRunning.value) {
toast("开启无障碍失败")
accessRestrictedSettingsShowFlow.value = true
Expand All @@ -148,9 +147,6 @@ fun fixRestartService() = appScope.launchTry(Dispatchers.IO) {
// 2. 用户配置开启了服务
// 3. 有写入系统设置权限
if (!A11yService.isRunning.value && storeFlow.value.enableService && writeSecureSettingsState.updateAndGet()) {
val t = System.currentTimeMillis()
if (t - lastRestartA11yServiceTimeFlow.value < 3_000) return@launchTry
lastRestartA11yServiceTimeFlow.value = t
val names = getServiceNames()
val a11yBroken = names.contains(a11yClsName)
if (a11yBroken) {
Expand All @@ -162,7 +158,7 @@ fun fixRestartService() = appScope.launchTry(Dispatchers.IO) {
}
names.add(a11yClsName)
updateServiceNames(names)
delay(300)
delay(500)
if (!A11yService.isRunning.value) {
toast("重启无障碍失败")
accessRestrictedSettingsShowFlow.value = true
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/kotlin/li/songe/gkd/util/Store.kt
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@ val privacyStoreFlow by lazy {
)
}

val lastRestartA11yServiceTimeFlow by lazy {
createLongFlow("last_restart_a11y_service_time")
}

fun initStore() {
storeFlow.value
actionCountFlow.value
Expand Down

0 comments on commit 708eda1

Please sign in to comment.