package com.tencent.mm.booter;

import android.bluetooth.BluetoothAdapter;
import android.os.Build.VERSION;
import android.os.Looper;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.g.a.ds;
import com.tencent.mm.m.g;
import com.tencent.mm.model.aw;
import com.tencent.mm.modelgeo.b.a;
import com.tencent.mm.modelgeo.d;
import com.tencent.mm.protocal.protobuf.atz;
import com.tencent.mm.sdk.b.c;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ap;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.storage.ac;
import com.tencent.ytcommon.BuildConfig;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;

public final class k {
    private static c ecA = new 3();
    private static d ecr;
    private static float ecs = -85.0f;
    private static float ect = -1000.0f;
    private static boolean ecu = false;
    private static Map<String, atz> ecv = new ConcurrentHashMap();
    private static List<atz> ecw = new CopyOnWriteArrayList();
    private static Boolean ecx = Boolean.FALSE;
    private static a ecy = new 1();
    private static ap ecz = new ap(Looper.getMainLooper(), new 2(), true);

    static {
        AppMethodBeat.i(15860);
        AppMethodBeat.o(15860);
    }

    public static void run() {
        AppMethodBeat.i(15859);
        if (!aw.RK() || aw.QT()) {
            AppMethodBeat.o(15859);
            return;
        }
        aw.ZK();
        Boolean valueOf = Boolean.valueOf(bo.a((Boolean) com.tencent.mm.model.c.Ry().get(ac.a.xMp, null), false));
        ab.i("MicroMsg.PostTaskStartRangeForIBeacon", "the range road status is ".concat(String.valueOf(valueOf)));
        if (valueOf.booleanValue()) {
            long anT = bo.anT();
            aw.ZK();
            long a = bo.a((Long) com.tencent.mm.model.c.Ry().get(ac.a.xMq, null), 0);
            aw.ZK();
            if (anT - a > bo.a((Long) com.tencent.mm.model.c.Ry().get(ac.a.xMk, null), 0)) {
                aw.ZK();
                com.tencent.mm.model.c.Ry().set(ac.a.xMp, Boolean.FALSE);
                aw.ZK();
                com.tencent.mm.model.c.Ry().set(ac.a.xMo, BuildConfig.FLAVOR);
                aw.ZK();
                com.tencent.mm.model.c.Ry().set(ac.a.xMn, BuildConfig.FLAVOR);
                aw.ZK();
                com.tencent.mm.model.c.QV();
                AppMethodBeat.o(15859);
                return;
            }
            BluetoothAdapter defaultAdapter = BluetoothAdapter.getDefaultAdapter();
            if (VERSION.SDK_INT < 18 || defaultAdapter == null || defaultAdapter.getState() != 12) {
                aw.ZK();
                com.tencent.mm.model.c.Ry().set(ac.a.xMn, BuildConfig.FLAVOR);
                AppMethodBeat.o(15859);
                return;
            }
            List<String> Nl = g.Nv().Nl();
            if (Nl != null) {
                for (String str : Nl) {
                    ab.i("MicroMsg.PostTaskStartRangeForIBeacon", "op=true,iBeacon = %s", new Object[]{str});
                    ds dsVar = new ds();
                    dsVar.cxg.cxi = str;
                    dsVar.cxg.cxf = true;
                    com.tencent.mm.sdk.b.a.xxA.m(dsVar);
                }
                ecr = d.agz();
                if (ecz.doT()) {
                    ecz.ae(3000, 3000);
                }
                if (!(ecu || ecr == null)) {
                    ecr.a(ecy, true);
                }
                com.tencent.mm.sdk.b.a.xxA.c(ecA);
            }
            AppMethodBeat.o(15859);
            return;
        }
        AppMethodBeat.o(15859);
    }
}
