package com.loc; import android.content.Context; import android.content.SharedPreferences; import android.text.TextUtils; import android.util.SparseArray; import com.amap.api.location.AMapLocation; import com.amap.api.location.AMapLocationClientOption; import com.amap.api.services.core.AMapException; import com.amap.api.services.geocoder.GeocodeSearch; import com.taobao.weex.common.Constants; import com.taobao.weex.performance.WXInstanceApm; import io.dcloud.common.DHInterface.IApp; import io.dcloud.common.constant.AbsoluteConst; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONObject; import tv.danmaku.ijk.media.player.IjkMediaPlayer; /* compiled from: ReportUtil */ public final class fo { static AMapLocation g = null; static boolean h = false; private static List<br> i = new ArrayList(); private static JSONArray j = null; public SparseArray<Long> a = new SparseArray<>(); public int b = -1; public long c = 0; String[] d = {"ol", "cl", "gl", "ha", "bs", "ds"}; public int e = -1; public long f = -1; /* access modifiers changed from: package-private */ /* renamed from: com.loc.fo$1 reason: invalid class name */ /* compiled from: ReportUtil */ public static /* synthetic */ class AnonymousClass1 { static final /* synthetic */ int[] a; /* JADX WARNING: Can't wrap try/catch for region: R(6:0|1|2|3|4|(3:5|6|8)) */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Missing exception handler attribute for start block: B:3:0x0012 */ /* JADX WARNING: Missing exception handler attribute for start block: B:5:0x001d */ static { int[] iArr = new int[AMapLocationClientOption.AMapLocationMode.values().length]; a = iArr; iArr[AMapLocationClientOption.AMapLocationMode.Battery_Saving.ordinal()] = 1; a[AMapLocationClientOption.AMapLocationMode.Device_Sensors.ordinal()] = 2; try { a[AMapLocationClientOption.AMapLocationMode.Hight_Accuracy.ordinal()] = 3; } catch (NoSuchFieldError unused) { } } } private static String a(int i2) { if (i2 == 2011) { return "ContextIsNull"; } if (i2 == 2031) { return "CreateApsReqException"; } if (i2 == 2041) { return "ResponseResultIsNull"; } if (i2 == 2081) { return "LocalLocException"; } if (i2 == 2091) { return "InitException"; } if (i2 == 2111) { return "ErrorCgiInfo"; } if (i2 == 2121) { return "NotLocPermission"; } if (i2 == 2141) { return "NoEnoughStatellites"; } if (i2 == 2021) { return "OnlyMainWifi"; } if (i2 == 2022) { return "OnlyOneWifiButNotMain"; } if (i2 == 2061) { return "ServerRetypeError"; } if (i2 == 2062) { return "ServerLocFail"; } switch (i2) { case 2051: return "NeedLoginNetWork\t"; case 2052: return "MaybeIntercepted"; case 2053: return "DecryptResponseException"; case 2054: return "ParserDataException"; default: switch (i2) { case AMapException.CODE_AMAP_NEARBY_KEY_NOT_BIND: return "BindAPSServiceException"; case 2102: return "AuthClientScodeFail"; case 2103: return "NotConfigAPSService"; default: switch (i2) { case 2131: return "NoCgiOAndWifiInfo"; case 2132: return "AirPlaneModeAndWifiOff"; case 2133: return "NoCgiAndWifiOff"; default: switch (i2) { case 2151: return "MaybeMockNetLoc"; case 2152: return "MaybeMockGPSLoc"; case 2153: return "UNSUPPORT_COARSE_LBSLOC"; case 2154: return "UNSUPPORT_CONTINUE_LOC"; default: return ""; } } } } } public static void a(long j2, long j3) { try { if (!h) { StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append("gpsTime:"); stringBuffer.append(fq.a(j2, "yyyy-MM-dd HH:mm:ss.SSS")); stringBuffer.append(","); stringBuffer.append("sysTime:"); stringBuffer.append(fq.a(j3, "yyyy-MM-dd HH:mm:ss.SSS")); stringBuffer.append(","); long t = fi.t(); String str = WXInstanceApm.VALUE_ERROR_CODE_DEFAULT; if (0 != t) { str = fq.a(t, "yyyy-MM-dd HH:mm:ss.SSS"); } stringBuffer.append("serverTime:"); stringBuffer.append(str); a("checkgpstime", stringBuffer.toString()); if (0 != t && Math.abs(j2 - t) < 31536000000L) { stringBuffer.append(", correctError"); a("checkgpstimeerror", stringBuffer.toString()); } stringBuffer.delete(0, stringBuffer.length()); h = true; } } catch (Throwable unused) { } } public static synchronized void a(Context context) { synchronized (fo.class) { if (context != null) { try { if (fi.a()) { List<br> list = i; if (list != null && list.size() > 0) { ArrayList arrayList = new ArrayList(); arrayList.addAll(i); bs.b(arrayList, context); i.clear(); } f(context); } } catch (Throwable th) { fj.a(th, "ReportUtil", Constants.Event.SLOT_LIFECYCLE.DESTORY); } } } } public static void a(Context context, int i2, int i3, long j2, long j3) { if (i2 != -1 && i3 != -1) { try { a(context, "O012", i2, i3, j2, j3); } catch (Throwable th) { fj.a(th, "ReportUtil", "reportServiceAliveTime"); } } } public static void a(Context context, long j2, boolean z) { if (context != null) { try { if (fi.a()) { a(context, j2, z, "O015"); } } catch (Throwable th) { fj.a(th, "ReportUtil", "reportGPSLocUseTime"); } } } private static void a(Context context, long j2, boolean z, String str) { a(context, str, !z ? "abroad" : "domestic", Long.valueOf(j2).intValue()); } /* JADX WARNING: Removed duplicated region for block: B:25:0x0034 */ public static synchronized void a(Context context, AMapLocation aMapLocation) { int i2; synchronized (fo.class) { try { if (fq.a(aMapLocation)) { int locationType = aMapLocation.getLocationType(); boolean z = false; if (locationType == 1) { i2 = 0; } else if (locationType == 2 || locationType == 4) { i2 = 1; } else if (locationType == 11) { i2 = 4; } else if (locationType == 8) { i2 = 3; } else if (locationType != 9) { i2 = 0; if (z) { int c2 = fi.c(); if (c2 != 0) { if (i2 == 0 || i2 == 4) { if (c2 == 2) { return; } } else if (c2 == 1) { return; } } if (j == null) { j = new JSONArray(); } JSONObject jSONObject = new JSONObject(); jSONObject.put("lon", fq.b(aMapLocation.getLongitude())); jSONObject.put("lat", fq.b(aMapLocation.getLatitude())); jSONObject.put("type", i2); jSONObject.put("timestamp", fq.a()); if (aMapLocation.getCoordType().equalsIgnoreCase(AMapLocation.COORD_TYPE_WGS84)) { jSONObject.put(AbsoluteConst.JSONKEY_MAP_COORD_TYPE, 1); } else { jSONObject.put(AbsoluteConst.JSONKEY_MAP_COORD_TYPE, 2); } if (i2 == 0) { JSONObject jSONObject2 = new JSONObject(); jSONObject2.put("accuracy", fq.c((double) aMapLocation.getAccuracy())); jSONObject2.put("altitude", fq.c(aMapLocation.getAltitude())); jSONObject2.put("bearing", fq.c((double) aMapLocation.getBearing())); jSONObject2.put("speed", fq.c((double) aMapLocation.getSpeed())); jSONObject.put("extension", jSONObject2); } JSONArray put = j.put(jSONObject); j = put; if (put.length() >= fi.b()) { f(context); } } } else { i2 = 2; } z = true; if (z) { } } } catch (Throwable th) { fj.a(th, "ReportUtil", "recordOfflineLocLog"); } } } public static void a(Context context, AMapLocation aMapLocation, ei eiVar) { int i2; if (aMapLocation != null) { try { if (GeocodeSearch.GPS.equalsIgnoreCase(aMapLocation.getProvider())) { return; } if (aMapLocation.getLocationType() != 1) { String str = "domestic"; if (a(aMapLocation)) { str = "abroad"; } int errorCode = aMapLocation.getErrorCode(); String str2 = IApp.ConfigProperty.CONFIG_CACHE; if (errorCode != 0) { int errorCode2 = aMapLocation.getErrorCode(); if (errorCode2 == 4 || errorCode2 == 5 || errorCode2 == 6 || errorCode2 == 11) { str2 = "net"; } i2 = 0; } else { int locationType = aMapLocation.getLocationType(); if (locationType == 5 || locationType == 6) { str2 = "net"; } i2 = 1; } a(context, "O016", str2, str, i2, aMapLocation.getErrorCode(), eiVar); } } catch (Throwable th) { fj.a(th, "ReportUtil", "reportBatting"); } } } private static void a(Context context, String str, int i2, int i3, long j2, long j3) { if (context != null) { try { if (fi.a()) { JSONObject jSONObject = new JSONObject(); jSONObject.put("param_int_first", i2); jSONObject.put("param_int_second", i3); jSONObject.put("param_long_first", j2); jSONObject.put("param_long_second", j3); a(context, str, jSONObject); } } catch (Throwable th) { fj.a(th, "ReportUtil", "applyStatisticsEx"); } } } private static void a(Context context, String str, String str2, int i2) { if (context != null) { try { if (fi.a()) { JSONObject jSONObject = new JSONObject(); if (!TextUtils.isEmpty(str2)) { jSONObject.put("param_string_first", str2); } if (!TextUtils.isEmpty(null)) { jSONObject.put("param_string_second", (Object) null); } if (i2 != Integer.MAX_VALUE) { jSONObject.put("param_int_first", i2); } a(context, str, jSONObject); } } catch (Throwable th) { fj.a(th, "ReportUtil", "applyStatisticsEx"); } } } private static void a(Context context, String str, String str2, String str3, int i2, int i3, ei eiVar) { if (context != null) { try { if (fi.a()) { JSONObject jSONObject = new JSONObject(); if (!TextUtils.isEmpty(str2)) { jSONObject.put("param_string_first", str2); } if (!TextUtils.isEmpty(str3)) { jSONObject.put("param_string_second", str3); } if (i2 != Integer.MAX_VALUE) { jSONObject.put("param_int_first", i2); } if (i3 != Integer.MAX_VALUE) { jSONObject.put("param_int_second", i3); } if (eiVar != null) { if (!TextUtils.isEmpty(eiVar.d())) { jSONObject.put("dns", eiVar.d()); } if (!TextUtils.isEmpty(eiVar.e())) { jSONObject.put("domain", eiVar.e()); } if (!TextUtils.isEmpty(eiVar.f())) { jSONObject.put("type", eiVar.f()); } if (!TextUtils.isEmpty(eiVar.g())) { jSONObject.put("reason", eiVar.g()); } if (!TextUtils.isEmpty(eiVar.c())) { jSONObject.put(IjkMediaPlayer.OnNativeInvokeListener.ARG_IP, eiVar.c()); } if (!TextUtils.isEmpty(eiVar.b())) { jSONObject.put("stack", eiVar.b()); } if (eiVar.h() > 0) { jSONObject.put("ctime", String.valueOf(eiVar.h())); } if (eiVar.a() > 0) { jSONObject.put("ntime", String.valueOf(eiVar.a())); } } a(context, str, jSONObject); } } catch (Throwable th) { fj.a(th, "ReportUtil", "applyStatisticsEx"); } } } public static synchronized void a(Context context, String str, JSONObject jSONObject) { synchronized (fo.class) { if (context != null) { try { if (fi.a()) { br brVar = new br(context, "loc", "6.0.1", str); if (jSONObject != null) { brVar.a(jSONObject.toString()); } i.add(brVar); if (i.size() >= 30) { ArrayList arrayList = new ArrayList(); arrayList.addAll(i); bs.b(arrayList, context); i.clear(); } } } catch (Throwable th) { fj.a(th, "ReportUtil", "applyStatistics"); } } } } public static void a(AMapLocation aMapLocation, AMapLocation aMapLocation2) { try { if (g == null) { if (!fq.a(aMapLocation)) { g = aMapLocation2; return; } g = aMapLocation.clone(); } if (fq.a(g) && fq.a(aMapLocation2)) { AMapLocation clone = aMapLocation2.clone(); if (!(g.getLocationType() == 1 || g.getLocationType() == 9 || GeocodeSearch.GPS.equalsIgnoreCase(g.getProvider()) || g.getLocationType() == 7 || clone.getLocationType() == 1 || clone.getLocationType() == 9 || GeocodeSearch.GPS.equalsIgnoreCase(clone.getProvider()) || clone.getLocationType() == 7)) { long abs = Math.abs(clone.getTime() - g.getTime()) / 1000; if (abs <= 0) { abs = 1; } if (abs <= 1800) { float a2 = fq.a(g, clone); float f2 = a2 / ((float) abs); if (a2 > 30000.0f && f2 > 1000.0f) { StringBuilder sb = new StringBuilder(); sb.append(g.getLatitude()); sb.append(","); sb.append(g.getLongitude()); sb.append(","); sb.append(g.getAccuracy()); sb.append(","); sb.append(g.getLocationType()); sb.append(","); if (aMapLocation.getTime() != 0) { sb.append(fq.a(g.getTime(), "yyyyMMdd_HH:mm:ss:SS")); } else { sb.append(g.getTime()); } sb.append("#"); sb.append(clone.getLatitude()); sb.append(","); sb.append(clone.getLongitude()); sb.append(","); sb.append(clone.getAccuracy()); sb.append(","); sb.append(clone.getLocationType()); sb.append(","); if (clone.getTime() != 0) { sb.append(fq.a(clone.getTime(), "yyyyMMdd_HH:mm:ss:SS")); } else { sb.append(clone.getTime()); } a("bigshiftstatistics", sb.toString()); sb.delete(0, sb.length()); } } } g = clone; } } catch (Throwable unused) { } } public static void a(String str, int i2) { a(str, String.valueOf(i2), a(i2)); } public static void a(String str, String str2) { try { an.b(fj.c(), str2, str); } catch (Throwable th) { fj.a(th, "ReportUtil", "reportLog"); } } public static void a(String str, String str2, String str3) { try { an.a(fj.c(), "/mobile/binary", str3, str, str2); } catch (Throwable unused) { } } public static void a(String str, Throwable th) { try { if (th instanceof k) { an.a(fj.c(), str, (k) th); } } catch (Throwable unused) { } } private static boolean a(AMapLocation aMapLocation) { return fq.a(aMapLocation) ? !fj.a(aMapLocation.getLatitude(), aMapLocation.getLongitude()) : "http://abroad.apilocate.amap.com/mobile/binary".equals(fj.c); } public static void b(Context context, long j2, boolean z) { if (context != null) { try { if (fi.a()) { a(context, j2, z, "O024"); } } catch (Throwable th) { fj.a(th, "ReportUtil", "reportCoarseLocUseTime"); } } } private static void f(Context context) { try { JSONArray jSONArray = j; if (jSONArray != null && jSONArray.length() > 0) { bq.a(new bp(context, fj.c(), j.toString()), context); j = null; } } catch (Throwable th) { fj.a(th, "ReportUtil", "writeOfflineLocLog"); } } public final void a(Context context, int i2) { try { int i3 = this.b; if (i3 != i2) { if (!(i3 == -1 || i3 == i2)) { this.a.append(this.b, Long.valueOf((fq.b() - this.c) + this.a.get(this.b, 0L).longValue())); } this.c = fq.b() - fp.a(context, "pref1", this.d[i2], 0L); this.b = i2; } } catch (Throwable th) { fj.a(th, "ReportUtil", "setLocationType"); } } public final void a(Context context, AMapLocationClientOption aMapLocationClientOption) { try { int i2 = AnonymousClass1.a[aMapLocationClientOption.getLocationMode().ordinal()]; int i3 = 3; if (i2 == 1) { i3 = 4; } else if (i2 == 2) { i3 = 5; } else if (i2 != 3) { i3 = -1; } int i4 = this.e; if (i4 != i3) { if (!(i4 == -1 || i4 == i3)) { this.a.append(this.e, Long.valueOf((fq.b() - this.f) + this.a.get(this.e, 0L).longValue())); } this.f = fq.b() - fp.a(context, "pref1", this.d[i3], 0L); this.e = i3; } } catch (Throwable th) { fj.a(th, "ReportUtil", "setLocationMode"); } } public final void b(Context context) { try { long b2 = fq.b() - this.c; int i2 = this.b; if (i2 != -1) { this.a.append(this.b, Long.valueOf(b2 + this.a.get(i2, 0L).longValue())); } long b3 = fq.b() - this.f; int i3 = this.e; if (i3 != -1) { this.a.append(this.e, Long.valueOf(b3 + this.a.get(i3, 0L).longValue())); } SharedPreferences.Editor a2 = fp.a(context, "pref1"); for (int i4 = 0; i4 < this.d.length; i4++) { long longValue = this.a.get(i4, 0L).longValue(); if (longValue > 0 && longValue > fp.a(context, "pref1", this.d[i4], 0L)) { fp.a(a2, this.d[i4], longValue); } } fp.a(a2); } catch (Throwable th) { fj.a(th, "ReportUtil", "saveLocationTypeAndMode"); } } public final int c(Context context) { try { long a2 = fp.a(context, "pref1", this.d[2], 0L); long a3 = fp.a(context, "pref1", this.d[0], 0L); long a4 = fp.a(context, "pref1", this.d[1], 0L); if (a2 == 0 && a3 == 0 && a4 == 0) { return -1; } long j2 = a3 - a2; long j3 = a4 - a2; return a2 > j2 ? a2 > j3 ? 2 : 1 : j2 > j3 ? 0 : 1; } catch (Throwable unused) { return -1; } } public final int d(Context context) { try { long a2 = fp.a(context, "pref1", this.d[3], 0L); long a3 = fp.a(context, "pref1", this.d[4], 0L); long a4 = fp.a(context, "pref1", this.d[5], 0L); if (a2 == 0 && a3 == 0 && a4 == 0) { return -1; } return a2 > a3 ? a2 > a4 ? 3 : 5 : a3 > a4 ? 4 : 5; } catch (Throwable unused) { return -1; } } public final void e(Context context) { try { SharedPreferences.Editor a2 = fp.a(context, "pref1"); int i2 = 0; while (true) { String[] strArr = this.d; if (i2 < strArr.length) { fp.a(a2, strArr[i2], 0L); i2++; } else { fp.a(a2); return; } } } catch (Throwable unused) { } } }