Commit db9a79a1 authored by liuyang's avatar liuyang

任务中断恢复

parent a7833cb4
...@@ -87,13 +87,15 @@ class Task : IAppBaseCallback { ...@@ -87,13 +87,15 @@ class Task : IAppBaseCallback {
this.launchApp() this.launchApp()
// 频道轮询处理 // 频道轮询处理
try { try {
val success = this.processChannels() val success = this.processChannels(0)
// 再次尝试 // 再次尝试
if (!success) { if (!success) {
this.reset()
this.prepareReport()
this.launchApp() this.launchApp()
this.processChannels() // 重新切换到上次崩溃的频道,接着抓取
for (i in 0 until this.channelIndex) {
AdbUtil.sendMultiKey(this.apkInfo.channelKeyEvent)
}
this.processChannels(this.channelIndex)
} }
// 上传图片 // 上传图片
this.uploadImage() this.uploadImage()
...@@ -159,16 +161,17 @@ class Task : IAppBaseCallback { ...@@ -159,16 +161,17 @@ class Task : IAppBaseCallback {
} }
} }
private fun processChannels(): Boolean { private fun processChannels(index:Int): Boolean {
Log.i(TAG, "processChannels") Log.i(TAG, "processChannels")
step() step()
for (i in 1 until this.apkInfo.channelCount) { for (i in index + 1 until this.apkInfo.channelCount) {
// 模拟按键事件. 切换频道进行抓取 // 模拟按键事件. 切换频道进行抓取
this.channelIndex = i this.channelIndex = i
capture(apkInfo.captureDelay) capture(apkInfo.captureDelay)
AdbUtil.sendMultiKey(this.apkInfo.channelKeyEvent) AdbUtil.sendMultiKey(this.apkInfo.channelKeyEvent)
if (!AppUtil.isAppBackground(context, this.apkInfo.packageName)) { if (!AppUtil.isAppBackground(context, this.apkInfo.packageName)) {
Log.i(TAG, "targe app crashed?")
return false return false
} }
...@@ -179,6 +182,7 @@ class Task : IAppBaseCallback { ...@@ -179,6 +182,7 @@ class Task : IAppBaseCallback {
} }
private fun step() { private fun step() {
Log.i(TAG, "step channel ${this.channelIndex}")
// 截图保存 // 截图保存
val screenShots = saveScreenShot() val screenShots = saveScreenShot()
if (screenShots.size > 0) if (screenShots.size > 0)
......
...@@ -98,6 +98,7 @@ class TaskManager { ...@@ -98,6 +98,7 @@ class TaskManager {
this.overTasks.clear() this.overTasks.clear()
this.isRunning = false this.isRunning = false
this.updateTime = 0L
} }
companion object { companion object {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment