Mi Love v2.1.19版本的 MD5 值为:359343d6da08b606640b0d6b4dd9d399

以下内容为反编译后的 ft.java 源代码,内容仅作参考


package c.t.m.g;

import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Pair;
import com.alibaba.sdk.android.oss.common.utils.HttpHeaders;
import com.bumptech.glide.load.Key;
import com.tencent.map.geolocation.util.SoUtils;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Iterator;
import java.util.Locale;
import java.util.concurrent.LinkedBlockingQueue;
public class ft {
    private static ft j;
    private final LinkedBlockingQueue<a> a = new LinkedBlockingQueue<>(3);
    private final ey b;
    private long f81c;
    private long d;
    private long e;
    private long f;
    private volatile boolean g;
    private boolean h;
    private volatile Handler i;

    public static ft a(ey eyVar) {
        if (j == null) {
            synchronized (ft.class) {
                if (j == null) {
                    j = new ft(eyVar);
                }
            }
        }
        return j;
    }

    private ft(ey eyVar) {
        this.b = eyVar;
    }

    public void a(String str) {
        try {
            if (TextUtils.isEmpty(str)) {
                return;
            }
            byte[] b = hc.b(str.getBytes(Key.STRING_CHARSET_NAME));
            if (gw.a) {
                gw.a("hh", "postWifisRequest fun_o");
            }
            SoUtils.fun_o(b, 2);
            if (gw.a) {
                gw.a("hh", "postWifisRequest fun_d");
            }
            a aVar = new a(3, b, "https://ue.indoorloc.map.qq.com/?wl", null);
            aVar.b = str;
            a(aVar);
        } catch (Throwable th) {
            if (gw.a) {
                gw.a("TxRequestSender", "", th);
            }
        }
    }

    public void a(String str, gb gbVar, int i) {
        try {
            if (gw.a) {
                gw.b("TxRequestSender", str);
            }
            byte[] a2 = hd.a(str.getBytes("GBK"));
            String a3 = a(a2, i);
            if (gw.a) {
                gw.b("TxRequestSender", "postLocationRequest url = " + a3);
            }
            a aVar = new a(1, a2, a3, gbVar);
            aVar.b = str;
            a(aVar);
        } catch (Throwable th) {
            if (gw.a) {
                gw.a("TxRequestSender", "", th);
            }
        }
    }

    private boolean a(a aVar) {
        String str;
        boolean offer = aVar.f != null ? this.a.offer(aVar) : false;
        if (!offer) {
            this.a.clear();
            this.a.offer(aVar);
            if (aVar.e == 2) {
                str = "List";
            } else {
                str = aVar.e == 3 ? "Wifis" : HttpHeaders.LOCATION;
            }
            if (gw.a) {
                gw.b("TxRequestSender", "post" + str + "Request: failed to add request,because the queue has full,so we delete the first");
            }
        }
        return offer;
    }

    public void a(Handler handler, boolean z) {
        if (this.g) {
            return;
        }
        this.g = true;
        this.i = handler;
        this.h = z;
        this.b.i().execute(new Runnable() {
            @Override
            public void run() {
                ft.this.a.clear();
                ft.this.c();
            }
        });
        this.f = SystemClock.elapsedRealtime();
    }

    public void a() {
        if (this.g) {
            this.g = false;
            this.a.clear();
            this.a.offer(a.d);
            this.i = null;
            if (this.f != 0) {
                String format = String.format(Locale.ENGLISH, "shutdown: duration=%ds, sent=%dB, recv=%dB, reqCount=%d", Long.valueOf((SystemClock.elapsedRealtime() - this.f) / 1000), Long.valueOf(this.d), Long.valueOf(this.e), Long.valueOf(this.f81c));
                if (gw.a) {
                    gw.a("TxRequestSender", format);
                }
            }
            b();
        }
    }

    private void b() {
        this.f81c = 0L;
        this.d = 0L;
        this.e = 0L;
        this.f = 0L;
    }

