package com.loc; import android.annotation.SuppressLint; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.HandlerThread; import android.os.Looper; import android.os.Message; import android.os.Parcelable; import android.text.TextUtils; import android.util.Log; import com.amap.api.fence.GeoFence; import com.amap.api.fence.GeoFenceListener; import com.amap.api.location.AMapLocation; import com.amap.api.location.AMapLocationClient; import com.amap.api.location.AMapLocationClientOption; import com.amap.api.location.AMapLocationListener; import com.amap.api.location.DPoint; import com.amap.api.maps.model.MyLocationStyle; import com.amap.api.services.district.DistrictSearchQuery; import com.autonavi.base.amap.mapcore.tools.GLMapStaticValue; import com.heytap.mcssdk.constant.Constants; import com.huawei.hms.common.internal.RequestManager; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.json.JSONObject; @SuppressLint({"NewApi"}) /* compiled from: GeoFenceManager */ public final class a { private static boolean A = false; /* renamed from: a reason: collision with root package name */ fo f6073a = null; /* renamed from: b reason: collision with root package name */ Context f6074b = null; /* renamed from: c reason: collision with root package name */ PendingIntent f6075c = null; /* renamed from: d reason: collision with root package name */ String f6076d = null; /* renamed from: e reason: collision with root package name */ GeoFenceListener f6077e = null; /* renamed from: f reason: collision with root package name */ volatile int f6078f = 1; /* renamed from: g reason: collision with root package name */ ArrayList<GeoFence> f6079g = new ArrayList<>(); c h = null; Object i = new Object(); Object j = new Object(); HandlerC0060a k = null; b l = null; volatile boolean m = false; volatile boolean n = false; volatile boolean o = false; b p = null; c q = null; AMapLocationClient r = null; volatile AMapLocation s = null; long t = 0; AMapLocationClientOption u = null; int v = 0; AMapLocationListener w = new AMapLocationListener() { /* class com.loc.a.AnonymousClass1 */ /* JADX WARNING: Removed duplicated region for block: B:16:0x005d A[Catch:{ all -> 0x0099 }] */ /* JADX WARNING: Removed duplicated region for block: B:18:0x0066 A[Catch:{ all -> 0x0099 }] */ @Override // com.amap.api.location.AMapLocationListener public final void onLocationChanged(AMapLocation aMapLocation) { boolean z; int i; try { if (!a.this.y && a.this.o) { a.this.s = aMapLocation; if (aMapLocation != null) { i = aMapLocation.getErrorCode(); if (aMapLocation.getErrorCode() == 0) { a.this.t = fq.b(); a.this.a(5, (Bundle) null, 0); z = true; if (!z) { a aVar = a.this; aVar.v = 0; aVar.a(6, (Bundle) null, 0); return; } Bundle bundle = new Bundle(); if (!a.this.m) { a.this.b(7); bundle.putLong("interval", 2000); a.this.a(8, bundle, 2000); } a aVar2 = a.this; int i2 = aVar2.v + 1; aVar2.v = i2; if (i2 >= 3) { bundle.putInt(GeoFence.BUNDLE_KEY_LOCERRORCODE, i); a.this.a(1002, bundle); return; } return; } a.a("定位失败", aMapLocation.getErrorCode(), aMapLocation.getErrorInfo(), "locationDetail:" + aMapLocation.getLocationDetail()); } else { i = 8; } z = false; if (!z) { } } } catch (Throwable unused) { } } }; final int x = 3; volatile boolean y = false; private Object z = new Object(); /* access modifiers changed from: package-private */ /* renamed from: com.loc.a$a reason: collision with other inner class name */ /* compiled from: GeoFenceManager */ public class HandlerC0060a extends Handler { public HandlerC0060a(Looper looper) { super(looper); } public final void handleMessage(Message message) { try { switch (message.what) { case 0: a.this.b(message.getData()); return; case 1: a.this.c(message.getData()); return; case 2: a.this.e(message.getData()); return; case 3: a.this.d(message.getData()); return; case 4: a.this.f(message.getData()); return; case 5: a.this.e(); return; case 6: a aVar = a.this; aVar.a(aVar.s); return; case 7: a.this.d(); return; case 8: a.this.j(message.getData()); return; case 9: a.this.a(message.getData()); return; case 10: a.this.c(); return; case 11: a.this.h(message.getData()); return; case 12: a.this.g(message.getData()); return; case 13: a.this.g(); return; default: return; } } catch (Throwable unused) { } } } /* access modifiers changed from: package-private */ /* compiled from: GeoFenceManager */ public static class b extends HandlerThread { public b(String str) { super(str); } public final void run() { try { super.run(); } catch (Throwable unused) { } } } /* access modifiers changed from: package-private */ /* compiled from: GeoFenceManager */ public class c extends Handler { public c() { } public c(Looper looper) { super(looper); } public final void handleMessage(Message message) { try { Bundle data = message.getData(); switch (message.what) { case 1000: a.this.i(data); return; case 1001: try { a.this.b((GeoFence) data.getParcelable("geoFence")); return; } catch (Throwable th) { th.printStackTrace(); return; } case 1002: try { a.this.c(data.getInt(GeoFence.BUNDLE_KEY_LOCERRORCODE)); return; } catch (Throwable th2) { th2.printStackTrace(); return; } default: return; } } catch (Throwable unused) { } } } public a(Context context) { try { this.f6074b = context.getApplicationContext(); j(); } catch (Throwable th) { fj.a(th, "GeoFenceManger", "<init>"); } } private static float a(AMapLocation aMapLocation, List<GeoFence> list) { float f2 = Float.MAX_VALUE; if (aMapLocation != null && aMapLocation.getErrorCode() == 0 && list != null && !list.isEmpty()) { DPoint dPoint = new DPoint(aMapLocation.getLatitude(), aMapLocation.getLongitude()); for (GeoFence geoFence : list) { if (geoFence.isAble()) { float a2 = fq.a(dPoint, geoFence.getCenter()); if (a2 > geoFence.getMinDis2Center() && a2 < geoFence.getMaxDis2Center()) { return 0.0f; } if (a2 > geoFence.getMaxDis2Center()) { f2 = Math.min(f2, a2 - geoFence.getMaxDis2Center()); } if (a2 < geoFence.getMinDis2Center()) { f2 = Math.min(f2, geoFence.getMinDis2Center() - a2); } } } } return f2; } static float a(DPoint dPoint, List<DPoint> list) { float f2 = Float.MAX_VALUE; if (!(dPoint == null || list == null || list.isEmpty())) { for (DPoint dPoint2 : list) { f2 = Math.min(f2, fq.a(dPoint, dPoint2)); } } return f2; } private int a(List<GeoFence> list) { try { if (this.f6079g == null) { this.f6079g = new ArrayList<>(); } for (GeoFence geoFence : list) { c(geoFence); } return 0; } catch (Throwable th) { fj.a(th, "GeoFenceManager", "addGeoFenceList"); a("添加围栏失败", 8, th.getMessage(), new String[0]); return 8; } } private static Bundle a(GeoFence geoFence, String str, String str2, int i2, int i3) { Bundle bundle = new Bundle(); if (str == null) { str = ""; } bundle.putString(GeoFence.BUNDLE_KEY_FENCEID, str); bundle.putString(GeoFence.BUNDLE_KEY_CUSTOMID, str2); bundle.putInt("event", i2); bundle.putInt(GeoFence.BUNDLE_KEY_LOCERRORCODE, i3); bundle.putParcelable(GeoFence.BUNDLE_KEY_FENCE, geoFence); return bundle; } private GeoFence a(Bundle bundle, boolean z2) { GeoFence geoFence = new GeoFence(); ArrayList arrayList = new ArrayList(); DPoint dPoint = new DPoint(); if (z2) { geoFence.setType(1); arrayList = bundle.getParcelableArrayList("pointList"); if (arrayList != null) { dPoint = b(arrayList); } geoFence.setMaxDis2Center(b(dPoint, arrayList)); geoFence.setMinDis2Center(a(dPoint, arrayList)); } else { geoFence.setType(0); dPoint = (DPoint) bundle.getParcelable("centerPoint"); if (dPoint != null) { arrayList.add(dPoint); } float f2 = 1000.0f; float f3 = bundle.getFloat("fenceRadius", 1000.0f); if (f3 > 0.0f) { f2 = f3; } geoFence.setRadius(f2); geoFence.setMinDis2Center(f2); geoFence.setMaxDis2Center(f2); } geoFence.setActivatesAction(this.f6078f); geoFence.setCustomId(bundle.getString(GeoFence.BUNDLE_KEY_CUSTOMID)); ArrayList arrayList2 = new ArrayList(); arrayList2.add(arrayList); geoFence.setPointList(arrayList2); geoFence.setCenter(dPoint); geoFence.setPendingIntentAction(this.f6076d); geoFence.setExpiration(-1); geoFence.setPendingIntent(this.f6075c); StringBuilder sb = new StringBuilder(); sb.append(c.a()); geoFence.setFenceId(sb.toString()); fo foVar = this.f6073a; if (foVar != null) { foVar.a(this.f6074b, 2); } return geoFence; } static void a(String str, int i2, String str2, String... strArr) { StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append("===========================================\n"); stringBuffer.append(" " + str + " "); stringBuffer.append("\n"); stringBuffer.append("-------------------------------------------\n"); stringBuffer.append("errorCode:".concat(String.valueOf(i2))); stringBuffer.append("\n"); stringBuffer.append("错误信息:".concat(String.valueOf(str2))); stringBuffer.append("\n"); if (strArr.length > 0) { for (String str3 : strArr) { stringBuffer.append(str3); stringBuffer.append("\n"); } } stringBuffer.append("===========================================\n"); Log.i("fenceErrLog", stringBuffer.toString()); } private static boolean a(int i2, String str, String str2, DPoint dPoint) { if (TextUtils.isEmpty(str)) { return false; } if (i2 != 1) { if (i2 == 2) { if (dPoint == null) { return false; } if (dPoint.getLatitude() > 90.0d || dPoint.getLatitude() < -90.0d || dPoint.getLongitude() > 180.0d || dPoint.getLongitude() < -180.0d) { a("添加围栏失败", 0, "经纬度错误,传入的纬度:" + dPoint.getLatitude() + "传入的经度:" + dPoint.getLongitude(), new String[0]); return false; } } } else if (TextUtils.isEmpty(str2)) { return false; } return true; } private static boolean a(GeoFence geoFence, int i2) { boolean z2 = true; boolean z3 = false; if ((i2 & 1) == 1) { try { if (geoFence.getStatus() == 1) { z3 = true; } } catch (Throwable th) { fj.a(th, "Utils", "remindStatus"); return false; } } if ((i2 & 2) == 2 && geoFence.getStatus() == 2) { z3 = true; } if (!((i2 & 4) == 4 && geoFence.getStatus() == 3)) { z2 = z3; } return z2; } private static boolean a(AMapLocation aMapLocation, GeoFence geoFence) { boolean z2 = false; try { if (fq.a(aMapLocation) && geoFence != null && geoFence.getPointList() != null && !geoFence.getPointList().isEmpty()) { int type = geoFence.getType(); if (type != 0) { if (type != 1) { if (type != 2) { if (type != 3) { } } } for (List<DPoint> list : geoFence.getPointList()) { if (b(aMapLocation, list)) { z2 = true; } } } if (a(aMapLocation, geoFence.getCenter(), geoFence.getRadius())) { return true; } } return z2; } catch (Throwable th) { fj.a(th, "Utils", "isInGeoFence"); return false; } } private static boolean a(AMapLocation aMapLocation, DPoint dPoint, float f2) { return fq.a(new double[]{dPoint.getLatitude(), dPoint.getLongitude(), aMapLocation.getLatitude(), aMapLocation.getLongitude()}) <= f2; } static float b(DPoint dPoint, List<DPoint> list) { float f2 = Float.MIN_VALUE; if (!(dPoint == null || list == null || list.isEmpty())) { for (DPoint dPoint2 : list) { f2 = Math.max(f2, fq.a(dPoint, dPoint2)); } } return f2; } private static DPoint b(List<DPoint> list) { DPoint dPoint = new DPoint(); if (list == null) { return dPoint; } try { double d2 = 0.0d; double d3 = 0.0d; for (DPoint dPoint2 : list) { d2 += dPoint2.getLatitude(); d3 += dPoint2.getLongitude(); } return new DPoint(fq.b(d2 / ((double) list.size())), fq.b(d3 / ((double) list.size()))); } catch (Throwable th) { fj.a(th, "GeoFenceUtil", "getPolygonCenter"); return dPoint; } } private void b(int i2, Bundle bundle) { int i3; String str; Throwable th; String str2; int i4; String str3; String str4; int i5; Bundle bundle2 = new Bundle(); try { ArrayList<? extends Parcelable> arrayList = new ArrayList<>(); if (bundle == null || bundle.isEmpty()) { str2 = MyLocationStyle.ERROR_CODE; i4 = 1; } else { List<GeoFence> arrayList2 = new ArrayList<>(); String string = bundle.getString(GeoFence.BUNDLE_KEY_CUSTOMID); String string2 = bundle.getString("keyWords"); String string3 = bundle.getString(DistrictSearchQuery.KEYWORDS_CITY); String string4 = bundle.getString("poiType"); DPoint dPoint = (DPoint) bundle.getParcelable("centerPoint"); int i6 = bundle.getInt("searchSize", 10); float f2 = bundle.getFloat("aroundRadius", 3000.0f); if (a(i2, string2, string4, dPoint)) { Bundle bundle3 = new Bundle(); bundle3.putString(GeoFence.BUNDLE_KEY_CUSTOMID, string); bundle3.putString("pendingIntentAction", this.f6076d); str3 = GeoFence.BUNDLE_KEY_CUSTOMID; str2 = MyLocationStyle.ERROR_CODE; try { bundle3.putLong("expiration", -1); bundle3.putInt("activatesAction", this.f6078f); if (i2 == 1) { bundle3.putFloat("fenceRadius", 1000.0f); str4 = this.p.a(this.f6074b, "http://restsdk.amap.com/v3/place/text?", string2, string4, string3, String.valueOf(i6)); } else if (i2 != 2) { str4 = i2 != 3 ? null : this.p.a(this.f6074b, "http://restsdk.amap.com/v3/config/district?", string2); } else { double b2 = fq.b(dPoint.getLatitude()); double b3 = fq.b(dPoint.getLongitude()); int intValue = Float.valueOf(f2).intValue(); bundle3.putFloat("fenceRadius", 200.0f); str4 = this.p.a(this.f6074b, "http://restsdk.amap.com/v3/place/around?", string2, string4, String.valueOf(i6), String.valueOf(b2), String.valueOf(b3), String.valueOf(intValue)); } if (str4 != null) { int a2 = 1 == i2 ? c.a(str4, arrayList2, bundle3) : 0; if (2 == i2) { a2 = c.b(str4, arrayList2, bundle3); } if (3 == i2) { a2 = this.q.c(str4, arrayList2, bundle3); } if (a2 != 10000) { i5 = d(a2); } else if (arrayList2.isEmpty()) { i5 = 16; } else { i3 = a(arrayList2); if (i3 == 0) { try { arrayList.addAll(arrayList2); } catch (Throwable th2) { th = th2; str = str2; } } } i3 = i5; } else { i3 = 4; } } catch (Throwable th3) { th = th3; str = str2; i3 = 0; try { fj.a(th, "GeoFenceManager", "doAddGeoFenceNearby"); bundle2.putInt(str, 8); a(1000, bundle2); } catch (Throwable th4) { bundle2.putInt(str, i3); a(1000, bundle2); throw th4; } } } else { str3 = GeoFence.BUNDLE_KEY_CUSTOMID; str2 = MyLocationStyle.ERROR_CODE; i3 = 1; } bundle2.putString(str3, string); bundle2.putParcelableArrayList("resultList", arrayList); i4 = i3; } bundle2.putInt(str2, i4); a(1000, bundle2); } catch (Throwable th5) { th = th5; str = MyLocationStyle.ERROR_CODE; i3 = 0; fj.a(th, "GeoFenceManager", "doAddGeoFenceNearby"); bundle2.putInt(str, 8); a(1000, bundle2); } } private static boolean b(AMapLocation aMapLocation, GeoFence geoFence) { Throwable th; boolean z2 = true; try { if (a(aMapLocation, geoFence)) { if (geoFence.getEnterTime() == -1) { if (geoFence.getStatus() != 1) { geoFence.setEnterTime(fq.b()); geoFence.setStatus(1); return true; } } else if (geoFence.getStatus() != 3 && fq.b() - geoFence.getEnterTime() > 600000) { geoFence.setStatus(3); return true; } } else if (geoFence.getStatus() != 2) { try { geoFence.setStatus(2); geoFence.setEnterTime(-1); return true; } catch (Throwable th2) { th = th2; } } return false; } catch (Throwable th3) { th = th3; z2 = false; fj.a(th, "Utils", "isFenceStatusChanged"); return z2; } } private static boolean b(AMapLocation aMapLocation, List<DPoint> list) { if (list.size() < 3) { return false; } return fj.a(new DPoint(aMapLocation.getLatitude(), aMapLocation.getLongitude()), list); } private int c(GeoFence geoFence) { try { if (this.f6079g == null) { this.f6079g = new ArrayList<>(); } if (this.f6079g.contains(geoFence)) { return 17; } this.f6079g.add(geoFence); return 0; } catch (Throwable th) { fj.a(th, "GeoFenceManager", "addGeoFence2List"); a("添加围栏失败", 8, th.getMessage(), new String[0]); return 8; } } private static int d(int i2) { if (!(i2 == 1 || i2 == 7 || i2 == 4 || i2 == 5 || i2 == 16 || i2 == 17)) { switch (i2) { case 10000: i2 = 0; break; case GLMapStaticValue.AM_CALLBACK_CHANGEMAPLOGO: case GLMapStaticValue.AM_CALLBACK_NEED_NEXTFRAME: case 10007: case 10008: case 10009: case RequestManager.NOTIFY_CONNECT_FAILED: case RequestManager.NOTIFY_CONNECT_SUSPENDED: i2 = 7; break; case GLMapStaticValue.AM_CALLBACK_INDOOR_NETWORK_ERR: case 10004: case 10005: case 10006: case 10010: case RequestManager.NOTIFY_CONNECT_SUCCESS: case 10014: case 10015: case 10016: case 10017: i2 = 4; break; default: switch (i2) { case 20000: case 20001: case 20002: i2 = 1; break; case 20003: default: i2 = 8; break; } } } if (i2 != 0) { a("添加围栏失败", i2, "searchErrCode is ".concat(String.valueOf(i2)), new String[0]); } return i2; } private void d(GeoFence geoFence) { Bundle bundle = new Bundle(); bundle.putParcelable("geoFence", geoFence); a(1001, bundle); } private void j() { if (!this.o) { this.o = true; } if (!this.n) { try { this.h = Looper.myLooper() == null ? new c(this.f6074b.getMainLooper()) : new c(); } catch (Throwable th) { fj.a(th, "GeoFenceManger", "init 1"); } try { b bVar = new b("fenceActionThread"); this.l = bVar; bVar.setPriority(5); this.l.start(); this.k = new HandlerC0060a(this.l.getLooper()); } catch (Throwable th2) { fj.a(th2, "GeoFenceManger", "init 2"); } try { this.p = new b(this.f6074b); this.q = new c(); this.u = new AMapLocationClientOption(); this.r = new AMapLocationClient(this.f6074b); this.u.setLocationCacheEnable(true); this.u.setNeedAddress(false); this.r.setLocationListener(this.w); if (this.f6073a == null) { this.f6073a = new fo(); } } catch (Throwable th3) { fj.a(th3, "GeoFenceManger", "initBase"); } this.n = true; try { String str = this.f6076d; if (str != null && this.f6075c == null) { a(str); } } catch (Throwable th4) { fj.a(th4, "GeoFenceManger", "init 4"); } if (!A) { A = true; fo.a(this.f6074b, "O020", (JSONObject) null); } } } private boolean k() { ArrayList<GeoFence> arrayList = this.f6079g; if (arrayList == null || arrayList.isEmpty()) { return true; } Iterator<GeoFence> it = this.f6079g.iterator(); while (it.hasNext()) { if (it.next().isAble()) { return false; } } return true; } private void l() { try { synchronized (this.j) { c cVar = this.h; if (cVar != null) { cVar.removeCallbacksAndMessages(null); } this.h = null; } } catch (Throwable th) { fj.a(th, "GeoFenceManager", "destroyResultHandler"); } } private void m() { try { synchronized (this.i) { HandlerC0060a aVar = this.k; if (aVar != null) { aVar.removeCallbacksAndMessages(null); } this.k = null; } } catch (Throwable th) { fj.a(th, "GeoFenceManager", "destroyActionHandler"); } } private void n() { if (this.y || this.k == null) { return; } if (p()) { a(6, (Bundle) null, 0); a(5, (Bundle) null, 0); return; } b(7); a(7, (Bundle) null, 0); } private void o() { try { if (this.m) { b(8); } AMapLocationClient aMapLocationClient = this.r; if (aMapLocationClient != null) { aMapLocationClient.stopLocation(); } this.m = false; } catch (Throwable unused) { } } private boolean p() { return this.s != null && fq.a(this.s) && fq.b() - this.t < Constants.MILLS_OF_EXCEPTION_TIME; } public final PendingIntent a(String str) { synchronized (this.z) { try { Intent intent = new Intent(str); intent.setPackage(l.c(this.f6074b)); this.f6075c = PendingIntent.getBroadcast(this.f6074b, 0, intent, 0); this.f6076d = str; ArrayList<GeoFence> arrayList = this.f6079g; if (arrayList != null && !arrayList.isEmpty()) { Iterator<GeoFence> it = this.f6079g.iterator(); while (it.hasNext()) { GeoFence next = it.next(); next.setPendingIntent(this.f6075c); next.setPendingIntentAction(this.f6076d); } } } catch (Throwable th) { fj.a(th, "GeoFenceManager", "createPendingIntent"); } } return this.f6075c; } public final void a() { try { this.o = false; a(10, (Bundle) null, 0); } catch (Throwable th) { fj.a(th, "GeoFenceManager", "removeGeoFence"); } } public final void a(int i2) { try { j(); if (i2 > 7 || i2 <= 0) { i2 = 1; } Bundle bundle = new Bundle(); bundle.putInt("activatesAction", i2); a(9, bundle, 0); } catch (Throwable th) { fj.a(th, "GeoFenceManager", "setActivateAction"); } } /* access modifiers changed from: package-private */ public final void a(int i2, Bundle bundle) { try { synchronized (this.j) { c cVar = this.h; if (cVar != null) { Message obtainMessage = cVar.obtainMessage(); obtainMessage.what = i2; obtainMessage.setData(bundle); this.h.sendMessage(obtainMessage); } } } catch (Throwable th) { fj.a(th, "GeoFenceManager", "sendResultHandlerMessage"); } } /* access modifiers changed from: package-private */ public final void a(int i2, Bundle bundle, long j2) { try { synchronized (this.i) { HandlerC0060a aVar = this.k; if (aVar != null) { Message obtainMessage = aVar.obtainMessage(); obtainMessage.what = i2; obtainMessage.setData(bundle); this.k.sendMessageDelayed(obtainMessage, j2); } } } catch (Throwable th) { fj.a(th, "GeoFenceManager", "sendActionHandlerMessage"); } } /* access modifiers changed from: package-private */ public final void a(Bundle bundle) { int i2 = 1; if (bundle != null) { try { i2 = bundle.getInt("activatesAction", 1); } catch (Throwable th) { fj.a(th, "GeoFenceManager", "doSetActivatesAction"); return; } } if (this.f6078f != i2) { ArrayList<GeoFence> arrayList = this.f6079g; if (arrayList != null && !arrayList.isEmpty()) { Iterator<GeoFence> it = this.f6079g.iterator(); while (it.hasNext()) { GeoFence next = it.next(); next.setStatus(0); next.setEnterTime(-1); } } n(); } this.f6078f = i2; } public final void a(GeoFenceListener geoFenceListener) { try { this.f6077e = geoFenceListener; } catch (Throwable unused) { } } /* access modifiers changed from: package-private */ public final void a(AMapLocation aMapLocation) { ArrayList<GeoFence> arrayList; try { if (this.y || (arrayList = this.f6079g) == null) { return; } if (!arrayList.isEmpty()) { if (aMapLocation != null && aMapLocation.getErrorCode() == 0) { Iterator<GeoFence> it = this.f6079g.iterator(); while (it.hasNext()) { GeoFence next = it.next(); if (next.isAble() && b(aMapLocation, next) && a(next, this.f6078f)) { next.setCurrentLocation(aMapLocation); d(next); } } } } } catch (Throwable th) { fj.a(th, "GeoFenceManager", "doCheckFence"); } } public final void a(DPoint dPoint, float f2, String str) { try { j(); Bundle bundle = new Bundle(); bundle.putParcelable("centerPoint", dPoint); bundle.putFloat("fenceRadius", f2); bundle.putString(GeoFence.BUNDLE_KEY_CUSTOMID, str); a(0, bundle, 0); } catch (Throwable th) { fj.a(th, "GeoFenceManager", "addRoundGeoFence"); } } public final void a(String str, String str2) { try { j(); Bundle bundle = new Bundle(); bundle.putString("keyWords", str); bundle.putString(GeoFence.BUNDLE_KEY_CUSTOMID, str2); a(4, bundle, 0); } catch (Throwable th) { fj.a(th, "GeoFenceManager", "addDistricetGeoFence"); } } public final void a(String str, String str2, DPoint dPoint, float f2, int i2, String str3) { try { j(); if (f2 <= 0.0f || f2 > 50000.0f) { f2 = 3000.0f; } if (i2 <= 0) { i2 = 10; } if (i2 > 25) { i2 = 25; } Bundle bundle = new Bundle(); bundle.putString("keyWords", str); bundle.putString("poiType", str2); bundle.putParcelable("centerPoint", dPoint); bundle.putFloat("aroundRadius", f2); bundle.putInt("searchSize", i2); bundle.putString(GeoFence.BUNDLE_KEY_CUSTOMID, str3); a(3, bundle, 0); } catch (Throwable th) { fj.a(th, "GeoFenceManager", "addNearbyGeoFence"); } } public final void a(String str, String str2, String str3, int i2, String str4) { try { j(); if (i2 <= 0) { i2 = 10; } if (i2 > 25) { i2 = 25; } Bundle bundle = new Bundle(); bundle.putString("keyWords", str); bundle.putString("poiType", str2); bundle.putString(DistrictSearchQuery.KEYWORDS_CITY, str3); bundle.putInt("searchSize", i2); bundle.putString(GeoFence.BUNDLE_KEY_CUSTOMID, str4); a(2, bundle, 0); } catch (Throwable th) { fj.a(th, "GeoFenceManager", "addKeywordGeoFence"); } } public final void a(String str, boolean z2) { try { j(); Bundle bundle = new Bundle(); bundle.putString("fid", str); bundle.putBoolean("ab", z2); a(12, bundle, 0); } catch (Throwable th) { fj.a(th, "GeoFenceManager", "setGeoFenceAble"); } } public final void a(List<DPoint> list, String str) { try { j(); Bundle bundle = new Bundle(); bundle.putParcelableArrayList("pointList", new ArrayList<>(list)); bundle.putString(GeoFence.BUNDLE_KEY_CUSTOMID, str); a(1, bundle, 0); } catch (Throwable th) { fj.a(th, "GeoFenceManager", "addPolygonGeoFence"); } } public final boolean a(GeoFence geoFence) { try { ArrayList<GeoFence> arrayList = this.f6079g; if (arrayList != null) { if (!arrayList.isEmpty()) { if (!this.f6079g.contains(geoFence)) { return false; } if (this.f6079g.size() == 1) { this.o = false; } Bundle bundle = new Bundle(); bundle.putParcelable("fc", geoFence); a(11, bundle, 0); return true; } } this.o = false; a(10, (Bundle) null, 0); return true; } catch (Throwable th) { fj.a(th, "GeoFenceManager", "removeGeoFence(GeoFence)"); return false; } } public final List<GeoFence> b() { try { if (this.f6079g == null) { this.f6079g = new ArrayList<>(); } return (ArrayList) this.f6079g.clone(); } catch (Throwable unused) { return new ArrayList(); } } /* access modifiers changed from: package-private */ public final void b(int i2) { try { synchronized (this.i) { HandlerC0060a aVar = this.k; if (aVar != null) { aVar.removeMessages(i2); } } } catch (Throwable th) { fj.a(th, "GeoFenceManager", "removeActionHandlerMessage"); } } /* access modifiers changed from: package-private */ public final void b(Bundle bundle) { String str; try { ArrayList<? extends Parcelable> arrayList = new ArrayList<>(); String str2 = ""; int i2 = 1; if (bundle != null && !bundle.isEmpty()) { DPoint dPoint = (DPoint) bundle.getParcelable("centerPoint"); str = bundle.getString(GeoFence.BUNDLE_KEY_CUSTOMID); if (dPoint == null) { str2 = str; } else if (dPoint.getLatitude() > 90.0d || dPoint.getLatitude() < -90.0d || dPoint.getLongitude() > 180.0d || dPoint.getLongitude() < -180.0d) { a("添加围栏失败", 1, "经纬度错误,传入的纬度:" + dPoint.getLatitude() + "传入的经度:" + dPoint.getLongitude(), new String[0]); Bundle bundle2 = new Bundle(); bundle2.putInt(MyLocationStyle.ERROR_CODE, i2); bundle2.putParcelableArrayList("resultList", arrayList); bundle2.putString(GeoFence.BUNDLE_KEY_CUSTOMID, str); a(1000, bundle2); } else { GeoFence a2 = a(bundle, false); i2 = c(a2); if (i2 == 0) { arrayList.add(a2); } Bundle bundle22 = new Bundle(); bundle22.putInt(MyLocationStyle.ERROR_CODE, i2); bundle22.putParcelableArrayList("resultList", arrayList); bundle22.putString(GeoFence.BUNDLE_KEY_CUSTOMID, str); a(1000, bundle22); } } str = str2; Bundle bundle222 = new Bundle(); bundle222.putInt(MyLocationStyle.ERROR_CODE, i2); bundle222.putParcelableArrayList("resultList", arrayList); bundle222.putString(GeoFence.BUNDLE_KEY_CUSTOMID, str); a(1000, bundle222); } catch (Throwable th) { fj.a(th, "GeoFenceManager", "doAddGeoFenceRound"); } } /* access modifiers changed from: package-private */ public final void b(GeoFence geoFence) { PendingIntent pendingIntent; Context context; try { synchronized (this.z) { if (this.f6074b != null) { if (this.f6075c != null || geoFence.getPendingIntent() != null) { Intent intent = new Intent(); intent.putExtras(a(geoFence, geoFence.getFenceId(), geoFence.getCustomId(), geoFence.getStatus(), 0)); String str = this.f6076d; if (str != null) { intent.setAction(str); } intent.setPackage(l.c(this.f6074b)); if (geoFence.getPendingIntent() != null) { pendingIntent = geoFence.getPendingIntent(); context = this.f6074b; } else { pendingIntent = this.f6075c; context = this.f6074b; } pendingIntent.send(context, 0, intent); } } } } catch (Throwable th) { fj.a(th, "GeoFenceManager", "resultTriggerGeoFence"); } } /* access modifiers changed from: package-private */ public final void c() { try { if (this.n) { ArrayList<GeoFence> arrayList = this.f6079g; if (arrayList != null) { arrayList.clear(); this.f6079g = null; } if (!this.o) { m(); AMapLocationClient aMapLocationClient = this.r; if (aMapLocationClient != null) { aMapLocationClient.stopLocation(); this.r.onDestroy(); } this.r = null; b bVar = this.l; if (bVar != null) { if (Build.VERSION.SDK_INT >= 18) { bVar.quitSafely(); } else { bVar.quit(); } } this.l = null; this.p = null; synchronized (this.z) { PendingIntent pendingIntent = this.f6075c; if (pendingIntent != null) { pendingIntent.cancel(); } this.f6075c = null; } l(); fo foVar = this.f6073a; if (foVar != null) { foVar.b(this.f6074b); } this.m = false; this.n = false; } } } catch (Throwable unused) { } } /* access modifiers changed from: package-private */ public final void c(int i2) { try { if (this.f6074b != null) { synchronized (this.z) { if (this.f6075c != null) { Intent intent = new Intent(); intent.putExtras(a((GeoFence) null, (String) null, (String) null, 4, i2)); this.f6075c.send(this.f6074b, 0, intent); } } } } catch (Throwable th) { fj.a(th, "GeoFenceManager", "resultRemindLocationError"); } } /* access modifiers changed from: package-private */ public final void c(Bundle bundle) { GeoFence a2; try { ArrayList<? extends Parcelable> arrayList = new ArrayList<>(); String str = ""; int i2 = 1; if (bundle != null && !bundle.isEmpty()) { ArrayList parcelableArrayList = bundle.getParcelableArrayList("pointList"); String string = bundle.getString(GeoFence.BUNDLE_KEY_CUSTOMID); if (parcelableArrayList != null && parcelableArrayList.size() > 2 && (i2 = c((a2 = a(bundle, true)))) == 0) { arrayList.add(a2); } str = string; } Bundle bundle2 = new Bundle(); bundle2.putString(GeoFence.BUNDLE_KEY_CUSTOMID, str); bundle2.putInt(MyLocationStyle.ERROR_CODE, i2); bundle2.putParcelableArrayList("resultList", arrayList); a(1000, bundle2); } catch (Throwable th) { fj.a(th, "GeoFenceManager", "doAddGeoFencePolygon"); } } /* access modifiers changed from: package-private */ public final void d() { try { if (this.r != null) { o(); this.u.setOnceLocation(true); this.r.setLocationOption(this.u); this.r.startLocation(); } } catch (Throwable th) { fj.a(th, "GeoFenceManager", "doStartOnceLocation"); } } /* access modifiers changed from: package-private */ public final void d(Bundle bundle) { b(2, bundle); } /* access modifiers changed from: package-private */ public final void e() { try { if (!this.y && fq.a(this.s)) { float a2 = a(this.s, this.f6079g); if (a2 != Float.MAX_VALUE) { if (a2 < 1000.0f) { b(7); Bundle bundle = new Bundle(); bundle.putLong("interval", 2000); a(8, bundle, 500); } else if (a2 < 5000.0f) { o(); b(7); a(7, (Bundle) null, Constants.MILLS_OF_EXCEPTION_TIME); } else { o(); b(7); a(7, (Bundle) null, (long) (((a2 - 4000.0f) / 100.0f) * 1000.0f)); } } } } catch (Throwable th) { fj.a(th, "GeoFenceManager", "doCheckLocationPolicy"); } } /* access modifiers changed from: package-private */ public final void e(Bundle bundle) { b(1, bundle); } public final void f() { try { j(); this.y = true; a(13, (Bundle) null, 0); } catch (Throwable th) { fj.a(th, "GeoFenceManager", "pauseGeoFence"); } } /* access modifiers changed from: package-private */ public final void f(Bundle bundle) { b(3, bundle); } /* access modifiers changed from: package-private */ public final void g() { try { b(7); b(8); AMapLocationClient aMapLocationClient = this.r; if (aMapLocationClient != null) { aMapLocationClient.stopLocation(); } this.m = false; } catch (Throwable th) { fj.a(th, "GeoFenceManager", "doPauseGeoFence"); } } /* access modifiers changed from: package-private */ public final void g(Bundle bundle) { if (bundle != null) { try { if (!bundle.isEmpty()) { String string = bundle.getString("fid"); if (!TextUtils.isEmpty(string)) { boolean z2 = bundle.getBoolean("ab", true); ArrayList<GeoFence> arrayList = this.f6079g; if (arrayList != null && !arrayList.isEmpty()) { Iterator<GeoFence> it = this.f6079g.iterator(); while (true) { if (!it.hasNext()) { break; } GeoFence next = it.next(); if (next.getFenceId().equals(string)) { next.setAble(z2); break; } } } if (z2) { n(); } else if (k()) { g(); } } } } catch (Throwable th) { fj.a(th, "GeoFenceManager", "doSetGeoFenceAble"); } } } public final void h() { try { j(); if (this.y) { this.y = false; n(); } } catch (Throwable th) { fj.a(th, "GeoFenceManager", "resumeGeoFence"); } } /* access modifiers changed from: package-private */ public final void h(Bundle bundle) { try { if (this.f6079g != null) { GeoFence geoFence = (GeoFence) bundle.getParcelable("fc"); if (this.f6079g.contains(geoFence)) { this.f6079g.remove(geoFence); } if (this.f6079g.size() <= 0) { c(); } else { n(); } } } catch (Throwable unused) { } } /* access modifiers changed from: package-private */ public final void i(Bundle bundle) { if (bundle != null) { try { if (!bundle.isEmpty()) { int i2 = bundle.getInt(MyLocationStyle.ERROR_CODE); ArrayList parcelableArrayList = bundle.getParcelableArrayList("resultList"); if (parcelableArrayList == null) { parcelableArrayList = new ArrayList(); } String string = bundle.getString(GeoFence.BUNDLE_KEY_CUSTOMID); if (string == null) { string = ""; } GeoFenceListener geoFenceListener = this.f6077e; if (geoFenceListener != null) { geoFenceListener.onGeoFenceCreateFinished((ArrayList) parcelableArrayList.clone(), i2, string); } if (i2 == 0) { n(); } } } catch (Throwable th) { fj.a(th, "GeoFenceManager", "resultAddGeoFenceFinished"); } } } public final boolean i() { return this.y; } /* access modifiers changed from: package-private */ public final void j(Bundle bundle) { try { if (this.r != null) { long j2 = 2000; if (bundle != null && !bundle.isEmpty()) { j2 = bundle.getLong("interval", 2000); } this.u.setOnceLocation(false); this.u.setInterval(j2); this.r.setLocationOption(this.u); if (!this.m) { this.r.stopLocation(); this.r.startLocation(); this.m = true; } } } catch (Throwable th) { fj.a(th, "GeoFenceManager", "doStartContinueLocation"); } } }