399 lines
14 KiB
Java
399 lines
14 KiB
Java
package com.baidu.cloud.media.player.a;
|
|
|
|
import android.content.Context;
|
|
import android.text.TextUtils;
|
|
import android.util.Log;
|
|
import com.baidu.cloud.media.player.BDCloudMediaPlayer;
|
|
import com.baidu.uaq.agent.android.AgentConfig;
|
|
import com.baidu.uaq.agent.android.UAQ;
|
|
import com.baidu.uaq.agent.android.customtransmission.APMAgent;
|
|
import com.baidu.uaq.agent.android.customtransmission.APMUploadConfigure;
|
|
import com.baidu.uaq.agent.android.customtransmission.APMUploadHandler;
|
|
import com.baidu.uaq.agent.android.customtransmission.MergeBlockCallBack;
|
|
import com.ubt.jimu.course.view.fragment.JimuMissionListFragment;
|
|
import java.util.HashMap;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.Executors;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class b {
|
|
private static String a = "";
|
|
private static boolean b = false;
|
|
private static b h;
|
|
private a c;
|
|
private APMAgent i;
|
|
private final APMUploadHandler j;
|
|
private APMUploadHandler k;
|
|
private long d = 0;
|
|
private boolean e = false;
|
|
private long f = 0;
|
|
private ExecutorService g = null;
|
|
private MergeBlockCallBack l = new MergeBlockCallBack() { // from class: com.baidu.cloud.media.player.a.b.3
|
|
};
|
|
private MergeBlockCallBack m = new MergeBlockCallBack() { // from class: com.baidu.cloud.media.player.a.b.4
|
|
};
|
|
|
|
private b(Context context) {
|
|
this.c = new a(context, a);
|
|
d.a().a(context);
|
|
this.i = UAQ.getInstance().setConfig(new AgentConfig.Builder().APIKey("6ab8e94e75b94316ae7cf4bfb6bd46e7").usePersistentUUID(true).reportCrashes(true).thingsMonitor(true).build()).startAPM(context.getApplicationContext());
|
|
APMUploadConfigure aPMUploadConfigure = new APMUploadConfigure(APMUploadConfigure.APMUPLOADNAME, null, this.m);
|
|
long j = 60;
|
|
aPMUploadConfigure.setInterval4g(j);
|
|
long j2 = 15;
|
|
aPMUploadConfigure.setIntervalWifi(j2);
|
|
long j3 = 204800;
|
|
long j4 = 86400;
|
|
aPMUploadConfigure.setMaxbytes4g(j3, j4);
|
|
long j5 = 0;
|
|
aPMUploadConfigure.setMaxbyteswifi(j5, j4);
|
|
aPMUploadConfigure.enableRetransmission(true);
|
|
HashMap<String, String> hashMap = new HashMap<>();
|
|
hashMap.put("Content-Type", "application/json");
|
|
hashMap.put("Content-Encoding", "deflate");
|
|
aPMUploadConfigure.setHeaderMap(hashMap);
|
|
this.j = this.i.addUploadConfigure(aPMUploadConfigure);
|
|
if (b) {
|
|
APMUploadConfigure aPMUploadConfigure2 = new APMUploadConfigure("userOperation", "https://drm.media.baidubce.com:8888/v2/sdk/player", this.l);
|
|
aPMUploadConfigure2.setInterval4g(j);
|
|
aPMUploadConfigure2.setIntervalWifi(j2);
|
|
aPMUploadConfigure2.setMaxbytes4g(j3, j4);
|
|
aPMUploadConfigure2.setMaxbyteswifi(j5, j4);
|
|
aPMUploadConfigure2.enableRetransmission(true);
|
|
HashMap<String, String> hashMap2 = new HashMap<>();
|
|
hashMap2.put("Content-Type", "application/json");
|
|
hashMap2.put("Content-Encoding", "gzip");
|
|
aPMUploadConfigure2.setHeaderMap(hashMap2);
|
|
this.k = this.i.addUploadConfigure(aPMUploadConfigure2);
|
|
}
|
|
}
|
|
|
|
public static b a(Context context) {
|
|
if (h == null) {
|
|
h = new b(context);
|
|
}
|
|
return h;
|
|
}
|
|
|
|
public static void a(String str) {
|
|
a = str;
|
|
}
|
|
|
|
private void a(String str, JSONObject jSONObject) throws JSONException {
|
|
if (!b || this.k == null) {
|
|
return;
|
|
}
|
|
jSONObject.put("type", str);
|
|
jSONObject.put("time", System.currentTimeMillis());
|
|
if (!TextUtils.isEmpty(this.c.b())) {
|
|
jSONObject.put("session", this.c.b());
|
|
}
|
|
final String jSONObject2 = jSONObject.toString();
|
|
Runnable runnable = new Runnable() { // from class: com.baidu.cloud.media.player.a.b.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
try {
|
|
b.this.i.addLogWithHandler(b.this.k, jSONObject2);
|
|
} catch (Exception e) {
|
|
Log.d("APMEventHandle", "" + e.getMessage());
|
|
}
|
|
}
|
|
};
|
|
ExecutorService executorService = this.g;
|
|
if (executorService == null || executorService.isShutdown()) {
|
|
this.g = Executors.newSingleThreadExecutor();
|
|
}
|
|
this.g.execute(runnable);
|
|
}
|
|
|
|
public static void a(boolean z) {
|
|
b = z;
|
|
}
|
|
|
|
private void d(JSONObject jSONObject) {
|
|
try {
|
|
JSONObject jSONObject2 = new JSONObject();
|
|
jSONObject2.put("TraceId", this.c.b());
|
|
jSONObject2.put("CommData", this.c.a());
|
|
jSONObject2.put("Event", jSONObject);
|
|
JSONObject jSONObject3 = new JSONObject();
|
|
jSONObject3.put("Trace", jSONObject2);
|
|
final String jSONObject4 = jSONObject3.toString();
|
|
Runnable runnable = new Runnable() { // from class: com.baidu.cloud.media.player.a.b.2
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
try {
|
|
b.this.i.addLogWithHandler(b.this.j, jSONObject4);
|
|
} catch (Exception e) {
|
|
Log.d("APMEventHandle", "" + e.getMessage());
|
|
}
|
|
}
|
|
};
|
|
if (this.g == null || this.g.isShutdown()) {
|
|
this.g = Executors.newSingleThreadExecutor();
|
|
}
|
|
this.g.execute(runnable);
|
|
} catch (Exception e) {
|
|
Log.d("APMEventHandle", "" + e.getMessage());
|
|
}
|
|
}
|
|
|
|
public void a() {
|
|
try {
|
|
a("dealloc", new JSONObject());
|
|
} catch (Exception e) {
|
|
Log.d("APMEventHandle", "release " + e.getMessage());
|
|
}
|
|
this.i.stopAPM();
|
|
h = null;
|
|
}
|
|
|
|
public void a(float f) {
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
jSONObject.put(JimuMissionListFragment.POSITION, f);
|
|
a("pause", jSONObject);
|
|
} catch (Exception e) {
|
|
Log.d("APMEventHandle", "onUserPause " + e.getMessage());
|
|
}
|
|
}
|
|
|
|
public void a(int i) {
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
jSONObject.put("Name", "domainIPFound");
|
|
jSONObject.put("StartTime", System.currentTimeMillis());
|
|
jSONObject.put("Duration", i);
|
|
d(jSONObject);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public void a(int i, int i2, int i3) {
|
|
JSONObject jSONObject = new JSONObject();
|
|
JSONObject jSONObject2 = new JSONObject();
|
|
try {
|
|
jSONObject.put(BDCloudMediaPlayer.OnNativeInvokeListener.ARG_ERROR, i);
|
|
jSONObject.put("errorInfo", i2);
|
|
jSONObject2.put("Name", "playEnd");
|
|
jSONObject2.put("StartTime", System.currentTimeMillis());
|
|
jSONObject2.put("Code", i3);
|
|
JSONObject jSONObject3 = new JSONObject();
|
|
jSONObject3.put("detail", "what=" + i + ";extra=" + i2);
|
|
jSONObject2.put("EventData", jSONObject3);
|
|
a(BDCloudMediaPlayer.OnNativeInvokeListener.ARG_ERROR, jSONObject);
|
|
d(jSONObject2);
|
|
} catch (Exception e) {
|
|
Log.d("APMEventHandle", "onPlayFail " + e.getMessage());
|
|
}
|
|
}
|
|
|
|
public void a(long j) {
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
jSONObject.put("Name", "httpConnected");
|
|
jSONObject.put("StartTime", System.currentTimeMillis());
|
|
jSONObject.put("Duration", j);
|
|
d(jSONObject);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public void a(String str, String str2, String str3) {
|
|
this.c.a(str, str2, str3);
|
|
}
|
|
|
|
public void a(JSONObject jSONObject) {
|
|
try {
|
|
a("play", jSONObject);
|
|
} catch (Exception e) {
|
|
Log.d("APMEventHandle", "onUserPlay " + e.getMessage());
|
|
}
|
|
}
|
|
|
|
public void b() {
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
jSONObject.put("Name", "playerCreated");
|
|
jSONObject.put("StartTime", System.currentTimeMillis());
|
|
d(jSONObject);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public void b(int i) {
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
jSONObject.put("Name", "networkSpeed");
|
|
jSONObject.put("StartTime", System.currentTimeMillis());
|
|
JSONObject jSONObject2 = new JSONObject();
|
|
jSONObject2.put("speed", i);
|
|
jSONObject.put("EventData", jSONObject2);
|
|
d(jSONObject);
|
|
} catch (Exception e) {
|
|
Log.d("APMEventHandle", "onNetworkSpeedReport " + e.getMessage());
|
|
}
|
|
}
|
|
|
|
public void b(long j) {
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
jSONObject.put("Name", "firstFrameRendered");
|
|
long currentTimeMillis = System.currentTimeMillis();
|
|
jSONObject.put("StartTime", currentTimeMillis);
|
|
jSONObject.put("Duration", currentTimeMillis - j);
|
|
d(jSONObject);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public void b(String str) {
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
jSONObject.put("videoUrl", str);
|
|
a("init", jSONObject);
|
|
} catch (Exception e) {
|
|
Log.d("APMEventHandle", "release " + e.getMessage());
|
|
}
|
|
this.c.a(str);
|
|
}
|
|
|
|
public void b(JSONObject jSONObject) {
|
|
try {
|
|
a("end", jSONObject);
|
|
} catch (Exception e) {
|
|
Log.d("APMEventHandle", "onUserPlayEnd " + e.getMessage());
|
|
}
|
|
}
|
|
|
|
public void c() {
|
|
this.e = true;
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
jSONObject.put("Name", "frameChasingStart");
|
|
this.f = System.currentTimeMillis();
|
|
jSONObject.put("StartTime", this.f);
|
|
d(jSONObject);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public void c(long j) {
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
jSONObject.put("Name", "firstBufferingEnd");
|
|
jSONObject.put("StartTime", System.currentTimeMillis());
|
|
jSONObject.put("Duration", j);
|
|
d(jSONObject);
|
|
} catch (Exception e) {
|
|
Log.d("APMEventHandle", "onFirstBufferEnd " + e.getMessage());
|
|
}
|
|
}
|
|
|
|
public void c(String str) {
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
jSONObject.put("Name", "updateCdn");
|
|
jSONObject.put("StartTime", System.currentTimeMillis());
|
|
JSONObject jSONObject2 = new JSONObject();
|
|
jSONObject2.put("cdnIp", str);
|
|
jSONObject.put("EventData", jSONObject2);
|
|
d(jSONObject);
|
|
} catch (Exception e) {
|
|
Log.d("APMEventHandle", "onUpdateCdn " + e.getMessage());
|
|
}
|
|
}
|
|
|
|
public void c(JSONObject jSONObject) {
|
|
try {
|
|
a("seek", jSONObject);
|
|
} catch (Exception e) {
|
|
Log.d("APMEventHandle", "onUserSeek " + e.getMessage());
|
|
}
|
|
}
|
|
|
|
public void d() {
|
|
this.e = false;
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
if (this.f <= 0) {
|
|
Log.d("APMEventHandle", "onFrameCharingEnd error: need invoke onFrameChasingStart first");
|
|
return;
|
|
}
|
|
jSONObject.put("Name", "frameChasingEnd");
|
|
long currentTimeMillis = System.currentTimeMillis();
|
|
jSONObject.put("StartTime", currentTimeMillis);
|
|
jSONObject.put("Duration", currentTimeMillis - this.f);
|
|
this.f = 0L;
|
|
d(jSONObject);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public void d(String str) {
|
|
this.c.b(str);
|
|
}
|
|
|
|
public void e() {
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
jSONObject.put("Name", "bufferingStart");
|
|
this.d = System.currentTimeMillis();
|
|
jSONObject.put("StartTime", this.d);
|
|
JSONObject jSONObject2 = new JSONObject();
|
|
jSONObject2.put("isFrameChasing", this.e);
|
|
jSONObject.put("EventData", jSONObject2);
|
|
d(jSONObject);
|
|
} catch (Exception e) {
|
|
Log.d("APMEventHandle", "onBufferingStart " + e.getMessage());
|
|
}
|
|
}
|
|
|
|
void e(String str) {
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
jSONObject.put("crashInfo", str);
|
|
a("crash", jSONObject);
|
|
} catch (Exception e) {
|
|
Log.d("APMEventHandle", "onPlayerCrash " + e.getMessage());
|
|
}
|
|
}
|
|
|
|
public void f() {
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
if (this.d <= 0) {
|
|
Log.d("APMEventHandle", "onBufferingEnd error: need invoke onBufferingStart first");
|
|
return;
|
|
}
|
|
jSONObject.put("Name", "bufferingEnd");
|
|
long currentTimeMillis = System.currentTimeMillis();
|
|
jSONObject.put("StartTime", currentTimeMillis);
|
|
jSONObject.put("Duration", currentTimeMillis - this.d);
|
|
this.d = 0L;
|
|
d(jSONObject);
|
|
} catch (Exception e) {
|
|
Log.d("APMEventHandle", "onBufferingEnd " + e.getMessage());
|
|
}
|
|
}
|
|
|
|
public void g() {
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
jSONObject.put("Name", "keepPlaying");
|
|
jSONObject.put("StartTime", System.currentTimeMillis());
|
|
d(jSONObject);
|
|
} catch (Exception e) {
|
|
Log.d("APMEventHandle", "onPlayCount " + e.getMessage());
|
|
}
|
|
}
|
|
}
|