forked from gkd-kit/gkd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
58 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
app/src/main/java/li/songe/gkd/debug/SnapshotTileService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package li.songe.gkd.debug | ||
|
||
import android.accessibilityservice.AccessibilityService | ||
import android.service.quicksettings.TileService | ||
import com.blankj.utilcode.util.ToastUtils | ||
import kotlinx.coroutines.delay | ||
import li.songe.gkd.appScope | ||
import li.songe.gkd.debug.SnapshotExt.captureSnapshot | ||
import li.songe.gkd.service.GkdAbService | ||
import li.songe.gkd.service.topActivityFlow | ||
import li.songe.gkd.util.launchTry | ||
|
||
class SnapshotTileService : TileService() { | ||
override fun onClick() { | ||
super.onClick() | ||
if (!GkdAbService.isRunning()) { | ||
ToastUtils.showShort("无障碍没有开启") | ||
return | ||
} | ||
val service = GkdAbService.service ?: return | ||
val oldAppId = topActivityFlow.value?.appId | ||
service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK) | ||
appScope.launchTry { | ||
var i = 0 | ||
while (topActivityFlow.value?.appId == oldAppId) { | ||
delay(100) | ||
i++ | ||
if (i * 100 > 3000) { | ||
ToastUtils.showShort("没有检测到界面切换,捕获失败") | ||
return@launchTry | ||
} | ||
} | ||
captureSnapshot() | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters