256 lines
12 KiB
Java
256 lines
12 KiB
Java
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;
|
|
}
|
|
}
|
|
}
|