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
800f67e4
Commit
800f67e4
authored
Dec 07, 2018
by
liuyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
APK图片抓取识别及轮播流地址抓取, 分离service和界面,避免程序在后台被杀
#BYLSERVER-1438
parent
474563b9
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
9 deletions
+17
-9
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-2
MainActivity.kt
app/src/main/java/com/duolebo/blyrobot/MainActivity.kt
+9
-3
Task.kt
app/src/main/java/com/duolebo/blyrobot/data/Task.kt
+1
-0
BylRobotService.kt
...main/java/com/duolebo/blyrobot/service/BylRobotService.kt
+5
-3
TaskManager.kt
app/src/main/java/com/duolebo/blyrobot/tools/TaskManager.kt
+1
-1
No files found.
app/src/main/AndroidManifest.xml
View file @
800f67e4
...
...
@@ -9,7 +9,6 @@
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.READ_LOGS"
/>
<application
android:allowBackup=
"true"
...
...
@@ -30,7 +29,7 @@
<activity
android:name=
".CaptureActivity"
/>
<activity
android:name=
".activity.PackageListActivity"
/>
<service
android:name=
".service.BylRobotService"
/>
<service
android:name=
".service.BylRobotService"
/>
<service
android:name=
".service.BylWebService"
/>
<receiver
android:name=
".service.BootBroadcastReceiver"
>
...
...
app/src/main/java/com/duolebo/blyrobot/MainActivity.kt
View file @
800f67e4
...
...
@@ -56,6 +56,11 @@ class MainActivity : AppCompatActivity(), IAppBaseCallback {
this
.
appInfoAdapter
=
AppConfigAdapter
()
listView
.
adapter
=
this
.
appInfoAdapter
listView
.
setOnItemClickListener
{
_
,
_
,
position
,
_
->
val
itemData
=
this
.
appInfoAdapter
.
getItem
(
position
)
as
ApkInfo
AdbUtil
.
launchApp
(
"${itemData.packageName}/${itemData.launcher}"
)
}
initRefreshTimer
()
val
hasRoot
=
AdbUtil
.
checkRootPermission
()
...
...
@@ -172,13 +177,13 @@ class MainActivity : AppCompatActivity(), IAppBaseCallback {
Log
.
i
(
TAG
,
"startRobot..."
)
val
intent
=
Intent
(
Constants
.
ACTION_LOCAL_SERVICE
)
intent
.
putExtra
(
Constants
.
KEY_CMD
,
Constants
.
CMD_START
)
LocalBroadcastManager
.
getInstance
(
this
).
sendBroadcast
(
intent
)
sendBroadcast
(
intent
)
}
private
fun
stopRobot
()
{
val
intent
=
Intent
(
Constants
.
ACTION_LOCAL_SERVICE
)
intent
.
putExtra
(
Constants
.
KEY_CMD
,
Constants
.
CMD_STOP
)
LocalBroadcastManager
.
getInstance
(
this
).
sendBroadcast
(
intent
)
sendBroadcast
(
intent
)
}
override
fun
onProtocolFailed
(
protocol
:
IProtocol
?)
{
...
...
@@ -263,8 +268,9 @@ class MainActivity : AppCompatActivity(), IAppBaseCallback {
else
itemView
=
convertView
as
AppConfigListItem
val
itemData
=
dataList
[
position
]
itemView
.
setData
(
dataList
[
position
])
val
drawable
=
getAppIcon
(
dataList
[
position
]
.
packageName
)
val
drawable
=
getAppIcon
(
itemData
.
packageName
)
drawable
?.
run
{
itemView
.
setIcon
(
this
)
}
...
...
app/src/main/java/com/duolebo/blyrobot/data/Task.kt
View file @
800f67e4
...
...
@@ -397,6 +397,7 @@ class Task : Thread, IAppBaseCallback {
Log
.
i
(
TAG
,
"sleep seconds:$seconds"
)
try
{
Thread
.
sleep
((
seconds
*
1000
).
toLong
())
// AdbUtil.exeCmdEcho("sleep $seconds", true)
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
...
...
app/src/main/java/com/duolebo/blyrobot/service/BylRobotService.kt
View file @
800f67e4
...
...
@@ -48,13 +48,13 @@ class BylRobotService: Service(), IAppBaseCallback {
super
.
onCreate
()
FtpManager
.
instance
.
start
()
initBroadcast
()
//
requestAppList()
requestAppList
()
}
private
fun
initBroadcast
()
{
Log
.
i
(
TAG
,
"initBroadcast..."
)
val
intentFilter
=
IntentFilter
(
Constants
.
ACTION_LOCAL_SERVICE
)
LocalBroadcastManager
.
getInstance
(
this
).
registerReceiver
(
broadcastReceiver
,
intentFilter
)
registerReceiver
(
broadcastReceiver
,
intentFilter
)
}
private
fun
requestAppList
()
{
...
...
@@ -93,7 +93,7 @@ class BylRobotService: Service(), IAppBaseCallback {
super
.
onDestroy
()
stopTask
()
FtpManager
.
instance
.
stop
()
LocalBroadcastManager
.
getInstance
(
this
).
unregisterReceiver
(
broadcastReceiver
)
unregisterReceiver
(
broadcastReceiver
)
}
override
fun
onProtocolFailed
(
protocol
:
IProtocol
?)
{
...
...
@@ -113,6 +113,8 @@ class BylRobotService: Service(), IAppBaseCallback {
TaskManager
.
instance
.
add
(
task
)
}
}
loadTask
()
}
}
}
\ No newline at end of file
app/src/main/java/com/duolebo/blyrobot/tools/TaskManager.kt
View file @
800f67e4
...
...
@@ -110,7 +110,7 @@ class TaskManager {
}
}
Thread
.
sleep
(
3
*
1000
)
Thread
.
sleep
(
5
*
1000
)
}
}
},
0
,
RUN_TASK_PERIOD
)
...
...
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