jimu-decompiled/sources/com/baidu/license/download/a/uiw.java
2025-05-13 19:24:51 +02:00

123 lines
4.2 KiB
Java

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