智慧考勤 v1.0.28版本的 MD5 值为:12729d810518c958a6eb8d5a86a946dd
以下内容为反编译后的 a.java 源代码,内容仅作参考
package com.loc;
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.fence.GeoFenceManagerBase;
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.taobao.accs.common.Constants;
import com.umeng.umcrash.UMCustomLogInfoBuilder;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class a implements GeoFenceManagerBase {
Context b;
dl a = null;
PendingIntent c = null;
String d = null;
GeoFenceListener e = null;
private Object A = new Object();
volatile int f = 1;
ArrayList<GeoFence> g = new ArrayList<>();
c h = null;
Object i = new Object();
Object j = new Object();
HandlerC0056a k = null;
b l = null;
volatile boolean m = false;
volatile boolean n = false;
volatile boolean o = false;
com.loc.b p = null;
com.loc.c q = null;
AMapLocationClient r = null;
volatile AMapLocation s = null;
long t = 0;
AMapLocationClientOption u = null;
int v = 0;
AMapLocationListener w = new AMapLocationListener() {
@Override
public final void onLocationChanged(AMapLocation aMapLocation) {
boolean z;
int i;
try {
if (!a.this.z && a.this.o) {
a.this.s = aMapLocation;
if (aMapLocation != null) {
i = aMapLocation.getErrorCode();
if (aMapLocation.getErrorCode() == 0) {
a.this.t = Cdo.b();
a.this.a(5, null, 0L);
z = true;
} else {
a.a("定位失败", aMapLocation.getErrorCode(), aMapLocation.getErrorInfo(), "locationDetail:" + aMapLocation.getLocationDetail());
z = false;
}
} else {
z = false;
i = 8;
}
if (z) {
a.this.v = 0;
a.this.a(6, null, 0L);
return;
}
Bundle bundle = new Bundle();
if (!a.this.m) {
a.this.a(7);
bundle.putLong("interval", 2000L);
a.this.a(8, bundle, 2000L);
}
a.this.v++;
if (a.this.v >= 3) {
bundle.putInt(GeoFence.BUNDLE_KEY_LOCERRORCODE, i);
a.this.a(1002, bundle);
}
}
} catch (Throwable unused) {
}
}
};
final int x = 3;
final int y = 2;
volatile boolean z = false;
public class HandlerC0056a extends Handler {
public HandlerC0056a(Looper looper) {
super(looper);
}
@Override
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.c();
return;
case 6:
a aVar = a.this;
aVar.a(aVar.s);
return;
case 7:
a.this.b();
return;
case 8:
a.this.j(message.getData());
return;
case 9:
a.this.a(message.getData());
return;
case 10:
a.this.a();
return;
case 11:
a.this.h(message.getData());
return;
case 12:
a.this.g(message.getData());
return;
case 13:
a.this.d();
return;
default:
return;
}
} catch (Throwable unused) {
}
}
}
public static class b extends HandlerThread {
public b(String str) {
super(str);
}
@Override
public final void run() {
try {
super.run();
} catch (Throwable unused) {
}
}
}
public class c extends Handler {
public c() {
}
public c(Looper looper) {
super(looper);
}
@Override
public final void handleMessage(Message message) {
try {
Bundle data = message.getData();
switch (message.what) {
case 1000:
a.this.i(data);
return;
case 1001:
a.this.a((GeoFence) data.getParcelable("geoFence"));
return;
case 1002:
a.this.b(data.getInt(GeoFence.BUNDLE_KEY_LOCERRORCODE));
return;
default:
return;
}
} catch (Throwable unused) {
}
}
}
public a(Context context) {
this.b = null;
try {
this.b = context.getApplicationContext();
e();
} catch (Throwable th) {
dg.a(th, "GeoFenceManger", "<init>");
}
}
public static float a(DPoint dPoint, List<DPoint> list) {
float f = Float.MAX_VALUE;
if (dPoint != null && list != null && !list.isEmpty()) {
for (DPoint dPoint2 : list) {
f = Math.min(f, Cdo.a(dPoint, dPoint2));
}
}
return f;
}
private int a(List<GeoFence> list) {
try {
if (this.g == null) {
this.g = new ArrayList<>();
}
for (GeoFence geoFence : list) {
b(geoFence);
}
return 0;
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "addGeoFenceList");
a("添加围栏失败", 8, th.getMessage(), new String[0]);
return 8;
}
}
private static Bundle a(GeoFence geoFence, String str, String str2, int i, int i2) {
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", i);
bundle.putInt(GeoFence.BUNDLE_KEY_LOCERRORCODE, i2);
bundle.putParcelable(GeoFence.BUNDLE_KEY_FENCE, geoFence);
return bundle;
}
private GeoFence a(Bundle bundle, boolean z) {
GeoFence geoFence = new GeoFence();
ArrayList arrayList = new ArrayList();
DPoint dPoint = new DPoint();
if (z) {
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 f = bundle.getFloat("fenceRadius", 1000.0f);
float f2 = f > 0.0f ? f : 1000.0f;
geoFence.setRadius(f2);
geoFence.setMinDis2Center(f2);
geoFence.setMaxDis2Center(f2);
}
geoFence.setActivatesAction(this.f);
geoFence.setCustomId(bundle.getString(GeoFence.BUNDLE_KEY_CUSTOMID));
ArrayList arrayList2 = new ArrayList();
arrayList2.add(arrayList);
geoFence.setPointList(arrayList2);
geoFence.setCenter(dPoint);
geoFence.setPendingIntentAction(this.d);
geoFence.setExpiration(-1L);
geoFence.setPendingIntent(this.c);
StringBuilder sb = new StringBuilder();
sb.append(com.loc.c.a());
geoFence.setFenceId(sb.toString());
dl dlVar = this.a;
if (dlVar != null) {
dlVar.a(this.b, 2);
}
return geoFence;
}
static void a(String str, int i, String str2, String... strArr) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("===========================================\n");
stringBuffer.append(" " + str + " ");
stringBuffer.append(UMCustomLogInfoBuilder.LINE_SEP);
stringBuffer.append("-------------------------------------------\n");
stringBuffer.append("errorCode:" + i);
stringBuffer.append(UMCustomLogInfoBuilder.LINE_SEP);
stringBuffer.append("错误信息:" + str2);
stringBuffer.append(UMCustomLogInfoBuilder.LINE_SEP);
if (strArr != null && strArr.length > 0) {
for (String str3 : strArr) {
stringBuffer.append(str3);
stringBuffer.append(UMCustomLogInfoBuilder.LINE_SEP);
}
}
stringBuffer.append("===========================================\n");
Log.i("fenceErrLog", stringBuffer.toString());
}
private static boolean a(double d, double d2, double d3, double d4, double d5, double d6) {
return Math.abs(((d3 - d) * (d6 - d2)) - ((d5 - d) * (d4 - d2))) < 1.0E-9d && (d - d3) * (d - d5) <= 0.0d && (d2 - d4) * (d2 - d6) <= 0.0d;
}
private static boolean a(GeoFence geoFence, int i) {
boolean z = true;
boolean z2 = false;
if ((i & 1) == 1) {
try {
if (geoFence.getStatus() == 1) {
z2 = true;
}
} catch (Throwable th) {
dg.a(th, "Utils", "remindStatus");
return z2;
}
}
if ((i & 2) == 2 && geoFence.getStatus() == 2) {
z2 = true;
}
if ((i & 4) == 4) {
}
z = z2;
return z;
}
private static boolean a(AMapLocation aMapLocation, GeoFence geoFence) {
boolean z;
boolean z2;
boolean z3 = false;
try {
if (Cdo.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) {
}
}
}
boolean z4 = false;
for (List<DPoint> list : geoFence.getPointList()) {
try {
double longitude = aMapLocation.getLongitude();
double latitude = aMapLocation.getLatitude();
double latitude2 = aMapLocation.getLatitude();
if (list.size() >= 3) {
if (!list.get(0).equals(list.get(list.size() - 1))) {
list.add(list.get(0));
}
int i = 0;
int i2 = 0;
while (true) {
if (i < list.size() - 1) {
double longitude2 = list.get(i).getLongitude();
double latitude3 = list.get(i).getLatitude();
int i3 = i + 1;
double longitude3 = list.get(i3).getLongitude();
double latitude4 = list.get(i3).getLatitude();
if (a(longitude, latitude, longitude2, latitude3, longitude3, latitude4)) {
break;
}
double d = latitude4 - latitude3;
if (Math.abs(d) >= 1.0E-9d) {
if (a(longitude2, latitude3, longitude, latitude, 180.0d, latitude2)) {
if (latitude3 <= latitude4) {
}
i2++;
} else if (!a(longitude3, latitude4, longitude, latitude, 180.0d, latitude2)) {
double d2 = longitude3 - longitude2;
double d3 = latitude2 - latitude;
double d4 = 180.0d - longitude;
double d5 = (d2 * d3) - (d * d4);
if (d5 != 0.0d) {
double d6 = latitude3 - latitude;
double d7 = longitude2 - longitude;
double d8 = ((d4 * d6) - (d3 * d7)) / d5;
double d9 = ((d6 * d2) - (d7 * d)) / d5;
if (d8 >= 0.0d && d8 <= 1.0d && d9 >= 0.0d && d9 <= 1.0d) {
z2 = true;
if (!z2) {
i2++;
}
}
}
z2 = false;
if (!z2) {
}
} else if (latitude4 > latitude3) {
i2++;
}
}
i = i3;
}
}
z = true;
if (!z) {
z4 = true;
}
}
z = false;
if (!z) {
}
} catch (Throwable th) {
th = th;
z3 = z4;
dg.a(th, "Utils", "isInGeoFence");
return z3;
}
}
z3 = z4;
}
DPoint center = geoFence.getCenter();
if (Cdo.a(new double[]{center.getLatitude(), center.getLongitude(), aMapLocation.getLatitude(), aMapLocation.getLongitude()}) <= geoFence.getRadius()) {
return true;
}
}
} catch (Throwable th2) {
th = th2;
}
return z3;
}
public static float b(DPoint dPoint, List<DPoint> list) {
float f = Float.MIN_VALUE;
if (dPoint != null && list != null && !list.isEmpty()) {
for (DPoint dPoint2 : list) {
f = Math.max(f, Cdo.a(dPoint, dPoint2));
}
}
return f;
}
private int b(GeoFence geoFence) {
try {
if (this.g == null) {
this.g = new ArrayList<>();
}
if (this.g.contains(geoFence)) {
return 17;
}
this.g.add(geoFence);
return 0;
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "addGeoFence2List");
a("添加围栏失败", 8, th.getMessage(), new String[0]);
return 8;
}
}
private static DPoint b(List<DPoint> list) {
DPoint dPoint = new DPoint();
if (list != null) {
try {
double d = 0.0d;
double d2 = 0.0d;
for (DPoint dPoint2 : list) {
d += dPoint2.getLatitude();
d2 += dPoint2.getLongitude();
}
return new DPoint(Cdo.c(d / list.size()), Cdo.c(d2 / list.size()));
} catch (Throwable th) {
dg.a(th, "GeoFenceUtil", "getPolygonCenter");
return dPoint;
}
}
return dPoint;
}
private void b(int i, Bundle bundle) {
String str;
int i2;
String str2;
boolean z;
boolean z2;
String str3;
String str4;
int i3;
String str5;
String a;
int i4;
Bundle bundle2 = new Bundle();
try {
ArrayList<? extends Parcelable> arrayList = new ArrayList<>();
if (bundle != null) {
try {
if (!bundle.isEmpty()) {
List<GeoFence> arrayList2 = new ArrayList<>();
String string = bundle.getString(GeoFence.BUNDLE_KEY_CUSTOMID);
String string2 = bundle.getString("keyWords");
String string3 = bundle.getString("city");
String string4 = bundle.getString("poiType");
DPoint dPoint = (DPoint) bundle.getParcelable("centerPoint");
int i5 = bundle.getInt("searchSize", 10);
float f = bundle.getFloat("aroundRadius", 3000.0f);
if (TextUtils.isEmpty(string2)) {
str2 = "添加围栏失败";
z2 = false;
} else {
if (i != 1) {
if (i == 2) {
if (dPoint == null) {
str2 = "添加围栏失败";
} else {
try {
if (dPoint.getLatitude() > 90.0d || dPoint.getLatitude() < -90.0d || dPoint.getLongitude() > 180.0d || dPoint.getLongitude() < -180.0d) {
str2 = "添加围栏失败";
a(str2, 0, "经纬度错误,传入的纬度:" + dPoint.getLatitude() + "传入的经度:" + dPoint.getLongitude(), new String[0]);
}
} catch (Throwable th) {
th = th;
str = Constants.KEY_ERROR_CODE;
i2 = 0;
try {
dg.a(th, "GeoFenceManager", "doAddGeoFenceNearby");
bundle2.putInt(str, 8);
a(1000, bundle2);
return;
} catch (Throwable th2) {
bundle2.putInt(str, i2);
a(1000, bundle2);
throw th2;
}
}
}
}
str2 = "添加围栏失败";
z = true;
} else {
str2 = "添加围栏失败";
z = TextUtils.isEmpty(string4) ? false : false;
z = true;
}
z2 = z;
}
if (z2) {
Bundle bundle3 = new Bundle();
bundle3.putString(GeoFence.BUNDLE_KEY_CUSTOMID, string);
bundle3.putString("pendingIntentAction", this.d);
str3 = GeoFence.BUNDLE_KEY_CUSTOMID;
str4 = Constants.KEY_ERROR_CODE;
try {
bundle3.putLong("expiration", -1L);
bundle3.putInt("activatesAction", this.f);
} catch (Throwable th3) {
th = th3;
}
try {
if (i == 1) {
bundle3.putFloat("fenceRadius", 1000.0f);
a = this.p.a(this.b, "http://restapi.amap.com/v3/place/text?", string2, string4, string3, String.valueOf(i5));
} else if (i != 2) {
a = i != 3 ? null : this.p.a(this.b, "http://restapi.amap.com/v3/config/district?", string2);
} else {
double c2 = Cdo.c(dPoint.getLatitude());
double c3 = Cdo.c(dPoint.getLongitude());
int intValue = Float.valueOf(f).intValue();
bundle3.putFloat("fenceRadius", 200.0f);
a = this.p.a(this.b, "http://restapi.amap.com/v3/place/around?", string2, string4, String.valueOf(i5), String.valueOf(c2), String.valueOf(c3), String.valueOf(intValue));
}
int i6 = 4;
if (a != null) {
int a2 = 1 == i ? com.loc.c.a(a, arrayList2, bundle3) : 0;
if (2 == i) {
a2 = com.loc.c.b(a, arrayList2, bundle3);
}
if (3 == i) {
a2 = this.q.c(a, arrayList2, bundle3);
}
if (a2 != 10000) {
if (a2 != 1 && a2 != 7 && a2 != 4 && a2 != 5 && a2 != 16 && a2 != 17) {
switch (a2) {
case 10000:
i4 = 0;
break;
case 10001:
case 10002:
case 10007:
case 10008:
case 10009:
case 10012:
case 10013:
i4 = 7;
break;
case 10003:
case 10004:
case 10005:
case 10006:
case 10010:
case 10011:
case 10014:
case 10015:
case 10016:
case 10017:
i4 = 4;
break;
default:
switch (a2) {
case 20000:
case 20001:
case 20002:
i4 = 1;
break;
case 20003:
default:
i4 = 8;
break;
}
}
} else {
i4 = a2;
}
if (i4 != 0) {
a(str2, i4, "searchErrCode is " + i4, new String[0]);
}
i2 = i4;
} else if (arrayList2.isEmpty()) {
i2 = 16;
} else {
i2 = a(arrayList2);
if (i2 == 0) {
try {
arrayList.addAll(arrayList2);
} catch (Throwable th4) {
th = th4;
str = str4;
dg.a(th, "GeoFenceManager", "doAddGeoFenceNearby");
bundle2.putInt(str, 8);
a(1000, bundle2);
return;
}
} else {
i6 = i2;
}
}
}
i2 = i6;
} catch (Throwable th5) {
th = th5;
str = str4;
i2 = 0;
dg.a(th, "GeoFenceManager", "doAddGeoFenceNearby");
bundle2.putInt(str, 8);
a(1000, bundle2);
return;
}
} else {
str3 = GeoFence.BUNDLE_KEY_CUSTOMID;
str4 = Constants.KEY_ERROR_CODE;
i2 = 1;
}
bundle2.putString(str3, string);
bundle2.putParcelableArrayList("resultList", arrayList);
i3 = i2;
str5 = str4;
bundle2.putInt(str5, i3);
a(1000, bundle2);
}
} catch (Throwable th6) {
th = th6;
}
}
str5 = Constants.KEY_ERROR_CODE;
i3 = 1;
bundle2.putInt(str5, i3);
a(1000, bundle2);
} catch (Throwable th7) {
th = th7;
str = Constants.KEY_ERROR_CODE;
}
}
private static boolean b(AMapLocation aMapLocation, GeoFence geoFence) {
boolean z = true;
try {
if (!a(aMapLocation, geoFence)) {
if (geoFence.getStatus() != 2) {
try {
geoFence.setStatus(2);
geoFence.setEnterTime(-1L);
} catch (Throwable th) {
th = th;
dg.a(th, "Utils", "isFenceStatusChanged");
return z;
}
}
z = false;
} else if (geoFence.getEnterTime() == -1) {
if (geoFence.getStatus() != 1) {
geoFence.setEnterTime(Cdo.b());
geoFence.setStatus(1);
}
z = false;
} else {
if (geoFence.getStatus() != 3 && Cdo.b() - geoFence.getEnterTime() > 600000) {
geoFence.setStatus(3);
}
z = false;
}
} catch (Throwable th2) {
th = th2;
z = false;
}
return z;
}
private void e() {
if (!this.o) {
this.o = true;
}
if (this.n) {
return;
}
try {
this.h = Looper.myLooper() == null ? new c(this.b.getMainLooper()) : new c();
} catch (Throwable th) {
dg.a(th, "GeoFenceManger", "init 1");
}
try {
b bVar = new b("fenceActionThread");
this.l = bVar;
bVar.setPriority(5);
this.l.start();
this.k = new HandlerC0056a(this.l.getLooper());
} catch (Throwable th2) {
dg.a(th2, "GeoFenceManger", "init 2");
}
try {
this.p = new com.loc.b();
this.q = new com.loc.c();
this.u = new AMapLocationClientOption();
this.r = new AMapLocationClient(this.b);
this.u.setLocationCacheEnable(true);
this.u.setNeedAddress(false);
this.r.setLocationListener(this.w);
if (this.a == null) {
this.a = new dl();
}
} catch (Throwable th3) {
dg.a(th3, "GeoFenceManger", "initBase");
}
this.n = true;
try {
String str = this.d;
if (str == null || this.c != null) {
return;
}
createPendingIntent(str);
} catch (Throwable th4) {
dg.a(th4, "GeoFenceManger", "init 4");
}
}
private void f() {
if (this.z || this.k == null) {
return;
}
boolean z = false;
if (this.s != null && Cdo.a(this.s) && Cdo.b() - this.t < 10000) {
z = true;
}
if (z) {
a(6, null, 0L);
a(5, null, 0L);
return;
}
a(7);
a(7, null, 0L);
}
private void g() {
try {
if (this.m) {
a(8);
}
AMapLocationClient aMapLocationClient = this.r;
if (aMapLocationClient != null) {
aMapLocationClient.stopLocation();
}
this.m = false;
} catch (Throwable unused) {
}
}
final void a() {
if (this.n) {
ArrayList<GeoFence> arrayList = this.g;
if (arrayList != null) {
arrayList.clear();
this.g = null;
}
if (this.o) {
return;
}
synchronized (this.i) {
HandlerC0056a handlerC0056a = this.k;
if (handlerC0056a != null) {
handlerC0056a.removeCallbacksAndMessages(null);
}
this.k = null;
}
AMapLocationClient aMapLocationClient = this.r;
if (aMapLocationClient != null) {
aMapLocationClient.stopLocation();
this.r.onDestroy();
}
this.r = null;
if (this.l != null) {
if (Build.VERSION.SDK_INT >= 18) {
this.l.quitSafely();
} else {
this.l.quit();
}
}
this.l = null;
this.p = null;
synchronized (this.A) {
PendingIntent pendingIntent = this.c;
if (pendingIntent != null) {
pendingIntent.cancel();
}
this.c = null;
}
synchronized (this.j) {
c cVar = this.h;
if (cVar != null) {
cVar.removeCallbacksAndMessages(null);
}
this.h = null;
}
dl dlVar = this.a;
if (dlVar != null) {
dlVar.b(this.b);
}
this.m = false;
this.n = false;
}
}
final void a(int i) {
try {
synchronized (this.i) {
HandlerC0056a handlerC0056a = this.k;
if (handlerC0056a != null) {
handlerC0056a.removeMessages(i);
}
}
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "removeActionHandlerMessage");
}
}
final void a(int i, Bundle bundle) {
try {
synchronized (this.j) {
c cVar = this.h;
if (cVar != null) {
Message obtainMessage = cVar.obtainMessage();
obtainMessage.what = i;
obtainMessage.setData(bundle);
this.h.sendMessage(obtainMessage);
}
}
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "sendResultHandlerMessage");
}
}
final void a(int i, Bundle bundle, long j) {
try {
synchronized (this.i) {
HandlerC0056a handlerC0056a = this.k;
if (handlerC0056a != null) {
Message obtainMessage = handlerC0056a.obtainMessage();
obtainMessage.what = i;
obtainMessage.setData(bundle);
this.k.sendMessageDelayed(obtainMessage, j);
}
}
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "sendActionHandlerMessage");
}
}
final void a(Bundle bundle) {
int i = 1;
if (bundle != null) {
try {
i = bundle.getInt("activatesAction", 1);
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "doSetActivatesAction");
return;
}
}
if (this.f != i) {
ArrayList<GeoFence> arrayList = this.g;
if (arrayList != null && !arrayList.isEmpty()) {
Iterator<GeoFence> it = this.g.iterator();
while (it.hasNext()) {
GeoFence next = it.next();
next.setStatus(0);
next.setEnterTime(-1L);
}
}
f();
}
this.f = i;
}
final void a(GeoFence geoFence) {
PendingIntent pendingIntent;
Context context;
try {
synchronized (this.A) {
if (this.b != null) {
if (this.c == null && geoFence.getPendingIntent() == null) {
return;
}
Intent intent = new Intent();
intent.putExtras(a(geoFence, geoFence.getFenceId(), geoFence.getCustomId(), geoFence.getStatus(), 0));
String str = this.d;
if (str != null) {
intent.setAction(str);
}
intent.setPackage(l.c(this.b));
if (geoFence.getPendingIntent() != null) {
pendingIntent = geoFence.getPendingIntent();
context = this.b;
} else {
pendingIntent = this.c;
context = this.b;
}
pendingIntent.send(context, 0, intent);
}
}
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "resultTriggerGeoFence");
}
}
final void a(AMapLocation aMapLocation) {
ArrayList<GeoFence> arrayList;
try {
if (this.z || (arrayList = this.g) == null || arrayList.isEmpty() || aMapLocation == null || aMapLocation.getErrorCode() != 0) {
return;
}
Iterator<GeoFence> it = this.g.iterator();
while (it.hasNext()) {
GeoFence next = it.next();
if (next.isAble() && b(aMapLocation, next) && a(next, this.f)) {
next.setCurrentLocation(aMapLocation);
Bundle bundle = new Bundle();
bundle.putParcelable("geoFence", next);
a(1001, bundle);
}
}
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "doCheckFence");
}
}
@Override
public void addDistrictGeoFence(String str, String str2) {
try {
e();
Bundle bundle = new Bundle();
bundle.putString("keyWords", str);
bundle.putString(GeoFence.BUNDLE_KEY_CUSTOMID, str2);
a(4, bundle, 0L);
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "addDistricetGeoFence");
}
}
@Override
public void addKeywordGeoFence(String str, String str2, String str3, int i, String str4) {
try {
e();
if (i <= 0) {
i = 10;
}
if (i > 25) {
i = 25;
}
Bundle bundle = new Bundle();
bundle.putString("keyWords", str);
bundle.putString("poiType", str2);
bundle.putString("city", str3);
bundle.putInt("searchSize", i);
bundle.putString(GeoFence.BUNDLE_KEY_CUSTOMID, str4);
a(2, bundle, 0L);
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "addKeywordGeoFence");
}
}
@Override
public void addNearbyGeoFence(String str, String str2, DPoint dPoint, float f, int i, String str3) {
try {
e();
f = (f <= 0.0f || f > 50000.0f) ? 3000.0f : 3000.0f;
if (i <= 0) {
i = 10;
}
if (i > 25) {
i = 25;
}
Bundle bundle = new Bundle();
bundle.putString("keyWords", str);
bundle.putString("poiType", str2);
bundle.putParcelable("centerPoint", dPoint);
bundle.putFloat("aroundRadius", f);
bundle.putInt("searchSize", i);
bundle.putString(GeoFence.BUNDLE_KEY_CUSTOMID, str3);
a(3, bundle, 0L);
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "addNearbyGeoFence");
}
}
@Override
public void addPolygonGeoFence(List<DPoint> list, String str) {
try {
e();
Bundle bundle = new Bundle();
bundle.putParcelableArrayList("pointList", new ArrayList<>(list));
bundle.putString(GeoFence.BUNDLE_KEY_CUSTOMID, str);
a(1, bundle, 0L);
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "addPolygonGeoFence");
}
}
@Override
public void addRoundGeoFence(DPoint dPoint, float f, String str) {
try {
e();
Bundle bundle = new Bundle();
bundle.putParcelable("centerPoint", dPoint);
bundle.putFloat("fenceRadius", f);
bundle.putString(GeoFence.BUNDLE_KEY_CUSTOMID, str);
a(0, bundle, 0L);
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "addRoundGeoFence");
}
}
final void b() {
try {
if (this.r != null) {
g();
this.u.setOnceLocation(true);
this.r.setLocationOption(this.u);
this.r.startLocation();
}
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "doStartOnceLocation");
}
}
final void b(int i) {
try {
if (this.b != null) {
synchronized (this.A) {
if (this.c == null) {
return;
}
Intent intent = new Intent();
intent.putExtras(a(null, null, null, 4, i));
this.c.send(this.b, 0, intent);
}
}
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "resultRemindLocationError");
}
}
final void b(Bundle bundle) {
String str;
try {
ArrayList<? extends Parcelable> arrayList = new ArrayList<>();
String str2 = "";
int i = 1;
if (bundle != null && !bundle.isEmpty()) {
DPoint dPoint = (DPoint) bundle.getParcelable("centerPoint");
str = bundle.getString(GeoFence.BUNDLE_KEY_CUSTOMID);
if (dPoint != null) {
if (dPoint.getLatitude() <= 90.0d && dPoint.getLatitude() >= -90.0d && dPoint.getLongitude() <= 180.0d && dPoint.getLongitude() >= -180.0d) {
GeoFence a = a(bundle, false);
i = b(a);
if (i == 0) {
arrayList.add(a);
}
Bundle bundle2 = new Bundle();
bundle2.putInt(Constants.KEY_ERROR_CODE, i);
bundle2.putParcelableArrayList("resultList", arrayList);
bundle2.putString(GeoFence.BUNDLE_KEY_CUSTOMID, str);
a(1000, bundle2);
}
a("添加围栏失败", 1, "经纬度错误,传入的纬度:" + dPoint.getLatitude() + "传入的经度:" + dPoint.getLongitude(), new String[0]);
Bundle bundle22 = new Bundle();
bundle22.putInt(Constants.KEY_ERROR_CODE, i);
bundle22.putParcelableArrayList("resultList", arrayList);
bundle22.putString(GeoFence.BUNDLE_KEY_CUSTOMID, str);
a(1000, bundle22);
}
str2 = str;
}
str = str2;
Bundle bundle222 = new Bundle();
bundle222.putInt(Constants.KEY_ERROR_CODE, i);
bundle222.putParcelableArrayList("resultList", arrayList);
bundle222.putString(GeoFence.BUNDLE_KEY_CUSTOMID, str);
a(1000, bundle222);
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "doAddGeoFenceRound");
}
}
final void c() {
float f;
float f2;
try {
if (!this.z && Cdo.a(this.s)) {
AMapLocation aMapLocation = this.s;
ArrayList<GeoFence> arrayList = this.g;
if (aMapLocation == null || aMapLocation.getErrorCode() != 0 || arrayList == null || arrayList.isEmpty()) {
f = Float.MAX_VALUE;
} else {
DPoint dPoint = new DPoint(aMapLocation.getLatitude(), aMapLocation.getLongitude());
f = Float.MAX_VALUE;
for (GeoFence geoFence : arrayList) {
if (geoFence.isAble()) {
float a = Cdo.a(dPoint, geoFence.getCenter());
if (a > geoFence.getMinDis2Center() && a < geoFence.getMaxDis2Center()) {
f2 = 0.0f;
break;
}
if (a > geoFence.getMaxDis2Center()) {
f = Math.min(f, a - geoFence.getMaxDis2Center());
}
if (a < geoFence.getMinDis2Center()) {
f = Math.min(f, geoFence.getMinDis2Center() - a);
}
}
}
}
f2 = f;
if (f2 == Float.MAX_VALUE) {
return;
}
if (f2 < 1000.0f) {
a(7);
Bundle bundle = new Bundle();
bundle.putLong("interval", 2000L);
a(8, bundle, 500L);
} else if (f2 < 5000.0f) {
g();
a(7);
a(7, null, 10000L);
} else {
g();
a(7);
a(7, null, ((f2 - 4000.0f) / 100.0f) * 1000.0f);
}
}
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "doCheckLocationPolicy");
}
}
final void c(Bundle bundle) {
GeoFence a;
try {
ArrayList<? extends Parcelable> arrayList = new ArrayList<>();
String str = "";
int i = 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 && (i = b((a = a(bundle, true)))) == 0) {
arrayList.add(a);
}
str = string;
}
Bundle bundle2 = new Bundle();
bundle2.putString(GeoFence.BUNDLE_KEY_CUSTOMID, str);
bundle2.putInt(Constants.KEY_ERROR_CODE, i);
bundle2.putParcelableArrayList("resultList", arrayList);
a(1000, bundle2);
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "doAddGeoFencePolygon");
}
}
@Override
public PendingIntent createPendingIntent(String str) {
synchronized (this.A) {
try {
Intent intent = new Intent(str);
intent.setPackage(l.c(this.b));
this.c = PendingIntent.getBroadcast(this.b, 0, intent, 0);
this.d = str;
ArrayList<GeoFence> arrayList = this.g;
if (arrayList != null && !arrayList.isEmpty()) {
Iterator<GeoFence> it = this.g.iterator();
while (it.hasNext()) {
GeoFence next = it.next();
next.setPendingIntent(this.c);
next.setPendingIntentAction(this.d);
}
}
}
}
return this.c;
}
final void d() {
try {
a(7);
a(8);
AMapLocationClient aMapLocationClient = this.r;
if (aMapLocationClient != null) {
aMapLocationClient.stopLocation();
}
this.m = false;
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "doPauseGeoFence");
}
}
final void d(Bundle bundle) {
b(2, bundle);
}
final void e(Bundle bundle) {
b(1, bundle);
}
final void f(Bundle bundle) {
b(3, bundle);
}
final void g(Bundle bundle) {
if (bundle != null) {
try {
if (bundle.isEmpty()) {
return;
}
String string = bundle.getString("fid");
if (TextUtils.isEmpty(string)) {
return;
}
boolean z = true;
boolean z2 = bundle.getBoolean("ab", true);
ArrayList<GeoFence> arrayList = this.g;
if (arrayList != null && !arrayList.isEmpty()) {
Iterator<GeoFence> it = this.g.iterator();
while (true) {
if (!it.hasNext()) {
break;
}
GeoFence next = it.next();
if (next.getFenceId().equals(string)) {
next.setAble(z2);
break;
}
}
}
if (z2) {
f();
return;
}
ArrayList<GeoFence> arrayList2 = this.g;
if (arrayList2 != null && !arrayList2.isEmpty()) {
Iterator<GeoFence> it2 = this.g.iterator();
while (true) {
if (!it2.hasNext()) {
break;
} else if (it2.next().isAble()) {
z = false;
break;
}
}
}
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "doSetGeoFenceAble");
}
}
}
@Override
public List<GeoFence> getAllGeoFence() {
try {
if (this.g == null) {
this.g = new ArrayList<>();
}
return (ArrayList) this.g.clone();
} catch (Throwable unused) {
return new ArrayList();
}
}
final void h(Bundle bundle) {
try {
if (this.g != null) {
GeoFence geoFence = (GeoFence) bundle.getParcelable("fc");
if (this.g.contains(geoFence)) {
this.g.remove(geoFence);
}
if (this.g.size() <= 0) {
a();
} else {
f();
}
}
} catch (Throwable unused) {
}
}
final void i(Bundle bundle) {
if (bundle != null) {
try {
if (bundle.isEmpty()) {
return;
}
int i = bundle.getInt(Constants.KEY_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.e;
if (geoFenceListener != null) {
geoFenceListener.onGeoFenceCreateFinished((ArrayList) parcelableArrayList.clone(), i, string);
}
if (i == 0) {
f();
}
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "resultAddGeoFenceFinished");
}
}
}
@Override
public boolean isPause() {
return this.z;
}
final void j(Bundle bundle) {
try {
if (this.r != null) {
long j = 2000;
if (bundle != null && !bundle.isEmpty()) {
j = bundle.getLong("interval", 2000L);
}
this.u.setOnceLocation(false);
this.u.setInterval(j);
this.r.setLocationOption(this.u);
if (this.m) {
return;
}
this.r.stopLocation();
this.r.startLocation();
this.m = true;
}
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "doStartContinueLocation");
}
}
@Override
public void pauseGeoFence() {
try {
e();
this.z = true;
a(13, null, 0L);
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "pauseGeoFence");
}
}
@Override
public void removeGeoFence() {
try {
this.o = false;
a(10, null, 0L);
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "removeGeoFence");
}
}
@Override
public boolean removeGeoFence(GeoFence geoFence) {
try {
ArrayList<GeoFence> arrayList = this.g;
if (arrayList != null && !arrayList.isEmpty()) {
if (this.g.contains(geoFence)) {
if (this.g.size() == 1) {
this.o = false;
}
Bundle bundle = new Bundle();
bundle.putParcelable("fc", geoFence);
a(11, bundle, 0L);
return true;
}
return false;
}
this.o = false;
a(10, null, 0L);
return true;
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "removeGeoFence(GeoFence)");
return false;
}
}
@Override
public void resumeGeoFence() {
try {
e();
if (this.z) {
this.z = false;
f();
}
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "resumeGeoFence");
}
}
@Override
public void setActivateAction(int i) {
try {
e();
i = (i > 7 || i <= 0) ? 1 : 1;
Bundle bundle = new Bundle();
bundle.putInt("activatesAction", i);
a(9, bundle, 0L);
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "setActivateAction");
}
}
@Override
public void setGeoFenceAble(String str, boolean z) {
try {
e();
Bundle bundle = new Bundle();
bundle.putString("fid", str);
bundle.putBoolean("ab", z);
a(12, bundle, 0L);
} catch (Throwable th) {
dg.a(th, "GeoFenceManager", "setGeoFenceAble");
}
}
@Override
public void setGeoFenceListener(GeoFenceListener geoFenceListener) {
try {
this.e = geoFenceListener;
} catch (Throwable unused) {
}
}
}