打牌网 v4.0.4版本的 MD5 值为:e257b9ecf68b0639529ede50d4c5ca4b
以下内容为反编译后的 dv.java 源代码,内容仅作参考
package c.t.m.g;
import android.bluetooth.BluetoothManager;
import android.content.IntentFilter;
import android.hardware.Sensor;
import android.location.Location;
import android.location.LocationManager;
import android.net.wifi.ScanResult;
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.SystemClock;
import android.support.v4.os.EnvironmentCompat;
import android.telephony.CellLocation;
import android.text.TextUtils;
import android.util.Pair;
import android.util.SparseArray;
import c.t.m.g.dp;
import c.t.m.g.dr;
import c.t.m.g.du;
import c.t.m.g.dx;
import c.t.m.g.dz;
import c.t.m.g.eb;
import c.t.m.g.eu;
import com.tencent.map.geolocation.TencentDistanceListener;
import com.tencent.map.geolocation.TencentLocation;
import com.tencent.map.geolocation.TencentLocationListener;
import com.tencent.map.geolocation.TencentLocationManagerOptions;
import com.tencent.map.geolocation.TencentLocationRequest;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.LinkedBlockingQueue;
import org.eclipse.jdt.annotation.Nullable;
import org.json.JSONException;
public final class dv {
public static final TencentLocationListener a;
private static SparseArray<String> v;
private dr A;
private dx B;
private boolean C;
private du D;
private dt E;
private dp F;
private dw G;
private dz H;
private HandlerThread I;
private ea J;
private di K;
private ee L;
private ei M;
private ei N;
private ef O;
private final dg P;
private long Q;
private double S;
private double T;
private eu U;
private long V;
private String W;
private ch Y;
public eb f56c;
public volatile int d;
public dh e;
public TencentLocationListener f;
public List<TencentLocationListener> g;
public TencentLocation p;
public TencentDistanceListener q;
public eu s;
private HandlerThread w;
private a x;
private c y;
private Handler z;
public int b = 1;
public long h = 0;
public volatile boolean i = false;
public volatile long j = 0;
public volatile int k = 0;
public volatile double l = 0.0d;
public int m = 0;
public int n = 0;
public int o = 0;
private final Object R = new Object();
public final TencentLocationRequest r = TencentLocationRequest.create();
public int t = 404;
public int u = b.d;
private volatile boolean X = false;
static boolean c() {
return false;
}
static boolean v(dv dvVar) {
dvVar.X = true;
return true;
}
static ei w(dv dvVar) {
dvVar.M = null;
return null;
}
static long y(dv dvVar) {
dvVar.h = 0L;
return 0L;
}
static {
SparseArray<String> sparseArray = new SparseArray<>();
v = sparseArray;
sparseArray.put(0, "OK");
v.put(1, "ERROR_NETWORK");
v.put(2, "ERROR_NO_CELL&WIFI");
v.put(4, "DEFLECT_FAILED");
v.put(404, "ERROR_SERVER_NOT_LOCATION");
HashMap hashMap = new HashMap();
hashMap.put("https", "true");
hashMap.put("up_apps", "true");
hashMap.put("up_wifis", "true");
hashMap.put("start_daemon", "true");
hashMap.put("up_daemon_delay", "300000");
hashMap.put("gps_kalman", "false");
hashMap.put("min_wifi_scan_interval", "8000");
hashMap.put("collect_bles", "false");
hashMap.put("start_event_track", "false");
hashMap.put("f_coll_item", "2");
dd.a(hashMap);
a = new TencentLocationListener() {
@Override
public final void onStatusUpdate(String str, int i, String str2) {
}
@Override
public final void onLocationChanged(TencentLocation tencentLocation, int i, String str) {
}
};
}
public static final class b {
public static final int a = 1;
public static final int b = 2;
public static final int f58c = 3;
public static final int d = 4;
static {
int[] iArr = {1, 2, 3, 4};
}
}
public dv(dg dgVar) {
this.Y = null;
this.d = 0;
this.P = dgVar;
if (TencentLocationManagerOptions.isLoadLibraryEnabled()) {
try {
System.loadLibrary("tencentloc");
} catch (Throwable th) {
this.d = 3;
return;
}
}
this.e = this.P.b;
String d = j.d(this.e.g);
this.W = a(d);
if (TextUtils.isEmpty(this.W)) {
new StringBuilder("requestLocationUpdates: illegal key [").append(d).append("]");
this.d = 2;
return;
}
this.P.a(this);
this.K = dj.b();
this.J = new ea();
this.g = new LinkedList();
this.G = new dw(this.P);
this.H = new dz(this.P);
this.E = dt.a(dgVar.a);
if (Build.VERSION.SDK_INT >= 21) {
this.F = new dp(this.P.a);
}
this.C = Build.VERSION.SDK_INT >= 18;
if (this.C) {
this.A = null;
this.f56c = j();
this.B = !this.P.b() ? null : new dx(this.P);
du i = i();
this.D = i;
new Object[1][0] = i;
} else {
this.B = null;
this.f56c = j();
this.A = this.P.b() ? new dr(this.P) : null;
du i2 = i();
this.D = i2;
new Object[1][0] = i2;
}
try {
dd.a(this.P.a, "txsdk", this.P.b.d());
dd.a(this.W);
dd.a().a = (dc) this.P.h;
} catch (Throwable th2) {
}
int b2 = de.a().b("f_coll_item");
if (b2 == 1 || b2 == 2) {
this.Y = ch.a(this.P.a);
}
}
public final int a(TencentLocationRequest tencentLocationRequest, TencentLocationListener tencentLocationListener, Looper looper) {
if (this.d != 0) {
return this.d;
}
f();
if (this.e != null) {
this.e.m = System.currentTimeMillis();
}
this.t = 404;
this.s = null;
synchronized (this.R) {
this.f = tencentLocationListener;
}
if (this.e != null && "0123456789ABCDEF".equals(this.e.a())) {
this.P.a();
}
this.e.f = tencentLocationRequest.getQQ();
TencentLocationRequest.copy(this.r, tencentLocationRequest);
if (TextUtils.isEmpty(j.d(this.e.d))) {
this.e.d = tencentLocationRequest.getPhoneNumber();
}
this.e.l = Math.max(de.a().c("min_wifi_scan_interval"), tencentLocationRequest.getInterval());
this.j = tencentLocationRequest.getInterval();
this.u = b.a;
if (this.I != null) {
this.I.quit();
this.I = null;
}
a(looper);
return 0;
}
public final TencentLocation a() {
if (this.t == 0) {
a(this.s);
return this.s;
}
return null;
}
public final void a(eu euVar) {
if (euVar != null) {
if (this.E != null && this.r.isAllowDirection()) {
euVar.getExtra().putDouble(TencentLocation.EXTRA_DIRECTION, this.E.a());
}
try {
euVar.getExtra().putAll(this.r.getExtras());
} catch (Exception e) {
}
}
}
public final void b() {
e();
try {
if (this.w != null) {
if (this.x != null) {
this.x.a();
this.x = null;
}
this.w.quit();
this.w = null;
}
} catch (Throwable th) {
}
synchronized (this.R) {
this.f = null;
}
if (this.K != null) {
this.K.a();
}
f();
if (de.a().d("start_daemon") && this.u == b.a && fa.c(this.P).equalsIgnoreCase("{}")) {
this.I = new HandlerThread("daemon_thread");
this.I.start();
this.u = b.b;
a(this.I.getLooper());
this.V = System.currentTimeMillis();
}
this.u = b.d;
}
private void e() {
ev.a = false;
if (this.G != null) {
dw dwVar = this.G;
if (dwVar.b) {
dwVar.b = false;
try {
dwVar.a.a.unregisterReceiver(dwVar);
} catch (Exception e) {
}
}
}
if (this.H != null) {
dz dzVar = this.H;
if (dzVar.g) {
dzVar.g = false;
dzVar.a.clear();
dzVar.a.offer(dz.a.d);
if (dzVar.f != 0) {
String.format(Locale.ENGLISH, "shutdown: duration=%ds, sent=%dB, recv=%dB, reqCount=%d", Long.valueOf((SystemClock.elapsedRealtime() - dzVar.f) / 1000), Long.valueOf(dzVar.d), Long.valueOf(dzVar.e), Long.valueOf(dzVar.f60c));
}
dzVar.f60c = 0L;
dzVar.d = 0L;
dzVar.e = 0L;
dzVar.f = 0L;
}
}
if (this.J != null) {
this.J.a();
}
if (this.f56c != null) {
eb ebVar = this.f56c;
synchronized (ebVar.j) {
if (ebVar.a) {
ebVar.a = false;
try {
ebVar.b.a.unregisterReceiver(ebVar);
} catch (Exception e2) {
}
ebVar.f64c = null;
if (ebVar.g != null) {
ebVar.g.clear();
}
if (ebVar.f64c != null) {
ebVar.f64c.clear();
}
if (ebVar.f != null) {
ebVar.f.removeCallbacksAndMessages(null);
ebVar.f = null;
}
if (ebVar.e != null) {
ebVar.e.removeCallbacksAndMessages(null);
ebVar.e = null;
}
}
}
}
if (this.C) {
if (this.B != null) {
dx dxVar = this.B;
if (dxVar.a) {
dxVar.a = false;
dxVar.a(0);
synchronized (dxVar) {
if (dxVar.d != null) {
dxVar.d.removeCallbacksAndMessages(null);
dxVar.d = null;
}
if (dxVar.f59c != null) {
dxVar.f59c.quit();
dxVar.f59c = null;
}
dxVar.b = null;
if (dxVar.g != null) {
dxVar.g = null;
}
}
}
}
} else {
if (this.A != null) {
dr drVar = this.A;
if (drVar.a) {
drVar.a = false;
drVar.a(0);
synchronized (drVar) {
if (drVar.h != null) {
drVar.h.removeCallbacksAndMessages(null);
drVar.h = null;
}
}
drVar.g.quit();
drVar.g = null;
drVar.f53c = null;
drVar.d = null;
drVar.e = null;
drVar.f = 0L;
}
}
}
if (this.D != null) {
du duVar = this.D;
if (duVar.j) {
duVar.j = false;
duVar.f55c = 0L;
duVar.b = 1024;
duVar.d = false;
duVar.e = false;
duVar.h = 0;
duVar.g = 0;
duVar.f = 0;
duVar.i.clear();
duVar.m = -1L;
duVar.k = false;
Arrays.fill(duVar.r, 0.0d);
duVar.a.b(duVar);
LocationManager locationManager = duVar.a.g;
try {
locationManager.removeGpsStatusListener(duVar);
} catch (Exception e3) {
}
try {
locationManager.removeUpdates(duVar);
} catch (Exception e4) {
}
duVar.n = null;
}
}
if ((this.E != null) && this.r.isAllowDirection()) {
dt dtVar = this.E;
if (dtVar.b && dtVar.f54c) {
dtVar.f54c = false;
dtVar.d = Double.NaN;
dtVar.a.unregisterListener(dtVar);
}
}
if (this.F != null) {
dp dpVar = this.F;
if (dpVar.e && dpVar.f != null) {
dpVar.f.sendEmptyMessage(2000);
}
}
if (this.X) {
dd.a().c();
this.X = false;
}
if (this.Y != null) {
ch chVar = this.Y;
if (chVar.a == null || !chVar.a.a) {
return;
}
cl clVar = chVar.a;
if (!clVar.a) {
return;
}
clVar.a = false;
try {
cl.a(clVar.j);
cl.a(clVar.i);
cl.a(clVar.f);
cl.a(clVar.g);
cl.a(clVar.h);
if (clVar.b != null && clVar.b.isAlive()) {
clVar.b.quit();
clVar.b = null;
}
clVar.f30c = null;
} catch (Throwable th) {
}
clVar.a();
}
}
private void f() {
this.k = 0;
this.M = null;
this.L = null;
this.O = null;
this.Q = 0L;
eg.a = 0;
if (Build.VERSION.SDK_INT >= 12) {
this.P.a(TencentLocationListener.CELL).a();
}
if (this.e == null) {
return;
}
this.e.p = "";
this.e.o = 0L;
this.e.n = 0L;
this.e.m = 0L;
}
public void a(int i, eu euVar) {
if (euVar != null) {
if (i == 0 && euVar.getLatitude() != 0.0d && euVar.getLongitude() != 0.0d) {
eu.a(euVar, (this.b == 1 && ew.a(euVar.getLatitude(), euVar.getLongitude())) ? 1 : 0);
}
if (g()) {
if (euVar.getAccuracy() < 5000.0f && euVar.getAccuracy() > 0.0f) {
this.J.a((TencentLocation) euVar);
if (this.i) {
this.p = euVar;
}
}
this.S = euVar.getLatitude();
this.T = euVar.getLongitude();
if ((this.f != null) && this.r.getInterval() > 0) {
a(11999, this.r.getInterval());
}
} else if (i == 0 && euVar.getLatitude() != 0.0d && euVar.getLongitude() != 0.0d && Math.abs(euVar.getLatitude() - this.S) >= 1.0E-8d && Math.abs(euVar.getLongitude() - this.T) >= 1.0E-8d) {
if (!this.J.a(euVar, this.P, this.D.c())) {
new StringBuilder("discard ").append(euVar);
return;
}
this.S = euVar.getLatitude();
this.T = euVar.getLongitude();
if (euVar.getAccuracy() < 5000.0f && euVar.getAccuracy() > 0.0f) {
this.J.a(euVar);
this.J.a((TencentLocation) euVar);
if (this.i) {
if (this.p != null) {
double a2 = j.a(this.p.getLatitude(), this.p.getLongitude(), euVar.getLatitude(), euVar.getLongitude());
if ((euVar.getProvider().equalsIgnoreCase(TencentLocation.NETWORK_PROVIDER) && a2 > 10.0d) || (euVar.getProvider().equalsIgnoreCase("gps") && a2 > 3.0d)) {
this.l = a2 + this.l;
if (euVar.getProvider().equalsIgnoreCase(TencentLocation.NETWORK_PROVIDER)) {
this.n++;
} else {
this.m++;
}
this.o++;
this.p = euVar;
}
} else {
this.p = euVar;
}
}
}
}
boolean z = this.t != 0 && i == 0;
this.t = i;
this.s = euVar;
if (this.r.getInterval() == 0) {
if ((this.f != null) && "gps" != this.s.getProvider()) {
a(11998);
return;
}
}
if (z) {
if (this.f != null) {
a(11998);
}
}
}
}
public boolean g() {
return this.t == 404;
}
public boolean h() {
return this.D != null && this.D.c() && this.D.b();
}
public final void a(int i) {
if (this.x != null) {
this.x.sendEmptyMessage(i);
}
}
private void a(int i, long j) {
if (this.x != null) {
this.x.removeMessages(i);
this.x.sendEmptyMessageDelayed(i, j);
}
}
public final void onStatusEvent(Message message) {
int i = message.what;
a(message.arg1, message.arg2);
}
public final void onNetworkEvent(Integer num) {
String str;
int c2 = j.c(this.P.a);
if (c2 != -1) {
if (c2 == 0) {
str = "mobile";
} else if (c2 == 1) {
str = TencentLocationListener.WIFI;
}
switch (num.intValue()) {
case -1:
default:
return;
case 0:
new StringBuilder("onNetworkEvent: ").append(str).append(" disconnected");
return;
case 1:
new StringBuilder("onNetworkEvent: ").append(str).append(" connected");
a(7999, 1000L);
return;
}
}
str = "none";
switch (num.intValue()) {
}
}
private void a(int i, int i2) {
String str;
String str2 = null;
switch (i) {
case 12001:
str = TencentLocationListener.WIFI;
switch (i2) {
case 0:
str2 = "wifi disabled";
break;
case 1:
str2 = "wifi enabled";
break;
case 2:
case 3:
case 4:
default:
str2 = EnvironmentCompat.MEDIA_UNKNOWN;
break;
case 5:
str2 = "location service switch is off";
break;
}
if (i2 != 5 && fa.a) {
str2 = "location permission denied";
i2 = 2;
break;
}
break;
case 12002:
str = "gps";
switch (i2) {
case 0:
str2 = "gps disabled";
break;
case 1:
str2 = "gps enabled";
break;
default:
str2 = EnvironmentCompat.MEDIA_UNKNOWN;
break;
}
case 12003:
str = TencentLocationListener.CELL;
if (i2 == 1) {
str2 = "cell enabled";
} else {
str2 = i2 == 0 ? "cell disabled" : EnvironmentCompat.MEDIA_UNKNOWN;
}
if (ev.a) {
str2 = "location permission denied";
i2 = 2;
break;
}
break;
case 12004:
str = "gps";
switch (i2) {
case 3:
str2 = "gps available";
break;
case 4:
str2 = "gps unavailable";
break;
default:
str2 = EnvironmentCompat.MEDIA_UNKNOWN;
break;
}
default:
str = null;
break;
}
Message obtainMessage = this.y.obtainMessage(3102);
Bundle data = obtainMessage.getData();
if (data == null) {
data = new Bundle();
}
data.clear();
data.putString("name", str);
data.putInt("status", i2);
data.putString("desc", str2);
obtainMessage.setData(data);
obtainMessage.sendToTarget();
}
public final void a(eu euVar, int i, int i2) {
if (euVar != null && this.y != null) {
Message obtainMessage = this.y.obtainMessage(i2);
Bundle data = obtainMessage.getData();
if (data == null) {
data = new Bundle();
}
data.clear();
data.putInt("error_code", i);
data.putParcelable("tx_location", euVar);
obtainMessage.setData(data);
obtainMessage.sendToTarget();
}
}
public class a extends Handler {
private int a;
private long b;
private boolean f57c;
private boolean d;
private int e;
a(Looper looper) {
super(looper);
this.e = 0;
this.b = 0L;
this.f57c = false;
this.d = false;
}
public final void a() {
this.e = 0;
removeCallbacksAndMessages(null);
}
@Override
public final void handleMessage(Message message) {
synchronized (dv.this.R) {
if (dv.this.f != null || dv.this.u != b.a) {
TencentLocationListener tencentLocationListener = dv.this.f;
TencentLocationRequest tencentLocationRequest = dv.this.r;
int requestLevel = tencentLocationRequest.getRequestLevel();
long j = dv.this.j;
try {
switch (message.what) {
case 554:
Bundle data = message.getData();
if (data != null) {
String string = data.getString("WIFIS");
if (!TextUtils.isEmpty(string)) {
dz dzVar = dv.this.H;
try {
if (!TextUtils.isEmpty(string)) {
byte[] a = j.a(string.getBytes("UTF-8"));
com.tencent.tencentmap.lbssdk.service.e.o(a, 2);
dz.a aVar = new dz.a(3, a, "http://ue.indoorloc.map.qq.com/?wl", null);
aVar.b = string;
dzVar.a(aVar);
return;
}
return;
} catch (Throwable th) {
return;
}
}
return;
}
return;
case 555:
dv.w(dv.this);
sendEmptyMessage(3999);
return;
case 3997:
eg m = dv.m(dv.this);
String a2 = m.a(requestLevel, dv.this.W, dv.this.P, false, false, false);
if (!(!j.e(a2))) {
dv.this.H.a(a2, m, dv.this.b);
return;
} else {
b(2);
return;
}
case 3999:
break;
case 4998:
if (dv.this.e.n == 0) {
dv.this.e.n = -1L;
}
b(1);
dv.this.Q = -1L;
return;
case 4999:
if (dv.this.e.n == 0) {
dv.this.e.n = System.currentTimeMillis() - dv.this.e.m;
}
removeMessages(4998);
Pair pair = (Pair) message.obj;
String obj = pair.first.toString();
dz.a aVar2 = (dz.a) pair.second;
eg egVar = (eg) aVar2.a;
dv.this.N = egVar.b;
String str = aVar2.b;
String str2 = egVar.a() ? "gps" : TencentLocation.NETWORK_PROVIDER;
try {
eu.a aVar3 = new eu.a();
aVar3.a = obj;
aVar3.f78c = requestLevel;
aVar3.d = str2;
eu a3 = aVar3.a();
a3.getExtra().putString(TencentLocation.EXTRA_RESP_JSON, obj);
if (a3.isMockGps() == 1) {
this.d = true;
}
eu.a(a3);
dv.this.Q = System.currentTimeMillis();
boolean z = !TextUtils.isEmpty(a3.getIndoorBuildingId());
if (z && dv.this.k == 1) {
dv.this.f56c.a(0L);
dv.this.f56c.i = 4000L;
if (dv.this.r.getInterval() > 4000) {
dv.this.j = 4000L;
}
dv.this.k = 2;
this.e = 0;
}
if (dv.this.k == 2) {
if (z) {
dv.this.a(a3, 0, 3101);
} else {
this.e++;
}
if (this.e >= 5) {
dv.this.f56c.i = dv.this.e.l;
new StringBuilder("indoor stop,").append(dv.this.r.getInterval());
dv.this.j = dv.this.r.getInterval();
dv.this.k = 1;
this.e = 0;
}
}
eu.a(a3, z);
dv.this.a(0, a3);
a(0);
dv.this.U = a3;
if (dv.this.u == b.a && !dv.this.X) {
dd.a().b();
dv.v(dv.this);
return;
}
return;
} catch (JSONException e) {
b(404);
return;
}
case 7999:
if (!dv.this.g()) {
long max = Math.max(dv.this.r.getInterval(), 4000L);
if (dv.this.Q == 0 || System.currentTimeMillis() - dv.this.Q < max) {
return;
}
} else {
return;
}
break;
case 11998:
if (dv.this.s != null && tencentLocationListener != null) {
dv.this.a(dv.this.s);
dv.this.a(dv.this.s, dv.this.t, 3101);
a(dv.this.s, "direct");
return;
}
return;
case 11999:
if (dv.this.s != null && tencentLocationRequest.getInterval() > 0 && tencentLocationListener != null && !dv.this.h()) {
dv.this.a(dv.this.s);
dv.this.a(dv.this.s, dv.this.t, 3101);
a(dv.this.s, "timed");
}
if (j > 0) {
sendEmptyMessageDelayed(11999, j);
return;
}
return;
default:
return;
}
removeMessages(3999);
if (dv.this.u != b.b) {
dv.c();
} else {
long c2 = de.a().c("up_daemon_delay");
if (c2 < 120000) {
c2 = 120000;
}
new StringBuilder("the daemonLocation,so we delay long time upload:").append(c2).append(",").append(System.currentTimeMillis()).append(",").append(dv.this.V);
if (System.currentTimeMillis() - dv.this.V >= c2) {
dv.this.V = System.currentTimeMillis();
} else {
return;
}
}
int i = dv.this.b;
eg m2 = dv.m(dv.this);
if (m2.a() && System.currentTimeMillis() - this.b > 60000) {
this.f57c = true;
this.d = false;
this.b = System.currentTimeMillis();
} else {
this.f57c = false;
}
String a4 = m2.a(requestLevel, dv.this.W, dv.this.P, this.f57c, this.d, dv.this.u == b.b);
if (!j.e(a4)) {
this.a++;
if (this.a >= 2) {
b(2);
this.a = 0;
return;
}
return;
}
this.a = 0;
if (dv.this.u == b.a) {
ej.b();
}
if (ej.a) {
dv.this.H.a(a4, m2, i);
di unused = dv.this.K;
System.currentTimeMillis();
}
} catch (Throwable th2) {
}
}
}
}
private void a(int i) {
if (dv.this.g != null) {
if (dv.this.t == 0) {
dv.this.a(dv.this.s, dv.this.t, 3103);
} else {
dv.this.a(eu.a, i, 3103);
}
dv.y(dv.this);
if (dv.this.u == b.f58c) {
dv.this.b();
}
}
}
private void b(int i) {
double d;
double d2 = 0.0d;
Location a = dv.this.D.a();
if (a == ds.a || dv.this.Q != 0 || System.currentTimeMillis() - a.getTime() > 120000) {
if (dv.this.t != 0 || dv.this.s == null || System.currentTimeMillis() - dv.this.s.getTime() >= 60000) {
dv.this.a(i, eu.a);
a(i);
return;
}
a(0);
return;
}
Location location = new Location(a);
Bundle extras = location.getExtras();
if (extras != null) {
d = extras.getDouble("lat");
d2 = extras.getDouble("lng");
} else {
d = 0.0d;
}
eu.a aVar = new eu.a();
aVar.d = TencentLocation.NETWORK_PROVIDER;
eu a2 = aVar.a(a).a();
if (dv.this.b == 1) {
location.setLatitude(d);
location.setLongitude(d2);
a2.a(location);
}
if (!dv.this.h()) {
dv.this.a(0, a2);
}
a(0);
}
private static void a(eu euVar, String str) {
String.format("%s,%.6f,%.6f,%.1f", str, Double.valueOf(euVar.getLatitude()), Double.valueOf(euVar.getLongitude()), Float.valueOf(euVar.getAccuracy()));
}
}
public class c extends Handler {
public c(Looper looper) {
super(looper);
}
@Override
public final void handleMessage(Message message) {
TencentLocationListener tencentLocationListener;
Bundle data = message.getData();
if (data != null) {
switch (message.what) {
case 3101:
case 3103:
int i = data.getInt("error_code");
eu euVar = eu.a;
if (i == 0) {
euVar = (eu) data.getParcelable("tx_location");
}
if (message.what == 3101) {
synchronized (dv.this.R) {
tencentLocationListener = dv.this.f;
}
if (tencentLocationListener != null) {
tencentLocationListener.onLocationChanged(euVar, i, (String) dv.v.get(i));
}
if (dv.this.i && dv.this.q != null) {
dv.this.q.onDistanceChanged(euVar, j.a(dv.this.l / 1000.0d, 2), i, (String) dv.v.get(i));
return;
}
return;
} else if (message.what == 3103 && dv.this.g != null) {
for (TencentLocationListener tencentLocationListener2 : dv.this.g) {
tencentLocationListener2.onLocationChanged(euVar, i, (String) dv.v.get(i));
}
dv.this.g.clear();
return;
} else {
return;
}
case 3102:
String string = data.getString("name");
int i2 = data.getInt("status");
String string2 = data.getString("desc");
synchronized (dv.this.R) {
if (dv.this.f != null) {
dv.this.f.onStatusUpdate(string, i2, string2);
}
}
return;
default:
return;
}
}
}
}
@Nullable
private du i() {
if (!(this.P.g != null)) {
return null;
}
return new du(this.P);
}
@Nullable
private eb j() {
if (!(this.P.f != null)) {
return null;
}
return new eb(this.P);
}
private static String a(String str) {
boolean z = true;
try {
if (str.contains(",")) {
String[] split = str.split(",");
if (split == null || split.length <= 1 || split[0] == null || split[1] == null || com.tencent.tencentmap.lbssdk.service.e.w(split[0], split[1]) <= 0) {
z = false;
}
return z ? split[0] : "";
}
int v2 = com.tencent.tencentmap.lbssdk.service.e.v(str);
return v2 >= 0 ? Integer.toString(v2) : "";
} catch (UnsatisfiedLinkError e) {
return null;
}
}
private void a(Looper looper) {
ee a2;
if (Looper.myLooper() == null) {
Looper.prepare();
}
if (this.y == null) {
this.y = new c(looper);
}
this.y.removeCallbacksAndMessages(null);
if (this.y.getLooper() != looper) {
this.y = new c(looper);
}
if (this.z == null || this.z.getLooper() != Looper.getMainLooper()) {
this.z = new Handler(Looper.getMainLooper());
}
e();
if (this.w == null) {
this.w = new HandlerThread("loc_inner_thread");
this.w.start();
this.x = new a(this.w.getLooper());
}
if (this.x != null) {
this.x.a();
}
boolean z = this.r.getExtras().getBoolean("use_network", true);
boolean z2 = b.b == this.u;
final a aVar = this.x;
final dz dzVar = this.H;
if (!dzVar.g) {
dzVar.g = true;
dzVar.h = z2;
dzVar.b.f43c.execute(new Runnable() {
@Override
public final void run() {
byte[] b2;
dzVar.a.clear();
dz dzVar2 = dzVar;
Handler handler = aVar;
a aVar2 = null;
LinkedBlockingQueue<a> linkedBlockingQueue = dzVar2.a;
while (true) {
a aVar3 = aVar2;
if (dzVar2.g) {
try {
aVar2 = linkedBlockingQueue.take();
try {
} catch (IOException e) {
new StringBuilder("cost:").append(System.currentTimeMillis() - 0).append(",run: io error");
dzVar2.b(aVar2);
handler.sendEmptyMessageDelayed(4998, 0L);
} catch (InterruptedException e2) {
}
} catch (IOException e3) {
aVar2 = aVar3;
} catch (InterruptedException e4) {
aVar2 = aVar3;
}
if (a.d == aVar2) {
return;
}
new StringBuilder("request:").append(aVar2.b);
long currentTimeMillis = System.currentTimeMillis();
dg dgVar = dzVar2.b;
String str = aVar2.g;
byte[] bArr = aVar2.f;
System.currentTimeMillis();
Bundle b3 = dgVar.h.b(str, bArr);
System.currentTimeMillis();
byte[] c2 = j.c(b3.getByteArray("data_bytes"));
String str2 = "{}";
if (c2 != null) {
str2 = new String(c2, b3.getString("data_charset"));
}
b3.remove("data_charset");
b3.remove("data_bytes");
b3.putString("result", str2);
String string = b3.getString("result");
long currentTimeMillis2 = System.currentTimeMillis() - currentTimeMillis;
new StringBuilder("cost:").append(currentTimeMillis2).append("request:").append(string);
dzVar2.f60c++;
dzVar2.d += aVar2.f.length;
dzVar2.e += j.b(string.getBytes()) != null ? b2.length : 0;
Message obtainMessage = handler.obtainMessage();
obtainMessage.arg1 = (int) currentTimeMillis2;
aVar2.f61c = currentTimeMillis;
if (!dzVar2.h && 1 == aVar2.e) {
obtainMessage.obj = Pair.create(string, aVar2);
obtainMessage.what = 4999;
obtainMessage.sendToTarget();
}
if (aVar2.e == 1 && dzVar2.b.b.o == 0) {
dzVar2.b.b.o = currentTimeMillis2;
dzVar2.b.b.p = b3.getString("req_key");
}
} else {
return;
}
}
}
});
dzVar.f = SystemClock.elapsedRealtime();
}
if (this.C) {
if (z) {
if (this.B != null) {
dx dxVar = this.B;
if (!dxVar.a) {
dxVar.f = aVar;
if (dxVar.g == null) {
dxVar.g = new ArrayList();
}
dxVar.f59c = new HandlerThread("new_cell_provider");
if (dxVar.f59c != null) {
try {
dxVar.f59c.start();
dxVar.d = new dx.a(dxVar, dxVar.f59c.getLooper(), (byte) 0);
} catch (Throwable th) {
dxVar.d = new dx.a(dxVar, dxVar.f.getLooper(), (byte) 0);
}
dxVar.d.post(dxVar.e);
if (!z2) {
dxVar.d.sendEmptyMessage(0);
}
}
}
}
}
} else if (z) {
if (this.A != null) {
dr drVar = this.A;
if (!drVar.a) {
drVar.a = true;
drVar.g = new HandlerThread("CellProvider");
drVar.g.start();
drVar.h = new dr.a(drVar, drVar.g.getLooper(), (byte) 0);
drVar.h.sendEmptyMessageDelayed(0, 3000L);
CellLocation a3 = ev.a(drVar.b);
if (drVar.a(a3) && (a2 = ee.a(drVar.b, a3, null)) != null) {
drVar.f53c = a3;
drVar.b.c(a2);
}
drVar.a(273);
}
}
}
if (z) {
if (this.f56c != null) {
this.f56c.i = this.e.l;
eb ebVar = this.f56c;
c cVar = this.y;
if (!ebVar.a) {
ebVar.a = true;
eb.d = z2;
ebVar.e = aVar;
if (ebVar.f == null || ebVar.f.getLooper() != aVar.getLooper()) {
if (ebVar.f != null) {
ebVar.f.removeCallbacksAndMessages(null);
}
ebVar.f = new eb.a(aVar.getLooper());
}
cVar.post(ebVar.h);
if (!eb.d) {
ebVar.a(0L);
}
}
}
}
if ((this.D != null) && this.r.isAllowGPS()) {
this.D.k = this.b == 1;
du duVar = this.D;
c cVar2 = this.y;
Handler handler = this.z;
long interval = this.r.getInterval();
if (!duVar.j) {
duVar.j = true;
duVar.l = Math.max(interval, 1000L);
if (duVar.n == null || duVar.n.getLooper() != cVar2.getLooper()) {
duVar.n = new du.a(cVar2.getLooper());
}
if (!z2) {
aVar.post(duVar.o);
handler.post(duVar.p);
} else {
aVar.post(duVar.q);
}
if (duVar.c()) {
duVar.b = 4;
duVar.d();
}
}
}
if (z2) {
dz dzVar2 = this.H;
String d = this.P.d();
try {
if (!TextUtils.isEmpty(d)) {
byte[] a4 = j.a(d.getBytes("UTF-8"));
com.tencent.tencentmap.lbssdk.service.e.o(a4, 2);
dz.a aVar2 = new dz.a(2, a4, "http://ue.indoorloc.map.qq.com/", null);
aVar2.b = d;
dzVar2.a(aVar2);
}
} catch (Throwable th2) {
}
} else {
if (!de.a().d("collect_bles")) {
this.F = null;
}
if (this.F != null) {
dp dpVar = this.F;
dpVar.g = new HandlerThread("bluetooth_provider");
dpVar.g.start();
dpVar.h = dpVar.g.getLooper();
dpVar.f = new dp.a(dpVar.h);
dpVar.b = (BluetoothManager) dpVar.a.getSystemService("bluetooth");
try {
dpVar.f51c = dpVar.b.getAdapter();
if (dpVar.f51c != null) {
dpVar.d = dpVar.f51c.getBluetoothLeScanner();
}
} catch (Throwable th3) {
th3.toString();
}
dpVar.f.sendEmptyMessage(1000);
}
dw dwVar = this.G;
if (!dwVar.b) {
dwVar.b = true;
try {
dwVar.a.a.registerReceiver(dwVar, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"), null, aVar);
} catch (Exception e) {
}
}
if ((this.E != null) && this.r.isAllowDirection()) {
dt dtVar = this.E;
if (dtVar.b && !dtVar.f54c) {
try {
Sensor defaultSensor = dtVar.a.getDefaultSensor(11);
if (defaultSensor != null) {
dtVar.a.registerListener(dtVar, defaultSensor, 3, aVar);
dtVar.f54c = true;
}
} catch (Error e2) {
} catch (Exception e3) {
}
}
}
}
if (this.Y != null) {
int b2 = de.a().b("f_coll_item");
new StringBuilder("fc:").append(ch.a()).append(",set:").append(b2).append(",daemon:").append(z2);
if (b2 == 2 || (b2 == 1 && !z2)) {
ch chVar = this.Y;
String f = this.e.f();
if (chVar.a != null) {
cm.a(chVar.a.d).f = f;
}
ch chVar2 = this.Y;
if (chVar2.a != null) {
cl clVar = chVar2.a;
if (!clVar.a) {
clVar.a = true;
clVar.a();
try {
clVar.b = new HandlerThread("F_C");
clVar.b.start();
clVar.f30c = clVar.b == null ? null : clVar.b.getLooper();
if (clVar.f30c != null) {
new Handler(clVar.f30c).post(clVar.e);
}
} catch (Throwable th4) {
clVar.f30c = null;
}
}
}
}
}
}
public final void onCellInfoEvent(ee eeVar) {
int i;
List<ScanResult> list;
this.L = eeVar;
long max = Math.max(this.r.getInterval(), 20000L);
List<ScanResult> emptyList = Collections.emptyList();
if (this.f56c != null) {
i = this.f56c.a() ? 0 : 1;
} else {
i = 1;
}
if (i != 0) {
this.M = null;
}
if (i == 1 || this.P == null) {
list = emptyList;
} else {
list = fa.c(this.P.f);
list.size();
}
if (i == 1 || list.size() == 0 || this.Q == -1 || (this.Q > 0 && System.currentTimeMillis() - this.Q > max)) {
a(3999);
}
new StringBuilder("cell change run prepare json,because status:").append(i).append(",mLastWF:").append(this.Q).append(",current:").append(System.currentTimeMillis());
}
public final void onWifiInfoEvent(ei eiVar) {
boolean z;
List<ScanResult> list;
boolean z2 = false;
if (this.N != null) {
ei eiVar2 = this.N;
if (eiVar != null) {
List<ScanResult> list2 = eiVar.b;
List<ScanResult> list3 = eiVar2.b;
if (list2.size() != 0 && list3.size() != 0) {
int size = list2.size();
int size2 = list3.size();
if (size == 0 && size2 == 0) {
z = true;
} else if (size == 0 || size2 == 0) {
z = false;
} else {
if (list2.size() > list3.size()) {
list = list2;
} else {
list = list3;
list3 = list2;
}
int i = 0;
for (ScanResult scanResult : list3) {
Iterator<ScanResult> it = list.iterator();
while (true) {
if (it.hasNext()) {
if (it.next().BSSID.equals(scanResult.BSSID)) {
i++;
break;
}
} else {
break;
}
}
}
int i2 = size + size2;
z = ((double) (i << 1)) < ((double) i2) * 0.85d || i < 13;
new StringBuilder("isDiffrent:c=").append(size).append(",k=").append(i).append(",f=").append(i2).append(",r=0.85,s=").append(z);
}
if (!z) {
z2 = true;
}
}
}
}
if (z2) {
this.Q = System.currentTimeMillis();
}
if (this.M == null || this.k == 2 || eiVar == ei.a || this.Q == -1 || Collections.unmodifiableList(eiVar.b).size() < 3 || !z2) {
a(3999);
}
this.M = eiVar;
}
public final void onGpsInfoEvent(ef efVar) {
double d;
eu a2;
double d2 = 0.0d;
if (efVar.a == ds.a) {
return;
}
this.O = efVar;
int i = this.b;
int requestLevel = this.r.getRequestLevel();
eu euVar = this.U;
Location location = new Location(efVar.a);
Bundle extras = location.getExtras();
if (extras != null) {
d = extras.getDouble("lat");
d2 = extras.getDouble("lng");
} else {
d = 0.0d;
}
if (i == 0) {
eu.a aVar = new eu.a();
aVar.b = euVar;
aVar.d = "gps";
aVar.f78c = requestLevel;
a2 = aVar.a(new Location(efVar.a)).a();
location.setLatitude(d);
location.setLongitude(d2);
a2.a(location);
a(0, a2);
} else {
if (g()) {
a(3999);
}
eu.a aVar2 = new eu.a();
aVar2.b = euVar;
aVar2.d = "gps";
aVar2.f78c = requestLevel;
a2 = aVar2.a(new Location(efVar.a)).a();
location.setLatitude(d);
location.setLongitude(d2);
a2.a(location);
a(0, a2);
}
if (this.k != 2 && a2 != null) {
a(a2, 0, 3101);
}
a(12004, 3);
if (this.D != null) {
this.D.b();
}
}
static eg m(dv dvVar) {
ei eiVar = dvVar.M;
ee eeVar = dvVar.L;
ef efVar = dvVar.O;
ef efVar2 = (efVar == null || dvVar.h()) ? efVar : null;
if (eeVar == null) {
dg dgVar = dvVar.P;
eeVar = ee.a(dgVar, ev.a(dgVar), null);
if (!ev.a(eeVar)) {
eeVar = null;
}
}
if (eiVar != null) {
if (!(System.currentTimeMillis() - eiVar.f69c < 60000)) {
eiVar = null;
}
}
if (eeVar != null && efVar2 != null && Build.VERSION.SDK_INT >= 12) {
int i = eeVar.d;
int i2 = eeVar.e;
Location location = efVar2.a;
Bundle bundle = new Bundle();
bundle.putString("cellkey", new StringBuilder().append(i).append(i2).toString());
bundle.putParcelable("location", location);
if (!dvVar.P.a(TencentLocationListener.CELL).b(bundle)) {
new StringBuilder("getFromLastKnownInfo: discard bad cell(").append(i).append(",").append(i2).append(")");
eeVar = null;
}
}
return new eg(eiVar, eeVar, efVar2, dvVar.F != null ? dvVar.F.a() : null);
}
}