OurPlay v5.5.9版本的 MD5 值为:d4e139798f4c2243a1145c8af5e21046
以下内容为反编译后的 d.java 源代码,内容仅作参考
package com.excelliance.kxqp.util.master;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.android.spush.FakeServiceHelper;
import com.excelliance.kxqp.GameUtil;
import com.excelliance.kxqp.bitmap.bean.RankingItem;
import com.excelliance.kxqp.gs.util.Upl;
import com.excelliance.kxqp.gs.util.as;
import com.excelliance.kxqp.gs.util.by;
import com.excelliance.kxqp.gs.util.g;
import com.excelliance.kxqp.gs.util.h;
import com.excelliance.kxqp.gs.util.w;
import com.excelliance.kxqp.gs.util.z;
import com.tencent.open.SocialConstants;
import java.io.File;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import org.json.JSONObject;
public class d {
public Context f15066a;
public a f15067b;
public boolean c;
private final String d;
private Thread e;
private JSONObject f;
private File g;
private boolean h;
private Handler i;
private boolean j;
public interface a {
boolean a(JSONObject jSONObject);
}
public static boolean a(Bundle bundle) {
return false;
}
public d(Context context) {
this(context, false);
}
public d(Context context, boolean z) {
this.h = false;
this.f15067b = null;
this.i = new Handler() {
@Override
public void handleMessage(Message message) {
if (d.this.c) {
Log.d("UpdateAssistanceHelper", "handleMessage: already destroy");
return;
}
if (message.what == 10 && d.this.f != null) {
int optInt = d.this.f.optInt("vc");
Log.d("UpdateAssistanceHelper", "serverVersionCode = " + optInt);
String optString = d.this.f.optString("showDialog");
if (optInt > 0) {
if (d.this.a(d.this.a(d.this.d), optInt).booleanValue()) {
float optInt2 = d.this.f.optInt(RankingItem.KEY_SIZE);
Log.d("UpdateAssistanceHelper", "showDialog = " + optString);
if (d.this.h) {
if (d.this.f15067b == null || !d.this.f15067b.a(d.this.f)) {
d.this.h();
return;
}
return;
}
if (TextUtils.equals(optString, "2")) {
d.this.a(optInt2, 0);
} else if (TextUtils.equals(optString, "3")) {
d.this.a(optInt2, 1);
}
}
}
}
}
};
this.j = false;
this.c = false;
this.f15066a = context;
this.d = e.b(this.f15066a);
this.h = z;
}
public String a(int i) {
String packageName = this.f15066a.getPackageName();
GameUtil intance = GameUtil.getIntance();
intance.q(this.f15066a);
int i2 = com.excelliance.kxqp.gs.ui.home.b.a(this.f15066a).d() ? 2 : 1;
StringBuilder sb = new StringBuilder();
sb.append("https://sdk.ourplay.com.cn/chkversion.php?chid=");
sb.append(e());
sb.append("&subchid=");
sb.append(f());
sb.append("&pkg=");
sb.append(this.d);
sb.append("&vc=");
sb.append(e.a(this.f15066a) ? a(this.d) : -1);
sb.append("&masterPkg=");
sb.append(packageName);
sb.append("&masterVc=");
sb.append(a(packageName));
sb.append("&mainver=");
sb.append(intance.m());
sb.append("&ent=");
sb.append(i);
sb.append("&sn=");
sb.append(e.a(this.f15066a) ? e.d(this.f15066a, this.d) : null);
sb.append("&needInfo=1&clientArch=");
sb.append(i2);
sb.append(g.a(this.f15066a).h());
return sb.toString();
}
public void a() {
if (!this.h && !e.a(this.f15066a)) {
Log.d("UpdateAssistanceHelper", "checkIsNewVersion: no " + this.d);
return;
}
this.e = new Thread(new Runnable() {
@Override
public void run() {
Throwable th;
InputStream inputStream;
Upl a2;
?? a3 = d.this.a(g.f12014a);
Log.d("UpdateAssistanceHelper", "path = " + a3);
try {
try {
try {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(a3).openConnection();
httpURLConnection.setConnectTimeout(5000);
httpURLConnection.setRequestMethod("GET");
inputStream = httpURLConnection.getInputStream();
try {
a2 = h.a().a(inputStream);
Log.d("UpdateAssistanceHelper", String.format("UpdateAssistanceHelper/checkIsNewVersion run:thread(%s) upl(%s)", Thread.currentThread().getName(), a2));
} catch (Exception e) {
e = e;
if (d.this.f15067b != null) {
d.this.f15067b.a(null);
}
e.printStackTrace();
if (inputStream != null) {
inputStream.close();
}
return;
}
} catch (Throwable th2) {
th = th2;
if (a3 != 0) {
try {
a3.close();
} catch (Exception e2) {
e2.printStackTrace();
}
}
throw th;
}
} catch (Exception e3) {
e = e3;
inputStream = null;
} catch (Throwable th3) {
th = th3;
a3 = 0;
if (a3 != 0) {
}
throw th;
}
if (a2 == null) {
if (d.this.f15067b != null) {
d.this.f15067b.a(null);
}
if (inputStream != null) {
try {
inputStream.close();
return;
} catch (Exception e4) {
e4.printStackTrace();
return;
}
}
return;
}
d.this.f = new JSONObject();
d.this.f.put("vc", TextUtils.isDigitsOnly(a2.getVc()) ? Integer.parseInt(a2.getVc()) : 0);
d.this.f.put(RankingItem.KEY_SIZE, TextUtils.isDigitsOnly(a2.getSize()) ? Integer.parseInt(a2.getSize()) : 0);
d.this.f.put(SocialConstants.PARAM_URL, a2.getUrl());
d.this.f.put("md5", a2.getMd5());
d.this.f.put(RankingItem.KEY_VER_NAME, a2.getVn());
d.this.f.put("showDialog", a2.getShowDialog());
if (!d.this.h) {
d.this.b();
} else if (d.this.f15067b == null || !d.this.f15067b.a(d.this.f)) {
Message message = new Message();
message.obj = d.this.f;
message.what = 10;
d.this.i.sendMessage(message);
}
if (inputStream != null) {
inputStream.close();
}
} catch (Exception e5) {
e5.printStackTrace();
}
}
});
this.e.start();
}
public boolean b() {
if (!this.h && (!e.a(this.f15066a) || this.f == null || this.f.optInt("vc") <= 0 || this.f.optInt("vc") <= a(this.d) || TextUtils.isEmpty(this.f.optString(SocialConstants.PARAM_URL)))) {
return false;
}
Message message = new Message();
message.obj = this.f;
message.what = 10;
this.i.sendMessage(message);
return true;
}
public boolean c() {
if (this.h) {
return true;
}
return e.a(this.f15066a) && this.f != null && this.f.optInt("vc") > 0 && this.f.optInt("vc") > a(this.d) && !TextUtils.isEmpty(this.f.optString(SocialConstants.PARAM_URL));
}
public int a(String str) {
try {
return this.f15066a.getPackageManager().getPackageInfo(str, 0).versionCode;
} catch (PackageManager.NameNotFoundException e) {
Log.e("UpdateAssistanceHelper", "getLocalVersionCode: " + e);
return -1;
}
}
public ApplicationInfo d() {
try {
return this.f15066a.getApplicationContext().getPackageManager().getApplicationInfo(this.f15066a.getPackageName(), 128);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return null;
}
}
public int e() {
ApplicationInfo d = d();
if (d == null) {
return 0;
}
return d.metaData.getInt("MainChId");
}
public int f() {
if (d() == null) {
return 0;
}
return d().metaData.getInt("SubChId");
}
public Boolean a(int i, int i2) {
if (i2 > i) {
return true;
}
return false;
}
public void a(float f, final int i) {
ViewGroup viewGroup = (ViewGroup) w.b(this.f15066a, "dialog_must_update_ly");
if (viewGroup == null) {
return;
}
a(f, viewGroup, i);
String e = w.e(this.f15066a, "yes_check");
String e2 = w.e(this.f15066a, "no_check");
Context context = this.f15066a;
boolean z = i == 1;
if (i == 1) {
e2 = null;
}
Dialog a2 = z.a(context, viewGroup, z, e2, e, new z.b() {
@Override
public void a(Dialog dialog) {
if (i != 1 && i == 0 && dialog != null && dialog.isShowing()) {
dialog.dismiss();
}
}
@Override
public void b(Dialog dialog) {
if (dialog != null && dialog.isShowing()) {
dialog.dismiss();
}
d.this.h();
}
});
if (a2 != null && a2.isShowing()) {
a2.dismiss();
}
if (a2 == null || !(this.f15066a instanceof Activity) || ((Activity) this.f15066a).isFinishing()) {
return;
}
a2.setCancelable(false);
a2.show();
}
public void h() {
if (this.j) {
if (this.g != null && this.g.isFile()) {
Intent e = as.e(this.g.getAbsolutePath());
e.setFlags(268435457);
try {
this.f15066a.startActivity(e);
return;
} catch (Exception e2) {
Log.e("UpdateAssistanceHelper", "onClickRight: " + e2);
return;
}
}
Toast.makeText(this.f15066a, com.excelliance.kxqp.swipe.a.a.getString(this.f15066a, "downloading"), 0).show();
return;
}
Toast.makeText(this.f15066a, com.excelliance.kxqp.swipe.a.a.getString(this.f15066a, "ad_start_download"), 0).show();
c(this.f.optString(SocialConstants.PARAM_URL));
}
private void a(float f, ViewGroup viewGroup, int i) {
LinearLayout linearLayout;
NetworkInfo networkInfo = ((ConnectivityManager) this.f15066a.getSystemService(FakeServiceHelper.CONNECTIVITY_SERVICE)).getNetworkInfo(1);
int d = w.d(this.f15066a, "tv_updateContent");
if (d != 0) {
TextView textView = (TextView) viewGroup.findViewById(d);
new StringBuilder();
float f2 = f > 0.0f ? f < 102.4f ? 0.1f : f / 1048576.0f : 0.0f;
if (networkInfo.isConnected()) {
int identifier = this.f15066a.getResources().getIdentifier("assistance_new_version_update", "string", this.f15066a.getPackageName());
if (identifier != 0) {
textView.setText(String.format(this.f15066a.getResources().getString(identifier), this.f.optString(RankingItem.KEY_VER_NAME), String.format("%.1f MB", Float.valueOf(f2))));
}
} else {
int identifier2 = this.f15066a.getResources().getIdentifier("assistance_new_no_wifi_version_update" + i, "string", this.f15066a.getPackageName());
if (identifier2 != 0) {
textView.setText(String.format(this.f15066a.getResources().getString(identifier2), this.f.optString(RankingItem.KEY_VER_NAME), String.format("%.1f MB", Float.valueOf(f2))));
}
}
}
int d2 = w.d(this.f15066a, "ll_checkbox");
if (d2 != 0 && (linearLayout = (LinearLayout) viewGroup.findViewById(d2)) != null) {
if (i == 0) {
linearLayout.setVisibility(0);
int d3 = w.d(this.f15066a, "cb_noToast");
if (d3 != 0) {
CheckBox checkBox = (CheckBox) viewGroup.findViewById(d3);
checkBox.setButtonDrawable(this.f15066a.getResources().getIdentifier("checkbox_add", "drawable", this.f15066a.getPackageName()));
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
}
});
}
} else if (i == 1) {
linearLayout.setVisibility(8);
}
linearLayout.setVisibility(8);
}
int d4 = w.d(this.f15066a, "tv_updateVersionCode");
if (d4 != 0) {
((TextView) viewGroup.findViewById(d4)).setVisibility(8);
}
}
public static String a(String str, String str2) {
return str + str2 + ".apk";
}
public static String b(String str) {
if (Environment.getExternalStorageState().equals("mounted")) {
return Environment.getExternalStorageDirectory().getPath() + "/" + Environment.DIRECTORY_DOWNLOADS + "/";
}
return "/data/data/" + str + "/";
}
protected void c(String str) {
this.j = true;
Intent intent = new Intent(this.f15066a.getPackageName() + ".action.download");
String a2 = a(this.d, this.f.optString(RankingItem.KEY_VER_NAME));
intent.putExtra("filename", a2);
intent.putExtra("gameid", this.d);
intent.putExtra("md5", this.f.optString("md5"));
intent.putExtra("isShowUpatePrompt", false);
String packageName = this.f15066a.getPackageName();
String b2 = b(packageName);
intent.setPackage(packageName);
String str2 = b2 + "apk";
intent.putExtra("filepath", str2);
intent.putExtra("urlpath", str);
intent.putExtra("type", "apk");
this.f15066a.startService(intent);
this.g = new File(str2, a2);
Log.d("UpdateAssistanceHelper", this.g.getPath() + " is exist:" + this.g.isFile());
}
public void g() {
this.c = true;
}
public void a(JSONObject jSONObject) {
this.f = jSONObject;
h();
}
public static int a(Context context, String str, int i) {
int c = by.a(context, "download_sp").c(str + "_lastVer", 0);
if (c > 0) {
return c;
}
b(context, str, i);
return i;
}
public static void b(Context context, String str, int i) {
by.a(context, "download_sp").a(str + "_lastVer", i);
}
public static void a(Context context, Bundle bundle) {
if (context == null || bundle == null) {
return;
}
int i = bundle.getInt("serverVersionCode_lastVer", 0);
short s = bundle.getShort("b64", (short) 0);
if (i > 0) {
b(context, s == 1 ? e.b(context) : context.getPackageName(), i);
}
}
}