OurPlay v5.5.9版本的 MD5 值为:d4e139798f4c2243a1145c8af5e21046
以下内容为反编译后的 b.java 源代码,内容仅作参考
package com.excelliance.staticslio.h;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import com.excelliance.staticslio.StatisticsManager;
import com.excelliance.staticslio.i.i;
import com.umeng.analytics.pro.am;
import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import org.apache.http.cookie.ClientCookie;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class b extends d {
public static String f15336a = "http://statis.multiopen.cn/getctrl.php";
private static String c = "http://statis.multiopen.cn/getctrlbk.php";
private a d;
private Context f;
private int e = -1;
private boolean g = false;
private String h = "";
private String i = "";
public boolean f15337b = false;
public interface a {
void a();
void a(Map<String, com.excelliance.staticslio.a.c> map, boolean z);
}
public b(Context context, long j, long j2) {
a(context, "get_ctrl_info_task");
this.f = context;
a(context);
b(j2);
a(System.currentTimeMillis() + j);
if (i.a()) {
i.a(StatisticsManager.TAG, "Get ctrlInfo task constructed!:" + b());
}
}
public void a(a aVar) {
this.d = aVar;
}
@Override
public void a() {
if (i.a()) {
i.a(StatisticsManager.TAG, "Execute getCtrlInfoTask!");
}
new Thread("get_ctrlinfo_thread") {
@Override
public void run() {
if (b.this.d != null) {
b.this.d.a();
}
Map<String, com.excelliance.staticslio.a.c> map = null;
if (b.this.f15337b) {
String h = b.this.h();
if (i.b(h)) {
b.this.g = false;
} else {
b.this.g = true;
if (i.a()) {
i.a(StatisticsManager.TAG, "NewCtrlInfo:" + h);
}
map = b.this.a(h);
b.this.a(h, map);
}
b.this.d.a(map, b.this.g);
return;
}
if (i.a()) {
i.b("GetCtrlInfoTask", "Get ctrl info network is not ok and quit");
}
b.this.g = false;
b.this.d.a(null, b.this.g);
}
}.start();
}
public void a(String str, Map<String, com.excelliance.staticslio.a.c> map) {
StringBuffer stringBuffer = new StringBuffer("\r\n\r\n\r\nTime:" + new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date(System.currentTimeMillis())) + "\r\nConnect uri:" + this.h + "\r\n" + str + "\r\n");
StringBuilder sb = new StringBuilder();
sb.append("RequestInfo:");
sb.append(this.i);
sb.append("\r\n");
stringBuffer.append(sb.toString());
stringBuffer.append("UserInfo: userRatio:" + this.e + ", userContry:" + com.excelliance.staticslio.b.d + "\r\n");
stringBuffer.append("Newest ctrlBean In DB:");
for (String str2 : map.keySet()) {
stringBuffer.append("\r\n");
com.excelliance.staticslio.a.c cVar = map.get(str2);
String d = cVar.d();
String f = cVar.f();
stringBuffer.append("[ctrlBean: funid:" + cVar.e() + ", bn:" + d + ", updateTime:" + f + ", priority:" + cVar.h() + ", interval:" + cVar.c() + ", validTime:" + cVar.b() + "]");
}
try {
FileOutputStream openFileOutput = this.f.openFileOutput("CtrlInfoLog.txt", 32768);
openFileOutput.write(stringBuffer.toString().getBytes());
openFileOutput.close();
} catch (Exception e) {
i.a(e);
}
}
public Map<String, com.excelliance.staticslio.a.c> a(String str) {
int i;
HashMap hashMap = new HashMap();
try {
JSONArray jSONArray = new JSONObject(StatisticsManager.sDebugMode ? "{\"ctrl_info\":[{\"prd_id\":\"105\",\"channel\":null,\"version_code\":null,\"os_version_code\":null,\"country\":null,\"network\":\"0\",\"user_type\":\"0\",\"user_ratio\":\"100\",\"bn\":\"1468566384\",\"upload_cycle\":\"0\",\"stat_id\":\"483,524\",\"valid_time\":\"2147483647\",\"update_time\":\"1468572661\",\"priority\":\"1\"},{\"prd_id\":\"105\",\"channel\":null,\"version_code\":null,\"os_version_code\":null,\"country\":null,\"network\":\"0\",\"user_type\":\"0\",\"user_ratio\":\"100\",\"bn\":\"1468566384\",\"upload_cycle\":\"8\",\"stat_id\":\"460,461,490\",\"valid_time\":\"2147483647\",\"update_time\":\"1468572661\",\"priority\":\"1\"}]}" : str).getJSONArray("ctrl_info");
i.b("GetCtrlInfoTask", "get simulated switch info:" + jSONArray.toString());
for (int i2 = 0; i2 < jSONArray.length(); i2++) {
JSONObject jSONObject = (JSONObject) jSONArray.opt(i2);
String string = jSONObject.getString(am.O);
String string2 = jSONObject.getString("channel");
String string3 = jSONObject.getString("version_code");
String string4 = jSONObject.getString("os_version_code");
int i3 = jSONObject.getInt("network");
String string5 = jSONObject.getString("bn");
if (!i.b(string5)) {
string5 = string5 + "000";
}
String str2 = string5;
long j = jSONObject.getLong("valid_time") * 1000;
String string6 = jSONObject.getString("update_time");
if (!i.b(string6)) {
string6 = string6 + "000";
}
String str3 = string6;
int i4 = jSONObject.getInt("user_type");
int i5 = jSONObject.getInt("user_ratio");
String string7 = jSONObject.getString("stat_id");
String string8 = jSONObject.getString("upload_cycle");
int i6 = jSONObject.getInt("priority");
if (b(i5) && e(string) && d(string2) && c(string3) && b(string4) && a(i4)) {
long longValue = Long.valueOf(string8).longValue() * 3600000;
if (!i.b(string7)) {
String[] split = string7.split(StatisticsManager.COMMA);
int length = split.length;
int i7 = 0;
while (i7 < length) {
String str4 = split[i7];
if (i.b(str4)) {
i = i7;
} else {
i = i7;
a(hashMap, new com.excelliance.staticslio.a.c(j, longValue, str2, str3, Integer.valueOf(str4.trim()).intValue(), System.currentTimeMillis(), i3, i6));
}
i7 = i + 1;
}
}
}
}
} catch (JSONException e) {
e.printStackTrace();
}
return hashMap;
}
private void a(Map<String, com.excelliance.staticslio.a.c> map, com.excelliance.staticslio.a.c cVar) {
com.excelliance.staticslio.a.c cVar2 = map.get(String.valueOf(cVar.e()));
if (cVar2 == null || cVar2.h() < cVar.h()) {
map.put(String.valueOf(cVar.e()), cVar);
if (i.a()) {
i.b("GetCtrlInfoTask", "ctrlBeanfunId:" + cVar.e() + ", validtime:" + cVar.b() + ", intervaltime:" + cVar.c());
}
}
}
private boolean a(int i) {
if (i == 0) {
return true;
}
return StatisticsManager.sIsNew;
}
private boolean b(int i) {
if (this.e == -1) {
a(this.f);
}
return this.e < i;
}
private boolean b(String str) {
return a(String.valueOf(StatisticsManager.sOSVersionCode), str);
}
private boolean c(String str) {
return a(String.valueOf(StatisticsManager.sVersionCode), str);
}
private boolean d(String str) {
return a(StatisticsManager.sChannel, str);
}
private boolean e(String str) {
return a(com.excelliance.staticslio.b.d, str);
}
private boolean a(String str, String str2) {
if (i.b(str2) || i.b(str)) {
return true;
}
for (String str3 : str2.split(StatisticsManager.COMMA)) {
if (i.a()) {
i.b("GetCtrlInfoTask", "serverInfo:" + str3 + ", localInfo:" + str);
}
if (str3.trim().equalsIgnoreCase(str)) {
return true;
}
}
return false;
}
public String h() {
String str;
HttpURLConnection httpURLConnection;
Log.d("GetCtrlInfoTask", "debugMode = " + StatisticsManager.sDebugMode);
if (StatisticsManager.sDebugMode) {
str = c;
if (i.a()) {
i.b("GetCtrlInfoTask", "Debug Build:" + c);
}
} else {
str = f15336a;
if (i.a()) {
i.b("GetCtrlInfoTask", "Release Build:" + f15336a);
}
}
String str2 = null;
StringBuilder sb = new StringBuilder();
try {
URL url = new URL(str + "?type=0");
this.h = url.toURI().toString();
httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
httpURLConnection.setUseCaches(false);
httpURLConnection.setRequestProperty("Content-type", "application/json");
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setReadTimeout(60000);
httpURLConnection.setConnectTimeout(60000);
httpURLConnection.connect();
this.i = i();
OutputStream outputStream = httpURLConnection.getOutputStream();
outputStream.write(this.i.getBytes());
outputStream.flush();
outputStream.close();
} catch (Exception e) {
e = e;
}
if (httpURLConnection.getResponseCode() == 200) {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream()));
while (true) {
String readLine = bufferedReader.readLine();
if (readLine != null) {
sb.append(readLine);
} else {
String sb2 = sb.toString();
try {
Log.d("GetCtrlInfoTask", "result = " + sb2);
return sb2;
} catch (Exception e2) {
str2 = sb2;
e = e2;
e.printStackTrace();
return str2;
}
}
}
} else {
Log.d("GetCtrlInfoTask", "getResponseCode = " + httpURLConnection.getResponseCode());
return str2;
}
}
private String i() {
JSONArray jSONArray = new JSONArray();
JSONObject jSONObject = new JSONObject();
try {
if (StatisticsManager.sAndroidId != null) {
jSONObject.put("android_id", com.excelliance.staticslio.i.a.a(StatisticsManager.sAndroidId).getBytes());
} else {
jSONObject.put("android_id", StatisticsManager.sAndroidId);
}
jSONObject.put(ClientCookie.VERSION_ATTR, "1468566384");
jSONObject.put("isnew", StatisticsManager.isNewCtrol);
jSONObject.put("m_ch", i.a(this.f, "MainChId"));
jSONObject.put("s_ch", i.a(this.f, "SubChId"));
jSONObject.put("ver_c", i.a(this.f, "VersionCode"));
jSONArray.put(jSONObject);
} catch (Exception e) {
if (i.a()) {
i.a(StatisticsManager.TAG, "getCtrInfo error:" + e);
}
}
return jSONArray.toString();
}
public int a(Context context) {
SharedPreferences sharedPreferences = context.getSharedPreferences("ctrl_sp", 0);
if (!sharedPreferences.contains("user_ratio")) {
SharedPreferences sharedPreferences2 = context.getSharedPreferences(StatisticsManager.CTRL_SP_NAME + context.getPackageName(), 0);
SharedPreferences.Editor edit = sharedPreferences2.edit();
this.e = sharedPreferences2.getInt("user_ratio", -1);
if (this.e == -1) {
this.e = new Random().nextInt(100);
edit.putInt("user_ratio", this.e);
edit.commit();
}
} else {
this.e = sharedPreferences.getInt("user_ratio", -1);
SharedPreferences sharedPreferences3 = context.getSharedPreferences(StatisticsManager.CTRL_SP_NAME + context.getPackageName(), 0);
if (this.e != -1) {
SharedPreferences.Editor edit2 = sharedPreferences3.edit();
edit2.putInt("user_ratio", this.e);
edit2.commit();
sharedPreferences.edit().remove("user_ratio").commit();
}
}
return this.e;
}
}