Commit efefe99f authored by liuyang's avatar liuyang

APK图片抓取识别及轮播流地址抓取,客户端添加自启动

#BYLSERVER-1438
parent cec45a35
...@@ -31,6 +31,12 @@ ...@@ -31,6 +31,12 @@
<service android:name=".service.BylRobotService" /> <service android:name=".service.BylRobotService" />
<service android:name=".service.BylWebService" /> <service android:name=".service.BylWebService" />
<receiver android:name=".service.BootBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
package com.duolebo.blyrobot.data package com.duolebo.blyrobot.data
import com.duolebo.appbase.IModel
import com.duolebo.appbase.prj.XMLHelper import com.duolebo.appbase.prj.XMLHelper
import com.duolebo.appbase.prj.bmtv.model.ModelBase
import org.json.JSONArray import org.json.JSONArray
import org.json.JSONObject import org.json.JSONObject
class ApkReportData: IModel { class ApkReportData: ModelBase() {
override fun from(p0: JSONObject?): Boolean { var result = -1
override fun from(json: JSONObject): Boolean {
val data = json.optJSONArray("data")
if (data != null) {
}
result = 0
return true return true
} }
...@@ -18,4 +24,8 @@ class ApkReportData: IModel { ...@@ -18,4 +24,8 @@ class ApkReportData: IModel {
return false return false
} }
override fun getCode(): Int {
return result
}
} }
\ No newline at end of file
package com.duolebo.blyrobot.service
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
class BootBroadcastReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (intent.action == "android.intent.action.BOOT_COMPLETED") {
context.startService(Intent(context, BylRobotService::class.java))
}
}
}
...@@ -9,8 +9,13 @@ import android.content.IntentFilter ...@@ -9,8 +9,13 @@ import android.content.IntentFilter
import android.os.IBinder import android.os.IBinder
import android.support.v4.content.LocalBroadcastManager import android.support.v4.content.LocalBroadcastManager
import android.util.Log import android.util.Log
import com.duolebo.appbase.AppBaseHandler
import com.duolebo.appbase.IAppBaseCallback
import com.duolebo.appbase.IProtocol
import com.duolebo.blyrobot.data.ApkInfo import com.duolebo.blyrobot.data.ApkInfo
import com.duolebo.blyrobot.data.AppInfoData
import com.duolebo.blyrobot.data.Task import com.duolebo.blyrobot.data.Task
import com.duolebo.blyrobot.protocol.GetAppInfoProtocol
import com.duolebo.blyrobot.tools.TaskManager import com.duolebo.blyrobot.tools.TaskManager
import com.duolebo.blyrobot.util.AdbUtil import com.duolebo.blyrobot.util.AdbUtil
import com.duolebo.blyrobot.util.AppUtil import com.duolebo.blyrobot.util.AppUtil
...@@ -20,11 +25,14 @@ import org.json.JSONObject ...@@ -20,11 +25,14 @@ import org.json.JSONObject
import java.util.* import java.util.*
@SuppressLint("Registered") @SuppressLint("Registered")
class BylRobotService: Service() { class BylRobotService: Service(), IAppBaseCallback {
private val TAG = "BylRobotService" private val TAG = "BylRobotService"
private var count = 0 private var count = 0
private lateinit var dataHandler: AppBaseHandler
private lateinit var apkInfoProtocol: GetAppInfoProtocol
private val broadcastReceiver = object : BroadcastReceiver() { private val broadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(p0: Context?, intent: Intent?) { override fun onReceive(p0: Context?, intent: Intent?) {
if (intent != null) { if (intent != null) {
...@@ -48,6 +56,13 @@ class BylRobotService: Service() { ...@@ -48,6 +56,13 @@ class BylRobotService: Service() {
LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, intentFilter) LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, intentFilter)
} }
private fun requestAppList() {
apkInfoProtocol = GetAppInfoProtocol(this, Config.instance)
this.dataHandler = AppBaseHandler(this)
apkInfoProtocol.execute(this.dataHandler)
}
private fun loadTask() { private fun loadTask() {
Log.i(TAG, "loadTask...") Log.i(TAG, "loadTask...")
...@@ -77,4 +92,24 @@ class BylRobotService: Service() { ...@@ -77,4 +92,24 @@ class BylRobotService: Service() {
super.onDestroy() super.onDestroy()
LocalBroadcastManager.getInstance(this).unregisterReceiver(broadcastReceiver) LocalBroadcastManager.getInstance(this).unregisterReceiver(broadcastReceiver)
} }
override fun onProtocolFailed(protocol: IProtocol?) {
}
override fun onHttpFailed(protocol: IProtocol?) {
}
override fun onProtocolSucceed(protocol: IProtocol?) {
if (protocol is GetAppInfoProtocol) {
val appInfoData = protocol.data as AppInfoData
for (apkInfo in appInfoData.apkInfos) {
if (AppUtil.isAppInstalled(this, apkInfo.packageName)) {
val task = Task(this.applicationContext)
task.from(apkInfo)
TaskManager.instance.add(task)
}
}
}
}
} }
\ No newline at end of file
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