Aqara Home v2.4.1版本的 MD5 值为:529779ac2bc0131db52a1fc3098d2b35
以下内容为反编译后的 l.java 源代码,内容仅作参考
package com.tencent.wxop.stat.common;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
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 com.amazonaws.auth.AWS4Signer;
import com.tencent.wxop.stat.StatConfig;
import com.tencent.wxop.stat.StatSpecifyReportedInfo;
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.json.JSONObject;
import t.b.u1;
public class l {
public static String a = null;
public static String b = null;
public static String c = null;
public static String d = null;
public static Random f13966e = null;
public static DisplayMetrics f13967f = null;
public static String f13968g = null;
public static String f13969h = "";
public static String f13970i = "";
public static int f13971j = -1;
public static StatLogger f13972k = null;
public static String f13973l = null;
public static String f13974m = null;
public static volatile int f13975n = -1;
public static String f13976o = null;
public static String f13977p = null;
public static long f13978q = -1;
public static String f13979r = "";
public static o f13980s = null;
public static String f13981t = "__MTA_FIRST_ACTIVATE__";
public static int f13982u = -1;
public static long f13983v = -1;
public static int f13984w = 0;
public static String f13985x = "";
public static String A(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);
ActivityInfo activityInfo = resolveActivity.activityInfo;
if (activityInfo == null || activityInfo.packageName.equals("android")) {
return null;
}
return resolveActivity.activityInfo.packageName;
}
public static long B(Context context) {
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
((ActivityManager) context.getSystemService("activity")).getMemoryInfo(memoryInfo);
return memoryInfo.availMem;
}
public static int a() {
return g().nextInt(Integer.MAX_VALUE);
}
public static int a(Context context, boolean z2) {
if (z2) {
f13984w = y(context);
}
return f13984w;
}
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(AWS4Signer.f2087l).format(calendar.getTime());
}
public static String a(long j2) {
return new SimpleDateFormat(AWS4Signer.f2087l).format(new Date(j2));
}
public static String a(Context context, String str) {
if (StatConfig.isEnableConcurrentProcess()) {
if (f13974m == null) {
f13974m = o(context);
}
if (f13974m != null) {
return str + "_" + f13974m;
}
}
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) {
f13972k.e(th);
}
if (context.getPackageManager().checkPermission(k.e.a.r.f.b, 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) {
f13984w = i2;
q.b(context, "mta.qq.com.difftime", i2);
}
public static boolean a(StatSpecifyReportedInfo statSpecifyReportedInfo) {
if (statSpecifyReportedInfo == null) {
return false;
}
return c(statSpecifyReportedInfo.getAppKey());
}
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 StatLogger b() {
StatLogger statLogger;
synchronized (l.class) {
if (f13972k == null) {
StatLogger statLogger2 = new StatLogger(StatConstants.LOG_TAG);
f13972k = statLogger2;
statLogger2.setDebugEnable(false);
}
statLogger = f13972k;
}
return statLogger;
}
public static synchronized String b(Context context) {
synchronized (l.class) {
if (a != null && a.trim().length() != 0) {
return a;
}
String a2 = r.a(context);
a = a2;
if (a2 == null || a2.trim().length() == 0) {
a = Integer.toString(g().nextInt(Integer.MAX_VALUE));
}
return a;
}
}
public static long c() {
try {
Calendar calendar = Calendar.getInstance();
calendar.set(11, 0);
calendar.set(12, 0);
calendar.set(13, 0);
calendar.set(14, 0);
return calendar.getTimeInMillis() + 86400000;
} catch (Throwable th) {
f13972k.e(th);
return System.currentTimeMillis() + 86400000;
}
}
public static synchronized String c(Context context) {
String str;
synchronized (l.class) {
if (c == null || c.trim().length() == 0) {
c = r.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 (f13967f == null) {
f13967f = new DisplayMetrics();
((WindowManager) context.getApplicationContext().getSystemService("window")).getDefaultDisplay().getMetrics(f13967f);
}
return f13967f;
}
public static String d() {
if (c(f13977p)) {
return f13977p;
}
long e2 = e() / u1.f32650e;
StatFs statFs = new StatFs(Environment.getDataDirectory().getPath());
long blockSize = (statFs.getBlockSize() * statFs.getAvailableBlocks()) / u1.f32650e;
String str = String.valueOf(blockSize) + "/" + String.valueOf(e2);
f13977p = 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) {
f13972k.e(th);
}
if (!r.a(context, "android.permission.ACCESS_WIFI_STATE")) {
f13972k.warn("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) {
if (context == null) {
return null;
}
return context.getClass().getName();
}
public static String g(Context context) {
TelephonyManager telephonyManager;
String str = f13968g;
if (str != null) {
return str;
}
try {
if (!r.a(context, "android.permission.READ_PHONE_STATE")) {
f13972k.e("Could not get permission of android.permission.READ_PHONE_STATE");
} else if (i(context) && (telephonyManager = (TelephonyManager) context.getSystemService("phone")) != null) {
f13968g = telephonyManager.getSimOperator();
}
} catch (Throwable th) {
f13972k.e(th);
}
return f13968g;
}
public static synchronized Random g() {
Random random;
synchronized (l.class) {
if (f13966e == null) {
f13966e = new Random();
}
random = f13966e;
}
return random;
}
public static long h() {
long j2 = f13978q;
if (j2 > 0) {
return j2;
}
long j3 = 1;
try {
BufferedReader bufferedReader = new BufferedReader(new FileReader("/proc/meminfo"), 8192);
j3 = Integer.valueOf(bufferedReader.readLine().split("\\s+")[1]).intValue() * 1024;
bufferedReader.close();
} catch (Exception unused) {
}
f13978q = j3;
return j3;
}
public static String h(Context context) {
if (c(f13969h)) {
return f13969h;
}
try {
String str = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
f13969h = str;
if (str == null) {
return "";
}
} catch (Throwable th) {
f13972k.e(th);
}
return f13969h;
}
public static boolean i(Context context) {
return context.getPackageManager().checkPermission("android.permission.READ_PHONE_STATE", context.getPackageName()) == 0;
}
public static String j(Context context) {
try {
if (r.a(context, "android.permission.INTERNET") && r.a(context, k.e.a.r.f.b)) {
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")) {
if (extraInfo == null) {
return "MOBILE";
}
} else if (extraInfo == null) {
return typeName;
}
return extraInfo;
}
}
} else {
f13972k.e("can not get the permission of android.permission.ACCESS_WIFI_STATE");
}
} catch (Throwable th) {
f13972k.e(th);
}
return "";
}
public static Integer k(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 l(Context context) {
String str;
if (c(f13970i)) {
return f13970i;
}
try {
str = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
f13970i = str;
} catch (Throwable th) {
f13972k.e(th);
}
if (str != null) {
if (str.length() == 0) {
return "unknown";
}
return f13970i;
}
return "unknown";
}
public static int m(Context context) {
int i2 = f13971j;
if (i2 != -1) {
return i2;
}
try {
if (p.a()) {
f13971j = 1;
}
} catch (Throwable th) {
f13972k.e(th);
}
f13971j = 0;
return 0;
}
public static String n(Context context) {
String path;
if (c(f13973l)) {
return f13973l;
}
try {
} catch (Throwable th) {
f13972k.e(th);
}
if (!r.a(context, "android.permission.WRITE_EXTERNAL_STORAGE")) {
f13972k.warn("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);
long blockCount = (statFs.getBlockCount() * statFs.getBlockSize()) / u1.f32650e;
long availableBlocks = (statFs.getAvailableBlocks() * statFs.getBlockSize()) / u1.f32650e;
String str = String.valueOf(availableBlocks) + "/" + String.valueOf(blockCount);
f13973l = str;
return str;
}
return null;
}
public static String o(Context context) {
if (f13974m != null) {
return f13974m;
}
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) {
f13974m = next.processName;
break;
}
}
return f13974m;
}
public static String p(Context context) {
return a(context, StatConstants.DATABASE_NAME);
}
public static synchronized Integer q(Context context) {
Integer valueOf;
synchronized (l.class) {
int i2 = 0;
if (f13975n <= 0) {
f13975n = q.a(context, "MTA_EVENT_INDEX", 0);
q.b(context, "MTA_EVENT_INDEX", f13975n + 1000);
} else if (f13975n % 1000 == 0) {
int i3 = f13975n + 1000;
if (f13975n < 2147383647) {
i2 = i3;
}
q.b(context, "MTA_EVENT_INDEX", i2);
}
int i4 = f13975n + 1;
f13975n = i4;
valueOf = Integer.valueOf(i4);
}
return valueOf;
}
public static String r(Context context) {
try {
long B = B(context) / u1.f32650e;
long h2 = h() / u1.f32650e;
return String.valueOf(B) + "/" + String.valueOf(h2);
} catch (Throwable th) {
th.printStackTrace();
return null;
}
}
public static JSONObject s(Context context) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("n", m.a());
String d2 = m.d();
if (d2 != null && d2.length() > 0) {
jSONObject.put("na", d2);
}
int b2 = m.b();
if (b2 > 0) {
jSONObject.put("fx", b2 / 1000000);
}
int c2 = m.c();
if (c2 > 0) {
jSONObject.put("fn", c2 / 1000000);
}
} catch (Throwable th) {
Log.w(StatConstants.LOG_TAG, "get cpu error", th);
}
return jSONObject;
}
public static String t(Context context) {
List<Sensor> sensorList;
if (c(f13979r)) {
return f13979r;
}
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(",");
}
}
f13979r = sb.toString();
}
} catch (Throwable th) {
f13972k.e(th);
}
return f13979r;
}
public static synchronized int u(Context context) {
synchronized (l.class) {
if (f13982u != -1) {
return f13982u;
}
v(context);
return f13982u;
}
}
public static void v(Context context) {
int a2 = q.a(context, f13981t, 1);
f13982u = a2;
if (a2 == 1) {
q.b(context, f13981t, 0);
}
}
public static boolean w(Context context) {
if (f13983v < 0) {
f13983v = q.a(context, "mta.qq.com.checktime", 0L);
}
return Math.abs(System.currentTimeMillis() - f13983v) > 86400000;
}
public static void x(Context context) {
long currentTimeMillis = System.currentTimeMillis();
f13983v = currentTimeMillis;
q.b(context, "mta.qq.com.checktime", currentTimeMillis);
}
public static int y(Context context) {
return q.a(context, "mta.qq.com.difftime", 0);
}
public static boolean z(Context context) {
ActivityManager activityManager;
if (context == null || (activityManager = (ActivityManager) context.getSystemService("activity")) == null) {
return false;
}
String packageName = context.getPackageName();
Iterator<ActivityManager.RunningAppProcessInfo> it = activityManager.getRunningAppProcesses().iterator();
while (true) {
if (!it.hasNext()) {
break;
}
ActivityManager.RunningAppProcessInfo next = it.next();
if (next.processName.startsWith(packageName)) {
if (next.importance == 400) {
return true;
}
}
}
return false;
}
}