add devatools

This commit is contained in:
zhongchao
2021-12-22 19:21:53 +08:00
parent 311e5e0af1
commit a6cd4afc6e
14 changed files with 116 additions and 54 deletions

View File

@@ -1,13 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zhjt.mogo_core_function_devatools">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Launcher" />
</manifest>

View File

@@ -4,11 +4,13 @@ import android.annotation.SuppressLint
import android.content.Context
import android.os.Handler
import android.os.Message
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.commons.AbsMogoApplication
import com.mogo.commons.debug.DebugConfig
import com.mogo.eagle.core.function.call.devatools.CallDevaToolsListenerManager
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsListenerManager
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.eagle.core.utilcode.util.TimeUtils
import com.mogo.module.common.MogoApisHandler
import com.mogo.service.cloud.socket.IMogoOnMessageListener
import com.mogo.utils.logger.LogLevel
@@ -23,6 +25,7 @@ import com.zhjt.mogo_core_function_devatools.logcatch.MogoLogCatchConst.Companio
import com.zhjt.mogo_core_function_devatools.logcatch.MogoLogCatchConst.Companion.LOG_PUSH_TYPE
import com.zhjt.mogo_core_function_devatools.logcatch.MogoLogCatchConst.Companion.START_CATCH_LOG
import com.zhjt.mogo_core_function_devatools.logcatch.MogoLogCatchConst.Companion.STOP_CATCH_LOG
import java.io.File
@SuppressLint("StaticFieldLeak")
object MogoLogCatchManager : IMogoOnMessageListener<RemoteLogPushContent>, Handler.Callback,
@@ -45,7 +48,7 @@ object MogoLogCatchManager : IMogoOnMessageListener<RemoteLogPushContent>, Handl
.getSocketManagerApi(AbsMogoApplication.getApp().applicationContext)
.registerOnMessageListener(LOG_PUSH_TYPE, this)
manualContent.duration = 60
manualContent.pkgName = MANUAL_CATCH_PKG_NAME
manualContent.pkgName = context.packageName
}
override fun target(): Class<RemoteLogPushContent> {
@@ -70,7 +73,7 @@ object MogoLogCatchManager : IMogoOnMessageListener<RemoteLogPushContent>, Handl
override fun handleMessage(msg: Message): Boolean {
if (msg.what == MSG_TRY_CLOSE_LOG) {
CallDevaToolsListenerManager.invokeDevaToolsLogCatch()
CallerDevaToolsListenerManager.invokeDevaToolsLogCatchClose()
closeLoggerLevel()
return true
}
@@ -103,7 +106,10 @@ object MogoLogCatchManager : IMogoOnMessageListener<RemoteLogPushContent>, Handl
}
handler.sendEmptyMessageDelayed(MSG_TRY_CLOSE_LOG, delay)
openLoggerLevel()
logInfoManager = LogInfoManagerFactory.createPushLogInfoManager(mContext, content, this)
logInfoManager = LogInfoManagerFactory.createPushLogInfoManager(
mContext,
MoGoAiCloudClientConfig.getInstance().sn + File.separator + TimeUtils.formatYMD(System.currentTimeMillis()),
content, this)
logInfoManager?.start()
}
@@ -142,7 +148,7 @@ object MogoLogCatchManager : IMogoOnMessageListener<RemoteLogPushContent>, Handl
override fun onClose(pkgName: String?) {
ThreadUtils.runOnUiThread {
CallDevaToolsListenerManager.invokeDevaToolsLogCatch()
CallerDevaToolsListenerManager.invokeDevaToolsLogCatchClose()
TipToast.shortTip("日志抓取默认计时结束")
}
}