湘游汇 v1.0版本的 MD5 值为:85338391d88b5d57da66e240ece801c7
以下内容为反编译后的 n.java 源代码,内容仅作参考
package com.tencent.c.a.a;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Proxy;
import android.os.Environment;
import android.os.Process;
import android.os.StatFs;
import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.WindowManager;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileReader;
import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.zip.GZIPInputStream;
import org.apache.http.HttpHost;
import org.cocos2dx.lib.BuildConfig;
import org.json.JSONObject;
public class n {
private static String f751a = null;
private static String b = null;
private static String c = null;
private static String d = null;
private static Random e = null;
private static DisplayMetrics f = null;
private static String g = null;
private static String h = "";
private static String i = "";
private static int j = -1;
private static b k = null;
private static String l = null;
private static String m = null;
private static volatile int n = -1;
private static String o = null;
private static String p = null;
private static long q = -1;
private static String r = "";
private static q s = null;
private static String t = "__MTA_FIRST_ACTIVATE__";
private static int u = -1;
private static long v = -1;
private static int w = 0;
private static String x = "";
public static int a() {
return g().nextInt(Integer.MAX_VALUE);
}
public static int a(Context context, boolean z) {
if (z) {
w = x(context);
}
return w;
}
public static Long a(String str, String str2, int i2, int i3, Long l2) {
if (str != null && str2 != null) {
if (str2.equalsIgnoreCase(".") || str2.equalsIgnoreCase("|")) {
str2 = "\\" + str2;
}
String[] split = str.split(str2);
if (split.length == i3) {
try {
Long l3 = 0L;
for (String str3 : split) {
l3 = Long.valueOf(i2 * (l3.longValue() + Long.valueOf(str3).longValue()));
}
return l3;
} catch (NumberFormatException unused) {
}
}
}
return l2;
}
public static String a(int i2) {
Calendar calendar = Calendar.getInstance();
calendar.roll(6, i2);
return new SimpleDateFormat("yyyyMMdd").format(calendar.getTime());
}
public static String a(long j2) {
return new SimpleDateFormat("yyyyMMdd").format(new Date(j2));
}
public static String a(Context context, String str) {
if (com.tencent.c.a.c.q()) {
if (m == null) {
m = n(context);
}
if (m != null) {
return str + "_" + m;
}
}
return str;
}
public static String a(String str) {
if (str == null) {
return "0";
}
try {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
messageDigest.update(str.getBytes());
byte[] digest = messageDigest.digest();
StringBuffer stringBuffer = new StringBuffer();
for (byte b2 : digest) {
int i2 = b2 & 255;
if (i2 < 16) {
stringBuffer.append("0");
}
stringBuffer.append(Integer.toHexString(i2));
}
return stringBuffer.toString();
} catch (Throwable unused) {
return "0";
}
}
public static HttpHost a(Context context) {
NetworkInfo activeNetworkInfo;
String extraInfo;
if (context == null) {
return null;
}
try {
} catch (Throwable th) {
k.b(th);
}
if (context.getPackageManager().checkPermission("android.permission.ACCESS_NETWORK_STATE", context.getPackageName()) == 0 && (activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo()) != null) {
if ((activeNetworkInfo.getTypeName() == null || !activeNetworkInfo.getTypeName().equalsIgnoreCase("WIFI")) && (extraInfo = activeNetworkInfo.getExtraInfo()) != null) {
if (!extraInfo.equals("cmwap") && !extraInfo.equals("3gwap") && !extraInfo.equals("uniwap")) {
if (extraInfo.equals("ctwap")) {
return new HttpHost("10.0.0.200", 80);
}
String defaultHost = Proxy.getDefaultHost();
if (defaultHost != null && defaultHost.trim().length() > 0) {
return new HttpHost(defaultHost, Proxy.getDefaultPort());
}
return null;
}
return new HttpHost("10.0.0.172", 80);
}
return null;
}
return null;
}
public static void a(Context context, int i2) {
w = i2;
s.b(context, "mta.qq.com.difftime", i2);
}
public static boolean a(com.tencent.c.a.g gVar) {
if (gVar == null) {
return false;
}
return c(gVar.c());
}
public static byte[] a(byte[] bArr) {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bArr);
GZIPInputStream gZIPInputStream = new GZIPInputStream(byteArrayInputStream);
byte[] bArr2 = new byte[4096];
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(bArr.length * 2);
while (true) {
int read = gZIPInputStream.read(bArr2);
if (read == -1) {
byte[] byteArray = byteArrayOutputStream.toByteArray();
byteArrayInputStream.close();
gZIPInputStream.close();
byteArrayOutputStream.close();
return byteArray;
}
byteArrayOutputStream.write(bArr2, 0, read);
}
}
public static long b(String str) {
return a(str, ".", 100, 3, 0L).longValue();
}
public static synchronized b b() {
b bVar;
synchronized (n.class) {
if (k == null) {
b bVar2 = new b("MtaSDK");
k = bVar2;
bVar2.a(false);
}
bVar = k;
}
return bVar;
}
public static synchronized String b(Context context) {
synchronized (n.class) {
if (f751a != null && f751a.trim().length() != 0) {
return f751a;
}
String a2 = t.a(context);
f751a = a2;
if (a2 == null || f751a.trim().length() == 0) {
f751a = Integer.toString(g().nextInt(Integer.MAX_VALUE));
}
return f751a;
}
}
public static long c() {
long currentTimeMillis;
try {
Calendar calendar = Calendar.getInstance();
calendar.set(11, 0);
calendar.set(12, 0);
calendar.set(13, 0);
calendar.set(14, 0);
currentTimeMillis = calendar.getTimeInMillis();
} catch (Throwable th) {
k.b(th);
currentTimeMillis = System.currentTimeMillis();
}
return currentTimeMillis + 86400000;
}
public static synchronized String c(Context context) {
String str;
synchronized (n.class) {
if (c == null || c.trim().length() == 0) {
c = t.b(context);
}
str = c;
}
return str;
}
public static boolean c(String str) {
return (str == null || str.trim().length() == 0) ? false : true;
}
public static DisplayMetrics d(Context context) {
if (f == null) {
f = new DisplayMetrics();
((WindowManager) context.getApplicationContext().getSystemService("window")).getDefaultDisplay().getMetrics(f);
}
return f;
}
public static String d() {
if (c(p)) {
return p;
}
StatFs statFs = new StatFs(Environment.getDataDirectory().getPath());
String str = String.valueOf((statFs.getBlockSize() * statFs.getAvailableBlocks()) / 1000000) + "/" + String.valueOf(e() / 1000000);
p = str;
return str;
}
public static long e() {
StatFs statFs = new StatFs(Environment.getDataDirectory().getPath());
return statFs.getBlockCount() * statFs.getBlockSize();
}
public static boolean e(Context context) {
NetworkInfo[] allNetworkInfo;
try {
} catch (Throwable th) {
k.b(th);
}
if (!t.a(context, "android.permission.ACCESS_WIFI_STATE")) {
k.c("can not get the permission of android.permission.ACCESS_WIFI_STATE");
return false;
}
ConnectivityManager connectivityManager = (ConnectivityManager) context.getApplicationContext().getSystemService("connectivity");
if (connectivityManager != null && (allNetworkInfo = connectivityManager.getAllNetworkInfo()) != null) {
for (int i2 = 0; i2 < allNetworkInfo.length; i2++) {
if (allNetworkInfo[i2].getTypeName().equalsIgnoreCase("WIFI") && allNetworkInfo[i2].isConnected()) {
return true;
}
}
}
return false;
}
public static String f(Context context) {
TelephonyManager telephonyManager;
if (g != null) {
return g;
}
try {
if (!t.a(context, "android.permission.READ_PHONE_STATE")) {
k.f("Could not get permission of android.permission.READ_PHONE_STATE");
} else if (h(context) && (telephonyManager = (TelephonyManager) context.getSystemService("phone")) != null) {
g = telephonyManager.getSimOperator();
}
} catch (Throwable th) {
k.b(th);
}
return g;
}
public static String g(Context context) {
if (c(h)) {
return h;
}
try {
String str = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
h = str;
if (str == null) {
return BuildConfig.FLAVOR;
}
} catch (Throwable th) {
k.b(th);
}
return h;
}
private static synchronized Random g() {
Random random;
synchronized (n.class) {
if (e == null) {
e = new Random();
}
random = e;
}
return random;
}
private static long h() {
if (q > 0) {
return q;
}
long j2 = 1;
try {
BufferedReader bufferedReader = new BufferedReader(new FileReader("/proc/meminfo"), 8192);
j2 = Integer.valueOf(bufferedReader.readLine().split("\\s+")[1]).intValue() * 1024;
bufferedReader.close();
} catch (Exception unused) {
}
q = j2;
return j2;
}
public static boolean h(Context context) {
return context.getPackageManager().checkPermission("android.permission.READ_PHONE_STATE", context.getPackageName()) == 0;
}
public static String i(Context context) {
String str = BuildConfig.FLAVOR;
try {
if (t.a(context, "android.permission.INTERNET") && t.a(context, "android.permission.ACCESS_NETWORK_STATE")) {
NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
if (activeNetworkInfo != null && activeNetworkInfo.isConnected()) {
String typeName = activeNetworkInfo.getTypeName();
String extraInfo = activeNetworkInfo.getExtraInfo();
if (typeName != null) {
if (typeName.equalsIgnoreCase("WIFI")) {
return "WIFI";
}
if (typeName.equalsIgnoreCase("MOBILE")) {
return extraInfo != null ? extraInfo : "MOBILE";
} else if (extraInfo != null) {
return extraInfo;
} else {
str = typeName;
}
}
}
} else {
k.f("can not get the permission of android.permission.ACCESS_WIFI_STATE");
}
} catch (Throwable th) {
k.b(th);
}
return str;
}
public static Integer j(Context context) {
try {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
if (telephonyManager != null) {
return Integer.valueOf(telephonyManager.getNetworkType());
}
return null;
} catch (Throwable unused) {
return null;
}
}
public static String k(Context context) {
String str;
if (c(i)) {
return i;
}
try {
str = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
i = str;
} catch (Throwable th) {
k.b(th);
}
if (str != null) {
if (i.length() == 0) {
return "unknown";
}
return i;
}
return "unknown";
}
public static int l(Context context) {
if (j != -1) {
return j;
}
try {
if (r.a()) {
j = 1;
}
} catch (Throwable th) {
k.b(th);
}
j = 0;
return 0;
}
public static String m(Context context) {
String path;
if (c(l)) {
return l;
}
try {
} catch (Throwable th) {
k.b(th);
}
if (!t.a(context, "android.permission.WRITE_EXTERNAL_STORAGE")) {
k.c("can not get the permission of android.permission.WRITE_EXTERNAL_STORAGE");
return null;
}
String externalStorageState = Environment.getExternalStorageState();
if (externalStorageState != null && externalStorageState.equals("mounted") && (path = Environment.getExternalStorageDirectory().getPath()) != null) {
StatFs statFs = new StatFs(path);
String str = String.valueOf((statFs.getAvailableBlocks() * statFs.getBlockSize()) / 1000000) + "/" + String.valueOf((statFs.getBlockCount() * statFs.getBlockSize()) / 1000000);
l = str;
return str;
}
return null;
}
public static String n(Context context) {
if (m != null) {
return m;
}
int myPid = Process.myPid();
Iterator<ActivityManager.RunningAppProcessInfo> it = ((ActivityManager) context.getSystemService("activity")).getRunningAppProcesses().iterator();
while (true) {
if (!it.hasNext()) {
break;
}
ActivityManager.RunningAppProcessInfo next = it.next();
if (next.pid == myPid) {
m = next.processName;
break;
}
}
return m;
}
public static String o(Context context) {
return a(context, a.b);
}
public static synchronized Integer p(Context context) {
Integer valueOf;
synchronized (n.class) {
if (n <= 0) {
n = s.a(context, "MTA_EVENT_INDEX", 0);
s.b(context, "MTA_EVENT_INDEX", n + 1000);
} else if (n % 1000 == 0) {
int i2 = n + 1000;
if (n >= 2147383647) {
i2 = 0;
}
s.b(context, "MTA_EVENT_INDEX", i2);
}
int i3 = n + 1;
n = i3;
valueOf = Integer.valueOf(i3);
}
return valueOf;
}
public static String q(Context context) {
try {
return String.valueOf(z(context) / 1000000) + "/" + String.valueOf(h() / 1000000);
} catch (Throwable th) {
th.printStackTrace();
return null;
}
}
public static JSONObject r(Context context) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("n", o.a());
String d2 = o.d();
if (d2 != null && d2.length() > 0) {
jSONObject.put("na", d2);
}
int b2 = o.b();
if (b2 > 0) {
jSONObject.put("fx", b2 / 1000000);
}
int c2 = o.c();
if (c2 > 0) {
jSONObject.put("fn", c2 / 1000000);
}
} catch (Throwable th) {
Log.w("MtaSDK", "get cpu error", th);
}
return jSONObject;
}
public static String s(Context context) {
List<Sensor> sensorList;
if (c(r)) {
return r;
}
try {
SensorManager sensorManager = (SensorManager) context.getSystemService("sensor");
if (sensorManager != null && (sensorList = sensorManager.getSensorList(-1)) != null) {
StringBuilder sb = new StringBuilder(sensorList.size() * 10);
for (int i2 = 0; i2 < sensorList.size(); i2++) {
sb.append(sensorList.get(i2).getType());
if (i2 != sensorList.size() - 1) {
sb.append(",");
}
}
r = sb.toString();
}
} catch (Throwable th) {
k.b(th);
}
return r;
}
public static synchronized int t(Context context) {
synchronized (n.class) {
if (u != -1) {
return u;
}
u(context);
return u;
}
}
public static void u(Context context) {
int a2 = s.a(context, t, 1);
u = a2;
if (a2 == 1) {
s.b(context, t, 0);
}
}
public static boolean v(Context context) {
if (v < 0) {
v = s.a(context, "mta.qq.com.checktime", 0L);
}
return Math.abs(System.currentTimeMillis() - v) > 86400000;
}
public static void w(Context context) {
v = System.currentTimeMillis();
s.b(context, "mta.qq.com.checktime", v);
}
public static int x(Context context) {
return s.a(context, "mta.qq.com.difftime", 0);
}
public static String y(Context context) {
if (context == null) {
return null;
}
Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory("android.intent.category.HOME");
ResolveInfo resolveActivity = context.getPackageManager().resolveActivity(intent, 0);
if (resolveActivity.activityInfo == null || resolveActivity.activityInfo.packageName.equals("android")) {
return null;
}
return resolveActivity.activityInfo.packageName;
}
private static long z(Context context) {
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
((ActivityManager) context.getSystemService("activity")).getMemoryInfo(memoryInfo);
return memoryInfo.availMem;
}
}