Initial commit
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
package com.baidu.uaq.agent.android.customtransmission;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
import com.baidu.uaq.agent.android.harvest.bean.h;
|
||||
import com.baidu.uaq.agent.android.harvest.bean.i;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
@Keep
|
||||
/* loaded from: classes.dex */
|
||||
public class APMAgent {
|
||||
private static final com.baidu.uaq.agent.android.logging.a LOG = com.baidu.uaq.agent.android.logging.b.a();
|
||||
private APMAgent apmAgent;
|
||||
|
||||
public void addDebugLog(String str) {
|
||||
}
|
||||
|
||||
public void addLogWithHandler(APMUploadHandler aPMUploadHandler, String str) {
|
||||
if (aPMUploadHandler == null || str == null || str.isEmpty()) {
|
||||
LOG.c("APMAgent addLogWithHandler failed, cause APMUploadHandler is null or log is empty!");
|
||||
} else if (aPMUploadHandler.getUploadName().equals(APMUploadConfigure.APMUPLOADNAME)) {
|
||||
i.b(new h(str));
|
||||
} else {
|
||||
b.a(aPMUploadHandler.getUploadName(), str);
|
||||
}
|
||||
}
|
||||
|
||||
public APMUploadHandler addUploadConfigure(APMUploadConfigure aPMUploadConfigure) {
|
||||
if (aPMUploadConfigure == null || aPMUploadConfigure.getUploadName() == null || aPMUploadConfigure.getUploadName().isEmpty()) {
|
||||
LOG.a("添加上报策略失败:APMUploadConfigure, uploadName 有空值");
|
||||
return null;
|
||||
}
|
||||
if (!aPMUploadConfigure.getUploadName().equals(APMUploadConfigure.APMUPLOADNAME)) {
|
||||
String url = aPMUploadConfigure.getUrl();
|
||||
if (aPMUploadConfigure.getMergeBlockCallBack() == null) {
|
||||
LOG.a("添加上报策略失败:mergeBlockCallBack为空");
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
new URL(url);
|
||||
} catch (MalformedURLException unused) {
|
||||
LOG.a("添加上报策略失败:url for newUploadConfigure is not legal! url: " + url);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
APMUploadHandler apmUploadHandler = aPMUploadConfigure.getApmUploadHandler();
|
||||
if (com.baidu.uaq.agent.android.harvest.multiharvest.a.c().a() > 0) {
|
||||
com.baidu.uaq.agent.android.harvest.multiharvest.a.c().a(aPMUploadConfigure);
|
||||
}
|
||||
LOG.d("addUploadConfigure getInstanceNumber:" + com.baidu.uaq.agent.android.harvest.multiharvest.a.c().a());
|
||||
return apmUploadHandler;
|
||||
}
|
||||
|
||||
public APMUploadConfigure newUploadConfigure(String str, String str2, MergeBlockCallBack mergeBlockCallBack) {
|
||||
return new APMUploadConfigure(str, str2, mergeBlockCallBack);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void removeUploadConfigure(APMUploadHandler aPMUploadHandler) {
|
||||
if (aPMUploadHandler == null) {
|
||||
return;
|
||||
}
|
||||
b.a(aPMUploadHandler.getUploadName());
|
||||
}
|
||||
|
||||
public void setAgent(APMAgent aPMAgent) {
|
||||
this.apmAgent = aPMAgent;
|
||||
}
|
||||
|
||||
public synchronized void stopAPM() {
|
||||
if (this.apmAgent != null) {
|
||||
com.baidu.uaq.agent.android.harvest.multiharvest.a.c().b();
|
||||
this.apmAgent = null;
|
||||
} else {
|
||||
LOG.d("This instance already stop one time");
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,118 @@
|
||||
package com.baidu.uaq.agent.android.customtransmission;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
import com.baidu.uaq.agent.android.UAQ;
|
||||
import java.util.HashMap;
|
||||
|
||||
@Keep
|
||||
/* loaded from: classes.dex */
|
||||
public class APMUploadConfigure {
|
||||
private static final UAQ AGENT = UAQ.getInstance();
|
||||
public static final String APMUPLOADNAME = "APMPerformanceConfigurationName";
|
||||
private static final long MAXBYTESPERIOD = 86400000;
|
||||
private static final long MAXBYTESWIFI = 0;
|
||||
public static final int MAXUPLOADRETRYCOUNT = 3;
|
||||
private static final int MSEC = 1000;
|
||||
private APMUploadHandler apmUploadHandler;
|
||||
private boolean enableRetransmission;
|
||||
private HashMap<String, String> headerMap = new HashMap<>();
|
||||
private long interval4g;
|
||||
private long intervalWifi;
|
||||
private long maxBytes4g;
|
||||
private long maxBytesPeriod4g;
|
||||
private long maxBytesPeriodWifi;
|
||||
private long maxBytesWifi;
|
||||
private MergeBlockCallBack mergeBlockCallBack;
|
||||
private String uploadName;
|
||||
private String url;
|
||||
|
||||
public APMUploadConfigure(String str, String str2, MergeBlockCallBack mergeBlockCallBack) {
|
||||
this.headerMap.put("Content-Type", "application/json");
|
||||
this.headerMap.put("Content-Encoding", "deflate");
|
||||
this.uploadName = str;
|
||||
this.url = str2;
|
||||
this.mergeBlockCallBack = mergeBlockCallBack;
|
||||
this.enableRetransmission = false;
|
||||
this.interval4g = AGENT.getConfig().getDataReportPeriod();
|
||||
this.intervalWifi = AGENT.getConfig().getDataReportPeriod();
|
||||
this.maxBytes4g = AGENT.getConfig().getDataReportLimit();
|
||||
this.maxBytesWifi = 0L;
|
||||
this.maxBytesPeriod4g = MAXBYTESPERIOD;
|
||||
this.maxBytesPeriodWifi = MAXBYTESPERIOD;
|
||||
this.apmUploadHandler = new APMUploadHandler(this.uploadName);
|
||||
}
|
||||
|
||||
public void enableRetransmission(boolean z) {
|
||||
this.enableRetransmission = z;
|
||||
}
|
||||
|
||||
public APMUploadHandler getApmUploadHandler() {
|
||||
return this.apmUploadHandler;
|
||||
}
|
||||
|
||||
public HashMap<String, String> getHeaderMap() {
|
||||
return this.headerMap;
|
||||
}
|
||||
|
||||
public long getInterval4g() {
|
||||
return this.interval4g;
|
||||
}
|
||||
|
||||
public long getIntervalWifi() {
|
||||
return this.intervalWifi;
|
||||
}
|
||||
|
||||
public long getMaxBytes4g() {
|
||||
return this.maxBytes4g;
|
||||
}
|
||||
|
||||
public long getMaxBytesPeriod4g() {
|
||||
return this.maxBytesPeriod4g;
|
||||
}
|
||||
|
||||
public long getMaxBytesPeriodWifi() {
|
||||
return this.maxBytesPeriodWifi;
|
||||
}
|
||||
|
||||
public long getMaxBytesWifi() {
|
||||
return this.maxBytesWifi;
|
||||
}
|
||||
|
||||
public MergeBlockCallBack getMergeBlockCallBack() {
|
||||
return this.mergeBlockCallBack;
|
||||
}
|
||||
|
||||
public String getUploadName() {
|
||||
return this.uploadName;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return this.url;
|
||||
}
|
||||
|
||||
public boolean isEnableRetransmission() {
|
||||
return this.enableRetransmission;
|
||||
}
|
||||
|
||||
public void setHeaderMap(HashMap<String, String> hashMap) {
|
||||
this.headerMap = hashMap;
|
||||
}
|
||||
|
||||
public void setInterval4g(long j) {
|
||||
this.interval4g = j * 1000;
|
||||
}
|
||||
|
||||
public void setIntervalWifi(long j) {
|
||||
this.intervalWifi = j * 1000;
|
||||
}
|
||||
|
||||
public void setMaxbytes4g(long j, long j2) {
|
||||
this.maxBytes4g = j;
|
||||
this.maxBytesPeriod4g = j2 * 1000;
|
||||
}
|
||||
|
||||
public void setMaxbyteswifi(long j, long j2) {
|
||||
this.maxBytesWifi = j;
|
||||
this.maxBytesPeriodWifi = j2 * 1000;
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package com.baidu.uaq.agent.android.customtransmission;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
@Keep
|
||||
/* loaded from: classes.dex */
|
||||
public class APMUploadHandler {
|
||||
private String uploadName;
|
||||
|
||||
public APMUploadHandler(String str) {
|
||||
this.uploadName = str;
|
||||
}
|
||||
|
||||
public String getUploadName() {
|
||||
return this.uploadName;
|
||||
}
|
||||
|
||||
public void setUploadName(String str) {
|
||||
this.uploadName = str;
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package com.baidu.uaq.agent.android.customtransmission;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Keep
|
||||
/* loaded from: classes.dex */
|
||||
public interface MergeBlockCallBack {
|
||||
String executeMerge(ArrayList<String> arrayList);
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
package com.baidu.uaq.agent.android.customtransmission;
|
||||
|
||||
/* compiled from: BlockData.java */
|
||||
/* loaded from: classes.dex */
|
||||
public class a {
|
||||
private String a;
|
||||
private int b;
|
||||
|
||||
public a(String str) {
|
||||
this.a = "";
|
||||
this.b = 0;
|
||||
this.a = str;
|
||||
this.b = 0;
|
||||
}
|
||||
|
||||
public String a() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public void b() {
|
||||
this.b++;
|
||||
}
|
||||
|
||||
public int c() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "BlockData{block='" + this.a + "', retryCount=" + this.b + '}';
|
||||
}
|
||||
}
|
122
sources/com/baidu/uaq/agent/android/customtransmission/b.java
Normal file
122
sources/com/baidu/uaq/agent/android/customtransmission/b.java
Normal file
@@ -0,0 +1,122 @@
|
||||
package com.baidu.uaq.agent.android.customtransmission;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/* compiled from: UploadConfigureStorage.java */
|
||||
/* loaded from: classes.dex */
|
||||
public class b {
|
||||
private static final com.baidu.uaq.agent.android.logging.a a = com.baidu.uaq.agent.android.logging.b.a();
|
||||
private static final ConcurrentHashMap<String, APMUploadConfigure> b = new ConcurrentHashMap<>();
|
||||
private static final ConcurrentHashMap<String, ArrayList<a>> c = new ConcurrentHashMap<>();
|
||||
|
||||
public static synchronized void a(APMUploadConfigure aPMUploadConfigure) {
|
||||
synchronized (b.class) {
|
||||
if (com.baidu.uaq.agent.android.harvest.multiharvest.a.c().a() < 1) {
|
||||
a.a("Agent has shutdown when add Upload Configure");
|
||||
} else {
|
||||
b.put(aPMUploadConfigure.getUploadName(), aPMUploadConfigure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized ConcurrentHashMap<String, ArrayList<a>> b() {
|
||||
ConcurrentHashMap<String, ArrayList<a>> concurrentHashMap;
|
||||
synchronized (b.class) {
|
||||
concurrentHashMap = c;
|
||||
}
|
||||
return concurrentHashMap;
|
||||
}
|
||||
|
||||
public static synchronized void b(String str, Boolean bool) {
|
||||
synchronized (b.class) {
|
||||
ArrayList<a> arrayList = c.get(str);
|
||||
if (bool.booleanValue()) {
|
||||
ArrayList arrayList2 = new ArrayList();
|
||||
Iterator<a> it = arrayList.iterator();
|
||||
while (it.hasNext()) {
|
||||
a next = it.next();
|
||||
if (next.c() == 0) {
|
||||
arrayList2.add(next);
|
||||
}
|
||||
}
|
||||
a(str, (ArrayList<a>) arrayList2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
static synchronized void a(String str) {
|
||||
synchronized (b.class) {
|
||||
b.remove(str);
|
||||
}
|
||||
}
|
||||
|
||||
static synchronized void a(String str, String str2) {
|
||||
synchronized (b.class) {
|
||||
if (com.baidu.uaq.agent.android.harvest.multiharvest.a.c().a() < 1) {
|
||||
a.a("Agent has shutdown when add Upload Block");
|
||||
} else {
|
||||
synchronized (c) {
|
||||
ArrayList<a> arrayList = c.get(str);
|
||||
if (arrayList == null) {
|
||||
arrayList = new ArrayList<>();
|
||||
}
|
||||
arrayList.add(new a(str2));
|
||||
c.put(str, arrayList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized ArrayList<String> a(String str, Boolean bool) {
|
||||
synchronized (b.class) {
|
||||
ArrayList<String> arrayList = new ArrayList<>();
|
||||
ArrayList arrayList2 = new ArrayList();
|
||||
synchronized (c) {
|
||||
ArrayList<a> arrayList3 = c.get(str);
|
||||
if (arrayList3 != null && arrayList3.size() != 0) {
|
||||
if (bool.booleanValue()) {
|
||||
for (int i = 0; i < arrayList3.size(); i++) {
|
||||
if (arrayList3.get(i).c() < 3) {
|
||||
arrayList2.add(arrayList3.get(i));
|
||||
arrayList3.get(i).b();
|
||||
arrayList.add(arrayList3.get(i).a());
|
||||
}
|
||||
}
|
||||
a(str, (ArrayList<a>) arrayList2);
|
||||
} else {
|
||||
Iterator<a> it = arrayList3.iterator();
|
||||
while (it.hasNext()) {
|
||||
arrayList.add(it.next().a());
|
||||
}
|
||||
c.remove(str);
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized ConcurrentHashMap<String, APMUploadConfigure> a() {
|
||||
ConcurrentHashMap<String, APMUploadConfigure> concurrentHashMap;
|
||||
synchronized (b.class) {
|
||||
concurrentHashMap = b;
|
||||
}
|
||||
return concurrentHashMap;
|
||||
}
|
||||
|
||||
static synchronized void a(String str, ArrayList<a> arrayList) {
|
||||
synchronized (b.class) {
|
||||
synchronized (c) {
|
||||
if (arrayList != null) {
|
||||
c.put(str, arrayList);
|
||||
} else {
|
||||
c.remove(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user