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
60741e96
Commit
60741e96
authored
Nov 19, 2018
by
liuyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
APK抓包>从频道1开始依次抓取, HDP多于100频道抓取成功上报失败跟踪
#BYLSERVER-1693
parent
05ae7ce0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
8 deletions
+32
-8
Task.kt
app/src/main/java/com/duolebo/blyrobot/data/Task.kt
+20
-8
AppUtil.kt
app/src/main/java/com/duolebo/blyrobot/util/AppUtil.kt
+12
-0
No files found.
app/src/main/java/com/duolebo/blyrobot/data/Task.kt
View file @
60741e96
...
@@ -35,7 +35,7 @@ class Task : Thread, IAppBaseCallback {
...
@@ -35,7 +35,7 @@ class Task : Thread, IAppBaseCallback {
lateinit
var
apkInfo
:
ApkInfo
lateinit
var
apkInfo
:
ApkInfo
// 截图存放路径
// 截图存放路径
private
lateinit
var
image
Path
:
String
private
lateinit
var
task
Path
:
String
// 抓包存放路径
// 抓包存放路径
private
var
capturePath
=
AppUtil
.
getAbsoluteSdcardPath
()
+
"/capture.txt"
private
var
capturePath
=
AppUtil
.
getAbsoluteSdcardPath
()
+
"/capture.txt"
...
@@ -71,10 +71,9 @@ class Task : Thread, IAppBaseCallback {
...
@@ -71,10 +71,9 @@ class Task : Thread, IAppBaseCallback {
*/
*/
fun
from
(
apkInfo
:
ApkInfo
)
{
fun
from
(
apkInfo
:
ApkInfo
)
{
this
.
apkInfo
=
apkInfo
this
.
apkInfo
=
apkInfo
// this.imagePath = this.context.cacheDir.absolutePath + "/" + apkInfo.packageName
val
sdPath
=
AppUtil
.
getAbsoluteSdcardPath
()
val
sdPath
=
AppUtil
.
getAbsoluteSdcardPath
()
this
.
image
Path
=
sdPath
+
"/upload/"
+
apkInfo
.
packageName
this
.
task
Path
=
sdPath
+
"/upload/"
+
apkInfo
.
packageName
val
dir
=
File
(
this
.
image
Path
)
val
dir
=
File
(
this
.
task
Path
)
if
(!
dir
.
exists
())
if
(!
dir
.
exists
())
dir
.
mkdirs
()
dir
.
mkdirs
()
}
}
...
@@ -149,12 +148,15 @@ class Task : Thread, IAppBaseCallback {
...
@@ -149,12 +148,15 @@ class Task : Thread, IAppBaseCallback {
this
.
channelIndex
=
0
this
.
channelIndex
=
0
this
.
uploadImages
.
clear
()
this
.
uploadImages
.
clear
()
val
dir
=
File
(
this
.
image
Path
)
val
dir
=
File
(
this
.
task
Path
)
if
(
dir
.
exists
())
{
if
(
dir
.
exists
())
{
for
(
file
in
dir
.
listFiles
())
for
(
file
in
dir
.
listFiles
())
{
if
(
file
.
name
.
endsWith
(
".log"
))
continue
file
.
delete
()
file
.
delete
()
}
}
}
}
}
fun
release
()
{
fun
release
()
{
// 杀掉tcpdump进程
// 杀掉tcpdump进程
...
@@ -177,6 +179,13 @@ class Task : Thread, IAppBaseCallback {
...
@@ -177,6 +179,13 @@ class Task : Thread, IAppBaseCallback {
this
.
taskListener
?.
run
{
this
.
taskListener
?.
run
{
onComplete
(
result
)
onComplete
(
result
)
}
}
try
{
val
logPath
=
this
.
taskPath
+
"/"
+
this
.
imageDateFormat
.
format
(
Date
())
+
".log"
Runtime
.
getRuntime
().
exec
(
"logcat -f $logPath"
)
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
}
}
/**
/**
...
@@ -268,13 +277,13 @@ class Task : Thread, IAppBaseCallback {
...
@@ -268,13 +277,13 @@ class Task : Thread, IAppBaseCallback {
val
screenImages
=
ArrayList
<
String
>()
val
screenImages
=
ArrayList
<
String
>()
var
time
=
imageDateFormat
.
format
(
Date
())
var
time
=
imageDateFormat
.
format
(
Date
())
val
absName
=
this
.
image
Path
+
"/${this.apkInfo.packageName}_${channelIndex}_$time"
val
absName
=
this
.
task
Path
+
"/${this.apkInfo.packageName}_${channelIndex}_$time"
screenShot
(
absName
)
screenShot
(
absName
)
screenImages
.
add
(
"$absName.jpg"
)
screenImages
.
add
(
"$absName.jpg"
)
AdbUtil
.
sendMultiKey
(
this
.
apkInfo
.
menuKeyEvent
)
AdbUtil
.
sendMultiKey
(
this
.
apkInfo
.
menuKeyEvent
)
time
=
imageDateFormat
.
format
(
Date
())
time
=
imageDateFormat
.
format
(
Date
())
val
absOkName
=
this
.
image
Path
+
"/${this.apkInfo.packageName}_${channelIndex}_${time}_ok"
val
absOkName
=
this
.
task
Path
+
"/${this.apkInfo.packageName}_${channelIndex}_${time}_ok"
screenShot
(
absOkName
)
screenShot
(
absOkName
)
screenImages
.
add
(
"$absOkName.jpg"
)
screenImages
.
add
(
"$absOkName.jpg"
)
...
@@ -474,6 +483,9 @@ class Task : Thread, IAppBaseCallback {
...
@@ -474,6 +483,9 @@ class Task : Thread, IAppBaseCallback {
reportArray
.
put
(
this
.
reportJson
)
reportArray
.
put
(
this
.
reportJson
)
postJson
.
putOpt
(
"data"
,
reportArray
)
postJson
.
putOpt
(
"data"
,
reportArray
)
reportProtocol
.
withBody
(
postJson
.
toString
()).
execute
(
dataHandler
)
reportProtocol
.
withBody
(
postJson
.
toString
()).
execute
(
dataHandler
)
val
reportPath
=
this
.
taskPath
+
"/"
+
this
.
imageDateFormat
.
format
(
Date
())
+
"_report.json"
AppUtil
.
saveToFile
(
reportPath
,
postJson
.
toString
())
}
}
override
fun
onProtocolFailed
(
p0
:
IProtocol
?)
{
override
fun
onProtocolFailed
(
p0
:
IProtocol
?)
{
...
...
app/src/main/java/com/duolebo/blyrobot/util/AppUtil.kt
View file @
60741e96
...
@@ -188,4 +188,16 @@ object AppUtil {
...
@@ -188,4 +188,16 @@ object AppUtil {
}
}
return
false
return
false
}
}
fun
saveToFile
(
fileName
:
String
,
content
:
String
)
{
try
{
val
fw
=
FileWriter
(
File
(
fileName
))
fw
.
write
(
content
)
fw
.
close
()
}
catch
(
e
:
FileNotFoundException
)
{
e
.
printStackTrace
()
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
}
}
}
\ No newline at end of file
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