Commit d453a8b0 authored by liuyang's avatar liuyang

APK图片抓取识别及轮播流地址抓取,客户端任务控制

#BYLSERVER-1438
parent 8b7715a1
......@@ -102,6 +102,18 @@ class Task : IAppBaseCallback {
AdbUtil.stopApp(this.apkInfo.packageName)
}
fun reset() {
this.status = "0"
this.channelIndex = 0
this.uploadImages.clear()
val dir = File(this.imagePath)
if (dir.exists()) {
for (file in dir.listFiles())
file.delete()
}
}
fun destroy() {
// 杀掉tcpdump进程
AdbUtil.killTcpdump()
......@@ -283,6 +295,7 @@ class Task : IAppBaseCallback {
private fun uploadImageCallback(): UploadStatusDelegate {
val totalUpload = this.uploadImages.size
Log.i(TAG, "total upload count : $totalUpload")
var uploadCount = 0
return object: UploadStatusDelegate {
......
......@@ -6,18 +6,28 @@ import kotlin.collections.ArrayList
class TaskManager {
private val TAG = "TaskManager"
private val RUN_TASK_PERIOD = 6*60*60*1000
val tasks = ArrayList<Task>()
private var isRunning = false
var isRunning = false
private var status = IDLE
private var currentTask: Task ?= null
// 处理时间
var updateTime = 0L
private val runnable = Runnable {
val dist = System.currentTimeMillis() - updateTime
while (isRunning && tasks.size > 0 && dist > 6*60*60*1000) {
this.updateTime = System.currentTimeMillis()
currentTask = tasks[0]
currentTask!!.start()
while (isRunning && this.status == 0) {
for (task in tasks) {
task.reset()
currentTask = task
currentTask!!.start()
}
this.status = COMPLETE
Thread.sleep(3 * 1000)
}
}
......@@ -60,6 +70,7 @@ class TaskManager {
}
this.isRunning = true
this.status = 0
val t = Thread(runnable)
t.start()
}
......@@ -70,11 +81,12 @@ class TaskManager {
it.destroy()
}
this.tasks.clear()
this.isRunning = false
}
companion object {
val instance = TaskManager()
const val IDLE = 0
const val COMPLETE = 1
}
}
\ No newline at end of file
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