@@ -26,6 +26,8 @@ import li.songe.gkd.a11y.topActivityFlow
26
26
import li.songe.gkd.notif.StopServiceReceiver
27
27
import li.songe.gkd.notif.recordNotif
28
28
import li.songe.gkd.permission.canDrawOverlaysState
29
+ import li.songe.gkd.shizuku.SafeTaskListener
30
+ import li.songe.gkd.shizuku.shizukuContextFlow
29
31
import li.songe.gkd.ui.component.AppNameText
30
32
import li.songe.gkd.ui.theme.AppTheme
31
33
import li.songe.gkd.util.appInfoCacheFlow
@@ -34,13 +36,19 @@ import li.songe.gkd.util.stopServiceByClass
34
36
35
37
36
38
class RecordService : OverlayWindowService () {
39
+ override val positionStoreKey = " overlay_xy_record"
40
+
37
41
val topAppInfoFlow by lazy {
38
42
appInfoCacheFlow.combine(topActivityFlow) { map, topActivity ->
39
43
map[topActivity.appId]
40
44
}.stateIn(lifecycleScope, SharingStarted .Eagerly , null )
41
45
}
42
46
43
- override val positionStoreKey = " overlay_xy_record"
47
+ val activityOkFlow by lazy {
48
+ combine(A11yService .isRunning, shizukuContextFlow) { a, b ->
49
+ a || (b.activityTaskManager != null && SafeTaskListener .isAvailable)
50
+ }.stateIn(scope = lifecycleScope, started = SharingStarted .Eagerly , initialValue = false )
51
+ }
44
52
45
53
@Composable
46
54
override fun ComposeContent () = AppTheme (invertedTheme = true ) {
@@ -52,7 +60,7 @@ class RecordService : OverlayWindowService() {
52
60
.padding(horizontal = 4 .dp, vertical = 2 .dp)
53
61
) {
54
62
CompositionLocalProvider (LocalContentColor provides contentColorFor(bgColor)) {
55
- if (A11yService .isRunning .collectAsState().value) {
63
+ if (activityOkFlow .collectAsState().value) {
56
64
val topActivity = topActivityFlow.collectAsState().value
57
65
Text (
58
66
text = topActivity.number.toString(),
@@ -73,7 +81,7 @@ class RecordService : OverlayWindowService() {
73
81
} else {
74
82
Column {
75
83
Text (text = " 记录服务" )
76
- Text (text = " 无障碍服务未运行 " )
84
+ Text (text = " 无权限检测界面切换 " )
77
85
}
78
86
}
79
87
}
0 commit comments