package com.tencent.c.a.a;

import android.content.Context;
import android.os.Handler;
import android.os.HandlerThread;
import android.preference.PreferenceManager;
import com.tencent.matrix.trace.core.AppMethodBeat;

public class i {
    private static i cbt = null;
    static f cbu = null;
    public static volatile long cbv = 0;
    static h cbw = null;
    public static Context mContext = null;
    public static Handler mHandler = null;
    private g cbx = null;

    private i(Context context) {
        AppMethodBeat.i(125771);
        HandlerThread handlerThread = new HandlerThread(i.class.getSimpleName());
        handlerThread.start();
        mHandler = new Handler(handlerThread.getLooper());
        Context applicationContext = context.getApplicationContext();
        mContext = applicationContext;
        cbv = PreferenceManager.getDefaultSharedPreferences(applicationContext).getLong("__MID_LAST_CHECK_TIME__", 0);
        AppMethodBeat.o(125771);
    }

    public static i aG(Context context) {
        AppMethodBeat.i(125772);
        if (cbt == null) {
            synchronized (i.class) {
                try {
                    if (cbt == null) {
                        cbt = new i(context);
                    }
                } catch (Throwable th) {
                    while (true) {
                        AppMethodBeat.o(125772);
                    }
                }
            }
        }
        i iVar = cbt;
        AppMethodBeat.o(125772);
        return iVar;
    }

    public static void a(f fVar) {
        cbu = fVar;
    }

    public final String zR() {
        AppMethodBeat.i(125773);
        if (this.cbx == null || !s.cp(this.cbx.cbr)) {
            int i;
            this.cbx = r.aI(mContext).zV();
            if (s.cp(this.cbx.cbr)) {
                i = 2;
            } else {
                i = 1;
            }
            if (mHandler != null) {
                mHandler.post(new n(mContext, i));
            }
            new StringBuilder("wx get mid:").append(this.cbx.cbr);
        }
        String str = this.cbx.cbr;
        AppMethodBeat.o(125773);
        return str;
    }

    public final String zS() {
        AppMethodBeat.i(125774);
        if (this.cbx == null || !s.cp(this.cbx.cbr)) {
            this.cbx = r.aI(mContext).zV();
        }
        String str = this.cbx.cbr;
        AppMethodBeat.o(125774);
        return str;
    }
}
