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.*
class Task {
private lateinit var packageName: String
lateinit var packageName: String
private lateinit var launcher: String
private lateinit var imagePath: String
private var launchDelay = 15
......@@ -22,7 +22,7 @@ class Task {
private val imageDateFormat = SimpleDateFormat("yyyy_MM_dd_HH_mm_ss", Locale.CHINA)
var proc: Process ?= null
public constructor(context: Context) {
constructor(context: Context) {
this.context = context
}
......@@ -89,17 +89,16 @@ class Task {
val host = it.substring(start)
val url = "http://$host$partUrl"
val item = JSONObject()
item.put("url", url)
item.put("time", timeStr)
item.put(Constants.KEY_URL, url)
item.put(Constants.KEY_TIME, timeStr)
playUrlItems.put(item)
partUrl = ""
}
}
if (playUrlItems.length() > 0) {
for (i in 0..playUrlItems.length()) {
playUrlItems.get(i)
}
for (i in 0..playUrlItems.length()) {
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
import android.annotation.SuppressLint
import android.app.Service
import android.content.Intent
import android.os.Environment
import android.os.IBinder
import android.util.Log
import com.duolebo.blyrobot.data.Task
import com.duolebo.blyrobot.util.AdbUtil
import java.text.SimpleDateFormat
import com.duolebo.blyrobot.util.AppUtil
import org.json.JSONObject
import java.util.*
@SuppressLint("Registered")
......@@ -16,6 +17,7 @@ class BylRobotService: Service() {
private val TAG = "BylRobotService"
private var timer: Timer? = null
private var count = 0
private val tasks = ArrayList<Task>()
override fun onCreate() {
super.onCreate()
......@@ -36,6 +38,13 @@ class BylRobotService: Service() {
},2000, 10*1000)
}
private fun loadTask() {
val task = Task(this)
task.from(JSONObject(AppUtil.readFromAssert(this, "test.json")))
tasks.add(task)
}
private fun screenShot() {
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
import android.content.Context
import android.text.TextUtils
import java.net.Inet4Address
import java.net.NetworkInterface
......@@ -117,4 +118,18 @@ object AppUtil {
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
object Constants {
val KEY_URL = "url"
val KEY_TIME = "time"
val KEY_MAP = mapOf(
"0" to "7",
"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