// Decompiled by Jadx (from NP Manager)
//
package com.test.load;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.SharedPreferences.Editor;
import android.net.wifi.WifiManager;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.test.load.util.MD5Digest;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.Random;
public class LogUtils {
private static int A = 1;
private static boolean B;
private static Date C = null;
private static boolean D;
private static boolean E;
private static boolean F;
private static String G;
private static String H = "E6B3A8E5868CE7A081E5A4B1E69588EFBC8CE58FAFE883BDE8B685E8BF87E69C89E69588E69C9FEFBC8CE8AFB7E9878DE696B0E6B3A8E5868C";
private static String I = "E69CBAE599A8E7A0813D";
private static String J = "E69CBAE599A8E7A081E5B7B2E5A48DE588B6E588B0E589AAE8B4B4E69DBF";
private static String K = "E8BE93E585A5E6B3A8E5868CE7A081";
private static String L = "E6B3A8E5868CE7A081E6ADA3E7A1AEEFBC8CE6ACA2E8BF8EE4BDBFE794A8E69CACE8BDAFE4BBB6";
private static String M = "E6B3A8E5868CE7A081E99499E8AFAFEFBC8CE8AFB7E8BE93E585A5E6ADA3E7A1AEE79A84E6B3A8E5868CE7A081";
private static String N = "E58F96E6B688";
private static String O = "E69C89E69588E69C9F3A";
private static String P = "E8AF95E794A8";
public static int PASSWD_LEN = 10;
public static String PASSWD_REGCODE;
private static String Q = "E782B9E587BBE69CBAE599A8E7A081E58FAFE5A48DE588B6E588B0E589AAE8B4B4E69DBF";
private static String R = "E4B8BBE9A1B5";
static Random b = new Random ();
static TextView c = null;
static EditText d = null;
static TextView e = null;
private static String f = "logutil";
private static boolean g = true;
private static String h = "1234567812345678";
private static int i = 1;
private static String j = "";
private static boolean k;
private static boolean l;
private static boolean m;
private static boolean n;
private static String o;
private static boolean p;
public static int periodTime;
private static boolean q;
private static String r;
private static boolean s;
private static boolean t = true;
public static int trialTime;
private static String u = "";
private static boolean v = true;
private static String w = "bm.aac";
private static String x = "settings";
private static final String[] y = new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"};
private static final char[] z = new char[]{ int a = -1903220365;
/* renamed from: com.test.load.LogUtils$1 */
class AnonymousClass1 implements Runnable {
private final /* synthetic */ Activity val$ctx;
public void run () {
this.val$ctx.startActivity (new Intent ("android.intent.action.VIEW", SimpleDateFormat.parse (LogUtils.LOAD_URL)));
}
AnonymousClass1 (Activity activity) {
this.val$ctx = activity;
}
}
/* renamed from: com.test.load.LogUtils$3 */
class AnonymousClass3 implements OnClickListener {
private final /* synthetic */ Activity val$ctx;
private final /* synthetic */ EditText val$etPasswd;
private final /* synthetic */ Handler val$handler;
public void onClick (DialogInterface dialogInterface, int i) {
String passwd = this.val$etPasswd.getText ().toString ().trim ();
Field declaredField;
if (passwd == null || passwd.equals ("")) {
Toast.makeText (this.val$ctx, "请输入密码", 0).show ();
try {
declaredField = dialogInterface.getClass ().getSuperclass ().getDeclaredField ("mShowing");
declaredField.setAccessible (true);
declaredField.set (dialogInterface, Boolean.valueOf (false));
} catch (Exception e) {
}
} else if (LogUtils.access$1 (this.val$ctx, passwd)) {
LogUtils.access$2 (this.val$ctx, "passwd", passwd);
Toast.makeText (this.val$ctx, "密码正确", 0).show ();
dialogInterface.dismiss ();
if (this.val$handler != null) {
Message message = new Message ();
message.what = 1;
this.val$handler.sendMessage (message);
}
try {
declaredField = dialogInterface.getClass ().getSuperclass ().getDeclaredField ("mShowing");
declaredField.setAccessible (true);
declaredField.set (dialogInterface, Boolean.valueOf (true));
} catch (Exception e2) {
}
} else {
Toast.makeText (this.val$ctx, "密码错误", 0).show ();
try {
declaredField = dialogInterface.getClass ().getSuperclass ().getDeclaredField ("mShowing");
declaredField.setAccessible (true);
declaredField.set (dialogInterface, Boolean.valueOf (false));
} catch (Exception e3) {
}
}
}
AnonymousClass3 (EditText editText, Activity activity, Handler handler) {
this.val$etPasswd = editText;
this.val$ctx = activity;
this.val$handler = handler;
}
}
/* renamed from: com.test.load.LogUtils$4 */
class AnonymousClass4 implements OnClickListener {
private final /* synthetic */ Activity val$ctx;
AnonymousClass4 (Activity activity) {
this.val$ctx = activity;
}
public void onClick (DialogInterface dialogInterface, int i) {
this.val$ctx.finish ();
}
}
static {
PASSWD_REGCODE = "PASSWD_REGCODE";
trialTime = 7200;
k = true;
l = false;
m = true;
periodTime = 60000;
n = false;
o = "";
p = true;
q = true;
r = "v1";
s = true;
trialTime = 120;
PASSWD_REGCODE = "bgc_v1";
r = "v1";
B = true;
D = false;
E = true;
F = false;
n = false;
G = "";
k = true;
l = true;
m = true;
periodTime = 60000;
o = "com.test.load.TestActivity";
p = true;
q = true;
s = true;
B = false;
D = false;
E = true;
F = true;
G = "";
}
private static int a (Context context, String str, int i) {
Properties properties = new Properties ();
properties.load (new InputStreamReader (context.getAssets ().open (w)));
try {
return Integer.parseInt (properties.getProperty (str, String.valueOf (i)));
} catch (Exception e) {
return i;
}
}
private static String a (String str, String str2, String str3) {
try {
Properties properties = new Properties ();
properties.load (new FileInputStream (str));
return properties.getProperty (str2, str3);
} catch (Exception e) {
return "";
}
}
private static void a (Activity activity, final Handler handler) {
String f = f ( (Context) activity);
View inflate = ( (LayoutInflater) activity.getSystemService ("layout_inflater")).inflate (activity.getResources ().getIdentifier ("load_dialogview", "layout", activity.getPackageName ()), null);
c = (TextView) inflate.findViewById (activity.getResources ().getIdentifier ("load_tv_deviceid", "id", activity.getPackageName ()));
d = (EditText) inflate.findViewById (activity.getResources ().getIdentifier ("load_et_passwd", "id", activity.getPackageName ()));
e = (Button) inflate.findViewById (activity.getResources ().getIdentifier ("load_btn_loadurl", "id", activity.getPackageName ()));
( (TextView) inflate.findViewById (activity.getResources ().getIdentifier ("load_tv_copydeviceid", "id", activity.getPackageName ()))).setText (new String (g (Q)));
c.setText (new String (g (I)) + f);
c.setOnClickListener (new h (activity, f));
if (t) {
e.setVisibility (8);
} else {
e.setVisibility (8);
}
e.setText (new String (g (R)));
e.setOnClickListener (new i (activity));
Builder onKeyListener = new Builder (activity).setCancelable (false).setTitle (G).setView (inflate).setPositiveButton (new String (g (K)), new l (activity, handler)).setNegativeButton (new String (g (N)), new k (activity)).setOnKeyListener (new j (activity));
if (!TextUtils.isEmpty (j)) {
Date parse;
SimpleDateFormat fileInputStream = new FileInputStream ("yyyyMMddHHmmss");
Date date = new Date ();
try {
parse = fileInputStream.parse (j);
} catch (Exception e) {
parse = new Date ();
}
SimpleDateFormat fileInputStream2 = new FileInputStream ("yyyy-MM-dd HH:mm:ss");
d.setHint (String.format ("%s%s", new Object[]{new String (g (O)), fileInputStream2.format (parse)}));
}
if (i == 2) {
onKeyListener.setNeutralButton (new String (g (P)), new OnClickListener () {
public void onClick (DialogInterface dialogInterface, int i) {
dialogInterface.dismiss ();
if (handler != null) {
Message message = new Message ();
message.what = 1;
handler.sendMessage (message);
}
try {
Field declaredField = dialogInterface.getClass ().getSuperclass ().getDeclaredField ("mShowing");
declaredField.setAccessible (true);
declaredField.set (dialogInterface, Boolean.valueOf (true));
} catch (Exception e) {
}
}
});
}
onKeyListener.show ();
}
private static boolean a (Context context, String str, boolean z) {
Properties properties = new Properties ();
properties.load (new InputStreamReader (context.getAssets ().open (w)));
try {
return Boolean.parseBoolean (properties.getProperty (str, String.valueOf (z)));
} catch (Exception e) {
return z;
}
}
public static void appStart (Activity activity) {
try {
if (m) {
activity.startService (new Intent (activity, LoadService.class));
}
activity.startActivity (new Intent (activity, Class.forName (o)));
activity.finish ();
} catch (Exception e) {
Toast.makeText (activity, e.getMessage (), 0).show ();
}
}
private static String b (Context context, String str, String str2) {
Properties properties = new Properties ();
properties.load (new InputStreamReader (context.getAssets ().open (w)));
return properties.getProperty (str, str2);
}
private static void b (Context context) {
Intent fileInputStream = new FileInputStream ("android.intent.action.MAIN");
fileInputStream.addCategory ("android.intent.category.HOME");
fileInputStream.setFlags (268435456);
context.startActivity (fileInputStream);
Process.killProcess (Process.myPid ());
}
private static void b (String str) {
if (g) {
SimpleDateFormat fileInputStream = new FileInputStream ("yyyy-MM-dd HH:mm:ss");
Log.d (f, String.format ("[%s] %s", new Object[]{fileInputStream.format (new Date ()), str}));
}
}
private static boolean b (Context context, String str) {
StringBuilder stringBuilder;
PASSWD_REGCODE = "PASSWD_REGCODE_weixin77891_v1";
String f = f (context);
String str2 = "";
Date date = new Date ();
date = null;
if (TextUtils.isEmpty (str) && trialTime != 0) {
try {
date = d (context);
Calendar instance = Calendar.getInstance ();
instance.setTime (date);
instance.add (13, trialTime);
str2 = new FileInputStream ("yyyyMMddHHmmss").format (instance.getTime ());
Log.v ("msg", str2);
stringBuilder = new StringBuilder ();
StringBuilder stringBuilder2 = new StringBuilder ();
String str3 = PASSWD_REGCODE;
Log.v (str3, str3);
str = f (stringBuilder.append (d (stringBuilder2.append (str3).append (f).append (str2).toString ()).toLowerCase ().substring (0, PASSWD_LEN)).append (str2).toString ());
} catch (Exception e) {
b (e.getMessage ());
i = 4;
j = str2;
try {
Toast.makeText (context, "获取系统时间错误,可能未联网,请打开网络:" + e.getMessage (), 0).show ();
} catch (Exception e2) {
}
return false;
}
}
if (str.length () > PASSWD_LEN) {
str2 = str.substring (PASSWD_LEN);
try {
Date parse = new FileInputStream ("yyyyMMddHHmmss").parse (str2);
if (date == null) {
date = d (context);
}
if (date.after (parse)) {
i = 3;
j = str2;
return false;
}
} catch (Exception e3) {
b (e3.getMessage ());
i = 4;
j = str2;
try {
Toast.makeText (context, "获取系统时间错误,可能未联网,请打开网络:" + e3.getMessage (), 0).show ();
} catch (Exception e4) {
}
return false;
}
}
StringBuilder stringBuilder3 = new StringBuilder ();
stringBuilder = new StringBuilder ();
String str4 = PASSWD_REGCODE;
String str5 = "msg";
Log.v (str5, str4);
stringBuilder = stringBuilder.append (str4);
Log.v (str5, f);
Log.v (str5, str2);
f = stringBuilder.append (f).append (str2).toString ();
Log.v (str5, f);
String f2 = f (stringBuilder3.append (d (f).toLowerCase ().substring (0, PASSWD_LEN)).append (str2).toString ());
if (f2.toLowerCase ().equals (str.toLowerCase ())) {
d (context, "passwd", f2);
if (TextUtils.isEmpty (str2)) {
i = 0;
} else {
i = 2;
}
j = str2;
try {
date = new FileInputStream ("yyyyMMddHHmmss").parse (j);
Toast.makeText (context, "使用有效期为:" + new FileInputStream ("yyyy-MM-dd HH:mm:ss").format (date), 0).show ();
} catch (Exception e5) {
}
return true;
}
i = 1;
j = str2;
return false;
}
private static String c (Context context, String str, String str2) {
try {
if (B) {
return context.getSharedPreferences (x, 0).getString (str, str2);
}
String str3;
if (Environment.getExternalStorageState ().equals ("mounted")) {
str3 = Environment.getExternalStorageDirectory ().getCanonicalPath () + "/.Android/" + context.getPackageName () + "/";
} else {
str3 = "/data/local/.Android/" + context.getPackageName () + "/";
}
return a (str3 + x, str, str2);
} catch (Exception e) {
b (e.getMessage ());
return str2;
}
}
private static String c (String str) {
try {
byte[] digest = MessageDigest.getInstance ("MD5").digest (str.getBytes ("UTF-8"));
StringBuilder stringBuilder = new StringBuilder (digest.length * 2);
for (byte b : digest) {
if ( (b & 255) < 16) {
stringBuilder.append ("0");
}
stringBuilder.append (Integer.toHexString (b & 255));
}
return stringBuilder.toString ();
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException ("Huh, MD5 should be supported?", e);
} catch (UnsupportedEncodingException e2) {
throw new RuntimeException ("Huh, UTF-8 should be supported?", e2);
}
}
private static void c (Context context) {
trialTime = a (context, "trialTime", trialTime);
B = a (context, "useAppDir", B);
D = a (context, "useMac", D);
E = a (context, "useImei", E);
F = a (context, "useAndroidId", F);
n = a (context, "useRandDeviceId", n);
G = b (context, "title", G);
k = a (context, "useValidTime", k);
l = a (context, "isShowRegActivity", l);
m = a (context, "isLoadService", m);
periodTime = a (context, "periodTime", periodTime);
o = b (context, "mainActivity", o);
p = a (context, "isDebug", p);
q = a (context, "useNetTime", q);
r = b (context, "rver", r);
s = a (context, "isShowValidTime", s);
String b = b (context, "pr", PASSWD_REGCODE);
PASSWD_REGCODE = b;
if (TextUtils.isEmpty (b)) {
PASSWD_REGCODE = "PASSWD_REGCODE_" + context.getPackageName () + "_" + r;
} else {
PASSWD_REGCODE = "PASSWD_REGCODE_" + PASSWD_REGCODE;
}
boolean a = a (context, "isLoadUrl", t);
t = a;
if (a) {
u = b (context, "loadUrlStr", u);
}
v = a (context, "isAlg", v);
}
private static String d (String str) {
if (!v) {
return c (str);
}
byte[] bArr = new byte[16];
try {
byte[] bytes = str.getBytes ();
MD5Digest mD5Digest = new MD5Digest ();
mD5Digest.reset ();
mD5Digest.update (bytes, 0, bytes.length);
mD5Digest.doFinal (bArr, 0);
StringBuilder stringBuilder = new StringBuilder (bArr.length * 2);
for (byte b : bArr) {
if ( (b & 255) < 16) {
stringBuilder.append ("0");
}
stringBuilder.append (Integer.toHexString (b & 255));
}
return stringBuilder.toString ();
} catch (Exception e) {
return "";
}
}
private static Date d (Context context) {
if (q) {
Thread thread = new Thread (new g (context));
thread.start ();
thread.join ();
if (C == null) {
C = e (context);
}
} else {
C = e (context);
}
return C;
}
private static void d (Context context, String str, String str2) {
try {
if (B) {
Editor edit = context.getSharedPreferences (x, 0).edit ();
edit.putString (str, str2);
edit.commit ();
return;
}
String str3;
if (Environment.getExternalStorageState ().equals ("mounted")) {
str3 = Environment.getExternalStorageDirectory ().getCanonicalPath () + "/.Android/" + context.getPackageName () + "/";
} else {
str3 = "/data/local/.Android/" + context.getPackageName () + "/";
}
new FileInputStream (str3).mkdirs ();
str3 = str3 + x;
try {
Properties properties = new Properties ();
try {
properties.load (new FileInputStream (str3));
} catch (Exception e) {
}
properties.setProperty (str, str2);
properties.store (new FileInputStream (str3), "");
} catch (Exception e2) {
}
} catch (Exception e3) {
b (e3.getMessage ());
}
}
private static Date e (Context context) {
String c = c (context, "lastTime", "1900-01-01 00:00:00");
SimpleDateFormat fileInputStream = new FileInputStream ("yyyyMMddHHmmss");
Date parse = fileInputStream.parse (c);
Date date = new Date ();
if (date.before (parse)) {
throw new FileInputStream ("系统时间有误");
}
d (context, "lastTime", fileInputStream.format (date));
return date;
}
private static void e (String str) {
if (p) {
SimpleDateFormat fileInputStream = new FileInputStream ("yyyy-MM-dd HH:mm:ss");
Log.d (f, String.format ("[%s]%s", new Object[]{fileInputStream.format (new Date ()), str}));
}
}
private static String f (Context context) {
String c;
if (n) {
c = c (context, "deviceId", "");
if (!TextUtils.isEmpty (c)) {
return c;
}
c = "";
int i = 0;
while (i < 10) {
i++;
c = c + (Math.abs (b.nextInt ()) % 10);
}
d (context, "deviceId", c);
return c;
}
String macAddress;
c = "";
String str = "";
String str2 = "";
if (D) {
try {
macAddress = ( (WifiManager) context.getSystemService ("wifi")).getConnectionInfo ().getMacAddress ();
} catch (Exception e) {
macAddress = "mac";
}
} else {
macAddress = c;
}
if (E) {
try {
c = ( (TelephonyManager) context.getSystemService ("phone")).getDeviceId ();
} catch (Exception e2) {
c = "imei";
}
} else {
c = str;
}
if (F) {
try {
str = Secure.getString (context.getContentResolver (), "android_id");
} catch (Exception e3) {
str = "androidId";
}
} else {
str = str2;
}
c = macAddress + c + str;
if (c == "") {
c = "gqzb1.0";
}
return d (c).toLowerCase ().substring (0, PASSWD_LEN);
}
private static String f (String str) {
String toLowerCase = str.replace (":", "").toLowerCase ();
for (int i = 0; i <= 5; i++) {
toLowerCase = toLowerCase.replace ( (char) (i + 97), (char) (i + 48));
}
return toLowerCase;
}
private static byte[] g (String str) {
if (str == null || str.equals ("")) {
return null;
}
String toUpperCase = str.toUpperCase ();
int length = toUpperCase.length () / 2;
char[] toCharArray = toUpperCase.toCharArray ();
byte[] bArr = new byte[length];
for (int i = 0; i < length; i++) {
int i2 = i * 2;
bArr[i] = (byte) ( ( (byte) "0123456789ABCDEF".indexOf (toCharArray[i2 + 1])) | ( ( (byte) "0123456789ABCDEF".indexOf (toCharArray[i2])) << 4));
}
return bArr;
}
public static void loadUrl (Activity activity, String str) {
activity.runOnUiThread (new f (str, activity));
}
public static boolean showRegActivity (Context context) {
try {
c (context);
} catch (Exception e) {
e.printStackTrace ();
}
if (b (context, c (context, "passwd", ""))) {
e ("showRegActivity passwdStatus=" + i);
return i == 0 ? true : true;
} else {
if (l) {
Intent intent = new Intent ();
intent.setFlags (335544320);
intent.setClass (context, LoadActivity.class);
context.startActivity (intent);
} else {
try {
new Handler (Looper.getMainLooper ()).post (new e (context, new String (g (H))));
} catch (Exception e2) {
e2.printStackTrace ();
}
}
e ("showRegActivity passwdStatus=" + i);
e ("showRegActivity ret=false");
return false;
}
}
public static boolean showRegDialog (Activity activity, Handler handler) {
try {
c ( (Context) activity);
} catch (Exception e) {
e.printStackTrace ();
}
if (m) {
boolean z;
String name = LoadService.class.getName ();
List runningServices = ( (ActivityManager) activity.getSystemService ("activity")).getRunningServices (30);
if (runningServices.size () <= 0) {
z = false;
} else {
for (int i = 0; i < runningServices.size (); i++) {
if ( ( (RunningServiceInfo) runningServices.get (i)).service.getClassName ().equals (name)) {
z = true;
break;
}
}
z = false;
}
if (z) {
activity.stopService (new Intent (activity, LoadService.class));
}
}
String str = "";
String c = c (activity, "passwd", str);
boolean equals = "v8".equals (c (activity, "vision", str));
if (! (b (activity, c))) {
a (activity, handler);
} else if (i == 0 || !s) {
return true;
} else {
a (activity, handler);
}
return false;
}
public static void test () {
}
public static void test (Context context) {
context.stopService (new Intent (context, LoadService.class));
}
}