百度手机卫士 v8.1.5版本的 MD5 值为:15af71eae74e2f2b5b9f845fe77a4804
以下内容为反编译后的 a.java 源代码,内容仅作参考
package com.baidu.zeus;
import android.accounts.NetworkErrorException;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.AssetManager;
import android.database.Cursor;
import android.text.TextUtils;
import android.util.Log;
import com.baidu.zeus.receiver.AlarmNetworkReceiver;
import com.baidu.zeus.service.ExcuteService;
import com.baidu.zeus.utils.CommonConst;
import com.baidu.zeus.utils.h;
import com.baidu.zeus.utils.i;
import com.baidu.zeus.utils.l;
import com.baidu.zeus.utils.m;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.UnknownHostException;
import java.util.List;
import org.json.JSONArray;
public final class a {
private static AlarmNetworkReceiver b = null;
public String a;
private Context c;
private com.baidu.zeus.f.b d;
private String e;
private boolean f = false;
public a() {
}
public a(Context context) {
this.c = context.getApplicationContext();
this.d = new com.baidu.zeus.f.b(this.c);
File baseFileDir = CommonConst.getBaseFileDir(this.c);
if (baseFileDir == null) {
for (int i = 0; i < 3; i++) {
try {
Thread.sleep((i + 1) * 500);
} catch (InterruptedException e) {
e.printStackTrace();
}
baseFileDir = CommonConst.getBaseFileDir(this.c);
if (baseFileDir != null) {
break;
}
}
}
if (baseFileDir != null) {
this.e = baseFileDir.getAbsolutePath() + "/.tmp/";
} else {
this.e = CommonConst.getBaseFilePath(this.c) + "/.tmp/";
}
}
public final void a() {
this.f = true;
if (this.d != null) {
this.d.a();
}
}
public final void a(int i) {
this.d.a(i);
}
public final void b(int i) {
this.d.b(i);
}
private boolean a(l lVar, int i, com.baidu.zeus.model.a aVar) {
String str;
boolean z;
boolean z2;
File file = null;
switch (i) {
case 1:
str = "deppkgz";
break;
case 2:
str = "Sig.datz";
break;
case 3:
str = "uniz";
break;
default:
str = "";
break;
}
File file2 = new File(this.e, str);
if (file2.exists()) {
String a = h.a(file2);
if (TextUtils.isEmpty(a)) {
file2.delete();
z = true;
} else if (a.equalsIgnoreCase(lVar.a)) {
file = file2;
z = false;
} else {
file2.delete();
}
if (!z && a(this.c, str, lVar.a) && a(str)) {
z = false;
} else {
file2 = file;
}
if (!z) {
String str2 = "i am down file : " + lVar.b;
if (com.baidu.zeus.utils.c.a) {
Log.d("Baidu", "[DownloadFiles] " + str2);
}
try {
File file3 = new File(this.e);
if (!file3.exists()) {
file3.mkdirs();
}
File createTempFile = File.createTempFile(str, ".out", file3);
try {
if (com.baidu.zeus.utils.c.a) {
System.out.println("create tmp file:" + createTempFile.getAbsolutePath());
}
try {
z2 = this.d.a(lVar.b, createTempFile);
} catch (NetworkErrorException e) {
if (aVar != null) {
try {
aVar.v = Integer.parseInt(e.getMessage());
} catch (Exception e2) {
z2 = false;
}
}
z2 = false;
} catch (UnknownHostException e3) {
this.a = e3.getClass().getName() + ":" + e3.getMessage();
String[] e4 = com.baidu.zeus.utils.c.e();
this.a += ";DNS IP : " + e4[0] + "/" + e4[1];
this.a += ";" + com.baidu.zeus.utils.c.e("www.126.com");
z2 = false;
} catch (Exception e5) {
this.a = e5.getClass().getName() + ":" + e5.getMessage();
e5.printStackTrace();
if (createTempFile == null || !createTempFile.exists()) {
return false;
}
createTempFile.delete();
return false;
}
String str3 = "mRs result:" + z2;
if (com.baidu.zeus.utils.c.a) {
Log.d("Baidu", "[DownloadFiles] " + str3);
}
if (!z2) {
if (createTempFile == null || !createTempFile.exists()) {
return false;
}
createTempFile.delete();
return false;
}
file2 = createTempFile;
} catch (IOException e6) {
e = e6;
file2 = createTempFile;
this.a = e.getClass().getName() + ":" + e.getMessage();
e.printStackTrace();
if (file2 == null || !file2.exists()) {
return false;
}
file2.delete();
return false;
}
} catch (IOException e7) {
e = e7;
}
} else if (aVar != null) {
if (i == 1) {
aVar.w |= 1;
} else if (i == 2) {
aVar.w |= 2;
}
}
if (file2 == null && file2.exists()) {
String a2 = h.a(file2);
if (z && (TextUtils.isEmpty(a2) || !a2.equalsIgnoreCase(lVar.a))) {
if (com.baidu.zeus.utils.c.a) {
String str4 = "tmpMd5:" + a2 + ",md5:" + lVar.a;
if (com.baidu.zeus.utils.c.a) {
Log.d("Baidu", "[DownloadFiles] " + str4);
}
}
if (file2 != null && file2.exists()) {
file2.delete();
}
this.a = "downLoadSignture md5 fail:" + lVar.b;
return false;
}
try {
m.a(this.c, file2, false, i);
if (!file2.getName().equals(str)) {
File file4 = new File(this.e, str);
if (file4.exists()) {
file4.delete();
}
File file5 = new File(this.e, str);
if (file2.renameTo(file5) && file5.exists() && file2.exists()) {
file2.delete();
}
}
return true;
} catch (Exception e8) {
this.a = e8.getClass().getName() + ":" + e8.getMessage();
e8.printStackTrace();
if (file2 == null || !file2.exists()) {
return false;
}
file2.delete();
return false;
}
}
}
z = true;
if (!z) {
}
file2 = file;
if (!z) {
}
return file2 == null ? false : false;
}
private static boolean a(Context context, String str, String str2) {
boolean z = false;
if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2)) {
InputStream inputStream = null;
try {
inputStream = com.baidu.zeus.utils.c.b(context).open(str);
String a = h.a(inputStream);
String str3 = "assetMd5:" + a;
if (com.baidu.zeus.utils.c.a) {
Log.d("Baidu", "[DownloadFiles] " + str3);
}
String str4 = str + "Md5:" + str2;
if (com.baidu.zeus.utils.c.a) {
Log.d("Baidu", "[DownloadFiles] " + str4);
}
if (!TextUtils.isEmpty(str2)) {
if (str2.equalsIgnoreCase(a)) {
z = true;
}
}
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (Exception e2) {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e3) {
e3.printStackTrace();
}
}
} catch (Throwable th) {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e4) {
e4.printStackTrace();
}
}
throw th;
}
}
return z;
}
public final int a(i iVar, boolean z, com.baidu.zeus.model.a aVar) {
boolean z2;
boolean z3;
File file;
boolean z4;
if (iVar.e == null || iVar.e.size() == 0) {
this.a = "downLoadRFile no info.dwloads";
return 0;
}
if (!com.baidu.zeus.utils.c.d(this.c)) {
this.a = "downLoadRFile no network";
return 0;
}
int i = 0;
int i2 = 0;
while (true) {
int i3 = i;
if (i3 >= iVar.e.size()) {
z2 = false;
break;
}
if (z && new File(CommonConst.getBaseFilePath(this.c) + "/.tmp/", "excutingtag.tf").exists()) {
ExcuteService.f();
}
String str = ((i.a) iVar.e.get(i3)).b;
String str2 = ((i.a) iVar.e.get(i3)).c;
String valueOf = String.valueOf(((i.a) iVar.e.get(i3)).a);
File file2 = new File(this.e, valueOf);
if (!TextUtils.isEmpty(str2) && file2.exists()) {
String a = h.a(file2);
if (!TextUtils.isEmpty(a) && a.equalsIgnoreCase(str2)) {
z3 = false;
if (!z3) {
if (a(this.c, valueOf, str2) && a(valueOf)) {
z3 = false;
}
} else if (aVar != null) {
aVar.w |= 4;
}
if (z3) {
i2++;
} else {
try {
file = File.createTempFile("zeus", ".out", new File(CommonConst.getBaseFilePath(this.c) + "/.tmp/"));
} catch (IOException e) {
e.printStackTrace();
file = null;
}
boolean z5 = false;
try {
z5 = this.d.a(str, file);
} catch (NetworkErrorException e2) {
if (aVar != null) {
try {
aVar.v = Integer.parseInt(e2.getMessage());
} catch (Exception e3) {
}
}
} catch (UnknownHostException e4) {
this.a = e4.getClass().getName() + ":" + e4.getMessage();
String[] e5 = com.baidu.zeus.utils.c.e();
this.a += ";DNS IP : " + e5[0] + "/" + e5[1];
this.a += ";" + com.baidu.zeus.utils.c.e("www.126.com");
} catch (Exception e6) {
this.a = e6.getClass().getName() + ":" + e6.getMessage();
e6.printStackTrace();
}
if (this.f) {
z2 = true;
if (file != null && file.exists()) {
file.delete();
}
} else {
if (!z5) {
try {
z4 = this.d.a(str, file);
} catch (UnknownHostException e7) {
this.a = e7.getClass().getName() + ":" + e7.getMessage();
String[] e8 = com.baidu.zeus.utils.c.e();
this.a += ";DNS IP : " + e8[0] + "/" + e8[1];
this.a += ";" + com.baidu.zeus.utils.c.e("www.126.com");
z4 = z5;
} catch (Exception e9) {
this.a = e9.getClass().getName() + ":" + e9.getMessage();
e9.printStackTrace();
}
if (z4) {
if (file != null && file.exists()) {
file.delete();
}
} else {
if (com.baidu.zeus.utils.c.a) {
String str3 = "rs id:" + ((i.a) iVar.e.get(i3)).a + ",rs:" + z4;
if (com.baidu.zeus.utils.c.a) {
Log.d("Baidu", "[DownloadFiles] " + str3);
}
}
List list = null;
try {
list = m.a(this.c, file, true, 1);
} catch (Exception e10) {
if (file != null && file.exists()) {
file.delete();
}
e10.printStackTrace();
}
File file3 = null;
if (list != null && list.size() > 0) {
file3 = (File) list.get(0);
}
if (file3 != null && file3.exists()) {
String a2 = h.a(file3);
if (com.baidu.zeus.utils.c.a) {
String str4 = "tmpMd5:" + a2 + ",md5:" + str2;
if (com.baidu.zeus.utils.c.a) {
Log.d("Baidu", "[DownloadFiles] " + str4);
}
}
if (TextUtils.isEmpty(a2) || !a2.equals(str2)) {
this.a = "downLoadRFile md5 fail";
if (file3 != null && file3.exists()) {
file3.delete();
}
} else {
i2++;
}
}
if (file != null && file.exists()) {
file.delete();
}
}
}
z4 = z5;
if (z4) {
}
}
}
i = i3 + 1;
} else {
file2.delete();
}
}
z3 = true;
if (!z3) {
}
if (z3) {
}
i = i3 + 1;
}
if (z2) {
return 0;
}
return i2;
}
public final boolean a(int i, int i2, com.baidu.zeus.model.a aVar) {
l lVar;
l lVar2 = null;
try {
lVar = this.d.a(new StringBuilder().append(i + 1).toString(), false);
} catch (NetworkErrorException e) {
if (aVar != null) {
try {
aVar.v = Integer.parseInt(e.getMessage());
} catch (Exception e2) {
lVar = null;
}
}
lVar = null;
} catch (UnknownHostException e3) {
try {
lVar2 = this.d.a(new StringBuilder().append(i + 1).toString(), true);
} catch (NetworkErrorException e4) {
if (aVar != null) {
try {
aVar.v = Integer.parseInt(e4.getMessage());
} catch (Exception e5) {
}
}
} catch (Exception e6) {
e6.printStackTrace();
}
this.a = e3.getClass().getName() + ":" + e3.getMessage();
String[] e7 = com.baidu.zeus.utils.c.e();
this.a += ";DNS IP : " + e7[0] + "/" + e7[1];
this.a += ";" + com.baidu.zeus.utils.c.e("www.126.com");
lVar = lVar2;
} catch (Exception e8) {
this.a = e8.getClass().getName() + ":" + e8.getMessage();
e8.printStackTrace();
lVar = null;
}
if (lVar == null || TextUtils.isEmpty(lVar.b)) {
if (aVar != null) {
aVar.u = -12002;
}
return false;
}
boolean a = a(lVar, i2, aVar);
if (this.f) {
return false;
}
if (!a) {
if (com.baidu.zeus.utils.c.a) {
Log.d("Baidu", "[DownloadFiles] fisrt lost ... ");
}
a = a(lVar, i2, aVar);
}
String str = "denpond result:" + a;
if (com.baidu.zeus.utils.c.a) {
Log.d("Baidu", "[DownloadFiles] " + str);
}
if (!a && aVar != null) {
aVar.u = -12003;
return a;
}
return a;
}
public final boolean a(int i, com.baidu.zeus.model.a aVar) {
l lVar;
l lVar2 = null;
try {
lVar = this.d.a(new StringBuilder().append(i).toString(), false);
} catch (NetworkErrorException e) {
if (aVar != null) {
try {
aVar.v = Integer.parseInt(e.getMessage());
} catch (Exception e2) {
lVar = null;
}
}
lVar = null;
} catch (UnknownHostException e3) {
try {
lVar2 = this.d.a(new StringBuilder().append(i).toString(), true);
} catch (Exception e4) {
e4.printStackTrace();
}
this.a = e3.getClass().getName() + ":" + e3.getMessage();
String[] e5 = com.baidu.zeus.utils.c.e();
this.a += ";DNS IP : " + e5[0] + "/" + e5[1];
this.a += ";" + com.baidu.zeus.utils.c.e("www.126.com");
lVar = lVar2;
} catch (Exception e6) {
this.a = e6.getClass().getName() + ":" + e6.getMessage();
e6.printStackTrace();
return false;
}
if (lVar == null || TextUtils.isEmpty(lVar.b)) {
this.a = "getSignture:sigInfo is null or sigInfo.url is null";
return false;
}
if (this.f) {
return false;
}
boolean a = a(lVar, 2, aVar);
if (this.f) {
return false;
}
if (!a) {
return a(lVar, 2, aVar);
}
return a;
}
public final i a(String str, int i, com.baidu.zeus.model.a aVar) {
i iVar = null;
try {
return this.d.a(str, i, false);
} catch (NetworkErrorException e) {
if (aVar == null) {
return null;
}
try {
aVar.v = Integer.parseInt(e.getMessage());
return null;
} catch (Exception e2) {
return null;
}
} catch (UnknownHostException e3) {
try {
iVar = this.d.a(str, i, true);
} catch (Exception e4) {
e4.printStackTrace();
}
this.a = e3.getClass().getName() + ":" + e3.getMessage();
String[] e5 = com.baidu.zeus.utils.c.e();
this.a += ";DNS IP : " + e5[0] + "/" + e5[1];
this.a += ";" + com.baidu.zeus.utils.c.e("www.126.com");
return iVar;
} catch (Exception e6) {
this.a = e6.getClass().getName() + ":" + e6.getMessage();
e6.printStackTrace();
return null;
}
}
public final i b(String str, int i, com.baidu.zeus.model.a aVar) {
i iVar = null;
try {
return this.d.b(str, i, false);
} catch (NetworkErrorException e) {
if (aVar == null) {
return null;
}
try {
aVar.v = Integer.parseInt(e.getMessage());
return null;
} catch (Exception e2) {
return null;
}
} catch (UnknownHostException e3) {
try {
iVar = this.d.b(str, i, true);
} catch (NetworkErrorException e4) {
if (aVar != null) {
aVar.v = Integer.parseInt(e4.getMessage());
}
} catch (Exception e5) {
e5.printStackTrace();
}
this.a = e3.getClass().getName() + ":" + e3.getMessage();
String[] e6 = com.baidu.zeus.utils.c.e();
this.a += ";DNS IP : " + e6[0] + "/" + e6[1];
this.a += ";" + com.baidu.zeus.utils.c.e("www.126.com");
return iVar;
} catch (Exception e7) {
this.a = e7.getClass().getName() + ":" + e7.getMessage();
return null;
}
}
public final synchronized void a(JSONArray jSONArray, int i, boolean z) {
Cursor cursor;
if (new com.baidu.zeus.c.a(this.c).a.getBoolean("upload_zeus_result", true)) {
int i2 = -1;
if (jSONArray != null) {
i2 = new com.baidu.zeus.f.b(this.c).a(jSONArray);
}
com.baidu.zeus.d.a a = com.baidu.zeus.d.a.a(this.c);
if (i2 == 200) {
if (!z) {
try {
a.e.delete("unfinish_trans", "_id=" + i, null);
} catch (Exception e) {
e.printStackTrace();
}
try {
cursor = a.e.query("unfinish_trans", new String[]{"count(*)"}, null, null, null, null, null);
} catch (Exception e2) {
e2.printStackTrace();
cursor = null;
}
if (cursor != null) {
cursor.moveToFirst();
if (cursor.getLong(0) == 0) {
Intent intent = new Intent();
intent.setClass(a.f, ExcuteService.class);
intent.setAction("check_unfinish_net_transction");
((AlarmManager) a.f.getSystemService("alarm")).cancel(PendingIntent.getService(a.f, 0, com.baidu.zeus.utils.c.a(a.f, ExcuteService.class, "handleWork", intent), 0));
}
try {
cursor.close();
} catch (Exception e3) {
e3.printStackTrace();
}
}
Context context = this.c;
try {
if (b != null) {
if (com.baidu.zeus.utils.c.a && com.baidu.zeus.utils.c.a) {
Log.d("Baidu", "[DownloadFiles] unreg receiver");
}
com.baidu.zeus.utils.c.a(this.c, b);
b = null;
}
} catch (Exception e4) {
e4.printStackTrace();
}
} else {
com.baidu.zeus.utils.c.a(this.c, ExcuteService.class, new Intent("check_unfinish_net_transction"));
}
} else {
JSONArray a2 = com.baidu.zeus.utils.c.a(jSONArray, i2);
String str = "new JsonString : " + a2.toString();
if (com.baidu.zeus.utils.c.a) {
Log.d("Baidu", "[DownloadFiles] " + str);
}
if (z) {
a.a(a2.toString());
} else {
a.a(i, a2.toString());
}
Context context2 = this.c;
b();
}
}
}
public final synchronized void a(com.baidu.zeus.model.a aVar) {
if (new com.baidu.zeus.c.a(this.c).a.getBoolean("upload_zeus_result", true)) {
try {
if (!TextUtils.isEmpty(aVar.c)) {
JSONArray a = com.baidu.zeus.utils.c.a(this.c, aVar);
String str = "upload:" + a;
if (com.baidu.zeus.utils.c.a) {
Log.d("Baidu", "[DownloadFiles] " + str);
}
a(a, 0, true);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
private synchronized void b() {
try {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
if (b == null) {
if (com.baidu.zeus.utils.c.a) {
Log.d("Baidu", "[DownloadFiles] register network");
}
b = new AlarmNetworkReceiver();
com.baidu.zeus.utils.c.a(this.c, b, intentFilter);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private boolean a(String str) {
FileOutputStream fileOutputStream;
InputStream inputStream;
InputStream inputStream2 = null;
boolean z = false;
AssetManager b2 = com.baidu.zeus.utils.c.b(this.c);
File file = new File(this.e, str);
try {
inputStream = b2.open(str);
try {
fileOutputStream = new FileOutputStream(file);
try {
byte[] bArr = new byte[1024];
while (true) {
int read = inputStream.read(bArr);
if (read == -1) {
break;
}
fileOutputStream.write(bArr, 0, read);
}
z = true;
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
fileOutputStream.close();
} catch (IOException e2) {
e2.printStackTrace();
}
} catch (IOException e3) {
inputStream2 = inputStream;
if (inputStream2 != null) {
try {
inputStream2.close();
} catch (IOException e4) {
e4.printStackTrace();
}
}
if (fileOutputStream != null) {
try {
fileOutputStream.close();
} catch (IOException e5) {
e5.printStackTrace();
}
}
return z;
} catch (Throwable th) {
th = th;
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e6) {
e6.printStackTrace();
}
}
if (fileOutputStream != null) {
try {
fileOutputStream.close();
} catch (IOException e7) {
e7.printStackTrace();
}
}
throw th;
}
} catch (IOException e8) {
fileOutputStream = null;
inputStream2 = inputStream;
} catch (Throwable th2) {
th = th2;
fileOutputStream = null;
}
} catch (IOException e9) {
fileOutputStream = null;
} catch (Throwable th3) {
th = th3;
fileOutputStream = null;
inputStream = null;
}
return z;
}
}