    public void c() {
        long j2;
        a take;
        LinkedBlockingQueue<a> linkedBlockingQueue = this.a;
        a aVar = null;
        while (this.g) {
            try {
                take = linkedBlockingQueue.take();
                try {
                    try {
                    } catch (IOException e) {
                        e = e;
                        j2 = 0;
                    }
                } catch (InterruptedException e2) {
                    e = e2;
                    aVar = take;
                    if (gw.a) {
                        gw.a("TxRequestSender", "run: thread is interrupted", e);
                    }
                } catch (Throwable th) {
                    th = th;
                    aVar = take;
                    if (gw.a) {
                        gw.a("TxRequestSender", "run: other exception.", th);
                    }
                }
            } catch (IOException e3) {
                e = e3;
                j2 = 0;
            } catch (InterruptedException e4) {
                e = e4;
            } catch (Throwable th2) {
                th = th2;
            }
            if (a.d == take) {
                if (gw.a) {
                    gw.a("TxRequestSender", "run: state=[shutdown]");
                    return;
                }
                return;
            }
            j2 = System.currentTimeMillis();
            try {
                Bundle a2 = this.b.a(take.g, take.f, true);
                String string = a2.getString("result");
                long currentTimeMillis = System.currentTimeMillis() - j2;
                gw.a("cost:" + currentTimeMillis + ",result:" + string);
                if (string == null) {
                    string = "";
                }
                a(take, string);
                Handler handler = this.i;
                take.f82c = j2;
                if (!this.h && this.g && handler != null && handler.getLooper().getThread().isAlive()) {
                    Message obtainMessage = handler.obtainMessage();
                    obtainMessage.arg1 = (int) currentTimeMillis;
                    a(string, take, obtainMessage);
                }
                if (take.e == 1 && this.b.h().m() == 0) {
                    this.b.h().c(currentTimeMillis);
                    this.b.h().i(a2.getString("req_key"));
                }
                aVar = take;
            } catch (IOException e5) {
                e = e5;
                aVar = take;
                long currentTimeMillis2 = System.currentTimeMillis() - j2;
                if (gw.a) {
                    gw.a("TxRequestSender", "cost:" + currentTimeMillis2 + ",run: io error", e);
                }
                b(aVar);
                if (gw.a) {
                    gw.b("TxRequestSender", "Send timeout");
                }
                Handler handler2 = this.i;
                Looper looper = handler2 == null ? null : handler2.getLooper();
                if (looper != null && looper.getThread().isAlive()) {
                    handler2.sendEmptyMessageDelayed(4998, 0L);
                }
            }
        }
    }

    private void a(a aVar, String str) throws FileNotFoundException, IOException {
        byte[] a2;
        this.f81c++;
        this.d += aVar.f.length;
        this.e += hd.a(str.getBytes(Key.STRING_CHARSET_NAME)) != null ? a2.length : 0;
    }

    private void b(a aVar) {
        boolean z;
        a.d(aVar);
        Iterator<a> it = this.a.iterator();
        while (true) {
            if (!it.hasNext()) {
                z = false;
                break;
            } else if (it.next().e == aVar.e) {
                z = true;
                break;
            }
        }
        if (aVar.h <= 0 || z) {
            return;
        }
        if (gw.a) {
            gw.a("TxRequestSender", "retryIfNeed: times=" + aVar.h);
        }
        this.a.offer(aVar);
    }

    private void a(String str, a aVar, Message message) {
        if (gw.a) {
            gw.b("TxRequestSender", "handleResponse");
        }
        if (1 == aVar.e) {
            if (gw.a) {
                gw.b("TxRequestSender", "handleResponse result: " + str);
            }
            message.obj = Pair.create(str, aVar);
            message.what = 4999;
            message.sendToTarget();
        }
    }

    private String a(byte[] bArr, int i) {
        boolean a2 = gh.a();
        try {
            if (gw.a) {
                gw.a("hh", "obfuscate fun_o");
            }
            if (!a2 && bArr != null && SoUtils.fun_o(bArr, 1) >= 0) {
                return fm.a(1, i, 1);
            }
            return fm.a(1, i, 0);
        } catch (UnsatisfiedLinkError unused) {
            return null;
        }
    }

    public static class a {
        public static final a d = new a();
        final Object a;
        public String b;
        public long f82c;
        private final int e;
        private final byte[] f;
        private final String g;
        private int h;

        static int d(a aVar) {
            int i = aVar.h;
            aVar.h = i - 1;
            return i;
        }

        private a() {
            this.h = 1;
            this.e = 0;
            this.f = null;
            this.g = null;
            this.a = null;
        }

        a(int i, byte[] bArr, String str, Object obj) {
            this.h = 1;
            this.e = i;
            this.f = bArr;
            this.g = str;
            this.a = obj;
        }
    }
}