得物.apk(点击下载) / h.java


package c.t.m.g;

import a.f;
import a0.b;
import a40.j;
import android.net.wifi.ScanResult;
import android.os.Looper;
import android.os.Message;
import android.util.Base64;
import androidx.core.view.accessibility.AccessibilityEventCompat;
import c.t.m.g.bv;
import com.shizhuang.duapp.modules.pay.R$styleable;
import h6.a;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/* compiled from: TML */
public class h extends av implements ao, Runnable {

    /* renamed from: c  reason: collision with root package name */
    private volatile boolean f2271c;
    private List<String> d = new ArrayList();
    private s e = new s(AccessibilityEventCompat.TYPE_VIEW_TEXT_SELECTION_CHANGED, 5);
    private volatile an f;

    /* renamed from: g  reason: collision with root package name */
    private File f2272g;

    /* renamed from: h  reason: collision with root package name */
    private String f2273h = "wf4_bf";
    private String i = "wf4";
    private StringBuilder j = new StringBuilder(100);

    public h(File file) {
        this.f2272g = file;
        if (bt.a()) {
            StringBuilder h12 = f.h("data dir:");
            h12.append(this.f2272g.getAbsolutePath());
            bt.a("WifiInfoPro", h12.toString());
        }
    }

    private void b(List<String> list) throws IOException {
        if (!(this.f2271c || by.a((Collection) list) || by.a(this.f))) {
            long length = this.f.b().length();
            if (bt.a()) {
                bt.a("WifiInfoPro", "wf file len:" + length);
            }
            if (length <= 51200) {
                StringBuilder k = j.k(500, "1|");
                k.append(list.size());
                for (String str : list) {
                    k.append('|');
                    k.append(str);
                }
                this.f.a(k.toString());
            }
            list.clear();
        }
    }

    public void a(List<ScanResult> list) {
        if (e() && !by.a((Collection) list)) {
            Message obtainMessage = d().obtainMessage(R$styleable.AppCompatTheme_textAppearanceListItemSecondary);
            obtainMessage.obj = list;
            a(obtainMessage, 0);
        }
    }

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

    public void run() {
        try {
            this.f2271c = true;
            if (this.f != null) {
                this.f.a();
                this.f = null;
            }
            final File file = new File(this.f2272g, this.i);
            if (bt.a()) {
                bt.a("WifiInfoPro", "upload:" + file.getName() + "," + file.length());
            }
            byte[] a5 = bf.a(bm.a(file));
            String str = j.f2279h ? "https://testdatalbs.sparta.html5.qq.com/tr?wf4" : "https://analytics.map.qq.com/?wf4";
            if (!j.e) {
                str = str.replace("https:", "http:");
            }
            j.k.a(str, a5, new ap() {
                /* class c.t.m.g.h.AnonymousClass1 */

                @Override // c.t.m.g.ap
                public void a(String str) {
                    file.delete();
                    if (bt.a()) {
                        bt.a("WifiInfoPro", "upload suc & del:" + str);
                    }
                }

                @Override // c.t.m.g.ap
                public void b(String str) {
                    if (bt.a()) {
                        bt.a("WifiInfoPro", "upload failed:" + str);
                    }
                }
            });
            if (e()) {
                this.f = new an(new File(this.f2272g, this.i));
                this.f.a(this);
            }
        } catch (Throwable th2) {
            this.f2271c = false;
            throw th2;
        }
        this.f2271c = false;
    }

    @Override // c.t.m.g.ay
    public int a(Looper looper) {
        a(100, 0);
        return 0;
    }

    @Override // c.t.m.g.ay
    public void a() {
        a(R$styleable.AppCompatTheme_textAppearanceListItem, 0);
    }

