package com.baidu.location.e; import android.content.Context; import android.location.Location; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.Build; import android.os.Environment; import android.os.Process; import android.provider.Settings; import android.util.Base64; import com.baidu.location.BDLocation; import com.baidu.location.Jni; import com.baidu.location.c.a; import com.baidu.location.c.b; import com.baidu.location.c.f; import com.baidu.location.c.i; import com.netease.nimlib.sdk.avchat.constant.AVChatControlCommand; import java.io.File; import java.io.FileInputStream; import java.math.BigInteger; import java.net.Inet4Address; import java.net.Inet6Address; import java.net.InetAddress; import java.net.NetworkInterface; import java.security.KeyFactory; import java.security.MessageDigest; import java.security.PublicKey; import java.security.Signature; import java.security.spec.X509EncodedKeySpec; import java.util.Calendar; import java.util.Enumeration; import java.util.Locale; public class k { public static float A = 2.2f; public static float B = 2.3f; public static float C = 3.8f; public static int D = 3; public static int E = 10; public static int F = 2; public static int G = 7; public static int H = 20; public static int I = 70; public static int J = 120; public static float K = 2.0f; public static float L = 10.0f; public static float M = 50.0f; public static float N = 200.0f; public static int O = 16; public static int P = 32; public static float Q = 0.9f; public static int R = 10000; public static float S = 0.5f; public static float T = 0.0f; public static float U = 0.1f; public static int V = 30; public static int W = 100; public static int X = 0; public static int Y = 0; public static int Z = 0; /* renamed from: a reason: collision with root package name */ public static boolean f1461a = false; private static String aA = "http://loc.map.baidu.com/user_err.php"; private static String aB = "http://loc.map.baidu.com/oqur.php"; private static String aC = "https://loc.map.baidu.com/tcu.php"; private static String aD = "http://loc.map.baidu.com/rtbu.php"; private static String aE = "http://loc.map.baidu.com/iofd.php"; private static String aF = "http://loc.map.baidu.com/wloc"; public static int aa = 420000; public static boolean ab = true; public static boolean ac = true; public static int ad = 20; public static int ae = 300; public static int af = 1000; public static int ag = Integer.MAX_VALUE; public static long ah = 900000; public static long ai = 420000; public static long aj = 180000; public static long ak = 0; public static long al = 15; public static long am = 300000; public static int an = 1000; public static int ao = 0; public static int ap = 30000; public static int aq = 30000; public static float ar = 10.0f; public static float as = 6.0f; public static float at = 10.0f; public static int au = 60; public static int av = 70; public static int aw = 6; public static String ax = null; public static boolean ay = false; private static String az = "http://loc.map.baidu.com/sdk.php"; /* renamed from: b reason: collision with root package name */ public static boolean f1462b = false; /* renamed from: c reason: collision with root package name */ public static boolean f1463c = false; /* renamed from: d reason: collision with root package name */ public static int f1464d = 0; /* renamed from: e reason: collision with root package name */ public static String f1465e = "http://loc.map.baidu.com/sdk_ep.php"; /* renamed from: f reason: collision with root package name */ public static String f1466f = "https://loc.map.baidu.com/sdk.php"; /* renamed from: g reason: collision with root package name */ public static String f1467g = "no"; /* renamed from: h reason: collision with root package name */ public static boolean f1468h = false; public static boolean i = false; public static boolean j = false; public static boolean k = false; public static boolean l = false; public static boolean m = false; public static String n = "gcj02"; public static String o = ""; public static boolean p = true; public static int q = 3; public static double r = 0.0d; public static double s = 0.0d; public static double t = 0.0d; public static double u = 0.0d; public static int v = 0; public static byte[] w = null; public static boolean x = false; public static int y = 0; public static float z = 1.1f; public static int a(Context context) { try { return Settings.System.getInt(context.getContentResolver(), "airplane_mode_on", 0); } catch (Exception unused) { return 2; } } /* JADX WARNING: Removed duplicated region for block: B:8:0x0016 A[RETURN] */ /* JADX WARNING: Removed duplicated region for block: B:9:0x0017 A[RETURN] */ public static int a(Context context, String str) { boolean z2; try { if (context.checkPermission(str, Process.myPid(), Process.myUid()) != 0) { z2 = false; return z2 ? 0 : 1; } } catch (Exception unused) { } z2 = true; if (z2) { } } public static int a(String str, String str2, String str3) { int indexOf; int length; int indexOf2; String substring; if (!(str == null || str.equals("") || (indexOf = str.indexOf(str2)) == -1 || (indexOf2 = str.indexOf(str3, (length = indexOf + str2.length()))) == -1 || (substring = str.substring(length, indexOf2)) == null || substring.equals(""))) { try { return Integer.parseInt(substring); } catch (NumberFormatException unused) { } } return Integer.MIN_VALUE; } public static String a() { Calendar instance = Calendar.getInstance(); int i2 = instance.get(5); int i3 = instance.get(1); int i4 = instance.get(11); int i5 = instance.get(12); int i6 = instance.get(13); return String.format(Locale.CHINA, "%d-%02d-%02d %02d:%02d:%02d", Integer.valueOf(i3), Integer.valueOf(instance.get(2) + 1), Integer.valueOf(i2), Integer.valueOf(i4), Integer.valueOf(i5), Integer.valueOf(i6)); } public static String a(a aVar, i iVar, Location location, String str, int i2) { return a(aVar, iVar, location, str, i2, false); } public static String a(a aVar, i iVar, Location location, String str, int i2, boolean z2) { String a2; String b2; StringBuffer stringBuffer = new StringBuffer(2048); if (!(aVar == null || (b2 = b.a().b(aVar)) == null)) { stringBuffer.append(b2); } if (iVar != null) { String b3 = i2 == 0 ? z2 ? iVar.b() : iVar.c() : iVar.d(); if (b3 != null) { stringBuffer.append(b3); } } if (location != null) { String b4 = (f1464d == 0 || i2 == 0) ? f.b(location) : f.c(location); if (b4 != null) { stringBuffer.append(b4); } } boolean z3 = false; if (i2 == 0) { z3 = true; } String a3 = b.a().a(z3); if (a3 != null) { stringBuffer.append(a3); } if (str != null) { stringBuffer.append(str); } if (!(aVar == null || (a2 = b.a().a(aVar)) == null || a2.length() + stringBuffer.length() >= 2000)) { stringBuffer.append(a2); } String stringBuffer2 = stringBuffer.toString(); if (!(location == null || iVar == null)) { try { float speed = location.getSpeed(); int i3 = f1464d; int h2 = iVar.h(); int a4 = iVar.a(); boolean i4 = iVar.i(); if (speed < as && ((i3 == 1 || i3 == 0) && (h2 < au || i4))) { q = 1; return stringBuffer2; } else if (speed < at && ((i3 == 1 || i3 == 0 || i3 == 3) && (h2 < av || a4 > aw))) { q = 2; return stringBuffer2; } } catch (Exception unused) { q = 3; } } q = 3; return stringBuffer2; } public static String a(File file, String str) { if (!file.isFile()) { return null; } byte[] bArr = new byte[1024]; try { MessageDigest instance = MessageDigest.getInstance(str); FileInputStream fileInputStream = new FileInputStream(file); while (true) { int read = fileInputStream.read(bArr, 0, 1024); if (read != -1) { instance.update(bArr, 0, read); } else { fileInputStream.close(); return new BigInteger(1, instance.digest()).toString(16); } } } catch (Exception e2) { e2.printStackTrace(); return null; } } public static String a(String str) { return Jni.en1(o + ";" + str); } public static boolean a(BDLocation bDLocation) { int locType = bDLocation.getLocType(); return (locType > 100 && locType < 200) || locType == 62; } public static int b(Context context) { if (Build.VERSION.SDK_INT < 19) { return -2; } try { return Settings.Secure.getInt(context.getContentResolver(), "location_mode", -1); } catch (Exception unused) { return -1; } } public static boolean b() { return false; } public static boolean b(String str, String str2, String str3) { try { PublicKey generatePublic = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(Base64.decode(str3.getBytes(), 0))); Signature instance = Signature.getInstance("SHA1WithRSA"); instance.initVerify(generatePublic); instance.update(str.getBytes()); return instance.verify(Base64.decode(str2.getBytes(), 0)); } catch (Exception e2) { e2.printStackTrace(); return false; } } public static String c() { try { Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); while (networkInterfaces.hasMoreElements()) { Enumeration<InetAddress> inetAddresses = networkInterfaces.nextElement().getInetAddresses(); while (true) { if (inetAddresses.hasMoreElements()) { InetAddress nextElement = inetAddresses.nextElement(); if (!nextElement.isLoopbackAddress() && (nextElement instanceof Inet4Address)) { byte[] address = nextElement.getAddress(); String str = ""; for (byte b2 : address) { String hexString = Integer.toHexString(b2 & AVChatControlCommand.UNKNOWN); if (hexString.length() == 1) { hexString = '0' + hexString; } str = str + hexString; } return str; } } } } return null; } catch (Exception unused) { return null; } } public static boolean c(Context context) { int i2; if (context == null) { return true; } try { i2 = context.checkCallingOrSelfPermission("android.permission.ACCESS_COARSE_LOCATION"); } catch (Exception e2) { e2.printStackTrace(); i2 = 0; } boolean z2 = i2 == 0; if (z2 && Build.VERSION.SDK_INT >= 23) { try { if (Settings.Secure.getInt(context.getContentResolver(), "location_mode", 1) == 0) { return false; } } catch (Exception unused) { } } return z2; } public static String d() { try { Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); while (networkInterfaces.hasMoreElements()) { Enumeration<InetAddress> inetAddresses = networkInterfaces.nextElement().getInetAddresses(); while (true) { if (inetAddresses.hasMoreElements()) { InetAddress nextElement = inetAddresses.nextElement(); if (!nextElement.isLoopbackAddress() && (nextElement instanceof Inet6Address) && nextElement.getHostAddress() != null && !nextElement.getHostAddress().startsWith("fe80:")) { return nextElement.getHostAddress(); } } } } return ""; } catch (Throwable unused) { return ""; } } public static String d(Context context) { int a2 = a(context, "android.permission.ACCESS_COARSE_LOCATION"); int a3 = a(context, "android.permission.ACCESS_FINE_LOCATION"); int a4 = a(context, "android.permission.READ_PHONE_STATE"); return "&per=" + a2 + "|" + a3 + "|" + a4; } public static String e() { return az; } public static String e(Context context) { int i2 = -1; if (context != null) { try { NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo(); if (activeNetworkInfo != null && activeNetworkInfo.isAvailable()) { i2 = activeNetworkInfo.getType(); } } catch (Throwable unused) { } } return "&netc=" + i2; } public static String f() { return aC; } public static String g() { return "https://daup.map.baidu.com/cltr/rcvr"; } /* JADX WARNING: Removed duplicated region for block: B:19:0x003f A[SYNTHETIC, Splitter:B:19:0x003f] */ /* JADX WARNING: Removed duplicated region for block: B:26:? A[RETURN, SYNTHETIC] */ public static String h() { String str; if (Build.VERSION.SDK_INT <= 28) { try { if (Environment.getExternalStorageState().equals("mounted")) { str = Environment.getExternalStorageDirectory().getPath(); if (str == null && Build.VERSION.SDK_INT > 28 && com.baidu.location.f.getServiceContext() != null) { str = com.baidu.location.f.getServiceContext().getExternalFilesDir(Environment.DIRECTORY_MOVIES).getAbsolutePath(); } if (str != null) { return str; } try { File file = new File(str + "/baidu/tempdata"); if (file.exists()) { return str; } file.mkdirs(); return str; } catch (Exception e2) { e2.printStackTrace(); return null; } } } catch (Exception e3) { e3.printStackTrace(); } } str = null; try { str = com.baidu.location.f.getServiceContext().getExternalFilesDir(Environment.DIRECTORY_MOVIES).getAbsolutePath(); } catch (Exception unused) { str = null; } if (str != null) { } } public static String i() { String h2 = h(); if (h2 == null) { return null; } return h2 + "/baidu/tempdata"; } public static String j() { try { File file = new File(com.baidu.location.f.getServiceContext().getFilesDir() + File.separator + "lldt"); if (!file.exists()) { file.mkdirs(); } return file.getAbsolutePath(); } catch (Exception unused) { return null; } } public static String k() { try { File file = new File(com.baidu.location.f.getServiceContext().getFilesDir() + File.separator + "/baidu/tempdata"); if (!file.exists()) { file.mkdirs(); } return com.baidu.location.f.getServiceContext().getFilesDir().getPath(); } catch (Exception unused) { return null; } } public static String l() { try { File file = new File(com.baidu.location.f.getServiceContext().getFilesDir() + File.separator + "/baidu/tempdata"); if (!file.exists()) { file.mkdirs(); } return com.baidu.location.f.getServiceContext().getFilesDir().getPath() + File.separator + "/baidu/tempdata"; } catch (Exception unused) { return null; } } }