Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View 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;
}
}
}

View 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();
}
}
}
});
}
}

View 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;
}
}

View 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();
}
}
}

View 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!");
}
}

View 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;
}
}

View 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();
}
}

View 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;
}
}

View 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);
}
}

View 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);
}
}

View 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;
}
}

View 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));
}
}

View 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!");
}
}

View File

@@ -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() {
}
}

View File

@@ -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();
}

View 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;
}
}

View File

@@ -0,0 +1,6 @@
package com.baidu.license.download.base;
/* loaded from: classes.dex */
public interface DownloadStatusDelivery {
void a(DownloadStatus downloadStatus);
}

View File

@@ -0,0 +1,27 @@
package com.baidu.license.download.base;
import com.baidu.license.download.exception.DownloadException;
/* loaded from: classes.dex */
public interface DownloadTask extends Runnable {
public interface OnDownloadListener {
void a(long j, long j2);
void a(String str);
void b(DownloadException downloadException);
void j();
void k();
}
void cancel();
boolean g();
boolean h();
void pause();
}

View File

@@ -0,0 +1,17 @@
package com.baidu.license.download.base;
/* loaded from: classes.dex */
public interface Downloader {
public interface OnDownloaderDestroyedListener {
void a(String str, Downloader downloader);
}
void cancel();
boolean isRunning();
void pause();
void start();
}

View File

@@ -0,0 +1,27 @@
package com.baidu.license.download.base;
import com.baidu.license.download.exception.DownloadException;
/* loaded from: classes.dex */
public interface HttpConnectTask extends Runnable {
public interface OnConnectListener {
void a();
void a(long j, long j2, boolean z);
void a(DownloadException downloadException);
void i();
void l();
}
void cancel();
boolean i();
boolean isCanceled();
void pause();
}

View File

@@ -0,0 +1,62 @@
package com.baidu.license.download.exception;
/* loaded from: classes.dex */
public class DownloadException extends Exception {
private int errorCode;
private String errorMessage;
public DownloadException() {
}
public int getErrorCode() {
return this.errorCode;
}
public String getErrorMessage() {
return this.errorMessage;
}
public void setErrorCode(int i) {
this.errorCode = i;
}
public void setErrorMessage(String str) {
this.errorMessage = str;
}
@Override // java.lang.Throwable
public String toString() {
return super.toString();
}
public DownloadException(String str) {
super(str);
this.errorMessage = str;
}
public DownloadException(int i, String str) {
super(str);
this.errorCode = i;
this.errorMessage = str;
}
public DownloadException(int i, Throwable th) {
super(th);
this.errorCode = i;
}
public DownloadException(String str, Throwable th) {
super(str, th);
this.errorMessage = str;
}
public DownloadException(int i, String str, Throwable th) {
super(str, th);
this.errorCode = i;
this.errorMessage = str;
}
public DownloadException(Throwable th) {
super(th);
}
}

View File

@@ -0,0 +1,78 @@
package com.baidu.license.download;
import android.text.TextUtils;
import com.liulishuo.filedownloader.model.FileDownloadModel;
import com.ubt.jimu.controller.data.widget.JockstickDataConverter;
import com.unity3d.ads.metadata.MediationMetaData;
import org.json.JSONException;
import org.json.JSONObject;
/* compiled from: RequestTask.java */
/* loaded from: classes.dex */
public final class nx {
private int e;
private String h;
private String a = "";
private String b = "";
private String c = "";
private String d = "";
private String f = "";
private int g = 0;
public final JSONObject a() {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put(MediationMetaData.KEY_NAME, this.a);
jSONObject.put(JockstickDataConverter.ID, this.b);
jSONObject.put("image", this.c);
jSONObject.put("url", this.d);
jSONObject.put("progress", this.e);
jSONObject.put("downloadPerSize", this.f);
jSONObject.put(FileDownloadModel.STATUS, this.g);
jSONObject.put("savePath", this.h);
} catch (JSONException e) {
e.printStackTrace();
}
return jSONObject;
}
public final String b() {
return this.d;
}
public final void c(String str) {
this.h = str;
}
public final void b(String str) {
this.f = str;
}
public final void b(int i) {
this.g = i;
}
public final boolean a(String str) {
if (TextUtils.isEmpty(str)) {
return false;
}
try {
JSONObject jSONObject = new JSONObject(str);
this.a = jSONObject.optString(MediationMetaData.KEY_NAME);
this.b = jSONObject.optString(JockstickDataConverter.ID);
this.c = jSONObject.optString("image");
this.d = jSONObject.optString("url");
this.e = jSONObject.optInt("progress");
this.f = jSONObject.optString("downloadPerSize");
this.g = jSONObject.optInt(FileDownloadModel.STATUS);
this.h = jSONObject.optString("savePath");
return true;
} catch (JSONException unused) {
return false;
}
}
public final void a(int i) {
this.e = i;
}
}

View File

@@ -0,0 +1,16 @@
package com.baidu.license.download;
/* compiled from: DownloadConfig.java */
/* loaded from: classes.dex */
public final class oi {
private int a = 10;
private int b = 2;
public final int a() {
return this.a;
}
public final int b() {
return this.b;
}
}

View File

@@ -0,0 +1,16 @@
package com.baidu.license.download.utils;
import java.text.DecimalFormat;
/* loaded from: classes.dex */
public class CommonUtils {
private static final DecimalFormat a = new DecimalFormat("0.00");
static {
new String[]{"android.permission.READ_EXTERNAL_STORAGE", "android.permission.WRITE_EXTERNAL_STORAGE"};
}
public static String a(long j, long j2) {
return a.format(j / 1048576.0f) + "M/" + a.format(j2 / 1048576.0f) + "M";
}
}

View File

@@ -0,0 +1,8 @@
package com.baidu.license.download.utils;
/* loaded from: classes.dex */
public class FileUtils {
public static final String a(String str) {
return str.substring(str.lastIndexOf("/") + 1, str.length());
}
}

View File

@@ -0,0 +1,17 @@
package com.baidu.license.download.utils;
/* loaded from: classes.dex */
public class LogUtils {
public static void a(String str) {
c("LogUtils", str);
}
public static void a(String str, String str2) {
}
public static void b(String str, String str2) {
}
public static void c(String str, String str2) {
}
}