Commit 8786046c authored by liuyang's avatar liuyang

add task

parent 3dafa733
{
"name": "电视家",
"packageName": "com.elinkway.tvlive2",
"launcher": "com.elinkway.tvlive2.activity.SplashActivity",
"launchDelay": "15"
}
\ No newline at end of file
...@@ -14,7 +14,7 @@ import java.util.* ...@@ -14,7 +14,7 @@ import java.util.*
class Task { class Task {
private lateinit var packageName: String lateinit var packageName: String
private lateinit var launcher: String private lateinit var launcher: String
private lateinit var imagePath: String private lateinit var imagePath: String
private var launchDelay = 15 private var launchDelay = 15
...@@ -22,7 +22,7 @@ class Task { ...@@ -22,7 +22,7 @@ class Task {
private val imageDateFormat = SimpleDateFormat("yyyy_MM_dd_HH_mm_ss", Locale.CHINA) private val imageDateFormat = SimpleDateFormat("yyyy_MM_dd_HH_mm_ss", Locale.CHINA)
var proc: Process ?= null var proc: Process ?= null
public constructor(context: Context) { constructor(context: Context) {
this.context = context this.context = context
} }
...@@ -89,17 +89,16 @@ class Task { ...@@ -89,17 +89,16 @@ class Task {
val host = it.substring(start) val host = it.substring(start)
val url = "http://$host$partUrl" val url = "http://$host$partUrl"
val item = JSONObject() val item = JSONObject()
item.put("url", url) item.put(Constants.KEY_URL, url)
item.put("time", timeStr) item.put(Constants.KEY_TIME, timeStr)
playUrlItems.put(item) playUrlItems.put(item)
partUrl = "" partUrl = ""
} }
} }
if (playUrlItems.length() > 0) {
for (i in 0..playUrlItems.length()) { for (i in 0..playUrlItems.length()) {
playUrlItems.get(i) val jo = playUrlItems.get(i) as JSONObject
} val url = jo.optString(Constants.KEY_URL)
} }
} }
......
package com.duolebo.blyrobot.protocol
class GetAppConfig {
}
\ No newline at end of file
...@@ -3,11 +3,12 @@ package com.duolebo.blyrobot.service ...@@ -3,11 +3,12 @@ package com.duolebo.blyrobot.service
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.Service import android.app.Service
import android.content.Intent import android.content.Intent
import android.os.Environment
import android.os.IBinder import android.os.IBinder
import android.util.Log import android.util.Log
import com.duolebo.blyrobot.data.Task
import com.duolebo.blyrobot.util.AdbUtil import com.duolebo.blyrobot.util.AdbUtil
import java.text.SimpleDateFormat import com.duolebo.blyrobot.util.AppUtil
import org.json.JSONObject
import java.util.* import java.util.*
@SuppressLint("Registered") @SuppressLint("Registered")
...@@ -16,6 +17,7 @@ class BylRobotService: Service() { ...@@ -16,6 +17,7 @@ class BylRobotService: Service() {
private val TAG = "BylRobotService" private val TAG = "BylRobotService"
private var timer: Timer? = null private var timer: Timer? = null
private var count = 0 private var count = 0
private val tasks = ArrayList<Task>()
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
...@@ -36,6 +38,13 @@ class BylRobotService: Service() { ...@@ -36,6 +38,13 @@ class BylRobotService: Service() {
},2000, 10*1000) },2000, 10*1000)
} }
private fun loadTask() {
val task = Task(this)
task.from(JSONObject(AppUtil.readFromAssert(this, "test.json")))
tasks.add(task)
}
private fun screenShot() { private fun screenShot() {
Thread(Runnable { Thread(Runnable {
......
package com.duolebo.blyrobot.tools
import com.duolebo.blyrobot.data.Task
import kotlin.collections.ArrayList
class TaskManager {
private val tasks = ArrayList<Task>()
fun add(task: Task) {
this.tasks.add(task)
}
fun remove(task: Task) {
val item = tasks.find {
it.packageName == task.packageName
}
item?.run {
tasks.remove(this)
}
}
fun isExist(task: Task): Boolean {
val item = tasks.find {
it.packageName == task.packageName
}
return item != null
}
fun start() {
}
fun stop() {
}
}
\ No newline at end of file
package com.duolebo.blyrobot.util package com.duolebo.blyrobot.util
import android.content.Context
import android.text.TextUtils import android.text.TextUtils
import java.net.Inet4Address import java.net.Inet4Address
import java.net.NetworkInterface import java.net.NetworkInterface
...@@ -117,4 +118,18 @@ object AppUtil { ...@@ -117,4 +118,18 @@ object AppUtil {
return result return result
} }
fun readFromAssert(context: Context, fileName: String): String {
var res = ""
try {
val inputStream = context.assets.open(fileName)
res = fileRead(inputStream)
inputStream.close()
} catch (e: IOException) {
// TODO Auto-generated catch block
e.printStackTrace()
}
return res
}
} }
\ No newline at end of file
package com.duolebo.blyrobot.util package com.duolebo.blyrobot.util
object Constants { object Constants {
val KEY_URL = "url"
val KEY_TIME = "time"
val KEY_MAP = mapOf( val KEY_MAP = mapOf(
"0" to "7", "0" to "7",
"1" to "8", "1" to "8",
......
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