mirror of
https://github.com/gkd-kit/gkd.git
synced 2024-11-16 11:42:22 +08:00
fix: 重启无障碍时没有自动开启通知栏服务
This commit is contained in:
parent
e64956067d
commit
787398210d
|
@ -14,6 +14,7 @@ import android.view.View
|
|||
import android.view.WindowManager
|
||||
import android.view.accessibility.AccessibilityEvent
|
||||
import android.view.accessibility.AccessibilityNodeInfo
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import com.blankj.utilcode.util.LogUtils
|
||||
import com.blankj.utilcode.util.ScreenUtils
|
||||
import com.blankj.utilcode.util.ToastUtils
|
||||
|
@ -450,6 +451,19 @@ class GkdAbService : CompositionAbService({
|
|||
onDestroy {
|
||||
isRunning.value = false
|
||||
}
|
||||
|
||||
// 在[系统重启]/[被其它高权限应用重启]时自动打开通知栏状态服务
|
||||
if (storeFlow.value.enableStatusService &&
|
||||
NotificationManagerCompat.from(context).areNotificationsEnabled() &&
|
||||
!ManageService.isRunning.value
|
||||
) {
|
||||
ManageService.start(context)
|
||||
}
|
||||
onDestroy {
|
||||
if (!storeFlow.value.enableStatusService && ManageService.isRunning.value) {
|
||||
ManageService.stop()
|
||||
}
|
||||
}
|
||||
}) {
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -91,14 +91,24 @@ fun ControlPage() {
|
|||
TextSwitch(
|
||||
name = "常驻通知栏",
|
||||
desc = "在通知栏显示服务运行状态,避免被某些系统回收",
|
||||
checked = manageRunning,
|
||||
checked = manageRunning && store.enableStatusService,
|
||||
onCheckedChange = {
|
||||
if (it) {
|
||||
if (!checkOrRequestNotifPermission(context)) {
|
||||
return@TextSwitch
|
||||
}
|
||||
updateStorage(
|
||||
storeFlow, store.copy(
|
||||
enableStatusService = true
|
||||
)
|
||||
)
|
||||
ManageService.start(context)
|
||||
} else {
|
||||
updateStorage(
|
||||
storeFlow, store.copy(
|
||||
enableStatusService = false
|
||||
)
|
||||
)
|
||||
ManageService.stop(context)
|
||||
}
|
||||
})
|
||||
|
|
|
@ -45,6 +45,7 @@ fun <T> updateStorage(stateFlow: StateFlow<T>, newState: T) {
|
|||
@Serializable
|
||||
data class Store(
|
||||
val enableService: Boolean = true,
|
||||
val enableStatusService: Boolean = true,
|
||||
val excludeFromRecents: Boolean = false,
|
||||
val captureScreenshot: Boolean = false,
|
||||
val httpServerPort: Int = 8888,
|
||||
|
|
Loading…
Reference in New Issue
Block a user