Commit 80c21a83 authored by liuyang's avatar liuyang

APK图片抓取识别及轮播流地址抓取, 增加自动清理图片缓存逻辑及部分异常捕捉

#BYLSERVER-1438
parent 74a9b4f1
......@@ -13,7 +13,7 @@ android {
minSdkVersion 15
targetSdkVersion 22
versionCode 15
versionName "1.4.40"
versionName "1.4.45"
}
signingConfigs {
......
......@@ -104,6 +104,7 @@ class Task : Thread, IAppBaseCallback {
var success = this.processChannels(0)
// 再次尝试
if (!success) {
Log.i(TAG, "app seems to be quit,so try again")
if (this.status == State.MANUAL_STOP) {
Log.i(TAG, "manual exit")
return
......@@ -116,9 +117,14 @@ class Task : Thread, IAppBaseCallback {
}
success = this.processChannels(this.channelIndex)
if (!success && this.status == State.MANUAL_STOP)
if (!success) {
Log.i(TAG, "interrupt on channel: $channelIndex")
if (this.status == State.MANUAL_STOP) {
Log.i(TAG, "manual exit and interrupt")
return
}
}
}
// 上传图片
this.uploadImage()
......@@ -126,6 +132,7 @@ class Task : Thread, IAppBaseCallback {
} catch (e: java.lang.Exception) {
this.status = State.INTERRUPT
e.printStackTrace()
Log.i(TAG, "exception : ${e.message}")
}
// 退出应用
AdbUtil.stopApp(this.apkInfo.packageName)
......@@ -199,7 +206,7 @@ class Task : Thread, IAppBaseCallback {
* @param index 频道序号
*/
private fun processChannels(index: Int): Boolean {
Log.i(TAG, "processChannels")
Log.i(TAG, "processChannels...count:${this.apkInfo.channelCount}")
quitCapture()
processChannelItem()
......@@ -236,6 +243,8 @@ class Task : Thread, IAppBaseCallback {
*/
private fun processChannelItem() {
Log.i(TAG, "processChannelItem channel ${this.channelIndex}")
try {
// 处理抓包数据
var playUrlItems = analysisCapture()
// 如果没有抓取到地址,再次尝试
......@@ -281,6 +290,10 @@ class Task : Thread, IAppBaseCallback {
channelJson.putOpt("channelId", this.channelIndex)
channels.put(channelJson)
} catch (e : Exception) {
e.printStackTrace()
Log.i(TAG, "exception processChannelItem channel ${this.channelIndex}")
}
}
// 抓包处理
......@@ -322,6 +335,8 @@ class Task : Thread, IAppBaseCallback {
var timeStr = ""
val tagGet = "GET /"
lines.forEach {
try {
if (it.contains("IP (")) {
val end = it.indexOf('.')
timeStr = it.substring(0, end)
......@@ -330,7 +345,10 @@ class Task : Thread, IAppBaseCallback {
if (it.contains(tagGet)) {
val start = it.indexOf(tagGet) + tagGet.length - 1
val end = it.lastIndexOf(' ')
if (start < end && end < it.length)
partUrl = it.substring(start, end)
else
partUrl = "/"
}
if (it.contains("Host")) {
......@@ -366,6 +384,10 @@ class Task : Thread, IAppBaseCallback {
partUrl = ""
}
} catch (e: Exception) {
e.printStackTrace()
Log.i(TAG, "exception at line: $it")
}
}
return playUrlItems
......@@ -408,7 +430,7 @@ class Task : Thread, IAppBaseCallback {
* 先上报数据,截图上传继续在后台进行
*/
private fun report() {
Log.i(TAG, "report....")
Log.i(TAG, "report....status: ${this.status}")
val postJson = JSONObject()
val reportArray = JSONArray()
try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment