OurPlay v5.5.9版本的 MD5 值为:d4e139798f4c2243a1145c8af5e21046
以下内容为反编译后的 a.java 源代码,内容仅作参考
package com.excelliance.kxqp.low;
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.net.Uri;
import android.os.Build;
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 androidx.core.content.FileProvider;
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.av;
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.excelliance.kxqp.util.master.e;
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 a {
public Context f12508a;
public InterfaceC0492a f12509b;
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 InterfaceC0492a {
boolean a(JSONObject jSONObject);
}
public a(Context context) {
this(context, false);
}
public a(Context context, boolean z) {
this.h = false;
this.f12509b = null;
this.i = new Handler() {
@Override
public void handleMessage(Message message) {
if (a.this.c) {
Log.d("UpdateAssistanceHelper", "handleMessage: already destroy");
return;
}
if (message.what == 10 && a.this.f != null) {
int optInt = a.this.f.optInt("vc");
Log.d("UpdateAssistanceHelper", "serverVersionCode = " + optInt);
String optString = a.this.f.optString("showDialog");
if (optInt > 0) {
if (a.this.a(a.this.a(a.this.d), optInt).booleanValue()) {
float optInt2 = a.this.f.optInt(RankingItem.KEY_SIZE);
Log.d("UpdateAssistanceHelper", "showDialog = " + optString);
if (a.this.h) {
if (a.this.f12509b == null || !a.this.f12509b.a(a.this.f)) {
a.this.f();
return;
}
return;
}
if (TextUtils.equals(optString, "2")) {
a.this.a(optInt2, 0);
} else if (TextUtils.equals(optString, "3")) {
a.this.a(optInt2, 1);
}
}
}
}
}
};
this.j = false;
this.c = false;
this.f12508a = context;
this.d = b.a(this.f12508a);
this.h = z;
}
public String a(int i) {
String packageName = this.f12508a.getPackageName();
GameUtil intance = GameUtil.getIntance();
intance.q(this.f12508a);
StringBuilder sb = new StringBuilder();
sb.append("https://sdk.ourplay.com.cn/chkversion.php");
sb.append("?chid=");
sb.append(d());
sb.append("&subchid=");
sb.append(e());
sb.append("&pkg=");
sb.append(this.d);
sb.append("&vc=");
sb.append(b.b(this.f12508a) ? 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(b.b(this.f12508a) ? e.d(this.f12508a, this.d) : null);
sb.append("&needInfo=1");
return sb.toString();
}
public void a() {
if (!this.h && !b.b(this.f12508a)) {
Log.d("UpdateAssistanceHelper", "checkIsNewVersion: no " + this.d);
return;
}
if (!av.a().b(this.f12508a)) {
Toast.makeText(this.f12508a, com.excelliance.kxqp.swipe.a.a.getString(this.f12508a, "network_error_retry"), 0).show();
} else {
this.e = new Thread(new Runnable() {
@Override
public void run() {
Throwable th;
InputStream inputStream;
Upl a2;
?? a3 = a.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);
} catch (Exception e) {
e = e;
if (a.this.f12509b != null) {
a.this.f12509b.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 (a.this.f12509b != null) {
a.this.f12509b.a(null);
}
if (inputStream != null) {
try {
inputStream.close();
return;
} catch (Exception e4) {
e4.printStackTrace();
return;
}
}
return;
}
a.this.f = new JSONObject();
a.this.f.put("vc", TextUtils.isDigitsOnly(a2.getVc()) ? Integer.parseInt(a2.getVc()) : 0);
a.this.f.put(RankingItem.KEY_SIZE, TextUtils.isDigitsOnly(a2.getSize()) ? Integer.parseInt(a2.getSize()) : 0);
a.this.f.put(SocialConstants.PARAM_URL, a2.getUrl());
a.this.f.put("md5", a2.getMd5());
a.this.f.put(RankingItem.KEY_VER_NAME, a2.getVn());
a.this.f.put("showDialog", a2.getShowDialog());
Log.d("UpdateAssistanceHelper", "run: " + a.this.f);
if (!a.this.h) {
a.this.b();
} else if (a.this.f12509b == null || !a.this.f12509b.a(a.this.f)) {
Message message = new Message();
message.obj = a.this.f;
message.what = 10;
a.this.i.sendMessage(message);
}
if (inputStream != null) {
inputStream.close();
}
} catch (Exception e5) {
e5.printStackTrace();
}
}
});
this.e.start();
}
}
public boolean b() {
if (!this.h && (!b.b(this.f12508a) || 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 int a(String str) {
try {
return this.f12508a.getPackageManager().getPackageInfo(str, 0).versionCode;
} catch (PackageManager.NameNotFoundException e) {
Log.e("UpdateAssistanceHelper", "getLocalVersionCode: " + e);
return -1;
}
}
public ApplicationInfo c() {
try {
return this.f12508a.getApplicationContext().getPackageManager().getApplicationInfo(this.f12508a.getPackageName(), 128);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return null;
}
}
public int d() {
ApplicationInfo c = c();
if (c == null) {
return 0;
}
return c.metaData.getInt("MainChId");
}
public int e() {
if (c() == null) {
return 0;
}
return c().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.f12508a, "dialog_must_update_ly");
if (viewGroup == null) {
return;
}
a(f, viewGroup, i);
String e = w.e(this.f12508a, "yes_check");
String e2 = w.e(this.f12508a, "no_check");
Context context = this.f12508a;
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();
}
a.this.f();
}
});
if (a2 != null && a2.isShowing()) {
a2.dismiss();
}
if (a2 == null || !(this.f12508a instanceof Activity) || ((Activity) this.f12508a).isFinishing()) {
return;
}
a2.setCancelable(false);
a2.show();
}
public static void a(Context context, final int i, final a aVar) {
LinearLayout linearLayout;
ViewGroup viewGroup = (ViewGroup) w.b(context, "dialog_must_update_ly");
if (viewGroup == null) {
return;
}
NetworkInfo networkInfo = ((ConnectivityManager) context.getSystemService(FakeServiceHelper.CONNECTIVITY_SERVICE)).getNetworkInfo(1);
int d = w.d(context, "tv_updateContent");
if (d != 0) {
TextView textView = (TextView) viewGroup.findViewById(d);
if (networkInfo.isConnected()) {
textView.setText(String.format(com.excelliance.kxqp.swipe.a.a.getString(context, "low_new_version_down"), com.excelliance.kxqp.swipe.a.a.getString(context, "low_name")));
} else {
textView.setText(String.format(com.excelliance.kxqp.swipe.a.a.getString(context, "low_new_no_wifi_version_down0"), com.excelliance.kxqp.swipe.a.a.getString(context, "low_name")));
}
}
int d2 = w.d(context, "ll_checkbox");
if (d2 != 0 && (linearLayout = (LinearLayout) viewGroup.findViewById(d2)) != null) {
if (i == 0) {
linearLayout.setVisibility(0);
int d3 = w.d(context, "cb_noToast");
if (d3 != 0) {
CheckBox checkBox = (CheckBox) viewGroup.findViewById(d3);
checkBox.setButtonDrawable(context.getResources().getIdentifier("checkbox_add", "drawable", context.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(context, "tv_updateVersionCode");
if (d4 != 0) {
((TextView) viewGroup.findViewById(d4)).setVisibility(8);
}
com.excelliance.kxqp.ui.util.b.a((TextView) com.excelliance.kxqp.ui.util.b.a("title", viewGroup), com.excelliance.kxqp.swipe.a.a.getString(context, "hint"), "");
String e = w.e(context, "exit_dialog_yes");
String e2 = w.e(context, "exit_dialog_no");
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();
}
aVar.h = true;
aVar.a();
}
});
if (a2 != null && a2.isShowing()) {
a2.dismiss();
}
if (a2 == null || !(context instanceof Activity) || ((Activity) context).isFinishing()) {
return;
}
a2.setCancelable(false);
a2.show();
}
public void f() {
Uri fromFile;
if (this.j) {
if (this.g != null && this.g.isFile()) {
if (Build.VERSION.SDK_INT >= 24) {
fromFile = FileProvider.getUriForFile(this.f12508a, this.f12508a.getPackageName() + ".fileProvider", this.g);
} else {
fromFile = Uri.fromFile(this.g);
}
Intent intent = new Intent("android.intent.action.VIEW");
intent.setDataAndType(fromFile, "application/vnd.android.package-archive");
intent.setFlags(268435457);
try {
this.f12508a.startActivity(intent);
return;
} catch (Exception e) {
Log.e("UpdateAssistanceHelper", "onClickRight: " + e);
return;
}
}
Toast.makeText(this.f12508a, com.excelliance.kxqp.swipe.a.a.getString(this.f12508a, "downloading"), 0).show();
return;
}
Toast.makeText(this.f12508a, com.excelliance.kxqp.swipe.a.a.getString(this.f12508a, "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.f12508a.getSystemService(FakeServiceHelper.CONNECTIVITY_SERVICE)).getNetworkInfo(1);
int d = w.d(this.f12508a, "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()) {
textView.setText(String.format(com.excelliance.kxqp.swipe.a.a.getString(this.f12508a, "low_new_version_update"), com.excelliance.kxqp.swipe.a.a.getString(this.f12508a, "low_name"), this.f.optString(RankingItem.KEY_VER_NAME), String.format("%.1f MB", Float.valueOf(f2))));
} else {
textView.setText(String.format(com.excelliance.kxqp.swipe.a.a.getString(this.f12508a, "low_new_no_wifi_version_update0"), com.excelliance.kxqp.swipe.a.a.getString(this.f12508a, "low_name"), this.f.optString(RankingItem.KEY_VER_NAME), String.format("%.1f MB", Float.valueOf(f2))));
}
}
int d2 = w.d(this.f12508a, "ll_checkbox");
if (d2 != 0 && (linearLayout = (LinearLayout) viewGroup.findViewById(d2)) != null) {
if (i == 0) {
linearLayout.setVisibility(0);
int d3 = w.d(this.f12508a, "cb_noToast");
if (d3 != 0) {
CheckBox checkBox = (CheckBox) viewGroup.findViewById(d3);
checkBox.setButtonDrawable(this.f12508a.getResources().getIdentifier("checkbox_add", "drawable", this.f12508a.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.f12508a, "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.f12508a.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.f12508a.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.f12508a.startService(intent);
this.g = new File(str2, a2);
Log.d("UpdateAssistanceHelper", this.g.getPath() + " is exist:" + this.g.isFile());
}
}