正在查看: XT工具箱 v3.6.15 应用的 k.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: XT工具箱 v3.6.15 应用的 k.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package a.d.a;
import android.R;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.os.StatFs;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray;
import androidx.core.view.InputDeviceCompat;
import androidx.recyclerview.widget.RecyclerView;
import java.io.BufferedInputStream;
import java.io.Closeable;
import java.io.File;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.zip.GZIPInputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
public class k extends AsyncTask<Void, Integer, Integer> implements Object<h> {
public static final String r;
public static final SparseArray<String> s;
public static final Executor t;
public static final Handler u;
public volatile h f319a;
public volatile Throwable h;
public g k;
public volatile long f320b = 0;
public volatile long f321c = -1;
public long f322d = 0;
public long e = 0;
public long f = 0;
public volatile long g = 0;
public long i = RecyclerView.FOREVER_NS;
public long j = 10000;
public AtomicBoolean l = new AtomicBoolean(false);
public AtomicBoolean m = new AtomicBoolean(false);
public AtomicBoolean n = new AtomicBoolean(false);
public volatile boolean o = false;
public boolean p = false;
public boolean q = false;
public final class a extends RandomAccessFile {
public a(File file) {
super(file, "rw");
}
@Override
public void write(byte[] bArr, int i, int i2) {
super.write(bArr, i, i2);
k.this.f320b += i2;
if (k.this.f319a != null) {
long j = k.this.f322d;
}
if (k.this.o) {
boolean z = k.this.q;
long elapsedRealtime = SystemClock.elapsedRealtime();
if (!z) {
k kVar = k.this;
if (elapsedRealtime - kVar.f < 1200) {
return;
}
kVar.f = elapsedRealtime;
if (kVar.p) {
kVar.publishProgress(1);
return;
} else {
kVar.onProgressUpdate(1);
return;
}
}
k kVar2 = k.this;
if (elapsedRealtime - kVar2.f < 1200) {
if (kVar2.p) {
kVar2.publishProgress(0);
return;
} else {
kVar2.onProgressUpdate(0);
return;
}
}
kVar2.f = elapsedRealtime;
if (kVar2.p) {
kVar2.publishProgress(1);
} else {
kVar2.onProgressUpdate(1);
}
}
}
}
static {
StringBuilder o = a.b.a.a.a.o("Download-");
o.append(k.class.getSimpleName());
r = o.toString();
SparseArray<String> sparseArray = new SparseArray<>(12);
s = sparseArray;
t = new s();
u = new Handler(Looper.getMainLooper());
sparseArray.append(1024, "Network connection error . ");
sparseArray.append(InputDeviceCompat.SOURCE_GAMEPAD, "Response code non-200 or non-206 . ");
sparseArray.append(1026, "Insufficient memory space . ");
sparseArray.append(1031, "Shutdown . ");
sparseArray.append(1027, "Download time is overtime . ");
sparseArray.append(1030, "The user canceled the download . ");
sparseArray.append(1040, "Resource not found . ");
sparseArray.append(1028, "paused . ");
sparseArray.append(1033, "IO Error . ");
sparseArray.append(1283, "Service Unavailable . ");
sparseArray.append(1032, "Too many redirects . ");
sparseArray.append(1041, "Md5 check fails . ");
sparseArray.append(512, "Download successful . ");
}
public h a() {
try {
return this.f319a;
} finally {
this.l.set(true);
}
}
@Override
public java.lang.Integer doInBackground(java.lang.Void[] r10) {
throw new UnsupportedOperationException("Method not decompiled: a.d.a.k.doInBackground(java.lang.Object[]):java.lang.Object");
}
public final boolean e() {
long j;
h hVar = this.f319a;
long length = hVar.u - hVar.w.length();
try {
StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().toString());
j = statFs.getAvailableBlocksLong() * statFs.getBlockSizeLong();
} catch (RuntimeException unused) {
j = 0;
}
if (length <= j - 104857600) {
return true;
}
r rVar = r.h;
String str = r;
Objects.requireNonNull(rVar);
Log.e(str, " 空间不足");
return false;
}
public void f(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
public final HttpURLConnection g(URL url) {
h hVar = this.f319a;
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setConnectTimeout((int) this.j);
httpURLConnection.setInstanceFollowRedirects(false);
httpURLConnection.setReadTimeout((int) hVar.o);
httpURLConnection.setRequestProperty("Accept", "*/*");
httpURLConnection.setRequestProperty("Accept-Encoding", "deflate,gzip");
return httpURLConnection;
}
public void h() {
h hVar;
if (this.l.get() || this.m.get() || (hVar = this.f319a) == null) {
return;
}
hVar.t = -1;
hVar.g = null;
hVar.v = null;
hVar.w = null;
hVar.e = false;
hVar.f326a = false;
hVar.f327b = true;
hVar.f328c = R.drawable.stat_sys_download;
hVar.f329d = R.drawable.stat_sys_download_done;
hVar.e = true;
hVar.f = true;
hVar.j = "";
hVar.h = "";
hVar.i = "";
Map<String, String> map = hVar.k;
if (map != null) {
map.clear();
hVar.k = null;
}
hVar.s = 3;
hVar.r = "";
hVar.q = "";
}
public final boolean i(Integer num) {
c cVar;
h hVar = this.f319a;
e eVar = hVar.x;
if (eVar == null) {
return false;
}
Objects.requireNonNull(r.h);
if (this.h != null) {
this.h.printStackTrace();
}
if (num.intValue() <= 512) {
cVar = null;
} else {
int intValue = num.intValue();
StringBuilder o = a.b.a.a.a.o("failed , cause:");
o.append(s.get(num.intValue()));
cVar = new c(intValue, o.toString());
}
return eVar.b(cVar, Uri.fromFile(hVar.w), hVar.g, this.f319a);
}
public final int j() {
boolean equalsIgnoreCase;
long l;
long j;
String str;
int i;
int i2;
String str2 = ")";
String str3 = "(";
h hVar = this.f319a;
long j2 = this.g;
long j3 = hVar.A;
long j4 = 0;
if (j3 == 0) {
hVar.A = j2;
} else if (j3 != j2) {
hVar.D = Math.abs(j2 - hVar.B) + hVar.D;
}
boolean z = false;
hVar.F = 0;
URL url = new URL(hVar.g);
HttpURLConnection httpURLConnection = null;
int i3 = 0;
while (true) {
int i4 = i3 + 1;
if (i3 > 7) {
return 1032;
}
if (httpURLConnection != null) {
try {
httpURLConnection.disconnect();
} finally {
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
}
}
if (hVar.F <= 0) {
httpURLConnection = g(url);
r(hVar, httpURLConnection);
} else {
httpURLConnection = g(url);
r(hVar, httpURLConnection);
o(hVar, httpURLConnection);
}
httpURLConnection.connect();
if (this.m.get()) {
httpURLConnection.disconnect();
return 1028;
}
if (this.l.get()) {
httpURLConnection.disconnect();
return 1030;
}
equalsIgnoreCase = "chunked".equalsIgnoreCase(httpURLConnection.getHeaderField("Transfer-Encoding"));
l = l(httpURLConnection, "Content-Length");
boolean z2 = l > j4 ? true : z;
boolean z3 = (!(equalsIgnoreCase && z2) && (equalsIgnoreCase || z2)) ? z : true;
int responseCode = httpURLConnection.getResponseCode();
r rVar = r.h;
String str4 = r;
Objects.requireNonNull(rVar);
Log.i(str4, "responseCode:" + responseCode);
if (responseCode == 206 && !z2) {
httpURLConnection.disconnect();
return 512;
}
String str5 = str2;
String str6 = str3;
if (responseCode != 200) {
if (responseCode == 206) {
if (z3) {
Log.e(str4, " error , giving up , EncodingChunked:" + equalsIgnoreCase + " hasLength:" + z2 + " response length:" + l + " responseCode:" + responseCode);
httpURLConnection.disconnect();
return 1033;
}
if (equalsIgnoreCase) {
this.f321c = -1L;
} else {
if (this.f321c > 0 && hVar.w.length() + l != this.f321c) {
httpURLConnection.disconnect();
return 1033;
}
if (this.f321c <= 0) {
this.f321c = l + hVar.w.length();
}
}
hVar.u = this.f321c;
if (!equalsIgnoreCase && !e()) {
httpURLConnection.disconnect();
return 1026;
}
int t2 = t(m(httpURLConnection), new a(hVar.w), !equalsIgnoreCase);
httpURLConnection.disconnect();
return t2;
}
if (responseCode != 307) {
if (responseCode == 404) {
httpURLConnection.disconnect();
return 1040;
}
if (responseCode != 416) {
switch (responseCode) {
case 301:
case 302:
case 303:
break;
default:
switch (responseCode) {
case 500:
case 501:
case 502:
case 503:
httpURLConnection.disconnect();
return 1283;
default:
httpURLConnection.disconnect();
return InputDeviceCompat.SOURCE_GAMEPAD;
}
}
} else {
if (hVar.w != null) {
Log.i(str4, " range not satisfiable .");
hVar.w.delete();
hVar.w.createNewFile();
}
str = str5;
str3 = str6;
j = 0;
}
}
url = new URL(url, httpURLConnection.getHeaderField("Location"));
i3 = i4;
str2 = str5;
str3 = str6;
z = false;
j4 = 0;
} else {
if (z3) {
Log.e(str4, " error , giving up , EncodingChunked:" + equalsIgnoreCase + " hasLength:" + z2 + " response length:" + l + " responseCode:" + responseCode);
httpURLConnection.disconnect();
return 1033;
}
this.f321c = l;
if (hVar.F <= 0) {
s(httpURLConnection);
hVar.F++;
j = 0;
if (hVar.w.length() > 0 && !equalsIgnoreCase) {
if (hVar.w.length() == l) {
if (rVar.g == null) {
rVar.g = new a.d.a.a();
}
String a2 = hVar.a();
String g = rVar.g(hVar.w);
if (a2 == null) {
a2 = "";
}
if (a2.trim().equalsIgnoreCase(g)) {
i2 = 1;
i = 1;
} else {
i = 3;
i2 = 1;
}
if (i == i2) {
this.f322d = l;
if (this.p) {
Integer[] numArr = new Integer[i2];
numArr[0] = Integer.valueOf(i2);
publishProgress(numArr);
} else {
Integer[] numArr2 = new Integer[i2];
numArr2[0] = Integer.valueOf(i2);
onProgressUpdate(numArr2);
}
httpURLConnection.disconnect();
return 512;
}
if (i == 2) {
hVar.w.delete();
hVar.w.createNewFile();
str = str5;
str3 = str6;
} else {
StringBuilder sb = new StringBuilder();
str3 = str6;
sb.append(str3);
sb.append(new File(hVar.w.getParent()).list().length - 1);
str = str5;
sb.append(str);
sb.append(hVar.w.getName());
String sb2 = sb.toString();
String str7 = str3 + new File(hVar.w.getParent()).list().length + str + hVar.w.getName();
File file = new File(hVar.w.getParent(), sb2);
File file2 = new File(hVar.w.getParent(), str7);
if (!file.exists() || file.length() >= l) {
if (!file2.exists() || file2.length() < l) {
if (!file2.exists()) {
}
hVar.w = file2;
} else {
file2.delete();
}
file2.createNewFile();
hVar.w = file2;
} else {
hVar.w = file;
}
Log.i(str4, "rename download , new file name:" + hVar.w.getName());
}
} else {
str = str5;
str3 = str6;
if (hVar.w.length() >= l) {
Log.i(str4, " file length error .");
hVar.w.delete();
hVar.w.createNewFile();
}
}
}
}
}
str2 = str;
j4 = j;
i3 = i4;
z = false;
}
if (equalsIgnoreCase) {
this.f321c = -1L;
} else if (hVar.w.length() >= l) {
this.f321c = l;
httpURLConnection.disconnect();
return 512;
}
hVar.u = this.f321c;
if (!equalsIgnoreCase && !e()) {
httpURLConnection.disconnect();
return 1026;
}
q(httpURLConnection);
hVar.u = this.f321c;
int t3 = t(m(httpURLConnection), new a(hVar.w), false);
httpURLConnection.disconnect();
return t3;
}
public final String k() {
String str = this.f319a.g;
r rVar = r.h;
String h = rVar.h(str);
Context context = ((b) rVar.f(this.f319a.v)).f306a;
Objects.requireNonNull(rVar);
String string = context.getSharedPreferences("Downloader", 0).getString(h, "-1");
if (TextUtils.isEmpty(string) || "-1".equals(string)) {
return null;
}
return string;
}
public final long l(HttpURLConnection httpURLConnection, String str) {
String headerField = httpURLConnection.getHeaderField(str);
if (headerField == null) {
return -1L;
}
try {
return Long.parseLong(headerField);
} catch (NumberFormatException e) {
Objects.requireNonNull(r.h);
e.printStackTrace();
return -1L;
}
}
public final InputStream m(HttpURLConnection httpURLConnection) {
return "gzip".equalsIgnoreCase(httpURLConnection.getContentEncoding()) ? new GZIPInputStream(httpURLConnection.getInputStream()) : "deflate".equalsIgnoreCase(httpURLConnection.getContentEncoding()) ? new InflaterInputStream(httpURLConnection.getInputStream(), new Inflater(true)) : httpURLConnection.getInputStream();
}
@Override
public void onProgressUpdate(Integer... numArr) {
h hVar = this.f319a;
try {
long elapsedRealtime = SystemClock.elapsedRealtime() - this.g;
this.e = elapsedRealtime;
if (elapsedRealtime != 0) {
long j = (this.f320b * 1000) / this.e;
}
if (numArr != null && numArr.length > 0 && numArr[0].intValue() == 1 && this.k != null) {
if (this.f321c > 0) {
this.k.i((int) (((this.f322d + this.f320b) / Float.valueOf(this.f321c).floatValue()) * 100.0f));
} else {
this.k.h(this.f322d + this.f320b);
}
}
if (hVar.x != null) {
hVar.y.a(hVar.g, this.f322d + this.f320b, this.f321c, hVar.e());
}
} catch (Throwable th) {
th.printStackTrace();
}
}
public final void o(h hVar, HttpURLConnection httpURLConnection) {
File file = hVar.w;
if (file != null && file.length() > 0) {
StringBuilder o = a.b.a.a.a.o("bytes=");
long length = hVar.w.length();
this.f322d = length;
o.append(length);
o.append("-");
httpURLConnection.setRequestProperty("Range", o.toString());
}
httpURLConnection.setRequestProperty("Connection", "close");
}
@Override
public void onPostExecute(java.lang.Integer r10) {
throw new UnsupportedOperationException("Method not decompiled: a.d.a.k.onPostExecute(java.lang.Object):void");
}
@Override
public void onPreExecute() {
throw new UnsupportedOperationException("Method not decompiled: a.d.a.k.onPreExecute():void");
}
public final void p(a.d.a.h r9) {
throw new UnsupportedOperationException("Method not decompiled: a.d.a.k.p(a.d.a.h):void");
}
public final void q(HttpURLConnection httpURLConnection) {
String headerField = httpURLConnection.getHeaderField("ETag");
if (TextUtils.isEmpty(headerField)) {
return;
}
String str = this.f319a.g;
r rVar = r.h;
String h = rVar.h(str);
Log.i(r, "save etag:" + headerField);
SharedPreferences.Editor edit = ((b) rVar.f(this.f319a.v)).f306a.getSharedPreferences("Downloader", 0).edit();
edit.putString(h, headerField);
edit.apply();
}
public final void r(h hVar, HttpURLConnection httpURLConnection) {
Map<String, String> map = hVar.k;
if (map != null && !map.isEmpty()) {
for (Map.Entry<String, String> entry : map.entrySet()) {
if (!TextUtils.isEmpty(entry.getKey()) && !TextUtils.isEmpty(entry.getValue())) {
httpURLConnection.setRequestProperty(entry.getKey(), entry.getValue());
}
}
}
String k = k();
if (!TextUtils.isEmpty(k)) {
r rVar = r.h;
Objects.requireNonNull(rVar);
Log.i(r, "Etag:" + k);
httpURLConnection.setRequestProperty("If-Match", k());
}
r rVar2 = r.h;
String str = r;
Objects.requireNonNull(rVar2);
Log.i(str, "settingHeaders");
}
public final void s(java.net.HttpURLConnection r5) {
throw new UnsupportedOperationException("Method not decompiled: a.d.a.k.s(java.net.HttpURLConnection):void");
}
public final int t(InputStream inputStream, RandomAccessFile randomAccessFile, boolean z) {
int i;
int read;
byte[] bArr = new byte[8192];
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, 8192);
h hVar = this.f319a;
try {
if (z) {
randomAccessFile.seek(randomAccessFile.length());
} else {
randomAccessFile.seek(0L);
this.f322d = 0L;
}
while (!this.l.get() && !this.n.get() && !this.m.get() && (read = bufferedInputStream.read(bArr, 0, 8192)) != -1) {
randomAccessFile.write(bArr, 0, read);
if (SystemClock.elapsedRealtime() - this.g > this.i) {
i = 1027;
break;
}
}
if (this.m.get()) {
i = 1028;
} else if (this.l.get()) {
i = 1030;
} else if (this.n.get()) {
i = 1031;
} else {
if (!TextUtils.isEmpty(hVar.a())) {
r rVar = r.h;
this.f319a.r = rVar.g(this.f319a.w);
String a2 = hVar.a();
if (TextUtils.isEmpty(hVar.r)) {
String g = rVar.g(hVar.w);
hVar.r = g;
if (g == null) {
hVar.r = "";
}
}
if (!a2.equalsIgnoreCase(hVar.r)) {
i = 1041;
}
}
i = 512;
}
return i;
} finally {
f(randomAccessFile);
f(bufferedInputStream);
f(inputStream);
}
}
}