package com.tencent.mm.plugin.appbrand.i;

import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.kernel.g;
import com.tencent.mm.plugin.appbrand.i.e.a;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.al;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;

public enum e$b {
    ;
    
    private AtomicBoolean cnv;
    Map<Integer, a> inB;
    private Runnable inC;

    private e$b(String str) {
        AppMethodBeat.i(132283);
        this.inB = new ConcurrentHashMap();
        this.cnv = new AtomicBoolean(true);
        this.inC = new 1(this);
        AppMethodBeat.o(132283);
    }

    static {
        AppMethodBeat.o(132291);
    }

    public final synchronized void start() {
        AppMethodBeat.i(132284);
        this.cnv.set(false);
        aIx();
        AppMethodBeat.o(132284);
    }

    public final synchronized void stop() {
        AppMethodBeat.i(132285);
        this.cnv.set(true);
        AppMethodBeat.o(132285);
    }

    /* Access modifiers changed, original: final|declared_synchronized */
    public final synchronized void aIx() {
        boolean z = false;
        boolean z2 = true;
        synchronized (this) {
            AppMethodBeat.i(132286);
            g.RS();
            al.af(this.inC);
            if (this.cnv.get()) {
                ab.d("MicroMsg.WxaUpdateableMsgService", "isPause, not sendUpdatableMsgRequest");
                AppMethodBeat.o(132286);
            } else if (this.inB.size() <= 0) {
                ab.d("MicroMsg.WxaUpdateableMsgService", "sGetUpdatableMsgWorkerMap is empty, not sendUpdatableMsgRequest");
                AppMethodBeat.o(132286);
            } else {
                long j;
                long j2 = Long.MAX_VALUE;
                for (a aVar : this.inB.values()) {
                    if (aVar.aIv()) {
                        j = 0;
                        break;
                    } else if (aVar.iny >= 0) {
                        j2 = Math.min((long) aVar.iny, j2);
                        z = true;
                    }
                }
                j = j2;
                z2 = z;
                ab.d("MicroMsg.WxaUpdateableMsgService", "needUpdate:%b minDelayTime:%d", new Object[]{Boolean.valueOf(z2), Long.valueOf(j)});
                if (z2) {
                    g.RS().m(this.inC, j * 1000);
                    AppMethodBeat.o(132286);
                } else {
                    AppMethodBeat.o(132286);
                }
            }
        }
    }
}
