Commit d453a8b0 authored by liuyang's avatar liuyang

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

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