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
a7833cb4
Commit
a7833cb4
authored
Oct 24, 2018
by
liuyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log增加
parent
2edfb106
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
14 deletions
+63
-14
MainActivity.kt
app/src/main/java/com/duolebo/blyrobot/MainActivity.kt
+55
-12
AdbUtil.kt
app/src/main/java/com/duolebo/blyrobot/util/AdbUtil.kt
+8
-2
No files found.
app/src/main/java/com/duolebo/blyrobot/MainActivity.kt
View file @
a7833cb4
...
@@ -38,6 +38,8 @@ class MainActivity : AppCompatActivity(), IAppBaseCallback {
...
@@ -38,6 +38,8 @@ class MainActivity : AppCompatActivity(), IAppBaseCallback {
private
lateinit
var
appInfoAdapter
:
AppConfigAdapter
private
lateinit
var
appInfoAdapter
:
AppConfigAdapter
private
lateinit
var
refreshTimer
:
Timer
private
lateinit
var
refreshTimer
:
Timer
private
lateinit
var
appInfoData
:
AppInfoData
private
lateinit
var
appInfoData
:
AppInfoData
private
var
startSet
=
false
private
var
isStart
=
false
private
var
apkPackageInfo
:
List
<
ApkPackageInfo
>?
=
null
private
var
apkPackageInfo
:
List
<
ApkPackageInfo
>?
=
null
...
@@ -65,7 +67,14 @@ class MainActivity : AppCompatActivity(), IAppBaseCallback {
...
@@ -65,7 +67,14 @@ class MainActivity : AppCompatActivity(), IAppBaseCallback {
startRobotService
()
startRobotService
()
startBtn
.
setOnClickListener
{
startBtn
.
setOnClickListener
{
toggle
()
if
(
isStart
)
{
stop
()
}
else
{
start
()
}
isStart
=
!
isStart
}
}
startBtn
.
requestFocus
()
startBtn
.
requestFocus
()
...
@@ -79,8 +88,24 @@ class MainActivity : AppCompatActivity(), IAppBaseCallback {
...
@@ -79,8 +88,24 @@ class MainActivity : AppCompatActivity(), IAppBaseCallback {
}
}
private
fun
toggle
()
{
private
fun
start
()
{
// 暂时测试用
startBtn
.
isEnabled
=
false
if
(
TaskManager
.
instance
.
tasks
.
size
>
0
)
{
startRobot
()
startBtn
.
postDelayed
({
startBtn
.
isEnabled
=
true
startBtn
.
text
=
"停止"
refreshBtn
.
isEnabled
=
false
},
2000
)
}
else
{
startSet
=
true
requestAppList
()
}
}
private
fun
stop
()
{
if
(
TaskManager
.
instance
.
isRunning
)
{
if
(
TaskManager
.
instance
.
isRunning
)
{
stopRobot
()
stopRobot
()
startBtn
.
isEnabled
=
false
startBtn
.
isEnabled
=
false
...
@@ -90,15 +115,12 @@ class MainActivity : AppCompatActivity(), IAppBaseCallback {
...
@@ -90,15 +115,12 @@ class MainActivity : AppCompatActivity(), IAppBaseCallback {
refreshBtn
.
isEnabled
=
true
refreshBtn
.
isEnabled
=
true
},
3000
)
},
3000
)
}
}
else
{
}
startRobot
()
startBtn
.
isEnabled
=
false
private
fun
resetStartBtn
()
{
startBtn
.
postDelayed
({
startBtn
.
isEnabled
=
true
startBtn
.
isEnabled
=
true
startBtn
.
text
=
"开始"
startBtn
.
text
=
"停止"
refreshBtn
.
isEnabled
=
true
refreshBtn
.
isEnabled
=
false
},
2000
)
}
}
}
private
fun
requestAppList
()
{
private
fun
requestAppList
()
{
...
@@ -151,10 +173,18 @@ class MainActivity : AppCompatActivity(), IAppBaseCallback {
...
@@ -151,10 +173,18 @@ class MainActivity : AppCompatActivity(), IAppBaseCallback {
override
fun
onProtocolFailed
(
protocol
:
IProtocol
?)
{
override
fun
onProtocolFailed
(
protocol
:
IProtocol
?)
{
Toast
.
makeText
(
this
,
"获取应用列表信息出错"
,
Toast
.
LENGTH_SHORT
).
show
()
Toast
.
makeText
(
this
,
"获取应用列表信息出错"
,
Toast
.
LENGTH_SHORT
).
show
()
if
(
startSet
)
{
resetStartBtn
()
startSet
=
false
}
}
}
override
fun
onHttpFailed
(
protocol
:
IProtocol
?)
{
override
fun
onHttpFailed
(
protocol
:
IProtocol
?)
{
Toast
.
makeText
(
this
,
"网络错误"
,
Toast
.
LENGTH_SHORT
).
show
()
Toast
.
makeText
(
this
,
"网络错误"
,
Toast
.
LENGTH_SHORT
).
show
()
if
(
startSet
)
{
resetStartBtn
()
startSet
=
false
}
}
}
override
fun
onProtocolSucceed
(
protocol
:
IProtocol
?)
{
override
fun
onProtocolSucceed
(
protocol
:
IProtocol
?)
{
...
@@ -172,6 +202,19 @@ class MainActivity : AppCompatActivity(), IAppBaseCallback {
...
@@ -172,6 +202,19 @@ class MainActivity : AppCompatActivity(), IAppBaseCallback {
}
}
}
}
}
}
if
(
startSet
)
{
startBtn
.
isEnabled
=
true
if
(
TaskManager
.
instance
.
tasks
.
size
>
0
)
{
startRobot
()
startSet
=
false
startBtn
.
text
=
"停止"
refreshBtn
.
isEnabled
=
false
}
else
{
Toast
.
makeText
(
this
,
"没有任务可以执行"
,
Toast
.
LENGTH_SHORT
).
show
()
}
}
}
}
}
}
...
...
app/src/main/java/com/duolebo/blyrobot/util/AdbUtil.kt
View file @
a7833cb4
...
@@ -19,9 +19,11 @@ object AdbUtil {
...
@@ -19,9 +19,11 @@ object AdbUtil {
// 通过id判断是否有root权限,部分盒子是没有su的
// 通过id判断是否有root权限,部分盒子是没有su的
fun
checkRootPermission
():
Boolean
{
fun
checkRootPermission
():
Boolean
{
var
proc
=
getShellProc
(
ROOT_SHELL
)
?:
return
false
var
proc
=
getShellProc
(
ROOT_SHELL
)
?:
return
false
var
commands
=
ArrayList
<
String
>()
Log
.
i
(
TAG
,
"get root proc success!"
)
val
commands
=
ArrayList
<
String
>()
commands
.
add
(
"id -u"
)
commands
.
add
(
"id -u"
)
var
result
=
this
.
sendCommands
(
commands
,
proc
)
val
result
=
this
.
sendCommands
(
commands
,
proc
)
Log
.
i
(
TAG
,
"check permission error ${result.errorLines} and message ${result.successLines}"
)
if
(
isRoot
(
result
))
{
if
(
isRoot
(
result
))
{
return
true
return
true
}
}
...
@@ -58,6 +60,10 @@ object AdbUtil {
...
@@ -58,6 +60,10 @@ object AdbUtil {
e
.
printStackTrace
()
e
.
printStackTrace
()
}
}
if
(
proc
==
null
)
{
Log
.
i
(
TAG
,
"get root proc failed"
)
}
return
proc
return
proc
}
}
...
...
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