OurPlay v5.5.9版本的 MD5 值为:d4e139798f4c2243a1145c8af5e21046
以下内容为反编译后的 a.java 源代码,内容仅作参考
package com.excelliance.kxqp.gs.multi.down;
import a.aa;
import a.ac;
import a.ad;
import a.q;
import a.x;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
import android.support.v4.media.session.PlaybackStateCompat;
import android.text.TextUtils;
import android.util.Log;
import androidx.core.app.NotificationCompat;
import androidx.fragment.app.FragmentActivity;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.work.WorkRequest;
import com.android.spush.util.WebActionRouter;
import com.excean.bytedancebi.bean.BiEventDialogShow;
import com.excean.bytedancebi.bean.BiEventPluginPause;
import com.excean.ggspace.main.R;
import com.excelliance.kxqp.VersionManager;
import com.excelliance.kxqp.api.ApiManager;
import com.excelliance.kxqp.bean.AppExtraBean;
import com.excelliance.kxqp.bean.ResourcesDownloadInfo;
import com.excelliance.kxqp.bitmap.bean.RankingItem;
import com.excelliance.kxqp.bitmap.bean.ResponseData;
import com.excelliance.kxqp.gs.base.GSBaseActivity;
import com.excelliance.kxqp.gs.bean.AppDownLoadInfoBean;
import com.excelliance.kxqp.gs.bean.VersionBean;
import com.excelliance.kxqp.gs.gamelanguage.k;
import com.excelliance.kxqp.gs.launch.function.aa;
import com.excelliance.kxqp.gs.launch.function.q;
import com.excelliance.kxqp.gs.m.a.f;
import com.excelliance.kxqp.gs.multi.down.model.DownBean;
import com.excelliance.kxqp.gs.multi.down.model.PatchDownBean;
import com.excelliance.kxqp.gs.thpool.tp;
import com.excelliance.kxqp.gs.util.ah;
import com.excelliance.kxqp.gs.util.an;
import com.excelliance.kxqp.gs.util.as;
import com.excelliance.kxqp.gs.util.au;
import com.excelliance.kxqp.gs.util.ay;
import com.excelliance.kxqp.gs.util.az;
import com.excelliance.kxqp.gs.util.ba;
import com.excelliance.kxqp.gs.util.bd;
import com.excelliance.kxqp.gs.util.bf;
import com.excelliance.kxqp.gs.util.bi;
import com.excelliance.kxqp.gs.util.bm;
import com.excelliance.kxqp.gs.util.bn;
import com.excelliance.kxqp.gs.util.bs;
import com.excelliance.kxqp.gs.util.by;
import com.excelliance.kxqp.gs.util.bz;
import com.excelliance.kxqp.gs.util.cd;
import com.excelliance.kxqp.gs.util.cf;
import com.excelliance.kxqp.gs.util.w;
import com.excelliance.kxqp.platforms.ExcellianceAppInfo;
import com.excelliance.kxqp.sdk.StatisticsBase;
import com.excelliance.kxqp.sdk.StatisticsBuilder;
import com.excelliance.kxqp.sdk.StatisticsGS;
import com.excelliance.kxqp.splash.bean.ResponseAdJarData;
import com.excelliance.kxqp.ui.InitialData;
import com.excelliance.kxqp.util.r;
import com.excelliance.staticslio.StatisticsManager;
import com.fred.patcher.PatcherInstall;
import com.tencent.open.SocialConstants;
import io.github.prototypez.appjoint.AppJoint;
import io.github.prototypez.service.adModule.IAdModule;
import java.io.EOFException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.io.UTFDataFormatException;
import java.net.InetAddress;
import java.net.ProtocolException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.UnknownHostException;
import java.net.UnknownServiceException;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLPeerUnverifiedException;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpHost;
import org.apache.http.cookie.ClientCookie;
import org.json.JSONException;
import org.json.JSONObject;
public class a extends Binder {
private static volatile a f7475b;
private static Context c;
private static final HashMap<String, Integer> o = new HashMap<>(5);
private static final HashMap<String, Set<String>> p = new HashMap<>(5);
private b l;
private boolean f7476a = false;
private Map<String, DownBean> d = new ConcurrentHashMap();
private Map<String, RunnableC0305a> e = new ConcurrentHashMap();
private Map<String, Float> f = new HashMap();
private Map<String, Float> g = new HashMap();
private Map<String, Integer> h = new ConcurrentHashMap();
private Map<String, Long> i = new ConcurrentHashMap();
private int j = 0;
private ConcurrentHashMap<String, DownBean> k = new ConcurrentHashMap<>();
private ConcurrentHashMap<String, Long[]> m = new ConcurrentHashMap<>();
private boolean n = false;
public class b extends Handler {
public b(Looper looper) {
super(looper);
}
@Override
public void handleMessage(Message message) {
switch (message.what) {
case 0:
DownBean downBean = (DownBean) message.obj;
int i = message.arg1;
if (downBean.needRemoveFile) {
Log.e("DownManager", "handleMessage: MSG_DELAY_REDOWNLOAD_ needRemoveFile need delete file: " + downBean.filePath);
an.c(downBean.filePath);
downBean.needRemoveFile = false;
i = -1;
} else {
Log.e("DownManager", "handleMessage: not need delete file: " + downBean.filePath);
if (i >= 0) {
RunnableC0305a runnableC0305a = (RunnableC0305a) a.this.e.get(downBean.name + "-" + i);
Log.e("DownManager", "handleMessage: MSG_DELAY_REDOWNLOAD_ dt: " + runnableC0305a + ", downloadErrorCount = " + downBean.downloadErrorCount);
if (runnableC0305a != null) {
downBean.downloadErrorCount = runnableC0305a.e;
}
}
}
Log.e("DownManager", "handleMessage: MSG_DELAY_REDOWNLOAD_ downloadBean_delay_redown: " + downBean);
a.this.d(downBean, i);
com.excelliance.kxqp.gs.multi.a.a.a(a.c).update(downBean.name, downBean.type, "");
if (downBean.downloadErrorCount < 5) {
Message obtainMessage = a.this.l.obtainMessage(1);
obtainMessage.obj = downBean;
obtainMessage.arg1 = i;
a.this.l.sendMessageDelayed(obtainMessage, downBean.downloadErrorCount * 5000);
}
if (i < 0) {
downBean.downloadErrorCount++;
return;
}
return;
case 1:
DownBean downBean2 = (DownBean) message.obj;
Log.e("DownManager", "handleMessage: MSG_REDOWNLOAD_ downloadBean_redown: " + downBean2);
if (downBean2 != null && downBean2.downloadErrorCount >= 4) {
Log.d("DownManager", "handleMessage: MSG_REDOWNLOAD_ downloadErrorCount: " + downBean2.downloadErrorCount);
String str = downBean2.downloadUrl2;
if (!TextUtils.isEmpty(str) && str.startsWith(HttpHost.DEFAULT_SCHEME_NAME)) {
downBean2.downloadUrl = str;
}
}
a.this.c(downBean2, message.arg1);
return;
case 2:
a.this.d((DownBean) message.obj, message.arg1);
return;
default:
return;
}
}
}
private a() {
HandlerThread handlerThread = new HandlerThread("DownManagerWorker", 10);
handlerThread.start();
this.l = new b(handlerThread.getLooper());
}
public static a a(Context context) {
if (f7475b == null) {
synchronized (a.class) {
if (f7475b == null) {
c = context.getApplicationContext();
f7475b = new a();
}
}
}
return f7475b;
}
public void a(final List<DownBean> list) {
this.l.post(new Runnable() {
@Override
public void run() {
if (list != null) {
az.d("DownManager", String.format("DownManager/downLoad run:thread(%s) downloadBeanList(%s)", Thread.currentThread().getName(), Integer.valueOf(list.size())));
for (DownBean downBean : list) {
az.d("DownManager", String.format("DownManager/downLoad run:thread(%s) downloadBean(%s)", Thread.currentThread().getName(), downBean));
DownBean downBean2 = (DownBean) a.this.d.get(downBean.name);
if (!TextUtils.isEmpty(downBean.name) && downBean2 == null) {
a.this.a(downBean);
}
if (downBean != null && downBean.type == 5 && a.this.k.get(downBean.packageName) == null) {
a.this.k.put(downBean.packageName, downBean);
}
}
}
}
});
}
public ConcurrentHashMap<String, DownBean> a() {
return this.k;
}
public void a(DownBean downBean) {
boolean z;
int i;
boolean z2;
int i2;
int i3;
int i4;
DownBean downBean2 = downBean;
char c2 = 0;
az.d("DownManager", String.format("DownManager/downLoad:thread(%s) downloadBean(%s)", Thread.currentThread().getName(), downBean2));
if (downBean2 == null || downBean2.threadNum <= 0 || TextUtils.isEmpty(downBean2.downloadUrl) || TextUtils.isEmpty(downBean2.filePath) || downBean2.endPos == null || downBean2.startPos == null) {
return;
}
int i5 = downBean2.threadNum;
String str = downBean2.name;
if (downBean2.type != 8) {
DownService.a(c, downBean2.name);
}
downBean2.downloadState = 2;
downBean2.downloadSubState = 0;
downBean2.hasPostPermissionError = false;
boolean S = com.excelliance.kxqp.gs.util.b.S(c);
long j = 1;
if (S) {
if (downBean2.type == 4 && new File(downBean2.filePath).exists() && downBean2.yalp_type == 0) {
boolean isExitsObbByLastInfo = com.excelliance.kxqp.util.master.e.d(c, downBean2.packageName, 0).isExitsObbByLastInfo(downBean2.md5, downBean2.filePath);
String str2 = isExitsObbByLastInfo ? downBean2.md5 : "";
if (isExitsObbByLastInfo && TextUtils.equals(str2, downBean2.md5)) {
for (int i6 = 0; i6 < i5; i6++) {
downBean2.endPos[i6] = downBean2.startPos[i6] - 1;
}
z = false;
} else if (new File(downBean2.filePath).length() > downBean2.endPos[downBean2.endPos.length - 1] + 1) {
an.c(downBean2.filePath);
downBean.resetPos();
az.d("DownManager", "downLoad: remove error file downloadBean: \t" + downBean.toString());
}
}
z = true;
} else {
if (downBean2.type == 4 && new File(downBean2.filePath).exists()) {
boolean isExitsObbByLastInfo2 = com.excelliance.kxqp.util.master.e.d(c, downBean2.packageName, 0).isExitsObbByLastInfo(downBean2.md5, downBean2.filePath);
String str3 = isExitsObbByLastInfo2 ? downBean2.md5 : "";
if (isExitsObbByLastInfo2 && TextUtils.equals(str3, downBean2.md5)) {
for (int i7 = 0; i7 < i5; i7++) {
downBean2.endPos[i7] = downBean2.startPos[i7] - 1;
}
z = false;
}
}
z = true;
}
if (this.d.get(str) != null) {
z = false;
}
if (S) {
if (PatcherInstall.f15641a && z && downBean2.type == 4 && downBean2.patchDownBean != null && !(downBean2 instanceof PatchDownBean) && downBean2.yalp_type == 0) {
downBean2 = downBean2.patchDownBean;
this.d.remove(str);
DownService.b(c, str);
i5 = downBean2.threadNum;
str = downBean2.name;
if (new File(downBean2.filePath).exists()) {
System.currentTimeMillis();
boolean isExitsObbByLastInfo3 = com.excelliance.kxqp.util.master.e.d(c, downBean2.packageName, 0).isExitsObbByLastInfo(downBean2.md5, downBean2.filePath);
String str4 = isExitsObbByLastInfo3 ? downBean2.md5 : "";
if (isExitsObbByLastInfo3 && TextUtils.equals(str4, downBean2.md5)) {
for (int i8 = 0; i8 < i5; i8++) {
downBean2.endPos[i8] = downBean2.startPos[i8] - 1;
}
}
}
}
} else if (PatcherInstall.f15641a && z && downBean2.type == 4 && downBean2.patchDownBean != null && !(downBean2 instanceof PatchDownBean)) {
downBean2 = downBean2.patchDownBean;
this.d.remove(str);
DownService.b(c, str);
i5 = downBean2.threadNum;
str = downBean2.name;
if (new File(downBean2.filePath).exists()) {
System.currentTimeMillis();
boolean isExitsObbByLastInfo4 = com.excelliance.kxqp.util.master.e.d(c, downBean2.packageName, 0).isExitsObbByLastInfo(downBean2.md5, downBean2.filePath);
String str5 = isExitsObbByLastInfo4 ? downBean2.md5 : "";
if (isExitsObbByLastInfo4 && TextUtils.equals(str5, downBean2.md5)) {
for (int i9 = 0; i9 < i5; i9++) {
downBean2.endPos[i9] = downBean2.startPos[i9] - 1;
}
}
}
}
int i10 = i5;
final DownBean downBean3 = downBean2;
if (this.d.get(str) == null || this.d.get(str) == downBean3) {
this.d.put(str, downBean3);
int i11 = 0;
int i12 = 0;
while (true) {
if (i11 >= i10) {
i = i12;
z2 = false;
i2 = 0;
break;
}
if (downBean3.endPos[i11] != downBean3.startPos[i11] - j) {
if (downBean3.startPos[i11] - j >= downBean3.endPos[i11]) {
i = i12;
z2 = false;
Log.e("DownManager", String.format("DownManager/downLoad:thread(%s) invalid index(%s),%s-%s,packageName(%s)", Thread.currentThread().getName(), Integer.valueOf(i11), Long.valueOf(downBean3.startPos[i11]), Long.valueOf(downBean3.endPos[i11]), downBean3.packageName));
i2 = 1;
break;
}
String str6 = downBean3.name + "-" + i11;
RunnableC0305a runnableC0305a = this.e.get(str6);
if (runnableC0305a == null || runnableC0305a.f7496a) {
i4 = i12;
RunnableC0305a runnableC0305a2 = new RunnableC0305a(this, downBean3, i11);
ThreadPoolExecutor a2 = d.a();
Object[] objArr = new Object[6];
objArr[c2] = Thread.currentThread().getName();
objArr[1] = Integer.valueOf(i11);
objArr[2] = Long.valueOf(downBean3.startPos[i11]);
objArr[3] = Long.valueOf(downBean3.endPos[i11]);
objArr[4] = downBean3.packageName;
objArr[5] = runnableC0305a;
az.d("DownManager", String.format("DownManager/downLoad:thread(%s) start task index(%s), %s-%s, packageName(%s), lastTask(%s)", objArr));
a2.execute(runnableC0305a2);
this.e.put(str6, runnableC0305a2);
} else if (runnableC0305a != null) {
StringBuilder sb = new StringBuilder();
sb.append("DownManager/downLoad:thread: exsits index = ");
sb.append(i11);
sb.append(StatisticsManager.COMMA);
sb.append(downBean3.endPos[i11]);
sb.append("-");
i4 = i12;
sb.append(downBean3.endPos[i11]);
sb.append(",lastTask");
sb.append(runnableC0305a);
sb.append("\t");
sb.append(str6);
az.d("DownManager", sb.toString());
} else {
i4 = i12;
}
i12 = i4;
} else {
i12++;
}
i11++;
c2 = 0;
j = 1;
}
if (i2 > 0) {
synchronized (downBean3) {
downBean3.needRemoveFile = true;
downBean3.downloadState = 16;
}
if (downBean3.type == 5) {
bz.a().f(c);
}
i3 = i;
z2 = true;
} else {
e(downBean3);
i3 = i;
if (i3 == i10) {
synchronized (downBean3) {
if (downBean3.downloadState != 18) {
downBean3.downloadState = 1;
}
}
}
}
az.i("DownManager", "---dBean:" + downBean3 + "-sucCount: " + i3 + "-faiCount: " + i2);
if (downBean3.downloadState == 1) {
d.a().execute(new Runnable() {
@Override
public void run() {
System.currentTimeMillis();
a.this.f(downBean3);
}
});
} else if (z2 || downBean3.downloadState != 16) {
f(downBean3);
}
a(c, downBean3);
return;
}
if (!TextUtils.equals(this.d.get(str).toString(), downBean3.toString())) {
az.d("DownManager", "downLoad: diff " + this.d.get(str).toString() + "\t" + downBean3.toString());
return;
}
az.d("DownManager", "downLoad: reload");
}
public void a(String str, int i) {
DownBean downBean;
if (TextUtils.isEmpty(str) || (downBean = this.d.get(str)) == null) {
return;
}
az.d("DownManager", String.format("DownManager/pause:thread(%s) pkg(%s) downStatus(%s)", Thread.currentThread().getName(), downBean.packageName, Integer.valueOf(downBean.downloadState)));
downBean.downloadState = 4;
downBean.downloadSubState = i;
f(downBean);
DownService.b(c, downBean.name);
}
public void a(final ExcellianceAppInfo excellianceAppInfo) {
boolean e = bf.e(c);
Log.d("DownManager", String.format("changeDownLoadStatus/run:thread(%s) netAvaliable(%s) ", Thread.currentThread().getName(), Boolean.valueOf(e)));
if (!e) {
cf.a(c, a(3, c.getString(R.string.network_disconnect_please_check), excellianceAppInfo.appPackageName), 0);
return;
}
Runnable runnable = new Runnable() {
@Override
public void run() {
az.d("DownManager", "changeDownLoadStatus gameType: " + excellianceAppInfo.getGameType());
boolean z = false;
for (Map.Entry<String, DownBean> entry : a.this.c().entrySet()) {
DownBean value = entry.getValue();
if (value != null && TextUtils.equals(excellianceAppInfo.getAppPackageName(), value.packageName)) {
a.this.b(entry.getKey(), 1);
z = true;
}
}
if (z || excellianceAppInfo == null || !excellianceAppInfo.isHandlePause()) {
return;
}
a.this.c(excellianceAppInfo.getAppPackageName());
}
};
if (by.a(c, "sp_config").b("sp_key_DLANTIADDICTION", new HashSet()).contains(excellianceAppInfo.appPackageName)) {
Activity a2 = com.zero.support.core.app.a.a();
if (a2 instanceof FragmentActivity) {
r.a((FragmentActivity) a2, runnable, true, excellianceAppInfo.fromPage);
return;
} else {
runnable.run();
return;
}
}
runnable.run();
}
public void a(String str) {
DownBean downBean;
int i;
if (TextUtils.isEmpty(str) || (downBean = this.d.get(str)) == null) {
return;
}
int i2 = downBean.threadNum;
int i3 = 0;
int i4 = 0;
int i5 = 0;
while (true) {
if (i3 >= i2) {
i = 0;
break;
}
if (downBean.startPos[i3] - 1 != downBean.endPos[i3]) {
if (downBean.startPos[i3] - 1 >= downBean.endPos[i3]) {
i = 1;
break;
}
i5++;
} else {
i4++;
}
i3++;
}
if (i > 0) {
synchronized (downBean) {
Log.e("DownManager", "startDownLoad: needRemoveFile downloadId = " + str + ",failureCount = " + i + ", downloadBean = " + downBean);
downBean.needRemoveFile = true;
downBean.downloadState = 16;
downBean.downloadSubState = 0;
}
f(downBean);
return;
}
if (i5 > 0) {
synchronized (downBean) {
downBean.downloadState = 2;
downBean.downloadSubState = 0;
}
a(downBean);
return;
}
if (i4 == i2) {
synchronized (downBean) {
if (downBean.downloadState != 18) {
downBean.downloadState = 1;
downBean.downloadSubState = 0;
f(downBean);
}
}
}
}
public void e(DownBean downBean) {
long j;
long j2;
long j3;
long j4;
int i = downBean.threadNum;
long j5 = downBean.startPos[0];
for (int i2 = 1; i2 < i; i2++) {
j5 += (downBean.startPos[i2] - downBean.endPos[i2 - 1]) - 1;
}
if (j5 > downBean.size) {
downBean.errorType |= 1;
Log.e("DownManager", "notifyProgressChange: length not match :" + downBean.packageName + j5 + "\t" + downBean.size);
c(downBean);
j = 0L;
} else {
j = j5;
}
if (downBean.size == 0) {
return;
}
if (downBean.type == 5) {
a(a(downBean.packageName, downBean.size, j, this.f), downBean.type);
a(downBean, j);
return;
}
Intent intent = new Intent();
intent.setAction(c.getPackageName() + ".download.notify.progress");
Bundle bundle = new Bundle();
downBean.lastPost = j;
long j6 = downBean.size;
if (downBean.type == 4) {
DownBean h = h(downBean);
if (h != null) {
if (h.lastPost == 0) {
long j7 = 0;
for (int i3 = 1; i3 < h.threadNum; i3++) {
j7 += (h.startPos[i3] - h.endPos[i3 - 1]) - 1;
}
j4 = j7;
} else {
j4 = h.lastPost;
}
j += j4;
j6 += h.size;
az.d("DownManager", "notifyProgressChange: " + j4 + "\t" + h.size + "\t" + h.name);
} else {
j += downBean.offPost;
j6 += downBean.offPost;
}
}
if (com.excelliance.kxqp.gs.util.b.S(c) && downBean.type == 7) {
List<DownBean> j8 = j(downBean);
if (j8.size() > 0) {
for (DownBean downBean2 : j8) {
if (downBean2 != null) {
if (downBean2.lastPost == 0) {
j3 = 0;
for (int i4 = 1; i4 < downBean2.threadNum; i4++) {
j3 += (downBean2.startPos[i4] - downBean2.endPos[i4 - 1]) - 1;
}
} else {
j3 = downBean2.lastPost;
}
j += j3;
j6 += downBean2.size;
}
}
j += downBean.offPost;
j6 += downBean.offPost;
} else {
j += downBean.offPost;
j6 += downBean.offPost;
}
}
if (downBean.type == 9) {
List<DownBean> k = k(downBean);
if (k.size() > 0) {
for (DownBean downBean3 : k) {
if (downBean3 != null) {
if (downBean3.lastPost == 0) {
j2 = 0;
for (int i5 = 1; i5 < downBean3.threadNum; i5++) {
j2 += (downBean3.startPos[i5] - downBean3.endPos[i5 - 1]) - 1;
}
} else {
j2 = downBean3.lastPost;
}
j += j2;
j6 += downBean3.size;
}
}
j += downBean.offPost;
j6 += downBean.offPost;
} else {
j += downBean.offPost;
j6 += downBean.offPost;
}
}
long j9 = j6;
bundle.putInt("index", downBean.index);
bundle.putLong(RankingItem.KEY_SIZE, j9);
bundle.putString(WebActionRouter.KEY_PKG, downBean.packageName);
bundle.putInt("type", downBean.type);
bundle.putLong(ExcellianceAppInfo.KEY_CURRNETPOS, j);
bundle.putString("md5", downBean.md5);
intent.putExtra("bundle", bundle);
a(intent, downBean.appName, downBean.name, downBean.packageName, j9, j, downBean.type, downBean.yalp_type, downBean.childType);
}
private int a(String str, long j, long j2, Map<String, Float> map) {
int size;
float f = (((float) j2) * 1.0f) / ((float) j);
synchronized (map) {
map.put(str, Float.valueOf(f));
float f2 = 0.0f;
Iterator<Float> it = map.values().iterator();
while (it.hasNext()) {
f2 += it.next().floatValue();
}
size = (int) ((f2 / map.size()) * 100.0f);
}
return size;
}
private void a(int i, int i2) {
if (this.j == 0) {
this.j = i;
b(i, i2);
} else if (i - this.j >= 1) {
this.j = i;
b(i, i2);
}
if (i == 100) {
synchronized (this.f) {
this.f.clear();
}
this.j = 0;
}
a(i);
}
private void a(int i) {
Intent intent = new Intent(c.getPackageName() + "action.updateProgress");
intent.putExtra(NotificationCompat.CATEGORY_PROGRESS, i);
c.sendBroadcast(intent);
}
private void b(int i, int i2) {
Intent intent = new Intent(c, (Class<?>) DownService.class);
intent.setAction("action.updateProgress");
intent.putExtra("type", i2);
intent.putExtra(NotificationCompat.CATEGORY_PROGRESS, i);
try {
c.startService(intent);
} catch (Exception e) {
e.printStackTrace();
Log.e("DownManager", "DownManager/sendPluginProgressService:" + e.toString());
}
}
private void a(Intent intent, String str, String str2, String str3, long j, long j2, int i, int i2, int i3) {
int i4;
Long l = this.i.get(str3);
long longValue = l != null ? l.longValue() : 0L;
long currentTimeMillis = System.currentTimeMillis();
boolean z = Math.abs(currentTimeMillis - longValue) > WorkRequest.MIN_BACKOFF_MILLIS;
Integer num = this.h.get(str3);
int i5 = (int) (((((float) j2) * 1.0f) / ((float) j)) * 100.0f);
if (num == null) {
this.h.put(str3, Integer.valueOf(i5));
a(intent, str, str3, i, i5, i2, j2, j, i3);
return;
}
if (j < 209715200 && !str3.equals(c.getPackageName()) && !str3.equals(com.excelliance.kxqp.gs.ui.home.b.a(c).e())) {
if ((i5 % 5 == 0 && i5 != num.intValue()) || z) {
this.h.put(str3, Integer.valueOf(i5));
a(intent, str, str3, i, i5, i2, j2, j, i3);
this.i.put(str3, Long.valueOf(currentTimeMillis));
i4 = i5;
}
i4 = i5;
} else {
i5 = i5;
if (i5 - num.intValue() >= 1 || i5 < num.intValue() || z) {
this.h.put(str3, Integer.valueOf(i5));
i4 = i5;
a(intent, str, str3, i, i5, i2, j2, j, i3);
this.i.put(str3, Long.valueOf(currentTimeMillis));
}
i4 = i5;
}
if (i4 >= 100) {
this.m.remove(str3);
this.h.remove(str3);
this.i.put(str3, Long.valueOf(currentTimeMillis));
}
}
private void a(Intent intent, String str, final String str2, int i, final int i2, int i3, final long j, final long j2, int i4) {
az.e("DownManager", "DownManager/sendAppProgressBroadcast appname:" + str + " packageName:" + str2 + " type:" + i + " percent:" + i2 + " currPos:" + j + " size:" + j2 + "childType:" + i4);
if (i == 8) {
if (i4 == 1 || i4 == 2) {
k.a(c).a(str2, j, j2, i2);
return;
}
return;
}
if (!a(i, str2) || i == 9) {
Intent intent2 = new Intent(c, (Class<?>) DownService.class);
intent2.setAction("action.updateProgress");
intent2.putExtra("type", i);
intent2.putExtra("yalp_type", i3);
intent2.putExtra("appName", str);
intent2.putExtra("packageName", str2);
intent2.putExtra(NotificationCompat.CATEGORY_PROGRESS, i2);
String[] a2 = a(str2, j, j2);
intent2.putExtra("speed", a2[0]);
intent2.putExtra("needTime", a2[1]);
try {
c.startService(intent2);
} catch (Exception unused) {
}
}
LocalBroadcastManager.getInstance(c).sendBroadcast(intent);
if (!cd.a(str2) && str2.equals(c.getPackageName())) {
Bundle bundleExtra = intent.getBundleExtra("bundle");
by.a(c, bundleExtra.getString("md5"), bundleExtra.getLong(ExcellianceAppInfo.KEY_CURRNETPOS), 2);
}
com.excelliance.kxqp.repository.a.a(c).a().runInTransaction(new Runnable() {
@Override
public void run() {
ExcellianceAppInfo b2 = com.excelliance.kxqp.repository.a.a(a.c).b(str2);
if (b2 != null) {
b2.size = j2;
b2.currnetPos = j;
b2.downloadProress = i2;
com.excelliance.kxqp.repository.a.a(a.c).b(b2);
}
}
});
}
private String[] a(String str, long j, long j2) {
String format;
long currentTimeMillis = System.currentTimeMillis();
Long[] lArr = this.m.get(str);
this.m.put(str, new Long[]{Long.valueOf(j), Long.valueOf(currentTimeMillis)});
String e = w.e(c, "caculating");
if (e == null) {
e = "计算中..";
}
if (lArr == null || lArr.length != 2 || j < lArr[0].longValue()) {
return new String[]{e, e};
}
long longValue = (long) (((j - lArr[0].longValue()) * 1000.0d) / (currentTimeMillis - lArr[1].longValue()));
double d = longValue;
long ceil = (long) Math.ceil(((j2 - j) * 1.0d) / d);
if (longValue > PlaybackStateCompat.ACTION_SET_CAPTIONING_ENABLED) {
String e2 = w.e(c, "speed_M");
if (e2 == null) {
e2 = "%s M/s";
}
format = String.format(e2, new DecimalFormat("0.00").format((d * 1.0d) / 1048576.0d));
} else if (longValue > 1024) {
String e3 = w.e(c, "speed_kB");
if (e3 == null) {
e3 = "%s KB/s";
}
format = String.format(e3, new DecimalFormat("0.00").format((d * 1.0d) / 1024.0d));
} else {
String e4 = w.e(c, "speed_k");
if (e4 == null) {
e4 = "%d K/s";
}
format = String.format(e4, Long.valueOf(longValue));
}
StringBuilder sb = new StringBuilder(" ");
long j3 = ceil / 86400;
if (j3 > 0) {
sb.append(j3);
sb.append("天");
}
long j4 = ceil % 86400;
long j5 = j4 / 3600;
if (j5 > 0) {
sb.append(j5);
sb.append("时");
}
long j6 = j4 % 3600;
long j7 = j6 / 60;
if (j7 > 0) {
sb.append(j7);
sb.append("分");
}
long j8 = j6 % 60;
if (j8 > 0) {
sb.append(j8);
sb.append("秒");
}
String[] strArr = new String[2];
strArr[0] = format;
if (j3 <= 100) {
e = sb.toString();
}
strArr[1] = e;
return strArr;
}
private void a(DownBean downBean, long j) {
Bundle bundle = new Bundle();
bundle.putLong("currentPro", j);
bundle.putLong(RankingItem.KEY_SIZE, downBean.size);
bundle.putInt("index", downBean.index);
Intent intent = new Intent(c.getPackageName() + ".action.plugin.progress");
intent.putExtra("bundle", bundle);
Integer num = this.h.get(downBean.name);
int i = (int) (((((float) j) * 1.0f) / ((float) downBean.size)) * 100.0f);
if (num == null) {
this.h.put(downBean.name, Integer.valueOf(i));
LocalBroadcastManager.getInstance(c).sendBroadcast(intent);
return;
}
if (i - num.intValue() >= 1 || i < num.intValue()) {
this.h.put(downBean.name, Integer.valueOf(i));
LocalBroadcastManager.getInstance(c).sendBroadcast(intent);
}
if (i >= 100) {
this.h.remove(downBean.name);
}
}
private void a(Bundle bundle, DownBean downBean) {
String str = "main." + downBean.versionCode;
String str2 = "patch." + downBean.versionCode;
String str3 = downBean.name;
String str4 = str3.contains(str) ? str3 : "";
if (!str3.contains(str2)) {
str3 = "";
}
bundle.putString("main", str4);
bundle.putString(ExcellianceAppInfo.KEY_PATCH, str3);
}
public void f(DownBean downBean) {
a(downBean, -1);
}
public void a(DownBean downBean, int i) {
int i2;
String a2;
synchronized (downBean) {
if (downBean.downloadState == 2 || downBean.downloadState == 0) {
int i3 = 0;
int i4 = 0;
int i5 = 0;
while (true) {
if (i3 >= downBean.threadNum) {
i2 = 0;
break;
}
if (downBean.startPos[i3] - 1 == downBean.endPos[i3]) {
i4++;
} else if (downBean.startPos[i3] - 1 < downBean.endPos[i3]) {
i5++;
} else if (downBean.startPos[i3] - 1 > downBean.endPos[i3]) {
downBean.errorType |= 1;
i2 = 1;
break;
}
i3++;
}
az.d("DownManager", "notifyStateChange: ----suc:" + i4 + "-dow:" + i5 + "-fai:" + i2 + " downloadBean.threadNum:" + downBean.threadNum + " key:" + downBean.name + " threadName:" + Thread.currentThread().getName());
if (i2 > 0) {
Log.e("DownManager", "notifyStateChange: needRemoveFile to remove old file and redown----suc:" + i4 + "-dow:" + i5 + "-fai:" + i2 + " downloadBean.threadNum:" + downBean.threadNum + " key:" + downBean.name + " threadName:" + Thread.currentThread().getName());
downBean.downloadState = 16;
downBean.needRemoveFile = true;
} else if (i4 == downBean.threadNum) {
if (downBean.downloadState != 18) {
downBean.downloadState = 1;
}
} else if (i5 > 0) {
downBean.downloadState = 2;
}
}
}
if (downBean.downloadState == 1) {
String str = null;
boolean S = com.excelliance.kxqp.gs.util.b.S(c);
if (S) {
if (downBean.yalp_type == 0) {
String str2 = downBean.filePath;
a2 = an.a(str2);
az.d("DownManager", String.format("DownManager/notifyStateChange:thread(%s) file(%s) md5 local(%s) server(%s), length(%s)", Thread.currentThread().getName(), str2, a2, downBean.md5, Long.valueOf(new File(str2).length())));
if (!a(downBean, a2)) {
File file = new File(str2);
if (file.exists() && file.isFile()) {
an.b(str2);
a2 = an.a(str2);
Log.e("DownManager", String.format("DownManager/notifyStateChange:thread(%s) decoded file md5 local(%s) server(%s), length(%s)", Thread.currentThread().getName(), a2, downBean.md5, Long.valueOf(new File(str2).length())));
}
}
str = a2;
}
if (downBean.type == 3) {
StatisticsGS.getInstance().uploadUserAction(c, 72, downBean.packageName);
az.i("DownManager", "download success downloadBean:" + downBean);
bz.a().b(c, downBean.packageName, downBean.downloadSource, downBean.download_special_source);
} else if (downBean.type == 5) {
f();
}
if (S) {
if (downBean.yalp_type == 0 && !a(downBean, str)) {
Log.e("DownManager", "notifyStateChange: 1 md5 not match " + downBean.packageName + "\t" + str + "\t" + downBean.md5);
downBean.errorType = 2 | downBean.errorType;
downBean.needRemoveFile = true;
c(downBean);
a(c, downBean, str, true);
} else if (S && downBean.yalp_type > 0 && !com.excelliance.kxqp.gs.m.a.d.a(downBean)) {
az.e("DownManager", "notifyStateChange: 2 SHA not match " + downBean.packageName + "\t" + downBean.SHA);
downBean.errorType = downBean.errorType | 2;
downBean.needRemoveFile = true;
c(downBean);
byte[] b2 = com.excelliance.kxqp.gs.m.a.d.b(downBean);
if (b2 != null && b2.length > 0 && downBean.SHA != null && downBean.SHA.length > 0) {
try {
a(c, downBean, new String(b2, "UTF-8"), false);
} catch (Exception unused) {
}
}
} else if (downBean.type == 6) {
b(downBean);
g(downBean.packageName);
} else if (downBean.type == 8) {
g(downBean);
g(downBean.name);
} else {
az.d("DownManager", "notifyStateChange--success1--md5: " + str + "--dBean: " + downBean);
n(downBean);
g(downBean.name);
}
} else if (!a(downBean, str)) {
Log.e("DownManager", "notifyStateChange: 3 md5 not match " + downBean.packageName + "\t" + str + "\t" + downBean.md5);
downBean.errorType = 2 | downBean.errorType;
downBean.needRemoveFile = true;
c(downBean);
a(c, downBean, str, true);
} else if (downBean.type == 6) {
b(downBean);
g(downBean.packageName);
} else {
az.d("DownManager", "notifyStateChange--success1--md5: " + str + "--dBean: " + downBean);
n(downBean);
g(downBean.name);
}
DownService.b(c, downBean.name);
} else {
String str3 = downBean.filePath;
a2 = an.a(str3);
az.i("DownManager", "notifyStateChange: ------md5-1-2: " + a2 + "----real md5: " + downBean.md5);
if (!a(downBean, a2)) {
File file2 = new File(str3);
boolean z = file2.exists() && file2.isFile();
az.i("DownManager", "notifyStateChange: ------md5-1: " + a2 + "----real md5: " + downBean.md5);
if (z) {
an.b(str3);
str = an.a(str3);
az.i("DownManager", "notifyStateChange: ------md5-2: " + str + "----real md5: " + downBean.md5);
if (downBean.type == 3) {
}
if (S) {
}
DownService.b(c, downBean.name);
}
}
str = a2;
if (downBean.type == 3) {
}
if (S) {
}
DownService.b(c, downBean.name);
}
} else if (downBean.downloadState == 16) {
Log.e("DownManager", String.format("DownManager/notifyStateChange:thread(%s) STATE_FAILURE, index(%s)", Thread.currentThread().getName(), Integer.valueOf(i)));
b(downBean, i);
DownService.b(c, downBean.name);
}
boolean S2 = com.excelliance.kxqp.gs.util.b.S(c);
if (S2) {
if (downBean.type != 7 && (downBean.downloadState != 1 || h(downBean) == null)) {
l(downBean);
}
} else if (downBean.downloadState != 1 || h(downBean) == null) {
l(downBean);
}
if (S2 && downBean.type == 7 && (downBean.downloadState != 1 || i(downBean) == null)) {
l(downBean);
}
if (downBean.downloadState != 16 || downBean.downloadErrorCount < 5) {
return;
}
Log.d("DownManager", String.format("DownManager/notifyStateChange:thread(%s) STATE_FAILURE and error count is limit", Thread.currentThread().getName()));
g(downBean.name);
if (bs.b(downBean.packageName)) {
cf.a(c, "您的谷歌套件下载失败,请检查网络后重试", 0);
this.l.postDelayed(new Runnable() {
@Override
public void run() {
ba.a(a.c).d();
ba.a(a.c).d(a.c);
}
}, 1000L);
} else {
if (downBean.hasPostPermissionError) {
return;
}
cf.a(c, a(1, c.getString(R.string.retry_many_times), downBean.packageName), 0);
}
}
private void g(DownBean downBean) {
az.d("DownManager", "installPlugin/install plugin: ");
boolean z = true;
if (TextUtils.equals(downBean.name, "plugin")) {
InitialData.a(c).a("plugin", "com.excelliance.packageplugin.PackagePluginCallbackImpl", (com.excelliance.kxqp.ui.b.a) null, false);
String string = c.getSharedPreferences("feature_all", 0).getString("current_plugin_path", null);
String str = Build.CPU_ABI;
String a2 = VersionManager.a("ro.product.cpu.abi");
if ((str == null || !str.contains("x86")) && (a2 == null || !a2.contains("x86"))) {
z = false;
}
if (string == null || !new File(string).exists() || z) {
return;
}
by a3 = by.a(c, "sp_flow_plugin_version");
for (String str2 : as.p(c)) {
int a4 = (str2.equals("com.excean.web") || aa.a(c, str2)) ? 0 : com.excelliance.kxqp.wr.a.a().a(0, str2, string, 2);
az.d("DownManager", "installPlugin/install plugin result: " + a4);
if (a4 > 0) {
a3.a(str2, (int) downBean.versionCode);
}
}
an.c(bn.a(c, downBean.name));
return;
}
if (TextUtils.equals(downBean.name, "kcpLib")) {
com.excelliance.kxqp.manager.e.a(c, downBean);
return;
}
if (TextUtils.equals(downBean.name, ResponseAdJarData.TYPE + downBean.packageName)) {
Log.d("DownManager", "installPlugin: adJar_, " + downBean.name + ", " + downBean.toString());
IAdModule iAdModule = (IAdModule) AppJoint.service(IAdModule.class);
if (iAdModule != null) {
iAdModule.downloadAdJarFinish(c, downBean.packageName, Integer.parseInt(String.valueOf(downBean.versionCode)), downBean.filePath);
StatisticsBuilder.getInstance().builder().setDescription("广告相关-下载广告jar成功").setPriKey1(148000).setPriKey2(5).setIntKey0().buildImmediate(c);
return;
}
return;
}
if (downBean.childType == 1 || downBean.childType == 2) {
k.a(c).a(downBean);
}
}
private DownBean h(DownBean downBean) {
if (downBean.type != 4) {
return null;
}
String str = downBean.packageName;
Iterator<Map.Entry<String, DownBean>> it = c().entrySet().iterator();
while (it.hasNext()) {
DownBean value = it.next().getValue();
if (value != null && value != downBean && downBean.type == 4 && TextUtils.equals(str, value.packageName)) {
az.d("DownManager", "notifyStateChange: wait " + downBean.name);
return value;
}
}
return null;
}
private DownBean i(DownBean downBean) {
if (downBean.type != 7) {
return null;
}
String str = downBean.packageName;
Iterator<Map.Entry<String, DownBean>> it = c().entrySet().iterator();
while (it.hasNext()) {
DownBean value = it.next().getValue();
if (value != null && value != downBean && downBean.type == 7 && TextUtils.equals(str, value.packageName)) {
az.d("DownManager", "hasOtherSplitDowning: DownBean: " + downBean.name + " otherSplit :" + value);
return value;
}
}
return null;
}
private List<DownBean> j(DownBean downBean) {
ArrayList arrayList = new ArrayList();
if (downBean.type == 7) {
String str = downBean.packageName;
Iterator<Map.Entry<String, DownBean>> it = c().entrySet().iterator();
while (it.hasNext()) {
DownBean value = it.next().getValue();
if (value != null && value != downBean && downBean.type == 7 && TextUtils.equals(str, value.packageName)) {
az.d("DownManager", "getOtherSplitDowning: DownBean: " + downBean.name + " otherSplit :" + value);
arrayList.add(value);
}
}
}
return arrayList;
}
private List<DownBean> k(DownBean downBean) {
ArrayList arrayList = new ArrayList();
if (downBean.type == 9) {
String str = downBean.packageName;
Iterator<Map.Entry<String, DownBean>> it = c().entrySet().iterator();
while (it.hasNext()) {
DownBean value = it.next().getValue();
if (value != null && value != downBean && downBean.type == 9 && TextUtils.equals(str, value.packageName)) {
az.d("DownManager", "getOtherResourcesDowning: DownBean: " + downBean.name + " otherResource :" + value);
arrayList.add(value);
}
}
}
return arrayList;
}
public boolean b(String str) {
az.d("DownManager", "hasResourcesDowning: pkg: " + str);
Iterator<Map.Entry<String, DownBean>> it = c().entrySet().iterator();
while (it.hasNext()) {
DownBean value = it.next().getValue();
if (value != null && value.type == 9 && TextUtils.equals(str, value.packageName)) {
az.d("DownManager", "hasResourcesDowning: DownBean: " + value.name);
return true;
}
}
return false;
}
public void b(DownBean downBean) {
Intent e = as.e(downBean.filePath);
e.setFlags(268435457);
c.startActivity(e);
}
private void l(final DownBean downBean) {
if (downBean.type == 8) {
return;
}
Intent intent = new Intent();
intent.setAction(c.getPackageName() + ".download.notify.state");
Bundle bundle = new Bundle();
bundle.putInt("index", downBean.index);
bundle.putInt("state", downBean.downloadState);
bundle.putInt("errorCount", downBean.downloadErrorCount);
bundle.putString(WebActionRouter.KEY_PKG, downBean.packageName);
bundle.putString("md5", downBean.md5);
bundle.putInt("type", downBean.type);
a(bundle, downBean);
intent.putExtra("bundle", bundle);
az.d("DownManager", "notifyStateChange bundle: " + bundle);
LocalBroadcastManager.getInstance(c).sendBroadcast(intent);
if (downBean.type != 5 && downBean.downloadState == 16 && downBean.downloadErrorCount >= 5) {
m(downBean);
}
if (!cd.a(downBean.packageName) && downBean.packageName.equals(c.getPackageName())) {
by.a(c, downBean.md5, 2147483647L, downBean.downloadState);
}
com.excelliance.kxqp.repository.a.a(c).a().runInTransaction(new Runnable() {
@Override
public void run() {
ExcellianceAppInfo b2 = com.excelliance.kxqp.repository.a.a(a.c).b(downBean.packageName);
if (b2 != null) {
b2.downloadStatus = downBean.downloadState;
if (b2.downloadStatus == 4 && downBean.downloadSubState == 1) {
b2.downloadSubStatus = downBean.downloadSubState;
} else if ((downBean.downloadState == 2 || downBean.downloadState == 11) && downBean.type == 9) {
b2.downloadSubStatus = 2;
} else {
b2.downloadSubStatus = 0;
}
if (downBean.downloadState == 16 && b2.lastDownloadTime > 0) {
com.excelliance.kxqp.gs.g.c.a().a(b2, false, a.this.a(downBean.errorType, downBean.size), b2.downloadForUpdate, b2.lastDownloadTime);
b2.lastDownloadTime = 0L;
}
com.excelliance.kxqp.repository.a.a(a.c).b(b2);
}
}
});
}
private void m(DownBean downBean) {
synchronized (downBean) {
downBean.downloadState = 4;
}
if (downBean.hasPostPermissionError) {
return;
}
cf.a(c, a(1, c.getString(R.string.retry_many_times), downBean.packageName), 1);
}
private void b(DownBean downBean, int i) {
Log.e("DownManager", "delayRedownLoad: index = " + i + ", downloadBean = " + downBean);
if (downBean.errorType != 0) {
Log.e("DownManager", "delayRedownLoad: " + downBean.errorType);
StatisticsGS.getInstance().uploadUserAction(c, StatisticsBase.UA_DOWNLOAD_FAIL, downBean.errorType, downBean.name);
downBean.errorType = 0;
}
if (downBean.hasPostPermissionError) {
return;
}
synchronized (downBean) {
downBean.downloadState = 16;
}
Message obtainMessage = this.l.obtainMessage(0);
obtainMessage.obj = downBean;
obtainMessage.arg1 = i;
this.l.sendMessage(obtainMessage);
}
public void c(DownBean downBean) {
Log.e("DownManager", "delayRedownLoad: downloadBean = " + downBean);
b(downBean, -1);
}
private boolean a(DownBean downBean, String str) {
String str2 = downBean.md5;
if (cd.a(str2)) {
File file = new File(downBean.filePath);
if (!(file.exists() && file.isFile())) {
return false;
}
long length = file.length();
Log.d("DownManager", String.format("DownManager/compareFile:thread(%s) file(%s) length local(%s) server(%s)", Thread.currentThread().getName(), file.getAbsolutePath(), Long.valueOf(length), Long.valueOf(downBean.size)));
if (length == downBean.size) {
return true;
}
}
return TextUtils.equals(str, str2);
}
private void n(DownBean downBean) {
boolean S = com.excelliance.kxqp.gs.util.b.S(c);
bm.a(c, downBean);
if (downBean.type == 4) {
o(downBean);
return;
}
if (downBean.type == 5) {
u(downBean);
return;
}
if (S && downBean.type == 7) {
p(downBean);
return;
}
if (downBean.type == 9) {
q(downBean);
return;
}
if (S && ((downBean.yalp_type == 3 || downBean.yalp_type == 4) && downBean.type == 3)) {
if (r(downBean) || s(downBean)) {
return;
}
} else if (com.excelliance.kxqp.util.d.b.c && downBean.yalp_type == 0 && downBean.type == 3 && com.excelliance.kxqp.util.d.b.a(c, downBean)) {
return;
}
t(downBean);
y(downBean);
}
private void o(DownBean downBean) {
ExcellianceAppInfo a2;
Log.d("DownManager", String.format("DownManager/installObb:thread(%s) downloadBean(%s)", Thread.currentThread().getName(), downBean));
boolean S = com.excelliance.kxqp.gs.util.b.S(c);
DownService.a(c, downBean.name);
if (downBean instanceof PatchDownBean) {
int v = v(downBean);
Log.i("DownManager", "patch install ret: " + v);
if (v < 0) {
return;
}
} else {
Set<String> set = p.get(downBean.packageName);
if (set != null && set.size() > 0 && (a2 = InitialData.a(c).a(-1, 0, downBean.packageName)) != null && a2.loseObb()) {
VersionManager.a(c, a2, 11);
synchronized (downBean) {
downBean.downloadState = 11;
}
Log.e("DownManager", "installGame: " + set.size() + "\t" + set.size());
l(downBean);
z(downBean);
}
}
try {
if (ResponseData.getClickDownloadPkg(c).contains(downBean.packageName)) {
StatisticsGS.getInstance().uploadUserAction(c, 91, downBean.packageName);
}
c.sendBroadcast(new Intent(c.getPackageName() + "refresh_updatedata"));
az.d("DownManager", "installGame GAME_OBB_FILE_TYPE_");
Intent intent = new Intent();
File file = new File(downBean.filePath);
if (S && downBean.yalp_type > 0) {
az.d("DownManager", "installGame update obb SHA downBean" + downBean);
com.excelliance.kxqp.util.master.e.a(c, file, downBean.packageName, 0, null, Arrays.toString(downBean.SHA));
} else {
com.excelliance.kxqp.util.master.e.a(c, file, downBean.packageName, 0, downBean.md5, null);
}
intent.setComponent(new ComponentName(c.getPackageName(), "com.excelliance.kxqp.gs.service.CustomIntentService"));
intent.setAction(c.getPackageName() + ".refresh.obb.download.state");
VersionBean g = as.g(c, as.b(c, downBean.packageName));
Bundle bundle = new Bundle();
bundle.putString("libName", downBean.packageName);
bundle.putLong(ClientCookie.VERSION_ATTR, g.getVersioncode());
bundle.putLong("obbVer", downBean.versionCode);
bundle.putInt("appId", downBean.appId);
a(bundle, downBean);
intent.putExtra("obbDownState", bundle);
try {
c.startService(intent);
} catch (Exception unused) {
}
} catch (Exception e) {
e.printStackTrace();
}
DownService.b(c, downBean.name);
}
private void p(DownBean downBean) {
az.d("DownManager", "0 installSplit GAME_SPLIT_FILE_TYPE_");
List<DownBean> j = j(downBean);
if (j.size() > 0) {
for (DownBean downBean2 : j) {
az.d("DownManager", "installSplit add offPost0: downBean offPost:" + downBean2.offPost + " downBean.name:" + downBean2.name + " downloadBean.size:" + downBean.size + " name:" + downBean.name);
downBean2.offPost = downBean2.offPost + downBean.size;
az.d("DownManager", "installSplit add offPost1: downBean offPost:" + downBean2.offPost + " downBean.name:" + downBean2.name + " downloadBean.size:" + downBean.size + " name:" + downBean.name);
}
}
if (j.size() == 0) {
az.d("DownManager", "1 installSplit GAME_SPLIT_FILE_TYPE_");
Intent intent = new Intent();
intent.setComponent(new ComponentName(c.getPackageName(), "com.excelliance.kxqp.gs.service.CustomIntentService"));
intent.setAction(c.getPackageName() + ".refresh.split.download.state");
Bundle bundle = new Bundle();
bundle.putString("libName", downBean.packageName);
bundle.putLong(ClientCookie.VERSION_ATTR, downBean.versionCode);
bundle.putInt("appId", downBean.appId);
bundle.putString("filePath", downBean.filePath);
bundle.putInt("downloadState", downBean.downloadState);
bundle.putString("split_name", downBean.split_name);
intent.putExtra("splitDownState", bundle);
try {
c.startService(intent);
} catch (Exception unused) {
}
}
}
private void q(DownBean downBean) {
az.d("DownManager", "0 installAppResources downloadBean = " + downBean);
List<DownBean> k = k(downBean);
if (k.size() > 0) {
for (DownBean downBean2 : k) {
az.d("DownManager", "installAppResources add offPost0: downBean offPost:" + downBean2.offPost + " downBean.name:" + downBean2.name + " downloadBean.size:" + downBean.size + " name:" + downBean.name);
downBean2.offPost = downBean2.offPost + downBean.size;
az.d("DownManager", "installAppResources add offPost1: downBean offPost:" + downBean2.offPost + " downBean.name:" + downBean2.name + " downloadBean.size:" + downBean.size + " name:" + downBean.name);
}
}
if (k.size() == 0) {
ExcellianceAppInfo b2 = com.excelliance.kxqp.repository.a.a(c).b(downBean.packageName);
try {
int i = downBean.downloadState;
downBean.downloadState = 11;
l(downBean);
q.a(c, downBean.filePath, b2);
downBean.downloadState = i;
b2.resourcesDownload = null;
b2.downloadSubStatus = 0;
com.excelliance.kxqp.repository.a.a(c).b(b2);
} catch (Exception e) {
e.printStackTrace();
az.e("DownManager", "installAppResources/unzip e:" + e.getMessage() + " filePath:" + downBean.filePath);
}
}
}
private boolean r(DownBean downBean) {
String path;
boolean z;
if (downBean.yalp_type != 3) {
return false;
}
az.e("DownManager", "checkApkDelta: delta diff enter ");
w(downBean);
synchronized (downBean) {
downBean.downloadState = 11;
}
l(downBean);
ExcellianceAppInfo a2 = InitialData.a(c).a(-1, 0, downBean.packageName);
if (a2 != null && a2.getDownloadStatus() != 11) {
az.e("DownManager", "checkApkDelta: delta diff enter 1");
VersionManager.a(c, a2, 11);
}
az.e("DownManager", "checkApkDelta: delta diff enter DownBean;" + downBean);
az.e("DownManager", "checkApkDelta: delta diff enter path;" + a2.getPath());
az.e("DownManager", " DELTA SIZE:" + downBean.size + " file:size:" + new File(downBean.filePath).length());
com.excelliance.kxqp.gs.m.d.a a3 = com.excelliance.kxqp.gs.m.d.a.a();
Context context = c;
String valueOf = String.valueOf(downBean.appId);
if (new File(a2.getPath()).isDirectory()) {
path = a2.getPath() + "/base.apk";
} else {
path = a2.getPath();
}
boolean a4 = a3.a(context, valueOf, "originalApkFilePath", path);
String str = null;
if (a4) {
if (downBean.isGzip) {
az.e("DownManager", "checkApkDelta: delta diff oldfile de gizp enter filePath:" + downBean.filePath);
str = new File(downBean.filePath).getParent() + File.separator + downBean.packageName + "." + downBean.versionCode + ".apk.delta";
File file = new File(downBean.filePath);
try {
com.excelliance.kxqp.gs.m.e.a.a(file, true);
} catch (Exception e) {
e.printStackTrace();
az.e("DownManager", "checkApkDelta: delta diff oldfile de gizp error ");
x(downBean);
synchronized (downBean) {
downBean.downloadState = 16;
downBean.downloadErrorCount = 5;
l(downBean);
File file2 = new File(str);
if (file2.exists()) {
file2.delete();
}
if (file.exists()) {
file.delete();
}
z = true;
}
}
}
z = false;
f b2 = com.excelliance.kxqp.gs.m.d.a.a().b(c, "appId", String.valueOf(downBean.appId));
b2.e = bn.n(c, b2.c);
b2.d = a2.getPath();
if (!cd.a(str)) {
b2.o.g = str;
}
az.e("DownManager", "checkApkDelta: delta diff enter yApp_Delta;" + b2);
if (!com.excelliance.kxqp.gs.m.e.d.a().a(c.getApplicationContext(), b2)) {
az.e("DownManager", "checkApkDelta: delta diff oldfile error ");
AppExtraBean d = com.excelliance.kxqp.util.master.e.d(c, downBean.packageName, 0);
if (!TextUtils.isEmpty(d.getLastInstallPath()) && new File(d.getLastInstallPath()).exists()) {
az.e("DownManager", "checkApkDelta: delta diff oldfile error 1");
x(downBean);
synchronized (downBean) {
downBean.downloadState = 16;
downBean.downloadErrorCount = 5;
}
l(downBean);
} else {
az.e("DownManager", "checkApkDelta: delta diff oldfile error 2");
x(downBean);
synchronized (downBean) {
downBean.downloadState = 12;
}
l(downBean);
}
} else {
az.e("DownManager", "checkApkDelta: delta diff oldfile success ");
if (!com.excelliance.kxqp.gs.m.a.d.a(b2.e, downBean)) {
az.e("DownManager", "checkApkDelta: delta sha CHECK error ");
AppExtraBean d2 = com.excelliance.kxqp.util.master.e.d(c, downBean.packageName, 0);
if (!TextUtils.isEmpty(d2.getLastInstallPath()) && new File(d2.getLastInstallPath()).exists()) {
az.e("DownManager", "checkApkDelta: delta sha CHECK error 1");
x(downBean);
synchronized (downBean) {
downBean.downloadState = 16;
downBean.downloadErrorCount = 5;
}
l(downBean);
} else {
az.e("DownManager", "checkApkDelta: delta sha CHECK error 2");
x(downBean);
synchronized (downBean) {
downBean.downloadState = 12;
}
l(downBean);
}
z = true;
}
x(downBean);
VersionManager.a(c, a2, 2);
return z;
}
} else {
az.e("DownManager", "checkApkDelta: delta diff oldfile update error 1");
x(downBean);
synchronized (downBean) {
downBean.downloadState = 16;
downBean.downloadErrorCount = 5;
}
l(downBean);
}
return true;
}
private boolean s(DownBean downBean) {
f b2 = com.excelliance.kxqp.gs.m.d.a.a().b(c, "appId", String.valueOf(downBean.appId));
if (b2 != null) {
if (b2.f()) {
return false;
}
az.d("DownManager", "checkSplitApk 0 split downloadBean: " + downBean + " versionCode: " + downBean.versionCode);
Intent intent = new Intent();
intent.putExtra(ClientCookie.VERSION_ATTR, downBean.versionCode);
intent.putExtra("appId", downBean.appId);
intent.putExtra("libName", downBean.packageName);
intent.setAction(c.getPackageName() + ".download.check.check.split");
intent.setComponent(new ComponentName(c.getPackageName(), "com.excelliance.kxqp.gs.service.CustomIntentService"));
try {
c.startService(intent);
} catch (Exception unused) {
}
synchronized (downBean) {
downBean.downloadState = 13;
}
l(downBean);
az.d("DownManager", "checkSplitApk 1 split downloadBean: " + downBean + " versionCode: " + downBean.versionCode);
return true;
}
az.e("DownManager", "checkSplitApk : delta split queryItem error 1");
x(downBean);
synchronized (downBean) {
downBean.downloadState = 16;
downBean.downloadErrorCount = 5;
}
l(downBean);
return true;
}
private void t(DownBean downBean) {
VersionBean g;
boolean S = com.excelliance.kxqp.gs.util.b.S(c);
Intent intent = new Intent();
if (S && downBean.yalp_type == 3) {
g = as.g(c, bn.n(c, downBean.packageName));
} else {
g = as.g(c, downBean.filePath);
}
if (TextUtils.isEmpty(g.getPackageName()) && TextUtils.isEmpty(g.getVesionname()) && g.getVersioncode() == 0) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put(WebActionRouter.KEY_PKG, downBean.packageName);
jSONObject.put(SocialConstants.PARAM_URL, downBean.downloadUrl);
} catch (JSONException e) {
e.printStackTrace();
}
az.d("DownManager", "checkNeedObb: failed to open Zip archive " + jSONObject);
StatisticsGS.getInstance().uploadUserAction(c, 97, 1, jSONObject.toString());
}
if (S && (downBean.yalp_type == 4 || downBean.yalp_type == 3)) {
intent.putExtra("appId", downBean.appId);
}
intent.putExtra(ClientCookie.VERSION_ATTR, g.getVersioncode());
intent.putExtra("libName", downBean.packageName);
ExcellianceAppInfo b2 = com.excelliance.kxqp.repository.a.a(c).b(downBean.packageName);
if (b2 != null) {
intent.putExtra("updateSource", false);
intent.putExtra("downloadForUpdate", b2.downloadForUpdate);
}
intent.setAction(c.getPackageName() + ".download.check.check.obb");
intent.setComponent(new ComponentName(c.getPackageName(), "com.excelliance.kxqp.gs.service.CustomIntentService"));
try {
c.startService(intent);
} catch (Exception unused) {
}
synchronized (downBean) {
downBean.downloadState = 13;
}
l(downBean);
az.d("DownManager", "checkNeedObb downloadBean: " + downBean + " versionByPath: " + g);
}
private void u(DownBean downBean) {
Log.d("DownManager", String.format("DownManager/installGMS:thread(%s) downloadBean(%s)", Thread.currentThread().getName(), downBean));
File file = new File(downBean.filePath);
Log.d("DownManager", String.format("DownManager/installGMS:thread(%s) file(%s) exist(%s) length(%s)", Thread.currentThread().getName(), file.getAbsolutePath(), Boolean.valueOf(file.exists()), Long.valueOf(file.length())));
Bundle bundle = new Bundle();
bundle.putInt("state", downBean.downloadState);
bundle.putInt("index", downBean.index);
Intent intent = new Intent(c.getPackageName() + ".action.plugin.state");
intent.putExtra("bundle", bundle);
LocalBroadcastManager.getInstance(c).sendBroadcast(intent);
}
private int v(DownBean downBean) {
String str;
boolean z;
DownBean h = h(downBean);
boolean z2 = h != null;
if (z2) {
h.offPost = downBean.size;
}
if (!z2) {
downBean.downloadState = 11;
l(downBean);
}
if (o.containsKey(downBean.md5)) {
az.d("DownManager", "installGame: loading generate " + downBean.filePath);
return -1;
}
ExcellianceAppInfo a2 = InitialData.a(c).a(-1, 0, downBean.packageName);
if (!z2 && a2 != null && a2.getDownloadStatus() != 11) {
VersionManager.a(c, a2, 11);
}
o.put(downBean.md5, 1);
Set<String> set = p.get(downBean.packageName);
if (set == null) {
set = new HashSet<>();
p.put(downBean.packageName, set);
}
set.add(downBean.name);
az.d("DownManager", "installGame: generate add " + downBean.name);
if (!z2) {
z(downBean);
}
AppExtraBean d = com.excelliance.kxqp.util.master.e.d(c, downBean.packageName, 0);
com.excelliance.kxqp.util.master.e.a(c, new File(downBean.filePath), downBean.packageName, 0, downBean.md5, null);
az.d("DownManager", "installGame: " + d.getObbInfoJson());
if (d.getObbInfoJson() != null) {
Iterator<String> keys = d.getObbInfoJson().keys();
str = null;
z = false;
while (keys.hasNext()) {
String next = keys.next();
JSONObject optJSONObject = d.getObbInfoJson().optJSONObject(next);
File file = new File(next);
PatchDownBean patchDownBean = (PatchDownBean) downBean;
if (TextUtils.equals(optJSONObject.optString("md5"), patchDownBean.oldMd5)) {
if (file.exists() && file.lastModified() == optJSONObject.optLong(AppExtraBean.KEY_LASTMODIFIED) && TextUtils.equals(an.a(next), patchDownBean.oldMd5)) {
int a3 = PatcherInstall.a(downBean.filePath, next, patchDownBean.targetObb.filePath);
if (a3 == 0) {
String a4 = an.a(patchDownBean.targetObb.filePath);
if (TextUtils.equals(a4, patchDownBean.targetObb.md5)) {
an.c(downBean.filePath);
z = true;
} else {
Log.d("DownManager", "installGame: diff error " + a4 + "\t" + patchDownBean.targetObb.md5);
}
} else {
Log.e("DownManager", "installGame: diff error " + a3 + "\t" + next);
return -2;
}
}
str = next;
}
}
} else {
str = null;
z = false;
}
if (o.containsKey(downBean.md5)) {
o.remove(downBean.md5);
Set<String> set2 = p.get(downBean.packageName);
if (set2 != null) {
set2.remove(downBean.name);
az.d("DownManager", "installGame: generate remove " + downBean.name);
}
}
if (!z) {
Log.e("DownManager", "installGame: diff oldfile error " + str);
if (!TextUtils.isEmpty(d.getLastInstallPath()) && new File(d.getLastInstallPath()).exists()) {
synchronized (downBean) {
downBean.downloadState = 16;
downBean.downloadErrorCount = 5;
}
l(downBean);
return -3;
}
synchronized (downBean) {
downBean.downloadState = 12;
}
l(downBean);
return -3;
}
synchronized (downBean) {
downBean.downloadState = 1;
}
return 0;
}
private void f() {
boolean z = true;
az.d("DownManager", String.format("DownManager/capturePluginDownload:thread(%s)", Thread.currentThread().getName()));
Iterator<Map.Entry<String, DownBean>> it = this.k.entrySet().iterator();
while (true) {
if (!it.hasNext()) {
break;
}
Map.Entry<String, DownBean> next = it.next();
az.d("DownManager", "reportPluginStatistic: " + next.getValue());
if (next.getValue().downloadState != 1) {
z = false;
break;
}
}
if (z) {
g();
}
}
private void g() {
bz.a().d(c);
com.excelliance.kxqp.gs.g.c.a().a(c, true, false, (String) null);
c.sendBroadcast(new Intent(c.getPackageName() + ".action_plugin_download_completed"));
}
private void w(DownBean downBean) {
Intent intent = new Intent();
intent.setAction(c.getPackageName() + ".download.notify.progress");
Bundle bundle = new Bundle();
bundle.putInt("index", downBean.index);
bundle.putLong(RankingItem.KEY_SIZE, downBean.size);
bundle.putString(WebActionRouter.KEY_PKG, downBean.packageName);
bundle.putInt("type", downBean.type);
bundle.putLong(ExcellianceAppInfo.KEY_CURRNETPOS, downBean.size);
intent.putExtra("bundle", bundle);
LocalBroadcastManager.getInstance(c).sendBroadcast(intent);
}
private void x(DownBean downBean) {
final ExcellianceAppInfo a2 = InitialData.a(c).a(-1, 0, downBean.packageName);
JSONObject jSONObject = new JSONObject();
try {
az.d("DownManager", "delta diff set delta status");
jSONObject.put(ExcellianceAppInfo.KEY_YALP_Delta, "not_has");
} catch (JSONException e) {
e.printStackTrace();
}
com.excelliance.kxqp.repository.a.a(c).a().runInTransaction(new Runnable() {
@Override
public void run() {
ExcellianceAppInfo b2 = com.excelliance.kxqp.repository.a.a(a.c).b(a2.getAppPackageName());
if (b2 != null) {
b2.yalpDelta = a2.yalpDelta;
com.excelliance.kxqp.repository.a.a(a.c).b(b2);
}
}
});
}
public static void a(f fVar, boolean z) {
Intent intent = new Intent();
intent.setAction(c.getPackageName() + ".download.notify.state");
Bundle bundle = new Bundle();
bundle.putInt("index", 1);
bundle.putInt("state", 13);
bundle.putInt("errorCount", 0);
bundle.putString(WebActionRouter.KEY_PKG, fVar.c);
bundle.putInt("type", 3);
intent.putExtra("bundle", bundle);
az.d("DownManager", "sendInstall notifyStateChange bundle: " + bundle);
LocalBroadcastManager.getInstance(c).sendBroadcast(intent);
int c2 = au.a().c(fVar.c);
az.d("DownManager", "sendInstall handleInstallGame: " + c2);
fVar.e = bn.n(c, fVar.c);
if ((c2 & 240) != 16) {
az.d("DownManager", "sendInstall notifyStateChange install service");
Intent intent2 = new Intent("com.excelliance.kxqp.action.installDownApps");
intent2.setComponent(new ComponentName(c.getPackageName(), "com.excelliance.kxqp.SmtServService"));
az.d("DownManager", "yalp addApps(): ");
Bundle bundle2 = new Bundle();
bundle2.putBoolean("is_split_apk", z);
bundle2.putString(WebActionRouter.KEY_PKG, fVar.c);
bundle2.putString("apkPath", fVar.e);
bundle2.putInt("installType", 1);
bundle2.putInt("sourceType", 3);
bundle.putInt("position", 11);
intent2.putExtra("bundle", bundle2);
az.d("DownManager", "sendInstall notifyStateChange install service 1");
try {
c.startService(intent2);
return;
} catch (Exception unused) {
return;
}
}
as.c(c, fVar.c, fVar.e);
}
private void y(DownBean downBean) {
String str;
int c2 = au.a().c(downBean.packageName);
az.d("DownManager", "handleInstallGame: " + c2);
if (com.excelliance.kxqp.gs.util.b.S(c) && downBean.yalp_type == 3) {
str = new File(downBean.filePath).getParent() + File.separator + "base.apk";
az.d("DownManager", "handleInstallGame: apkPath" + str);
} else {
str = downBean.filePath;
}
if ((c2 & 240) != 16) {
Intent intent = new Intent("com.excelliance.kxqp.action.installDownApps");
intent.setComponent(new ComponentName(c.getPackageName(), "com.excelliance.kxqp.SmtServService"));
az.d("DownManager", "addApps(): " + downBean);
Bundle bundle = new Bundle();
bundle.putString(WebActionRouter.KEY_PKG, downBean.packageName);
bundle.putString("apkPath", str);
az.d("DownManager", "handleInstallGame: apkPath" + str);
bundle.putInt("installType", 1);
bundle.putInt("sourceType", downBean.type);
bundle.putString(ExcellianceAppInfo.KEY_DOWNLOAD_SOURCE, downBean.downloadSource);
bundle.putInt("position", 11);
intent.putExtra("bundle", bundle);
try {
c.startService(intent);
return;
} catch (Exception unused) {
return;
}
}
as.c(c, downBean.packageName, downBean.filePath);
}
private void z(DownBean downBean) {
int i;
Intent intent = new Intent();
intent.setAction(c.getPackageName() + ".download.notify.progress");
Bundle bundle = new Bundle();
bundle.putInt("index", downBean.index);
long j = 100;
bundle.putLong(RankingItem.KEY_SIZE, 100L);
bundle.putString(WebActionRouter.KEY_PKG, downBean.packageName);
bundle.putInt("type", downBean.type);
if (o.containsKey(downBean.md5)) {
i = 2;
j = 1;
} else {
i = 1;
}
bundle.putLong(ExcellianceAppInfo.KEY_CURRNETPOS, j);
intent.putExtra("bundle", bundle);
LocalBroadcastManager.getInstance(c).sendBroadcast(intent);
bundle.putString("a", getClass().getSimpleName());
Intent intent2 = new Intent(c.getPackageName() + ".mock.progress");
intent2.setComponent(new ComponentName(c.getPackageName(), "com.excelliance.kxqp.gs.service.CustomIntentService"));
intent2.putExtra("bundle", bundle);
PendingIntent service = PendingIntent.getService(c, 0, intent2, 0);
AlarmManager alarmManager = (AlarmManager) c.getSystemService(NotificationCompat.CATEGORY_ALARM);
alarmManager.cancel(service);
alarmManager.set(1, System.currentTimeMillis() + ((long) i) < 80 ? 1000L : 4000L, service);
}
public void c(DownBean downBean, int i) {
if (downBean == null) {
return;
}
Log.e("DownManager", String.format("DownManager/reDownloadBean:thread(%s) downIndex(%s),downloadBean(%s)", Thread.currentThread().getName(), Integer.valueOf(i), downBean));
synchronized (downBean) {
int i2 = downBean.threadNum;
if (i < 0 || i >= i2) {
for (int i3 = 0; i3 < i2; i3++) {
if (i3 == 0) {
downBean.startPos[i3] = 0;
} else {
downBean.startPos[i3] = downBean.endPos[i3 - 1] + 1;
}
}
downBean.count = 0L;
} else {
az.d("DownManager", String.format("DownManager/reDownloadBean:thread(%s) downloadBean(%s)", Thread.currentThread().getName(), downBean));
}
downBean.downloadState = 2;
}
String str = downBean.filePath;
if (TextUtils.isEmpty(str)) {
return;
}
File parentFile = new File(str).getParentFile();
if (parentFile != null && !parentFile.exists()) {
parentFile.mkdirs();
}
ay.a(downBean, c);
a(downBean);
}
public void b(final String str, final int i) {
tp.f(new Runnable() {
@Override
public void run() {
if (TextUtils.isEmpty(str)) {
return;
}
int d = a.this.d(str);
az.d("DownManager", String.format("DownManager/switchState:thread(%s) downloadId(%s) downloadState(%s)", Thread.currentThread().getName(), str, Integer.valueOf(d)));
if (d == 2) {
a.this.a(str, i);
} else {
a.this.a(str);
}
}
});
}
public void a(String str, int i, int i2) {
az.d("DownManager", "switchState downloadId downloadId: " + str + " current state: " + i);
if (TextUtils.isEmpty(str) || d(str) == i) {
return;
}
az.d("DownManager", "switchState downloadId downloadId: " + str + " new state: " + i);
if (i == 2) {
a(str);
} else {
if (i != 4) {
return;
}
a(str, i2);
}
}
public void c(final String str) {
tp.f(new Runnable() {
@Override
public void run() {
ResourcesDownloadInfo t;
boolean z;
ExcellianceAppInfo b2 = com.excelliance.kxqp.repository.a.a(a.c).b(str);
if (b2 != null) {
boolean z2 = false;
if ("7".equals(b2.gameType) && b2.downloadStatus != 1 && b2.downloadStatus != 0 && com.excelliance.kxqp.util.d.b.a(b2) && b2.isHandlePause()) {
if (a.this.a(str, (ExcellianceAppInfo) null)) {
ArrayList<DownBean> arrayList = new ArrayList();
DownBean a2 = ah.a(a.c, b2.getAppName(), str, 3, "");
if (!TextUtils.isEmpty(b2.getPath()) && !b2.getPath().contains(com.excelliance.kxqp.util.master.e.b(a.c))) {
a2.filePath = b2.getPath();
if (a2.filePath != null && !a2.filePath.contains(a.c.getPackageName())) {
a2.filePath = bn.k(a.c, str);
}
}
az.d("DownManager", String.format("resumeNewDownloadToTaskMainlandPauseHandle:thread(%s) name(%s)", Thread.currentThread().getName(), b2.getAppName()));
arrayList.add(a2);
ah.a(a.c, arrayList);
ArrayList arrayList2 = new ArrayList();
for (DownBean downBean : arrayList) {
if (!cd.a(downBean.packageName) && !cd.a(downBean.downloadUrl)) {
arrayList2.add(downBean);
}
}
if (arrayList2.size() > 0) {
a.this.a(arrayList2);
return;
}
return;
}
return;
}
if (com.excelliance.kxqp.util.d.b.c && b2.loseYalpSplit() && b2.isHandlePause()) {
az.d("DownManager", " resumeNewDownloadToTaskMainlandPauseHandle: splitLose " + str + "\t" + b2.getGameType());
AppDownLoadInfoBean a3 = com.excelliance.kxqp.gs.d.a.a().a(a.c, str);
if (a3 == null || a3.baseIsEmpty() || cd.a(a3.mBase.filePath)) {
return;
}
int h = as.h(a.c, a3.mBase.filePath);
Intent intent = new Intent();
intent.putExtra(ClientCookie.VERSION_ATTR, Long.valueOf(h));
intent.putExtra("libName", str);
intent.putExtra("ignoreFile", true);
intent.putExtra("appId", b2.appId);
intent.putExtra("filePath", a3.mBase.filePath);
intent.setAction(a.c.getPackageName() + ".download.check.check.split");
intent.setComponent(new ComponentName(a.c.getPackageName(), "com.excelliance.kxqp.gs.service.CustomIntentService"));
a.c.startService(intent);
return;
}
if (b2.loseObb() && b2.isHandlePause()) {
ArrayList<DownBean> arrayList3 = new ArrayList();
String mainObb = b2.getMainObb();
int h2 = as.h(a.c, b2.getPath());
if (TextUtils.isEmpty(mainObb) || TextUtils.equals(mainObb, "null")) {
z = true;
} else {
if (a.this.a(mainObb, (ExcellianceAppInfo) null)) {
arrayList3.add(ah.a(a.c, b2.getAppName(), mainObb, str, h2));
}
z = false;
}
String patchObb = b2.getPatchObb();
if (TextUtils.isEmpty(patchObb) || TextUtils.equals(patchObb, "null")) {
z2 = z;
} else if (a.this.a(patchObb, (ExcellianceAppInfo) null)) {
arrayList3.add(ah.a(a.c, b2.getAppName(), patchObb, str, h2));
}
if (!z2 || h2 <= 0) {
ah.a(a.c, arrayList3);
ArrayList arrayList4 = new ArrayList();
for (DownBean downBean2 : arrayList3) {
if (!cd.a(downBean2.packageName) && !cd.a(downBean2.downloadUrl)) {
arrayList4.add(downBean2);
}
}
if (arrayList4.size() > 0) {
a.this.a(arrayList4);
return;
}
return;
}
Log.d("DownManager", "resumeNewDownloadToTaskMainlandPauseHandle: obbLose " + str + "\t" + b2.getGameType());
Intent intent2 = new Intent();
intent2.putExtra(ClientCookie.VERSION_ATTR, Long.valueOf((long) h2));
intent2.putExtra("libName", str);
intent2.putExtra("ignoreFile", true);
intent2.setAction(a.c.getPackageName() + ".download.check.check.obb");
intent2.setComponent(new ComponentName(a.c.getPackageName(), "com.excelliance.kxqp.gs.service.CustomIntentService"));
a.c.startService(intent2);
return;
}
if (!b2.loseResources() || !b2.isHandlePause() || (t = ay.t(b2.resourcesDownload)) == null || TextUtils.isEmpty(t.url) || t.size <= 0) {
return;
}
DownBean downBean3 = new DownBean();
downBean3.appName = b2.appName;
downBean3.downloadUrl = t.url;
downBean3.name = "resources:" + b2.getVersionCode() + ":" + b2.getAppPackageName();
downBean3.packageName = b2.getAppPackageName();
downBean3.type = 9;
downBean3.size = t.size;
downBean3.md5 = t.md5;
String path = b2.getPath();
if (path == null || !path.contains(a.c.getPackageName())) {
path = bn.k(a.c, b2.getAppPackageName());
}
File file = new File(path);
if (file.isFile()) {
path = file.getParent();
}
downBean3.filePath = path + File.separator + "resources" + File.separator + "resources.zip";
if (!new File(path + File.separator + "resources").exists()) {
new File(path + File.separator + "resources").mkdirs();
}
File file2 = new File(downBean3.filePath);
if (file2.exists() && new File(downBean3.filePath).length() > downBean3.size) {
az.e("DownManager", "resumeNewDownloadToTaskMainlandPauseHandle loseResources called with: thread = 【" + Thread.currentThread() + "】, delete file = " + downBean3.filePath);
file2.delete();
}
downBean3.versionCode = 1;
downBean3.downloadSource = "";
as.a(downBean3);
az.e("DownManager", "resumeNewDownloadToTaskMainlandPauseHandle loseResources called with: thread = 【" + Thread.currentThread() + "】, downBean = " + downBean3);
a.a(a.c).a(downBean3);
}
}
});
}
public boolean a(String str, ExcellianceAppInfo excellianceAppInfo) {
az.d("DownManager", "checkPlayDownloadLegal pkg: " + str);
if (cd.a(str)) {
return false;
}
boolean z = !e(str);
az.d("DownManager", "checkPlayDownloadLegal isLegal1: " + z);
if (excellianceAppInfo == null) {
return z;
}
if (!com.excelliance.kxqp.bitmap.a.a.b(c, str).update) {
az.d("DownManager", "checkPlayDownloadLegal isLegal2: " + str);
z = false;
}
return z ? !bs.d(str) : z;
}
public int d(String str) {
DownBean downBean;
if (TextUtils.isEmpty(str) || (downBean = this.d.get(str)) == null) {
return 0;
}
return downBean.downloadState;
}
public void d(DownBean downBean, int i) {
if (i == -1) {
int i2 = downBean.threadNum;
for (int i3 = 0; i3 < i2; i3++) {
RunnableC0305a runnableC0305a = this.e.get(downBean.name + "-" + i3);
if (runnableC0305a != null) {
d.a(runnableC0305a);
this.e.remove(downBean.name + "-" + i3);
}
}
return;
}
RunnableC0305a runnableC0305a2 = this.e.get(downBean.name + "-" + i);
if (runnableC0305a2 != null) {
d.a(runnableC0305a2);
this.e.remove(downBean.name + "-" + i);
}
}
public void d(DownBean downBean) {
int i = downBean.threadNum;
for (int i2 = 0; i2 < i; i2++) {
RunnableC0305a runnableC0305a = this.e.get(downBean.name + "-" + i2);
if (runnableC0305a != null) {
runnableC0305a.c.downloadState = 18;
d.a(runnableC0305a);
this.e.remove(downBean.name + "-" + i2);
File file = new File(runnableC0305a.c.filePath);
if (file.exists()) {
file.delete();
}
if (!bs.m(runnableC0305a.c.name)) {
az.d("DownManager", "1 gyz remove bean:" + runnableC0305a.c);
com.excelliance.kxqp.gs.multi.a.a.a(c).update(runnableC0305a.c.name, runnableC0305a.c.type, "");
}
}
}
this.d.remove(downBean.name);
bi.a().b(c, downBean.packageName);
DownService.b(c, downBean.packageName);
DownService.b(c, downBean.name);
}
public class RunnableC0305a implements Runnable {
public boolean f7496a;
private DownBean c;
private int d;
private int e;
private final int f;
RunnableC0305a(a aVar, DownBean downBean, int i) {
this(downBean, i, 0);
}
RunnableC0305a(DownBean downBean, int i, int i2) {
this.f = 5;
this.f7496a = false;
this.c = downBean;
this.d = i;
this.e = i2;
}
public String toString() {
return "DownLoadTask{mDownloadBean=" + this.c + ", mIndex=" + this.d + ", mRetryIndex=" + this.e + ", retryMax=5, cancel=" + this.f7496a + '}';
}
@Override
public void run() {
HttpsURLConnection httpsURLConnection;
Process.setThreadPriority(10);
File file = new File(this.c.filePath);
if (!file.exists()) {
az.d("DownManager", String.format("DownLoadTask/run:thread(%s) file(%s) exist(%s)", Thread.currentThread().getName(), file, Boolean.valueOf(file.exists())));
try {
org.apache.commons.b.b.c(file);
} catch (IOException e) {
e.printStackTrace();
if (!e.toString().contains("Unable to set the last modification time")) {
Log.e("DownManager", "DownLoadTask/run: touch exception " + e.toString());
if (Build.VERSION.SDK_INT >= 30 && !a.c.getPackageManager().canRequestPackageInstalls()) {
com.excelliance.kxqp.bitmap.ui.b.a().a(GSBaseActivity.SHOW_REQUEST_PACKAGE_INSTALL_REQ);
}
synchronized (this.c) {
this.c.downloadState = 4;
a.this.f(this.c);
return;
}
}
Log.e("DownManager", "DownLoadTask/run:" + e.toString());
}
az.d("DownManager", String.format("DownLoadTask/run:thread(%s) after touch file(%s) exist(%s)", Thread.currentThread().getName(), file, Boolean.valueOf(file.exists())));
}
try {
try {
ac b2 = new x.a().b(60L, TimeUnit.SECONDS).c(60L, TimeUnit.SECONDS).a(60L, TimeUnit.SECONDS).a().a(new aa.a().a(this.c.downloadUrl).b(HttpHeaders.RANGE, "bytes=" + this.c.startPos[this.d] + "-" + this.c.endPos[this.d]).b()).b();
az.d("DownManager", String.format("DownLoadTask/run:thread(%s) response code(%s) Content-Length(%s), mIndex(%s), %s-%s(%s),", Thread.currentThread().getName(), Integer.valueOf(b2.c()), b2.a("Content-Length"), Integer.valueOf(this.d), Long.valueOf(this.c.startPos[this.d]), Long.valueOf(this.c.endPos[this.d]), Long.valueOf(this.c.endPos[this.d] - this.c.startPos[this.d])));
ad h = b2.h();
if (a.c.getPackageName().equals(this.c.packageName)) {
try {
long parseLong = Long.parseLong(b2.a("Content-Length"));
if (parseLong > 0) {
this.c.endPos[this.d] = (this.c.startPos[this.d] + parseLong) - 1;
}
az.i("DownManager", String.format("op update download:startPos(%s),endPos(%s)", Long.valueOf(this.c.startPos[this.d]), Long.valueOf(this.c.endPos[this.d])));
} catch (Exception unused) {
az.i("DownManager", "op update download,parse Content-Length,faild");
}
}
int c = b2.c();
if (c < 200 || c >= 300) {
this.e++;
a(this.d);
Log.e("DownManager", String.format("DownLoadTask/run:thread(%s) response error code(%s) mIndex(%s),(%s-%s)", Thread.currentThread().getName(), Integer.valueOf(c), Integer.valueOf(this.d), Long.valueOf(this.c.startPos[this.d]), Long.valueOf(this.c.endPos[this.d])));
} else if (h != null) {
a(file, h.f());
} else {
Log.e("DownManager", String.format("DownLoadTask/run:thread(%s) empty body error code(%s) mIndex(%s),(%s-%s)", Thread.currentThread().getName(), Integer.valueOf(c), Integer.valueOf(this.d), Long.valueOf(this.c.startPos[this.d]), Long.valueOf(this.c.endPos[this.d])));
a(this.d);
}
} catch (IOException e2) {
Log.e("DownManager", "DownLoadTask/run:exception mIndex = " + this.d + ", " + this.c.startPos[this.d] + "-" + this.c.endPos[this.d]);
e2.printStackTrace();
StringBuilder sb = new StringBuilder();
sb.append("DownLoadTask/run:");
sb.append(e2.toString());
Log.e("DownManager", sb.toString());
a(this.d);
if (e2 instanceof SSLHandshakeException) {
HttpsURLConnection httpsURLConnection2 = null;
try {
try {
String str = this.c.downloadUrl;
if (!TextUtils.isEmpty(str) && str.toLowerCase().startsWith("https:")) {
httpsURLConnection = (HttpsURLConnection) new URL(str).openConnection();
try {
httpsURLConnection.connect();
Certificate[] serverCertificates = httpsURLConnection.getServerCertificates();
Log.e("DownManager", String.format("DownLoadTask/run:thread(%s) ssl certificate downloadUrl(%s)", Thread.currentThread().getName(), this.c.downloadUrl));
if (serverCertificates != null) {
Log.e("DownManager", "DownLoadTask/run:ssl certificate certs.length = " + serverCertificates.length + ",downloadUrl = " + this.c.downloadUrl);
for (Certificate certificate : serverCertificates) {
X509Certificate x509Certificate = (X509Certificate) certificate;
Log.e("DownManager", "DownLoadTask/run:ssl certificate x509Certificate = " + x509Certificate + ",downloadUrl = " + this.c.downloadUrl);
if (x509Certificate != null) {
Log.e("DownManager", String.format("DownLoadTask/run:ssl certificate getSubjectDN(%s), getNotBefore(%s), getNotAfter(%s), ", x509Certificate.getSubjectDN(), x509Certificate.getNotBefore(), x509Certificate.getNotAfter()));
} else {
Log.e("DownManager", "DownLoadTask/run:ssl certificate x509Certificate = null downloadUrl = " + this.c.downloadUrl);
}
}
}
httpsURLConnection2 = httpsURLConnection;
} catch (Exception e3) {
e = e3;
httpsURLConnection2 = httpsURLConnection;
e.printStackTrace();
Log.e("DownManager", "DownLoadTask/run:ssl certificate Exception mDownloadBean = " + this.c);
} catch (Throwable th) {
th = th;
if (httpsURLConnection != null) {
httpsURLConnection.disconnect();
}
throw th;
}
}
} catch (Exception e4) {
e = e4;
}
} catch (Throwable th2) {
th = th2;
httpsURLConnection = httpsURLConnection2;
}
}
}
} finally {
this.f7496a = true;
}
}
private void a(int i) {
boolean e = bf.e(a.c);
Log.d("DownManager", String.format("DownLoadTask/run:thread(%s) netAvaliable(%s) mIndex(%s), connect fail", Thread.currentThread().getName(), Boolean.valueOf(e), Integer.valueOf(this.d)));
if (e) {
cf.a(a.c, a.this.a(2, a.c.getString(R.string.network_data_wrong_and_retry), this.c.packageName), 0);
synchronized (this.c) {
if (this.c.downloadState != 4) {
this.c.downloadState = 16;
}
}
} else {
cf.a(a.c, a.this.a(3, a.c.getString(R.string.network_disconnect_please_check), this.c.packageName), 0);
synchronized (this.c) {
this.c.downloadState = 4;
}
}
a.this.a(this.c, i);
}
private boolean a(File file, InputStream inputStream) {
if (this.d == 0 && this.c.type == 3) {
StatisticsGS.getInstance().uploadUserAction(a.c, 73, this.c.packageName);
}
a.this.a(this.c, a.c);
int a2 = a(inputStream, this.c, this.d, file);
boolean z = true;
az.d("DownManager", String.format("DownLoadTask/readData:thread(%s) index(%s), mRetryIndex(%s) taskResult(%s), downloadState(%s)", Thread.currentThread().getName(), Integer.valueOf(this.d), Integer.valueOf(this.e), Integer.valueOf(a2), Integer.valueOf(this.c.downloadState)));
this.f7496a = true;
if (this.c.downloadState == 18) {
return true;
}
a.this.e(this.c);
synchronized (this.c) {
if (this.c.downloadState != 16) {
a.this.A(this.c);
if (a2 == 1) {
a.this.f(this.c);
} else if (a2 == 2) {
if (this.c.downloadState == 4) {
a.this.f(this.c);
} else if (this.e >= 5) {
cf.a(a.c, a.this.a(2, a.c.getString(R.string.network_data_wrong_and_retry), this.c.packageName), 0);
this.c.downloadState = 16;
a.this.f(this.c);
} else {
this.e++;
String str = this.c.name + "-" + this.d;
if (a.this.e.get(str) != this) {
z = false;
}
Log.e("DownManager", "DownLoadTask/readData: retryIndex " + this.e + "\t" + z + "\t" + str + "\t" + this.f7496a);
if (z && this.f7496a) {
RunnableC0305a runnableC0305a = new RunnableC0305a(this.c, this.d, this.e);
Log.e("DownManager", "DownLoadTask/readData: inDown and cancel retryIndex " + this.e + ",mIndex=" + this.d + ", key = " + str + ", mDownloadBean = " + this.c);
a.this.e.put(str, runnableC0305a);
d.a().execute(runnableC0305a);
}
}
}
} else {
Log.d("DownManager", String.format("DownLoadTask/readData:thread(%s) STATE_FAILURE restart all index(%s), mRetryIndex(%s) taskResult(%s), downloadState(%s)", Thread.currentThread().getName(), Integer.valueOf(this.d), Integer.valueOf(this.e), Integer.valueOf(a2), Integer.valueOf(this.c.downloadState)));
this.c.errorType |= 4;
a.this.a(this.c, this.d);
}
}
return false;
}
private int a(InputStream inputStream, DownBean downBean, int i, File file) {
Throwable th;
RandomAccessFile randomAccessFile;
com.excelliance.kxqp.gs.multi.down.b bVar = new com.excelliance.kxqp.gs.multi.down.b(a.c, inputStream, downBean.packageName);
Context context = a.c;
int i2 = 4;
int i3 = 0;
int i4 = 1;
RandomAccessFile randomAccessFile2 = null;
try {
try {
randomAccessFile = new RandomAccessFile(file, "rwd");
} catch (IOException e) {
e = e;
}
} catch (Throwable th2) {
th = th2;
randomAccessFile = randomAccessFile2;
}
try {
randomAccessFile.seek(downBean.startPos[i]);
byte[] bArr = new byte[8192];
while (true) {
int a2 = bVar.a(bArr, downBean);
if (a2 == -1 || downBean.downloadState == i2 || downBean.downloadState == 18) {
break;
}
if (this.e > 0) {
Log.e("DownManager", "writeToLocal: reset mRetryIndex " + this.e + ", index = " + i + ", len = " + a2);
this.e = i3;
}
if (downBean.startPos[i] + a2 > downBean.endPos[i] + 1) {
Log.e("DownManager", "writeToLocal: pre " + a2);
a2 = (int) ((downBean.endPos[i] + 1) - downBean.startPos[i]);
Log.e("DownManager", "writeToLocal: need " + a2);
if (a2 <= 0) {
a2 = 0;
}
downBean.errorType |= i4;
}
randomAccessFile.write(bArr, i3, a2);
long[] jArr = downBean.startPos;
jArr[i] = jArr[i] + a2;
downBean.count++;
if (downBean.count % 1000 == 0) {
a.this.A(downBean);
}
a.this.e(downBean);
i2 = 4;
i3 = 0;
i4 = 1;
}
if (downBean.startPos[i] == 0) {
try {
randomAccessFile.close();
} catch (IOException e2) {
e2.printStackTrace();
}
com.excelliance.kxqp.gs.util.q.a(bVar.b());
return 2;
}
try {
randomAccessFile.close();
} catch (IOException e3) {
e3.printStackTrace();
}
com.excelliance.kxqp.gs.util.q.a(bVar.b());
return 1;
} catch (IOException e4) {
e = e4;
randomAccessFile2 = randomAccessFile;
a.this.a(context, e, downBean);
e.printStackTrace();
Log.e("DownManager", "DownManager/writeToLocal:" + e.toString());
String message = e.getMessage();
boolean z = message != null && message.toLowerCase().contains("permission");
Log.e("DownManager", "DownManager/writeToLocal: errMsg = " + message + ", permissionError = " + z);
if (z && Build.VERSION.SDK_INT >= 30 && !a.c.getPackageManager().canRequestPackageInstalls() && !downBean.hasPostPermissionError) {
com.excelliance.kxqp.bitmap.ui.b.a().a(GSBaseActivity.SHOW_REQUEST_PACKAGE_INSTALL_REQ);
downBean.hasPostPermissionError = true;
synchronized (downBean) {
downBean.downloadState = 4;
}
}
if (randomAccessFile2 != null) {
try {
randomAccessFile2.close();
} catch (IOException e5) {
e5.printStackTrace();
}
}
com.excelliance.kxqp.gs.util.q.a(bVar.b());
return 2;
} catch (Throwable th3) {
th = th3;
if (randomAccessFile != null) {
try {
randomAccessFile.close();
} catch (IOException e6) {
e6.printStackTrace();
}
}
com.excelliance.kxqp.gs.util.q.a(bVar.b());
throw th;
}
}
}
public String a(int i, String str, String str2) {
String format = String.format("下载失败(%s):%s", Integer.valueOf(i), str);
BiEventDialogShow biEventDialogShow = new BiEventDialogShow();
biEventDialogShow.game_packagename = str2;
biEventDialogShow.dialog_type = "toast";
biEventDialogShow.toast_name = format;
com.excelliance.kxqp.gs.g.c.a().a(biEventDialogShow);
return format;
}
public void a(DownBean downBean, Context context) {
int i;
try {
if (bf.a(context)) {
i = 1;
} else {
i = bf.b(context) ? 2 : 3;
}
if (downBean != null) {
String str = downBean.downloadUrl;
String str2 = downBean.downloadUrl2;
if (TextUtils.isEmpty(str) || !TextUtils.equals(str, str2)) {
return;
}
Intent intent = new Intent("com.excelliance.kxqp.action.space.stat");
intent.setComponent(new ComponentName(context.getPackageName(), "com.excelliance.kxqp.SmtServService"));
intent.putExtra("type", StatisticsBase.UA_SUITE_DOWNLOAD_BACK_UP_URL_OK);
intent.putExtra("sk1", i);
context.startService(intent);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void A(DownBean downBean) {
az.d("DownManager", "refreshPluginJson downloadBean: " + downBean);
ay.a(downBean, c);
}
public void a(boolean z) {
this.f7476a = z;
}
public void b() {
Iterator<String> it = this.e.keySet().iterator();
while (it.hasNext()) {
d.a(this.e.get(it.next()));
}
this.e.clear();
this.d.clear();
}
public boolean e(String str) {
for (String str2 : this.d.keySet()) {
az.d("DownManager", "checkInQueue name: " + str + " key: " + str2);
if (TextUtils.equals(str2, str) && this.d.get(str2).downloadState == 2) {
return true;
}
}
return false;
}
public void f(String str) {
if (TextUtils.isEmpty(str)) {
return;
}
DownBean downBean = this.d.get(str);
az.d("DownManager", "gyz remove bean: " + downBean);
if (downBean != null) {
synchronized (downBean) {
if (downBean.downloadState != 1) {
downBean.downloadState = 18;
}
}
g(str);
DownService.b(c, downBean.name);
}
}
public void g(String str) {
DownBean downBean;
if (TextUtils.isEmpty(str) || (downBean = this.d.get(str)) == null) {
return;
}
az.d("DownManager", String.format("DownManager/clearDownloadRecord:thread(%s) packageName(%s)", Thread.currentThread().getName(), downBean.packageName));
for (String str2 : this.e.keySet()) {
if (str2.startsWith(str)) {
d.a(this.e.get(str2));
}
}
d(downBean, -1);
this.d.remove(str);
this.g.remove(downBean.packageName);
if (bs.m(str)) {
return;
}
az.d("DownManager", "1 gyz remove bean:" + downBean);
com.excelliance.kxqp.gs.multi.a.a.a(c).update(downBean.name, downBean.type, "");
}
public Map<String, DownBean> c() {
return this.d;
}
private List<DownBean> i(String str) {
ArrayList arrayList = new ArrayList();
if (this.d.size() > 0) {
for (Map.Entry<String, DownBean> entry : this.d.entrySet()) {
if (entry.getValue().packageName.equals(str)) {
arrayList.add(entry.getValue());
}
}
}
return arrayList;
}
public void h(String str) {
List<DownBean> i = i(str);
if (i.size() > 0) {
Iterator<DownBean> it = i.iterator();
while (it.hasNext()) {
d(it.next());
}
}
}
private void a(Context context, DownBean downBean) {
int i;
if (downBean != null && downBean.type == 5) {
bz.a().a(c, downBean);
com.excelliance.kxqp.gs.g.c.a().a(c, false, false, (String) null);
}
try {
Intent intent = new Intent("com.excelliance.kxqp.action.space.stat");
intent.setComponent(new ComponentName(context.getPackageName(), "com.excelliance.kxqp.SmtServService"));
intent.putExtra("type", 66);
if (bf.a(context)) {
i = 1;
} else {
i = bf.b(context) ? 2 : 3;
}
intent.putExtra("pk2", i);
intent.putExtra("sk1", downBean.packageName);
context.startService(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
public boolean a(Context context, Exception exc, DownBean downBean) {
int i;
if (exc == null || downBean == null || context == null || bs.a(downBean.packageName) <= 0) {
return false;
}
if (exc instanceof UnknownHostException) {
exc.printStackTrace();
try {
Intent intent = new Intent("com.excelliance.kxqp.action.space.stat");
intent.setComponent(new ComponentName(context.getPackageName(), "com.excelliance.kxqp.SmtServService"));
intent.putExtra("type", 77);
if (bf.a(context)) {
i = 1;
} else {
i = bf.b(context) ? 2 : 3;
}
intent.putExtra("pk2", i);
intent.putExtra("sk1", downBean.downloadUrl);
context.startService(intent);
} catch (Exception e) {
e.printStackTrace();
}
exc.printStackTrace();
} else if (exc instanceof SocketTimeoutException) {
a("SocketTimeoutException" + a(exc, downBean.downloadUrl), context, downBean);
exc.printStackTrace();
} else if (exc instanceof UnknownServiceException) {
a("UnknownServiceException" + a(exc, downBean.downloadUrl), context, downBean);
exc.printStackTrace();
} else if (exc instanceof SSLPeerUnverifiedException) {
a("SSLPeerUnverifiedException" + a(exc, downBean.downloadUrl), context, downBean);
} else if (exc instanceof IllegalStateException) {
a("IllegalStateException" + a(exc, downBean.downloadUrl), context, downBean);
exc.printStackTrace();
} else if (exc instanceof IllegalArgumentException) {
a("IllegalArgumentException" + a(exc, downBean.downloadUrl), context, downBean);
exc.printStackTrace();
} else if (exc instanceof SecurityException) {
a("SecurityException" + a(exc, downBean.downloadUrl), context, downBean);
exc.printStackTrace();
} else if (exc instanceof ProtocolException) {
a("ProtocolException" + a(exc, downBean.downloadUrl), context, downBean);
exc.printStackTrace();
} else if (exc instanceof FileNotFoundException) {
a("FileNotFoundException" + a(exc, downBean.downloadUrl), context, downBean);
exc.printStackTrace();
} else if (exc instanceof EOFException) {
a("EOFException" + a(exc, downBean.downloadUrl), context, downBean);
exc.printStackTrace();
} else if (exc instanceof UTFDataFormatException) {
a("UTFDataFormatException" + a(exc, downBean.downloadUrl), context, downBean);
exc.printStackTrace();
} else if (exc instanceof NullPointerException) {
a("NullPointerException" + a(exc, downBean.downloadUrl), context, downBean);
} else if (exc instanceof SSLException) {
a("SSLException" + a(exc, downBean.downloadUrl), context, downBean);
exc.printStackTrace();
}
return true;
}
private void a(String str, Context context, DownBean downBean) {
int i;
try {
if (bf.a(context)) {
i = 1;
} else {
i = bf.b(context) ? 2 : 3;
}
JSONObject jSONObject = new JSONObject();
jSONObject.put("info", str);
jSONObject.put("linkType", downBean.downloadUrl.contains("cdn") ? "cdn" : "src");
bz.a().a(c, 42000, i, "未知网络下套件下载失败", jSONObject.toString());
com.excelliance.kxqp.gs.g.c.a().a(c, true, true, str);
Intent intent = new Intent("com.excelliance.kxqp.action.space.stat");
intent.setComponent(new ComponentName(context.getPackageName(), "com.excelliance.kxqp.SmtServService"));
intent.putExtra("type", 81);
intent.putExtra("pk2", i);
intent.putExtra("sk1", str);
context.startService(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
private String a(Exception exc, String str) {
String str2;
String localizedMessage;
String message;
String str3 = System.currentTimeMillis() + "";
try {
str2 = str3 + "-" + str + "-" + bd.a(str) + "-" + as.k() + "-";
} catch (Exception e) {
e = e;
}
if (exc != null) {
try {
localizedMessage = exc.getLocalizedMessage();
message = exc.getMessage();
} catch (Exception e2) {
e = e2;
str3 = str2;
}
if (message != null) {
str3 = str2 + message;
if (str3.length() > 224) {
return str3.substring(0, 224);
}
return str3;
}
if (localizedMessage != null) {
String str4 = str2 + "L";
try {
str2 = str4 + localizedMessage;
} catch (Exception e3) {
str3 = str4;
e = e3;
e.printStackTrace();
return str3;
}
}
}
str3 = str2;
if (str3.length() > 224) {
}
return str3;
}
public boolean d() {
return this.n;
}
public void b(boolean z) {
this.n = z;
}
private boolean a(int i, String str) {
if (i != 3 && i != 4 && i != 7) {
return false;
}
ExcellianceAppInfo b2 = com.excelliance.kxqp.repository.a.a(c).b(str);
return b2 == null || !b2.isDownloadAvailable();
}
public String a(int i, long j) {
return (i & 2) == 2 ? "MAD5错误" : !bf.e(c) ? BiEventPluginPause.Reason.REASON_NET : (i & 1) == 1 ? "数据错误" : com.excelliance.kxqp.bitmap.ui.a.e.a() < j ? "内存不足" : BiEventPluginPause.Reason.REASON_NET;
}
private void a(final Context context, final DownBean downBean, final String str, final boolean z) {
Log.e("DownManager", "reportMD5Mismatch: downBean = " + downBean + ",md5Local = " + str);
if (TextUtils.isEmpty(str) || downBean == null || TextUtils.equals(str, downBean.md5)) {
return;
}
tp.f(new Runnable() {
@Override
public void run() {
String str2 = null;
try {
String host = new URL(downBean.downloadUrl).getHost();
Log.d("DownManager", "reportMD5Mismatch: domainName = " + host + ",downloadUrl = " + downBean.downloadUrl);
InetAddress byName = InetAddress.getByName(host);
if (byName != null) {
Log.d("DownManager", "reportMD5Mismatch: domainName = " + host + ", getHostAddress = " + byName.getHostAddress());
}
if (byName != null && !TextUtils.isEmpty(byName.getHostAddress())) {
str2 = byName.getHostAddress();
}
} catch (Exception e) {
e.printStackTrace();
}
Log.e("DownManager", "reportMD5Mismatch: get remote ip:" + str2 + ",downloadUrl = " + downBean.downloadUrl);
if (TextUtils.isEmpty(str2)) {
Log.e("DownManager", "reportMD5Mismatch: unable to get remote ip,downloadUrl = " + downBean.downloadUrl);
return;
}
try {
com.excelliance.kxqp.api.c cVar = new com.excelliance.kxqp.api.c(context);
a.q a2 = new q.a().a(SocialConstants.PARAM_URL, downBean.downloadUrl).a("cdnIp", str2).a("serverHash", z ? downBean.md5 : new String(downBean.SHA, "UTF-8")).a("clientHash", str).a();
az.d("DownManager", "reportMD5Mismatch requestData=" + a2);
cVar.a(ApiManager.getInstance().a(context, 15000L, 15000L, "https://api.ourplay.com.cn/").X(a2));
Log.d("DownManager", "reportMD5Mismatch responseData=" + cVar.b());
} catch (Exception e2) {
e2.printStackTrace();
}
}
});
}
}