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
c76d67f3
Commit
c76d67f3
authored
Nov 19, 2018
by
liuyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
APK抓包>从频道1开始依次抓取, 清除png图片,减少磁盘空间占用
#BYLSERVER-1693
parent
60741e96
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
14 deletions
+41
-14
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-0
MainActivity.kt
app/src/main/java/com/duolebo/blyrobot/MainActivity.kt
+4
-1
Task.kt
app/src/main/java/com/duolebo/blyrobot/data/Task.kt
+11
-12
AppUtil.kt
app/src/main/java/com/duolebo/blyrobot/util/AppUtil.kt
+25
-1
No files found.
app/src/main/AndroidManifest.xml
View file @
c76d67f3
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.READ_LOGS"
/>
<application
<application
android:allowBackup=
"true"
android:allowBackup=
"true"
...
...
app/src/main/java/com/duolebo/blyrobot/MainActivity.kt
View file @
c76d67f3
...
@@ -47,6 +47,10 @@ class MainActivity : AppCompatActivity(), IAppBaseCallback {
...
@@ -47,6 +47,10 @@ class MainActivity : AppCompatActivity(), IAppBaseCallback {
Log
.
i
(
TAG
,
"onCreate...."
)
Log
.
i
(
TAG
,
"onCreate...."
)
setContentView
(
R
.
layout
.
activity_main
)
setContentView
(
R
.
layout
.
activity_main
)
init
()
}
private
fun
init
()
{
getLocalAppList
()
getLocalAppList
()
this
.
appInfoAdapter
=
AppConfigAdapter
()
this
.
appInfoAdapter
=
AppConfigAdapter
()
...
@@ -84,7 +88,6 @@ class MainActivity : AppCompatActivity(), IAppBaseCallback {
...
@@ -84,7 +88,6 @@ class MainActivity : AppCompatActivity(), IAppBaseCallback {
this
.
appInfoAdapter
.
clear
()
this
.
appInfoAdapter
.
clear
()
requestAppList
()
requestAppList
()
}
}
}
}
private
fun
start
()
{
private
fun
start
()
{
...
...
app/src/main/java/com/duolebo/blyrobot/data/Task.kt
View file @
c76d67f3
...
@@ -56,7 +56,7 @@ class Task : Thread, IAppBaseCallback {
...
@@ -56,7 +56,7 @@ class Task : Thread, IAppBaseCallback {
constructor
(
context
:
Context
)
{
constructor
(
context
:
Context
)
{
this
.
context
=
context
this
.
context
=
context
this
.
reportProtocol
=
ApkReportProtocol
(
context
,
Config
.
instance
)
this
.
reportProtocol
=
ApkReportProtocol
(
context
,
Config
.
instance
)
this
.
reportProtocol
.
retryPolicy
=
DefaultRetryPolicy
(
1
0
*
1000
,
3
,
DEFAULT_BACKOFF_MULT
)
this
.
reportProtocol
.
retryPolicy
=
DefaultRetryPolicy
(
3
0
*
1000
,
3
,
DEFAULT_BACKOFF_MULT
)
this
.
dataHandler
=
AppBaseHandler
(
this
)
this
.
dataHandler
=
AppBaseHandler
(
this
)
}
}
...
@@ -179,13 +179,6 @@ class Task : Thread, IAppBaseCallback {
...
@@ -179,13 +179,6 @@ 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
()
}
}
}
/**
/**
...
@@ -407,8 +400,10 @@ class Task : Thread, IAppBaseCallback {
...
@@ -407,8 +400,10 @@ class Task : Thread, IAppBaseCallback {
AdbUtil
.
screenShot
(
pngPath
)
AdbUtil
.
screenShot
(
pngPath
)
// png转换成jpg
// png转换成jpg
val
pngFile
=
File
(
pngPath
)
val
pngFile
=
File
(
pngPath
)
if
(
pngFile
.
exists
())
if
(
pngFile
.
exists
())
{
AppUtil
.
pngToJpg
(
pngPath
,
jpgPath
)
AppUtil
.
pngToJpg
(
pngPath
,
jpgPath
)
pngFile
.
delete
()
}
else
{
else
{
Log
.
i
(
TAG
,
"screen shot failed"
)
Log
.
i
(
TAG
,
"screen shot failed"
)
}
}
...
@@ -480,9 +475,13 @@ class Task : Thread, IAppBaseCallback {
...
@@ -480,9 +475,13 @@ class Task : Thread, IAppBaseCallback {
Log
.
i
(
TAG
,
"report...."
)
Log
.
i
(
TAG
,
"report...."
)
val
postJson
=
JSONObject
()
val
postJson
=
JSONObject
()
val
reportArray
=
JSONArray
()
val
reportArray
=
JSONArray
()
try
{
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
)
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
val
reportPath
=
this
.
taskPath
+
"/"
+
this
.
imageDateFormat
.
format
(
Date
())
+
"_report.json"
val
reportPath
=
this
.
taskPath
+
"/"
+
this
.
imageDateFormat
.
format
(
Date
())
+
"_report.json"
AppUtil
.
saveToFile
(
reportPath
,
postJson
.
toString
())
AppUtil
.
saveToFile
(
reportPath
,
postJson
.
toString
())
...
...
app/src/main/java/com/duolebo/blyrobot/util/AppUtil.kt
View file @
c76d67f3
...
@@ -14,6 +14,9 @@ import android.os.Build
...
@@ -14,6 +14,9 @@ import android.os.Build
import
android.os.Environment
import
android.os.Environment
import
java.util.regex.Pattern
import
java.util.regex.Pattern
import
android.app.ActivityManager.RunningAppProcessInfo
import
android.app.ActivityManager.RunningAppProcessInfo
import
java.nio.file.Files.delete
...
@@ -76,13 +79,34 @@ object AppUtil {
...
@@ -76,13 +79,34 @@ object AppUtil {
fun
pngToJpg
(
pngFilePath
:
String
,
jpgFilePath
:
String
)
{
fun
pngToJpg
(
pngFilePath
:
String
,
jpgFilePath
:
String
)
{
val
bitmap
=
BitmapFactory
.
decodeFile
(
pngFilePath
)
val
bitmap
=
BitmapFactory
.
decodeFile
(
pngFilePath
)
try
{
try
{
BufferedOutputStream
(
FileOutputStream
(
jpgFilePath
)).
use
{
bos
->
val
fos
=
FileOutputStream
(
jpgFilePath
)
BufferedOutputStream
(
fos
).
use
{
bos
->
if
(
bitmap
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
80
,
bos
))
{
if
(
bitmap
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
80
,
bos
))
{
bos
.
flush
()
bos
.
flush
()
}
}
bos
.
close
()
}
fos
.
close
()
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
finally
{
bitmap
!!
.
recycle
()
}
}
fun
pngToJpg2
(
pngFilePath
:
String
,
jpgFilePath
:
String
)
{
val
bitmap
:
Bitmap
?
=
BitmapFactory
.
decodeFile
(
pngFilePath
)
try
{
val
bos
=
BufferedOutputStream
(
FileOutputStream
(
jpgFilePath
))
bitmap
?.
run
{
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
100
,
bos
)
bos
.
flush
()
}
}
bos
.
close
()
}
catch
(
e
:
IOException
)
{
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
e
.
printStackTrace
()
}
finally
{
bitmap
!!
.
recycle
()
}
}
}
}
...
...
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