package c.t.m.g; import android.location.Location; import android.os.Handler; import android.os.Looper; import android.os.Message; import com.meizu.cloud.pushsdk.constants.PushConstants; import java.util.Locale; import java.util.concurrent.atomic.AtomicInteger; /* compiled from: TML */ public class f extends av { /* renamed from: c reason: collision with root package name */ private volatile Handler f2236c; private volatile a d = new a(); private StringBuilder e = new StringBuilder(); private AtomicInteger f = new AtomicInteger(0); @Override // c.t.m.g.av public void a(Message message) throws Exception { String sb2; if (message.what == 1001) { bp.b(d(), PushConstants.PUSHSERVICE_INFO_SEND_MESSAGE_BY_BROADCAST); bp.a(d(), (int) PushConstants.PUSHSERVICE_INFO_SEND_MESSAGE_BY_BROADCAST, 5000); int i = this.f.get(); synchronized (this.b) { sb2 = this.e.toString(); this.e.setLength(0); this.f.set(0); } if (sb2.length() > 0 && this.f2236c != null) { this.d.a(sb2, i); bp.a(this.f2236c, this.d); } } } @Override // c.t.m.g.ay public String b() { return "GpsNaviPro"; } /* compiled from: TML */ public static class a implements ap, Runnable { /* renamed from: a reason: collision with root package name */ private volatile String f2237a; private volatile int b; private a() { } public void a(String str, int i) { if (by.a(str)) { this.f2237a = ""; } else { this.f2237a = str; } this.b = i; } @Override // c.t.m.g.ap public void b(String str) { if (bt.a()) { bt.a("GpsNaviPro", "upload fail:" + str); } } public void run() { try { if (!by.a(this.f2237a)) { byte[] bytes = this.f2237a.getBytes("UTF-8"); this.f2237a = ""; a(bytes); } } catch (Throwable th2) { if (bt.a()) { bt.a("GpsNaviPro", "upload error.", th2); } } } private void a(byte[] bArr) { byte[] a5 = bf.a(bArr); byte[] a12 = bd.a(a5.length); byte[] bArr2 = new byte[(a12.length + 1 + a5.length)]; bArr2[0] = 1; System.arraycopy(a12, 0, bArr2, 1, a12.length); System.arraycopy(a5, 0, bArr2, a12.length + 1, a5.length); byte[] a13 = bj.a(bArr2, bj.a("fc_gps_for_navi")); if (bt.a()) { StringBuilder h12 = a.f.h("start upload:strBytes="); h12.append(bArr.length); h12.append(",encBytes="); h12.append(a13.length); bt.a("GpsNaviPro", h12.toString()); } aq.f1960a.a("https://rttgpsreport.map.qq.com/report?type=sdk&key=5e1fe70424035ee83066ac22b24f31dc", a13, this); } @Override // c.t.m.g.ap public void a(String str) { StringBuilder h12 = a.f.h("NaviGps,"); h12.append(this.b); bt.d("FC", h12.toString()); if (bt.a()) { bt.a("GpsNaviPro", "upload success:" + str); } } } @Override // c.t.m.g.ay public int a(Looper looper) { bp.a(d(), (int) PushConstants.PUSHSERVICE_INFO_SEND_MESSAGE_BY_BROADCAST, 5000); this.f2236c = new Handler(bn.a("th_loc_task_t_consume").getLooper()); this.e.setLength(0); this.f.set(0); return 0; } @Override // c.t.m.g.ay public void a() { this.e.setLength(0); this.f.set(0); this.d.a("", 0); this.f2236c = null; bn.b("th_loc_task_t_consume"); } public void a(int i, Location location) { String str; synchronized (this.b) { if (this.e.length() > 5120) { this.e.setLength(0); this.f.set(0); } if (this.e.length() > 0) { this.e.append('\n'); } a aVar = j.j; if (by.a(aVar.a())) { str = "null"; } else { str = "loc_" + aVar.a(); } this.e.append(String.format(Locale.ENGLISH, "%s,%d,%d,%.6f,%.6f,%.3f,%.3f,%.3f,%.3f,%d,%d,%d,%d,%d,%d,%d,%s,%s,%s", cb.d(), 12, Integer.valueOf(i), Double.valueOf(location.getLatitude()), Double.valueOf(location.getLongitude()), Double.valueOf(location.getAltitude()), Float.valueOf(location.getAccuracy()), Float.valueOf(location.getBearing()), Float.valueOf(location.getSpeed()), Long.valueOf(location.getTime() / 1000), 2, 0, 2, 2, 1, 0, "null", str, "null")); this.f.getAndAdd(1); } } }