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
0ab9467f
Commit
0ab9467f
authored
Nov 20, 2018
by
liuyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
APK抓包>从频道1开始依次抓取, ftp上传优化
#BYLSERVER-1693
parent
4e6bf84b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
13 deletions
+21
-13
ImageUploadTask.kt
...rc/main/java/com/duolebo/blyrobot/data/ImageUploadTask.kt
+15
-9
BylRobotService.kt
...main/java/com/duolebo/blyrobot/service/BylRobotService.kt
+2
-3
FtpManager.kt
app/src/main/java/com/duolebo/blyrobot/tools/FtpManager.kt
+4
-1
No files found.
app/src/main/java/com/duolebo/blyrobot/data/ImageUploadTask.kt
View file @
0ab9467f
...
@@ -2,7 +2,6 @@ package com.duolebo.blyrobot.data
...
@@ -2,7 +2,6 @@ package com.duolebo.blyrobot.data
import
android.content.Context
import
android.content.Context
import
android.util.Log
import
android.util.Log
import
com.duolebo.blyrobot.tools.FtpManager
import
com.duolebo.blyrobot.util.Config
import
com.duolebo.blyrobot.util.Config
import
net.gotev.uploadservice.*
import
net.gotev.uploadservice.*
import
net.gotev.uploadservice.ftp.FTPUploadRequest
import
net.gotev.uploadservice.ftp.FTPUploadRequest
...
@@ -14,6 +13,11 @@ import java.io.File
...
@@ -14,6 +13,11 @@ import java.io.File
*/
*/
class
ImageUploadTask
{
class
ImageUploadTask
{
companion
object
{
const
val
TAG
=
"RobotTaskUpload"
}
var
packageName
:
String
=
""
var
uploadImages
=
ArrayList
<
String
>()
var
uploadImages
=
ArrayList
<
String
>()
var
uploadId
:
String
=
""
var
uploadId
:
String
=
""
var
reUpload
=
false
var
reUpload
=
false
...
@@ -26,6 +30,7 @@ class ImageUploadTask {
...
@@ -26,6 +30,7 @@ class ImageUploadTask {
}
}
fun
from
(
task
:
Task
)
{
fun
from
(
task
:
Task
)
{
this
.
packageName
=
task
.
apkInfo
.
packageName
this
.
uploadImages
.
clear
()
this
.
uploadImages
.
clear
()
this
.
uploadImages
.
addAll
(
task
.
uploadImages
)
this
.
uploadImages
.
addAll
(
task
.
uploadImages
)
}
}
...
@@ -58,7 +63,7 @@ class ImageUploadTask {
...
@@ -58,7 +63,7 @@ class ImageUploadTask {
}
}
private
fun
uploadImage
()
{
private
fun
uploadImage
()
{
Log
.
i
(
FtpManager
.
TAG
,
"upload image...."
)
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
())
...
@@ -77,14 +82,14 @@ class ImageUploadTask {
...
@@ -77,14 +82,14 @@ class ImageUploadTask {
}
}
this
.
uploadId
=
uploadRequest
.
startUpload
()
this
.
uploadId
=
uploadRequest
.
startUpload
()
Log
.
i
(
FtpManager
.
TAG
,
"upload id $uploadId"
)
Log
.
i
(
TAG
,
"upload id $uploadId"
)
}
catch
(
exc
:
Exception
)
{
}
catch
(
exc
:
Exception
)
{
Log
.
e
(
FtpManager
.
TAG
,
exc
.
message
,
exc
)
Log
.
e
(
TAG
,
exc
.
message
,
exc
)
}
}
}
}
private
fun
uploadComplete
(
errorCount
:
Int
)
{
private
fun
uploadComplete
(
errorCount
:
Int
)
{
Log
.
i
(
FtpManager
.
TAG
,
"upload errorCount: $errorCount"
)
Log
.
i
(
TAG
,
"upload errorCount: $errorCount"
)
this
.
isRunning
=
false
this
.
isRunning
=
false
if
(
errorCount
>
0
&&
errorCount
>
this
.
uploadImages
.
size
/
3
)
{
if
(
errorCount
>
0
&&
errorCount
>
this
.
uploadImages
.
size
/
3
)
{
this
.
reUpload
=
true
this
.
reUpload
=
true
...
@@ -105,24 +110,25 @@ class ImageUploadTask {
...
@@ -105,24 +110,25 @@ class ImageUploadTask {
*/
*/
private
fun
uploadImageCallback
():
UploadStatusDelegate
{
private
fun
uploadImageCallback
():
UploadStatusDelegate
{
val
totalUpload
=
this
.
uploadImages
.
size
val
totalUpload
=
this
.
uploadImages
.
size
Log
.
i
(
FtpManager
.
TAG
,
"total upload count : $totalUpload"
)
Log
.
i
(
TAG
,
"total upload count : $totalUpload"
)
return
object
:
UploadStatusDelegate
{
return
object
:
UploadStatusDelegate
{
override
fun
onCancelled
(
context
:
Context
?,
uploadInfo
:
UploadInfo
?)
{
override
fun
onCancelled
(
context
:
Context
?,
uploadInfo
:
UploadInfo
?)
{
// empty
}
}
override
fun
onProgress
(
context
:
Context
?,
uploadInfo
:
UploadInfo
?)
{
override
fun
onProgress
(
context
:
Context
?,
uploadInfo
:
UploadInfo
?)
{
// empty
}
}
override
fun
onError
(
context
:
Context
?,
uploadInfo
:
UploadInfo
?,
serverResponse
:
ServerResponse
?,
exception
:
java
.
lang
.
Exception
?)
{
override
fun
onError
(
context
:
Context
?,
uploadInfo
:
UploadInfo
?,
serverResponse
:
ServerResponse
?,
exception
:
java
.
lang
.
Exception
?)
{
val
uploadSize
=
uploadInfo
?.
successfullyUploadedFiles
!!
.
size
val
uploadSize
=
uploadInfo
?.
successfullyUploadedFiles
!!
.
size
Log
.
i
(
FtpManager
.
TAG
,
"onError...uploadCount: $uploadSize"
)
Log
.
i
(
TAG
,
"onError...uploadCount: $uploadSize"
)
}
}
override
fun
onCompleted
(
context
:
Context
?,
uploadInfo
:
UploadInfo
?,
serverResponse
:
ServerResponse
?)
{
override
fun
onCompleted
(
context
:
Context
?,
uploadInfo
:
UploadInfo
?,
serverResponse
:
ServerResponse
?)
{
val
uploadSize
=
uploadInfo
?.
successfullyUploadedFiles
!!
.
size
val
uploadSize
=
uploadInfo
?.
successfullyUploadedFiles
!!
.
size
Log
.
i
(
FtpManager
.
TAG
,
"onCompleted...uploadCount: $uploadSize"
)
Log
.
i
(
TAG
,
"onCompleted...uploadCount: $uploadSize"
)
uploadComplete
(
totalUpload
-
uploadSize
)
uploadComplete
(
totalUpload
-
uploadSize
)
}
}
}
}
...
...
app/src/main/java/com/duolebo/blyrobot/service/BylRobotService.kt
View file @
0ab9467f
...
@@ -18,12 +18,10 @@ import com.duolebo.blyrobot.data.Task
...
@@ -18,12 +18,10 @@ import com.duolebo.blyrobot.data.Task
import
com.duolebo.blyrobot.protocol.GetAppInfoProtocol
import
com.duolebo.blyrobot.protocol.GetAppInfoProtocol
import
com.duolebo.blyrobot.tools.FtpManager
import
com.duolebo.blyrobot.tools.FtpManager
import
com.duolebo.blyrobot.tools.TaskManager
import
com.duolebo.blyrobot.tools.TaskManager
import
com.duolebo.blyrobot.util.AdbUtil
import
com.duolebo.blyrobot.util.AppUtil
import
com.duolebo.blyrobot.util.AppUtil
import
com.duolebo.blyrobot.util.Config
import
com.duolebo.blyrobot.util.Config
import
com.duolebo.blyrobot.util.Constants
import
com.duolebo.blyrobot.util.Constants
import
org.json.JSONObject
import
org.json.JSONObject
import
java.util.*
@SuppressLint
(
"Registered"
)
@SuppressLint
(
"Registered"
)
class
BylRobotService
:
Service
(),
IAppBaseCallback
{
class
BylRobotService
:
Service
(),
IAppBaseCallback
{
...
@@ -48,7 +46,7 @@ class BylRobotService: Service(), IAppBaseCallback {
...
@@ -48,7 +46,7 @@ class BylRobotService: Service(), IAppBaseCallback {
override
fun
onCreate
()
{
override
fun
onCreate
()
{
super
.
onCreate
()
super
.
onCreate
()
FtpManager
.
instance
.
init
(
this
)
FtpManager
.
instance
.
start
(
)
initBroadcast
()
initBroadcast
()
// requestAppList()
// requestAppList()
}
}
...
@@ -93,6 +91,7 @@ class BylRobotService: Service(), IAppBaseCallback {
...
@@ -93,6 +91,7 @@ class BylRobotService: Service(), IAppBaseCallback {
override
fun
onDestroy
()
{
override
fun
onDestroy
()
{
Log
.
i
(
TAG
,
"destroy..."
)
Log
.
i
(
TAG
,
"destroy..."
)
super
.
onDestroy
()
super
.
onDestroy
()
FtpManager
.
instance
.
stop
()
LocalBroadcastManager
.
getInstance
(
this
).
unregisterReceiver
(
broadcastReceiver
)
LocalBroadcastManager
.
getInstance
(
this
).
unregisterReceiver
(
broadcastReceiver
)
}
}
...
...
app/src/main/java/com/duolebo/blyrobot/tools/FtpManager.kt
View file @
0ab9467f
package
com.duolebo.blyrobot.tools
package
com.duolebo.blyrobot.tools
import
android.util.Log
import
com.duolebo.blyrobot.data.ImageUploadTask
import
com.duolebo.blyrobot.data.ImageUploadTask
import
net.gotev.uploadservice.UploadService
import
net.gotev.uploadservice.UploadService
import
java.util.*
import
java.util.*
...
@@ -20,6 +21,7 @@ class FtpManager {
...
@@ -20,6 +21,7 @@ class FtpManager {
private
var
scheduleTime
:
Timer
?
=
null
private
var
scheduleTime
:
Timer
?
=
null
fun
start
()
{
fun
start
()
{
Log
.
i
(
TAG
,
"ftp manager start..."
)
scheduleTime
?.
run
{
cancel
()
}
scheduleTime
?.
run
{
cancel
()
}
this
.
isRunning
=
true
this
.
isRunning
=
true
scheduleTime
=
Timer
()
scheduleTime
=
Timer
()
...
@@ -28,13 +30,14 @@ class FtpManager {
...
@@ -28,13 +30,14 @@ class FtpManager {
while
(
isRunning
)
{
while
(
isRunning
)
{
for
(
uploadTask
in
uploadTasks
)
{
for
(
uploadTask
in
uploadTasks
)
{
if
(
uploadTask
.
needReUpload
())
{
if
(
uploadTask
.
needReUpload
())
{
Log
.
i
(
TAG
,
"task ${uploadTask.packageName} need upload again"
)
uploadTask
.
start
()
uploadTask
.
start
()
}
}
}
}
Thread
.
sleep
(
1
*
60
*
1000
)
Thread
.
sleep
(
1
*
60
*
1000
)
}
}
}
}
},
0
)
},
5
*
100
0
)
}
}
...
...
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