[3.2.0][APM] APM初始化在读是否是Debug时,切换到子线程

This commit is contained in:
renwj
2023-06-01 19:33:24 +08:00
parent ef9e64cf5a
commit b24d3588d1
2 changed files with 25 additions and 10 deletions

View File

@@ -27,6 +27,10 @@ import com.mogo.test.crashreport.ITestCrashReportProvider;
import java.util.HashMap;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
/**
* @author congtaowang
@@ -50,16 +54,24 @@ public class ApmCrashReportProvider implements ITestCrashReportProvider {
@Override
public void init(Context context) {
IApmEnvProvider provider = CallerDevaToolsManager.INSTANCE.apmEnvProvider();
boolean isDebug = DebugConfig.isDebug();
if (provider != null) {
Boolean enabled = provider.isDebugEnabled();
if (enabled != null) {
isDebug = enabled;
}
}
initCrash(context, isDebug);
initApmInsight(context, isDebug);
Observable.defer(() -> {
IApmEnvProvider provider = CallerDevaToolsManager.INSTANCE.apmEnvProvider();
boolean isDebug = DebugConfig.isDebug();
if (provider != null) {
Boolean enabled = provider.isDebugEnabled();
if (enabled != null) {
isDebug = enabled;
}
}
return Observable.just(isDebug);
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnNext(isDebug -> {
initCrash(context, isDebug);
initApmInsight(context, isDebug);
}).subscribe();
}
private void initCrash(final Context context, boolean isDebug) {