大xiang v2.8.2版本的 MD5 值为:15b284c26af8fa068f351168eb25f2f1
以下内容为反编译后的 MainActivity.java 源代码,内容仅作参考
package com.win.first;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.Base64;
import com.alibaba.fastjson.JSONObject;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.http.HttpHost;
import org.apache.http.protocol.HttpRequestExecutor;
public class MainActivity extends BaseActivity {
public static String BackHomeIcon = "btnback";
public static boolean LOAD_FINISHED = false;
public static int LOAD_PROGRESS = 0;
public static String URL_KEY = "GAME_SAVE_DATA";
public static boolean WaitLoadNotice;
public int mIndex = 0;
public long mTime = System.currentTimeMillis();
public int TIMEOUT = 60;
public String appCode = "daxiang";
public String[] mGitUrlList = {"https://privacypolicy.bybxmp.com/data/daxiang", "https://privacypolicy.yimunongzhuang.net/data/daxiang", "https://terms.privacypolicy.world/data/daxiang"};
public String[] mList = new String[0];
public int mGitIndex = 0;
public ArrayList<String> mUrlList = new ArrayList<>();
public String mLoadingUrl = "";
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
LOAD_PROGRESS = 0;
LOAD_FINISHED = false;
JsToJava.LoadComplete = false;
Bundle extras = getIntent().getExtras();
if (extras != null && extras.getBoolean("cdvStartInBackground", false)) {
moveTaskToBack(true);
}
JsToJava.init(this);
getWindow().addFlags(128);
setVolumeControlStream(3);
startActivity(new Intent(this, LogoActivity.class));
if (!Utils.isNetConnection(this)) {
displayError("", getResources().getString(com.bsitoqau.zcepwldf.R.string.network_failure), getResources().getString(com.bsitoqau.zcepwldf.R.string.ok), true);
return;
}
setSaveData();
AndroidBug5497Workaround.assistActivity(this);
new Timer().schedule(new TimerTask() {
@Override
public void run() {
MainActivity.this.getConfigData();
}
}, 1500L);
loadUrl("");
startLoadUrl();
}
public void setSaveData() {
String[] split;
try {
String saveData = getSaveData();
if (saveData.length() > 0) {
for (String str : saveData.split("\\|")) {
if (str.indexOf(HttpHost.DEFAULT_SCHEME_NAME) != -1) {
this.mUrlList.add(str);
}
}
}
if (this.mUrlList.size() == 0) {
for (int i = 0; i < this.mList.length; i++) {
String str2 = this.mList[i];
if (str2.length() > 0) {
this.mUrlList.add(str2);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void getConfigData() {
EventManager.getInstance().publishEvent(new EventEntity(EventEntity.Event_Git_Load, this.mGitIndex));
String str = this.mGitUrlList[this.mGitIndex];
httpGet(str + "?" + System.currentTimeMillis());
}
public void onGitHttpError() {
int length = this.mGitUrlList.length;
int i = this.mGitIndex;
if (i < length - 1) {
this.mGitIndex = i + 1;
getConfigData();
}
}
public void startLoadUrl() {
if (this.mUrlList.size() > 0) {
new Timer().schedule(new TimerTask() {
@Override
public void run() {
try {
Uri.Builder buildUpon = Uri.parse(MainActivity.this.mUrlList.get(MainActivity.this.mIndex)).buildUpon();
buildUpon.appendQueryParameter("rt", System.currentTimeMillis() + "");
MainActivity.this.mLoadingUrl = buildUpon.toString();
MainActivity.this.loadUrl(MainActivity.this.mLoadingUrl);
EventManager.getInstance().publishEvent(new EventEntity(EventEntity.Event_Game_Load, MainActivity.this.mIndex));
} catch (Exception e) {
e.printStackTrace();
}
}
}, 1500L);
}
}
public void httpGet(String str) {
try {
String userAgent = Utils.getUserAgent(this);
String format = String.format(" Network/%s Appcode/%s Appver/%s", getNetType(), this.appCode, getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
new OkHttpClient.Builder().connectTimeout(5L, TimeUnit.SECONDS).readTimeout(5L, TimeUnit.SECONDS).retryOnConnectionFailure(false).build().newCall(new Request.Builder().url(str).removeHeader("User-Agent").addHeader("User-Agent", userAgent + format).get().build()).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException iOException) {
MainActivity.this.onGitHttpError();
iOException.printStackTrace();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
response.body();
MainActivity.this.processData(response.body().string());
}
});
} catch (Exception e) {
onGitHttpError();
e.printStackTrace();
}
}
public void processData(String str) {
try {
int i = 0;
JSONObject parseObject = JSONObject.parseObject(new String(Base64.decode(new StringBuffer(str).reverse().toString(), 0)));
String string = parseObject.getString("min");
String string2 = parseObject.getString("goto");
if (Utils.compareVersion(string, Utils.getPackageVersionName(this)) > 0) {
if (string2.length() > 0) {
showApkJump(string2);
return;
} else {
showApkInvalid();
return;
}
}
List list = (List) parseObject.getObject("url", List.class);
String str2 = "";
for (int i2 = 0; i2 < list.size(); i2++) {
String str3 = (String) list.get(i2);
str2 = i2 == 0 ? str3 : str2 + "|" + str3;
}
SharedPreferences.Editor edit = getSharedPreferences(getPackageName(), 0).edit();
edit.putString(URL_KEY, str2);
edit.commit();
if (str2.length() > 0) {
String[] split = str2.split("\\|");
if (!(this.mUrlList.size() > 0 ? this.mUrlList.get(this.mIndex) : "").equals(split[0])) {
this.mUrlList.clear();
while (i < split.length) {
String str4 = split[i];
if (str4.indexOf(HttpHost.DEFAULT_SCHEME_NAME) != -1) {
this.mUrlList.add(str4);
}
i++;
}
if (this.mLoadingUrl == "") {
startLoadUrl();
return;
}
return;
}
while (i < split.length) {
String str5 = split[i];
if (str5.indexOf(HttpHost.DEFAULT_SCHEME_NAME) != -1) {
this.mUrlList.add(str5);
}
i++;
}
}
} catch (Exception e) {
onGitHttpError();
e.printStackTrace();
}
}
public String getSaveData() {
return getSharedPreferences(getPackageName(), 0).getString(URL_KEY, "");
}
public String addParameter(String str) {
Calendar calendar = Calendar.getInstance();
return (((str + "?from=1") + "&version=" + getVersionName()) + "&t=" + ("" + calendar.get(1) + (calendar.get(2) + 1) + calendar.get(5) + calendar.get(11) + calendar.get(12) + calendar.get(13) + calendar.get(14))) + "&id=" + Config.CHANNEL_FLAG;
}
public String getVersionName() {
try {
return getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
} catch (Exception e) {
e.printStackTrace();
return "0.0.0";
}
}
@Override
public String getAppCode() {
return this.appCode;
}
@Override
public String getNetType() {
return Utils.getNetWorkClass(this);
}
@Override
public void openUrl(String str) {
JsToJava.openURL(str);
}
@Override
public void openWebView(String str) {
Intent intent = new Intent(this, WebActivity.class);
Bundle bundle = new Bundle();
bundle.putString("url", str);
intent.putExtras(bundle);
startActivity(intent);
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public void onReceivedError(int i, String str, String str2) {
if (Math.round((float) ((System.currentTimeMillis() - this.mTime) / 1000)) <= this.TIMEOUT) {
int i2 = this.mIndex + 1;
this.mIndex = i2;
if (i2 >= this.mUrlList.size()) {
this.mIndex = 0;
}
startLoadUrl();
return;
}
showErrorDialog();
}
@Override
public void onPageFinished() {
EventManager.getInstance().publishEvent(new EventEntity(EventEntity.Event_Load_Finished, 100));
}
@Override
public void onProgressChanged(int i) {
EventManager.getInstance().publishEvent(new EventEntity(EventEntity.Event_Load_Progress, i));
}
@Override
public void onUrlLoadFinished() {
JsToJava.LoadComplete = true;
}
@Override
public void onOpenUrl(String str) {
JsToJava.openURL(str);
}
public void showErrorDialog() {
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
this.appView.getView().setVisibility(8);
this.displayError("", MainActivity.this.getResources().getString(com.bsitoqau.zcepwldf.R.string.network_failure), MainActivity.this.getResources().getString(com.bsitoqau.zcepwldf.R.string.ok), true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public void checkUrlValid(final String str) {
new Thread(new Runnable() {
@Override
public void run() {
try {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
httpURLConnection.setUseCaches(false);
httpURLConnection.setConnectTimeout(HttpRequestExecutor.DEFAULT_WAIT_FOR_CONTINUE);
httpURLConnection.getResponseCode();
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
public String getMobileInfo() {
String str = Build.MODEL;
String str2 = Build.MANUFACTURER;
String str3 = Build.VERSION.RELEASE;
HashMap hashMap = new HashMap();
hashMap.put("model", str);
hashMap.put("manufacturer", str2);
hashMap.put("systemVersion", str3);
return new org.json.JSONObject(hashMap).toString();
}
public void showApkInvalid() {
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
List<BaseActivity> activityList = MyApplication.getInstance().getActivityList();
BaseActivity baseActivity = activityList.get(activityList.size() - 1);
baseActivity.showError = true;
AlertDialog.Builder builder = new AlertDialog.Builder(baseActivity);
builder.setMessage("当前版本已过期!");
builder.setTitle("");
builder.setCancelable(false);
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
MyApplication.getInstance().exit();
}
});
builder.create();
builder.show();
this.appView.getView().setVisibility(8);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public void showApkJump(final String str) {
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
List<BaseActivity> activityList = MyApplication.getInstance().getActivityList();
BaseActivity baseActivity = activityList.get(activityList.size() - 1);
baseActivity.showError = true;
AlertDialog.Builder builder = new AlertDialog.Builder(baseActivity);
builder.setMessage("请前往下载新的版本!");
builder.setTitle("");
builder.setCancelable(false);
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
try {
MainActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
} catch (Exception e) {
e.printStackTrace();
}
}
});
builder.create();
builder.show();
this.appView.getView().setVisibility(8);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}