package sd2; import com.tencent.mm.R; import com.tencent.mm.sdk.http.HttpWrapperBase; import com.tencent.mm.sdk.platformtools.LocaleUtil; import com.tencent.mm.sdk.platformtools.Log; import com.tencent.mm.sdk.platformtools.MMApplicationContext; import com.tencent.mm.sdk.platformtools.QueueWorkerThread; import com.tencent.mm.sdk.platformtools.Util; import com.tencent.mm.sdk.platformtools.WeChatHosts; import com.tencent.mm.vfs.VFSStrategy; import com.tencent.mm.vfs.h0; import com.tencent.mm.vfs.n2; import com.tencent.mm.vfs.o2; import com.tencent.mm.vfs.u1; import d60.z; import gh.g; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import jr0.b; import ju3.c; import ju3.e; import yf0.n; import yf0.y; public class r implements n { /* renamed from: j reason: collision with root package name */ public static final String f300839j = (HttpWrapperBase.PROTOCAL_HTTPS + WeChatHosts.domainString(R.string.fyl) + "/api?size=%d*%d¢er=%f,%f&zoom=%d&referer=weixin"); /* renamed from: d reason: collision with root package name */ public QueueWorkerThread f300840d = new QueueWorkerThread(1, "location_worker"); /* renamed from: e reason: collision with root package name */ public LinkedList<e> f300841e = new LinkedList<>(); /* renamed from: f reason: collision with root package name */ public e f300842f = null; /* renamed from: g reason: collision with root package name */ public List<c> f300843g = new ArrayList(); /* renamed from: h reason: collision with root package name */ public int f300844h = 300; /* renamed from: i reason: collision with root package name */ public int f300845i = 300; public class a implements QueueWorkerThread.ThreadObject { /* renamed from: d reason: collision with root package name */ public byte[] f300846d; /* renamed from: e reason: collision with root package name */ public String f300847e = ""; /* renamed from: f reason: collision with root package name */ public boolean f300848f; /* renamed from: g reason: collision with root package name */ public int f300849g; /* renamed from: h reason: collision with root package name */ public int f300850h; /* renamed from: i reason: collision with root package name */ public String f300851i; public a(boolean z15, String str, String str2) { this.f300848f = z15; this.f300849g = r.this.f300844h; this.f300850h = r.this.f300845i; this.f300847e = str; while (true) { int i15 = this.f300849g; int i16 = this.f300850h; if (i15 * i16 > 270000) { this.f300849g = (int) (((double) i15) / 1.2d); this.f300850h = (int) (((double) i16) / 1.2d); } else { this.f300851i = str2; Log.i("MicroMsg.StaticMapServer", "get url %s %s", str, Util.nullAs(str2, "")); return; } } } @Override // com.tencent.mm.sdk.platformtools.QueueWorkerThread.ThreadObject public boolean doInBackground() { byte[] httpGet = Util.httpGet(this.f300847e); this.f300846d = httpGet; if (httpGet == null) { return true; } u1.S(this.f300851i, httpGet, 0, httpGet.length); return true; } @Override // com.tencent.mm.sdk.platformtools.QueueWorkerThread.ThreadObject public boolean onPostExecute() { boolean z15; StringBuilder sb5 = new StringBuilder(); sb5.append("http onPostExecute "); if (this.f300846d == null) { z15 = true; } else { z15 = false; } sb5.append(z15); sb5.append(" isGoole: "); sb5.append(this.f300848f); Log.i("MicroMsg.StaticMapServer", sb5.toString()); if (this.f300846d != null) { r rVar = r.this; String str = r.f300839j; rVar.b(true, 0); return false; } else if (this.f300848f) { r rVar2 = r.this; if (rVar2.f300842f == null) { rVar2.b(false, 0); return false; } String format = String.format(r.f300839j, Integer.valueOf(this.f300849g), Integer.valueOf(this.f300850h), Float.valueOf(r.this.f300842f.f243386b), Float.valueOf(r.this.f300842f.f243385a), Integer.valueOf(r.this.f300842f.f243387c)); this.f300847e = format; r rVar3 = r.this; rVar3.f300840d.add(new a(false, format, r.a(rVar3.f300842f))); return false; } else { r rVar4 = r.this; String str2 = r.f300839j; rVar4.b(false, 0); return false; } } } public r() { z.d().a(b.CTRL_INDEX, this); } public static String a(e eVar) { String f15 = g.f((eVar.toString() + "").getBytes()); String str = VFSStrategy.b("StaticMap") + '/' + f15.charAt(0) + f15.charAt(1) + "/" + f15.charAt(3) + f15.charAt(4) + "/"; if (!u1.k(str)) { n2 a15 = n2.a(str); String str2 = a15.f189021f; if (str2 != null) { String k15 = o2.k(str2, false, false); if (!a15.f189021f.equals(k15)) { a15 = new n2(a15.f189019d, a15.f189020e, k15, a15.f189022g, a15.f189023h); } } h0.h l15 = h0.i.f188954a.l(a15, null); if (l15.a()) { l15.f188951a.i(l15.f188952b); } } return str + "static_map_" + f15; } public final void b(boolean z15, int i15) { Log.i("MicroMsg.StaticMapServer", "httpgetStaticmapDone %b", Boolean.valueOf(z15)); if (z15) { if (this.f300842f != null) { Iterator it = ((ArrayList) this.f300843g).iterator(); while (it.hasNext()) { c cVar = (c) it.next(); if (cVar != null) { cVar.b(a(this.f300842f), this.f300842f); } } } } else if (this.f300842f != null) { Iterator it4 = ((ArrayList) this.f300843g).iterator(); while (it4.hasNext()) { c cVar2 = (c) it4.next(); if (cVar2 != null) { cVar2.a(this.f300842f); } } } this.f300842f = null; d(); } public void c(c cVar) { ((ArrayList) this.f300843g).remove(cVar); Log.i("MicroMsg.StaticMapServer", "removeCallback " + ((ArrayList) this.f300843g).size()); if (((ArrayList) this.f300843g).size() == 0) { Log.i("MicroMsg.StaticMapServer", "clean task"); this.f300841e.clear(); this.f300842f = null; Log.i("MicroMsg.StaticMapServer", "stop static map server"); z.d().p(b.CTRL_INDEX, this); } } public final void d() { int i15; if (this.f300842f == null && this.f300841e.size() > 0) { this.f300842f = this.f300841e.removeFirst(); try { i15 = Integer.valueOf(Util.nullAs(((jt3.b) z.q(jt3.b.class)).gv0().d("StaticMapGetClient"), "")).intValue(); } catch (Exception unused) { i15 = 0; } Log.i("MicroMsg.StaticMapServer", "run local %d", Integer.valueOf(i15)); if (i15 == 0) { e eVar = this.f300842f; z.d().f(new l(eVar.f243385a, eVar.f243386b, eVar.f243387c + 1, 0, this.f300844h, this.f300845i, a(eVar), LocaleUtil.getApplicationLanguage())); return; } int i16 = this.f300844h; int i17 = this.f300845i; while (i16 * i17 > 270000) { i16 = (int) (((double) i16) / 1.2d); i17 = (int) (((double) i17) / 1.2d); } if (Util.isOverseasUser(MMApplicationContext.getContext())) { this.f300840d.add(new a(true, String.format("https://maps.googleapis.com/maps/api/staticmap?size=%dx%d¢er=%f,%f&zoom=%d&format=jpg&language=%s&sensor=true", Integer.valueOf(i16), Integer.valueOf(i17), Float.valueOf(this.f300842f.f243385a), Float.valueOf(this.f300842f.f243386b), Integer.valueOf(this.f300842f.f243387c), LocaleUtil.getApplicationLanguage()), a(this.f300842f))); return; } this.f300840d.add(new a(false, String.format(f300839j, Integer.valueOf(i16), Integer.valueOf(i17), Float.valueOf(this.f300842f.f243386b), Float.valueOf(this.f300842f.f243385a), Integer.valueOf(this.f300842f.f243387c)), a(this.f300842f))); } } @Override // yf0.n public void onSceneEnd(int i15, int i16, String str, y yVar) { if (yVar.getType() != 648) { return; } if (i15 == 0 && i16 == 0 && this.f300842f != null) { b(true, i15); } else { b(false, i15); } } }