213 lines
5.9 KiB
Java
213 lines
5.9 KiB
Java
package com.baidu.uaq.agent.android;
|
|
|
|
import android.content.Context;
|
|
import android.util.Log;
|
|
import androidx.annotation.Keep;
|
|
import com.baidu.uaq.agent.android.AgentConfig;
|
|
import com.baidu.uaq.agent.android.customtransmission.APMAgent;
|
|
import com.baidu.uaq.agent.android.harvest.bean.h;
|
|
import com.baidu.uaq.agent.android.harvest.bean.i;
|
|
|
|
@Keep
|
|
/* loaded from: classes.dex */
|
|
public class UAQ {
|
|
private static final com.baidu.uaq.agent.android.logging.a LOG = com.baidu.uaq.agent.android.logging.b.a();
|
|
private static volatile UAQ instance;
|
|
private AgentConfig savedConfig;
|
|
private boolean started = false;
|
|
private boolean isDisableCollect = false;
|
|
private boolean needBasicInfo = true;
|
|
private AgentConfig agentConfig = new AgentConfig.Builder().build();
|
|
|
|
private UAQ() {
|
|
}
|
|
|
|
public static UAQ getInstance() {
|
|
if (instance == null) {
|
|
synchronized (UAQ.class) {
|
|
if (instance == null) {
|
|
instance = new UAQ();
|
|
}
|
|
}
|
|
}
|
|
return instance;
|
|
}
|
|
|
|
public static String getVersion() {
|
|
return a.g() + "." + a.b();
|
|
}
|
|
|
|
private boolean isInstrumented() {
|
|
return false;
|
|
}
|
|
|
|
public static void onLiveEvent(String str) {
|
|
LOG.d("Get Live Event: " + str);
|
|
if (str.isEmpty()) {
|
|
return;
|
|
}
|
|
i.b(new h(str));
|
|
}
|
|
|
|
@Deprecated
|
|
public static UAQ setCUID(String str) {
|
|
getInstance().setConfig(new AgentConfig.Builder().APIKey("0b32398f92284103a76f03680104c775").cuid(str).channel("APM_TEST_CHANNEL").logEnabled(true).build());
|
|
return getInstance();
|
|
}
|
|
|
|
public static void setxxDebug(boolean z) {
|
|
}
|
|
|
|
@Deprecated
|
|
public static void shutdown() {
|
|
getInstance().shutdown_v2();
|
|
}
|
|
|
|
@Deprecated
|
|
public static UAQ usingCollectorAddress(String str) {
|
|
return getInstance();
|
|
}
|
|
|
|
@Deprecated
|
|
public static UAQ usingSsl(boolean z) {
|
|
return getInstance();
|
|
}
|
|
|
|
@Deprecated
|
|
public static UAQ withApplicationToken(String str) {
|
|
return getInstance();
|
|
}
|
|
|
|
@Deprecated
|
|
public static UAQ withLogLevel(int i) {
|
|
return getInstance();
|
|
}
|
|
|
|
@Deprecated
|
|
public static UAQ withLogPersist(boolean z) {
|
|
return getInstance();
|
|
}
|
|
|
|
@Deprecated
|
|
public static UAQ withLoggingEnabled(boolean z) {
|
|
return getInstance();
|
|
}
|
|
|
|
@Deprecated
|
|
public void agentExceptionNow() {
|
|
com.baidu.uaq.agent.android.harvest.health.a.a(new RuntimeException("This is a demonstration agent exception of UAQ"));
|
|
}
|
|
|
|
public void disableCollect() {
|
|
this.agentConfig = this.agentConfig.newBuilder().build();
|
|
}
|
|
|
|
public void enableCollect(AgentConfig agentConfig) {
|
|
if (agentConfig == null) {
|
|
throw new NullPointerException("savedConfig == null.");
|
|
}
|
|
this.agentConfig = agentConfig;
|
|
}
|
|
|
|
public AgentConfig getConfig() {
|
|
return this.agentConfig;
|
|
}
|
|
|
|
public AgentConfig getSavedConfig() {
|
|
return this.savedConfig;
|
|
}
|
|
|
|
@Deprecated
|
|
public void harvestNow() {
|
|
}
|
|
|
|
public boolean isDisableCollect() {
|
|
return this.isDisableCollect;
|
|
}
|
|
|
|
public boolean isNeedBasicInfo() {
|
|
return this.needBasicInfo;
|
|
}
|
|
|
|
public boolean isStarted() {
|
|
return this.started;
|
|
}
|
|
|
|
public synchronized void reconfig(AgentConfig agentConfig) {
|
|
if (agentConfig == null) {
|
|
throw new NullPointerException("agentConfig == null.");
|
|
}
|
|
this.agentConfig = agentConfig;
|
|
}
|
|
|
|
public UAQ setConfig(AgentConfig agentConfig) {
|
|
if (agentConfig == null) {
|
|
throw new NullPointerException("agentConfig == null.");
|
|
}
|
|
this.agentConfig = agentConfig;
|
|
return instance;
|
|
}
|
|
|
|
public void setDisableCollect(boolean z) {
|
|
this.isDisableCollect = z;
|
|
}
|
|
|
|
public void setNeedBasicInfo(boolean z) {
|
|
this.needBasicInfo = z;
|
|
}
|
|
|
|
public void setSavedConfig(AgentConfig agentConfig) {
|
|
this.savedConfig = agentConfig;
|
|
}
|
|
|
|
@Deprecated
|
|
public synchronized void shutdown_v2() {
|
|
com.baidu.uaq.agent.android.logging.a aVar;
|
|
String str;
|
|
try {
|
|
LOG.d("Agent try to shutdown");
|
|
} catch (Throwable th) {
|
|
try {
|
|
LOG.a("Caught error while stop the UAQ agent!", th);
|
|
a.a(e.a);
|
|
aVar = LOG;
|
|
str = "Agent finish shutdown";
|
|
} finally {
|
|
a.a(e.a);
|
|
LOG.d("Agent finish shutdown");
|
|
}
|
|
}
|
|
if (isStarted()) {
|
|
disableCollect();
|
|
this.started = false;
|
|
a.a().shutdown();
|
|
a.a(e.a);
|
|
aVar = LOG;
|
|
str = "Agent finish shutdown";
|
|
aVar.d(str);
|
|
}
|
|
}
|
|
|
|
public synchronized APMAgent startAPM(Context context) {
|
|
APMAgent aPMAgent;
|
|
aPMAgent = new APMAgent();
|
|
aPMAgent.setAgent(aPMAgent);
|
|
try {
|
|
long currentTimeMillis = System.currentTimeMillis();
|
|
if (!(a.a() instanceof d)) {
|
|
com.baidu.uaq.agent.android.logging.b.a(this.agentConfig.isLogEnabled() ? new com.baidu.uaq.agent.android.logging.c() : new com.baidu.uaq.agent.android.logging.e());
|
|
LOG.a(this.agentConfig.getLogLevel());
|
|
d.a(context);
|
|
}
|
|
g.a();
|
|
com.baidu.uaq.agent.android.harvest.multiharvest.a.c().a(context);
|
|
long currentTimeMillis2 = System.currentTimeMillis();
|
|
LOG.d("Start UAQ " + a.g() + "." + a.b() + ", using time: " + (currentTimeMillis2 - currentTimeMillis) + "ms");
|
|
Log.d("Baidu UAQ APM", "Start UAQ APM instance success!");
|
|
} catch (Throwable th) {
|
|
LOG.a("Caught error while start the UAQ agent!", th);
|
|
}
|
|
return aPMAgent;
|
|
}
|
|
}
|