添加monitor模块

This commit is contained in:
tongchenfei
2020-08-06 10:00:50 +08:00
parent 1f1420735c
commit 43e0324182
16 changed files with 197 additions and 3 deletions

1
.idea/gradle.xml generated
View File

@@ -40,6 +40,7 @@
<option value="$PROJECT_DIR$/modules/mogo-module-main" />
<option value="$PROJECT_DIR$/modules/mogo-module-map" />
<option value="$PROJECT_DIR$/modules/mogo-module-media" />
<option value="$PROJECT_DIR$/modules/mogo-module-monitor" />
<option value="$PROJECT_DIR$/modules/mogo-module-obu" />
<option value="$PROJECT_DIR$/modules/mogo-module-push" />
<option value="$PROJECT_DIR$/modules/mogo-module-push-base" />

2
.idea/misc.xml generated
View File

@@ -4,7 +4,7 @@
<asm skipDebug="false" skipFrames="false" skipCode="false" expandFrames="false" />
<groovy codeStyle="LEGACY" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
</project>

View File

@@ -273,6 +273,7 @@ dependencies {
implementation rootProject.ext.dependencies.moduleservice
implementation rootProject.ext.dependencies.modulesplash
implementation rootProject.ext.dependencies.moduleV2x
implementation rootProject.ext.dependencies.mogomonitor
} else {
launcherImplementation project(':main-extensions:mogo-module-main-launcher')
independentImplementation project(':main-extensions:mogo-module-main-independent')
@@ -284,6 +285,7 @@ dependencies {
implementation project(':modules:mogo-module-service')
implementation project(':modules:mogo-module-splash')
implementation project(':modules:mogo-module-v2x')
implementation project(':modules:mogo-module-monitor')
}
apply from: "./functions/baseservices.gradle"

View File

@@ -174,6 +174,8 @@ targetSdkVersion : 22,
mogobaseserviceapk : "com.mogo.base:services-apk:${MOGO_BASE_SERVICES_APK_VERSION}",
// loglib
mogologlib : "com.mogo.module:module-loglib:${LOGLIB_VERSION}",
// monitor
mogomonitor : "com.mogo.module:module-monitor:${MOGO_MODULE_MONITOR_VERSION}",
// google
googlezxing : "com.google.zxing:core:3.3.3",

View File

@@ -101,7 +101,9 @@ MOGO_MODULE_SPLASH_VERSION = 1.0.0-SNAPSHOT
MOGO_MODULE_SPLASH_NOOP_VERSION = 1.0.0-SNAPSHOT
# loglib
LOGLIB_VERSION = 1.0.0-SNAPSHOT
LOGLIB_VERSION = 1.0.1-SNAPSHOT
# monitor
MOGO_MODULE_MONITOR_VERSION = 1.0.0-SNAPSHOT
## 产品库必备配置产品库自动对versionCode和versionName版本进行升级
applicationId=com.mogo.launcer

View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1,43 @@
apply plugin: 'com.android.library'
apply plugin: 'com.alibaba.arouter'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
// buildToolsVersion rootProject.ext.android.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode Integer.valueOf(VERSION_CODE)
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation rootProject.ext.dependencies.mogologlib
implementation rootProject.ext.dependencies.arouter
annotationProcessor rootProject.ext.dependencies.aroutercompiler
if (Boolean.valueOf(RELEASE)) {
compileOnly rootProject.ext.dependencies.modulecommon
} else {
compileOnly project(':modules:mogo-module-common')
}
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -0,0 +1,3 @@
GROUP=com.mogo.module
POM_ARTIFACT_ID=module-monitor
VERSION_CODE=1

View File

@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -0,0 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zhidao.mogo.module.monitor">
/
</manifest>

View File

@@ -0,0 +1,11 @@
package com.zhidao.mogo.module.monitor;
class MogoMonitorConst {
public static final String MODULE_NAME = "MogoMonitor";
public static final String MODULE_PATH = "/monitor/api";
public static final int LOG_PUSH_TYPE = 500000;
public static final int START_CATCH_LOG = 1;
public static final int STOP_CATCH_LOG = 2;
}

View File

@@ -0,0 +1,80 @@
package com.zhidao.mogo.module.monitor;
import android.content.Context;
import android.util.ArrayMap;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.connection.IMogoOnMessageListener;
import com.mogo.service.monitor.IMogoMonitorProvider;
import com.mogo.utils.logger.Logger;
import com.zhidao.loglib.LogInfoManager;
import com.zhidao.loglib.bean.RemoteLogPushContent;
import com.zhidao.loglib.upload.UploadManager;
import com.zhidao.loglib.util.LoggingNotice;
import java.util.Map;
/**
* 应用监控模块provider
* @author tongchenfei
*/
@Route(path = MogoMonitorConst.MODULE_PATH)
public class MogoMonitorProvider implements IMogoMonitorProvider, IMogoOnMessageListener<RemoteLogPushContent> {
private static final String TAG = MogoMonitorConst.MODULE_NAME;
private LogInfoManager manualCatchLog = null;
private Map<String, LogInfoManager> managerCache = new ArrayMap<>();
private Context context;
@Override
public void showLogDebugDialog() {
if (manualCatchLog == null) {
manualCatchLog = new LogInfoManager.Builder(context).build();
}
manualCatchLog.showDebugWindow();
}
@Override
public void init(Context context) {
IMogoServiceApis apis =
(IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context);
apis.getSocketManagerApi(context).registerOnMessageListener(MogoMonitorConst.LOG_PUSH_TYPE,this);
}
@Override
public void resetActivityContext(Context context) {
this.context = context;
UploadManager.getInstance().init(context);
LoggingNotice.getInstance().init(context);
}
@Override
public Class<RemoteLogPushContent> target() {
return RemoteLogPushContent.class;
}
@Override
public void onMsgReceived(RemoteLogPushContent obj) {
switch (obj.getType()){
case MogoMonitorConst.START_CATCH_LOG:
if (managerCache.containsKey(obj.getPkgName())) {
Logger.d(TAG, "这个包名的日志正在抓了: " + obj);
return;
}
LogInfoManager infoManager = new LogInfoManager.Builder(context).build();
infoManager.start();
managerCache.put(obj.getPkgName(), infoManager);
break;
case MogoMonitorConst.STOP_CATCH_LOG:
LogInfoManager stopManager = managerCache.get(obj.getPkgName());
if (stopManager != null) {
stopManager.stop();
}
break;
default:
break;
}
}
}

View File

@@ -231,5 +231,5 @@ public class MogoServicePaths {
* 日志上传
*/
@Deprecated
public static final String PATH_LOG_LIB = "/loglib/api";
public static final String PATH_MOGO_MONITOR = "/monitor/api";
}

View File

@@ -0,0 +1,22 @@
package com.mogo.service.monitor;
import android.content.Context;
import com.alibaba.android.arouter.facade.template.IProvider;
/**
* monitor接口
* @author tongchenfei
*/
public interface IMogoMonitorProvider extends IProvider {
/**
* 显示日志抓取窗口
*/
void showLogDebugDialog();
/**
* 重置context设置成activity的context
* @param context activity的context
*/
void resetActivityContext(Context context);
}

View File

@@ -1,3 +1,4 @@
include ':modules:mogo-module-monitor'
include ':foudations:mogo-base-services-apk'
include ':foudations:mogo-base-services-sdk'
include ':modules:mogo-module-splash-noop'