diff --git a/app/src/main/java/li/songe/gkd/data/ComplexSnapshot.kt b/app/src/main/java/li/songe/gkd/data/ComplexSnapshot.kt index e4d8c36..5029d1b 100644 --- a/app/src/main/java/li/songe/gkd/data/ComplexSnapshot.kt +++ b/app/src/main/java/li/songe/gkd/data/ComplexSnapshot.kt @@ -5,8 +5,8 @@ import com.blankj.utilcode.util.ScreenUtils import kotlinx.serialization.Serializable import li.songe.gkd.BuildConfig import li.songe.gkd.service.GkdAbService +import li.songe.gkd.service.getCurrentRules import li.songe.gkd.service.safeActiveWindow -import li.songe.gkd.service.topActivityFlow @Serializable data class ComplexSnapshot( @@ -33,7 +33,7 @@ data class ComplexSnapshot( fun createComplexSnapshot(): ComplexSnapshot { val currentAbNode = GkdAbService.service?.safeActiveWindow val appId = currentAbNode?.packageName?.toString() - val currentActivityId = topActivityFlow.value?.activityId + val currentActivityId = getCurrentRules().topActivity?.activityId val appInfo = if (appId == null) null else AppUtils.getAppInfo(appId) return ComplexSnapshot( diff --git a/app/src/main/java/li/songe/gkd/debug/SnapshotTileService.kt b/app/src/main/java/li/songe/gkd/debug/SnapshotTileService.kt index d30b33f..c2707df 100644 --- a/app/src/main/java/li/songe/gkd/debug/SnapshotTileService.kt +++ b/app/src/main/java/li/songe/gkd/debug/SnapshotTileService.kt @@ -3,6 +3,7 @@ package li.songe.gkd.debug import android.accessibilityservice.AccessibilityService import android.service.quicksettings.TileService import com.blankj.utilcode.util.ToastUtils +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay import li.songe.gkd.appScope import li.songe.gkd.debug.SnapshotExt.captureSnapshot @@ -18,9 +19,9 @@ class SnapshotTileService : TileService() { ToastUtils.showShort("无障碍没有开启") return } - val oldAppId = service.safeActiveWindow?.packageName - ?: return ToastUtils.showShort("获取界面信息根节点失败") - appScope.launchTry { + appScope.launchTry(Dispatchers.IO) { + val oldAppId = service.safeActiveWindow?.packageName + ?: return@launchTry ToastUtils.showShort("获取界面信息根节点失败") val interval = 500L val waitTime = 3000L var i = 0