九游游戏中心HD v4.6.8.1版本的 MD5 值为:78c397802cc5ffdcc7f5502ede90502e
以下内容为反编译后的 b.java 源代码,内容仅作参考
package cn.ninegame.gamemanager.game.packagemanager.helper;
import android.os.Bundle;
import android.text.TextUtils;
import cn.ninegame.framework.NineGameClientApplication;
import cn.ninegame.framework.ipc.notification.IPCNotificationTransfer;
import cn.ninegame.gamemanager.download.model.pojo.DownloadRecord;
import cn.ninegame.gamemanager.game.follow.model.InterestedGame;
import cn.ninegame.gamemanager.game.packagemanager.InstalledGameInfo;
import cn.ninegame.gamemanagerhd.R;
import cn.ninegame.library.storage.db.e;
import org.json.JSONException;
import org.json.JSONObject;
public final class b {
public static String a(int i, String str, int i2) {
int i3;
int i4;
JSONObject d = ((cn.ninegame.gamemanager.download.model.a) e.a(cn.ninegame.gamemanager.download.model.a.class)).d(i, str);
if (d != null) {
try {
r3 = d.has("downloadState") ? d.getInt("downloadState") : -1;
i3 = d.has("versionCode") ? d.getInt("versionCode") : 0;
try {
i4 = d.has("errorState") ? d.getInt("errorState") : 0;
} catch (JSONException e) {
e = e;
cn.ninegame.library.stat.b.b.d("%s#getPackageStateImpl2 JSONException:%s", "Download", e);
i4 = 0;
return a(i, str, i2, r3, i3, i4);
}
} catch (JSONException e2) {
e = e2;
i3 = 0;
}
} else {
i3 = 0;
i4 = 0;
}
return a(i, str, i2, r3, i3, i4);
}
public static String a(int i, String str, int i2, int i3, int i4, int i5) {
int i6;
String str2;
cn.ninegame.gamemanager.download.model.a aVar = (cn.ninegame.gamemanager.download.model.a) e.a(cn.ninegame.gamemanager.download.model.a.class);
if (i3 == 3) {
i6 = aVar.e(i, str);
if (i6 == -1 || i6 == 3) {
i6 = i3;
}
} else {
i6 = i3;
}
switch (i6) {
case 0:
str2 = "100";
cn.ninegame.library.stat.b.b.a("%s PkgName:%s, result:%s", "Download", str, str2);
break;
case 1:
str2 = "104";
cn.ninegame.library.stat.b.b.a("%s PkgName:%s, result:%s", "Download", str, str2);
break;
case 2:
str2 = "103";
cn.ninegame.library.stat.b.b.a("%s PkgName:%s, result:%s", "Download", str, str2);
break;
case 3:
str2 = "107";
cn.ninegame.library.stat.b.b.a("%s PkgName:%s, result:%s", "Download", str, str2);
break;
case 4:
if (i5 == 400) {
str2 = "206";
} else if (i5 == 401) {
str2 = "207";
} else if (i5 == 301) {
str2 = "106";
} else if (i5 == 302) {
str2 = "106";
} else {
str2 = "106";
}
cn.ninegame.library.stat.b.b.a("%s PkgName:%s, result:%s", "Download", str, str2);
break;
case 5:
str2 = "200";
cn.ninegame.library.stat.b.b.a("%s PkgName:%s, result:%s", "Download", str, str2);
break;
case 6:
str2 = "205";
cn.ninegame.library.stat.b.b.a("%s PkgName:%s, result:%s", "Download", str, str2);
break;
case 7:
str2 = "102";
cn.ninegame.library.stat.b.b.a("%s PkgName:%s, result:%s", "Download", str, str2);
break;
case 8:
str2 = "101";
cn.ninegame.library.stat.b.b.a("%s PkgName:%s, result:%s", "Download", str, str2);
break;
case 9:
str2 = "108";
cn.ninegame.library.stat.b.b.a("%s PkgName:%s, result:%s", "Download", str, str2);
break;
default:
str2 = a(str, i, i2, i4, i3);
if (TextUtils.isEmpty(str2)) {
str2 = "0";
cn.ninegame.library.stat.b.b.a("%s PkgName:%s, result:%s", "Download", str, str2);
break;
}
break;
}
return str2;
}
public static String a(String str, int i, int i2, int i3, int i4) {
String str2;
InstalledGameInfo a2 = a.a().a(str);
if (a2 != null && a2.gameId == i) {
if (i4 == 3 && i3 > a2.versionCode) {
str2 = "302";
} else {
str2 = "300";
}
if (i2 > a2.versionCode) {
return "301";
}
return str2;
}
try {
NineGameClientApplication.a().getPackageManager().getApplicationInfo(str, 8192);
return "300";
} catch (Exception e) {
return null;
}
}
public static void a(DownloadRecord downloadRecord) {
a(downloadRecord, downloadRecord.downloadedBytes, downloadRecord.fileLength);
}
public static void a(DownloadRecord downloadRecord, long j, long j2) {
if (downloadRecord != null) {
if (downloadRecord.downloadState != 4 && downloadRecord.downloadState != 9) {
downloadRecord.errorState = 100;
}
switch (downloadRecord.downloadState) {
case 0:
IPCNotificationTransfer.sendNotification("base_biz_download_event_prepare", DownloadRecord.DOWNLOAD_RECORD, downloadRecord);
try {
JSONObject jSONObject = new JSONObject();
jSONObject.put("downloadedBytes", j);
jSONObject.put("fileSize", j2);
jSONObject.put("downloadSpeed", 0);
a(downloadRecord, "100", jSONObject);
return;
} catch (JSONException e) {
cn.ninegame.library.stat.b.b.a(e);
return;
}
case 1:
a(downloadRecord, "104");
return;
case 2:
IPCNotificationTransfer.sendNotification("base_biz_download_event_pause", DownloadRecord.DOWNLOAD_RECORD, downloadRecord);
try {
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("downloadedBytes", j);
jSONObject2.put("fileSize", j2);
jSONObject2.put("downloadSpeed", 0);
a(downloadRecord, "103", jSONObject2);
return;
} catch (JSONException e2) {
cn.ninegame.library.stat.b.b.b(e2);
return;
}
case 3:
a(downloadRecord, 1);
IPCNotificationTransfer.sendNotification("base_biz_download_event_complete", DownloadRecord.DOWNLOAD_RECORD, downloadRecord);
return;
case 4:
IPCNotificationTransfer.sendNotification("base_biz_download_event_error", DownloadRecord.DOWNLOAD_RECORD, downloadRecord);
try {
JSONObject jSONObject3 = new JSONObject();
jSONObject3.put("msg", b(downloadRecord));
jSONObject3.put("downloadedBytes", j);
jSONObject3.put("fileSize", j2);
jSONObject3.put("downloadSpeed", 0);
if (downloadRecord.errorState == 400 || downloadRecord.errorState == 501) {
IPCNotificationTransfer.sendNotification("base_biz_package_clear_installing_or_extracting_state", DownloadRecord.DOWNLOAD_RECORD, downloadRecord);
a(downloadRecord, "206", jSONObject3);
} else {
a(downloadRecord, "106", jSONObject3);
}
return;
} catch (JSONException e3) {
cn.ninegame.library.stat.b.b.b(e3);
return;
}
case 5:
default:
return;
case 6:
a(downloadRecord, "205");
return;
case 7:
IPCNotificationTransfer.sendNotification("base_biz_download_event_queue", DownloadRecord.DOWNLOAD_RECORD, downloadRecord);
a(downloadRecord, "102");
return;
case 8:
IPCNotificationTransfer.sendNotification("base_biz_download_event_pending", DownloadRecord.DOWNLOAD_RECORD, downloadRecord);
a(downloadRecord, "101");
return;
case 9:
IPCNotificationTransfer.sendNotification("base_biz_download_event_stop", DownloadRecord.DOWNLOAD_RECORD, downloadRecord);
try {
JSONObject jSONObject4 = new JSONObject();
jSONObject4.put("downloadedBytes", j);
jSONObject4.put("fileSize", j2);
jSONObject4.put("downloadSpeed", 0);
a(downloadRecord, "108", jSONObject4);
return;
} catch (JSONException e4) {
cn.ninegame.library.stat.b.b.b(e4);
return;
}
}
}
}
public static String b(DownloadRecord downloadRecord) {
NineGameClientApplication a2 = NineGameClientApplication.a();
switch (downloadRecord.errorState) {
case 100:
return "";
case 200:
return a2.getString(R.string.txt_wifi_disconnect);
case 201:
return a2.getString(R.string.txt_download_error_response_code);
case 301:
return a2.getString(R.string.txt_download_retry_fail);
case 302:
return a2.getString(R.string.txt_download_retry_fail_by_network_disconnect);
case 303:
return NineGameClientApplication.a().getString(R.string.txt_storage_space_not_enough_short);
case 304:
return NineGameClientApplication.a().getString(R.string.txt_storage_unavailable_short);
case 400:
return a2.getString(R.string.txt_download_extract_fail);
case 401:
return a2.getString(R.string.txt_download_install_fail);
case 501:
return a2.getString(R.string.txt_download_storage_no_space);
default:
return "";
}
}
public static void a(DownloadRecord downloadRecord, int i) {
if (downloadRecord.downloadState != 4) {
downloadRecord.errorState = 100;
}
InstalledGameInfo a2 = a.a().a(downloadRecord.pkgName);
if (a2 != null && a2.gameId != -1) {
if (i == 2) {
if (a2.versionCode >= downloadRecord.versionCode) {
a(downloadRecord, "300");
} else {
a(downloadRecord, "301");
}
} else if (i == 1) {
a(downloadRecord, "302");
}
} else if (i == 2) {
a(downloadRecord, "0");
} else if (i == 1) {
a(downloadRecord, "107");
}
}
private static void a(DownloadRecord downloadRecord, String str) {
a(downloadRecord, str, new JSONObject());
}
public static void a(DownloadRecord downloadRecord, String str, JSONObject jSONObject) {
if (downloadRecord.downloadState != 4 && downloadRecord.downloadState != 9) {
downloadRecord.errorState = 100;
}
String str2 = cn.ninegame.library.network.b.a(NineGameClientApplication.a()).g;
cn.ninegame.library.stat.b.b.a("%s callbackJSWithDownloadState gameId:%d, pkgName:%s, state:%s, network:%s, data:%s", "Download", Integer.valueOf(downloadRecord.gameId), downloadRecord.pkgName, str, str2, jSONObject.toString());
try {
Bundle bundle = new Bundle();
bundle.putInt("gameId", downloadRecord.gameId);
bundle.putString(InterestedGame.PKG_NAME, downloadRecord.pkgName);
bundle.putString("state", str);
jSONObject.put("network", str2);
bundle.putString("data", jSONObject.toString());
IPCNotificationTransfer.sendNotification("base_biz_webview_pkg_states_change", bundle);
} catch (JSONException e) {
cn.ninegame.library.stat.b.b.d("Download#callbackJSWithDownloadState get JSONException:" + e, new Object[0]);
}
}
}