@@ -17,32 +17,32 @@ import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/9/9
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
@Route( path = CrashReportConstants.PATH )
|
||||
class BuglyCrashReportProvider implements ITestCrashReportProvider {
|
||||
@Route(path = CrashReportConstants.PATH)
|
||||
public class BuglyCrashReportProvider implements ITestCrashReportProvider {
|
||||
|
||||
private static final String TAG = "BuglyCrashReportProvider";
|
||||
|
||||
@Override
|
||||
public void init(Context context ) {
|
||||
public void init(Context context) {
|
||||
Logger.d(TAG, "init");
|
||||
String packageName = context.getPackageName();
|
||||
String processName = getProcessName( android.os.Process.myPid() );
|
||||
CrashReport.UserStrategy strategy = new CrashReport.UserStrategy( context );
|
||||
strategy.setUploadProcess( processName == null || processName.equals( packageName ) );
|
||||
String processName = getProcessName(android.os.Process.myPid());
|
||||
CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(context);
|
||||
strategy.setUploadProcess(processName == null || processName.equals(packageName));
|
||||
|
||||
String productFlavor = DebugConfig.getProductFlavor();
|
||||
strategy.setAppChannel(productFlavor);
|
||||
Bugly.init(context, "ac71228f85", true, strategy);
|
||||
Bugly.init(context, CrashReportConstants.buglyAppID, true, strategy);
|
||||
Bugly.putUserData(context, "serial", MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
String mapSDKVersion = AppUtils.getCustomMapSDKVersion(context);
|
||||
Bugly.putUserData(context, "MAP_SDK_VERSION",mapSDKVersion);
|
||||
String mapSDKVersion = AppUtils.getCustomMapSDKVersion(context);
|
||||
Bugly.putUserData(context, "MAP_SDK_VERSION", mapSDKVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,23 +51,23 @@ class BuglyCrashReportProvider implements ITestCrashReportProvider {
|
||||
* @param pid 进程号
|
||||
* @return 进程名
|
||||
*/
|
||||
private static String getProcessName( int pid ) {
|
||||
private static String getProcessName(int pid) {
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
reader = new BufferedReader( new FileReader( "/proc/" + pid + "/cmdline" ) );
|
||||
reader = new BufferedReader(new FileReader("/proc/" + pid + "/cmdline"));
|
||||
String processName = reader.readLine();
|
||||
if ( !TextUtils.isEmpty( processName ) ) {
|
||||
if (!TextUtils.isEmpty(processName)) {
|
||||
processName = processName.trim();
|
||||
}
|
||||
return processName;
|
||||
} catch ( Throwable throwable ) {
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if ( reader != null ) {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
} catch ( IOException exception ) {
|
||||
} catch (IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,9 +47,11 @@ dependencies {
|
||||
kapt rootProject.ext.dependencies.aroutercompiler
|
||||
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
api rootProject.ext.dependencies.crashreport
|
||||
implementation rootProject.ext.dependencies.mogoutils
|
||||
implementation rootProject.ext.dependencies.mogocommons
|
||||
} else {
|
||||
api project(":test:crashreport")
|
||||
implementation project(":foudations:mogo-utils")
|
||||
implementation project(":foudations:mogo-commons")
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.test.crashreport.CrashReportConstants;
|
||||
import com.mogo.utils.AppUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.tencent.bugly.Bugly;
|
||||
@@ -38,7 +39,7 @@ public class UpgradeReportProvider implements IProvider {
|
||||
|
||||
String productFlavor = DebugConfig.getProductFlavor();
|
||||
strategy.setAppChannel(productFlavor);
|
||||
Bugly.init(context, "ac71228f85", true, strategy);
|
||||
Bugly.init(context, CrashReportConstants.buglyAppID, true, strategy);
|
||||
Bugly.putUserData(context, "serial", MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
String mapSDKVersion = AppUtils.getCustomMapSDKVersion(context);
|
||||
Bugly.putUserData(context, "MAP_SDK_VERSION", mapSDKVersion);
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
package com.mogo.test.crashreport;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/9/9
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
class CrashReportConstants {
|
||||
public class CrashReportConstants {
|
||||
|
||||
public static final String PATH = "/crashreport/api";
|
||||
|
||||
public static final String NAME = "CrashReportApi";
|
||||
|
||||
|
||||
/**
|
||||
* https://bugly.qq.com/
|
||||
* 在线日统计平台 App ID
|
||||
*/
|
||||
public static String buglyAppID = "";
|
||||
|
||||
}
|
||||
|
||||
@@ -2,13 +2,12 @@ package com.mogo.test.crashreport;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/9/9
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
interface ITestCrashReportProvider extends IProvider {
|
||||
public interface ITestCrashReportProvider extends IProvider {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user