Initial commit
This commit is contained in:
16
sources/com/baidu/cloud/media/download/DownloadObserver.java
Normal file
16
sources/com/baidu/cloud/media/download/DownloadObserver.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.baidu.cloud.media.download;
|
||||
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class DownloadObserver implements Observer {
|
||||
public abstract void update(DownloadableVideoItem downloadableVideoItem);
|
||||
|
||||
@Override // java.util.Observer
|
||||
public void update(Observable observable, Object obj) {
|
||||
if (observable instanceof DownloadableVideoItem) {
|
||||
update((DownloadableVideoItem) observable);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,108 @@
|
||||
package com.baidu.cloud.media.download;
|
||||
|
||||
import com.ijm.dataencryption.de.DataDecryptTool;
|
||||
import com.ubt.jimu.base.entities.Course;
|
||||
import java.util.Observable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class DownloadableVideoItem extends Observable {
|
||||
public static final int ERROR_CODE_INVALID_URL = 1;
|
||||
public static final int ERROR_CODE_M3U8_DRM_INVALID = 6;
|
||||
public static final int ERROR_CODE_M3U8_INVALID_FORMAT = 4;
|
||||
public static final int ERROR_CODE_M3U8_SAVE_FAILED = 5;
|
||||
public static final int ERROR_CODE_NETWORK_FAILED = 2;
|
||||
public static final int ERROR_CODE_NO_ERROR = 0;
|
||||
public static final int ERROR_CODE_SDCARD_UNMOUNTED = 3;
|
||||
public static final int ERROR_CODE_TS_SAVE_FAILED = 7;
|
||||
public static final String[] a = {"ERROR_CODE_NO_ERROR", "ERROR_CODE_INVALID_URL", "ERROR_CODE_NETWORK_FAILED", "ERROR_CODE_SDCARD_UNMOUNTED", "ERROR_CODE_M3U8_INVALID_FORMAT", "ERROR_CODE_M3U8_SAVE_FAILED", "ERROR_CODE_M3U8_DRM_INVALID", "ERROR_CODE_TS_SAVE_FAILED"};
|
||||
protected String b;
|
||||
protected String c;
|
||||
protected String d;
|
||||
protected volatile int e;
|
||||
protected volatile int f;
|
||||
protected volatile int g;
|
||||
protected volatile DownloadStatus h = DownloadStatus.NONE;
|
||||
protected String i;
|
||||
protected volatile int j;
|
||||
|
||||
public enum DownloadStatus {
|
||||
NONE(0, "first add"),
|
||||
DOWNLOADING(1, "downloading videos"),
|
||||
PAUSED(2, "paused"),
|
||||
COMPLETED(3, Course.STATUS_COMPLETED),
|
||||
ERROR(4, "failed to download"),
|
||||
DELETED(5, "delete manually"),
|
||||
PENDING(6, "pending, will start automatically(blocked by Parallel Strategy)");
|
||||
|
||||
private int code;
|
||||
private String msg;
|
||||
|
||||
DownloadStatus(int i, String str) {
|
||||
this.code = i;
|
||||
this.msg = str;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.msg;
|
||||
}
|
||||
}
|
||||
|
||||
public int getErrorCode() {
|
||||
return this.j;
|
||||
}
|
||||
|
||||
public String getFailReason() {
|
||||
return this.i;
|
||||
}
|
||||
|
||||
public String getLocalAbsolutePath() {
|
||||
String str = this.d;
|
||||
if (str == null || str.equals("")) {
|
||||
return this.c;
|
||||
}
|
||||
String str2 = this.c;
|
||||
if (str2 == null || str2.equals("")) {
|
||||
return null;
|
||||
}
|
||||
return this.c + "/" + this.d;
|
||||
}
|
||||
|
||||
public float getProgress() {
|
||||
return this.e / 100.0f;
|
||||
}
|
||||
|
||||
public String getSpeed() {
|
||||
StringBuilder sb;
|
||||
String str;
|
||||
if (this.h != DownloadStatus.DOWNLOADING) {
|
||||
return "0KB/s";
|
||||
}
|
||||
if (this.f < 1024) {
|
||||
sb = new StringBuilder();
|
||||
sb.append(this.f);
|
||||
str = "KB/s";
|
||||
} else {
|
||||
sb = new StringBuilder();
|
||||
sb.append(this.f / DataDecryptTool.DECRYPT_SP_FILE);
|
||||
str = "MB/s";
|
||||
}
|
||||
sb.append(str);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public DownloadStatus getStatus() {
|
||||
return this.h;
|
||||
}
|
||||
|
||||
public int getTotalSize() {
|
||||
return this.g;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return this.b;
|
||||
}
|
||||
}
|
47
sources/com/baidu/cloud/media/download/LocalHlsSec.java
Normal file
47
sources/com/baidu/cloud/media/download/LocalHlsSec.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package com.baidu.cloud.media.download;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class LocalHlsSec {
|
||||
static {
|
||||
System.loadLibrary("hls-download");
|
||||
}
|
||||
|
||||
public static String bytes2HexStr(byte[] bArr) {
|
||||
if (bArr == null || bArr.length == 0) {
|
||||
return null;
|
||||
}
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
for (int i = 0; i < bArr.length; i++) {
|
||||
if ((bArr[i] & 255) < 16) {
|
||||
stringBuffer.append("0");
|
||||
}
|
||||
stringBuffer.append(Long.toHexString(bArr[i] & 255));
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public static String decryptStr(Context context, String str) {
|
||||
return bytes2HexStr(new LocalHlsSec().crypt(context, hexStr2Bytes(str), 1));
|
||||
}
|
||||
|
||||
public static byte[] hexStr2Bytes(String str) {
|
||||
if (str.length() < 1) {
|
||||
return null;
|
||||
}
|
||||
byte[] bArr = new byte[str.length() / 2];
|
||||
for (int i = 0; i < str.length() / 2; i++) {
|
||||
int i2 = i * 2;
|
||||
int i3 = i2 + 1;
|
||||
bArr[i] = (byte) ((Integer.parseInt(str.substring(i2, i3), 16) * 16) + Integer.parseInt(str.substring(i3, i2 + 2), 16));
|
||||
}
|
||||
return bArr;
|
||||
}
|
||||
|
||||
public native byte[] crypt(Context context, byte[] bArr, int i);
|
||||
|
||||
public String getMD5(String str) {
|
||||
return a.b(str);
|
||||
}
|
||||
}
|
238
sources/com/baidu/cloud/media/download/VideoDownloadManager.java
Normal file
238
sources/com/baidu/cloud/media/download/VideoDownloadManager.java
Normal file
@@ -0,0 +1,238 @@
|
||||
package com.baidu.cloud.media.download;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import com.baidu.cloud.media.download.DownloadableVideoItem;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class VideoDownloadManager {
|
||||
private static int c = 5;
|
||||
private static volatile VideoDownloadManager i;
|
||||
private static volatile String j;
|
||||
private String a;
|
||||
private String b;
|
||||
private Context f;
|
||||
private String g;
|
||||
private volatile int d = 0;
|
||||
private Queue<String> e = new LinkedList();
|
||||
private ConcurrentHashMap<String, b> h = new ConcurrentHashMap<>();
|
||||
|
||||
private VideoDownloadManager(Context context, String str) {
|
||||
this.a = "_unk@nown_##$ default $##_unk@nown_";
|
||||
this.b = "4f0fecb0c26217433bafbf2a0d595c4e";
|
||||
this.f = context.getApplicationContext();
|
||||
this.a = str;
|
||||
this.b = a.b(str);
|
||||
f();
|
||||
}
|
||||
|
||||
protected static VideoDownloadManager b() {
|
||||
return i;
|
||||
}
|
||||
|
||||
private void f() {
|
||||
this.h.clear();
|
||||
try {
|
||||
for (Map.Entry entry : ((HashMap) this.f.getSharedPreferences(e(), 0).getAll()).entrySet()) {
|
||||
try {
|
||||
String str = (String) entry.getKey();
|
||||
JSONObject jSONObject = new JSONObject((String) entry.getValue());
|
||||
jSONObject.put("urle", str);
|
||||
this.h.put(jSONObject.getString("url"), b.a(this.f, e(), jSONObject));
|
||||
} catch (Exception e) {
|
||||
Log.d("VideoDownloadManager", "" + e.getMessage());
|
||||
}
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
Log.d("VideoDownloadManager", "" + e2.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized VideoDownloadManager getInstance(Context context, String str) {
|
||||
synchronized (VideoDownloadManager.class) {
|
||||
if (str != null) {
|
||||
if (!str.equals("")) {
|
||||
if (!str.equals(j)) {
|
||||
j = str;
|
||||
if (i != null) {
|
||||
i.stopAll();
|
||||
i = null;
|
||||
}
|
||||
}
|
||||
if (i == null) {
|
||||
i = new VideoDownloadManager(context, str);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
Log.e("VideoDownloadManager", "getInstance failed, userName is null or empty.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected String a() {
|
||||
return this.g;
|
||||
}
|
||||
|
||||
protected boolean a(String str) {
|
||||
boolean z;
|
||||
synchronized (this.e) {
|
||||
z = false;
|
||||
if (!this.e.contains(str)) {
|
||||
if (this.d >= c) {
|
||||
this.e.offer(str);
|
||||
} else {
|
||||
this.d++;
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
protected void b(String str) {
|
||||
synchronized (this.e) {
|
||||
this.e.remove(str);
|
||||
}
|
||||
}
|
||||
|
||||
protected void c() {
|
||||
int i2;
|
||||
synchronized (this.e) {
|
||||
if (!this.e.isEmpty()) {
|
||||
b bVar = this.h.get(this.e.poll());
|
||||
if (bVar.getStatus() == DownloadableVideoItem.DownloadStatus.PENDING) {
|
||||
bVar.a();
|
||||
} else if (this.d > 0) {
|
||||
i2 = this.d;
|
||||
this.d = i2 - 1;
|
||||
}
|
||||
} else if (this.d > 0) {
|
||||
i2 = this.d;
|
||||
this.d = i2 - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void changeMaxDownloadingItems(int i2) {
|
||||
if (i2 <= 0 || i2 > 10) {
|
||||
Log.e("VideoDownloadManager", "changeMaxDownloadingItems, maxItems should be 0<x<100");
|
||||
} else {
|
||||
c = i2;
|
||||
}
|
||||
}
|
||||
|
||||
protected String d() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public void deleteDownloader(String str) {
|
||||
b bVar = this.h.get(str);
|
||||
if (bVar == null) {
|
||||
Log.e("VideoDownloadManager", "deleteDownloader but there is no downloader for url=" + str);
|
||||
return;
|
||||
}
|
||||
if (bVar.getStatus() == DownloadableVideoItem.DownloadStatus.PENDING) {
|
||||
b(str);
|
||||
}
|
||||
bVar.c();
|
||||
this.h.remove(str);
|
||||
}
|
||||
|
||||
protected String e() {
|
||||
return "__cyberplayer_dl_" + d();
|
||||
}
|
||||
|
||||
public HashMap<String, DownloadableVideoItem> getAllDownloadableVideoItems() {
|
||||
HashMap<String, DownloadableVideoItem> hashMap = new HashMap<>();
|
||||
hashMap.putAll(this.h);
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
public String getDownloadRootForCurrentUser() {
|
||||
File externalFilesDir = this.f.getExternalFilesDir(null);
|
||||
if (externalFilesDir == null) {
|
||||
return null;
|
||||
}
|
||||
return externalFilesDir.getAbsolutePath() + "/cyberplayer_download_videos/" + d() + "/";
|
||||
}
|
||||
|
||||
public DownloadableVideoItem getDownloadableVideoItemByUrl(String str) {
|
||||
return this.h.get(str);
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public void pauseDownloader(String str) {
|
||||
b bVar = this.h.get(str);
|
||||
if (bVar != null) {
|
||||
if (bVar.getStatus() == DownloadableVideoItem.DownloadStatus.PENDING) {
|
||||
b(str);
|
||||
}
|
||||
bVar.b();
|
||||
} else {
|
||||
Log.e("VideoDownloadManager", "pauseDownloader but there is no downloader for url=" + str);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCustomizedPlayerId(String str) {
|
||||
this.g = str;
|
||||
}
|
||||
|
||||
public void startOrResumeDownloader(String str, DownloadObserver downloadObserver) {
|
||||
startOrResumeDownloaderWithToken(str, null, downloadObserver);
|
||||
}
|
||||
|
||||
public void startOrResumeDownloaderWithToken(String str, String str2, DownloadObserver downloadObserver) {
|
||||
String str3;
|
||||
if (str == null) {
|
||||
Log.e("VideoDownloadManager", "url is null");
|
||||
return;
|
||||
}
|
||||
b bVar = this.h.get(str);
|
||||
if (bVar == null) {
|
||||
String b = a.b(str);
|
||||
String downloadRootForCurrentUser = getDownloadRootForCurrentUser();
|
||||
if (downloadRootForCurrentUser != null) {
|
||||
str3 = downloadRootForCurrentUser + b + "/";
|
||||
} else {
|
||||
str3 = null;
|
||||
}
|
||||
bVar = new b(this.f, str, b, str3, b + ".m3u8", e());
|
||||
this.h.put(str, bVar);
|
||||
}
|
||||
if (downloadObserver != null) {
|
||||
bVar.addObserver(downloadObserver);
|
||||
}
|
||||
if (str2 != null && !str2.equals("")) {
|
||||
bVar.a(str2);
|
||||
}
|
||||
if (a(str)) {
|
||||
bVar.a();
|
||||
} else {
|
||||
bVar.a(DownloadableVideoItem.DownloadStatus.PENDING);
|
||||
Log.w("VideoDownloadManager", "startOrResumeDownloader: too many tasks are downloading , this task is suspending now(will download automatically after other task down)");
|
||||
}
|
||||
}
|
||||
|
||||
public void stopAll() {
|
||||
try {
|
||||
Iterator<Map.Entry<String, b>> it = this.h.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().getValue().b();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.d("VideoDownloadManager", "" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
255
sources/com/baidu/cloud/media/download/a.java
Normal file
255
sources/com/baidu/cloud/media/download/a.java
Normal file
@@ -0,0 +1,255 @@
|
||||
package com.baidu.cloud.media.download;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.util.Log;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class a {
|
||||
/* JADX WARN: Can't wrap try/catch for region: R(22:28|29|(1:31)|32|(1:34)|35|(1:37)|38|39|40|41|(2:42|(1:44)(1:45))|46|(2:48|(10:50|(1:52)|53|54|55|56|57|58|(2:61|62)|60)(1:70))(1:72)|71|54|55|56|57|58|(0)|60) */
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
/* JADX WARN: Removed duplicated region for block: B:105:0x015d A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:109:0x0156 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:113:0x014f A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:117:0x0129 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:125:0x0172 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:131:? A[SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:132:0x016b A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:136:0x0164 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:61:0x00eb A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:88:0x0147 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:92:0x0140 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:96:0x0139 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/* JADX WARN: Type inference failed for: r11v10 */
|
||||
/* JADX WARN: Type inference failed for: r11v11 */
|
||||
/* JADX WARN: Type inference failed for: r11v2, types: [java.io.File] */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public static com.baidu.cloud.media.download.c.b a(java.lang.String r16, java.lang.String r17) {
|
||||
/*
|
||||
Method dump skipped, instructions count: 374
|
||||
To view this dump change 'Code comments level' option to 'DEBUG'
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.baidu.cloud.media.download.a.a(java.lang.String, java.lang.String):com.baidu.cloud.media.download.c$b");
|
||||
}
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:63:0x006a, code lost:
|
||||
|
||||
r5.disconnect();
|
||||
*/
|
||||
/* JADX WARN: Removed duplicated region for block: B:48:0x0098 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:54:? A[SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:55:0x0091 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public static java.lang.String a(java.lang.String r5) {
|
||||
/*
|
||||
java.lang.StringBuilder r0 = new java.lang.StringBuilder
|
||||
r0.<init>()
|
||||
r1 = 0
|
||||
java.net.URL r2 = new java.net.URL // Catch: java.lang.Throwable -> L73 java.lang.Exception -> L76
|
||||
r2.<init>(r5) // Catch: java.lang.Throwable -> L73 java.lang.Exception -> L76
|
||||
java.net.URLConnection r5 = r2.openConnection() // Catch: java.lang.Throwable -> L73 java.lang.Exception -> L76
|
||||
java.net.HttpURLConnection r5 = (java.net.HttpURLConnection) r5 // Catch: java.lang.Throwable -> L73 java.lang.Exception -> L76
|
||||
r2 = 30000(0x7530, float:4.2039E-41)
|
||||
r5.setConnectTimeout(r2) // Catch: java.lang.Throwable -> L6e java.lang.Exception -> L70
|
||||
r5.setReadTimeout(r2) // Catch: java.lang.Throwable -> L6e java.lang.Exception -> L70
|
||||
r5.connect() // Catch: java.lang.Throwable -> L6e java.lang.Exception -> L70
|
||||
int r2 = r5.getResponseCode() // Catch: java.lang.Throwable -> L6e java.lang.Exception -> L70
|
||||
int r2 = r2 / 100
|
||||
r3 = 2
|
||||
if (r2 != r3) goto L68
|
||||
int r2 = r5.getContentLength() // Catch: java.lang.Throwable -> L6e java.lang.Exception -> L70
|
||||
r3 = 5242880(0x500000, float:7.34684E-39)
|
||||
if (r2 <= r3) goto L2e
|
||||
goto L68
|
||||
L2e:
|
||||
java.io.BufferedReader r2 = new java.io.BufferedReader // Catch: java.lang.Throwable -> L6e java.lang.Exception -> L70
|
||||
java.io.InputStreamReader r3 = new java.io.InputStreamReader // Catch: java.lang.Throwable -> L6e java.lang.Exception -> L70
|
||||
java.io.InputStream r4 = r5.getInputStream() // Catch: java.lang.Throwable -> L6e java.lang.Exception -> L70
|
||||
r3.<init>(r4) // Catch: java.lang.Throwable -> L6e java.lang.Exception -> L70
|
||||
r2.<init>(r3) // Catch: java.lang.Throwable -> L6e java.lang.Exception -> L70
|
||||
L3c:
|
||||
java.lang.String r3 = r2.readLine() // Catch: java.lang.Exception -> L66 java.lang.Throwable -> L8d
|
||||
if (r3 == 0) goto L57
|
||||
java.lang.StringBuilder r4 = new java.lang.StringBuilder // Catch: java.lang.Exception -> L66 java.lang.Throwable -> L8d
|
||||
r4.<init>() // Catch: java.lang.Exception -> L66 java.lang.Throwable -> L8d
|
||||
r4.append(r3) // Catch: java.lang.Exception -> L66 java.lang.Throwable -> L8d
|
||||
java.lang.String r3 = "\n"
|
||||
r4.append(r3) // Catch: java.lang.Exception -> L66 java.lang.Throwable -> L8d
|
||||
java.lang.String r3 = r4.toString() // Catch: java.lang.Exception -> L66 java.lang.Throwable -> L8d
|
||||
r0.append(r3) // Catch: java.lang.Exception -> L66 java.lang.Throwable -> L8d
|
||||
goto L3c
|
||||
L57:
|
||||
java.lang.String r0 = r0.toString() // Catch: java.lang.Exception -> L66 java.lang.Throwable -> L8d
|
||||
r2.close() // Catch: java.lang.Exception -> L5f
|
||||
goto L60
|
||||
L5f:
|
||||
L60:
|
||||
if (r5 == 0) goto L65
|
||||
r5.disconnect() // Catch: java.lang.Exception -> L65
|
||||
L65:
|
||||
return r0
|
||||
L66:
|
||||
r0 = move-exception
|
||||
goto L79
|
||||
L68:
|
||||
if (r5 == 0) goto L6d
|
||||
r5.disconnect() // Catch: java.lang.Exception -> L6d
|
||||
L6d:
|
||||
return r1
|
||||
L6e:
|
||||
r0 = move-exception
|
||||
goto L8f
|
||||
L70:
|
||||
r0 = move-exception
|
||||
r2 = r1
|
||||
goto L79
|
||||
L73:
|
||||
r0 = move-exception
|
||||
r5 = r1
|
||||
goto L8f
|
||||
L76:
|
||||
r0 = move-exception
|
||||
r5 = r1
|
||||
r2 = r5
|
||||
L79:
|
||||
java.lang.String r3 = "DownloadUtils"
|
||||
java.lang.String r4 = ""
|
||||
android.util.Log.d(r3, r4, r0) // Catch: java.lang.Throwable -> L8d
|
||||
if (r2 == 0) goto L87
|
||||
r2.close() // Catch: java.lang.Exception -> L86
|
||||
goto L87
|
||||
L86:
|
||||
L87:
|
||||
if (r5 == 0) goto L8c
|
||||
r5.disconnect() // Catch: java.lang.Exception -> L8c
|
||||
L8c:
|
||||
return r1
|
||||
L8d:
|
||||
r0 = move-exception
|
||||
r1 = r2
|
||||
L8f:
|
||||
if (r1 == 0) goto L96
|
||||
r1.close() // Catch: java.lang.Exception -> L95
|
||||
goto L96
|
||||
L95:
|
||||
L96:
|
||||
if (r5 == 0) goto L9b
|
||||
r5.disconnect() // Catch: java.lang.Exception -> L9b
|
||||
L9b:
|
||||
throw r0
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.baidu.cloud.media.download.a.a(java.lang.String):java.lang.String");
|
||||
}
|
||||
|
||||
public static boolean a(Context context) {
|
||||
NetworkInfo[] allNetworkInfo;
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
|
||||
if (connectivityManager != null && (allNetworkInfo = connectivityManager.getAllNetworkInfo()) != null && allNetworkInfo.length > 0) {
|
||||
for (NetworkInfo networkInfo : allNetworkInfo) {
|
||||
if (networkInfo.getState() == NetworkInfo.State.CONNECTED) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean a(byte[] bArr, String str) {
|
||||
File file;
|
||||
FileOutputStream fileOutputStream = null;
|
||||
try {
|
||||
try {
|
||||
file = new File(str);
|
||||
try {
|
||||
if (!file.getParentFile().exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
file.createNewFile();
|
||||
FileOutputStream fileOutputStream2 = new FileOutputStream(file);
|
||||
try {
|
||||
fileOutputStream2.write(bArr);
|
||||
fileOutputStream2.flush();
|
||||
fileOutputStream2.close();
|
||||
try {
|
||||
fileOutputStream2.close();
|
||||
} catch (IOException e) {
|
||||
Log.d("DownloadUtils", "" + e.getMessage());
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e2) {
|
||||
e = e2;
|
||||
fileOutputStream = fileOutputStream2;
|
||||
Log.d("DownloadUtils", "" + Log.getStackTraceString(e));
|
||||
if (file != null && file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
if (fileOutputStream != null) {
|
||||
try {
|
||||
fileOutputStream.close();
|
||||
} catch (IOException e3) {
|
||||
Log.d("DownloadUtils", "" + e3.getMessage());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
fileOutputStream = fileOutputStream2;
|
||||
if (fileOutputStream != null) {
|
||||
try {
|
||||
fileOutputStream.close();
|
||||
} catch (IOException e4) {
|
||||
Log.d("DownloadUtils", "" + e4.getMessage());
|
||||
}
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
} catch (Exception e5) {
|
||||
e = e5;
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
}
|
||||
} catch (Exception e6) {
|
||||
e = e6;
|
||||
file = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String b(String str) {
|
||||
byte[] bytes = str.getBytes();
|
||||
char[] cArr = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||
try {
|
||||
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
|
||||
messageDigest.update(bytes);
|
||||
byte[] digest = messageDigest.digest();
|
||||
char[] cArr2 = new char[32];
|
||||
int i = 0;
|
||||
for (int i2 = 0; i2 < 16; i2++) {
|
||||
byte b = digest[i2];
|
||||
int i3 = i + 1;
|
||||
cArr2[i] = cArr[(b >>> 4) & 15];
|
||||
i = i3 + 1;
|
||||
cArr2[i3] = cArr[b & 15];
|
||||
}
|
||||
return new String(cArr2);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
Log.e("DownloadUtils", "", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
464
sources/com/baidu/cloud/media/download/b.java
Normal file
464
sources/com/baidu/cloud/media/download/b.java
Normal file
@@ -0,0 +1,464 @@
|
||||
package com.baidu.cloud.media.download;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
import com.baidu.cloud.media.download.DownloadableVideoItem;
|
||||
import com.baidu.cloud.media.download.c;
|
||||
import com.baidu.cloud.media.download.d;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class b extends DownloadableVideoItem {
|
||||
private volatile boolean m;
|
||||
private ArrayList<String> n;
|
||||
private String o;
|
||||
private String p;
|
||||
private Context q;
|
||||
private ExecutorService k = null;
|
||||
private volatile int l = 0;
|
||||
private String r = null;
|
||||
|
||||
public b(Context context, String str, String str2, String str3, String str4, String str5) {
|
||||
this.o = "";
|
||||
this.p = "";
|
||||
this.q = context;
|
||||
this.b = str;
|
||||
this.o = str2;
|
||||
this.c = str3;
|
||||
this.d = str4;
|
||||
this.p = str5;
|
||||
}
|
||||
|
||||
public static b a(Context context, String str, JSONObject jSONObject) {
|
||||
b bVar;
|
||||
try {
|
||||
String string = jSONObject.getString("url");
|
||||
String string2 = jSONObject.getString("urle");
|
||||
String optString = jSONObject.optString("fold", null);
|
||||
String string3 = jSONObject.getString("file");
|
||||
int i = jSONObject.getInt("st");
|
||||
int i2 = jSONObject.getInt("prgr");
|
||||
int i3 = jSONObject.getInt("tsdl");
|
||||
bVar = new b(context, string, string2, optString, string3, str);
|
||||
try {
|
||||
bVar.a(i, i2, i3);
|
||||
} catch (Exception e) {
|
||||
e = e;
|
||||
Log.e("HLSVideoDownloader", "" + Log.getStackTraceString(e));
|
||||
return bVar;
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
e = e2;
|
||||
bVar = null;
|
||||
}
|
||||
return bVar;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void a(c.a aVar) {
|
||||
if (this.l >= this.n.size()) {
|
||||
i();
|
||||
return;
|
||||
}
|
||||
c cVar = new c(this.n.get(this.l), this.c + "/" + (this.l + 1) + ".ts", aVar);
|
||||
ExecutorService executorService = this.k;
|
||||
if (executorService == null || executorService.isShutdown()) {
|
||||
Log.d("HLSVideoDownloader", "new executor is created now");
|
||||
this.k = Executors.newSingleThreadExecutor();
|
||||
}
|
||||
this.k.execute(cVar);
|
||||
}
|
||||
|
||||
private void d() {
|
||||
try {
|
||||
if (!new URL(this.b).getPath().endsWith(".m3u8")) {
|
||||
this.i = "only download m3u8 video";
|
||||
this.j = 1;
|
||||
a(DownloadableVideoItem.DownloadStatus.ERROR);
|
||||
return;
|
||||
}
|
||||
String str = this.c;
|
||||
if (str == null || str.equals("")) {
|
||||
String downloadRootForCurrentUser = VideoDownloadManager.b().getDownloadRootForCurrentUser();
|
||||
if (downloadRootForCurrentUser == null) {
|
||||
this.i = "sdcard is unmounted";
|
||||
this.j = 3;
|
||||
a(DownloadableVideoItem.DownloadStatus.ERROR);
|
||||
return;
|
||||
} else {
|
||||
this.c = downloadRootForCurrentUser + this.o + "/";
|
||||
}
|
||||
}
|
||||
if (!this.m) {
|
||||
if (!g()) {
|
||||
if (!e()) {
|
||||
a(DownloadableVideoItem.DownloadStatus.ERROR);
|
||||
return;
|
||||
}
|
||||
Runnable runnable = new Runnable() { // from class: com.baidu.cloud.media.download.b.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
d.a aVar = new d.a() { // from class: com.baidu.cloud.media.download.b.1.1
|
||||
@Override // com.baidu.cloud.media.download.d.a
|
||||
public void a(int i) {
|
||||
if (b.this.h == DownloadableVideoItem.DownloadStatus.DOWNLOADING) {
|
||||
Log.d("HLSVideoDownloader", "Parse failed: error code is " + i);
|
||||
b.this.i = "parse M3U8 failed, reason = " + DownloadableVideoItem.a[i];
|
||||
b bVar = b.this;
|
||||
bVar.j = i;
|
||||
bVar.a(DownloadableVideoItem.DownloadStatus.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.download.d.a
|
||||
public void a(List<String> list) {
|
||||
if (b.this.h == DownloadableVideoItem.DownloadStatus.DOWNLOADING) {
|
||||
b.this.n = (ArrayList) list;
|
||||
b.this.f();
|
||||
b.this.m = true;
|
||||
b.this.h();
|
||||
}
|
||||
}
|
||||
};
|
||||
d dVar = new d(b.this.q, b.this.c + "/" + b.this.d);
|
||||
b bVar = b.this;
|
||||
dVar.a(bVar.b, bVar.r, aVar);
|
||||
}
|
||||
};
|
||||
ExecutorService executorService = this.k;
|
||||
if (executorService == null || executorService.isShutdown()) {
|
||||
Log.d("HLSVideoDownloader", "new executor is created now to download m3u8 file");
|
||||
this.k = Executors.newSingleThreadExecutor();
|
||||
}
|
||||
this.k.execute(runnable);
|
||||
return;
|
||||
}
|
||||
this.m = true;
|
||||
}
|
||||
h();
|
||||
} catch (Exception e) {
|
||||
Log.d("HLSVideoDownloader", "" + e.getMessage());
|
||||
this.i = "url format is invalid";
|
||||
this.j = 1;
|
||||
a(DownloadableVideoItem.DownloadStatus.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ int e(b bVar) {
|
||||
int i = bVar.l;
|
||||
bVar.l = i + 1;
|
||||
return i;
|
||||
}
|
||||
|
||||
private boolean e() {
|
||||
boolean z = true;
|
||||
try {
|
||||
if (!"mounted".equals(Environment.getExternalStorageState())) {
|
||||
this.i = "save file failed, sdcard unmounted";
|
||||
this.j = 3;
|
||||
z = false;
|
||||
}
|
||||
if (a.a(this.q)) {
|
||||
return z;
|
||||
}
|
||||
this.i = "network is not available";
|
||||
this.j = 2;
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
Log.d("HLSVideoDownloader", "checkEnvironment " + e.getMessage());
|
||||
return z;
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
public void f() {
|
||||
ArrayList<String> arrayList = this.n;
|
||||
if (arrayList == null || arrayList.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
FileOutputStream fileOutputStream = null;
|
||||
fileOutputStream = null;
|
||||
try {
|
||||
try {
|
||||
try {
|
||||
FileOutputStream fileOutputStream2 = new FileOutputStream(this.c + "/tsdl.data");
|
||||
try {
|
||||
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream2);
|
||||
objectOutputStream.writeObject(this.n);
|
||||
fileOutputStream2.close();
|
||||
fileOutputStream = objectOutputStream;
|
||||
} catch (Exception e) {
|
||||
e = e;
|
||||
fileOutputStream = fileOutputStream2;
|
||||
Log.d("HLSVideoDownloader", "" + e.getMessage());
|
||||
if (fileOutputStream != null) {
|
||||
fileOutputStream.close();
|
||||
fileOutputStream = fileOutputStream;
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
fileOutputStream = fileOutputStream2;
|
||||
if (fileOutputStream != null) {
|
||||
try {
|
||||
fileOutputStream.close();
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
e = e2;
|
||||
}
|
||||
} catch (IOException unused2) {
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean g() {
|
||||
if (!new File(this.c + "/" + this.d).exists()) {
|
||||
return false;
|
||||
}
|
||||
if (this.n != null) {
|
||||
return true;
|
||||
}
|
||||
FileInputStream fileInputStream = null;
|
||||
try {
|
||||
try {
|
||||
FileInputStream fileInputStream2 = new FileInputStream(this.c + "/tsdl.data");
|
||||
try {
|
||||
this.n = (ArrayList) new ObjectInputStream(fileInputStream2).readObject();
|
||||
try {
|
||||
fileInputStream2.close();
|
||||
return true;
|
||||
} catch (IOException unused) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e = e;
|
||||
fileInputStream = fileInputStream2;
|
||||
Log.d("HLSVideoDownloader", "" + e.getMessage());
|
||||
if (fileInputStream != null) {
|
||||
try {
|
||||
fileInputStream.close();
|
||||
} catch (IOException unused2) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
fileInputStream = fileInputStream2;
|
||||
if (fileInputStream != null) {
|
||||
try {
|
||||
fileInputStream.close();
|
||||
} catch (IOException unused3) {
|
||||
}
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
e = e2;
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void h() {
|
||||
ArrayList<String> arrayList = this.n;
|
||||
if (arrayList == null || arrayList.size() == 0) {
|
||||
this.i = "tsList.size == 0";
|
||||
this.j = 4;
|
||||
a(DownloadableVideoItem.DownloadStatus.ERROR);
|
||||
} else if (e()) {
|
||||
a(new c.a() { // from class: com.baidu.cloud.media.download.b.2
|
||||
@Override // com.baidu.cloud.media.download.c.a
|
||||
public void a(int i, int i2, int i3) {
|
||||
b bVar;
|
||||
int i4;
|
||||
if (i == 1) {
|
||||
if (b.this.h == DownloadableVideoItem.DownloadStatus.PAUSED || b.this.h == DownloadableVideoItem.DownloadStatus.DELETED) {
|
||||
return;
|
||||
}
|
||||
b.e(b.this);
|
||||
b.this.a(i2, i3);
|
||||
b.this.a(this);
|
||||
return;
|
||||
}
|
||||
if (b.this.h == DownloadableVideoItem.DownloadStatus.PAUSED || b.this.h == DownloadableVideoItem.DownloadStatus.DELETED) {
|
||||
return;
|
||||
}
|
||||
if (i == -2) {
|
||||
bVar = b.this;
|
||||
bVar.i = "network has problem";
|
||||
i4 = 2;
|
||||
} else {
|
||||
b.this.i = "save the " + b.this.l + "th ts file - interrupted";
|
||||
bVar = b.this;
|
||||
i4 = 7;
|
||||
}
|
||||
bVar.j = i4;
|
||||
b.this.a(DownloadableVideoItem.DownloadStatus.ERROR);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
a(DownloadableVideoItem.DownloadStatus.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
private void i() {
|
||||
a(DownloadableVideoItem.DownloadStatus.COMPLETED);
|
||||
}
|
||||
|
||||
private void j() {
|
||||
String k;
|
||||
if (this.h == DownloadableVideoItem.DownloadStatus.DELETED || (k = k()) == null) {
|
||||
return;
|
||||
}
|
||||
SharedPreferences.Editor edit = this.q.getSharedPreferences(this.p, 0).edit();
|
||||
edit.putString(this.o, k);
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
edit.apply();
|
||||
} else {
|
||||
edit.commit();
|
||||
}
|
||||
}
|
||||
|
||||
private String k() {
|
||||
try {
|
||||
JSONObject jSONObject = new JSONObject();
|
||||
jSONObject.put("url", this.b);
|
||||
jSONObject.put("fold", this.c);
|
||||
jSONObject.put("file", this.d);
|
||||
jSONObject.put("st", this.h.getCode());
|
||||
jSONObject.put("prgr", this.e);
|
||||
jSONObject.put("tsdl", this.l);
|
||||
return jSONObject.toString();
|
||||
} catch (Exception e) {
|
||||
Log.e("HLSVideoDownloader", "" + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void a(int i, int i2) {
|
||||
ArrayList<String> arrayList;
|
||||
if (this.h == DownloadableVideoItem.DownloadStatus.DOWNLOADING && (arrayList = this.n) != null && arrayList.size() > 0) {
|
||||
this.e = Math.round((this.l / this.n.size()) * 10000.0f);
|
||||
this.f = i;
|
||||
this.g += i2;
|
||||
}
|
||||
j();
|
||||
setChanged();
|
||||
notifyObservers();
|
||||
}
|
||||
|
||||
protected void a(int i, int i2, int i3) {
|
||||
this.e = i2;
|
||||
this.l = i3;
|
||||
DownloadableVideoItem.DownloadStatus downloadStatus = DownloadableVideoItem.DownloadStatus.values()[i];
|
||||
if (downloadStatus == DownloadableVideoItem.DownloadStatus.DOWNLOADING || downloadStatus == DownloadableVideoItem.DownloadStatus.PENDING) {
|
||||
downloadStatus = DownloadableVideoItem.DownloadStatus.PAUSED;
|
||||
}
|
||||
this.h = downloadStatus;
|
||||
}
|
||||
|
||||
protected void a(DownloadableVideoItem.DownloadStatus downloadStatus) {
|
||||
VideoDownloadManager b;
|
||||
DownloadableVideoItem.DownloadStatus downloadStatus2 = this.h;
|
||||
DownloadableVideoItem.DownloadStatus downloadStatus3 = DownloadableVideoItem.DownloadStatus.DOWNLOADING;
|
||||
if (downloadStatus2 == downloadStatus3 && downloadStatus != downloadStatus3 && (b = VideoDownloadManager.b()) != null) {
|
||||
b.c();
|
||||
}
|
||||
this.h = downloadStatus;
|
||||
if (downloadStatus != DownloadableVideoItem.DownloadStatus.PAUSED && downloadStatus != DownloadableVideoItem.DownloadStatus.ERROR) {
|
||||
this.i = "";
|
||||
}
|
||||
if (downloadStatus != DownloadableVideoItem.DownloadStatus.ERROR) {
|
||||
this.j = 0;
|
||||
}
|
||||
a(0, 0);
|
||||
}
|
||||
|
||||
public void a(String str) {
|
||||
this.r = str;
|
||||
}
|
||||
|
||||
public boolean a() {
|
||||
DownloadableVideoItem.DownloadStatus downloadStatus = this.h;
|
||||
DownloadableVideoItem.DownloadStatus downloadStatus2 = DownloadableVideoItem.DownloadStatus.DOWNLOADING;
|
||||
if (downloadStatus != downloadStatus2) {
|
||||
a(downloadStatus2);
|
||||
d();
|
||||
return true;
|
||||
}
|
||||
Log.e("HLSVideoDownloader", "start failed because downloadStatus = " + this.h.name());
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean b() {
|
||||
if (this.h == DownloadableVideoItem.DownloadStatus.PAUSED || this.h == DownloadableVideoItem.DownloadStatus.COMPLETED || this.h == DownloadableVideoItem.DownloadStatus.DELETED) {
|
||||
Log.e("HLSVideoDownloader", "pause not work, && downloadStatus = " + this.h.name());
|
||||
return false;
|
||||
}
|
||||
ExecutorService executorService = this.k;
|
||||
if (executorService != null && !executorService.isShutdown()) {
|
||||
this.k.shutdownNow();
|
||||
}
|
||||
this.i = "manually pause";
|
||||
a(DownloadableVideoItem.DownloadStatus.PAUSED);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean c() {
|
||||
try {
|
||||
a(DownloadableVideoItem.DownloadStatus.DELETED);
|
||||
if (this.k != null && !this.k.isTerminated() && !this.k.isShutdown()) {
|
||||
this.k.shutdownNow();
|
||||
}
|
||||
SharedPreferences.Editor edit = this.q.getSharedPreferences(this.p, 0).edit();
|
||||
edit.remove(this.o);
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
edit.apply();
|
||||
} else {
|
||||
edit.commit();
|
||||
}
|
||||
if (this.c != null) {
|
||||
File file = new File(this.c);
|
||||
if (file.exists() && file.isDirectory()) {
|
||||
File[] listFiles = file.listFiles();
|
||||
for (int i = 0; i < listFiles.length; i++) {
|
||||
if (listFiles[i].isFile()) {
|
||||
listFiles[i].delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.c = "";
|
||||
this.d = "";
|
||||
this.e = 0;
|
||||
this.j = 0;
|
||||
this.i = "delete manually";
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
Log.e("HLSVideoDownloader", "" + e.getMessage());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
33
sources/com/baidu/cloud/media/download/c.java
Normal file
33
sources/com/baidu/cloud/media/download/c.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.baidu.cloud.media.download;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class c implements Runnable {
|
||||
String a;
|
||||
String b;
|
||||
a c;
|
||||
|
||||
public static abstract class a {
|
||||
public abstract void a(int i, int i2, int i3);
|
||||
}
|
||||
|
||||
static class b {
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
|
||||
b() {
|
||||
}
|
||||
}
|
||||
|
||||
public c(String str, String str2, a aVar) {
|
||||
this.a = str;
|
||||
this.b = str2;
|
||||
this.c = aVar;
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
b a2 = com.baidu.cloud.media.download.a.a(this.a, this.b);
|
||||
this.c.a(a2.a, a2.b, a2.c);
|
||||
}
|
||||
}
|
222
sources/com/baidu/cloud/media/download/d.java
Normal file
222
sources/com/baidu/cloud/media/download/d.java
Normal file
@@ -0,0 +1,222 @@
|
||||
package com.baidu.cloud.media.download;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class d {
|
||||
private String a;
|
||||
private List<String> b;
|
||||
private a c;
|
||||
private Context d;
|
||||
private String f;
|
||||
private String e = null;
|
||||
private String g = null;
|
||||
|
||||
public static abstract class a {
|
||||
public abstract void a(int i);
|
||||
|
||||
public abstract void a(List<String> list);
|
||||
}
|
||||
|
||||
public d(Context context, String str) {
|
||||
this.a = "";
|
||||
this.b = null;
|
||||
this.c = null;
|
||||
this.d = context.getApplicationContext();
|
||||
this.f = str;
|
||||
this.a = "";
|
||||
this.b = new ArrayList();
|
||||
this.c = null;
|
||||
}
|
||||
|
||||
private long a(String str) {
|
||||
try {
|
||||
String[] split = str.split(":|=|,");
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
if (split[i].trim().equals("BANDWIDTH")) {
|
||||
return Long.parseLong(split[i + 1].trim());
|
||||
}
|
||||
}
|
||||
return 0L;
|
||||
} catch (Exception e) {
|
||||
Log.d("M3U8Parser", "" + e.getMessage());
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
private void a() {
|
||||
SharedPreferences.Editor edit = this.d.getSharedPreferences("__cyberplayer_dl_sec", 0).edit();
|
||||
edit.putString(this.f, this.e);
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
edit.apply();
|
||||
} else {
|
||||
edit.commit();
|
||||
}
|
||||
}
|
||||
|
||||
private void a(String str, List<String> list) {
|
||||
String str2;
|
||||
if (str == null || TextUtils.isEmpty(str)) {
|
||||
this.c.a(1);
|
||||
return;
|
||||
}
|
||||
Scanner scanner = new Scanner(str);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String str3 = null;
|
||||
long j = 0;
|
||||
String str4 = null;
|
||||
boolean z = false;
|
||||
boolean z2 = false;
|
||||
while (true) {
|
||||
try {
|
||||
String str5 = "";
|
||||
if (!scanner.hasNextLine()) {
|
||||
scanner.close();
|
||||
if (!z) {
|
||||
if (this.e != null) {
|
||||
a();
|
||||
}
|
||||
if (com.baidu.cloud.media.download.a.a(sb.toString().getBytes(), this.f)) {
|
||||
this.c.a(this.b);
|
||||
return;
|
||||
} else {
|
||||
this.c.a(5);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.b.clear();
|
||||
if (!str3.startsWith("http://")) {
|
||||
str5 = this.a;
|
||||
}
|
||||
a(com.baidu.cloud.media.download.a.a(str5 + str3), this.b);
|
||||
return;
|
||||
}
|
||||
String nextLine = scanner.nextLine();
|
||||
if (!z2 && !nextLine.startsWith("#EXTM3U")) {
|
||||
scanner.close();
|
||||
this.c.a(4);
|
||||
return;
|
||||
}
|
||||
if (TextUtils.isEmpty(str4) || !str4.startsWith("#EXT-X-STREAM-INF:")) {
|
||||
if (!TextUtils.isEmpty(str4) && str4.startsWith("#EXTINF:")) {
|
||||
if (!nextLine.contains("://")) {
|
||||
str5 = this.a;
|
||||
}
|
||||
if (nextLine.startsWith("/")) {
|
||||
str5 = str5.substring(0, str5.indexOf("/", str5.indexOf("://") + 3));
|
||||
} else if (nextLine.startsWith("../")) {
|
||||
if (str5.endsWith("/")) {
|
||||
str5 = str5.substring(0, str5.length() - 1);
|
||||
}
|
||||
str5 = str5.substring(0, str5.lastIndexOf("/") + 1);
|
||||
nextLine = nextLine.substring(3);
|
||||
}
|
||||
list.add(str5 + nextLine);
|
||||
str2 = String.valueOf(list.size()) + ".ts\n";
|
||||
} else if (TextUtils.isEmpty(nextLine) || !nextLine.startsWith("#EXT-X-KEY:")) {
|
||||
str2 = nextLine + "\n";
|
||||
} else {
|
||||
String b = b(nextLine);
|
||||
if (b == null) {
|
||||
scanner.close();
|
||||
this.c.a(6);
|
||||
return;
|
||||
} else {
|
||||
str2 = b + "\n";
|
||||
}
|
||||
}
|
||||
sb.append(str2);
|
||||
str4 = nextLine;
|
||||
} else {
|
||||
long a2 = a(str4);
|
||||
if (a2 > j) {
|
||||
str3 = nextLine;
|
||||
} else {
|
||||
a2 = j;
|
||||
}
|
||||
j = a2;
|
||||
str4 = nextLine;
|
||||
z = true;
|
||||
}
|
||||
z2 = true;
|
||||
} catch (Exception e) {
|
||||
Log.d("M3U8Parser", Log.getStackTraceString(e));
|
||||
this.c.a(2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String b(String str) {
|
||||
String str2;
|
||||
String str3 = null;
|
||||
try {
|
||||
boolean contains = str.contains("=media-drm-player-binding");
|
||||
boolean contains2 = str.contains("=media-drm-safe-code");
|
||||
boolean contains3 = str.contains("=media-drm-token");
|
||||
if (!contains && !contains2 && !contains3) {
|
||||
return str;
|
||||
}
|
||||
if (this.e == null) {
|
||||
String substring = str.substring(str.indexOf("URI=\"") + 5);
|
||||
String substring2 = substring.substring(0, substring.indexOf("\""));
|
||||
String str4 = "pid-android-1";
|
||||
try {
|
||||
String a2 = VideoDownloadManager.b().a();
|
||||
if (!TextUtils.isEmpty(a2)) {
|
||||
str4 = a2;
|
||||
}
|
||||
} catch (Exception unused) {
|
||||
}
|
||||
String str5 = substring2 + "&playerId=" + str4;
|
||||
if (contains3) {
|
||||
str5 = str5 + "&token=" + this.g;
|
||||
}
|
||||
this.e = LocalHlsSec.bytes2HexStr(new LocalHlsSec().crypt(this.d, LocalHlsSec.hexStr2Bytes(new JSONObject(com.baidu.cloud.media.download.a.a(str5)).getString("encryptedVideoKey")), 0));
|
||||
}
|
||||
if (contains) {
|
||||
str2 = "media-drm-player-binding";
|
||||
} else if (contains2) {
|
||||
str2 = "media-drm-safe-code";
|
||||
} else {
|
||||
if (!contains3) {
|
||||
return str;
|
||||
}
|
||||
str2 = "media-drm-token";
|
||||
}
|
||||
try {
|
||||
str = str.replace(str2, "media-drm-local-key");
|
||||
return str;
|
||||
} catch (Exception e) {
|
||||
str3 = str;
|
||||
e = e;
|
||||
Log.d("M3U8Parser", "", e);
|
||||
return str3;
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
e = e2;
|
||||
}
|
||||
}
|
||||
|
||||
public int a(String str, String str2, a aVar) {
|
||||
if (TextUtils.isEmpty(str) || aVar == null) {
|
||||
return 1;
|
||||
}
|
||||
this.g = str2;
|
||||
this.c = aVar;
|
||||
this.b.clear();
|
||||
if (TextUtils.isEmpty(this.a)) {
|
||||
this.a = str.substring(0, str.lastIndexOf(47) + 1);
|
||||
}
|
||||
a(com.baidu.cloud.media.download.a.a(str), this.b);
|
||||
return 0;
|
||||
}
|
||||
}
|
138
sources/com/baidu/cloud/media/player/AbstractMediaPlayer.java
Normal file
138
sources/com/baidu/cloud/media/player/AbstractMediaPlayer.java
Normal file
@@ -0,0 +1,138 @@
|
||||
package com.baidu.cloud.media.player;
|
||||
|
||||
import android.os.Bundle;
|
||||
import com.baidu.cloud.media.player.IMediaPlayer;
|
||||
import com.baidu.cloud.media.player.misc.IMediaDataSource;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class AbstractMediaPlayer implements IMediaPlayer {
|
||||
private IMediaPlayer.OnPreparedListener a;
|
||||
private IMediaPlayer.OnCompletionListener b;
|
||||
private IMediaPlayer.OnBufferingUpdateListener c;
|
||||
private IMediaPlayer.OnSeekCompleteListener d;
|
||||
private IMediaPlayer.OnVideoSizeChangedListener e;
|
||||
private IMediaPlayer.OnErrorListener f;
|
||||
private IMediaPlayer.OnInfoListener g;
|
||||
private IMediaPlayer.OnTimedTextListener h;
|
||||
private IMediaPlayer.OnMetadataListener i;
|
||||
|
||||
protected final void a() {
|
||||
IMediaPlayer.OnPreparedListener onPreparedListener = this.a;
|
||||
if (onPreparedListener != null) {
|
||||
onPreparedListener.onPrepared(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected final void a(int i) {
|
||||
IMediaPlayer.OnBufferingUpdateListener onBufferingUpdateListener = this.c;
|
||||
if (onBufferingUpdateListener != null) {
|
||||
onBufferingUpdateListener.onBufferingUpdate(this, i);
|
||||
}
|
||||
}
|
||||
|
||||
protected final void a(int i, int i2, int i3, int i4) {
|
||||
IMediaPlayer.OnVideoSizeChangedListener onVideoSizeChangedListener = this.e;
|
||||
if (onVideoSizeChangedListener != null) {
|
||||
onVideoSizeChangedListener.onVideoSizeChanged(this, i, i2, i3, i4);
|
||||
}
|
||||
}
|
||||
|
||||
protected final void a(Bundle bundle) {
|
||||
IMediaPlayer.OnMetadataListener onMetadataListener = this.i;
|
||||
if (onMetadataListener != null) {
|
||||
onMetadataListener.onMetadata(this, bundle);
|
||||
}
|
||||
}
|
||||
|
||||
protected final void a(BDTimedText bDTimedText) {
|
||||
IMediaPlayer.OnTimedTextListener onTimedTextListener = this.h;
|
||||
if (onTimedTextListener != null) {
|
||||
onTimedTextListener.onTimedText(this, bDTimedText);
|
||||
}
|
||||
}
|
||||
|
||||
protected final boolean a(int i, int i2) {
|
||||
IMediaPlayer.OnErrorListener onErrorListener = this.f;
|
||||
return onErrorListener != null && onErrorListener.onError(this, i, i2);
|
||||
}
|
||||
|
||||
protected final void b() {
|
||||
IMediaPlayer.OnCompletionListener onCompletionListener = this.b;
|
||||
if (onCompletionListener != null) {
|
||||
onCompletionListener.onCompletion(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected final boolean b(int i, int i2) {
|
||||
IMediaPlayer.OnInfoListener onInfoListener = this.g;
|
||||
return onInfoListener != null && onInfoListener.onInfo(this, i, i2);
|
||||
}
|
||||
|
||||
protected final void c() {
|
||||
IMediaPlayer.OnSeekCompleteListener onSeekCompleteListener = this.d;
|
||||
if (onSeekCompleteListener != null) {
|
||||
onSeekCompleteListener.onSeekComplete(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void resetListeners() {
|
||||
this.a = null;
|
||||
this.c = null;
|
||||
this.b = null;
|
||||
this.d = null;
|
||||
this.e = null;
|
||||
this.f = null;
|
||||
this.g = null;
|
||||
this.h = null;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
||||
public void setDataSource(IMediaDataSource iMediaDataSource) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
||||
public final void setOnBufferingUpdateListener(IMediaPlayer.OnBufferingUpdateListener onBufferingUpdateListener) {
|
||||
this.c = onBufferingUpdateListener;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
||||
public final void setOnCompletionListener(IMediaPlayer.OnCompletionListener onCompletionListener) {
|
||||
this.b = onCompletionListener;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
||||
public final void setOnErrorListener(IMediaPlayer.OnErrorListener onErrorListener) {
|
||||
this.f = onErrorListener;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
||||
public final void setOnInfoListener(IMediaPlayer.OnInfoListener onInfoListener) {
|
||||
this.g = onInfoListener;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
||||
public final void setOnMetadataListener(IMediaPlayer.OnMetadataListener onMetadataListener) {
|
||||
this.i = onMetadataListener;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
||||
public final void setOnPreparedListener(IMediaPlayer.OnPreparedListener onPreparedListener) {
|
||||
this.a = onPreparedListener;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
||||
public final void setOnSeekCompleteListener(IMediaPlayer.OnSeekCompleteListener onSeekCompleteListener) {
|
||||
this.d = onSeekCompleteListener;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
||||
public final void setOnTimedTextListener(IMediaPlayer.OnTimedTextListener onTimedTextListener) {
|
||||
this.h = onTimedTextListener;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.IMediaPlayer
|
||||
public final void setOnVideoSizeChangedListener(IMediaPlayer.OnVideoSizeChangedListener onVideoSizeChangedListener) {
|
||||
this.e = onVideoSizeChangedListener;
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package com.baidu.cloud.media.player;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface BDCloudLibLoader {
|
||||
void loadLibrary(String str) throws UnsatisfiedLinkError, SecurityException;
|
||||
}
|
1488
sources/com/baidu/cloud/media/player/BDCloudMediaPlayer.java
Normal file
1488
sources/com/baidu/cloud/media/player/BDCloudMediaPlayer.java
Normal file
File diff suppressed because it is too large
Load Diff
24
sources/com/baidu/cloud/media/player/BDTimedText.java
Normal file
24
sources/com/baidu/cloud/media/player/BDTimedText.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.baidu.cloud.media.player;
|
||||
|
||||
import android.graphics.Rect;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class BDTimedText {
|
||||
private Rect a;
|
||||
private String b;
|
||||
|
||||
public BDTimedText(Rect rect, String str) {
|
||||
this.a = null;
|
||||
this.b = null;
|
||||
this.a = rect;
|
||||
this.b = str;
|
||||
}
|
||||
|
||||
public Rect getBounds() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.b;
|
||||
}
|
||||
}
|
165
sources/com/baidu/cloud/media/player/IMediaPlayer.java
Normal file
165
sources/com/baidu/cloud/media/player/IMediaPlayer.java
Normal file
@@ -0,0 +1,165 @@
|
||||
package com.baidu.cloud.media.player;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.Surface;
|
||||
import android.view.SurfaceHolder;
|
||||
import com.baidu.cloud.media.player.misc.IMediaDataSource;
|
||||
import com.baidu.cloud.media.player.misc.ITrackInfo;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface IMediaPlayer {
|
||||
public static final int MEDIA_ERROR_AUTH_FAILURE = -1000;
|
||||
public static final int MEDIA_ERROR_IO = -1004;
|
||||
public static final int MEDIA_ERROR_MALFORMED = -1007;
|
||||
public static final int MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK = 200;
|
||||
public static final int MEDIA_ERROR_SERVER_DIED = 100;
|
||||
public static final int MEDIA_ERROR_TIMED_OUT = -110;
|
||||
public static final int MEDIA_ERROR_UNKNOWN = 1;
|
||||
public static final int MEDIA_ERROR_UNSUPPORTED = -1010;
|
||||
public static final int MEDIA_INFO_AUDIO_RENDERING_START = 10002;
|
||||
public static final int MEDIA_INFO_BAD_INTERLEAVING = 800;
|
||||
public static final int MEDIA_INFO_BUFFERING_END = 702;
|
||||
public static final int MEDIA_INFO_BUFFERING_START = 701;
|
||||
public static final int MEDIA_INFO_FRAMECHASING_END = 10004;
|
||||
public static final int MEDIA_INFO_FRAMECHASING_START = 10003;
|
||||
public static final int MEDIA_INFO_MEDIA_CHANGE_END = 10006;
|
||||
public static final int MEDIA_INFO_MEDIA_CHANGE_START = 10005;
|
||||
public static final int MEDIA_INFO_METADATA_UPDATE = 802;
|
||||
public static final int MEDIA_INFO_NETWORK_BANDWIDTH = 703;
|
||||
public static final int MEDIA_INFO_NOT_SEEKABLE = 801;
|
||||
public static final int MEDIA_INFO_STARTED_AS_NEXT = 2;
|
||||
public static final int MEDIA_INFO_SUBTITLE_TIMED_OUT = 902;
|
||||
public static final int MEDIA_INFO_TIMED_TEXT_ERROR = 900;
|
||||
public static final int MEDIA_INFO_UNKNOWN = 1;
|
||||
public static final int MEDIA_INFO_UNSUPPORTED_SUBTITLE = 901;
|
||||
public static final int MEDIA_INFO_VIDEO_RENDERING_START = 3;
|
||||
public static final int MEDIA_INFO_VIDEO_ROTATION_CHANGED = 10001;
|
||||
public static final int MEDIA_INFO_VIDEO_TRACK_LAGGING = 700;
|
||||
|
||||
public interface OnBufferingUpdateListener {
|
||||
void onBufferingUpdate(IMediaPlayer iMediaPlayer, int i);
|
||||
}
|
||||
|
||||
public interface OnCompletionListener {
|
||||
void onCompletion(IMediaPlayer iMediaPlayer);
|
||||
}
|
||||
|
||||
public interface OnErrorListener {
|
||||
boolean onError(IMediaPlayer iMediaPlayer, int i, int i2);
|
||||
}
|
||||
|
||||
public interface OnInfoListener {
|
||||
boolean onInfo(IMediaPlayer iMediaPlayer, int i, int i2);
|
||||
}
|
||||
|
||||
public interface OnMetadataListener {
|
||||
void onMetadata(IMediaPlayer iMediaPlayer, Bundle bundle);
|
||||
}
|
||||
|
||||
public interface OnPreparedListener {
|
||||
void onPrepared(IMediaPlayer iMediaPlayer);
|
||||
}
|
||||
|
||||
public interface OnSeekCompleteListener {
|
||||
void onSeekComplete(IMediaPlayer iMediaPlayer);
|
||||
}
|
||||
|
||||
public interface OnTimedTextListener {
|
||||
void onTimedText(IMediaPlayer iMediaPlayer, BDTimedText bDTimedText);
|
||||
}
|
||||
|
||||
public interface OnVideoSizeChangedListener {
|
||||
void onVideoSizeChanged(IMediaPlayer iMediaPlayer, int i, int i2, int i3, int i4);
|
||||
}
|
||||
|
||||
int getAudioSessionId();
|
||||
|
||||
long getCurrentPosition();
|
||||
|
||||
String getDataSource();
|
||||
|
||||
long getDuration();
|
||||
|
||||
c getMediaInfo();
|
||||
|
||||
ITrackInfo[] getTrackInfo();
|
||||
|
||||
int getVideoHeight();
|
||||
|
||||
int getVideoSarDen();
|
||||
|
||||
int getVideoSarNum();
|
||||
|
||||
int getVideoWidth();
|
||||
|
||||
boolean isLooping();
|
||||
|
||||
boolean isPlayable();
|
||||
|
||||
boolean isPlaying();
|
||||
|
||||
void pause() throws IllegalStateException;
|
||||
|
||||
void prepareAsync() throws IllegalStateException;
|
||||
|
||||
void release();
|
||||
|
||||
void reset();
|
||||
|
||||
void seekTo(long j) throws IllegalStateException;
|
||||
|
||||
void setAudioStreamType(int i);
|
||||
|
||||
void setDataSource(Context context, Uri uri) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;
|
||||
|
||||
void setDataSource(Context context, Uri uri, Map<String, String> map) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;
|
||||
|
||||
void setDataSource(IMediaDataSource iMediaDataSource);
|
||||
|
||||
void setDataSource(FileDescriptor fileDescriptor) throws IOException, IllegalArgumentException, IllegalStateException;
|
||||
|
||||
void setDataSource(String str) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;
|
||||
|
||||
void setDisplay(SurfaceHolder surfaceHolder);
|
||||
|
||||
void setKeepInBackground(boolean z);
|
||||
|
||||
void setLogEnabled(boolean z);
|
||||
|
||||
void setLooping(boolean z);
|
||||
|
||||
void setOnBufferingUpdateListener(OnBufferingUpdateListener onBufferingUpdateListener);
|
||||
|
||||
void setOnCompletionListener(OnCompletionListener onCompletionListener);
|
||||
|
||||
void setOnErrorListener(OnErrorListener onErrorListener);
|
||||
|
||||
void setOnInfoListener(OnInfoListener onInfoListener);
|
||||
|
||||
void setOnMetadataListener(OnMetadataListener onMetadataListener);
|
||||
|
||||
void setOnPreparedListener(OnPreparedListener onPreparedListener);
|
||||
|
||||
void setOnSeekCompleteListener(OnSeekCompleteListener onSeekCompleteListener);
|
||||
|
||||
void setOnTimedTextListener(OnTimedTextListener onTimedTextListener);
|
||||
|
||||
void setOnVideoSizeChangedListener(OnVideoSizeChangedListener onVideoSizeChangedListener);
|
||||
|
||||
void setScreenOnWhilePlaying(boolean z);
|
||||
|
||||
void setSurface(Surface surface);
|
||||
|
||||
void setVolume(float f, float f2);
|
||||
|
||||
void setWakeMode(Context context, int i);
|
||||
|
||||
void start() throws IllegalStateException;
|
||||
|
||||
void stop() throws IllegalStateException;
|
||||
}
|
193
sources/com/baidu/cloud/media/player/a.java
Normal file
193
sources/com/baidu/cloud/media/player/a.java
Normal file
@@ -0,0 +1,193 @@
|
||||
package com.baidu.cloud.media.player;
|
||||
|
||||
import android.media.MediaCodecInfo;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import com.ijm.dataencryption.de.DataDecryptTool;
|
||||
import com.ubt.jimu.base.util.FileUtil;
|
||||
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
||||
import com.ubtrobot.jimu.robotapi.PeripheralType;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class a {
|
||||
private static Map<String, Integer> d;
|
||||
public MediaCodecInfo a;
|
||||
public int b = 0;
|
||||
public String c;
|
||||
|
||||
public static a a(MediaCodecInfo mediaCodecInfo, String str) {
|
||||
if (mediaCodecInfo == null || Build.VERSION.SDK_INT < 16) {
|
||||
return null;
|
||||
}
|
||||
String name = mediaCodecInfo.getName();
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
return null;
|
||||
}
|
||||
String lowerCase = name.toLowerCase(Locale.US);
|
||||
int i = 600;
|
||||
if (!lowerCase.startsWith("omx.")) {
|
||||
i = 100;
|
||||
} else if (lowerCase.startsWith("omx.pv") || lowerCase.startsWith("omx.google.") || lowerCase.startsWith("omx.ffmpeg.") || lowerCase.startsWith("omx.k3.ffmpeg.") || lowerCase.startsWith("omx.avcodec.")) {
|
||||
i = 200;
|
||||
} else {
|
||||
if (!lowerCase.startsWith("omx.ittiam.")) {
|
||||
if (!lowerCase.startsWith("omx.mtk.")) {
|
||||
Integer num = a().get(lowerCase);
|
||||
if (num != null) {
|
||||
i = num.intValue();
|
||||
} else {
|
||||
try {
|
||||
if (mediaCodecInfo.getCapabilitiesForType(str) != null) {
|
||||
i = IMediaPlayer.MEDIA_INFO_VIDEO_TRACK_LAGGING;
|
||||
}
|
||||
} catch (Throwable unused) {
|
||||
}
|
||||
}
|
||||
} else if (Build.VERSION.SDK_INT >= 18 && !lowerCase.endsWith("decoder.mpeg4")) {
|
||||
i = 800;
|
||||
}
|
||||
}
|
||||
i = 0;
|
||||
}
|
||||
a aVar = new a();
|
||||
aVar.a = mediaCodecInfo;
|
||||
aVar.b = i;
|
||||
aVar.c = str;
|
||||
return aVar;
|
||||
}
|
||||
|
||||
public static String a(int i) {
|
||||
return i != 1 ? i != 2 ? i != 4 ? i != 8 ? i != 16 ? i != 32 ? i != 64 ? "Unknown" : "High444" : "High422" : "High10" : "High" : "Extends" : "Main" : "Baseline";
|
||||
}
|
||||
|
||||
public static String a(int i, int i2) {
|
||||
return String.format(Locale.US, " %s Profile Level %s (%d,%d)", a(i), b(i2), Integer.valueOf(i), Integer.valueOf(i2));
|
||||
}
|
||||
|
||||
private static synchronized Map<String, Integer> a() {
|
||||
synchronized (a.class) {
|
||||
if (d != null) {
|
||||
return d;
|
||||
}
|
||||
d = new TreeMap(String.CASE_INSENSITIVE_ORDER);
|
||||
d.put("OMX.Nvidia.h264.decode", 800);
|
||||
d.put("OMX.Nvidia.h264.decode.secure", 300);
|
||||
d.put("OMX.Intel.hw_vd.h264", Integer.valueOf(IMediaPlayer.MEDIA_INFO_NOT_SEEKABLE));
|
||||
d.put("OMX.Intel.VideoDecoder.AVC", 800);
|
||||
d.put("OMX.qcom.video.decoder.avc", 800);
|
||||
d.put("OMX.ittiam.video.decoder.avc", 0);
|
||||
d.put("OMX.SEC.avc.dec", 800);
|
||||
d.put("OMX.SEC.AVC.Decoder", 799);
|
||||
d.put("OMX.SEC.avcdec", 798);
|
||||
d.put("OMX.SEC.avc.sw.dec", 200);
|
||||
d.put("OMX.Exynos.avc.dec", 800);
|
||||
d.put("OMX.Exynos.AVC.Decoder", 799);
|
||||
d.put("OMX.k3.video.decoder.avc", 800);
|
||||
d.put("OMX.IMG.MSVDX.Decoder.AVC", 800);
|
||||
d.put("OMX.TI.DUCATI1.VIDEO.DECODER", 800);
|
||||
d.put("OMX.rk.video_decoder.avc", 800);
|
||||
d.put("OMX.amlogic.avc.decoder.awesome", 800);
|
||||
d.put("OMX.MARVELL.VIDEO.HW.CODA7542DECODER", 800);
|
||||
d.put("OMX.MARVELL.VIDEO.H264DECODER", 200);
|
||||
d.remove("OMX.Action.Video.Decoder");
|
||||
d.remove("OMX.allwinner.video.decoder.avc");
|
||||
d.remove("OMX.BRCM.vc4.decoder.avc");
|
||||
d.remove("OMX.brcm.video.h264.hw.decoder");
|
||||
d.remove("OMX.brcm.video.h264.decoder");
|
||||
d.remove("OMX.cosmo.video.decoder.avc");
|
||||
d.remove("OMX.duos.h264.decoder");
|
||||
d.remove("OMX.hantro.81x0.video.decoder");
|
||||
d.remove("OMX.hantro.G1.video.decoder");
|
||||
d.remove("OMX.hisi.video.decoder");
|
||||
d.remove("OMX.LG.decoder.video.avc");
|
||||
d.remove("OMX.MS.AVC.Decoder");
|
||||
d.remove("OMX.RENESAS.VIDEO.DECODER.H264");
|
||||
d.remove("OMX.RTK.video.decoder");
|
||||
d.remove("OMX.sprd.h264.decoder");
|
||||
d.remove("OMX.ST.VFM.H264Dec");
|
||||
d.remove("OMX.vpu.video_decoder.avc");
|
||||
d.remove("OMX.WMT.decoder.avc");
|
||||
d.remove("OMX.bluestacks.hw.decoder");
|
||||
d.put("OMX.google.h264.decoder", 200);
|
||||
d.put("OMX.google.h264.lc.decoder", 200);
|
||||
d.put("OMX.k3.ffmpeg.decoder", 200);
|
||||
d.put("OMX.ffmpeg.video.decoder", 200);
|
||||
d.put("OMX.sprd.soft.h264.decoder", 200);
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
public static String b(int i) {
|
||||
if (i == 1) {
|
||||
return "1";
|
||||
}
|
||||
if (i == 2) {
|
||||
return "1b";
|
||||
}
|
||||
switch (i) {
|
||||
case 4:
|
||||
return "11";
|
||||
case 8:
|
||||
return "12";
|
||||
case 16:
|
||||
return "13";
|
||||
case 32:
|
||||
return "2";
|
||||
case 64:
|
||||
return "21";
|
||||
case PeripheralType.SERVO /* 128 */:
|
||||
return "22";
|
||||
case DataDecryptTool.DECRYPT_ALL_FILE /* 256 */:
|
||||
return "3";
|
||||
case DataDecryptTool.DECRYPT_DB_FILE /* 512 */:
|
||||
return "31";
|
||||
case DataDecryptTool.DECRYPT_SP_FILE /* 1024 */:
|
||||
return "32";
|
||||
case 2048:
|
||||
return "4";
|
||||
case FileUtil.ZIP_BUFFER_SIZE /* 4096 */:
|
||||
return "41";
|
||||
case UnityActivity.BLOCKLY_TYPE_NONE /* 8192 */:
|
||||
return "42";
|
||||
case 16384:
|
||||
return "5";
|
||||
case 32768:
|
||||
return "51";
|
||||
case 65536:
|
||||
return "52";
|
||||
default:
|
||||
return "0";
|
||||
}
|
||||
}
|
||||
|
||||
public void a(String str) {
|
||||
int i;
|
||||
int i2;
|
||||
if (Build.VERSION.SDK_INT < 16) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
MediaCodecInfo.CodecCapabilities capabilitiesForType = this.a.getCapabilitiesForType(str);
|
||||
if (capabilitiesForType == null || capabilitiesForType.profileLevels == null) {
|
||||
i = 0;
|
||||
i2 = 0;
|
||||
} else {
|
||||
i = 0;
|
||||
i2 = 0;
|
||||
for (MediaCodecInfo.CodecProfileLevel codecProfileLevel : capabilitiesForType.profileLevels) {
|
||||
if (codecProfileLevel != null) {
|
||||
i = Math.max(i, codecProfileLevel.profile);
|
||||
i2 = Math.max(i2, codecProfileLevel.level);
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.i("BDCloudMediaCodecInfo", String.format(Locale.US, "%s", a(i, i2)));
|
||||
} catch (Throwable unused) {
|
||||
Log.i("BDCloudMediaCodecInfo", "profile-level: exception");
|
||||
}
|
||||
}
|
||||
}
|
89
sources/com/baidu/cloud/media/player/a/a.java
Normal file
89
sources/com/baidu/cloud/media/player/a/a.java
Normal file
@@ -0,0 +1,89 @@
|
||||
package com.baidu.cloud.media.player.a;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import com.baidu.cloud.media.player.BDCloudMediaPlayer;
|
||||
import java.util.Random;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class a {
|
||||
private String a;
|
||||
private String b;
|
||||
private String c = "";
|
||||
private String d = BDCloudMediaPlayer.SDK_VERSION;
|
||||
private String e = "sw";
|
||||
private String f = "";
|
||||
private e g;
|
||||
private f h;
|
||||
private c i;
|
||||
private JSONObject j;
|
||||
|
||||
public a(Context context, String str) {
|
||||
this.g = new e(context, str);
|
||||
this.h = new f(context);
|
||||
this.i = new c(context);
|
||||
}
|
||||
|
||||
private String a(int i) {
|
||||
Random random = new Random();
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
for (int i2 = 0; i2 < i; i2++) {
|
||||
stringBuffer.append("abcdefghijklmnopqrstuvwxyz".charAt(random.nextInt(26)));
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
private String c() {
|
||||
return ("" + System.currentTimeMillis()) + a(8);
|
||||
}
|
||||
|
||||
public JSONObject a() {
|
||||
if (this.j == null) {
|
||||
this.j = new JSONObject();
|
||||
try {
|
||||
this.j.put("url", this.a);
|
||||
this.j.put("vvid", this.b);
|
||||
this.j.put("isLive", true);
|
||||
this.j.put("playerVersion", this.d);
|
||||
this.j.put("decodeMode", this.e);
|
||||
this.j.put("ak", this.f);
|
||||
this.j.put("bitrate", 0);
|
||||
} catch (Exception e) {
|
||||
Log.d("BaseInfo", "" + e.getMessage());
|
||||
}
|
||||
}
|
||||
try {
|
||||
this.j.put("playID", this.c);
|
||||
} catch (JSONException e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
return this.j;
|
||||
}
|
||||
|
||||
public void a(String str) {
|
||||
if (str == null || str.equals("")) {
|
||||
return;
|
||||
}
|
||||
this.a = str;
|
||||
this.b = c();
|
||||
Log.i("BaseInfo", "Current vvid is:" + this.b);
|
||||
this.j = null;
|
||||
}
|
||||
|
||||
public void a(String str, String str2, String str3) {
|
||||
this.d = str;
|
||||
this.e = str2;
|
||||
this.f = str3;
|
||||
this.j = null;
|
||||
}
|
||||
|
||||
public String b() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public void b(String str) {
|
||||
this.c = str;
|
||||
}
|
||||
}
|
398
sources/com/baidu/cloud/media/player/a/b.java
Normal file
398
sources/com/baidu/cloud/media/player/a/b.java
Normal file
@@ -0,0 +1,398 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
31
sources/com/baidu/cloud/media/player/a/c.java
Normal file
31
sources/com/baidu/cloud/media/player/a/c.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.baidu.cloud.media.player.a;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.util.Log;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class c {
|
||||
private String a;
|
||||
private String b;
|
||||
private String c;
|
||||
private String d;
|
||||
|
||||
public c(Context context) {
|
||||
a(context);
|
||||
}
|
||||
|
||||
private void a(Context context) {
|
||||
try {
|
||||
this.b = context.getPackageName();
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
PackageInfo packageInfo = packageManager.getPackageInfo(this.b, 0);
|
||||
this.d = packageInfo.versionName;
|
||||
this.c = "" + packageInfo.versionCode;
|
||||
this.a = (String) packageManager.getApplicationLabel(packageInfo.applicationInfo);
|
||||
} catch (Exception e) {
|
||||
Log.d("BaseInfo", "" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
51
sources/com/baidu/cloud/media/player/a/d.java
Normal file
51
sources/com/baidu/cloud/media/player/a/d.java
Normal file
@@ -0,0 +1,51 @@
|
||||
package com.baidu.cloud.media.player.a;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.Thread;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class d implements Thread.UncaughtExceptionHandler {
|
||||
private static d a = new d();
|
||||
private Thread.UncaughtExceptionHandler b = null;
|
||||
private Context c = null;
|
||||
|
||||
private d() {
|
||||
}
|
||||
|
||||
public static d a() {
|
||||
return a;
|
||||
}
|
||||
|
||||
public void a(Context context) {
|
||||
if (this.b == null) {
|
||||
this.b = Thread.getDefaultUncaughtExceptionHandler();
|
||||
Thread.setDefaultUncaughtExceptionHandler(this);
|
||||
}
|
||||
if (this.c == null) {
|
||||
this.c = context.getApplicationContext();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.lang.Thread.UncaughtExceptionHandler
|
||||
public void uncaughtException(Thread thread, Throwable th) {
|
||||
try {
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
PrintWriter printWriter = new PrintWriter(stringWriter);
|
||||
th.printStackTrace(printWriter);
|
||||
printWriter.close();
|
||||
String obj = stringWriter.toString();
|
||||
if (obj.contains("com.baidu.cloud.media")) {
|
||||
b.a(this.c).e(obj);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.d("SDKCrashHandler", "" + e.getMessage());
|
||||
}
|
||||
if (this.b.equals(this)) {
|
||||
return;
|
||||
}
|
||||
this.b.uncaughtException(thread, th);
|
||||
}
|
||||
}
|
65
sources/com/baidu/cloud/media/player/a/e.java
Normal file
65
sources/com/baidu/cloud/media/player/a/e.java
Normal file
@@ -0,0 +1,65 @@
|
||||
package com.baidu.cloud.media.player.a;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
import java.util.Locale;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class e {
|
||||
private String b;
|
||||
private int c;
|
||||
private String d;
|
||||
private String e;
|
||||
private String f;
|
||||
private int g;
|
||||
private int h;
|
||||
private String i;
|
||||
private String j;
|
||||
private String k;
|
||||
private String l;
|
||||
private String a = "android";
|
||||
private String m = "";
|
||||
|
||||
public e(Context context, String str) {
|
||||
a(context, str);
|
||||
}
|
||||
|
||||
private void a(Context context, String str) {
|
||||
int i;
|
||||
try {
|
||||
this.b = Build.VERSION.RELEASE;
|
||||
this.c = Build.VERSION.SDK_INT;
|
||||
this.d = Build.MODEL;
|
||||
this.e = Build.BRAND;
|
||||
this.f = Build.CPU_ABI;
|
||||
this.i = Locale.getDefault().getLanguage();
|
||||
this.l = Settings.Secure.getString(context.getContentResolver(), "android_id");
|
||||
this.j = this.l;
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
if (Build.VERSION.SDK_INT >= 17) {
|
||||
((WindowManager) context.getSystemService("window")).getDefaultDisplay().getRealMetrics(displayMetrics);
|
||||
} else {
|
||||
((WindowManager) context.getSystemService("window")).getDefaultDisplay().getMetrics(displayMetrics);
|
||||
}
|
||||
if (displayMetrics.widthPixels > displayMetrics.heightPixels) {
|
||||
this.g = displayMetrics.heightPixels;
|
||||
i = displayMetrics.widthPixels;
|
||||
} else {
|
||||
this.g = displayMetrics.widthPixels;
|
||||
i = displayMetrics.heightPixels;
|
||||
}
|
||||
this.h = i;
|
||||
if (context.checkCallingOrSelfPermission("android.permission.READ_PHONE_STATE") != -1) {
|
||||
this.k = ((TelephonyManager) context.getSystemService("phone")).getDeviceId();
|
||||
}
|
||||
this.m = str;
|
||||
} catch (Exception e) {
|
||||
Log.d("BaseInfo", "" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
75
sources/com/baidu/cloud/media/player/a/f.java
Normal file
75
sources/com/baidu/cloud/media/player/a/f.java
Normal file
@@ -0,0 +1,75 @@
|
||||
package com.baidu.cloud.media.player.a;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class f {
|
||||
private String a;
|
||||
private String b;
|
||||
private String c;
|
||||
|
||||
public f(Context context) {
|
||||
b(context);
|
||||
}
|
||||
|
||||
private void b(Context context) {
|
||||
try {
|
||||
this.c = a(context);
|
||||
this.a = ((TelephonyManager) context.getSystemService("phone")).getNetworkOperator();
|
||||
this.b = ((TelephonyManager) context.getSystemService("phone")).getNetworkOperatorName();
|
||||
} catch (Exception e) {
|
||||
Log.d("BaseInfo", "" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public String a(Context context) {
|
||||
NetworkInfo activeNetworkInfo;
|
||||
NetworkInfo.State state;
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
|
||||
if (connectivityManager == null || (activeNetworkInfo = connectivityManager.getActiveNetworkInfo()) == null || !activeNetworkInfo.isAvailable()) {
|
||||
return "NONE";
|
||||
}
|
||||
NetworkInfo networkInfo = connectivityManager.getNetworkInfo(1);
|
||||
if (networkInfo != null && (state = networkInfo.getState()) != null && (state == NetworkInfo.State.CONNECTED || state == NetworkInfo.State.CONNECTING)) {
|
||||
return "WIFI";
|
||||
}
|
||||
NetworkInfo networkInfo2 = connectivityManager.getNetworkInfo(0);
|
||||
if (networkInfo2 == null) {
|
||||
return "";
|
||||
}
|
||||
NetworkInfo.State state2 = networkInfo2.getState();
|
||||
networkInfo2.getSubtypeName();
|
||||
if (state2 == null) {
|
||||
return "";
|
||||
}
|
||||
if (state2 != NetworkInfo.State.CONNECTED && state2 != NetworkInfo.State.CONNECTING) {
|
||||
return "";
|
||||
}
|
||||
switch (activeNetworkInfo.getSubtype()) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
case 7:
|
||||
case 11:
|
||||
return "2G";
|
||||
case 3:
|
||||
case 5:
|
||||
case 6:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 12:
|
||||
case 14:
|
||||
case 15:
|
||||
return "3G";
|
||||
case 13:
|
||||
return "4G";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
package com.baidu.cloud.media.player.annotations;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public @interface AccessedByNative {
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package com.baidu.cloud.media.player.annotations;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public @interface CalledByNative {
|
||||
String value();
|
||||
}
|
193
sources/com/baidu/cloud/media/player/b.java
Normal file
193
sources/com/baidu/cloud/media/player/b.java
Normal file
@@ -0,0 +1,193 @@
|
||||
package com.baidu.cloud.media.player;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import com.baidu.cloud.media.player.misc.IMediaFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class b {
|
||||
public Bundle a;
|
||||
public String b;
|
||||
public long c;
|
||||
public long d;
|
||||
public long e;
|
||||
public final ArrayList<a> f = new ArrayList<>();
|
||||
public a g;
|
||||
public a h;
|
||||
|
||||
public static class a {
|
||||
public Bundle a;
|
||||
public final int b;
|
||||
public String c;
|
||||
public String d;
|
||||
public String e;
|
||||
public String f;
|
||||
public String g;
|
||||
public long h;
|
||||
public int i;
|
||||
public int j;
|
||||
public int k;
|
||||
public int l;
|
||||
public int m;
|
||||
public int n;
|
||||
public int o;
|
||||
public int p;
|
||||
public int q;
|
||||
public long r;
|
||||
|
||||
public a(int i) {
|
||||
this.b = i;
|
||||
}
|
||||
|
||||
public int a(String str, int i) {
|
||||
String a = a(str);
|
||||
if (TextUtils.isEmpty(a)) {
|
||||
return i;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(a);
|
||||
} catch (NumberFormatException unused) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
public long a(String str, long j) {
|
||||
String a = a(str);
|
||||
if (TextUtils.isEmpty(a)) {
|
||||
return j;
|
||||
}
|
||||
try {
|
||||
return Long.parseLong(a);
|
||||
} catch (NumberFormatException unused) {
|
||||
return j;
|
||||
}
|
||||
}
|
||||
|
||||
public String a() {
|
||||
return !TextUtils.isEmpty(this.e) ? this.e : "N/A";
|
||||
}
|
||||
|
||||
public String a(String str) {
|
||||
return this.a.getString(str);
|
||||
}
|
||||
|
||||
public int b(String str) {
|
||||
return a(str, 0);
|
||||
}
|
||||
|
||||
public String b() {
|
||||
int i = this.i;
|
||||
return (i <= 0 || this.j <= 0) ? "N/A" : (this.o <= 0 || this.p <= 0) ? String.format(Locale.US, "%d x %d", Integer.valueOf(this.i), Integer.valueOf(this.j)) : String.format(Locale.US, "%d x %d [SAR %d:%d]", Integer.valueOf(i), Integer.valueOf(this.j), Integer.valueOf(this.o), Integer.valueOf(this.p));
|
||||
}
|
||||
|
||||
public long c(String str) {
|
||||
return a(str, 0L);
|
||||
}
|
||||
|
||||
public String c() {
|
||||
long j = this.h;
|
||||
return j <= 0 ? "N/A" : j < 1000 ? String.format(Locale.US, "%d bit/s", Long.valueOf(j)) : String.format(Locale.US, "%d kb/s", Long.valueOf(j / 1000));
|
||||
}
|
||||
|
||||
public String d() {
|
||||
int i = this.q;
|
||||
return i <= 0 ? "N/A" : String.format(Locale.US, "%d Hz", Integer.valueOf(i));
|
||||
}
|
||||
}
|
||||
|
||||
public static b a(Bundle bundle) {
|
||||
if (bundle == null) {
|
||||
return null;
|
||||
}
|
||||
b bVar = new b();
|
||||
bVar.a = bundle;
|
||||
bVar.b = bVar.a("format");
|
||||
bVar.c = bVar.b("duration_us");
|
||||
bVar.d = bVar.b("start_us");
|
||||
bVar.e = bVar.b("bitrate");
|
||||
int i = -1;
|
||||
int a2 = bVar.a("video", -1);
|
||||
int a3 = bVar.a("audio", -1);
|
||||
ArrayList<Bundle> c = bVar.c("streams");
|
||||
if (c == null) {
|
||||
return bVar;
|
||||
}
|
||||
Iterator<Bundle> it = c.iterator();
|
||||
while (it.hasNext()) {
|
||||
Bundle next = it.next();
|
||||
i++;
|
||||
if (next != null) {
|
||||
a aVar = new a(i);
|
||||
aVar.a = next;
|
||||
aVar.c = aVar.a("type");
|
||||
aVar.d = aVar.a("language");
|
||||
if (!TextUtils.isEmpty(aVar.c)) {
|
||||
aVar.e = aVar.a("codec_name");
|
||||
aVar.f = aVar.a("codec_profile");
|
||||
aVar.g = aVar.a("codec_long_name");
|
||||
aVar.h = aVar.b("bitrate");
|
||||
if (aVar.c.equalsIgnoreCase("video")) {
|
||||
aVar.i = aVar.b(IMediaFormat.KEY_WIDTH);
|
||||
aVar.j = aVar.b(IMediaFormat.KEY_HEIGHT);
|
||||
aVar.k = aVar.b("fps_num");
|
||||
aVar.l = aVar.b("fps_den");
|
||||
aVar.m = aVar.b("tbr_num");
|
||||
aVar.n = aVar.b("tbr_den");
|
||||
aVar.o = aVar.b("sar_num");
|
||||
aVar.p = aVar.b("sar_den");
|
||||
if (a2 == i) {
|
||||
bVar.g = aVar;
|
||||
}
|
||||
} else if (aVar.c.equalsIgnoreCase("audio")) {
|
||||
aVar.q = aVar.b("sample_rate");
|
||||
aVar.r = aVar.c("channel_layout");
|
||||
if (a3 == i) {
|
||||
bVar.h = aVar;
|
||||
}
|
||||
}
|
||||
bVar.f.add(aVar);
|
||||
}
|
||||
}
|
||||
}
|
||||
return bVar;
|
||||
}
|
||||
|
||||
public int a(String str, int i) {
|
||||
String a2 = a(str);
|
||||
if (TextUtils.isEmpty(a2)) {
|
||||
return i;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(a2);
|
||||
} catch (NumberFormatException unused) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
public long a(String str, long j) {
|
||||
String a2 = a(str);
|
||||
if (TextUtils.isEmpty(a2)) {
|
||||
return j;
|
||||
}
|
||||
try {
|
||||
return Long.parseLong(a2);
|
||||
} catch (NumberFormatException unused) {
|
||||
return j;
|
||||
}
|
||||
}
|
||||
|
||||
public String a(String str) {
|
||||
return this.a.getString(str);
|
||||
}
|
||||
|
||||
public long b(String str) {
|
||||
return a(str, 0L);
|
||||
}
|
||||
|
||||
public ArrayList<Bundle> c(String str) {
|
||||
return this.a.getParcelableArrayList(str);
|
||||
}
|
||||
}
|
57
sources/com/baidu/cloud/media/player/b/a.java
Normal file
57
sources/com/baidu/cloud/media/player/b/a.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package com.baidu.cloud.media.player.b;
|
||||
|
||||
import android.util.Log;
|
||||
import java.util.Locale;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class a {
|
||||
public static boolean a = true;
|
||||
public static boolean b = false;
|
||||
public static boolean c = true;
|
||||
public static boolean d = false;
|
||||
public static boolean e = false;
|
||||
|
||||
public static void a(String str, String str2) {
|
||||
if (a) {
|
||||
Log.e(str, str2);
|
||||
}
|
||||
}
|
||||
|
||||
public static void a(String str, String str2, Object... objArr) {
|
||||
if (b) {
|
||||
Log.i(str, String.format(Locale.US, str2, objArr));
|
||||
}
|
||||
}
|
||||
|
||||
public static void a(boolean z) {
|
||||
a = true;
|
||||
c = true;
|
||||
if (z) {
|
||||
b = true;
|
||||
d = true;
|
||||
e = true;
|
||||
} else {
|
||||
b = false;
|
||||
d = false;
|
||||
e = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void b(String str, String str2) {
|
||||
if (b) {
|
||||
Log.i(str, str2);
|
||||
}
|
||||
}
|
||||
|
||||
public static void c(String str, String str2) {
|
||||
if (c) {
|
||||
Log.w(str, str2);
|
||||
}
|
||||
}
|
||||
|
||||
public static void d(String str, String str2) {
|
||||
if (d) {
|
||||
Log.d(str, str2);
|
||||
}
|
||||
}
|
||||
}
|
11
sources/com/baidu/cloud/media/player/c.java
Normal file
11
sources/com/baidu/cloud/media/player/c.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.baidu.cloud.media.player;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class c {
|
||||
public String a;
|
||||
public String b;
|
||||
public String c;
|
||||
public String d;
|
||||
public String e;
|
||||
public b f;
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package com.baidu.cloud.media.player.ffmpeg;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FFmpegApi {
|
||||
public static native String av_base64_encode(byte[] bArr);
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
package com.baidu.cloud.media.player.misc;
|
||||
|
||||
import android.media.MediaFormat;
|
||||
import com.ubtrobot.jimu.robotapi.PeripheralType;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AndroidMediaFormat implements IMediaFormat {
|
||||
private final MediaFormat a;
|
||||
|
||||
public AndroidMediaFormat(MediaFormat mediaFormat) {
|
||||
this.a = mediaFormat;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.misc.IMediaFormat
|
||||
public int getInteger(String str) {
|
||||
MediaFormat mediaFormat = this.a;
|
||||
if (mediaFormat == null) {
|
||||
return 0;
|
||||
}
|
||||
return mediaFormat.getInteger(str);
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.misc.IMediaFormat
|
||||
public String getString(String str) {
|
||||
MediaFormat mediaFormat = this.a;
|
||||
if (mediaFormat == null) {
|
||||
return null;
|
||||
}
|
||||
return mediaFormat.getString(str);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder(PeripheralType.SERVO);
|
||||
sb.append(AndroidMediaFormat.class.getName());
|
||||
sb.append('{');
|
||||
MediaFormat mediaFormat = this.a;
|
||||
sb.append(mediaFormat != null ? mediaFormat.toString() : "null");
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@@ -0,0 +1,199 @@
|
||||
package com.baidu.cloud.media.player.misc;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.baidu.cloud.media.player.b;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BDCloudMediaFormat implements IMediaFormat {
|
||||
public static final String CODEC_NAME_H264 = "h264";
|
||||
public static final String KEY_IJK_BIT_RATE_UI = "ijk-bit-rate-ui";
|
||||
public static final String KEY_IJK_CHANNEL_UI = "ijk-channel-ui";
|
||||
public static final String KEY_IJK_CODEC_LONG_NAME_UI = "ijk-codec-long-name-ui";
|
||||
public static final String KEY_IJK_CODEC_NAME_UI = "ijk-codec-name-ui";
|
||||
public static final String KEY_IJK_CODEC_PIXEL_FORMAT_UI = "ijk-pixel-format-ui";
|
||||
public static final String KEY_IJK_CODEC_PROFILE_LEVEL_UI = "ijk-profile-level-ui";
|
||||
public static final String KEY_IJK_FRAME_RATE_UI = "ijk-frame-rate-ui";
|
||||
public static final String KEY_IJK_RESOLUTION_UI = "ijk-resolution-ui";
|
||||
public static final String KEY_IJK_SAMPLE_RATE_UI = "ijk-sample-rate-ui";
|
||||
private static final Map<String, a> b = new HashMap();
|
||||
public final b.a a;
|
||||
|
||||
private static abstract class a {
|
||||
private a() {
|
||||
}
|
||||
|
||||
protected String a() {
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
protected abstract String a(BDCloudMediaFormat bDCloudMediaFormat);
|
||||
|
||||
public String b(BDCloudMediaFormat bDCloudMediaFormat) {
|
||||
String a = a(bDCloudMediaFormat);
|
||||
return TextUtils.isEmpty(a) ? a() : a;
|
||||
}
|
||||
}
|
||||
|
||||
public BDCloudMediaFormat(b.a aVar) {
|
||||
b.put(KEY_IJK_CODEC_LONG_NAME_UI, new a() { // from class: com.baidu.cloud.media.player.misc.BDCloudMediaFormat.1
|
||||
@Override // com.baidu.cloud.media.player.misc.BDCloudMediaFormat.a
|
||||
public String a(BDCloudMediaFormat bDCloudMediaFormat) {
|
||||
return BDCloudMediaFormat.this.a.a("codec_long_name");
|
||||
}
|
||||
});
|
||||
b.put(KEY_IJK_CODEC_NAME_UI, new a() { // from class: com.baidu.cloud.media.player.misc.BDCloudMediaFormat.2
|
||||
@Override // com.baidu.cloud.media.player.misc.BDCloudMediaFormat.a
|
||||
public String a(BDCloudMediaFormat bDCloudMediaFormat) {
|
||||
return BDCloudMediaFormat.this.a.a("codec_name");
|
||||
}
|
||||
});
|
||||
b.put(KEY_IJK_BIT_RATE_UI, new a() { // from class: com.baidu.cloud.media.player.misc.BDCloudMediaFormat.3
|
||||
@Override // com.baidu.cloud.media.player.misc.BDCloudMediaFormat.a
|
||||
protected String a(BDCloudMediaFormat bDCloudMediaFormat) {
|
||||
int integer = bDCloudMediaFormat.getInteger("bitrate");
|
||||
if (integer <= 0) {
|
||||
return null;
|
||||
}
|
||||
return integer < 1000 ? String.format(Locale.US, "%d bit/s", Integer.valueOf(integer)) : String.format(Locale.US, "%d kb/s", Integer.valueOf(integer / 1000));
|
||||
}
|
||||
});
|
||||
b.put(KEY_IJK_CODEC_PROFILE_LEVEL_UI, new a() { // from class: com.baidu.cloud.media.player.misc.BDCloudMediaFormat.4
|
||||
@Override // com.baidu.cloud.media.player.misc.BDCloudMediaFormat.a
|
||||
protected String a(BDCloudMediaFormat bDCloudMediaFormat) {
|
||||
String str;
|
||||
switch (bDCloudMediaFormat.getInteger("codec_profile_id")) {
|
||||
case 44:
|
||||
str = "CAVLC 4:4:4";
|
||||
break;
|
||||
case 66:
|
||||
str = "Baseline";
|
||||
break;
|
||||
case 77:
|
||||
str = "Main";
|
||||
break;
|
||||
case 88:
|
||||
str = "Extended";
|
||||
break;
|
||||
case 100:
|
||||
str = "High";
|
||||
break;
|
||||
case 110:
|
||||
str = "High 10";
|
||||
break;
|
||||
case 122:
|
||||
str = "High 4:2:2";
|
||||
break;
|
||||
case 144:
|
||||
str = "High 4:4:4";
|
||||
break;
|
||||
case 244:
|
||||
str = "High 4:4:4 Predictive";
|
||||
break;
|
||||
case 578:
|
||||
str = "Constrained Baseline";
|
||||
break;
|
||||
case 2158:
|
||||
str = "High 10 Intra";
|
||||
break;
|
||||
case 2170:
|
||||
str = "High 4:2:2 Intra";
|
||||
break;
|
||||
case 2292:
|
||||
str = "High 4:4:4 Intra";
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(str);
|
||||
String string = bDCloudMediaFormat.getString("codec_name");
|
||||
if (!TextUtils.isEmpty(string) && string.equalsIgnoreCase(BDCloudMediaFormat.CODEC_NAME_H264)) {
|
||||
int integer = bDCloudMediaFormat.getInteger("codec_level");
|
||||
if (integer < 10) {
|
||||
return sb.toString();
|
||||
}
|
||||
sb.append(" Profile Level ");
|
||||
sb.append((integer / 10) % 10);
|
||||
int i = integer % 10;
|
||||
if (i != 0) {
|
||||
sb.append(".");
|
||||
sb.append(i);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
});
|
||||
b.put(KEY_IJK_CODEC_PIXEL_FORMAT_UI, new a() { // from class: com.baidu.cloud.media.player.misc.BDCloudMediaFormat.5
|
||||
@Override // com.baidu.cloud.media.player.misc.BDCloudMediaFormat.a
|
||||
protected String a(BDCloudMediaFormat bDCloudMediaFormat) {
|
||||
return bDCloudMediaFormat.getString("codec_pixel_format");
|
||||
}
|
||||
});
|
||||
b.put(KEY_IJK_RESOLUTION_UI, new a() { // from class: com.baidu.cloud.media.player.misc.BDCloudMediaFormat.6
|
||||
@Override // com.baidu.cloud.media.player.misc.BDCloudMediaFormat.a
|
||||
protected String a(BDCloudMediaFormat bDCloudMediaFormat) {
|
||||
int integer = bDCloudMediaFormat.getInteger(IMediaFormat.KEY_WIDTH);
|
||||
int integer2 = bDCloudMediaFormat.getInteger(IMediaFormat.KEY_HEIGHT);
|
||||
int integer3 = bDCloudMediaFormat.getInteger("sar_num");
|
||||
int integer4 = bDCloudMediaFormat.getInteger("sar_den");
|
||||
if (integer <= 0 || integer2 <= 0) {
|
||||
return null;
|
||||
}
|
||||
return (integer3 <= 0 || integer4 <= 0) ? String.format(Locale.US, "%d x %d", Integer.valueOf(integer), Integer.valueOf(integer2)) : String.format(Locale.US, "%d x %d [SAR %d:%d]", Integer.valueOf(integer), Integer.valueOf(integer2), Integer.valueOf(integer3), Integer.valueOf(integer4));
|
||||
}
|
||||
});
|
||||
b.put(KEY_IJK_FRAME_RATE_UI, new a() { // from class: com.baidu.cloud.media.player.misc.BDCloudMediaFormat.7
|
||||
@Override // com.baidu.cloud.media.player.misc.BDCloudMediaFormat.a
|
||||
protected String a(BDCloudMediaFormat bDCloudMediaFormat) {
|
||||
int integer = bDCloudMediaFormat.getInteger("fps_num");
|
||||
int integer2 = bDCloudMediaFormat.getInteger("fps_den");
|
||||
if (integer <= 0 || integer2 <= 0) {
|
||||
return null;
|
||||
}
|
||||
return String.valueOf(integer / integer2);
|
||||
}
|
||||
});
|
||||
b.put(KEY_IJK_SAMPLE_RATE_UI, new a() { // from class: com.baidu.cloud.media.player.misc.BDCloudMediaFormat.8
|
||||
@Override // com.baidu.cloud.media.player.misc.BDCloudMediaFormat.a
|
||||
protected String a(BDCloudMediaFormat bDCloudMediaFormat) {
|
||||
int integer = bDCloudMediaFormat.getInteger("sample_rate");
|
||||
if (integer <= 0) {
|
||||
return null;
|
||||
}
|
||||
return String.format(Locale.US, "%d Hz", Integer.valueOf(integer));
|
||||
}
|
||||
});
|
||||
b.put(KEY_IJK_CHANNEL_UI, new a() { // from class: com.baidu.cloud.media.player.misc.BDCloudMediaFormat.9
|
||||
@Override // com.baidu.cloud.media.player.misc.BDCloudMediaFormat.a
|
||||
protected String a(BDCloudMediaFormat bDCloudMediaFormat) {
|
||||
int integer = bDCloudMediaFormat.getInteger("channel_layout");
|
||||
if (integer <= 0) {
|
||||
return null;
|
||||
}
|
||||
long j = integer;
|
||||
return j == 4 ? "mono" : j == 3 ? "stereo" : String.format(Locale.US, "%x", Integer.valueOf(integer));
|
||||
}
|
||||
});
|
||||
this.a = aVar;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.misc.IMediaFormat
|
||||
public int getInteger(String str) {
|
||||
b.a aVar = this.a;
|
||||
if (aVar == null) {
|
||||
return 0;
|
||||
}
|
||||
return aVar.b(str);
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.misc.IMediaFormat
|
||||
public String getString(String str) {
|
||||
if (this.a == null) {
|
||||
return null;
|
||||
}
|
||||
return b.containsKey(str) ? b.get(str).b(this) : this.a.a(str);
|
||||
}
|
||||
}
|
14
sources/com/baidu/cloud/media/player/misc/IAndroidIO.java
Normal file
14
sources/com/baidu/cloud/media/player/misc/IAndroidIO.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.baidu.cloud.media.player.misc;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface IAndroidIO {
|
||||
int close() throws IOException;
|
||||
|
||||
int open(String str) throws IOException;
|
||||
|
||||
int read(byte[] bArr, int i) throws IOException;
|
||||
|
||||
long seek(long j, int i) throws IOException;
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package com.baidu.cloud.media.player.misc;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface IMediaDataSource {
|
||||
void close() throws IOException;
|
||||
|
||||
long getSize() throws IOException;
|
||||
|
||||
int readAt(long j, byte[] bArr, int i, int i2) throws IOException;
|
||||
}
|
12
sources/com/baidu/cloud/media/player/misc/IMediaFormat.java
Normal file
12
sources/com/baidu/cloud/media/player/misc/IMediaFormat.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.baidu.cloud.media.player.misc;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface IMediaFormat {
|
||||
public static final String KEY_HEIGHT = "height";
|
||||
public static final String KEY_MIME = "mime";
|
||||
public static final String KEY_WIDTH = "width";
|
||||
|
||||
int getInteger(String str);
|
||||
|
||||
String getString(String str);
|
||||
}
|
19
sources/com/baidu/cloud/media/player/misc/ITrackInfo.java
Normal file
19
sources/com/baidu/cloud/media/player/misc/ITrackInfo.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.baidu.cloud.media.player.misc;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface ITrackInfo {
|
||||
public static final int MEDIA_TRACK_TYPE_AUDIO = 2;
|
||||
public static final int MEDIA_TRACK_TYPE_METADATA = 5;
|
||||
public static final int MEDIA_TRACK_TYPE_SUBTITLE = 4;
|
||||
public static final int MEDIA_TRACK_TYPE_TIMEDTEXT = 3;
|
||||
public static final int MEDIA_TRACK_TYPE_UNKNOWN = 0;
|
||||
public static final int MEDIA_TRACK_TYPE_VIDEO = 1;
|
||||
|
||||
IMediaFormat getFormat();
|
||||
|
||||
String getInfoInline();
|
||||
|
||||
String getLanguage();
|
||||
|
||||
int getTrackType();
|
||||
}
|
67
sources/com/baidu/cloud/media/player/misc/a.java
Normal file
67
sources/com/baidu/cloud/media/player/misc/a.java
Normal file
@@ -0,0 +1,67 @@
|
||||
package com.baidu.cloud.media.player.misc;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.baidu.cloud.media.player.b;
|
||||
import com.ubtrobot.jimu.robotapi.PeripheralType;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class a implements ITrackInfo {
|
||||
private int a = 0;
|
||||
private b.a b;
|
||||
|
||||
public a(b.a aVar) {
|
||||
this.b = aVar;
|
||||
}
|
||||
|
||||
public void a(int i) {
|
||||
this.a = i;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.misc.ITrackInfo
|
||||
public IMediaFormat getFormat() {
|
||||
return new BDCloudMediaFormat(this.b);
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.misc.ITrackInfo
|
||||
public String getInfoInline() {
|
||||
String b;
|
||||
StringBuilder sb = new StringBuilder(PeripheralType.SERVO);
|
||||
int i = this.a;
|
||||
if (i == 1) {
|
||||
sb.append("VIDEO");
|
||||
sb.append(", ");
|
||||
sb.append(this.b.a());
|
||||
sb.append(", ");
|
||||
sb.append(this.b.c());
|
||||
sb.append(", ");
|
||||
b = this.b.b();
|
||||
} else if (i != 2) {
|
||||
b = i != 3 ? i != 4 ? "UNKNOWN" : "SUBTITLE" : "TIMEDTEXT";
|
||||
} else {
|
||||
sb.append("AUDIO");
|
||||
sb.append(", ");
|
||||
sb.append(this.b.a());
|
||||
sb.append(", ");
|
||||
sb.append(this.b.c());
|
||||
sb.append(", ");
|
||||
b = this.b.d();
|
||||
}
|
||||
sb.append(b);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.misc.ITrackInfo
|
||||
public String getLanguage() {
|
||||
b.a aVar = this.b;
|
||||
return (aVar == null || TextUtils.isEmpty(aVar.d)) ? "und" : this.b.d;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.media.player.misc.ITrackInfo
|
||||
public int getTrackType() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return a.class.getSimpleName() + '{' + getInfoInline() + "}";
|
||||
}
|
||||
}
|
16
sources/com/baidu/cloud/videocache/Cache.java
Normal file
16
sources/com/baidu/cloud/videocache/Cache.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface Cache {
|
||||
int a(byte[] bArr, long j, int i);
|
||||
|
||||
void a();
|
||||
|
||||
void a(byte[] bArr, int i);
|
||||
|
||||
long available();
|
||||
|
||||
boolean b();
|
||||
|
||||
void close();
|
||||
}
|
8
sources/com/baidu/cloud/videocache/CacheListener.java
Normal file
8
sources/com/baidu/cloud/videocache/CacheListener.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface CacheListener {
|
||||
void a(File file, String str, int i);
|
||||
}
|
74
sources/com/baidu/cloud/videocache/ProxyCacheManager.java
Normal file
74
sources/com/baidu/cloud/videocache/ProxyCacheManager.java
Normal file
@@ -0,0 +1,74 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import android.content.Context;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ProxyCacheManager implements CacheListener {
|
||||
private static ProxyCacheManager d;
|
||||
private g a;
|
||||
private CacheListener b;
|
||||
private File c;
|
||||
|
||||
private g a(Context context) {
|
||||
i iVar = new i(context.getApplicationContext());
|
||||
iVar.a(a(context, this.c));
|
||||
return iVar.a();
|
||||
}
|
||||
|
||||
private File a(Context context, File file) {
|
||||
if (file == null || (!file.exists() && !file.mkdirs())) {
|
||||
file = ad.a(context);
|
||||
}
|
||||
this.c = file;
|
||||
return file;
|
||||
}
|
||||
|
||||
public static synchronized ProxyCacheManager b() {
|
||||
ProxyCacheManager proxyCacheManager;
|
||||
synchronized (ProxyCacheManager.class) {
|
||||
if (d == null) {
|
||||
d = new ProxyCacheManager();
|
||||
}
|
||||
proxyCacheManager = d;
|
||||
}
|
||||
return proxyCacheManager;
|
||||
}
|
||||
|
||||
public static g b(Context context) {
|
||||
g gVar = b().a;
|
||||
if (gVar != null) {
|
||||
return gVar;
|
||||
}
|
||||
ProxyCacheManager b = b();
|
||||
g a = b().a(context);
|
||||
b.a = a;
|
||||
return a;
|
||||
}
|
||||
|
||||
public String a(Context context, String str) {
|
||||
if (!str.startsWith("http") || str.contains("127.0.0.1")) {
|
||||
return str;
|
||||
}
|
||||
g b = b(context.getApplicationContext());
|
||||
String a = b.a(str);
|
||||
b.a(this, str);
|
||||
return a;
|
||||
}
|
||||
|
||||
public void a() {
|
||||
g gVar = this.a;
|
||||
if (gVar != null) {
|
||||
gVar.a(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(CacheListener cacheListener) {
|
||||
this.b = cacheListener;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.CacheListener
|
||||
public void a(File file, String str, int i) {
|
||||
this.b.a(file, str, i);
|
||||
}
|
||||
}
|
12
sources/com/baidu/cloud/videocache/Source.java
Normal file
12
sources/com/baidu/cloud/videocache/Source.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface Source {
|
||||
void a(long j);
|
||||
|
||||
void close();
|
||||
|
||||
long length();
|
||||
|
||||
int read(byte[] bArr);
|
||||
}
|
28
sources/com/baidu/cloud/videocache/a.java
Normal file
28
sources/com/baidu/cloud/videocache/a.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import com.baidu.cloud.videocache.file.DiskUsage;
|
||||
import com.baidu.cloud.videocache.file.FileNameGenerator;
|
||||
import com.baidu.cloud.videocache.headers.HeaderInjector;
|
||||
import com.baidu.cloud.videocache.sourcestorage.SourceInfoStorage;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class a {
|
||||
public final File a;
|
||||
public final FileNameGenerator b;
|
||||
public final DiskUsage c;
|
||||
public final SourceInfoStorage d;
|
||||
public final HeaderInjector e;
|
||||
|
||||
a(File file, FileNameGenerator fileNameGenerator, DiskUsage diskUsage, SourceInfoStorage sourceInfoStorage, HeaderInjector headerInjector) {
|
||||
this.a = file;
|
||||
this.b = fileNameGenerator;
|
||||
this.c = diskUsage;
|
||||
this.d = sourceInfoStorage;
|
||||
this.e = headerInjector;
|
||||
}
|
||||
|
||||
File a(String str) {
|
||||
return new File(this.a, this.b.a(str));
|
||||
}
|
||||
}
|
18
sources/com/baidu/cloud/videocache/aa.java
Normal file
18
sources/com/baidu/cloud/videocache/aa.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class aa {
|
||||
public final String a;
|
||||
public long b;
|
||||
public final String c;
|
||||
|
||||
public aa(String str, long j, String str2) {
|
||||
this.a = str;
|
||||
this.b = j;
|
||||
this.c = str2;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "SourceInfo{url='" + this.a + "', length=" + this.b + ", mime='" + this.c + "'}";
|
||||
}
|
||||
}
|
44
sources/com/baidu/cloud/videocache/ab.java
Normal file
44
sources/com/baidu/cloud/videocache/ab.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Environment;
|
||||
import java.io.File;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class ab {
|
||||
private static final Logger a = LoggerFactory.getLogger("StorageUtils");
|
||||
|
||||
public static File a(Context context) {
|
||||
return new File(a(context, true), "video-cache");
|
||||
}
|
||||
|
||||
private static File a(Context context, boolean z) {
|
||||
String str;
|
||||
try {
|
||||
str = Environment.getExternalStorageState();
|
||||
} catch (NullPointerException unused) {
|
||||
str = "";
|
||||
}
|
||||
File b = (z && "mounted".equals(str)) ? b(context) : null;
|
||||
if (b == null) {
|
||||
b = context.getCacheDir();
|
||||
}
|
||||
if (b != null) {
|
||||
return b;
|
||||
}
|
||||
String str2 = "/data/data/" + context.getPackageName() + "/cache/";
|
||||
a.warn("Can't define system cache directory! '" + str2 + "%s' will be used.");
|
||||
return new File(str2);
|
||||
}
|
||||
|
||||
private static File b(Context context) {
|
||||
File file = new File(new File(new File(new File(Environment.getExternalStorageDirectory(), "Android"), "data"), context.getPackageName()), "cache");
|
||||
if (file.exists() || file.mkdirs()) {
|
||||
return file;
|
||||
}
|
||||
a.warn("Unable to create external cache directory");
|
||||
return null;
|
||||
}
|
||||
}
|
138
sources/com/baidu/cloud/videocache/ac.java
Normal file
138
sources/com/baidu/cloud/videocache/ac.java
Normal file
@@ -0,0 +1,138 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ac {
|
||||
public static Uri a(String str, String str2) {
|
||||
return Uri.parse(b(str, str2));
|
||||
}
|
||||
|
||||
private static String a(StringBuilder sb, int i, int i2) {
|
||||
int i3;
|
||||
int i4;
|
||||
if (i >= i2) {
|
||||
return sb.toString();
|
||||
}
|
||||
if (sb.charAt(i) == '/') {
|
||||
i++;
|
||||
}
|
||||
int i5 = i;
|
||||
int i6 = i2;
|
||||
while (true) {
|
||||
for (int i7 = i5; i7 <= i6; i7++) {
|
||||
if (i7 == i6) {
|
||||
i3 = i7;
|
||||
} else if (sb.charAt(i7) == '/') {
|
||||
i3 = i7 + 1;
|
||||
}
|
||||
int i8 = i5 + 1;
|
||||
if (i7 == i8 && sb.charAt(i5) == '.') {
|
||||
sb.delete(i5, i3);
|
||||
i6 -= i3 - i5;
|
||||
} else {
|
||||
if (i7 == i5 + 2 && sb.charAt(i5) == '.' && sb.charAt(i8) == '.') {
|
||||
i4 = sb.lastIndexOf("/", i5 - 2) + 1;
|
||||
int i9 = i4 > i ? i4 : i;
|
||||
sb.delete(i9, i3);
|
||||
i6 -= i3 - i9;
|
||||
} else {
|
||||
i4 = i7 + 1;
|
||||
}
|
||||
i5 = i4;
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private static int[] a(String str) {
|
||||
int i;
|
||||
int[] iArr = new int[4];
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
iArr[0] = -1;
|
||||
return iArr;
|
||||
}
|
||||
int length = str.length();
|
||||
int indexOf = str.indexOf("#");
|
||||
if (indexOf != -1) {
|
||||
length = indexOf;
|
||||
}
|
||||
int indexOf2 = str.indexOf("?");
|
||||
if (indexOf2 == -1 || indexOf2 > length) {
|
||||
indexOf2 = length;
|
||||
}
|
||||
int indexOf3 = str.indexOf("/");
|
||||
if (indexOf3 == -1 && indexOf3 > indexOf2) {
|
||||
indexOf3 = indexOf2;
|
||||
}
|
||||
int indexOf4 = str.indexOf(":");
|
||||
if (indexOf4 > indexOf3) {
|
||||
indexOf4 = -1;
|
||||
}
|
||||
int i2 = indexOf4 + 2;
|
||||
if (i2 < indexOf2 && str.charAt(indexOf4 + 1) == '/' && str.charAt(i2) == '/') {
|
||||
i = str.indexOf(47, indexOf4 + 3);
|
||||
if (i == -1 || i > indexOf2) {
|
||||
i = indexOf2;
|
||||
}
|
||||
} else {
|
||||
i = indexOf4 + 1;
|
||||
}
|
||||
iArr[0] = indexOf4;
|
||||
iArr[1] = i;
|
||||
iArr[2] = indexOf2;
|
||||
iArr[3] = length;
|
||||
return iArr;
|
||||
}
|
||||
|
||||
private static String b(String str, String str2) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (str == null) {
|
||||
str = "";
|
||||
}
|
||||
if (str2 == null) {
|
||||
str2 = "";
|
||||
}
|
||||
int[] a = a(str2);
|
||||
if (a[0] != -1) {
|
||||
sb.append(str2);
|
||||
a(sb, a[1], a[2]);
|
||||
return sb.toString();
|
||||
}
|
||||
int[] a2 = a(str);
|
||||
if (a[3] == 0) {
|
||||
sb.append((CharSequence) str, 0, a2[3]);
|
||||
sb.append(str2);
|
||||
return sb.toString();
|
||||
}
|
||||
if (a[2] == 0) {
|
||||
sb.append((CharSequence) str, 0, a2[2]);
|
||||
sb.append(str2);
|
||||
return sb.toString();
|
||||
}
|
||||
if (a[1] != 0) {
|
||||
int i = a2[0] + 1;
|
||||
sb.append((CharSequence) str, 0, i);
|
||||
sb.append(str2);
|
||||
return a(sb, a[1] + i, i + a[2]);
|
||||
}
|
||||
if (str2.charAt(a[1]) == '/') {
|
||||
sb.append((CharSequence) str, 0, a2[1]);
|
||||
sb.append(str2);
|
||||
return a(sb, a2[1], a2[1] + a[2]);
|
||||
}
|
||||
if (a2[0] + 2 < a2[1] && a2[1] == a2[2]) {
|
||||
sb.append((CharSequence) str, 0, a2[1]);
|
||||
sb.append('/');
|
||||
sb.append(str2);
|
||||
return a(sb, a2[1], a2[1] + a[2] + 1);
|
||||
}
|
||||
int lastIndexOf = str.lastIndexOf(47, a2[2] - 1);
|
||||
int i2 = lastIndexOf == -1 ? a2[1] : lastIndexOf + 1;
|
||||
sb.append((CharSequence) str, 0, i2);
|
||||
sb.append(str2);
|
||||
return a(sb, a2[1], i2 + a[2]);
|
||||
}
|
||||
}
|
24
sources/com/baidu/cloud/videocache/ad.java
Normal file
24
sources/com/baidu/cloud/videocache/ad.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import android.content.Context;
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ad {
|
||||
public static int a(String str) {
|
||||
String b = b(str);
|
||||
if (b.endsWith(".m3u8")) {
|
||||
return 1;
|
||||
}
|
||||
return b.endsWith(".mpd") ? 2 : 0;
|
||||
}
|
||||
|
||||
public static File a(Context context) {
|
||||
return new File(context.getExternalCacheDir(), "video-cache");
|
||||
}
|
||||
|
||||
public static String b(String str) {
|
||||
return str == null ? "" : str.toLowerCase(Locale.US);
|
||||
}
|
||||
}
|
58
sources/com/baidu/cloud/videocache/b.java
Normal file
58
sources/com/baidu/cloud/videocache/b.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class b {
|
||||
private static final Pattern d = Pattern.compile("[R,r]ange:[ ]?bytes=(\\d*)-");
|
||||
private static final Pattern e = Pattern.compile("GET /(.*) HTTP");
|
||||
public final String a;
|
||||
public final long b;
|
||||
public final boolean c;
|
||||
|
||||
public b(String str) {
|
||||
t.a(str);
|
||||
long a = a(str);
|
||||
this.b = Math.max(0L, a);
|
||||
this.c = a >= 0;
|
||||
this.a = b(str);
|
||||
}
|
||||
|
||||
private long a(String str) {
|
||||
Matcher matcher = d.matcher(str);
|
||||
if (matcher.find()) {
|
||||
return Long.parseLong(matcher.group(1));
|
||||
}
|
||||
return -1L;
|
||||
}
|
||||
|
||||
public static b a(InputStream inputStream) {
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (true) {
|
||||
String readLine = bufferedReader.readLine();
|
||||
if (TextUtils.isEmpty(readLine)) {
|
||||
return new b(sb.toString());
|
||||
}
|
||||
sb.append(readLine);
|
||||
sb.append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
private String b(String str) {
|
||||
Matcher matcher = e.matcher(str);
|
||||
if (matcher.find()) {
|
||||
return matcher.group(1);
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid request `" + str + "`: url not found!");
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "GetRequest{rangeOffset=" + this.b + ", partial=" + this.c + ", uri='" + this.a + "'}";
|
||||
}
|
||||
}
|
58
sources/com/baidu/cloud/videocache/c.java
Normal file
58
sources/com/baidu/cloud/videocache/c.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import java.util.Scanner;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class c {
|
||||
private static final Logger a = LoggerFactory.getLogger("HlsPlaylistUtil");
|
||||
|
||||
private static String a(String str, String str2, String str3) {
|
||||
if (str3 == null || str3.isEmpty()) {
|
||||
return str3;
|
||||
}
|
||||
Uri a2 = ac.a(str, str2);
|
||||
return TextUtils.isEmpty(a2.toString()) ? str3 : str3.replace(str2, z.b(a2.toString()));
|
||||
}
|
||||
|
||||
private static boolean a(Scanner scanner) {
|
||||
return scanner != null && scanner.hasNextLine() && "#EXTM3U".equals(scanner.nextLine());
|
||||
}
|
||||
|
||||
public static byte[] a(byte[] bArr, String str) {
|
||||
if (bArr == null || bArr.length == 0) {
|
||||
return null;
|
||||
}
|
||||
String trim = new String(bArr).trim();
|
||||
Scanner scanner = new Scanner(trim);
|
||||
if (!a(scanner)) {
|
||||
a.debug("Input does not start with the #EXTM3U.url :" + str);
|
||||
return null;
|
||||
}
|
||||
char c = 65535;
|
||||
while (scanner.hasNextLine()) {
|
||||
String trim2 = scanner.nextLine().trim();
|
||||
if (c == 65535) {
|
||||
if (trim2.startsWith("#EXT-X-STREAM-INF")) {
|
||||
c = 1;
|
||||
} else if (trim2.startsWith("#EXT-X-TARGETDURATION") || trim2.startsWith("#EXT-X-MEDIA-SEQUENCE") || trim2.startsWith("#EXTINF") || trim2.startsWith("#EXT-X-KEY") || trim2.startsWith("#EXT-X-BYTERANGE") || trim2.equals("#EXT-X-DISCONTINUITY") || trim2.equals("#EXT-X-DISCONTINUITY-SEQUENCE") || trim2.equals("#EXT-X-ENDLIST")) {
|
||||
c = 2;
|
||||
}
|
||||
}
|
||||
if (c == 1) {
|
||||
if (trim2.startsWith("#EXT-X-STREAM-INF")) {
|
||||
trim2 = scanner.nextLine();
|
||||
trim = a(str, trim2, trim);
|
||||
}
|
||||
} else if (c == 2 && !trim2.startsWith("#")) {
|
||||
trim = a(str, trim2, trim);
|
||||
}
|
||||
}
|
||||
scanner.close();
|
||||
a.debug("Convert completed:\n" + trim);
|
||||
return trim.getBytes();
|
||||
}
|
||||
}
|
135
sources/com/baidu/cloud/videocache/d.java
Normal file
135
sources/com/baidu/cloud/videocache/d.java
Normal file
@@ -0,0 +1,135 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class d extends f {
|
||||
private static final Logger o = LoggerFactory.getLogger("HlsProxyCache");
|
||||
private e m;
|
||||
private b n;
|
||||
|
||||
public d(e eVar, com.baidu.cloud.videocache.file.a aVar) {
|
||||
super(eVar, aVar);
|
||||
this.m = eVar;
|
||||
}
|
||||
|
||||
private void f() {
|
||||
long j;
|
||||
Throwable th;
|
||||
long j2 = -1;
|
||||
try {
|
||||
this.m.a(0L);
|
||||
j2 = this.m.length();
|
||||
byte[] bArr = new byte[UnityActivity.BLOCKLY_TYPE_NONE];
|
||||
byte[] bArr2 = new byte[(int) this.m.length()];
|
||||
j = 0;
|
||||
int i = 0;
|
||||
while (true) {
|
||||
try {
|
||||
int read = this.m.read(bArr);
|
||||
if (read != -1) {
|
||||
synchronized (this.d) {
|
||||
if (d()) {
|
||||
return;
|
||||
}
|
||||
System.arraycopy(bArr, 0, bArr2, i, read);
|
||||
i += read;
|
||||
}
|
||||
j += read;
|
||||
a(j, j2);
|
||||
} else {
|
||||
if (!d() && i == this.m.length()) {
|
||||
byte[] a = c.a(bArr2, this.m.b());
|
||||
this.k.a(a, a.length);
|
||||
this.m.b(a.length);
|
||||
}
|
||||
c();
|
||||
b();
|
||||
o.debug("Read hls file to cache. available is" + this.k.available());
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
try {
|
||||
this.e.incrementAndGet();
|
||||
a(th);
|
||||
return;
|
||||
} finally {
|
||||
e();
|
||||
a(j, j2);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable th3) {
|
||||
j = 0;
|
||||
th = th3;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.f
|
||||
public void a(b bVar, Socket socket) {
|
||||
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(socket.getOutputStream());
|
||||
this.n = bVar;
|
||||
o.info("Hls request: {\n" + bVar + "}");
|
||||
long j = bVar.b;
|
||||
if (a(bVar)) {
|
||||
a(bufferedOutputStream, j);
|
||||
} else {
|
||||
b(bufferedOutputStream, j);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.f
|
||||
protected void a(OutputStream outputStream, long j) {
|
||||
if (!this.k.b() && !d()) {
|
||||
f();
|
||||
}
|
||||
if (this.k.b() && this.h != 100) {
|
||||
this.h = 100;
|
||||
a(100);
|
||||
}
|
||||
byte[] bArr = new byte[UnityActivity.BLOCKLY_TYPE_NONE];
|
||||
outputStream.write(b(this.n).getBytes("UTF-8"));
|
||||
while (true) {
|
||||
int a = this.k.a(bArr, j, bArr.length);
|
||||
if (a == -1) {
|
||||
outputStream.flush();
|
||||
return;
|
||||
} else {
|
||||
outputStream.write(bArr, 0, a);
|
||||
j += a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.f
|
||||
protected void b(OutputStream outputStream, long j) {
|
||||
e eVar = new e(this.m);
|
||||
try {
|
||||
eVar.a((int) j);
|
||||
byte[] bArr = new byte[UnityActivity.BLOCKLY_TYPE_NONE];
|
||||
byte[] bArr2 = new byte[(int) this.m.length()];
|
||||
int i = 0;
|
||||
while (true) {
|
||||
int read = eVar.read(bArr);
|
||||
if (read == -1) {
|
||||
byte[] a = c.a(bArr2, this.m.b());
|
||||
this.m.b(a.length);
|
||||
outputStream.write(b(this.n).getBytes("UTF-8"));
|
||||
outputStream.write(a, 0, a.length);
|
||||
outputStream.flush();
|
||||
o.info("Read from source bytes " + i);
|
||||
return;
|
||||
}
|
||||
System.arraycopy(bArr, 0, bArr2, i, read);
|
||||
i += read;
|
||||
}
|
||||
} finally {
|
||||
eVar.close();
|
||||
}
|
||||
}
|
||||
}
|
21
sources/com/baidu/cloud/videocache/e.java
Normal file
21
sources/com/baidu/cloud/videocache/e.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import com.baidu.cloud.videocache.headers.HeaderInjector;
|
||||
import com.baidu.cloud.videocache.sourcestorage.SourceInfoStorage;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class e extends n {
|
||||
public e(n nVar) {
|
||||
super(nVar);
|
||||
}
|
||||
|
||||
public e(String str, SourceInfoStorage sourceInfoStorage, HeaderInjector headerInjector) {
|
||||
super(str, sourceInfoStorage, headerInjector);
|
||||
}
|
||||
|
||||
public void b(long j) {
|
||||
aa aaVar = this.c;
|
||||
aaVar.b = j;
|
||||
this.a.a(aaVar.a, aaVar);
|
||||
}
|
||||
}
|
102
sources/com/baidu/cloud/videocache/f.java
Normal file
102
sources/com/baidu/cloud/videocache/f.java
Normal file
@@ -0,0 +1,102 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.util.Locale;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class f extends u {
|
||||
private final n j;
|
||||
protected final com.baidu.cloud.videocache.file.a k;
|
||||
private CacheListener l;
|
||||
|
||||
public f(n nVar, com.baidu.cloud.videocache.file.a aVar) {
|
||||
super(nVar, aVar);
|
||||
this.k = aVar;
|
||||
this.j = nVar;
|
||||
}
|
||||
|
||||
protected String a(String str, Object... objArr) {
|
||||
return String.format(Locale.US, str, objArr);
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.u
|
||||
protected void a(int i) {
|
||||
CacheListener cacheListener = this.l;
|
||||
if (cacheListener != null) {
|
||||
cacheListener.a(this.k.b, this.j.b(), i);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(CacheListener cacheListener) {
|
||||
this.l = cacheListener;
|
||||
}
|
||||
|
||||
public void a(b bVar, Socket socket) {
|
||||
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(socket.getOutputStream());
|
||||
bufferedOutputStream.write(b(bVar).getBytes("UTF-8"));
|
||||
long j = bVar.b;
|
||||
if (a(bVar)) {
|
||||
a(bufferedOutputStream, j);
|
||||
} else {
|
||||
b(bufferedOutputStream, j);
|
||||
}
|
||||
}
|
||||
|
||||
protected void a(OutputStream outputStream, long j) {
|
||||
byte[] bArr = new byte[UnityActivity.BLOCKLY_TYPE_NONE];
|
||||
while (true) {
|
||||
int a = a(bArr, j, bArr.length);
|
||||
if (a == -1) {
|
||||
outputStream.flush();
|
||||
return;
|
||||
} else {
|
||||
outputStream.write(bArr, 0, a);
|
||||
j += a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean a(b bVar) {
|
||||
long length = this.j.length();
|
||||
return (((length > 0L ? 1 : (length == 0L ? 0 : -1)) > 0) && bVar.c && ((float) bVar.b) > ((float) this.k.available()) + (((float) length) * 0.2f)) ? false : true;
|
||||
}
|
||||
|
||||
protected String b(b bVar) {
|
||||
String a = this.j.a();
|
||||
boolean z = !TextUtils.isEmpty(a);
|
||||
long available = this.k.b() ? this.k.available() : this.j.length();
|
||||
boolean z2 = available >= 0;
|
||||
long j = bVar.c ? available - bVar.b : available;
|
||||
boolean z3 = z2 && bVar.c;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(bVar.c ? "HTTP/1.1 206 PARTIAL CONTENT\n" : "HTTP/1.1 200 OK\n");
|
||||
sb.append("Accept-Ranges: bytes\n");
|
||||
sb.append(z2 ? a("Content-Length: %d\n", Long.valueOf(j)) : "");
|
||||
sb.append(z3 ? a("Content-Range: bytes %d-%d/%d\n", Long.valueOf(bVar.b), Long.valueOf(available - 1), Long.valueOf(available)) : "");
|
||||
sb.append(z ? a("Content-Type: %s\n", a) : "");
|
||||
sb.append("\n");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected void b(OutputStream outputStream, long j) {
|
||||
n nVar = new n(this.j);
|
||||
try {
|
||||
nVar.a((int) j);
|
||||
byte[] bArr = new byte[UnityActivity.BLOCKLY_TYPE_NONE];
|
||||
while (true) {
|
||||
int read = nVar.read(bArr);
|
||||
if (read == -1) {
|
||||
outputStream.flush();
|
||||
return;
|
||||
}
|
||||
outputStream.write(bArr, 0, read);
|
||||
}
|
||||
} finally {
|
||||
nVar.close();
|
||||
}
|
||||
}
|
||||
}
|
8
sources/com/baidu/cloud/videocache/file/DiskUsage.java
Normal file
8
sources/com/baidu/cloud/videocache/file/DiskUsage.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.baidu.cloud.videocache.file;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface DiskUsage {
|
||||
void a(File file);
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package com.baidu.cloud.videocache.file;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface FileNameGenerator {
|
||||
String a(String str);
|
||||
}
|
105
sources/com/baidu/cloud/videocache/file/a.java
Normal file
105
sources/com/baidu/cloud/videocache/file/a.java
Normal file
@@ -0,0 +1,105 @@
|
||||
package com.baidu.cloud.videocache.file;
|
||||
|
||||
import com.baidu.cloud.videocache.Cache;
|
||||
import com.baidu.cloud.videocache.x;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class a implements Cache {
|
||||
private final DiskUsage a;
|
||||
public File b;
|
||||
private RandomAccessFile c;
|
||||
|
||||
public a(File file, DiskUsage diskUsage) {
|
||||
File file2;
|
||||
try {
|
||||
if (diskUsage == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
this.a = diskUsage;
|
||||
b.a(file.getParentFile());
|
||||
boolean exists = file.exists();
|
||||
if (exists) {
|
||||
file2 = file;
|
||||
} else {
|
||||
file2 = new File(file.getParentFile(), file.getName() + ".download");
|
||||
}
|
||||
this.b = file2;
|
||||
this.c = new RandomAccessFile(this.b, exists ? "r" : "rw");
|
||||
} catch (IOException e) {
|
||||
throw new x("Error using file " + file + " as disc cache", e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean a(File file) {
|
||||
return file.getName().endsWith(".download");
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.Cache
|
||||
public synchronized int a(byte[] bArr, long j, int i) {
|
||||
try {
|
||||
this.c.seek(j);
|
||||
} catch (IOException e) {
|
||||
throw new x(String.format("Error reading %d bytes with offset %d from file[%d bytes] to buffer[%d bytes]", Integer.valueOf(i), Long.valueOf(j), Long.valueOf(available()), Integer.valueOf(bArr.length)), e);
|
||||
}
|
||||
return this.c.read(bArr, 0, i);
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.Cache
|
||||
public synchronized void a() {
|
||||
if (b()) {
|
||||
return;
|
||||
}
|
||||
close();
|
||||
File file = new File(this.b.getParentFile(), this.b.getName().substring(0, this.b.getName().length() - 9));
|
||||
if (!this.b.renameTo(file)) {
|
||||
throw new x("Error renaming file " + this.b + " to " + file + " for completion!");
|
||||
}
|
||||
this.b = file;
|
||||
try {
|
||||
this.c = new RandomAccessFile(this.b, "r");
|
||||
this.a.a(this.b);
|
||||
} catch (IOException e) {
|
||||
throw new x("Error opening " + this.b + " as disc cache", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.Cache
|
||||
public synchronized void a(byte[] bArr, int i) {
|
||||
try {
|
||||
if (b()) {
|
||||
throw new x("Error append cache: cache file " + this.b + " is completed!");
|
||||
}
|
||||
this.c.seek(available());
|
||||
this.c.write(bArr, 0, i);
|
||||
} catch (IOException e) {
|
||||
throw new x(String.format("Error writing %d bytes to %s from buffer with size %d", Integer.valueOf(i), this.c, Integer.valueOf(bArr.length)), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.Cache
|
||||
public synchronized long available() {
|
||||
try {
|
||||
} catch (IOException e) {
|
||||
throw new x("Error reading length of file " + this.b, e);
|
||||
}
|
||||
return (int) this.c.length();
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.Cache
|
||||
public synchronized boolean b() {
|
||||
return !a(this.b);
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.Cache
|
||||
public synchronized void close() {
|
||||
try {
|
||||
this.c.close();
|
||||
this.a.a(this.b);
|
||||
} catch (IOException e) {
|
||||
throw new x("Error closing file " + this.b, e);
|
||||
}
|
||||
}
|
||||
}
|
76
sources/com/baidu/cloud/videocache/file/b.java
Normal file
76
sources/com/baidu/cloud/videocache/file/b.java
Normal file
@@ -0,0 +1,76 @@
|
||||
package com.baidu.cloud.videocache.file;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class b {
|
||||
private static final Logger a = LoggerFactory.getLogger("Files");
|
||||
|
||||
static void a(File file) {
|
||||
if (!file.exists()) {
|
||||
if (!file.mkdirs()) {
|
||||
throw new IOException(String.format("Directory %s can't be created", file.getAbsolutePath()));
|
||||
}
|
||||
} else {
|
||||
if (file.isDirectory()) {
|
||||
return;
|
||||
}
|
||||
throw new IOException("File " + file + " is not directory!");
|
||||
}
|
||||
}
|
||||
|
||||
static List b(File file) {
|
||||
LinkedList linkedList = new LinkedList();
|
||||
File[] listFiles = file.listFiles();
|
||||
if (listFiles == null) {
|
||||
return linkedList;
|
||||
}
|
||||
List asList = Arrays.asList(listFiles);
|
||||
Collections.sort(asList, new d());
|
||||
return asList;
|
||||
}
|
||||
|
||||
static void c(File file) {
|
||||
if (file.exists()) {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
if (file.setLastModified(currentTimeMillis)) {
|
||||
return;
|
||||
}
|
||||
d(file);
|
||||
if (file.lastModified() < currentTimeMillis) {
|
||||
a.warn("Last modified date {} is not set for file {}", new Date(file.lastModified()), file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void d(File file) {
|
||||
long length = file.length();
|
||||
if (length == 0) {
|
||||
e(file);
|
||||
return;
|
||||
}
|
||||
RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rwd");
|
||||
long j = length - 1;
|
||||
randomAccessFile.seek(j);
|
||||
byte readByte = randomAccessFile.readByte();
|
||||
randomAccessFile.seek(j);
|
||||
randomAccessFile.write(readByte);
|
||||
randomAccessFile.close();
|
||||
}
|
||||
|
||||
private static void e(File file) {
|
||||
if (file.delete() && file.createNewFile()) {
|
||||
return;
|
||||
}
|
||||
throw new IOException("Error recreate zero-size file " + file);
|
||||
}
|
||||
}
|
23
sources/com/baidu/cloud/videocache/file/d.java
Normal file
23
sources/com/baidu/cloud/videocache/file/d.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package com.baidu.cloud.videocache.file;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Comparator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class d implements Comparator {
|
||||
private d() {
|
||||
}
|
||||
|
||||
private int a(long j, long j2) {
|
||||
if (j < j2) {
|
||||
return -1;
|
||||
}
|
||||
return j == j2 ? 0 : 1;
|
||||
}
|
||||
|
||||
@Override // java.util.Comparator
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public int compare(File file, File file2) {
|
||||
return a(file.lastModified(), file2.lastModified());
|
||||
}
|
||||
}
|
56
sources/com/baidu/cloud/videocache/file/e.java
Normal file
56
sources/com/baidu/cloud/videocache/file/e.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package com.baidu.cloud.videocache.file;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class e implements DiskUsage {
|
||||
private static final Logger b = LoggerFactory.getLogger("LruDiskUsage");
|
||||
private final ExecutorService a = Executors.newSingleThreadExecutor();
|
||||
|
||||
private void a(List list) {
|
||||
long b2 = b(list);
|
||||
int size = list.size();
|
||||
Iterator it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
File file = (File) it.next();
|
||||
if (!a(file, b2, size)) {
|
||||
long length = file.length();
|
||||
if (file.delete()) {
|
||||
size--;
|
||||
b2 -= length;
|
||||
b.info("Cache file " + file + " is deleted because it exceeds cache limit");
|
||||
} else {
|
||||
b.error("Error deleting file " + file + " for trimming cache");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long b(List list) {
|
||||
Iterator it = list.iterator();
|
||||
long j = 0;
|
||||
while (it.hasNext()) {
|
||||
j += ((File) it.next()).length();
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void b(File file) {
|
||||
b.c(file);
|
||||
a(b.b(file.getParentFile()));
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.file.DiskUsage
|
||||
public void a(File file) {
|
||||
this.a.submit(new f(this, file));
|
||||
}
|
||||
|
||||
protected abstract boolean a(File file, long j, int i);
|
||||
}
|
22
sources/com/baidu/cloud/videocache/file/f.java
Normal file
22
sources/com/baidu/cloud/videocache/file/f.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.baidu.cloud.videocache.file;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class f implements Callable {
|
||||
private final File a;
|
||||
final /* synthetic */ e b;
|
||||
|
||||
public f(e eVar, File file) {
|
||||
this.b = eVar;
|
||||
this.a = file;
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.Callable
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public Void call() {
|
||||
this.b.b(this.a);
|
||||
return null;
|
||||
}
|
||||
}
|
20
sources/com/baidu/cloud/videocache/file/g.java
Normal file
20
sources/com/baidu/cloud/videocache/file/g.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.baidu.cloud.videocache.file;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class g extends e {
|
||||
private final long c;
|
||||
|
||||
public g(long j) {
|
||||
if (j <= 0) {
|
||||
throw new IllegalArgumentException("Max size must be positive number!");
|
||||
}
|
||||
this.c = j;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.file.e
|
||||
protected boolean a(File file, long j, int i) {
|
||||
return j <= this.c;
|
||||
}
|
||||
}
|
11
sources/com/baidu/cloud/videocache/file/h.java
Normal file
11
sources/com/baidu/cloud/videocache/file/h.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.baidu.cloud.videocache.file;
|
||||
|
||||
import com.baidu.cloud.videocache.z;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class h implements FileNameGenerator {
|
||||
@Override // com.baidu.cloud.videocache.file.FileNameGenerator
|
||||
public String a(String str) {
|
||||
return z.b(str);
|
||||
}
|
||||
}
|
246
sources/com/baidu/cloud/videocache/g.java
Normal file
246
sources/com/baidu/cloud/videocache/g.java
Normal file
@@ -0,0 +1,246 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import android.net.Uri;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class g {
|
||||
private static final Logger i = LoggerFactory.getLogger("HttpProxyCacheServer");
|
||||
private final Object a;
|
||||
private final ExecutorService b;
|
||||
private final Map c;
|
||||
private final ServerSocket d;
|
||||
private final int e;
|
||||
private Thread f;
|
||||
private final a g;
|
||||
private final q h;
|
||||
|
||||
private g(a aVar) {
|
||||
this.a = new Object();
|
||||
this.b = Executors.newFixedThreadPool(8);
|
||||
this.c = new ConcurrentHashMap();
|
||||
t.a(aVar);
|
||||
this.g = aVar;
|
||||
try {
|
||||
this.d = new ServerSocket(0, 8, InetAddress.getByName("127.0.0.1"));
|
||||
this.e = this.d.getLocalPort();
|
||||
o.a("127.0.0.1", this.e);
|
||||
a();
|
||||
this.h = new q("127.0.0.1", this.e);
|
||||
i.info("Proxy cache server started. Is it alive? " + b());
|
||||
} catch (IOException | InterruptedException e) {
|
||||
this.b.shutdown();
|
||||
throw new IllegalStateException("Error starting local proxy server", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void a() {
|
||||
CountDownLatch countDownLatch = new CountDownLatch(1);
|
||||
this.f = new Thread(new k(this, countDownLatch));
|
||||
this.f.start();
|
||||
countDownLatch.await();
|
||||
}
|
||||
|
||||
private void a(File file) {
|
||||
try {
|
||||
this.g.c.a(file);
|
||||
} catch (IOException e) {
|
||||
i.error("Error touching file " + file, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void a(Throwable th) {
|
||||
i.error("HttpProxyCacheServer error", th);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void a(Socket socket) {
|
||||
Logger logger;
|
||||
StringBuilder sb;
|
||||
try {
|
||||
try {
|
||||
b a = b.a(socket.getInputStream());
|
||||
i.debug("Request to cache proxy:" + a);
|
||||
String c = z.c(a.a);
|
||||
if (this.h.a(c)) {
|
||||
this.h.a(socket);
|
||||
} else {
|
||||
e(c).a(a, socket);
|
||||
}
|
||||
b(socket);
|
||||
logger = i;
|
||||
sb = new StringBuilder();
|
||||
} catch (x e) {
|
||||
e = e;
|
||||
a(new x("Error processing request", e));
|
||||
b(socket);
|
||||
logger = i;
|
||||
sb = new StringBuilder();
|
||||
} catch (SocketException unused) {
|
||||
i.debug("Closing socket… Socket is closed by client.");
|
||||
b(socket);
|
||||
logger = i;
|
||||
sb = new StringBuilder();
|
||||
} catch (IOException e2) {
|
||||
e = e2;
|
||||
a(new x("Error processing request", e));
|
||||
b(socket);
|
||||
logger = i;
|
||||
sb = new StringBuilder();
|
||||
}
|
||||
sb.append("Opened connections: ");
|
||||
sb.append(d());
|
||||
logger.debug(sb.toString());
|
||||
} catch (Throwable th) {
|
||||
b(socket);
|
||||
i.debug("Opened connections: " + d());
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
private void b(Socket socket) {
|
||||
c(socket);
|
||||
d(socket);
|
||||
e(socket);
|
||||
}
|
||||
|
||||
private boolean b() {
|
||||
return this.h.a(3, 70);
|
||||
}
|
||||
|
||||
private String c(String str) {
|
||||
return String.format(Locale.US, "http://%s:%d/%s", "127.0.0.1", Integer.valueOf(this.e), z.b(str));
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void c() {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
try {
|
||||
Socket accept = this.d.accept();
|
||||
i.debug("Accept new socket " + accept);
|
||||
this.b.submit(new j(this, accept));
|
||||
} catch (IOException e) {
|
||||
a(new x("Error during waiting connection", e));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void c(Socket socket) {
|
||||
try {
|
||||
if (socket.isInputShutdown()) {
|
||||
return;
|
||||
}
|
||||
socket.shutdownInput();
|
||||
} catch (SocketException unused) {
|
||||
i.debug("Releasing input stream… Socket is closed by client.");
|
||||
} catch (IOException e) {
|
||||
a(new x("Error closing socket input stream", e));
|
||||
}
|
||||
}
|
||||
|
||||
private int d() {
|
||||
int i2;
|
||||
synchronized (this.a) {
|
||||
i2 = 0;
|
||||
Iterator it = this.c.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
i2 += ((l) it.next()).a();
|
||||
}
|
||||
}
|
||||
return i2;
|
||||
}
|
||||
|
||||
private File d(String str) {
|
||||
a aVar = this.g;
|
||||
return new File(aVar.a, aVar.b.a(str));
|
||||
}
|
||||
|
||||
private void d(Socket socket) {
|
||||
try {
|
||||
if (socket.isOutputShutdown()) {
|
||||
return;
|
||||
}
|
||||
socket.shutdownOutput();
|
||||
} catch (IOException e) {
|
||||
i.warn("Failed to close socket on proxy side: {}. It seems client have already closed connection.", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private l e(String str) {
|
||||
l lVar;
|
||||
synchronized (this.a) {
|
||||
lVar = (l) this.c.get(str);
|
||||
if (lVar == null) {
|
||||
lVar = new l(str, this.g);
|
||||
this.c.put(str, lVar);
|
||||
}
|
||||
}
|
||||
return lVar;
|
||||
}
|
||||
|
||||
private void e(Socket socket) {
|
||||
try {
|
||||
if (socket.isClosed()) {
|
||||
return;
|
||||
}
|
||||
socket.close();
|
||||
} catch (IOException e) {
|
||||
a(new x("Error closing socket", e));
|
||||
}
|
||||
}
|
||||
|
||||
public String a(String str) {
|
||||
int a = ad.a(str);
|
||||
return (a == 1 || a == 2) ? a(str, false) : a(str, true);
|
||||
}
|
||||
|
||||
public String a(String str, boolean z) {
|
||||
if (!z || !b(str)) {
|
||||
return b() ? c(str) : str;
|
||||
}
|
||||
File d = d(str);
|
||||
a(d);
|
||||
return Uri.fromFile(d).toString();
|
||||
}
|
||||
|
||||
public void a(CacheListener cacheListener) {
|
||||
t.a(cacheListener);
|
||||
synchronized (this.a) {
|
||||
Iterator it = this.c.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
((l) it.next()).b(cacheListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void a(CacheListener cacheListener, String str) {
|
||||
t.a(cacheListener, str);
|
||||
synchronized (this.a) {
|
||||
try {
|
||||
e(str).a(cacheListener);
|
||||
} catch (x e) {
|
||||
i.warn("Error registering cache listener", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean b(String str) {
|
||||
t.a(str, "Url can't be null!");
|
||||
return d(str).exists();
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package com.baidu.cloud.videocache.headers;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface HeaderInjector {
|
||||
Map a(String str);
|
||||
}
|
12
sources/com/baidu/cloud/videocache/headers/a.java
Normal file
12
sources/com/baidu/cloud/videocache/headers/a.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.baidu.cloud.videocache.headers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class a implements HeaderInjector {
|
||||
@Override // com.baidu.cloud.videocache.headers.HeaderInjector
|
||||
public Map a(String str) {
|
||||
return new HashMap();
|
||||
}
|
||||
}
|
36
sources/com/baidu/cloud/videocache/i.java
Normal file
36
sources/com/baidu/cloud/videocache/i.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import android.content.Context;
|
||||
import com.baidu.cloud.videocache.file.DiskUsage;
|
||||
import com.baidu.cloud.videocache.file.FileNameGenerator;
|
||||
import com.baidu.cloud.videocache.headers.HeaderInjector;
|
||||
import com.baidu.cloud.videocache.sourcestorage.SourceInfoStorage;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class i {
|
||||
private File a;
|
||||
private SourceInfoStorage d;
|
||||
private DiskUsage c = new com.baidu.cloud.videocache.file.g(536870912);
|
||||
private FileNameGenerator b = new com.baidu.cloud.videocache.file.h();
|
||||
private HeaderInjector e = new com.baidu.cloud.videocache.headers.a();
|
||||
|
||||
public i(Context context) {
|
||||
this.d = com.baidu.cloud.videocache.sourcestorage.c.a(context);
|
||||
this.a = ab.a(context);
|
||||
}
|
||||
|
||||
private a b() {
|
||||
return new a(this.a, this.b, this.c, this.d, this.e);
|
||||
}
|
||||
|
||||
public g a() {
|
||||
return new g(b());
|
||||
}
|
||||
|
||||
public i a(File file) {
|
||||
t.a(file);
|
||||
this.a = file;
|
||||
return this;
|
||||
}
|
||||
}
|
19
sources/com/baidu/cloud/videocache/j.java
Normal file
19
sources/com/baidu/cloud/videocache/j.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import java.net.Socket;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class j implements Runnable {
|
||||
private final Socket a;
|
||||
final /* synthetic */ g b;
|
||||
|
||||
public j(g gVar, Socket socket) {
|
||||
this.b = gVar;
|
||||
this.a = socket;
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
this.b.a(this.a);
|
||||
}
|
||||
}
|
20
sources/com/baidu/cloud/videocache/k.java
Normal file
20
sources/com/baidu/cloud/videocache/k.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class k implements Runnable {
|
||||
private final CountDownLatch a;
|
||||
final /* synthetic */ g b;
|
||||
|
||||
public k(g gVar, CountDownLatch countDownLatch) {
|
||||
this.b = gVar;
|
||||
this.a = countDownLatch;
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
this.a.countDown();
|
||||
this.b.c();
|
||||
}
|
||||
}
|
63
sources/com/baidu/cloud/videocache/l.java
Normal file
63
sources/com/baidu/cloud/videocache/l.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import java.net.Socket;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class l {
|
||||
private final String b;
|
||||
private volatile f c;
|
||||
private final CacheListener e;
|
||||
private final a f;
|
||||
private final AtomicInteger a = new AtomicInteger(0);
|
||||
private final List d = new CopyOnWriteArrayList();
|
||||
|
||||
public l(String str, a aVar) {
|
||||
t.a(str);
|
||||
this.b = str;
|
||||
t.a(aVar);
|
||||
this.f = aVar;
|
||||
this.e = new m(str, this.d);
|
||||
}
|
||||
|
||||
private synchronized void b() {
|
||||
this.c = this.c == null ? d() : this.c;
|
||||
}
|
||||
|
||||
private synchronized void c() {
|
||||
if (this.a.decrementAndGet() <= 0) {
|
||||
this.c.a();
|
||||
this.c = null;
|
||||
}
|
||||
}
|
||||
|
||||
private f d() {
|
||||
f a = y.a(this.b, this.f);
|
||||
a.a(this.e);
|
||||
return a;
|
||||
}
|
||||
|
||||
public int a() {
|
||||
return this.a.get();
|
||||
}
|
||||
|
||||
public void a(CacheListener cacheListener) {
|
||||
this.d.add(cacheListener);
|
||||
}
|
||||
|
||||
public void a(b bVar, Socket socket) {
|
||||
b();
|
||||
try {
|
||||
this.a.incrementAndGet();
|
||||
this.c.a(bVar, socket);
|
||||
} finally {
|
||||
c();
|
||||
}
|
||||
}
|
||||
|
||||
public void b(CacheListener cacheListener) {
|
||||
this.d.remove(cacheListener);
|
||||
}
|
||||
}
|
36
sources/com/baidu/cloud/videocache/m.java
Normal file
36
sources/com/baidu/cloud/videocache/m.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class m extends Handler implements CacheListener {
|
||||
private final String a;
|
||||
private final List b;
|
||||
|
||||
public m(String str, List list) {
|
||||
super(Looper.getMainLooper());
|
||||
this.a = str;
|
||||
this.b = list;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.CacheListener
|
||||
public void a(File file, String str, int i) {
|
||||
Message obtainMessage = obtainMessage();
|
||||
obtainMessage.arg1 = i;
|
||||
obtainMessage.obj = file;
|
||||
sendMessage(obtainMessage);
|
||||
}
|
||||
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(Message message) {
|
||||
Iterator it = this.b.iterator();
|
||||
while (it.hasNext()) {
|
||||
((CacheListener) it.next()).a((File) message.obj, this.a, message.arg1);
|
||||
}
|
||||
}
|
||||
}
|
291
sources/com/baidu/cloud/videocache/n.java
Normal file
291
sources/com/baidu/cloud/videocache/n.java
Normal file
@@ -0,0 +1,291 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.baidu.cloud.videocache.headers.HeaderInjector;
|
||||
import com.baidu.cloud.videocache.sourcestorage.SourceInfoStorage;
|
||||
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class n implements Source {
|
||||
private static final Logger f = LoggerFactory.getLogger("HttpUrlSource");
|
||||
protected final SourceInfoStorage a;
|
||||
private final HeaderInjector b;
|
||||
protected aa c;
|
||||
private HttpURLConnection d;
|
||||
private InputStream e;
|
||||
|
||||
public n(n nVar) {
|
||||
this.c = nVar.c;
|
||||
this.a = nVar.a;
|
||||
this.b = nVar.b;
|
||||
}
|
||||
|
||||
public n(String str) {
|
||||
this(str, com.baidu.cloud.videocache.sourcestorage.c.a());
|
||||
}
|
||||
|
||||
public n(String str, SourceInfoStorage sourceInfoStorage) {
|
||||
this(str, sourceInfoStorage, new com.baidu.cloud.videocache.headers.a());
|
||||
}
|
||||
|
||||
public n(String str, SourceInfoStorage sourceInfoStorage, HeaderInjector headerInjector) {
|
||||
t.a(sourceInfoStorage);
|
||||
this.a = sourceInfoStorage;
|
||||
t.a(headerInjector);
|
||||
this.b = headerInjector;
|
||||
aa aaVar = sourceInfoStorage.get(str);
|
||||
this.c = aaVar == null ? new aa(str, -2147483648L, z.a(str)) : aaVar;
|
||||
}
|
||||
|
||||
private long a(HttpURLConnection httpURLConnection) {
|
||||
String headerField = httpURLConnection.getHeaderField("Content-Length");
|
||||
if (headerField == null) {
|
||||
return -1L;
|
||||
}
|
||||
return Long.parseLong(headerField);
|
||||
}
|
||||
|
||||
private long a(HttpURLConnection httpURLConnection, long j, int i) {
|
||||
long a = a(httpURLConnection);
|
||||
return i == 200 ? a : i == 206 ? a + j : this.c.b;
|
||||
}
|
||||
|
||||
private HttpURLConnection a(long j, int i) {
|
||||
String str;
|
||||
HttpURLConnection httpURLConnection;
|
||||
boolean z;
|
||||
String str2 = this.c.a;
|
||||
int i2 = 0;
|
||||
do {
|
||||
Logger logger = f;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Open connection ");
|
||||
if (j > 0) {
|
||||
str = " with offset " + j;
|
||||
} else {
|
||||
str = "";
|
||||
}
|
||||
sb.append(str);
|
||||
sb.append(" to ");
|
||||
sb.append(str2);
|
||||
logger.debug(sb.toString());
|
||||
httpURLConnection = (HttpURLConnection) new URL(str2).openConnection();
|
||||
a(httpURLConnection, str2);
|
||||
if (j > 0) {
|
||||
httpURLConnection.setRequestProperty("Range", "bytes=" + j + "-");
|
||||
}
|
||||
if (i > 0) {
|
||||
httpURLConnection.setConnectTimeout(i);
|
||||
httpURLConnection.setReadTimeout(i);
|
||||
}
|
||||
int responseCode = httpURLConnection.getResponseCode();
|
||||
z = responseCode == 301 || responseCode == 302 || responseCode == 303;
|
||||
if (z) {
|
||||
str2 = httpURLConnection.getHeaderField("Location");
|
||||
i2++;
|
||||
httpURLConnection.disconnect();
|
||||
}
|
||||
if (i2 > 5) {
|
||||
throw new x("Too many redirects: " + i2);
|
||||
}
|
||||
} while (z);
|
||||
return httpURLConnection;
|
||||
}
|
||||
|
||||
private void a(HttpURLConnection httpURLConnection, String str) {
|
||||
for (Map.Entry entry : this.b.a(str).entrySet()) {
|
||||
httpURLConnection.setRequestProperty((String) entry.getKey(), (String) entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:10:0x008e, code lost:
|
||||
|
||||
return;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:17:0x0089, code lost:
|
||||
|
||||
if (r0 == null) goto L25;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:7:0x0060, code lost:
|
||||
|
||||
if (r0 != null) goto L19;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:8:0x008b, code lost:
|
||||
|
||||
r0.disconnect();
|
||||
r0 = r0;
|
||||
*/
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
/* JADX WARN: Removed duplicated region for block: B:22:0x0094 */
|
||||
/* JADX WARN: Type inference failed for: r0v1 */
|
||||
/* JADX WARN: Type inference failed for: r0v12 */
|
||||
/* JADX WARN: Type inference failed for: r0v13 */
|
||||
/* JADX WARN: Type inference failed for: r0v14 */
|
||||
/* JADX WARN: Type inference failed for: r0v2 */
|
||||
/* JADX WARN: Type inference failed for: r0v4, types: [java.net.HttpURLConnection] */
|
||||
/* JADX WARN: Type inference failed for: r0v5 */
|
||||
/* JADX WARN: Type inference failed for: r0v7 */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
private void c() {
|
||||
/*
|
||||
r7 = this;
|
||||
org.slf4j.Logger r0 = com.baidu.cloud.videocache.n.f
|
||||
java.lang.StringBuilder r1 = new java.lang.StringBuilder
|
||||
r1.<init>()
|
||||
java.lang.String r2 = "Read content info from "
|
||||
r1.append(r2)
|
||||
com.baidu.cloud.videocache.aa r2 = r7.c
|
||||
java.lang.String r2 = r2.a
|
||||
r1.append(r2)
|
||||
java.lang.String r1 = r1.toString()
|
||||
r0.debug(r1)
|
||||
r0 = 0
|
||||
r2 = 10000(0x2710, float:1.4013E-41)
|
||||
r3 = 0
|
||||
java.net.HttpURLConnection r0 = r7.a(r0, r2) // Catch: java.lang.Throwable -> L67 java.io.IOException -> L6a
|
||||
long r1 = r7.a(r0) // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
java.lang.String r4 = r0.getContentType() // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
java.io.InputStream r3 = r0.getInputStream() // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
com.baidu.cloud.videocache.aa r5 = new com.baidu.cloud.videocache.aa // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
com.baidu.cloud.videocache.aa r6 = r7.c // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
java.lang.String r6 = r6.a // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
r5.<init>(r6, r1, r4) // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
r7.c = r5 // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
com.baidu.cloud.videocache.sourcestorage.SourceInfoStorage r1 = r7.a // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
com.baidu.cloud.videocache.aa r2 = r7.c // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
java.lang.String r2 = r2.a // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
com.baidu.cloud.videocache.aa r4 = r7.c // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
r1.a(r2, r4) // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
org.slf4j.Logger r1 = com.baidu.cloud.videocache.n.f // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
java.lang.StringBuilder r2 = new java.lang.StringBuilder // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
r2.<init>() // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
java.lang.String r4 = "Source info fetched: "
|
||||
r2.append(r4) // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
com.baidu.cloud.videocache.aa r4 = r7.c // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
r2.append(r4) // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
java.lang.String r2 = r2.toString() // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
r1.debug(r2) // Catch: java.lang.Throwable -> L63 java.io.IOException -> L65
|
||||
com.baidu.cloud.videocache.z.a(r3)
|
||||
if (r0 == 0) goto L8e
|
||||
goto L8b
|
||||
L63:
|
||||
r1 = move-exception
|
||||
goto L8f
|
||||
L65:
|
||||
r1 = move-exception
|
||||
goto L6c
|
||||
L67:
|
||||
r1 = move-exception
|
||||
r0 = r3
|
||||
goto L8f
|
||||
L6a:
|
||||
r1 = move-exception
|
||||
r0 = r3
|
||||
L6c:
|
||||
org.slf4j.Logger r2 = com.baidu.cloud.videocache.n.f // Catch: java.lang.Throwable -> L63
|
||||
java.lang.StringBuilder r4 = new java.lang.StringBuilder // Catch: java.lang.Throwable -> L63
|
||||
r4.<init>() // Catch: java.lang.Throwable -> L63
|
||||
java.lang.String r5 = "Error fetching info from "
|
||||
r4.append(r5) // Catch: java.lang.Throwable -> L63
|
||||
com.baidu.cloud.videocache.aa r5 = r7.c // Catch: java.lang.Throwable -> L63
|
||||
java.lang.String r5 = r5.a // Catch: java.lang.Throwable -> L63
|
||||
r4.append(r5) // Catch: java.lang.Throwable -> L63
|
||||
java.lang.String r4 = r4.toString() // Catch: java.lang.Throwable -> L63
|
||||
r2.error(r4, r1) // Catch: java.lang.Throwable -> L63
|
||||
com.baidu.cloud.videocache.z.a(r3)
|
||||
if (r0 == 0) goto L8e
|
||||
L8b:
|
||||
r0.disconnect()
|
||||
L8e:
|
||||
return
|
||||
L8f:
|
||||
com.baidu.cloud.videocache.z.a(r3)
|
||||
if (r0 == 0) goto L97
|
||||
r0.disconnect()
|
||||
L97:
|
||||
throw r1
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.baidu.cloud.videocache.n.c():void");
|
||||
}
|
||||
|
||||
public synchronized String a() {
|
||||
if (TextUtils.isEmpty(this.c.c)) {
|
||||
c();
|
||||
}
|
||||
return this.c.c;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.Source
|
||||
public void a(long j) {
|
||||
try {
|
||||
this.d = a(j, -1);
|
||||
String contentType = this.d.getContentType();
|
||||
this.e = new BufferedInputStream(this.d.getInputStream(), UnityActivity.BLOCKLY_TYPE_NONE);
|
||||
this.c = new aa(this.c.a, a(this.d, j, this.d.getResponseCode()), contentType);
|
||||
this.a.a(this.c.a, this.c);
|
||||
} catch (IOException e) {
|
||||
throw new x("Error opening connection for " + this.c.a + " with offset " + j, e);
|
||||
}
|
||||
}
|
||||
|
||||
public String b() {
|
||||
return this.c.a;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.Source
|
||||
public void close() {
|
||||
HttpURLConnection httpURLConnection = this.d;
|
||||
if (httpURLConnection != null) {
|
||||
try {
|
||||
httpURLConnection.disconnect();
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
f.error("Error closing connection correctly. Should happen only on Android L. If anybody know how to fix it, please visithttps://github.com/danikula/AndroidVideoCache/issues/88. Until good solution is not know, just ignore this issue :(", e);
|
||||
} catch (IllegalArgumentException e2) {
|
||||
e = e2;
|
||||
throw new RuntimeException("Wait... but why? WTF!? Really shouldn't happen any more after fixing https://github.com/danikula/AndroidVideoCache/issues/43. If you read it on your device log, please, notify me danikula@gmail.com or create issue here https://github.com/danikula/AndroidVideoCache/issues.", e);
|
||||
} catch (NullPointerException e3) {
|
||||
e = e3;
|
||||
throw new RuntimeException("Wait... but why? WTF!? Really shouldn't happen any more after fixing https://github.com/danikula/AndroidVideoCache/issues/43. If you read it on your device log, please, notify me danikula@gmail.com or create issue here https://github.com/danikula/AndroidVideoCache/issues.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.Source
|
||||
public synchronized long length() {
|
||||
if (this.c.b == -2147483648L) {
|
||||
c();
|
||||
}
|
||||
return this.c.b;
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.Source
|
||||
public int read(byte[] bArr) {
|
||||
InputStream inputStream = this.e;
|
||||
if (inputStream == null) {
|
||||
throw new x("Error reading data from " + this.c.a + ": connection is absent!");
|
||||
}
|
||||
try {
|
||||
return inputStream.read(bArr, 0, bArr.length);
|
||||
} catch (InterruptedIOException e) {
|
||||
throw new p("Reading source " + this.c.a + " is interrupted", e);
|
||||
} catch (IOException e2) {
|
||||
throw new x("Error reading data from " + this.c.a, e2);
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "HttpUrlSource{sourceInfo='" + this.c + "}";
|
||||
}
|
||||
}
|
39
sources/com/baidu/cloud/videocache/o.java
Normal file
39
sources/com/baidu/cloud/videocache/o.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Proxy;
|
||||
import java.net.ProxySelector;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class o extends ProxySelector {
|
||||
private static final List d = Arrays.asList(Proxy.NO_PROXY);
|
||||
private final ProxySelector a;
|
||||
private final String b;
|
||||
private final int c;
|
||||
|
||||
o(ProxySelector proxySelector, String str, int i) {
|
||||
t.a(proxySelector);
|
||||
this.a = proxySelector;
|
||||
t.a(str);
|
||||
this.b = str;
|
||||
this.c = i;
|
||||
}
|
||||
|
||||
static void a(String str, int i) {
|
||||
ProxySelector.setDefault(new o(ProxySelector.getDefault(), str, i));
|
||||
}
|
||||
|
||||
@Override // java.net.ProxySelector
|
||||
public void connectFailed(URI uri, SocketAddress socketAddress, IOException iOException) {
|
||||
this.a.connectFailed(uri, socketAddress, iOException);
|
||||
}
|
||||
|
||||
@Override // java.net.ProxySelector
|
||||
public List select(URI uri) {
|
||||
return this.b.equals(uri.getHost()) && this.c == uri.getPort() ? d : this.a.select(uri);
|
||||
}
|
||||
}
|
8
sources/com/baidu/cloud/videocache/p.java
Normal file
8
sources/com/baidu/cloud/videocache/p.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class p extends x {
|
||||
public p(String str, Throwable th) {
|
||||
super(str, th);
|
||||
}
|
||||
}
|
99
sources/com/baidu/cloud/videocache/q.java
Normal file
99
sources/com/baidu/cloud/videocache/q.java
Normal file
@@ -0,0 +1,99 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.net.ProxySelector;
|
||||
import java.net.Socket;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class q {
|
||||
private static final Logger d = LoggerFactory.getLogger("Pinger");
|
||||
private final ExecutorService a = Executors.newSingleThreadExecutor();
|
||||
private final String b;
|
||||
private final int c;
|
||||
|
||||
q(String str, int i) {
|
||||
t.a(str);
|
||||
this.b = str;
|
||||
this.c = i;
|
||||
}
|
||||
|
||||
private List a() {
|
||||
try {
|
||||
return ProxySelector.getDefault().select(new URI(c()));
|
||||
} catch (URISyntaxException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean b() {
|
||||
n nVar = new n(c());
|
||||
try {
|
||||
byte[] bytes = "ping ok".getBytes();
|
||||
nVar.a(0L);
|
||||
byte[] bArr = new byte[bytes.length];
|
||||
nVar.read(bArr);
|
||||
boolean equals = Arrays.equals(bytes, bArr);
|
||||
d.info("Ping response: `" + new String(bArr) + "`, pinged? " + equals);
|
||||
return equals;
|
||||
} catch (x e) {
|
||||
d.error("Error reading ping response", e);
|
||||
return false;
|
||||
} finally {
|
||||
nVar.close();
|
||||
}
|
||||
}
|
||||
|
||||
private String c() {
|
||||
return String.format(Locale.US, "http://%s:%d/%s", this.b, Integer.valueOf(this.c), "ping");
|
||||
}
|
||||
|
||||
void a(Socket socket) {
|
||||
OutputStream outputStream = socket.getOutputStream();
|
||||
outputStream.write("HTTP/1.1 200 OK\n\n".getBytes());
|
||||
outputStream.write("ping ok".getBytes());
|
||||
}
|
||||
|
||||
boolean a(int i, int i2) {
|
||||
t.a(i >= 1);
|
||||
t.a(i2 > 0);
|
||||
int i3 = i2;
|
||||
int i4 = 0;
|
||||
while (i4 < i) {
|
||||
try {
|
||||
} catch (InterruptedException e) {
|
||||
e = e;
|
||||
d.error("Error pinging server due to unexpected error", e);
|
||||
} catch (ExecutionException e2) {
|
||||
e = e2;
|
||||
d.error("Error pinging server due to unexpected error", e);
|
||||
} catch (TimeoutException unused) {
|
||||
d.warn("Error pinging server (attempt: " + i4 + ", timeout: " + i3 + "). ");
|
||||
}
|
||||
if (((Boolean) this.a.submit(new s(this)).get(i3, TimeUnit.MILLISECONDS)).booleanValue()) {
|
||||
return true;
|
||||
}
|
||||
i4++;
|
||||
i3 *= 2;
|
||||
}
|
||||
String format = String.format(Locale.US, "Error pinging server (attempts: %d, max timeout: %d). If you see this message, please, report athttps://github.com/danikula/AndroidVideoCache/issues/134. Default proxies are: %s", Integer.valueOf(i4), Integer.valueOf(i3 / 2), a());
|
||||
d.error(format, new x(format));
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean a(String str) {
|
||||
return "ping".equals(str);
|
||||
}
|
||||
}
|
20
sources/com/baidu/cloud/videocache/s.java
Normal file
20
sources/com/baidu/cloud/videocache/s.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class s implements Callable {
|
||||
final /* synthetic */ q a;
|
||||
|
||||
private s(q qVar) {
|
||||
this.a = qVar;
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.Callable
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public Boolean call() {
|
||||
boolean b;
|
||||
b = this.a.b();
|
||||
return Boolean.valueOf(b);
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package com.baidu.cloud.videocache.sourcestorage;
|
||||
|
||||
import com.baidu.cloud.videocache.aa;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface SourceInfoStorage {
|
||||
void a(String str, aa aaVar);
|
||||
|
||||
aa get(String str);
|
||||
}
|
87
sources/com/baidu/cloud/videocache/sourcestorage/a.java
Normal file
87
sources/com/baidu/cloud/videocache/sourcestorage/a.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package com.baidu.cloud.videocache.sourcestorage;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import com.baidu.cloud.media.player.misc.IMediaFormat;
|
||||
import com.baidu.cloud.videocache.aa;
|
||||
import com.baidu.cloud.videocache.t;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class a extends SQLiteOpenHelper implements SourceInfoStorage {
|
||||
private static final String[] a = {FileDownloadModel.ID, "url", "length", IMediaFormat.KEY_MIME};
|
||||
|
||||
a(Context context) {
|
||||
super(context, "AndroidVideoCache.db", (SQLiteDatabase.CursorFactory) null, 1);
|
||||
t.a(context);
|
||||
}
|
||||
|
||||
private ContentValues a(aa aaVar) {
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put("url", aaVar.a);
|
||||
contentValues.put("length", Long.valueOf(aaVar.b));
|
||||
contentValues.put(IMediaFormat.KEY_MIME, aaVar.c);
|
||||
return contentValues;
|
||||
}
|
||||
|
||||
private aa a(Cursor cursor) {
|
||||
return new aa(cursor.getString(cursor.getColumnIndexOrThrow("url")), cursor.getLong(cursor.getColumnIndexOrThrow("length")), cursor.getString(cursor.getColumnIndexOrThrow(IMediaFormat.KEY_MIME)));
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.sourcestorage.SourceInfoStorage
|
||||
public void a(String str, aa aaVar) {
|
||||
t.a(str, aaVar);
|
||||
boolean z = get(str) != null;
|
||||
ContentValues a2 = a(aaVar);
|
||||
if (z) {
|
||||
getWritableDatabase().update("SourceInfo", a2, "url=?", new String[]{str});
|
||||
} else {
|
||||
getWritableDatabase().insert("SourceInfo", null, a2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.sourcestorage.SourceInfoStorage
|
||||
public aa get(String str) {
|
||||
t.a(str);
|
||||
Cursor cursor = null;
|
||||
r0 = null;
|
||||
aa a2 = null;
|
||||
try {
|
||||
Cursor query = getReadableDatabase().query("SourceInfo", a, "url=?", new String[]{str}, null, null, null);
|
||||
if (query != null) {
|
||||
try {
|
||||
if (query.moveToFirst()) {
|
||||
a2 = a(query);
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
cursor = query;
|
||||
th = th;
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
if (query != null) {
|
||||
query.close();
|
||||
}
|
||||
return a2;
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.database.sqlite.SQLiteOpenHelper
|
||||
public void onCreate(SQLiteDatabase sQLiteDatabase) {
|
||||
t.a(sQLiteDatabase);
|
||||
sQLiteDatabase.execSQL("CREATE TABLE SourceInfo (_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,url TEXT NOT NULL,mime TEXT,length INTEGER);");
|
||||
}
|
||||
|
||||
@Override // android.database.sqlite.SQLiteOpenHelper
|
||||
public void onUpgrade(SQLiteDatabase sQLiteDatabase, int i, int i2) {
|
||||
throw new IllegalStateException("Should not be called. There is no any migration");
|
||||
}
|
||||
}
|
15
sources/com/baidu/cloud/videocache/sourcestorage/b.java
Normal file
15
sources/com/baidu/cloud/videocache/sourcestorage/b.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.baidu.cloud.videocache.sourcestorage;
|
||||
|
||||
import com.baidu.cloud.videocache.aa;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class b implements SourceInfoStorage {
|
||||
@Override // com.baidu.cloud.videocache.sourcestorage.SourceInfoStorage
|
||||
public void a(String str, aa aaVar) {
|
||||
}
|
||||
|
||||
@Override // com.baidu.cloud.videocache.sourcestorage.SourceInfoStorage
|
||||
public aa get(String str) {
|
||||
return null;
|
||||
}
|
||||
}
|
14
sources/com/baidu/cloud/videocache/sourcestorage/c.java
Normal file
14
sources/com/baidu/cloud/videocache/sourcestorage/c.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.baidu.cloud.videocache.sourcestorage;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class c {
|
||||
public static SourceInfoStorage a() {
|
||||
return new b();
|
||||
}
|
||||
|
||||
public static SourceInfoStorage a(Context context) {
|
||||
return new a(context);
|
||||
}
|
||||
}
|
38
sources/com/baidu/cloud/videocache/t.java
Normal file
38
sources/com/baidu/cloud/videocache/t.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class t {
|
||||
public static Object a(Object obj) {
|
||||
if (obj != null) {
|
||||
return obj;
|
||||
}
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
public static Object a(Object obj, String str) {
|
||||
if (obj != null) {
|
||||
return obj;
|
||||
}
|
||||
throw new NullPointerException(str);
|
||||
}
|
||||
|
||||
static void a(boolean z) {
|
||||
if (!z) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
static void a(boolean z, String str) {
|
||||
if (!z) {
|
||||
throw new IllegalArgumentException(str);
|
||||
}
|
||||
}
|
||||
|
||||
public static void a(Object... objArr) {
|
||||
for (Object obj : objArr) {
|
||||
if (obj == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
175
sources/com/baidu/cloud/videocache/u.java
Normal file
175
sources/com/baidu/cloud/videocache/u.java
Normal file
@@ -0,0 +1,175 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
||||
import java.lang.Thread;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class u {
|
||||
private static final Logger i = LoggerFactory.getLogger("ProxyCache");
|
||||
private final Source a;
|
||||
private final Cache b;
|
||||
protected final AtomicInteger e;
|
||||
private volatile Thread f;
|
||||
private volatile boolean g;
|
||||
private final Object c = new Object();
|
||||
protected final Object d = new Object();
|
||||
protected volatile int h = -1;
|
||||
|
||||
public u(Source source, Cache cache) {
|
||||
t.a(source);
|
||||
this.a = source;
|
||||
t.a(cache);
|
||||
this.b = cache;
|
||||
this.e = new AtomicInteger();
|
||||
}
|
||||
|
||||
private void f() {
|
||||
int i2 = this.e.get();
|
||||
if (i2 < 1) {
|
||||
return;
|
||||
}
|
||||
this.e.set(0);
|
||||
throw new x("Error reading source " + i2 + " times");
|
||||
}
|
||||
|
||||
private synchronized void g() {
|
||||
boolean z = (this.f == null || this.f.getState() == Thread.State.TERMINATED) ? false : true;
|
||||
if (!this.g && !this.b.b() && !z) {
|
||||
this.f = new Thread(new w(this), "Source reader for " + this.a);
|
||||
this.f.start();
|
||||
}
|
||||
}
|
||||
|
||||
private void h() {
|
||||
synchronized (this.c) {
|
||||
try {
|
||||
try {
|
||||
this.c.wait(1000L);
|
||||
} catch (InterruptedException e) {
|
||||
throw new x("Waiting source data is interrupted!", e);
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void i() {
|
||||
long j = -1;
|
||||
long j2 = 0;
|
||||
try {
|
||||
j2 = this.b.available();
|
||||
this.a.a(j2);
|
||||
j = this.a.length();
|
||||
byte[] bArr = new byte[UnityActivity.BLOCKLY_TYPE_NONE];
|
||||
while (true) {
|
||||
int read = this.a.read(bArr);
|
||||
if (read == -1) {
|
||||
c();
|
||||
b();
|
||||
break;
|
||||
}
|
||||
synchronized (this.d) {
|
||||
if (d()) {
|
||||
return;
|
||||
} else {
|
||||
this.b.a(bArr, read);
|
||||
}
|
||||
}
|
||||
j2 += read;
|
||||
a(j2, j);
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int a(byte[] bArr, long j, int i2) {
|
||||
z.a(bArr, j, i2);
|
||||
while (!this.b.b() && this.b.available() < i2 + j && !this.g) {
|
||||
g();
|
||||
h();
|
||||
f();
|
||||
}
|
||||
int a = this.b.a(bArr, j, i2);
|
||||
if (this.b.b() && this.h != 100) {
|
||||
this.h = 100;
|
||||
a(100);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
public void a() {
|
||||
synchronized (this.d) {
|
||||
i.debug("Shutdown proxy for " + this.a);
|
||||
try {
|
||||
this.g = true;
|
||||
if (this.f != null) {
|
||||
this.f.interrupt();
|
||||
}
|
||||
this.b.close();
|
||||
} catch (x e) {
|
||||
a(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void a(int i2) {
|
||||
throw null;
|
||||
}
|
||||
|
||||
protected void a(long j, long j2) {
|
||||
b(j, j2);
|
||||
synchronized (this.c) {
|
||||
this.c.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
protected final void a(Throwable th) {
|
||||
if (th instanceof p) {
|
||||
i.debug("ProxyCache is interrupted");
|
||||
} else {
|
||||
i.error("ProxyCache error", th);
|
||||
}
|
||||
}
|
||||
|
||||
protected void b() {
|
||||
this.h = 100;
|
||||
a(this.h);
|
||||
}
|
||||
|
||||
protected void b(long j, long j2) {
|
||||
int i2 = (j2 > 0L ? 1 : (j2 == 0L ? 0 : -1)) == 0 ? 100 : (int) ((j / j2) * 100.0f);
|
||||
boolean z = i2 != this.h;
|
||||
if ((j2 >= 0) && z) {
|
||||
a(i2);
|
||||
}
|
||||
this.h = i2;
|
||||
}
|
||||
|
||||
protected void c() {
|
||||
synchronized (this.d) {
|
||||
if (!d() && this.b.available() == this.a.length()) {
|
||||
this.b.a();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean d() {
|
||||
return Thread.currentThread().isInterrupted() || this.g;
|
||||
}
|
||||
|
||||
protected void e() {
|
||||
try {
|
||||
this.a.close();
|
||||
} catch (x e) {
|
||||
a(new x("Error closing source " + this.a, e));
|
||||
}
|
||||
}
|
||||
}
|
15
sources/com/baidu/cloud/videocache/w.java
Normal file
15
sources/com/baidu/cloud/videocache/w.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class w implements Runnable {
|
||||
final /* synthetic */ u a;
|
||||
|
||||
private w(u uVar) {
|
||||
this.a = uVar;
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
this.a.i();
|
||||
}
|
||||
}
|
12
sources/com/baidu/cloud/videocache/x.java
Normal file
12
sources/com/baidu/cloud/videocache/x.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class x extends Exception {
|
||||
public x(String str) {
|
||||
super(str + ". Version: 2.7.1");
|
||||
}
|
||||
|
||||
public x(String str, Throwable th) {
|
||||
super(str + ". Version: 2.7.1", th);
|
||||
}
|
||||
}
|
17
sources/com/baidu/cloud/videocache/y.java
Normal file
17
sources/com/baidu/cloud/videocache/y.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class y {
|
||||
public static f a(String str, a aVar) {
|
||||
t.a(str);
|
||||
t.a(aVar);
|
||||
int a = ad.a(str);
|
||||
if (a == 0) {
|
||||
return new f(new n(str, aVar.d, aVar.e), new com.baidu.cloud.videocache.file.a(aVar.a(str), aVar.c));
|
||||
}
|
||||
if (a == 1) {
|
||||
return new d(new e(str, aVar.d, aVar.e), new com.baidu.cloud.videocache.file.a(aVar.a(str), aVar.c));
|
||||
}
|
||||
throw new x("Unsupported media type: " + a);
|
||||
}
|
||||
}
|
57
sources/com/baidu/cloud/videocache/z.java
Normal file
57
sources/com/baidu/cloud/videocache/z.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package com.baidu.cloud.videocache;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class z {
|
||||
private static final Logger a = LoggerFactory.getLogger("ProxyCacheUtils");
|
||||
|
||||
static String a(String str) {
|
||||
MimeTypeMap singleton = MimeTypeMap.getSingleton();
|
||||
String fileExtensionFromUrl = MimeTypeMap.getFileExtensionFromUrl(str);
|
||||
if (TextUtils.isEmpty(fileExtensionFromUrl)) {
|
||||
return null;
|
||||
}
|
||||
return singleton.getMimeTypeFromExtension(fileExtensionFromUrl);
|
||||
}
|
||||
|
||||
static void a(Closeable closeable) {
|
||||
if (closeable != null) {
|
||||
try {
|
||||
closeable.close();
|
||||
} catch (IOException e) {
|
||||
a.error("Error closing resource", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void a(byte[] bArr, long j, int i) {
|
||||
t.a(bArr, "Buffer must be not null!");
|
||||
t.a(j >= 0, "Data offset must be positive!");
|
||||
t.a(i >= 0 && i <= bArr.length, "Length must be in range [0..buffer.length]");
|
||||
}
|
||||
|
||||
public static String b(String str) {
|
||||
try {
|
||||
return URLEncoder.encode(str, "utf-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException("Error encoding url", e);
|
||||
}
|
||||
}
|
||||
|
||||
static String c(String str) {
|
||||
try {
|
||||
return URLDecoder.decode(str, "utf-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException("Error decoding url", e);
|
||||
}
|
||||
}
|
||||
}
|
5
sources/com/baidu/license/INotProguard.java
Normal file
5
sources/com/baidu/license/INotProguard.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package com.baidu.license;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface INotProguard {
|
||||
}
|
27
sources/com/baidu/license/LicenseManager.java
Normal file
27
sources/com/baidu/license/LicenseManager.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.baidu.license;
|
||||
|
||||
import android.content.Context;
|
||||
import com.baidu.license.util.oi;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class LicenseManager implements INotProguard {
|
||||
private static Context a;
|
||||
|
||||
public static void a(Context context, String str) {
|
||||
a = context;
|
||||
oi.a(context, str);
|
||||
SDKHttpConfig.a(str);
|
||||
SDKHttpConfig.b(context.getPackageName());
|
||||
SDKHttpConfig.c("2.7.1");
|
||||
oi.a(context);
|
||||
}
|
||||
|
||||
public static boolean b() {
|
||||
oi.a(a(), SDKHttpConfig.a());
|
||||
return oi.b();
|
||||
}
|
||||
|
||||
public static Context a() {
|
||||
return a;
|
||||
}
|
||||
}
|
20
sources/com/baidu/license/SDKHttpConfig.java
Normal file
20
sources/com/baidu/license/SDKHttpConfig.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.baidu.license;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SDKHttpConfig implements INotProguard {
|
||||
private static String a = "";
|
||||
|
||||
public static String a() {
|
||||
return a;
|
||||
}
|
||||
|
||||
public static void b(String str) {
|
||||
}
|
||||
|
||||
public static void c(String str) {
|
||||
}
|
||||
|
||||
public static void a(String str) {
|
||||
a = str;
|
||||
}
|
||||
}
|
38
sources/com/baidu/license/api/ApiService.java
Normal file
38
sources/com/baidu/license/api/ApiService.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.baidu.license.api;
|
||||
|
||||
import com.baidu.license.template.bean.TemplateListModel;
|
||||
import java.util.Map;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface ApiService {
|
||||
@POST("/v1/sdk/filter?list")
|
||||
Call<ResponseBody> reqFilter(@Body Map<String, Object> map);
|
||||
|
||||
@POST("v1/sdk/subtitle?get")
|
||||
Call<ResponseBody> reqGetResolveResult(@Body Map<String, Object> map);
|
||||
|
||||
@POST("/v1/sdk/license?valid")
|
||||
Call<Object> reqLicenseValid(@Body Map<String, Object> map);
|
||||
|
||||
@POST("/v1/sdk/face")
|
||||
Call<Object> reqOneSticker(@Body Map<String, Object> map);
|
||||
|
||||
@POST("/v1/sdk/subtitle?process")
|
||||
Call<ResponseBody> reqStartResolve(@Body Map<String, Object> map);
|
||||
|
||||
@POST("/v1/sdk/face?list")
|
||||
Call<Object> reqStickerList(@Body Map<String, Object> map);
|
||||
|
||||
@POST("/v1/sdk/template?list")
|
||||
Call<TemplateListModel> reqTemplateList(@Body Map<String, Object> map);
|
||||
|
||||
@POST("/v1/sdk/transition?list")
|
||||
Call<ResponseBody> reqTransitions(@Body Map<String, Object> map);
|
||||
|
||||
@POST("/v1/sdk/subtitle?apply")
|
||||
Call<ResponseBody> reqUploadParams(@Body Map<String, Object> map);
|
||||
}
|
229
sources/com/baidu/license/download/CaptureDownloadService.java
Normal file
229
sources/com/baidu/license/download/CaptureDownloadService.java
Normal file
@@ -0,0 +1,229 @@
|
||||
package com.baidu.license.download;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import com.baidu.license.download.DownloadRequest;
|
||||
import com.baidu.license.download.base.DownloadCallback;
|
||||
import com.baidu.license.download.exception.DownloadException;
|
||||
import com.baidu.license.download.utils.CommonUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CaptureDownloadService extends Service {
|
||||
private DownloadManager a;
|
||||
|
||||
private void a(String str) {
|
||||
this.a.a(str);
|
||||
}
|
||||
|
||||
private void b(String str) {
|
||||
this.a.b(str);
|
||||
}
|
||||
|
||||
@Override // android.app.Service
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // android.app.Service
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
this.a = DownloadManager.c();
|
||||
}
|
||||
|
||||
@Override // android.app.Service
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
this.a.b();
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
|
||||
/* JADX WARN: Code restructure failed: missing block: B:5:0x0034, code lost:
|
||||
|
||||
if (r0.equals("com.baidu.cloudar.download.ACTION_DOWNLOAD") != false) goto L22;
|
||||
*/
|
||||
@Override // android.app.Service
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public int onStartCommand(android.content.Intent r12, int r13, int r14) {
|
||||
/*
|
||||
r11 = this;
|
||||
if (r12 == 0) goto L7e
|
||||
java.lang.String r0 = r12.getAction()
|
||||
r1 = 0
|
||||
java.lang.String r2 = "extra_position"
|
||||
int r2 = r12.getIntExtra(r2, r1)
|
||||
com.baidu.license.download.nx r3 = new com.baidu.license.download.nx
|
||||
r3.<init>()
|
||||
java.lang.String r4 = "extra_file_info"
|
||||
java.lang.String r4 = r12.getStringExtra(r4)
|
||||
r3.a(r4)
|
||||
java.lang.String r4 = "extra_tag"
|
||||
java.lang.String r4 = r12.getStringExtra(r4)
|
||||
r5 = -1
|
||||
int r6 = r0.hashCode()
|
||||
r7 = 4
|
||||
r8 = 3
|
||||
r9 = 2
|
||||
r10 = 1
|
||||
switch(r6) {
|
||||
case -1845641145: goto L55;
|
||||
case -1229466579: goto L4b;
|
||||
case -540402171: goto L41;
|
||||
case 1657148651: goto L37;
|
||||
case 1915551059: goto L2e;
|
||||
default: goto L2d;
|
||||
}
|
||||
L2d:
|
||||
goto L5f
|
||||
L2e:
|
||||
java.lang.String r6 = "com.baidu.cloudar.download.ACTION_DOWNLOAD"
|
||||
boolean r0 = r0.equals(r6)
|
||||
if (r0 == 0) goto L5f
|
||||
goto L60
|
||||
L37:
|
||||
java.lang.String r1 = "com.baidu.cloudar.download.ACTION_PAUSE"
|
||||
boolean r0 = r0.equals(r1)
|
||||
if (r0 == 0) goto L5f
|
||||
r1 = 1
|
||||
goto L60
|
||||
L41:
|
||||
java.lang.String r1 = "com.baidu.cloudar.download.ACTION_CANCEL"
|
||||
boolean r0 = r0.equals(r1)
|
||||
if (r0 == 0) goto L5f
|
||||
r1 = 2
|
||||
goto L60
|
||||
L4b:
|
||||
java.lang.String r1 = "com.baidu.cloudar.download.ACTION_PAUSE_ALL"
|
||||
boolean r0 = r0.equals(r1)
|
||||
if (r0 == 0) goto L5f
|
||||
r1 = 3
|
||||
goto L60
|
||||
L55:
|
||||
java.lang.String r1 = "com.baidu.cloudar.download.ACTION_CANCEL_ALL"
|
||||
boolean r0 = r0.equals(r1)
|
||||
if (r0 == 0) goto L5f
|
||||
r1 = 4
|
||||
goto L60
|
||||
L5f:
|
||||
r1 = -1
|
||||
L60:
|
||||
if (r1 == 0) goto L7b
|
||||
if (r1 == r10) goto L77
|
||||
if (r1 == r9) goto L73
|
||||
if (r1 == r8) goto L6f
|
||||
if (r1 == r7) goto L6b
|
||||
goto L7e
|
||||
L6b:
|
||||
r11.a()
|
||||
goto L7e
|
||||
L6f:
|
||||
r11.b()
|
||||
goto L7e
|
||||
L73:
|
||||
r11.a(r4)
|
||||
goto L7e
|
||||
L77:
|
||||
r11.b(r4)
|
||||
goto L7e
|
||||
L7b:
|
||||
r11.a(r2, r3, r4)
|
||||
L7e:
|
||||
int r12 = super.onStartCommand(r12, r13, r14)
|
||||
return r12
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.baidu.license.download.CaptureDownloadService.onStartCommand(android.content.Intent, int, int):int");
|
||||
}
|
||||
|
||||
private void a() {
|
||||
this.a.a();
|
||||
}
|
||||
|
||||
private void b() {
|
||||
this.a.b();
|
||||
}
|
||||
|
||||
private void a(int i, nx nxVar, String str) {
|
||||
DownloadRequest.Builder builder = new DownloadRequest.Builder();
|
||||
builder.a(nxVar.b());
|
||||
this.a.a(builder.a(), str, new ProgressCallback(i, nxVar, getApplicationContext()));
|
||||
}
|
||||
|
||||
public static class ProgressCallback extends DownloadCallback {
|
||||
private int a;
|
||||
private nx b;
|
||||
private LocalBroadcastManager c;
|
||||
private long d;
|
||||
private int e;
|
||||
|
||||
public ProgressCallback(int i, nx nxVar, Context context) {
|
||||
this.a = i;
|
||||
this.b = nxVar;
|
||||
this.c = LocalBroadcastManager.a(context);
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadCallback
|
||||
public void a(long j, long j2, int i) {
|
||||
if (this.d == 0) {
|
||||
this.d = System.currentTimeMillis();
|
||||
}
|
||||
this.b.b(3);
|
||||
this.b.a(i);
|
||||
this.b.b(CommonUtils.a(j, j2));
|
||||
if (a(i)) {
|
||||
a(this.b);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadCallback
|
||||
public void b() {
|
||||
this.b.b(0);
|
||||
this.b.a(0);
|
||||
this.b.b("");
|
||||
a(this.b);
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadCallback
|
||||
public void c() {
|
||||
this.b.b(4);
|
||||
a(this.b);
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadCallback
|
||||
public void a(String str) {
|
||||
this.b.b(6);
|
||||
this.b.a(100);
|
||||
this.b.c(str);
|
||||
a(this.b);
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadCallback
|
||||
public void a(DownloadException downloadException) {
|
||||
downloadException.printStackTrace();
|
||||
this.b.b(5);
|
||||
a(this.b);
|
||||
}
|
||||
|
||||
private void a(nx nxVar) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction("com.baidu.cloudar.download.ACTION_BROAD_CAST");
|
||||
intent.putExtra("extra_position", this.a);
|
||||
intent.putExtra("extra_file_info", nxVar.a().toString());
|
||||
this.c.a(intent);
|
||||
}
|
||||
|
||||
private boolean a(int i) {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
if (currentTimeMillis - this.d <= 300 || i == this.e) {
|
||||
return false;
|
||||
}
|
||||
this.d = currentTimeMillis;
|
||||
this.e = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
138
sources/com/baidu/license/download/DownloadManager.java
Normal file
138
sources/com/baidu/license/download/DownloadManager.java
Normal file
@@ -0,0 +1,138 @@
|
||||
package com.baidu.license.download;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import com.baidu.license.download.a.a;
|
||||
import com.baidu.license.download.a.trw;
|
||||
import com.baidu.license.download.base.DownloadCallback;
|
||||
import com.baidu.license.download.base.DownloadStatusDelivery;
|
||||
import com.baidu.license.download.base.Downloader;
|
||||
import com.baidu.license.download.utils.LogUtils;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DownloadManager implements Downloader.OnDownloaderDestroyedListener {
|
||||
private static DownloadManager f;
|
||||
private oi b;
|
||||
private ExecutorService c;
|
||||
private DownloadStatusDelivery d;
|
||||
private Handler e = new Handler(Looper.getMainLooper());
|
||||
private Map<String, Downloader> a = new LinkedHashMap();
|
||||
|
||||
private DownloadManager() {
|
||||
a(new oi());
|
||||
}
|
||||
|
||||
public static DownloadManager c() {
|
||||
if (f == null) {
|
||||
synchronized (DownloadManager.class) {
|
||||
if (f == null) {
|
||||
f = new DownloadManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
private boolean d(String str) {
|
||||
Downloader downloader;
|
||||
if (!this.a.containsKey(str) || (downloader = this.a.get(str)) == null) {
|
||||
return false;
|
||||
}
|
||||
if (downloader.isRunning()) {
|
||||
LogUtils.a("DownloadInfo has been started!");
|
||||
return true;
|
||||
}
|
||||
LogUtils.a("DownloadInfo not started!");
|
||||
return false;
|
||||
}
|
||||
|
||||
public void b(String str) {
|
||||
String c = c(str);
|
||||
if (this.a.containsKey(c)) {
|
||||
Downloader downloader = this.a.get(c);
|
||||
if (downloader != null && downloader.isRunning()) {
|
||||
downloader.pause();
|
||||
}
|
||||
this.a.remove(c);
|
||||
}
|
||||
}
|
||||
|
||||
private void a(oi oiVar) {
|
||||
if (oiVar.b() > oiVar.a()) {
|
||||
throw new IllegalArgumentException("thread num must < max thread num");
|
||||
}
|
||||
this.b = oiVar;
|
||||
this.c = Executors.newFixedThreadPool(this.b.a());
|
||||
this.d = new trw(this.e);
|
||||
}
|
||||
|
||||
private String c(String str) {
|
||||
if (str != null) {
|
||||
return String.valueOf(str.hashCode());
|
||||
}
|
||||
throw new IllegalArgumentException("Tag can't be null!");
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.Downloader.OnDownloaderDestroyedListener
|
||||
public void a(final String str, Downloader downloader) {
|
||||
this.e.post(new Runnable() { // from class: com.baidu.license.download.DownloadManager.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (DownloadManager.this.a.containsKey(str)) {
|
||||
DownloadManager.this.a.remove(str);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void b() {
|
||||
this.e.post(new Runnable() { // from class: com.baidu.license.download.DownloadManager.2
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
for (Downloader downloader : DownloadManager.this.a.values()) {
|
||||
if (downloader != null && downloader.isRunning()) {
|
||||
downloader.pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void a(DownloadRequest downloadRequest, String str, DownloadCallback downloadCallback) {
|
||||
String c = c(str);
|
||||
if (d(c)) {
|
||||
return;
|
||||
}
|
||||
a aVar = new a(downloadRequest, new com.baidu.license.download.a.nx(this.d, downloadCallback), this.c, c, this.b, this);
|
||||
this.a.put(c, aVar);
|
||||
aVar.start();
|
||||
}
|
||||
|
||||
public void a(String str) {
|
||||
String c = c(str);
|
||||
if (this.a.containsKey(c)) {
|
||||
Downloader downloader = this.a.get(c);
|
||||
if (downloader != null) {
|
||||
downloader.cancel();
|
||||
}
|
||||
this.a.remove(c);
|
||||
}
|
||||
}
|
||||
|
||||
public void a() {
|
||||
this.e.post(new Runnable() { // from class: com.baidu.license.download.DownloadManager.3
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
for (Downloader downloader : DownloadManager.this.a.values()) {
|
||||
if (downloader != null && downloader.isRunning()) {
|
||||
downloader.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
49
sources/com/baidu/license/download/DownloadRequest.java
Normal file
49
sources/com/baidu/license/download/DownloadRequest.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package com.baidu.license.download;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.baidu.license.download.utils.FileUtils;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DownloadRequest {
|
||||
private String a;
|
||||
private File b;
|
||||
private CharSequence c;
|
||||
|
||||
public static class Builder {
|
||||
private String a;
|
||||
private File b;
|
||||
private CharSequence c;
|
||||
private CharSequence d;
|
||||
|
||||
public Builder a(String str) {
|
||||
this.a = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DownloadRequest a() {
|
||||
return new DownloadRequest(this.a, this.b, this.c, this.d);
|
||||
}
|
||||
}
|
||||
|
||||
public File a() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public CharSequence b() {
|
||||
if (TextUtils.isEmpty(this.c)) {
|
||||
this.c = FileUtils.a(c());
|
||||
}
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public String c() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
private DownloadRequest(String str, File file, CharSequence charSequence, CharSequence charSequence2) {
|
||||
this.a = str;
|
||||
this.b = file;
|
||||
this.c = charSequence;
|
||||
}
|
||||
}
|
255
sources/com/baidu/license/download/a/a.java
Normal file
255
sources/com/baidu/license/download/a/a.java
Normal file
@@ -0,0 +1,255 @@
|
||||
package com.baidu.license.download.a;
|
||||
|
||||
import com.baidu.license.download.DownloadRequest;
|
||||
import com.baidu.license.download.base.DownloadResponse;
|
||||
import com.baidu.license.download.base.DownloadTask;
|
||||
import com.baidu.license.download.base.Downloader;
|
||||
import com.baidu.license.download.base.HttpConnectTask;
|
||||
import com.baidu.license.download.exception.DownloadException;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/* compiled from: DownloaderImpl.java */
|
||||
/* loaded from: classes.dex */
|
||||
public final class a implements DownloadTask.OnDownloadListener, Downloader, HttpConnectTask.OnConnectListener {
|
||||
private DownloadRequest a;
|
||||
private DownloadResponse b;
|
||||
private Executor c;
|
||||
private String d;
|
||||
private com.baidu.license.download.oi e;
|
||||
private Downloader.OnDownloaderDestroyedListener f;
|
||||
private int g;
|
||||
private oi h;
|
||||
private HttpConnectTask i;
|
||||
private List<DownloadTask> j = new LinkedList();
|
||||
|
||||
public a(DownloadRequest downloadRequest, DownloadResponse downloadResponse, Executor executor, String str, com.baidu.license.download.oi oiVar, Downloader.OnDownloaderDestroyedListener onDownloaderDestroyedListener) {
|
||||
this.a = downloadRequest;
|
||||
this.b = downloadResponse;
|
||||
this.c = executor;
|
||||
this.d = str;
|
||||
this.e = oiVar;
|
||||
this.f = onDownloaderDestroyedListener;
|
||||
this.h = new oi(this.a.b().toString(), this.a.c(), this.a.a());
|
||||
}
|
||||
|
||||
private void c() {
|
||||
File file = new File(this.h.b(), this.h.a());
|
||||
if (file.exists() && file.isFile()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.HttpConnectTask.OnConnectListener
|
||||
public final void a(long j, long j2, boolean z) {
|
||||
if (this.i.isCanceled()) {
|
||||
l();
|
||||
return;
|
||||
}
|
||||
this.g = 103;
|
||||
this.b.a(j, j2, z);
|
||||
this.h.a(z);
|
||||
this.h.a(j2);
|
||||
this.g = 104;
|
||||
this.j.clear();
|
||||
if (z) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
int b = this.e.b();
|
||||
int i = 0;
|
||||
int i2 = 0;
|
||||
while (i2 < b) {
|
||||
long j3 = j2 / b;
|
||||
long j4 = j3 * i2;
|
||||
arrayList.add(new e(i2, this.d, this.a.c(), j4, i2 == b + (-1) ? j2 : (j3 + j4) - 1));
|
||||
i2++;
|
||||
}
|
||||
Iterator it = arrayList.iterator();
|
||||
while (it.hasNext()) {
|
||||
i = (int) (i + ((e) it.next()).d());
|
||||
}
|
||||
this.h.b(i);
|
||||
Iterator it2 = arrayList.iterator();
|
||||
while (it2.hasNext()) {
|
||||
this.j.add(new c(this.h, (e) it2.next(), this));
|
||||
}
|
||||
} else {
|
||||
this.j.add(new d(this.h, new e(this.d, this.a.c()), this));
|
||||
}
|
||||
Iterator<DownloadTask> it3 = this.j.iterator();
|
||||
while (it3.hasNext()) {
|
||||
this.c.execute(it3.next());
|
||||
}
|
||||
}
|
||||
|
||||
public final void b() {
|
||||
this.f.a(this.d, this);
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.Downloader
|
||||
public final void cancel() {
|
||||
HttpConnectTask httpConnectTask = this.i;
|
||||
if (httpConnectTask != null) {
|
||||
httpConnectTask.cancel();
|
||||
}
|
||||
Iterator<DownloadTask> it = this.j.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().cancel();
|
||||
}
|
||||
if (this.g != 104) {
|
||||
j();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.HttpConnectTask.OnConnectListener
|
||||
public final void i() {
|
||||
this.g = 102;
|
||||
this.b.i();
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.Downloader
|
||||
public final boolean isRunning() {
|
||||
int i = this.g;
|
||||
return i == 101 || i == 102 || i == 103 || i == 104;
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadTask.OnDownloadListener
|
||||
public final void j() {
|
||||
boolean z;
|
||||
Iterator<DownloadTask> it = this.j.iterator();
|
||||
while (true) {
|
||||
if (!it.hasNext()) {
|
||||
z = true;
|
||||
break;
|
||||
} else if (it.next().h()) {
|
||||
z = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (z) {
|
||||
c();
|
||||
this.g = 107;
|
||||
this.b.j();
|
||||
b();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadTask.OnDownloadListener
|
||||
public final void k() {
|
||||
boolean z;
|
||||
Iterator<DownloadTask> it = this.j.iterator();
|
||||
while (true) {
|
||||
if (!it.hasNext()) {
|
||||
z = true;
|
||||
break;
|
||||
} else if (it.next().h()) {
|
||||
z = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (z) {
|
||||
this.g = 106;
|
||||
this.b.k();
|
||||
b();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.HttpConnectTask.OnConnectListener
|
||||
public final void l() {
|
||||
c();
|
||||
this.g = 107;
|
||||
this.b.l();
|
||||
b();
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.Downloader
|
||||
public final void pause() {
|
||||
HttpConnectTask httpConnectTask = this.i;
|
||||
if (httpConnectTask != null) {
|
||||
httpConnectTask.pause();
|
||||
}
|
||||
Iterator<DownloadTask> it = this.j.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().pause();
|
||||
}
|
||||
if (this.g != 104) {
|
||||
k();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.Downloader
|
||||
public final void start() {
|
||||
this.g = 101;
|
||||
this.b.m();
|
||||
this.i = new b(this.a.c(), this);
|
||||
this.c.execute(this.i);
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadTask.OnDownloadListener
|
||||
public final void b(DownloadException downloadException) {
|
||||
boolean z;
|
||||
Iterator<DownloadTask> it = this.j.iterator();
|
||||
while (true) {
|
||||
if (!it.hasNext()) {
|
||||
z = true;
|
||||
break;
|
||||
} else if (it.next().h()) {
|
||||
z = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (z) {
|
||||
this.g = 108;
|
||||
this.b.b(downloadException);
|
||||
b();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.HttpConnectTask.OnConnectListener
|
||||
public final void a() {
|
||||
k();
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.HttpConnectTask.OnConnectListener
|
||||
public final void a(DownloadException downloadException) {
|
||||
if (this.i.isCanceled()) {
|
||||
l();
|
||||
} else {
|
||||
if (this.i.i()) {
|
||||
k();
|
||||
return;
|
||||
}
|
||||
this.g = 108;
|
||||
this.b.a(downloadException);
|
||||
b();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadTask.OnDownloadListener
|
||||
public final void a(long j, long j2) {
|
||||
this.b.a(j, j2, (int) ((100 * j) / j2));
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadTask.OnDownloadListener
|
||||
public final void a(String str) {
|
||||
boolean z;
|
||||
Iterator<DownloadTask> it = this.j.iterator();
|
||||
while (true) {
|
||||
if (!it.hasNext()) {
|
||||
z = true;
|
||||
break;
|
||||
} else if (!it.next().g()) {
|
||||
z = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (z) {
|
||||
this.g = 105;
|
||||
this.b.a(str);
|
||||
b();
|
||||
}
|
||||
}
|
||||
}
|
152
sources/com/baidu/license/download/a/b.java
Normal file
152
sources/com/baidu/license/download/a/b.java
Normal file
@@ -0,0 +1,152 @@
|
||||
package com.baidu.license.download.a;
|
||||
|
||||
import android.os.Process;
|
||||
import android.text.TextUtils;
|
||||
import com.baidu.license.download.base.HttpConnectTask;
|
||||
import com.baidu.license.download.exception.DownloadException;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.ProtocolException;
|
||||
import java.net.URL;
|
||||
|
||||
/* compiled from: HttpConnectTaskImpl.java */
|
||||
/* loaded from: classes.dex */
|
||||
public final class b implements HttpConnectTask {
|
||||
private final String a;
|
||||
private final HttpConnectTask.OnConnectListener b;
|
||||
private volatile int c;
|
||||
private volatile long d;
|
||||
|
||||
public b(String str, HttpConnectTask.OnConnectListener onConnectListener) {
|
||||
this.a = str;
|
||||
this.b = onConnectListener;
|
||||
}
|
||||
|
||||
private void a(HttpURLConnection httpURLConnection, boolean z) {
|
||||
String headerField = httpURLConnection.getHeaderField("Content-Length");
|
||||
long contentLength = (TextUtils.isEmpty(headerField) || headerField.equals("0") || headerField.equals("-1")) ? httpURLConnection.getContentLength() : Long.parseLong(headerField);
|
||||
if (contentLength <= 0) {
|
||||
String headerField2 = httpURLConnection.getHeaderField("Ohc-File-Size");
|
||||
contentLength = (TextUtils.isEmpty(headerField2) || headerField2.equals("0") || headerField2.equals("-1")) ? httpURLConnection.getContentLength() : Long.parseLong(headerField2);
|
||||
if (contentLength <= 0) {
|
||||
throw new DownloadException(108, "length <= 0");
|
||||
}
|
||||
}
|
||||
a();
|
||||
this.c = 103;
|
||||
this.b.a(System.currentTimeMillis() - this.d, contentLength, z);
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.HttpConnectTask
|
||||
public final void cancel() {
|
||||
this.c = 107;
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.HttpConnectTask
|
||||
public final boolean i() {
|
||||
return this.c == 106;
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.HttpConnectTask
|
||||
public final boolean isCanceled() {
|
||||
return this.c == 107;
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.HttpConnectTask
|
||||
public final void pause() {
|
||||
this.c = 106;
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
IOException e;
|
||||
ProtocolException e2;
|
||||
HttpURLConnection httpURLConnection;
|
||||
Process.setThreadPriority(10);
|
||||
this.c = 102;
|
||||
this.b.i();
|
||||
try {
|
||||
this.d = System.currentTimeMillis();
|
||||
HttpURLConnection httpURLConnection2 = null;
|
||||
try {
|
||||
try {
|
||||
try {
|
||||
httpURLConnection = (HttpURLConnection) new URL(this.a).openConnection();
|
||||
} catch (ProtocolException e3) {
|
||||
e2 = e3;
|
||||
} catch (IOException e4) {
|
||||
e = e4;
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
if (0 != 0) {
|
||||
httpURLConnection2.disconnect();
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
try {
|
||||
httpURLConnection.setConnectTimeout(4000);
|
||||
httpURLConnection.setReadTimeout(4000);
|
||||
httpURLConnection.setRequestMethod("GET");
|
||||
httpURLConnection.setRequestProperty("Range", "bytes=0-");
|
||||
int responseCode = httpURLConnection.getResponseCode();
|
||||
if (responseCode == 200) {
|
||||
a(httpURLConnection, false);
|
||||
} else {
|
||||
if (responseCode != 206) {
|
||||
throw new DownloadException(108, "UnSupported response code:".concat(String.valueOf(responseCode)));
|
||||
}
|
||||
a(httpURLConnection, true);
|
||||
}
|
||||
if (httpURLConnection != null) {
|
||||
httpURLConnection.disconnect();
|
||||
}
|
||||
} catch (ProtocolException e5) {
|
||||
e2 = e5;
|
||||
throw new DownloadException(108, "Protocol error", e2);
|
||||
} catch (IOException e6) {
|
||||
e = e6;
|
||||
throw new DownloadException(108, "IO error", e);
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
}
|
||||
} catch (MalformedURLException e7) {
|
||||
throw new DownloadException(108, "Bad url.", e7);
|
||||
}
|
||||
} catch (DownloadException e8) {
|
||||
switch (e8.getErrorCode()) {
|
||||
case 106:
|
||||
synchronized (this.b) {
|
||||
this.c = 106;
|
||||
this.b.a();
|
||||
return;
|
||||
}
|
||||
case 107:
|
||||
synchronized (this.b) {
|
||||
this.c = 107;
|
||||
this.b.l();
|
||||
return;
|
||||
}
|
||||
case 108:
|
||||
synchronized (this.b) {
|
||||
this.c = 108;
|
||||
this.b.a(e8);
|
||||
return;
|
||||
}
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown state");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void a() {
|
||||
if (!isCanceled()) {
|
||||
if (i()) {
|
||||
throw new DownloadException(106, "Connection Paused!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new DownloadException(107, "Connection Canceled!");
|
||||
}
|
||||
}
|
39
sources/com/baidu/license/download/a/c.java
Normal file
39
sources/com/baidu/license/download/a/c.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package com.baidu.license.download.a;
|
||||
|
||||
import com.baidu.license.download.base.DownloadTask;
|
||||
import java.io.File;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/* compiled from: MultiDownloadTask.java */
|
||||
/* loaded from: classes.dex */
|
||||
public final class c extends uiw {
|
||||
public c(oi oiVar, e eVar, DownloadTask.OnDownloadListener onDownloadListener) {
|
||||
super(oiVar, eVar, onDownloadListener);
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.a.uiw
|
||||
protected final int a() {
|
||||
return 206;
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.a.uiw
|
||||
protected final Map<String, String> a(e eVar) {
|
||||
HashMap hashMap = new HashMap();
|
||||
hashMap.put("Range", "bytes=" + (eVar.b() + eVar.d()) + "-" + eVar.c());
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.a.uiw
|
||||
protected final String b() {
|
||||
return c.class.getSimpleName();
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.a.uiw
|
||||
protected final RandomAccessFile a(File file, String str, long j) {
|
||||
RandomAccessFile randomAccessFile = new RandomAccessFile(new File(file, str), "rwd");
|
||||
randomAccessFile.seek(j);
|
||||
return randomAccessFile;
|
||||
}
|
||||
}
|
36
sources/com/baidu/license/download/a/d.java
Normal file
36
sources/com/baidu/license/download/a/d.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.baidu.license.download.a;
|
||||
|
||||
import com.baidu.license.download.base.DownloadTask;
|
||||
import java.io.File;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.Map;
|
||||
|
||||
/* compiled from: SingleDownloadTask.java */
|
||||
/* loaded from: classes.dex */
|
||||
public final class d extends uiw {
|
||||
public d(oi oiVar, e eVar, DownloadTask.OnDownloadListener onDownloadListener) {
|
||||
super(oiVar, eVar, onDownloadListener);
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.a.uiw
|
||||
protected final int a() {
|
||||
return 200;
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.a.uiw
|
||||
protected final RandomAccessFile a(File file, String str, long j) {
|
||||
RandomAccessFile randomAccessFile = new RandomAccessFile(new File(file, str), "rwd");
|
||||
randomAccessFile.seek(0L);
|
||||
return randomAccessFile;
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.a.uiw
|
||||
protected final Map<String, String> a(e eVar) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.a.uiw
|
||||
protected final String b() {
|
||||
return d.class.getSimpleName();
|
||||
}
|
||||
}
|
44
sources/com/baidu/license/download/a/e.java
Normal file
44
sources/com/baidu/license/download/a/e.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.baidu.license.download.a;
|
||||
|
||||
/* compiled from: ThreadRecord.java */
|
||||
/* loaded from: classes.dex */
|
||||
public final class e {
|
||||
private String a;
|
||||
private long b;
|
||||
private long c;
|
||||
private long d;
|
||||
|
||||
public e() {
|
||||
}
|
||||
|
||||
public final String a() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public final long b() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public final long c() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public final long d() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public e(String str, String str2) {
|
||||
this(0, str, str2, 0L, 0L);
|
||||
}
|
||||
|
||||
public final void a(long j) {
|
||||
this.d = j;
|
||||
}
|
||||
|
||||
public e(int i, String str, String str2, long j, long j2) {
|
||||
this.a = str2;
|
||||
this.b = j;
|
||||
this.c = j2;
|
||||
this.d = 0L;
|
||||
}
|
||||
}
|
19
sources/com/baidu/license/download/a/mas.java
Normal file
19
sources/com/baidu/license/download/a/mas.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.baidu.license.download.a;
|
||||
|
||||
import android.os.Handler;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/* compiled from: DownloadStatusDeliveryImpl.java */
|
||||
/* loaded from: classes.dex */
|
||||
final class mas implements Executor {
|
||||
final /* synthetic */ Handler a;
|
||||
|
||||
mas(trw trwVar, Handler handler) {
|
||||
this.a = handler;
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.Executor
|
||||
public final void execute(Runnable runnable) {
|
||||
this.a.post(runnable);
|
||||
}
|
||||
}
|
87
sources/com/baidu/license/download/a/nx.java
Normal file
87
sources/com/baidu/license/download/a/nx.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package com.baidu.license.download.a;
|
||||
|
||||
import com.baidu.license.download.base.DownloadCallback;
|
||||
import com.baidu.license.download.base.DownloadResponse;
|
||||
import com.baidu.license.download.base.DownloadStatus;
|
||||
import com.baidu.license.download.base.DownloadStatusDelivery;
|
||||
import com.baidu.license.download.exception.DownloadException;
|
||||
|
||||
/* compiled from: DownloadResponseImpl.java */
|
||||
/* loaded from: classes.dex */
|
||||
public final class nx implements DownloadResponse {
|
||||
private DownloadStatusDelivery a;
|
||||
private DownloadStatus b = new DownloadStatus();
|
||||
|
||||
public nx(DownloadStatusDelivery downloadStatusDelivery, DownloadCallback downloadCallback) {
|
||||
this.a = downloadStatusDelivery;
|
||||
this.b.a(downloadCallback);
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadResponse
|
||||
public final void a(long j, long j2, boolean z) {
|
||||
this.b.c(j);
|
||||
this.b.a(z);
|
||||
this.b.b(103);
|
||||
this.a.a(this.b);
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadResponse
|
||||
public final void b(DownloadException downloadException) {
|
||||
this.b.a(downloadException);
|
||||
this.b.b(108);
|
||||
this.a.a(this.b);
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadResponse
|
||||
public final void i() {
|
||||
this.b.b(102);
|
||||
this.a.a(this.b);
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadResponse
|
||||
public final void j() {
|
||||
this.b.b(107);
|
||||
this.a.a(this.b);
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadResponse
|
||||
public final void k() {
|
||||
this.b.b(106);
|
||||
this.a.a(this.b);
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadResponse
|
||||
public final void l() {
|
||||
this.b.b(107);
|
||||
this.a.a(this.b);
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadResponse
|
||||
public final void m() {
|
||||
this.b.b(101);
|
||||
this.b.a().d();
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadResponse
|
||||
public final void a(DownloadException downloadException) {
|
||||
this.b.a(downloadException);
|
||||
this.b.b(108);
|
||||
this.a.a(this.b);
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadResponse
|
||||
public final void a(long j, long j2, int i) {
|
||||
this.b.a(j);
|
||||
this.b.b(j2);
|
||||
this.b.a(i);
|
||||
this.b.b(104);
|
||||
this.a.a(this.b);
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadResponse
|
||||
public final void a(String str) {
|
||||
this.b.b(105);
|
||||
this.b.a(str);
|
||||
this.a.a(this.b);
|
||||
}
|
||||
}
|
44
sources/com/baidu/license/download/a/oi.java
Normal file
44
sources/com/baidu/license/download/a/oi.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.baidu.license.download.a;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/* compiled from: DownloadInfo.java */
|
||||
/* loaded from: classes.dex */
|
||||
public final class oi {
|
||||
private String a;
|
||||
private File b;
|
||||
private long c;
|
||||
private long d;
|
||||
|
||||
public oi(String str, String str2, File file) {
|
||||
this.a = str;
|
||||
this.b = file;
|
||||
}
|
||||
|
||||
public final String a() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public final void a(boolean z) {
|
||||
}
|
||||
|
||||
public final File b() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public final long c() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public final long d() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public final void a(long j) {
|
||||
this.c = j;
|
||||
}
|
||||
|
||||
public final void b(long j) {
|
||||
this.d = j;
|
||||
}
|
||||
}
|
73
sources/com/baidu/license/download/a/trw.java
Normal file
73
sources/com/baidu/license/download/a/trw.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package com.baidu.license.download.a;
|
||||
|
||||
import android.os.Handler;
|
||||
import com.baidu.license.download.base.DownloadCallback;
|
||||
import com.baidu.license.download.base.DownloadStatus;
|
||||
import com.baidu.license.download.base.DownloadStatusDelivery;
|
||||
import com.baidu.license.download.exception.DownloadException;
|
||||
import com.baidu.license.download.utils.LogUtils;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/* compiled from: DownloadStatusDeliveryImpl.java */
|
||||
/* loaded from: classes.dex */
|
||||
public final class trw implements DownloadStatusDelivery {
|
||||
private Executor a;
|
||||
|
||||
/* compiled from: DownloadStatusDeliveryImpl.java */
|
||||
private static class oi implements Runnable {
|
||||
private final DownloadStatus a;
|
||||
private final DownloadCallback b;
|
||||
|
||||
public oi(DownloadStatus downloadStatus) {
|
||||
this.a = downloadStatus;
|
||||
this.b = this.a.a();
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
switch (this.a.h()) {
|
||||
case 102:
|
||||
LogUtils.a("DownloadStatusDelivery", "STATUS_CONNECTING");
|
||||
this.b.a();
|
||||
break;
|
||||
case 103:
|
||||
LogUtils.a("DownloadStatusDelivery", "STATUS_CONNECTED length: " + this.a.e() + " acceptRanges: " + this.a.i());
|
||||
this.b.a(this.a.e(), this.a.i());
|
||||
break;
|
||||
case 104:
|
||||
LogUtils.a("DownloadStatusDelivery", "STATUS_PROGRESS finished: " + this.a.d() + " length: " + this.a.e() + " percent: " + this.a.f());
|
||||
this.b.a(this.a.d(), this.a.e(), this.a.f());
|
||||
break;
|
||||
case 105:
|
||||
LogUtils.a("DownloadStatusDelivery", "STATUS_COMPLETED Path:" + this.a.g());
|
||||
if (!this.a.b()) {
|
||||
this.a.b(true);
|
||||
this.b.a(this.a.g());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 106:
|
||||
LogUtils.a("DownloadStatusDelivery", "STATUS_PAUSED");
|
||||
this.b.c();
|
||||
break;
|
||||
case 107:
|
||||
LogUtils.a("DownloadStatusDelivery", "STATUS_CANCELED");
|
||||
this.b.b();
|
||||
break;
|
||||
case 108:
|
||||
LogUtils.b("DownloadStatusDelivery", "STATUS_FAILED error: " + this.a.c().getCause());
|
||||
this.b.a((DownloadException) this.a.c());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public trw(Handler handler) {
|
||||
this.a = new mas(this, handler);
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadStatusDelivery
|
||||
public final void a(DownloadStatus downloadStatus) {
|
||||
this.a.execute(new oi(downloadStatus));
|
||||
}
|
||||
}
|
122
sources/com/baidu/license/download/a/uiw.java
Normal file
122
sources/com/baidu/license/download/a/uiw.java
Normal file
@@ -0,0 +1,122 @@
|
||||
package com.baidu.license.download.a;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.baidu.license.download.base.DownloadTask;
|
||||
import com.baidu.license.download.exception.DownloadException;
|
||||
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Map;
|
||||
|
||||
/* compiled from: DownloadTaskImpl.java */
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class uiw implements DownloadTask {
|
||||
private String a;
|
||||
private final oi b;
|
||||
private final e c;
|
||||
private final DownloadTask.OnDownloadListener d;
|
||||
private volatile int e;
|
||||
private volatile int f = 0;
|
||||
|
||||
public uiw(oi oiVar, e eVar, DownloadTask.OnDownloadListener onDownloadListener) {
|
||||
this.b = oiVar;
|
||||
this.c = eVar;
|
||||
this.d = onDownloadListener;
|
||||
this.a = b();
|
||||
if (TextUtils.isEmpty(this.a)) {
|
||||
this.a = getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
|
||||
private static void a(Map<String, String> map, URLConnection uRLConnection) {
|
||||
if (map != null) {
|
||||
for (String str : map.keySet()) {
|
||||
uRLConnection.setRequestProperty(str, map.get(str));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract int a();
|
||||
|
||||
protected abstract RandomAccessFile a(File file, String str, long j);
|
||||
|
||||
protected abstract Map<String, String> a(e eVar);
|
||||
|
||||
protected abstract String b();
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadTask
|
||||
public void cancel() {
|
||||
this.f = 107;
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadTask
|
||||
public boolean g() {
|
||||
return this.e == 105;
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadTask
|
||||
public boolean h() {
|
||||
return this.e == 104;
|
||||
}
|
||||
|
||||
@Override // com.baidu.license.download.base.DownloadTask
|
||||
public void pause() {
|
||||
this.f = 106;
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
/* JADX WARN: Removed duplicated region for block: B:75:0x010f A[Catch: DownloadException -> 0x011c, TRY_ENTER, TryCatch #11 {DownloadException -> 0x011c, blocks: (B:3:0x0009, B:5:0x000b, B:31:0x0077, B:32:0x007a, B:33:0x007c, B:42:0x00ae, B:75:0x010f, B:76:0x0112, B:85:0x0114, B:86:0x011b, B:36:0x007f, B:37:0x00aa), top: B:2:0x0009, inners: #9, #17 }] */
|
||||
/* JADX WARN: Type inference failed for: r0v10 */
|
||||
/* JADX WARN: Type inference failed for: r0v15, types: [java.net.HttpURLConnection] */
|
||||
/* JADX WARN: Type inference failed for: r0v8, types: [java.net.URL] */
|
||||
@Override // java.lang.Runnable
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public void run() {
|
||||
/*
|
||||
Method dump skipped, instructions count: 360
|
||||
To view this dump change 'Code comments level' option to 'DEBUG'
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.baidu.license.download.a.uiw.run():void");
|
||||
}
|
||||
|
||||
private static void a(Closeable closeable) {
|
||||
if (closeable != null) {
|
||||
synchronized (uiw.class) {
|
||||
closeable.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void a(InputStream inputStream, RandomAccessFile randomAccessFile) {
|
||||
byte[] bArr = new byte[UnityActivity.BLOCKLY_TYPE_NONE];
|
||||
while (this.f != 107) {
|
||||
if (this.f != 106) {
|
||||
try {
|
||||
int read = inputStream.read(bArr);
|
||||
if (read == -1) {
|
||||
return;
|
||||
}
|
||||
randomAccessFile.write(bArr, 0, read);
|
||||
long j = read;
|
||||
this.c.a(this.c.d() + j);
|
||||
synchronized (this.d) {
|
||||
this.b.b(this.b.d() + j);
|
||||
this.d.a(this.b.d(), this.b.c());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new DownloadException(108, e);
|
||||
}
|
||||
} else {
|
||||
throw new DownloadException(106, "Download paused!");
|
||||
}
|
||||
}
|
||||
throw new DownloadException(107, "Download canceled!");
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
package com.baidu.license.download.base;
|
||||
|
||||
import com.baidu.license.download.exception.DownloadException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class DownloadCallback {
|
||||
public void a() {
|
||||
}
|
||||
|
||||
public abstract void a(long j, long j2, int i);
|
||||
|
||||
public void a(long j, boolean z) {
|
||||
}
|
||||
|
||||
public abstract void a(DownloadException downloadException);
|
||||
|
||||
public abstract void a(String str);
|
||||
|
||||
public abstract void b();
|
||||
|
||||
public abstract void c();
|
||||
|
||||
public void d() {
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
package com.baidu.license.download.base;
|
||||
|
||||
import com.baidu.license.download.exception.DownloadException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface DownloadResponse {
|
||||
void a(long j, long j2, int i);
|
||||
|
||||
void a(long j, long j2, boolean z);
|
||||
|
||||
void a(DownloadException downloadException);
|
||||
|
||||
void a(String str);
|
||||
|
||||
void b(DownloadException downloadException);
|
||||
|
||||
void i();
|
||||
|
||||
void j();
|
||||
|
||||
void k();
|
||||
|
||||
void l();
|
||||
|
||||
void m();
|
||||
}
|
91
sources/com/baidu/license/download/base/DownloadStatus.java
Normal file
91
sources/com/baidu/license/download/base/DownloadStatus.java
Normal file
@@ -0,0 +1,91 @@
|
||||
package com.baidu.license.download.base;
|
||||
|
||||
import com.baidu.license.download.exception.DownloadException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DownloadStatus {
|
||||
private int a;
|
||||
private long b;
|
||||
private long c;
|
||||
private int d;
|
||||
private boolean e;
|
||||
private DownloadException f;
|
||||
private DownloadCallback g;
|
||||
private String h;
|
||||
private boolean i;
|
||||
|
||||
public void a(long j) {
|
||||
this.c = j;
|
||||
}
|
||||
|
||||
public void b(int i) {
|
||||
this.a = i;
|
||||
}
|
||||
|
||||
public Exception c() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
public void c(long j) {
|
||||
}
|
||||
|
||||
public long d() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public long e() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public int f() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public String g() {
|
||||
return this.h;
|
||||
}
|
||||
|
||||
public int h() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public boolean i() {
|
||||
return this.e;
|
||||
}
|
||||
|
||||
public void a(int i) {
|
||||
this.d = i;
|
||||
}
|
||||
|
||||
public void b(long j) {
|
||||
this.b = j;
|
||||
}
|
||||
|
||||
public void a(boolean z) {
|
||||
this.e = z;
|
||||
}
|
||||
|
||||
public void b(boolean z) {
|
||||
this.i = z;
|
||||
}
|
||||
|
||||
public void a(DownloadException downloadException) {
|
||||
this.f = downloadException;
|
||||
}
|
||||
|
||||
public boolean b() {
|
||||
return this.i;
|
||||
}
|
||||
|
||||
public DownloadCallback a() {
|
||||
return this.g;
|
||||
}
|
||||
|
||||
public void a(DownloadCallback downloadCallback) {
|
||||
this.g = downloadCallback;
|
||||
}
|
||||
|
||||
public void a(String str) {
|
||||
this.h = str;
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package com.baidu.license.download.base;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface DownloadStatusDelivery {
|
||||
void a(DownloadStatus downloadStatus);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user