    /* JADX WARNING: Removed duplicated region for block: B:22:0x00a1  */
    /* JADX WARNING: Removed duplicated region for block: B:34:0x00d6  */
    /* JADX WARNING: Removed duplicated region for block: B:36:0x00fc A[RETURN] */
    /* JADX WARNING: Removed duplicated region for block: B:37:0x00fd  */
    @Override // c.t.m.g.av
    public void a(Message message) throws Exception {
        if (this.f2272g != null) {
            boolean z = false;
            switch (message.what) {
                case 100:
                    this.f = new an(new File(this.f2272g, this.i));
                    this.f.a(this);
                    byte[] a5 = bm.a(new File(this.f2272g, this.f2273h));
                    long longValue = ((Long) ca.b("LocationSDK", "log_fc_wf_bf_create_t_ms", (Object) 0L)).longValue();
                    long currentTimeMillis = System.currentTimeMillis();
                    if (currentTimeMillis - longValue >= 2592000000L || by.a(a5)) {
                        ca.a("LocationSDK", "log_fc_wf_bf_create_t_ms", Long.valueOf(currentTimeMillis));
                        bt.a("WifiInfoPro", "bf reset.");
                    } else {
                        this.e.a(a5);
                        bt.a("WifiInfoPro", "bf init.");
                    }
                    a(R$styleable.AppCompatTheme_textAppearanceListItemSmall, 300000);
                    bm.a(new File(this.f2272g, this.f2273h), this.e.a(), false);
                    a(R$styleable.AppCompatTheme_textAppearancePopupMenuHeader, 300000);
                    return;
                case R$styleable.AppCompatTheme_textAppearanceListItem /*{ENCODED_INT: 101}*/:
                    b(this.d);
                    bm.a(new File(this.f2272g, this.f2273h), this.e.a(), false);
                    if (this.f != null) {
                        this.f.a();
                        this.f = null;
                    }
                    if (e()) {
                        a(R$styleable.AppCompatTheme_textAppearanceListItemSmall, 1800000);
                    }
                    long currentTimeMillis2 = System.currentTimeMillis();
                    long longValue2 = ((Long) ca.b("LocationSDK", "log_fc_wf_up_t_ms", (Object) 0L)).longValue();
                    bv.a a12 = bv.a();
                    if (a12 == bv.a.NETWORK_WIFI || (a12 == bv.a.NETWORK_MOBILE && (j.f || j.f2278g))) {
                        z = true;
                    }
                    if (bt.a()) {
                        StringBuilder g3 = b.g("lastUpT:", longValue2, ",deltaT:");
                        g3.append(currentTimeMillis2 - longValue2);
                        g3.append(",network status:");
                        g3.append(a12);
                        g3.append(",isUpload:");
                        g3.append(z);
                        bt.a("WifiInfoPro", g3.toString());
                    }
                    if (!z) {
                        int i3 = (longValue2 > 0 ? 1 : (longValue2 == 0 ? 0 : -1));
                        if (i3 != 0 && currentTimeMillis2 - longValue2 >= 86400000) {
                            bn.a("th_loc_task_t_consume", this);
                            ca.a("LocationSDK", "log_fc_wf_up_t_ms", Long.valueOf(currentTimeMillis2));
                            return;
                        } else if (i3 == 0) {
                            ca.a("LocationSDK", "log_fc_wf_up_t_ms", Long.valueOf(currentTimeMillis2));
                            return;
                        } else {
                            return;
                        }
                    } else {
                        return;
                    }
                case R$styleable.AppCompatTheme_textAppearanceListItemSecondary /*{ENCODED_INT: 102}*/:
                    for (ScanResult scanResult : (List) message.obj) {
                        if (!this.e.b(scanResult.BSSID)) {
                            this.e.a(scanResult.BSSID);
                            this.d.add(a(scanResult));
                        }
                    }
                    if (bt.a()) {
                        StringBuilder h12 = f.h("wf list size:");
                        h12.append(this.d.size());
                        bt.a("WifiInfoPro", h12.toString());
                    }
                    if (this.d.size() >= 30) {
                        b(this.d);
                        return;
                    }
                    return;
                case R$styleable.AppCompatTheme_textAppearanceListItemSmall /*{ENCODED_INT: 103}*/:
                    if (e()) {
                    }
                    long currentTimeMillis22 = System.currentTimeMillis();
                    long longValue22 = ((Long) ca.b("LocationSDK", "log_fc_wf_up_t_ms", (Object) 0L)).longValue();
                    bv.a a122 = bv.a();
                    z = true;
                    if (bt.a()) {
                    }
                    if (!z) {
                    }
                    break;
                case R$styleable.AppCompatTheme_textAppearancePopupMenuHeader /*{ENCODED_INT: 104}*/:
                    bm.a(new File(this.f2272g, this.f2273h), this.e.a(), false);
                    a(R$styleable.AppCompatTheme_textAppearancePopupMenuHeader, 300000);
                    return;
                default:
                    return;
            }
        }
    }

    private String a(ScanResult scanResult) {
        this.j.setLength(0);
        try {
            StringBuilder sb2 = this.j;
            sb2.append(scanResult.BSSID);
            sb2.append(',');
            StringBuilder sb3 = this.j;
            sb3.append(Base64.encodeToString(scanResult.SSID.getBytes("UTF-8"), 2));
            sb3.append(',');
            StringBuilder sb4 = this.j;
            sb4.append(scanResult.frequency);
            sb4.append(',');
            this.j.append(Base64.encodeToString(scanResult.capabilities.getBytes("UTF-8"), 2));
        } catch (Throwable unused) {
            this.j.setLength(0);
        }
        return this.j.toString();
    }

    @Override // c.t.m.g.ao
    public byte[] a(byte[] bArr) {
        byte[] a5 = bj.a(bf.a(bArr), bj.a("fc_wf_up"));
        if (!by.a(a5)) {
            byte[] encode = Base64.encode(a5, 2);
            if (!by.a(encode)) {
                try {
                    return a.j(new String(encode), '$').getBytes("UTF-8");
                } catch (Throwable unused) {
                }
            }
        }
        return new byte[0];
    }
}