京东到家.apk(点击下载) / f.java


package c.t.m.g;

import android.location.Location;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicInteger;
import net.lingala.zip4j.crypto.PBKDF2.BinTools;

/* compiled from: TML */
public class f extends av {

    /* renamed from: c  reason: collision with root package name */
    private volatile Handler f158c = null;
    private volatile a d = new a();
    private StringBuilder e = new StringBuilder();
    private AtomicInteger f = new AtomicInteger(0);

    @Override // c.t.m.g.ay
    public String b() {
        return "GpsNaviPro";
    }

    @Override // c.t.m.g.av
    public void a(Message message) throws Exception {
        String sb;
        if (message.what == 1001) {
            bq.b(d(), 1001);
            bq.a(d(), 1001, 5000);
            int i = this.f.get();
            synchronized (this.b) {
                sb = this.e.toString();
                this.e.setLength(0);
                this.f.set(0);
            }
            if (sb.length() > 0 && this.f158c != null) {
                this.d.a(sb, i);
                bq.a(this.f158c, this.d);
            }
        }
    }

    @Override // c.t.m.g.ay
    public int a(Looper looper) {
        bq.a(d(), 1001, 5000);
        this.f158c = new Handler(bo.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.f158c = null;
        bo.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');
            }
            if (bz.a(j.j.a())) {
                str = "null";
            } else {
                str = "loc_" + j.j.a();
            }
            String f2 = cc.f();
            if (bz.a(f2) || BinTools.hex.equals(f2)) {
                f2 = cc.b();
            }
            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", f2, 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);
        }
    }

    /* compiled from: TML */
    static class a implements ap, Runnable {
        private volatile String a;
        private volatile int b;

        private a() {
            this.b = 0;
        }

        public void a(String str, int i) {
            if (bz.a(str)) {
                this.a = "";
            } else {
                this.a = str;
            }
            this.b = i;
        }

        public void run() {
            try {
                if (!bz.a(this.a)) {
                    byte[] bytes = this.a.getBytes("UTF-8");
                    this.a = "";
                    a(bytes);
                }
            } catch (Throwable th) {
                if (bu.a()) {
                    bu.a("GpsNaviPro", "upload error.", th);
                }
            }
        }

        private void a(byte[] bArr) {
            byte[] a2 = bg.a(bArr);
            byte[] a3 = be.a(a2.length);
            byte[] bArr2 = new byte[(a3.length + 1 + a2.length)];
            bArr2[0] = 1;
            System.arraycopy(a3, 0, bArr2, 1, a3.length);
            System.arraycopy(a2, 0, bArr2, a3.length + 1, a2.length);
            byte[] a4 = bk.a(bArr2, bk.a("fc_gps_for_navi"));
            if (bu.a()) {
                bu.a("GpsNaviPro", "start upload:strBytes=" + bArr.length + ",encBytes=" + a4.length);
            }
            ar.a.a("https://rttgpsreport.map.qq.com/report?type=sdk&key=5e1fe70424035ee83066ac22b24f31dc", a4, this);
        }

        @Override // c.t.m.g.ap
        public void a(String str) {
            bu.c("FC", "NaviGps," + this.b);
            if (bu.a()) {
                bu.a("GpsNaviPro", "upload success:" + str);
            }
        }

        @Override // c.t.m.g.ap
        public void b(String str) {
            if (bu.a()) {
                bu.a("GpsNaviPro", "upload fail:" + str);
            }
        }
    }
}