Commit db9a79a1 authored by liuyang's avatar liuyang

任务中断恢复

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