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
2662cddf
Commit
2662cddf
authored
Nov 16, 2018
by
liuyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
APK抓包>从频道1开始依次抓取, 截图epg逻辑优化
#BYLSERVER-1693
parent
83be0201
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
50 deletions
+44
-50
Task.kt
app/src/main/java/com/duolebo/blyrobot/data/Task.kt
+44
-50
No files found.
app/src/main/java/com/duolebo/blyrobot/data/Task.kt
View file @
2662cddf
...
@@ -209,26 +209,31 @@ class Task : Thread, IAppBaseCallback {
...
@@ -209,26 +209,31 @@ class Task : Thread, IAppBaseCallback {
*/
*/
private
fun
processChannels
(
index
:
Int
):
Boolean
{
private
fun
processChannels
(
index
:
Int
):
Boolean
{
Log
.
i
(
TAG
,
"processChannels"
)
Log
.
i
(
TAG
,
"processChannels"
)
step
()
processChannelItem
()
quitCapture
()
quitCapture
()
AdbUtil
.
sendMultiKey
(
this
.
apkInfo
.
channelKeyEvent
)
for
(
i
in
index
+
1
until
this
.
apkInfo
.
channelCount
)
{
for
(
i
in
index
+
1
until
this
.
apkInfo
.
channelCount
)
{
if
(
this
.
status
==
State
.
MANUAL_STOP
)
if
(
this
.
status
==
State
.
MANUAL_STOP
)
return
false
return
false
// 模拟按键事件. 切换频道进行抓取
val
halfSeconds
=
apkInfo
.
captureDelay
/
2
;
this
.
channelIndex
=
i
this
.
channelIndex
=
i
capture
(
apkInfo
.
captureDelay
)
AdbUtil
.
sendMultiKey
(
this
.
apkInfo
.
channelKeyEvent
)
// 抓包挺
capture
(
apkInfo
.
captureDelay
,
false
)
sleepBySeconds
(
halfSeconds
+
1
)
if
(!
AppUtil
.
isAppForeground
(
context
,
this
.
apkInfo
.
packageName
))
{
if
(!
AppUtil
.
isAppForeground
(
context
,
this
.
apkInfo
.
packageName
))
{
Log
.
i
(
TAG
,
"target app crashed?"
)
Log
.
i
(
TAG
,
"target app crashed?"
)
return
false
return
false
}
}
step
()
processChannelItem
()
sleepBySeconds
(
halfSeconds
)
AdbUtil
.
sendMultiKey
(
this
.
apkInfo
.
channelKeyEvent
)
quitCapture
(
)
}
}
return
true
return
true
...
@@ -238,13 +243,9 @@ class Task : Thread, IAppBaseCallback {
...
@@ -238,13 +243,9 @@ class Task : Thread, IAppBaseCallback {
* 单个频道处理
* 单个频道处理
* 分析抓包数据+屏幕截图
* 分析抓包数据+屏幕截图
*/
*/
private
fun
step
()
{
private
fun
processChannelItem
()
{
Log
.
i
(
TAG
,
"step channel ${this.channelIndex}"
)
Log
.
i
(
TAG
,
"processChannelItem channel ${this.channelIndex}"
)
doCapture
()
// 处理抓包数据
doScreenShot
()
}
private
fun
doCapture
()
{
var
playUrlItems
=
analysisCapture
()
var
playUrlItems
=
analysisCapture
()
// 如果没有抓取到地址,再次尝试
// 如果没有抓取到地址,再次尝试
if
(
playUrlItems
.
size
<=
0
)
{
if
(
playUrlItems
.
size
<=
0
)
{
...
@@ -253,7 +254,6 @@ class Task : Thread, IAppBaseCallback {
...
@@ -253,7 +254,6 @@ class Task : Thread, IAppBaseCallback {
}
}
val
channels
=
this
.
reportJson
.
optJSONArray
(
"channels"
)
val
channels
=
this
.
reportJson
.
optJSONArray
(
"channels"
)
val
channelJson
=
JSONObject
()
val
channelJson
=
JSONObject
()
channelJson
.
putOpt
(
"channelId"
,
this
.
channelIndex
)
val
playUrls
=
JSONArray
()
val
playUrls
=
JSONArray
()
for
(
playUrl
in
playUrlItems
)
{
for
(
playUrl
in
playUrlItems
)
{
...
@@ -262,6 +262,30 @@ class Task : Thread, IAppBaseCallback {
...
@@ -262,6 +262,30 @@ class Task : Thread, IAppBaseCallback {
channelJson
.
putOpt
(
"playUrls"
,
playUrls
)
channelJson
.
putOpt
(
"playUrls"
,
playUrls
)
// 处理图片上传信息
val
screenImages
=
ArrayList
<
String
>()
var
time
=
imageDateFormat
.
format
(
Date
())
val
absName
=
this
.
imagePath
+
"/${this.apkInfo.packageName}_${channelIndex}_$time"
screenShot
(
absName
)
screenImages
.
add
(
"$absName.jpg"
)
AdbUtil
.
sendMultiKey
(
this
.
apkInfo
.
menuKeyEvent
)
time
=
imageDateFormat
.
format
(
Date
())
val
absOkName
=
this
.
imagePath
+
"/${this.apkInfo.packageName}_${channelIndex}_${time}_ok"
screenShot
(
absOkName
)
screenImages
.
add
(
"$absOkName.jpg"
)
AdbUtil
.
sendMultiKey
(
"back"
)
if
(
screenImages
.
size
>
0
)
uploadImages
.
addAll
(
screenImages
)
val
channelImageFile
=
File
(
screenImages
[
0
])
channelJson
.
putOpt
(
"channelImage"
,
channelImageFile
.
name
)
val
channelEpgImageFile
=
File
(
screenImages
[
1
])
channelJson
.
putOpt
(
"channelEpgImage"
,
channelEpgImageFile
.
name
)
channelJson
.
putOpt
(
"channelId"
,
this
.
channelIndex
)
channels
.
put
(
channelJson
)
channels
.
put
(
channelJson
)
}
}
...
@@ -277,8 +301,7 @@ class Task : Thread, IAppBaseCallback {
...
@@ -277,8 +301,7 @@ class Task : Thread, IAppBaseCallback {
if
(
quit
)
{
if
(
quit
)
{
Log
.
i
(
TAG
,
"capture sleep $delay seconds"
)
Log
.
i
(
TAG
,
"capture sleep $delay seconds"
)
sleepBySeconds
(
delay
)
sleepBySeconds
(
delay
.
toLong
())
quitCapture
()
quitCapture
()
}
}
}
}
...
@@ -354,39 +377,10 @@ class Task : Thread, IAppBaseCallback {
...
@@ -354,39 +377,10 @@ class Task : Thread, IAppBaseCallback {
return
playUrlItems
return
playUrlItems
}
}
// 截取一张频道图+一张显示频道节目的图
private
fun
sleepBySeconds
(
seconds
:
Int
)
{
private
fun
doScreenShot
()
{
Log
.
i
(
TAG
,
"sleep seconds:$seconds"
)
val
screenImages
=
ArrayList
<
String
>()
var
time
=
imageDateFormat
.
format
(
Date
())
val
absName
=
this
.
imagePath
+
"/${this.apkInfo.packageName}_${channelIndex}_$time"
screenShot
(
absName
)
screenImages
.
add
(
"$absName.jpg"
)
AdbUtil
.
sendMultiKey
(
this
.
apkInfo
.
menuKeyEvent
)
time
=
imageDateFormat
.
format
(
Date
())
val
absOkName
=
this
.
imagePath
+
"/${this.apkInfo.packageName}_${channelIndex}_${time}_ok"
screenShot
(
absOkName
)
screenImages
.
add
(
"$absOkName.jpg"
)
AdbUtil
.
sendMultiKey
(
"back"
)
if
(
screenImages
.
size
>
0
)
uploadImages
.
addAll
(
screenImages
)
val
channelJson
=
JSONObject
()
val
channelImageFile
=
File
(
screenImages
[
0
])
channelJson
.
putOpt
(
"channelImage"
,
channelImageFile
.
name
)
val
channelEpgImageFile
=
File
(
screenImages
[
1
])
channelJson
.
putOpt
(
"channelEpgImage"
,
channelEpgImageFile
.
name
)
channelJson
.
putOpt
(
"channelId"
,
this
.
channelIndex
)
}
private
fun
sleepBySeconds
(
seconds
:
Long
)
{
try
{
try
{
Thread
.
sleep
(
seconds
*
1000
)
Thread
.
sleep
(
(
seconds
*
1000
).
toLong
()
)
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
e
.
printStackTrace
()
}
}
...
@@ -440,7 +434,7 @@ class Task : Thread, IAppBaseCallback {
...
@@ -440,7 +434,7 @@ class Task : Thread, IAppBaseCallback {
//通过ftp上传图片到服务器
//通过ftp上传图片到服务器
private
fun
uploadImage
()
{
private
fun
uploadImage
()
{
Log
.
i
(
TAG
,
"upload image...."
)
try
{
try
{
val
uploadRequest
=
FTPUploadRequest
(
context
,
Config
.
instance
.
getFtpServer
(),
21
)
val
uploadRequest
=
FTPUploadRequest
(
context
,
Config
.
instance
.
getFtpServer
(),
21
)
.
setUsernameAndPassword
(
Config
.
instance
.
getFtpUserName
(),
Config
.
instance
.
getFtpPassword
())
.
setUsernameAndPassword
(
Config
.
instance
.
getFtpUserName
(),
Config
.
instance
.
getFtpPassword
())
...
...
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