Commit 80c21a83 authored by liuyang's avatar liuyang

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

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