Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
BYLAppRobot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuyang
BYLAppRobot
Commits
8786046c
Commit
8786046c
authored
Sep 24, 2018
by
liuyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add task
parent
3dafa733
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
85 additions
and
10 deletions
+85
-10
test.json
app/src/main/assets/test.json
+6
-0
Task.kt
app/src/main/java/com/duolebo/blyrobot/data/Task.kt
+7
-8
GetAppConfig.kt
...c/main/java/com/duolebo/blyrobot/protocol/GetAppConfig.kt
+5
-0
BylRobotService.kt
...main/java/com/duolebo/blyrobot/service/BylRobotService.kt
+11
-2
TaskManager.kt
app/src/main/java/com/duolebo/blyrobot/tools/TaskManager.kt
+38
-0
AppUtil.kt
app/src/main/java/com/duolebo/blyrobot/util/AppUtil.kt
+15
-0
Constants.kt
app/src/main/java/com/duolebo/blyrobot/util/Constants.kt
+3
-0
No files found.
app/src/main/assets/test.json
0 → 100644
View file @
8786046c
{
"name"
:
"电视家"
,
"packageName"
:
"com.elinkway.tvlive2"
,
"launcher"
:
"com.elinkway.tvlive2.activity.SplashActivity"
,
"launchDelay"
:
"15"
}
\ No newline at end of file
app/src/main/java/com/duolebo/blyrobot/data/Task.kt
View file @
8786046c
...
...
@@ -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
)
}
}
...
...
app/src/main/java/com/duolebo/blyrobot/protocol/GetAppConfig.kt
0 → 100644
View file @
8786046c
package
com.duolebo.blyrobot.protocol
class
GetAppConfig
{
}
\ No newline at end of file
app/src/main/java/com/duolebo/blyrobot/service/BylRobotService.kt
View file @
8786046c
...
...
@@ -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
{
...
...
app/src/main/java/com/duolebo/blyrobot/tools/TaskManager.kt
0 → 100644
View file @
8786046c
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
app/src/main/java/com/duolebo/blyrobot/util/AppUtil.kt
View file @
8786046c
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
app/src/main/java/com/duolebo/blyrobot/util/Constants.kt
View file @
8786046c
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"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment