package com.tencent.mm.plugin.appbrand.dynamic.k;

import android.os.Looper;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.kernel.g;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.ytcommon.BuildConfig;
import java.util.concurrent.CountDownLatch;

public final class a {
    public static <T extends com.tencent.mm.kernel.c.a> T ag(Class<T> cls) {
        AppMethodBeat.i(11036);
        com.tencent.mm.kernel.c.a K = g.K(cls);
        if (K != null) {
            AppMethodBeat.o(11036);
            return K;
        } else if (Looper.myLooper() == Looper.getMainLooper()) {
            AppMethodBeat.o(11036);
            return null;
        } else if (g.RQ().eKi.eKC) {
            AppMethodBeat.o(11036);
            return null;
        } else {
            CountDownLatch countDownLatch = new CountDownLatch(1);
            1 1 = new 1(countDownLatch);
            g.RQ().a(1);
            try {
                countDownLatch.await();
                g.RQ().b(1);
            } catch (InterruptedException e) {
                ab.printErrStackTrace("MicroMsg.SyncGetter", e, BuildConfig.FLAVOR, new Object[0]);
                g.RQ().b(1);
            } catch (Throwable th) {
                g.RQ().b(1);
                AppMethodBeat.o(11036);
            }
            T K2 = g.K(cls);
            AppMethodBeat.o(11036);
            return K2;
        }
    }
}
