package com.baidu.location.g; import android.os.Message; import android.text.TextUtils; import com.baidu.location.Address; import com.baidu.location.BDLocation; import com.baidu.location.Jni; import com.baidu.location.b.f; import com.baidu.location.b.k; import com.baidu.location.b.l; import com.baidu.location.b.m; import com.baidu.location.b.o; import com.baidu.location.e.d; import com.baidu.location.h.c; import com.baidu.location.h.h; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.Date; import org.apache.http.util.EntityUtils; import org.json.JSONObject; public class b implements f { private static SimpleDateFormat ji = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); long je = 0; h jf = null; private l jg = new l(); com.baidu.location.h.f jh = null; boolean jj = false; a jk = null; class a extends m { BDLocation e1 = null; public a(BDLocation bDLocation) { this.e1 = bDLocation; } /* access modifiers changed from: package-private */ public void aT() { ar(); } @Override // com.baidu.location.b.m public void at() { try { this.c9 = k.Z() + "?&x=" + this.e1.getLongitude() + "&y=" + this.e1.getLatitude() + "&r=100&prodname=searchbox" + "&addr=" + URLEncoder.encode("country|country_code|province|city|city_code|street|street_number|district", "UTF-8"); } catch (UnsupportedEncodingException e2) { this.c9 = k.Z() + "?&x=" + this.e1.getLongitude() + "&y=" + this.e1.getLatitude() + "&r=100"; } } /* JADX WARNING: Code restructure failed: missing block: B:45:0x00cb, code lost: if (android.text.TextUtils.isEmpty(r0) == false) goto L_0x00cd; */ /* JADX WARNING: Removed duplicated region for block: B:14:0x0043 A[Catch:{ Exception -> 0x018d }] */ /* JADX WARNING: Removed duplicated region for block: B:19:0x0058 A[Catch:{ Exception -> 0x018d }] */ /* JADX WARNING: Removed duplicated region for block: B:24:0x006d A[Catch:{ Exception -> 0x018d }] */ /* JADX WARNING: Removed duplicated region for block: B:29:0x0082 A[Catch:{ Exception -> 0x018d }] */ /* JADX WARNING: Removed duplicated region for block: B:34:0x0097 A[Catch:{ Exception -> 0x018d }] */ /* JADX WARNING: Removed duplicated region for block: B:39:0x00ac A[Catch:{ Exception -> 0x018d }] */ /* JADX WARNING: Removed duplicated region for block: B:44:0x00c1 A[Catch:{ Exception -> 0x018d }] */ @Override // com.baidu.location.b.m /* renamed from: int reason: not valid java name */ public void m366int(boolean z) { String str; String str2; String str3; String str4; String str5; String str6; String str7; String str8; if (!z || this.da == null) { if (b.this.jk.cw()) { double[] dArr = Jni.m11if(b.this.jk.ct(), b.this.jk.cs(), "gps2gcj"); this.e1.setCoorType("gcj02"); this.e1.setLongitude(dArr[0]); this.e1.setLatitude(dArr[1]); } Message obtainMessage = com.baidu.location.e.m.bf().fX.obtainMessage(21); obtainMessage.obj = this.e1; obtainMessage.sendToTarget(); return; } try { JSONObject jSONObject = new JSONObject(EntityUtils.toString(this.da, "utf-8")); if (jSONObject.has("addr")) { JSONObject jSONObject2 = jSONObject.getJSONObject("addr"); if (jSONObject2.has("country")) { String string = jSONObject2.getString("country"); if (!TextUtils.isEmpty(string)) { str = string; if (jSONObject2.has("country_code")) { String string2 = jSONObject2.getString("country_code"); if (!TextUtils.isEmpty(string2)) { str2 = string2; if (jSONObject2.has("province")) { String string3 = jSONObject2.getString("province"); if (!TextUtils.isEmpty(string3)) { str3 = string3; if (jSONObject2.has("city")) { String string4 = jSONObject2.getString("city"); if (!TextUtils.isEmpty(string4)) { str4 = string4; if (jSONObject2.has("city_code")) { String string5 = jSONObject2.getString("city_code"); if (!TextUtils.isEmpty(string5)) { str5 = string5; if (jSONObject2.has("district")) { String string6 = jSONObject2.getString("district"); if (!TextUtils.isEmpty(string6)) { str6 = string6; if (jSONObject2.has("street")) { String string7 = jSONObject2.getString("street"); if (!TextUtils.isEmpty(string7)) { str7 = string7; if (jSONObject2.has("street_number")) { str8 = jSONObject2.getString("street_number"); } str8 = null; this.e1.setAddr(new Address.Builder().country(str).countryCode(str2).province(str3).city(str4).cityCode(str5).district(str6).street(str7).streetNumber(str8).build()); } } str7 = null; if (jSONObject2.has("street_number")) { } str8 = null; this.e1.setAddr(new Address.Builder().country(str).countryCode(str2).province(str3).city(str4).cityCode(str5).district(str6).street(str7).streetNumber(str8).build()); } } str6 = null; if (jSONObject2.has("street")) { } str7 = null; if (jSONObject2.has("street_number")) { } str8 = null; this.e1.setAddr(new Address.Builder().country(str).countryCode(str2).province(str3).city(str4).cityCode(str5).district(str6).street(str7).streetNumber(str8).build()); } } str5 = null; if (jSONObject2.has("district")) { } str6 = null; if (jSONObject2.has("street")) { } str7 = null; if (jSONObject2.has("street_number")) { } str8 = null; this.e1.setAddr(new Address.Builder().country(str).countryCode(str2).province(str3).city(str4).cityCode(str5).district(str6).street(str7).streetNumber(str8).build()); } } str4 = null; if (jSONObject2.has("city_code")) { } str5 = null; if (jSONObject2.has("district")) { } str6 = null; if (jSONObject2.has("street")) { } str7 = null; if (jSONObject2.has("street_number")) { } str8 = null; this.e1.setAddr(new Address.Builder().country(str).countryCode(str2).province(str3).city(str4).cityCode(str5).district(str6).street(str7).streetNumber(str8).build()); } } str3 = null; if (jSONObject2.has("city")) { } str4 = null; if (jSONObject2.has("city_code")) { } str5 = null; if (jSONObject2.has("district")) { } str6 = null; if (jSONObject2.has("street")) { } str7 = null; if (jSONObject2.has("street_number")) { } str8 = null; this.e1.setAddr(new Address.Builder().country(str).countryCode(str2).province(str3).city(str4).cityCode(str5).district(str6).street(str7).streetNumber(str8).build()); } } str2 = null; if (jSONObject2.has("province")) { } str3 = null; if (jSONObject2.has("city")) { } str4 = null; if (jSONObject2.has("city_code")) { } str5 = null; if (jSONObject2.has("district")) { } str6 = null; if (jSONObject2.has("street")) { } str7 = null; if (jSONObject2.has("street_number")) { } str8 = null; this.e1.setAddr(new Address.Builder().country(str).countryCode(str2).province(str3).city(str4).cityCode(str5).district(str6).street(str7).streetNumber(str8).build()); } } str = null; if (jSONObject2.has("country_code")) { } str2 = null; if (jSONObject2.has("province")) { } str3 = null; if (jSONObject2.has("city")) { } str4 = null; if (jSONObject2.has("city_code")) { } str5 = null; if (jSONObject2.has("district")) { } str6 = null; if (jSONObject2.has("street")) { } str7 = null; if (jSONObject2.has("street_number")) { } str8 = null; this.e1.setAddr(new Address.Builder().country(str).countryCode(str2).province(str3).city(str4).cityCode(str5).district(str6).street(str7).streetNumber(str8).build()); } if (b.this.jk.cw()) { double[] dArr2 = Jni.m11if(b.this.jk.ct(), b.this.jk.cs(), "gps2gcj"); this.e1.setCoorType("gcj02"); this.e1.setLongitude(dArr2[0]); this.e1.setLatitude(dArr2[1]); } Message obtainMessage2 = com.baidu.location.e.m.bf().fX.obtainMessage(21); obtainMessage2.obj = this.e1; obtainMessage2.sendToTarget(); } catch (Exception e2) { } } } /* access modifiers changed from: package-private */ /* renamed from: com.baidu.location.g.b$b reason: collision with other inner class name */ public class C0009b extends m { public C0009b() { } @Override // com.baidu.location.b.m public void at() { } /* access modifiers changed from: package-private */ public void h(String str) { this.f2043de = str; au(); } @Override // com.baidu.location.b.m /* renamed from: int reason: not valid java name */ public void m367int(boolean z) { b.this.jg.m88for(System.currentTimeMillis()); if (!z || this.da == null) { BDLocation bDLocation = new BDLocation(); bDLocation.setLocType(63); d.bv().m270try(bDLocation); return; } try { String entityUtils = EntityUtils.toString(this.da, "utf-8"); b.this.jk = new a(entityUtils); if (b.this.jj && b.this.jk.cr()) { BDLocation bDLocation2 = new BDLocation(); bDLocation2.setLongitude(b.this.jk.ct()); bDLocation2.setLatitude(b.this.jk.cs()); bDLocation2.setRadius(b.this.jk.cu()); bDLocation2.setLocType(161); bDLocation2.setLocationWhere(0); bDLocation2.setCoorType("wgs84"); bDLocation2.setNetworkLocationType("sky"); String str = b.this.jk.i5; String str2 = b.this.jk.i4; String str3 = b.this.jk.i8; String str4 = b.this.jk.jd; String str5 = b.this.jk.ja; new Address.Builder().country(str).province(str2).city(str3).district(str4).street(str5).streetNumber(b.this.jk.i2).build(); bDLocation2.setTime(b.ji.format(new Date())); bDLocation2.setOperators(c.a().cP()); if (com.baidu.location.e.b.a6().a9()) { bDLocation2.setDirection(com.baidu.location.e.b.a6().a5()); } if (b.this.jk.cw()) { double[] dArr = Jni.m11if(b.this.jk.ct(), b.this.jk.cs(), "gps2gcj"); bDLocation2.setCoorType("gcj02"); bDLocation2.setLongitude(dArr[0]); bDLocation2.setLatitude(dArr[1]); } Message obtainMessage = com.baidu.location.e.m.bf().fX.obtainMessage(21); obtainMessage.obj = bDLocation2; obtainMessage.sendToTarget(); b.this.jg.m91int(System.currentTimeMillis()); b.this.jg.m85char(l.c4); if (b.this.jf != null) { b.this.jg.m87else(b.this.jf.dv()); } o.aX().m108if(b.this.jg); } else if (b.this.jj && !b.this.jk.cr()) { BDLocation bDLocation3 = new BDLocation(); bDLocation3.setLocType(167); d.bv().m270try(bDLocation3); b.this.jg.m91int(System.currentTimeMillis()); b.this.jg.m85char(l.c1); if (b.this.jf != null) { b.this.jg.m87else(b.this.jf.dv()); } o.aX().m108if(b.this.jg); } } catch (Exception e3) { } } } public b() { } public b(h hVar, com.baidu.location.h.f fVar, boolean z) { this.jf = hVar; this.jh = fVar; this.jj = z; this.jg.ai(); long currentTimeMillis = System.currentTimeMillis(); this.jg.m86do(currentTimeMillis); this.jg.m90if(currentTimeMillis); } public void cy() { String str = null; StringBuffer stringBuffer = new StringBuffer(1024); String i = (this.jh == null || this.jh.dj() <= 1) ? null : this.jh.i(15); if (this.jf != null && this.jf.dq()) { str = this.jf.du(); } if (i != null || str != null) { stringBuffer.append("<LocationRQ xmlns=\"http://skyhookwireless.com/wps/2005\"\nversion=\"2.21\"\nstreet-address-lookup=\"full\">\n<authentication version=\"2.2\">\n<key key=\"" + Jni.dE() + "\"\n" + "username=\"BAIDULOC\"/></authentication>\n"); if (i != null) { stringBuffer.append(i); } if (str != null) { stringBuffer.append(str); } stringBuffer.append("</LocationRQ>"); new C0009b().h(stringBuffer.toString()); this.je = System.currentTimeMillis(); } } }