手机管家 v7.2.0版本的 MD5 值为:dd92ba71696e35a4b841cd1b5de53cd3

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


package tcs;

import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import com.tencent.kingkong.database.SQLiteDatabase;
import com.tencent.mm.sdk.modelmsg.c;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.WXAPIFactory;
import com.tencent.qqpimsecure.account.AccountInfo;
import com.tencent.qqpimsecure.account.MainAccountInfo;
import com.tencent.qqpimsecure.plugin.account.fg.PiAccount;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import meri.pluginsdk.PluginIntent;
import meri.pluginsdk.d;
import oicq.wlogin_sdk.request.Ticket;
import oicq.wlogin_sdk.request.WUserSigInfo;
import oicq.wlogin_sdk.request.WtloginHelper;
import oicq.wlogin_sdk.request.WtloginListener;
import oicq.wlogin_sdk.sharemem.WloginLoginInfo;
import oicq.wlogin_sdk.sharemem.WloginSimpleInfo;
import oicq.wlogin_sdk.tools.ErrMsg;
import oicq.wlogin_sdk.tools.util;
import org.json.JSONException;
import org.json.JSONObject;
import tcs.ang;
import tcs.asn;
import tcs.azr;

public class bqp extends bqy {
    private static final int[] gGS = {64, 128, 4096, 131072, 32, 524288};
    private static bqp gHd = null;
    private final aha alA;
    private final List<j> gGT;
    private final AtomicInteger gGU;
    private j gGV;
    private WtloginHelper gGW;
    private IWXAPI gGX;
    private final meri.pluginsdk.c gGY;
    private final Handler gGZ;
    private final bqx gHa;
    public a gHb;
    public b gHc;
    private WtloginListener gHe;

    public interface a {
        void h(int i, String str, int i2);
    }

    public interface b {
        void g(int i, String str, String str2);
    }

    public interface c {
        void a(int i, String str, int i2, String str2, byte[] bArr);
    }

    public interface e {
        void a(int i, String str, int i2, String str2, String str3);
    }

    public interface h {
        boolean aC(Bundle bundle);
    }

    public interface k {
        void a(int i, String str, int i2, ArrayList<Bundle> arrayList);
    }

    public interface n {
        boolean aD(Bundle bundle);
    }

    public static class j {
        public int gHz;

        private j() {
        }
    }

    public static class g extends j {
        public long gHv;
        public Intent gHw;
        public a gHx;

        private g() {
            super();
        }
    }

    public static class o extends j {
        public a gHx;
        public Bundle gHy;

        private o() {
            super();
        }
    }

    public static class i extends j {
        public a gHx;
        public Bundle gHy;

        private i() {
            super();
        }
    }

    public static class l extends j {
        public int gHA;
        public boolean gHB;
        public k gHC;
        public int gHq;
        public String gHr;

        private l() {
            super();
        }
    }

    public static class d extends j {
        public int gHq;
        public String gHr;
        public boolean gHs;
        public c gHt;

        private d() {
            super();
        }
    }

    public static class f extends j {
        public int gHq;
        public String gHr;
        public e gHu;

        private f() {
            super();
        }
    }

    public static class m {
        public String fql;
        public long fzS;
        public String gHD;
        public String gHE;
        public String gHF;
        public String gHG;
        public String gHH;

        m() {
        }
    }

    public static synchronized void d(meri.pluginsdk.c cVar) {
        synchronized (bqp.class) {
            if (gHd == null) {
                gHd = new bqp(cVar);
            }
        }
    }

    public static synchronized void destroy() {
        synchronized (bqp.class) {
            if (gHd != null) {
                gHd.quit();
            }
            gHd = null;
        }
    }

    public static synchronized bqp ane() {
        bqp bqpVar;
        synchronized (bqp.class) {
            if (gHd == null) {
                throw new RuntimeException("You should call init first!!!");
            }
            bqpVar = gHd;
        }
        return bqpVar;
    }

    private WtloginHelper anf() {
        if (this.gGW == null) {
            this.gGW = new WtloginHelper(this.gGY.kI());
            this.gGW.SetImgType(1);
            this.gGW.SetListener(this.gHe);
        }
        return this.gGW;
    }

    private IWXAPI ang() {
        if (this.gGX == null) {
            this.gGX = WXAPIFactory.createWXAPI(this.gGY.kI(), "wxccac4ab14315add3", true);
            try {
                this.gGX.registerApp("wxccac4ab14315add3");
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
        return this.gGX;
    }

    private bqp(meri.pluginsdk.c cVar) {
        super(cVar, "AccountAuthService");
        this.gHe = new WtloginListener() {
            @Override
            public void OnGetStWithoutPasswd(String str, long j2, long j3, int i2, long j4, WUserSigInfo wUserSigInfo, int i3, ErrMsg errMsg) {
                if (errMsg != null) {
                    errMsg.getMessage();
                }
                bqp.this.b(rM(i3), (Object) null);
            }

            @Override
            public void onQuickLogin(String str, WtloginHelper.QuickLoginParam quickLoginParam, int i2, ErrMsg errMsg) {
                String str2 = "no err msg";
                if (errMsg != null) {
                    str2 = errMsg.getMessage();
                }
                bqp.this.b(rM(i2), str);
                adj.f(11, "[onQuickLogin] ret = " + i2 + ", msg = " + str2 + ", qq = " + str);
            }

            @Override
            public void OnException(ErrMsg errMsg, int i2, WUserSigInfo wUserSigInfo) {
                String str = "no err msg";
                if (errMsg != null) {
                    str = errMsg.getMessage();
                }
                bqp.this.b(255, (Object) null);
                adj.f(11, "[OnException] cmd = " + i2 + ", msg = " + str);
            }

            private int rM(int i2) {
                switch (i2) {
                    case util.E_INPUT:
                        return 4;
                    case -1000:
                        return 2;
                    case 0:
                        return 0;
                    case 1:
                        return 3;
                    default:
                        return 255;
                }
            }
        };
        this.gGT = new ArrayList();
        this.gGU = new AtomicInteger(0);
        this.gGV = null;
        this.gGY = cVar;
        this.alA = ((aid) cVar.kH().gf(9)).dG("QQSecureProvider");
        this.gGZ = new Handler(Looper.getMainLooper());
        this.gHa = bqx.aod();
    }

    public void a(String str, ArrayList<String> arrayList, String str2, int i2, String str3, boolean z, String str4, b bVar) {
        int i3;
        this.gHc = bVar;
        if (i2 == 0) {
            i3 = 17498225;
        } else {
            i3 = 17498226;
        }
        PluginIntent pluginIntent = new PluginIntent(i3);
        Bundle bundle = new Bundle();
        bundle.putString("app_id", str);
        bundle.putStringArrayList(azr.b.dCx, arrayList);
        bundle.putString("state", str2);
        bundle.putString(azr.b.eUv, str3);
        bundle.putString("source", str4);
        pluginIntent.putExtra("args", bundle);
        pluginIntent.putExtra(PluginIntent.csC, 1);
        if (z) {
            pluginIntent.gg(17);
        }
        ((meri.pluginsdk.b) this.gGY).a(pluginIntent, false);
    }

    public void a(a aVar, int i2, int i3, String str, String str2, String str3, String str4, boolean z, boolean z2, boolean z3, int i4) {
        int i5;
        if (m(i2, i3, str)) {
            qe(str);
            if (aVar != null) {
                aVar.h(0, str, 1);
                return;
            }
            return;
        }
        String n2 = n(i2, i3, str);
        this.gHb = aVar;
        boolean z4 = false;
        if (i3 == 0) {
            if (brh.aoY()) {
                i5 = 17498213;
            } else {
                z4 = true;
                i5 = 17498218;
            }
        } else if (i3 == 1) {
            i5 = 17498215;
        } else if (i3 == 2) {
            i5 = 17498221;
        } else if (i3 == 3) {
            i5 = 17498215;
        } else if (i3 == 4) {
            if (isWXAppSupportAPI()) {
                i5 = 17498221;
            } else {
                i5 = 17498215;
            }
        } else if (i3 == 5) {
            i5 = 17498215;
        } else if (i3 == 6) {
            i5 = 17498216;
        } else if (i3 == 7) {
            i5 = 17498215;
        } else if (i3 == 8) {
            i5 = 17498215;
        } else if (i3 == 9) {
            i5 = 17498222;
        } else if (i3 == 10) {
            i5 = 17498218;
        } else if (i3 == 11) {
            i5 = 17498223;
        } else if (i3 == 12) {
            i5 = 17498217;
        } else if (i3 == 13) {
            i5 = 17498224;
        } else if (i3 == 14) {
            i5 = 17498213;
        } else if (i3 == 15) {
            i5 = 17498227;
        } else if (brh.aoY()) {
            i5 = 17498213;
        } else {
            z4 = true;
            i5 = 17498218;
        }
        PluginIntent pluginIntent = new PluginIntent(i5);
        Bundle bundle = new Bundle();
        bundle.putInt(azr.b.eke, i2);
        bundle.putInt(azr.b.ekf, i3);
        bundle.putString(azr.b.ekg, n2);
        bundle.putString("title", str2);
        bundle.putString(azr.b.ejV, str3);
        bundle.putString("source", str4);
        bundle.putBoolean(azr.b.ejT, z2);
        bundle.putBoolean(azr.b.dFc, z3);
        bundle.putBoolean("mixed_login", z4);
        pluginIntent.putExtra("args", bundle);
        if (i5 == 17498215 || i5 == 17498221 || i5 == 17498217 || i5 == 17498222 || i5 == 17498223 || i5 == 17498224 || i5 == 17498227) {
            pluginIntent.putExtra(PluginIntent.csC, 1);
        }
        if (z) {
            pluginIntent.addFlags(402653184);
        }
        if (i4 == 0) {
            ((meri.pluginsdk.b) this.gGY).a(pluginIntent, false);
        } else {
            ((meri.pluginsdk.b) this.gGY).a(pluginIntent, i4, false);
        }
    }

    private boolean m(int i2, int i3, String str) {
        MainAccountInfo ank;
        if (i2 != 3) {
            return false;
        }
        if ((i3 != 1 && i3 != 5) || TextUtils.isEmpty(str) || (ank = ank()) == null || ank.dxY == null) {
            return false;
        }
        return str.equals(ank.dxY.dxP) ? false : true;
    }

    private String n(int i2, int i3, String str) {
        if (TextUtils.isEmpty(str) && i2 == 1) {
            MainAccountInfo ank = ank();
            switch (i3) {
                case 1:
                case 3:
                case 8:
                    if (ank != null && ank.dxY != null) {
                        return ank.dxY.dxP;
                    }
                    return str;
                case 2:
                case 4:
                    if (ank != null && ank.dxZ != null) {
                        return ank.dxZ.dxP;
                    }
                    return str;
                case 5:
                case 6:
                case 7:
                default:
                    return str;
            }
        }
        return str;
    }

    public void a(String str, int i2, boolean z, c cVar) {
        d dVar = new d();
        dVar.gHz = 5;
        dVar.gHr = str;
        dVar.gHq = i2;
        dVar.gHs = z;
        dVar.gHt = cVar;
        Message obtain = Message.obtain();
        obtain.what = 100;
        obtain.obj = dVar;
        a(this.gGU.getAndIncrement(), obtain, 0L);
    }

    public void a(String str, int i2, e eVar) {
        f fVar = new f();
        fVar.gHz = 6;
        fVar.gHr = str;
        fVar.gHq = i2;
        fVar.gHu = eVar;
        Message obtain = Message.obtain();
        obtain.what = 100;
        obtain.obj = fVar;
        a(this.gGU.getAndIncrement(), obtain, 0L);
    }

    public void a(String str, int i2, int i3, boolean z, k kVar) {
        l lVar = new l();
        lVar.gHz = 4;
        lVar.gHr = str;
        lVar.gHq = i2;
        lVar.gHA = i3;
        lVar.gHB = z;
        lVar.gHC = kVar;
        Message obtain = Message.obtain();
        obtain.what = 100;
        obtain.obj = lVar;
        a(this.gGU.getAndIncrement(), obtain, 0L);
    }

    public String p(String str, int i2, int i3) {
        if (TextUtils.isEmpty(str)) {
            return SQLiteDatabase.KeyEmpty;
        }
        if (i2 == 1) {
            long j2 = 526017603;
            if (!str.equals(this.gHa.aog())) {
                j2 = 727037202;
            }
            return b(anf().GetLocalTicket(str, j2, i3));
        }
        if (i2 == 2) {
            m qf = qf(str);
            return qf != null ? qf.gHG : SQLiteDatabase.KeyEmpty;
        }
        if (i2 == 4) {
            m qm = qm(str);
            return qm != null ? qm.gHG : SQLiteDatabase.KeyEmpty;
        }
        return SQLiteDatabase.KeyEmpty;
    }

    @Override
    protected void O(Object obj) {
        Message message = (Message) obj;
        switch (message.what) {
            case 100:
                a((j) message.obj);
                return;
            case 101:
                ani();
                return;
            case 102:
                c(message.arg1, message.obj);
                return;
            default:
                return;
        }
    }

    private void a(j jVar) {
        this.gGT.add(jVar);
        if (this.gGT.size() == 1 && this.gGV == null) {
            anh();
        }
    }

    private void anh() {
        Message obtain = Message.obtain();
        obtain.what = 101;
        a(this.gGU.getAndIncrement(), obtain, 0L);
    }

    private void ani() {
        if (this.gGT.size() != 0) {
            j remove = this.gGT.remove(0);
            this.gGV = remove;
            switch (remove.gHz) {
                case 1:
                    a((g) remove);
                    return;
                case 2:
                    a((o) remove);
                    return;
                case 3:
                    a((i) remove);
                    return;
                case 4:
                    l lVar = (l) remove;
                    if (lVar.gHq == 1) {
                        a((l) remove);
                        return;
                    } else if (lVar.gHq == 2) {
                        b((l) remove);
                        return;
                    } else {
                        if (lVar.gHq == 4) {
                            c((l) remove);
                            return;
                        }
                        return;
                    }
                case 5:
                    a((d) remove);
                    return;
                case 6:
                    a((f) remove);
                    return;
                default:
                    return;
            }
        }
    }

    public void b(int i2, Object obj) {
        Message obtain = Message.obtain();
        obtain.what = 102;
        obtain.arg1 = i2;
        obtain.obj = obj;
        a(this.gGU.getAndIncrement(), obtain, 0L);
    }

    private void c(int i2, Object obj) {
        if (this.gGV == null) {
            anh();
            return;
        }
        j jVar = this.gGV;
        switch (jVar.gHz) {
            case 1:
                a(i2, (g) jVar, obj);
                break;
            case 2:
                a(i2, (o) jVar, obj);
                break;
            case 3:
                a(i2, (i) jVar, obj);
                break;
            case 4:
                a(i2, (l) jVar, obj);
                break;
            case 5:
                a(i2, (d) jVar, obj);
                break;
            case 6:
                a(i2, (f) jVar, obj);
                break;
        }
        if (this.gGV == null) {
            anh();
        }
    }

    private void a(final int i2, d dVar, Object obj) {
        final String str = dVar.gHr;
        final int i3 = dVar.gHq;
        final String ai = ai(str, i3);
        final byte[] bArr = (byte[]) obj;
        final c cVar = dVar.gHt;
        if (cVar != null) {
            this.gGZ.post(new Runnable() {
                @Override
                public void run() {
                    cVar.a(i2, str, i3, ai, bArr);
                }
            });
        }
        this.gGV = null;
    }

    private void a(final int i2, f fVar, Object obj) {
        final String str = fVar.gHr;
        final int i3 = fVar.gHq;
        final String ai = ai(str, i3);
        final String str2 = (String) obj;
        final e eVar = fVar.gHu;
        if (eVar != null) {
            this.gGZ.post(new Runnable() {
                @Override
                public void run() {
                    eVar.a(i2, str, i3, ai, str2);
                }
            });
        }
        this.gGV = null;
    }

    private void a(g gVar) {
        if (gVar.gHw != null) {
            WtloginHelper.QuickLoginParam quickLoginParam = new WtloginHelper.QuickLoginParam();
            quickLoginParam.appid = gVar.gHv;
            quickLoginParam.sigMap = 659680;
            anf().onQuickLoginActivityResultData(quickLoginParam, gVar.gHw);
            adj.f(11, "[doQQAuth] quick");
            return;
        }
        b(255, (Object) null);
    }

    private void pT(String str) {
        meri.pluginsdk.h kI = this.gGY.kI();
        String pW = pW(str);
        if (!TextUtils.isEmpty(pW)) {
            new File(kI.getFilesDir(), "qq_face/" + pW).delete();
            new File(kI.getCacheDir(), tmsdk.common.internal.utils.q.iG(pW)).delete();
            return;
        }
        File[] listFiles = new File(kI.getFilesDir(), "qq_face").listFiles();
        if (listFiles != null) {
            for (File file : listFiles) {
                file.delete();
            }
        }
    }

    private boolean a(d dVar, boolean z) {
        String str;
        JSONObject jSONObject;
        String str2 = dVar.gHr;
        if (TextUtils.isEmpty(str2)) {
            str2 = this.gHa.aog();
        }
        String pW = pW(str2);
        meri.pluginsdk.h kI = this.gGY.kI();
        File file = new File(kI.getFilesDir(), "qq_face/" + pW);
        Object ae = brh.ae(file);
        if (ae != null) {
            dVar.gHq = 1;
            dVar.gHr = pW;
            b(0, ae);
            return true;
        }
        Object ae2 = brh.ae(new File(kI.getCacheDir(), tmsdk.common.internal.utils.q.iG(pW)));
        if (ae2 != null) {
            dVar.gHq = 1;
            dVar.gHr = pW;
            b(0, ae2);
            return true;
        }
        byte[] ay = brc.ay(kI, "http://w.aq.qq.com/cn/mbtoken3/mbtoken3_get_photo_v2?uin=" + pW);
        if (ay == null) {
            if (z) {
                b(2, (Object) null);
            }
            return false;
        }
        try {
            jSONObject = new JSONObject(new String(ay));
        } catch (JSONException e2) {
        }
        if (jSONObject.getInt("err") == 0) {
            str = jSONObject.getString(ang.a.dUI);
            if (str != null) {
                if (z) {
                    b(2, (Object) null);
                }
                return false;
            }
            if (str.endsWith("&t=0")) {
                str = str.replace("&s=100", "&s=40");
            }
            byte[] ay2 = brc.ay(kI, str);
            if (ay2 != null) {
                brh.b(file, ay2);
                dVar.gHq = 1;
                dVar.gHr = pW;
                b(0, ay2);
                return true;
            }
            if (z) {
                b(2, (Object) null);
            }
            return false;
        }
        str = null;
        if (str != null) {
        }
    }

    private void a(l lVar) {
        String str = lVar.gHr;
        int i2 = lVar.gHA;
        boolean z = lVar.gHB;
        if (TextUtils.isEmpty(str)) {
            b(4, (Object) null);
            return;
        }
        long j2 = 526017603;
        if (!str.equals(this.gHa.aog())) {
            j2 = 727037202;
        }
        WUserSigInfo GetLocalSig = anf().GetLocalSig(str, j2);
        if (GetLocalSig == null) {
            b(3, (Object) null);
            return;
        }
        boolean z2 = false;
        for (int i3 : gGS) {
            if ((i2 & i3) != 0) {
                Ticket GetLocalTicket = anf().GetLocalTicket(str, j2, i3);
                if (i3 == 64) {
                    if (a(GetLocalTicket, 1296000000L)) {
                        z2 = true;
                        break;
                    }
                } else if (a(GetLocalTicket)) {
                    z2 = true;
                    break;
                }
            }
        }
        if (!z2 && !z) {
            b(0, (Object) null);
        } else if (anf().GetStWithoutPasswd(str, j2, j2, 1L, i2, GetLocalSig) != -1001) {
            b(4, (Object) null);
        }
    }

    private void a(ArrayList<Bundle> arrayList, int i2, String str) {
        long j2 = 526017603;
        if (!str.equals(this.gHa.aog())) {
            j2 = 727037202;
        }
        for (int i3 : gGS) {
            if ((i2 & i3) != 0) {
                String b2 = b(anf().GetLocalTicket(str, j2, i3));
                Bundle bundle = new Bundle();
                bundle.putInt("token_type", i3);
                bundle.putString(azr.a.ejg, b2);
                arrayList.add(bundle);
            }
        }
    }

    private void a(final int i2, l lVar, Object obj) {
        final String str = lVar.gHr;
        final int i3 = lVar.gHq;
        int i4 = lVar.gHA;
        final ArrayList<Bundle> arrayList = new ArrayList<>();
        if (i2 == 0) {
            if (lVar.gHq == 1) {
                a(arrayList, i4, str);
            } else {
                Bundle bundle = new Bundle();
                bundle.putInt("token_type", 0);
                bundle.putString(azr.a.ejg, obj != null ? obj.toString() : SQLiteDatabase.KeyEmpty);
                arrayList.add(bundle);
            }
        }
        final k kVar = lVar.gHC;
        if (kVar != null) {
            this.gGZ.post(new Runnable() {
                @Override
                public void run() {
                    kVar.a(i2, str, i3, arrayList);
                }
            });
        }
        this.gGV = null;
    }

    private void a(final int i2, g gVar, Object obj) {
        final String str = (String) obj;
        final a aVar = gVar.gHx;
        if (aVar != null) {
            this.gGZ.post(new Runnable() {
                @Override
                public void run() {
                    aVar.h(i2, str, 1);
                }
            });
        }
        this.gGV = null;
    }

    private boolean a(Ticket ticket) {
        return ticket == null || ticket._sig == null || ticket._sig.length == 0 || System.currentTimeMillis() >= ticket._expire_time * 1000;
    }

    private boolean a(Ticket ticket, long j2) {
        return ticket == null || ticket._sig == null || ticket._sig.length == 0 || System.currentTimeMillis() - (ticket._create_time * 1000) > j2;
    }

    private String b(Ticket ticket) {
        if (ticket == null || ticket._sig == null || ticket._sig.length == 0) {
            return SQLiteDatabase.KeyEmpty;
        }
        if (ticket._type == 64) {
            return util.buf_to_string(ticket._sig);
        }
        if (ticket._type == 128) {
            return util.buf_to_string(ticket._sig);
        }
        if (ticket._type == 4096) {
            return new String(ticket._sig);
        }
        if (ticket._type == 131072) {
            return new String(ticket._sig);
        }
        if (ticket._type == 32) {
            return util.buf_to_string(ticket._sig);
        }
        if (ticket._type == 524288) {
            return new String(ticket._sig);
        }
        return SQLiteDatabase.KeyEmpty;
    }

    public boolean pU(String str) {
        return a(anf().GetLocalTicket(str, 526017603L, 64));
    }

    public boolean pV(String str) {
        return a(anf().GetLocalTicket(str, 526017603L, 64), 1296000000L);
    }

    public String pW(String str) {
        if (TextUtils.isEmpty(str)) {
            return SQLiteDatabase.KeyEmpty;
        }
        WloginSimpleInfo wloginSimpleInfo = new WloginSimpleInfo();
        try {
            if (anf().GetBasicUserInfo(str, wloginSimpleInfo).booleanValue()) {
                return Long.toString(wloginSimpleInfo._uin);
            }
            return str;
        } catch (Exception e2) {
            return str;
        }
    }

    public boolean a(Activity activity, long j2, String str, boolean z) {
        WtloginHelper.QuickLoginParam quickLoginParam = new WtloginHelper.QuickLoginParam();
        quickLoginParam.appid = j2;
        if (z || !TextUtils.isEmpty(str)) {
            quickLoginParam.forceWebLogin = true;
            quickLoginParam.isUserAccountLocked = true;
        }
        quickLoginParam.sigMap = 659680;
        quickLoginParam.bAw = str;
        quickLoginParam.titleBackgroundColor = "#3F51B5";
        quickLoginParam.titleTextColor = "#FFFFFF";
        int quickLogin = anf().quickLogin(activity, j2, 1L, "1", quickLoginParam);
        return quickLogin == 0 || quickLogin == -2000 || quickLogin == -2001;
    }

    public void a(long j2, Intent intent, a aVar) {
        g gVar = new g();
        gVar.gHz = 1;
        gVar.gHv = j2;
        gVar.gHw = intent;
        gVar.gHx = aVar;
        Message obtain = Message.obtain();
        obtain.what = 100;
        obtain.obj = gVar;
        a(this.gGU.getAndIncrement(), obtain, 0L);
        if (intent != null) {
            adj.f(11, "[qqAuth] quick");
        } else {
            adj.f(11, "[qqAuth] password");
        }
    }

    public boolean anj() {
        c.a aVar = new c.a();
        aVar.dnt = "qqpimsecure_auth";
        aVar.dsD = "snsapi_userinfo";
        aVar.Rf = "qqpimsecure";
        return ang().a(aVar);
    }

    public boolean a(Bundle bundle, a aVar) {
        if (bundle.getInt("err_code") != 0) {
            return false;
        }
        o oVar = new o();
        oVar.gHz = 2;
        oVar.gHy = bundle;
        oVar.gHx = aVar;
        Message obtain = Message.obtain();
        obtain.what = 100;
        obtain.obj = oVar;
        a(this.gGU.getAndIncrement(), obtain, 0L);
        return true;
    }

    private void a(o oVar) {
        Bundle bundle = oVar.gHy;
        int i2 = bundle.getInt("err_code");
        if (i2 == -4) {
            b(3, (Object) null);
            return;
        }
        if (i2 == -2) {
            b(1, (Object) null);
            return;
        }
        if (i2 != 0) {
            b(255, (Object) null);
            return;
        }
        bundle.getString("err_msg");
        bundle.getString("country");
        bundle.getString("lang");
        String string = bundle.getString(azr.b.dCz);
        meri.pluginsdk.h kI = this.gGY.kI();
        m pZ = pZ(string);
        if (pZ == null) {
            b(2, (Object) null);
            return;
        }
        m b2 = b(new String(brc.ay(kI, bg(pZ.gHD, pZ.gHG))), pZ);
        if (b2 == null) {
            b(2, (Object) null);
        } else {
            a(b2);
            b(0, b2);
        }
    }

    private void a(final int i2, o oVar, Object obj) {
        m mVar = (m) obj;
        final String str = mVar != null ? mVar.gHD : SQLiteDatabase.KeyEmpty;
        final a aVar = oVar.gHx;
        if (aVar != null) {
            this.gGZ.post(new Runnable() {
                @Override
                public void run() {
                    aVar.h(i2, str, 2);
                }
            });
        }
        this.gGV = null;
    }

    private void pX(String str) {
        meri.pluginsdk.h kI = this.gGY.kI();
        if (!TextUtils.isEmpty(str)) {
            new File(kI.getFilesDir(), "wx_face/" + str).delete();
            return;
        }
        File[] listFiles = new File(kI.getFilesDir(), "wx_face").listFiles();
        if (listFiles != null) {
            for (File file : listFiles) {
                file.delete();
            }
        }
    }

    private boolean b(d dVar, boolean z) {
        String str = dVar.gHr;
        if (TextUtils.isEmpty(str)) {
            str = this.gHa.aoi();
        }
        meri.pluginsdk.h kI = this.gGY.kI();
        File file = new File(kI.getFilesDir(), "wx_face/" + str);
        Object ae = brh.ae(file);
        if (ae != null) {
            dVar.gHq = 2;
            dVar.gHr = str;
            b(0, ae);
            return true;
        }
        m qf = qf(str);
        if (qf == null) {
            if (z) {
                b(3, (Object) null);
            }
            return false;
        }
        byte[] ay = brc.ay(kI, qf.gHH);
        if (ay != null) {
            brh.b(file, ay);
            dVar.gHq = 2;
            dVar.gHr = str;
            b(0, ay);
            return true;
        }
        if (z) {
            b(2, (Object) null);
        }
        return false;
    }

    private void b(l lVar) {
        meri.pluginsdk.h kI = this.gGY.kI();
        m qf = qf(lVar.gHr);
        if (qf == null) {
            b(255, (Object) null);
            return;
        }
        m a2 = a(new String(brc.ay(kI, pY(qf.gHF))), qf);
        if (a2 != null) {
            a(a2);
        }
        if (a2 != null && !TextUtils.isEmpty(a2.gHG)) {
            b(0, a2.gHG);
        } else {
            b(255, (Object) null);
        }
    }

    private String pY(String str) {
        return "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=wxccac4ab14315add3&grant_type=refresh_token&refresh_token=" + str;
    }

    private String bg(String str, String str2) {
        return "https://api.weixin.qq.com/sns/userinfo?access_token=" + str2 + "&openid=" + str;
    }

    private m a(String str, m mVar) {
        try {
            JSONObject jSONObject = new JSONObject(str);
            String string = jSONObject.getString("openid");
            String string2 = jSONObject.getString("refresh_token");
            String string3 = jSONObject.getString("access_token");
            long j2 = jSONObject.getLong("expires_in");
            mVar.gHD = string;
            mVar.gHF = string2;
            mVar.gHG = string3;
            mVar.fzS = j2;
            return mVar;
        } catch (Exception e2) {
            e2.printStackTrace();
            return null;
        }
    }

    private m pZ(String str) {
        bgi bgiVar = new bgi();
        bgiVar.dsE = str;
        bgiVar.O = 3;
        gu a2 = brh.a((aic) this.gGY.kH().gf(5), "AccountAuthService", 3530, bgiVar, 13530, new bgj(), 30000L);
        if (a2 != null && (a2 instanceof bgj)) {
            bgj bgjVar = (bgj) a2;
            if (bgjVar.result != 0) {
                return null;
            }
            m mVar = new m();
            mVar.gHD = bgjVar.dnw;
            mVar.gHG = bgjVar.frn;
            mVar.fzS = bgjVar.fzS;
            mVar.gHF = bgjVar.fro;
            return mVar;
        }
        return null;
    }

    private m b(String str, m mVar) {
        try {
            JSONObject jSONObject = new JSONObject(str);
            String string = jSONObject.getString("openid");
            String string2 = jSONObject.getString("unionid");
            String string3 = jSONObject.getString("nickname");
            String string4 = jSONObject.getString("headimgurl");
            mVar.gHD = string;
            mVar.gHE = string2;
            mVar.fql = string3;
            mVar.gHH = string4;
            return mVar;
        } catch (Exception e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public boolean isWXAppSupportAPI() {
        return ang().isWXAppSupportAPI();
    }

    public MainAccountInfo ank() {
        long aon = this.gHa.aon();
        if (aon == 0) {
            return null;
        }
        MainAccountInfo mainAccountInfo = new MainAccountInfo();
        mainAccountInfo.dxX = aon;
        String aog = this.gHa.aog();
        if (!TextUtils.isEmpty(aog)) {
            mainAccountInfo.dxY = aj(aog, 1);
        }
        String aoi = this.gHa.aoi();
        if (!TextUtils.isEmpty(aoi)) {
            mainAccountInfo.dxZ = aj(aoi, 2);
        }
        String aol = this.gHa.aol();
        if (!TextUtils.isEmpty(aol)) {
            mainAccountInfo.epX = aj(aol, 4);
        }
        mainAccountInfo.dya = this.gHa.aok();
        mainAccountInfo.an = this.gHa.aoo();
        return mainAccountInfo;
    }

    public String qa(String str) {
        if (TextUtils.isEmpty(str)) {
            str = this.gHa.aog();
        }
        AccountInfo aj = aj(str, 1);
        if (aj == null) {
            return SQLiteDatabase.KeyEmpty;
        }
        String str2 = aj.name;
        if (TextUtils.isEmpty(str2)) {
            return brh.qH(aj.dxP);
        }
        return str2;
    }

    public String qb(String str) {
        if (TextUtils.isEmpty(str)) {
            str = this.gHa.aoi();
        }
        AccountInfo aj = aj(str, 2);
        if (aj == null) {
            return SQLiteDatabase.KeyEmpty;
        }
        return aj.name;
    }

    public String qc(String str) {
        if (TextUtils.isEmpty(str)) {
            str = this.gHa.aok();
        }
        return brh.qI(str);
    }

    public String ai(String str, int i2) {
        switch (i2) {
            case 1:
                return qa(str);
            case 2:
                return qb(str);
            case 3:
                return qc(str);
            case 4:
                return qh(str);
            default:
                String qb = qb(str);
                if (TextUtils.isEmpty(qb)) {
                    qb = qa(str);
                }
                if (TextUtils.isEmpty(qb)) {
                    qb = qc(str);
                }
                if (TextUtils.isEmpty(qb)) {
                    return qh(str);
                }
                return qb;
        }
    }

    public AccountInfo aj(String str, int i2) {
        boolean z;
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        if (i2 == 1) {
            String aog = this.gHa.aog();
            String pW = pW(str);
            AccountInfo accountInfo = new AccountInfo();
            accountInfo.type = 1;
            accountInfo.dxP = pW;
            accountInfo.dxQ = pW;
            WloginSimpleInfo wloginSimpleInfo = new WloginSimpleInfo();
            try {
                z = anf().GetBasicUserInfo(str, wloginSimpleInfo).booleanValue();
            } catch (Exception e2) {
                e2.printStackTrace();
                z = false;
            }
            if (!z) {
                if (str.equals(aog)) {
                    accountInfo.name = this.gHa.aoh();
                } else {
                    accountInfo.name = SQLiteDatabase.KeyEmpty;
                }
                accountInfo.status = 1;
            } else {
                accountInfo.name = new String(wloginSimpleInfo._nick);
                if (pU(str)) {
                    accountInfo.status = 2;
                } else {
                    accountInfo.status = 0;
                }
            }
            if (str.equals(aog)) {
                accountInfo.dxW = true;
                return accountInfo;
            }
            accountInfo.dxW = false;
            return accountInfo;
        }
        if (i2 == 2) {
            String aoi = this.gHa.aoi();
            AccountInfo accountInfo2 = new AccountInfo();
            accountInfo2.type = 2;
            accountInfo2.dxP = str;
            m qf = qf(str);
            if (qf == null) {
                accountInfo2.dxQ = SQLiteDatabase.KeyEmpty;
                if (str.equals(aoi)) {
                    accountInfo2.name = this.gHa.aoj();
                } else {
                    accountInfo2.name = SQLiteDatabase.KeyEmpty;
                }
                accountInfo2.status = 1;
            } else {
                accountInfo2.dxQ = qf.gHE;
                accountInfo2.name = qf.fql;
                accountInfo2.status = 0;
            }
            if (str.equals(aoi)) {
                accountInfo2.dxW = true;
                return accountInfo2;
            }
            accountInfo2.dxW = false;
            return accountInfo2;
        }
        if (i2 == 3) {
            String aok = this.gHa.aok();
            AccountInfo accountInfo3 = new AccountInfo();
            accountInfo3.type = 3;
            accountInfo3.dxP = str;
            if (str.equals(aok)) {
                accountInfo3.dxQ = str;
                accountInfo3.name = SQLiteDatabase.KeyEmpty;
                accountInfo3.status = 0;
                accountInfo3.dxW = true;
                return accountInfo3;
            }
            accountInfo3.dxQ = str;
            accountInfo3.name = SQLiteDatabase.KeyEmpty;
            accountInfo3.status = 1;
            accountInfo3.dxW = false;
            return accountInfo3;
        }
        if (i2 == 4) {
            String aol = this.gHa.aol();
            AccountInfo accountInfo4 = new AccountInfo();
            accountInfo4.type = 4;
            accountInfo4.dxP = str;
            m qm = qm(str);
            if (qm == null) {
                accountInfo4.dxQ = SQLiteDatabase.KeyEmpty;
                if (str.equals(aol)) {
                    accountInfo4.name = this.gHa.aom();
                } else {
                    accountInfo4.name = SQLiteDatabase.KeyEmpty;
                }
                accountInfo4.status = 1;
            } else {
                accountInfo4.dxQ = qm.gHE;
                accountInfo4.name = qm.fql;
                accountInfo4.status = 0;
            }
            if (str.equals(aol)) {
                accountInfo4.dxW = true;
                return accountInfo4;
            }
            accountInfo4.dxW = false;
            return accountInfo4;
        }
        return null;
    }

    public ArrayList<AccountInfo> anl() {
        ArrayList<AccountInfo> arrayList = new ArrayList<>();
        List<WloginLoginInfo> GetAllLoginInfo = anf().GetAllLoginInfo();
        if (GetAllLoginInfo == null) {
            return arrayList;
        }
        for (WloginLoginInfo wloginLoginInfo : GetAllLoginInfo) {
            if (wloginLoginInfo.mAppid == 526017603) {
                arrayList.add(aj(wloginLoginInfo.cuC, 1));
            }
        }
        return arrayList;
    }

    private int a(m mVar) {
        ContentValues contentValues = new ContentValues();
        contentValues.put("openid", mVar.gHD);
        contentValues.put("unionid", mVar.gHE);
        contentValues.put("refresh_token", mVar.gHF);
        contentValues.put("access_token", mVar.gHG);
        contentValues.put("expires_in", Long.valueOf(mVar.fzS));
        contentValues.put("nickname", mVar.fql);
        contentValues.put("headimgurl", mVar.gHH);
        if (this.alA.b("wx_user_info_table", contentValues) > 0) {
            return 0;
        }
        return -1;
    }

    public int qd(String str) {
        pX(str);
        if (this.alA.delete("wx_user_info_table", !TextUtils.isEmpty(str) ? "openid='" + str + "'" : null, null) > 0) {
            return 0;
        }
        return -1;
    }

    public int qe(String str) {
        boolean booleanValue;
        pT(str);
        if (TextUtils.isEmpty(str)) {
            List<WloginLoginInfo> GetAllLoginInfo = anf().GetAllLoginInfo();
            if (brh.r(GetAllLoginInfo)) {
                booleanValue = false;
            } else {
                booleanValue = false;
                for (WloginLoginInfo wloginLoginInfo : GetAllLoginInfo) {
                    if (wloginLoginInfo != null && wloginLoginInfo.cuC != null) {
                        booleanValue = anf().ClearUserLoginData(wloginLoginInfo.cuC, 526017603L).booleanValue();
                    }
                }
            }
        } else {
            booleanValue = anf().ClearUserLoginData(str, 526017603L).booleanValue();
        }
        return booleanValue ? 0 : -1;
    }

    public m qf(String str) {
        Cursor cursor;
        Exception e2;
        m mVar;
        Cursor cursor2 = null;
        try {
            cursor = this.alA.a("wx_user_info_table", null, "openid='" + str + "'", null, null);
        } catch (Exception e3) {
            e2 = e3;
            mVar = null;
        } catch (Throwable th) {
            th = th;
            cursor = null;
        }
        if (cursor != null) {
            try {
                try {
                } catch (Throwable th2) {
                    th = th2;
                    brh.P(cursor);
                    throw th;
                }
            } catch (Exception e4) {
                e2 = e4;
                mVar = null;
                cursor2 = cursor;
            }
            if (cursor.moveToFirst()) {
                int columnIndex = cursor.getColumnIndex("unionid");
                int columnIndex2 = cursor.getColumnIndex("refresh_token");
                int columnIndex3 = cursor.getColumnIndex("access_token");
                int columnIndex4 = cursor.getColumnIndex("expires_in");
                int columnIndex5 = cursor.getColumnIndex("nickname");
                int columnIndex6 = cursor.getColumnIndex("headimgurl");
                String string = cursor.getString(columnIndex);
                String string2 = cursor.getString(columnIndex2);
                String string3 = cursor.getString(columnIndex3);
                long j2 = cursor.getLong(columnIndex4);
                String string4 = cursor.getString(columnIndex5);
                String string5 = cursor.getString(columnIndex6);
                mVar = new m();
                try {
                    mVar.gHD = str;
                    mVar.gHE = string;
                    mVar.gHF = string2;
                    mVar.gHG = string3;
                    mVar.fzS = j2;
                    mVar.fql = string4;
                    mVar.gHH = string5;
                    brh.P(cursor);
                } catch (Exception e5) {
                    e2 = e5;
                    cursor2 = cursor;
                    try {
                        e2.printStackTrace();
                        brh.P(cursor2);
                        return mVar;
                    } catch (Throwable th3) {
                        th = th3;
                        cursor = cursor2;
                        brh.P(cursor);
                        throw th;
                    }
                }
                return mVar;
            }
        }
        mVar = null;
        brh.P(cursor);
        return mVar;
    }

    private boolean c(d dVar, boolean z) {
        String str = dVar.gHr;
        if (TextUtils.isEmpty(str)) {
            str = this.gHa.aok();
        }
        byte[] aoX = brh.aoX();
        if (aoX != null) {
            dVar.gHq = 3;
            dVar.gHr = str;
            b(0, aoX);
            return true;
        }
        if (z) {
            b(2, (Object) null);
        }
        return false;
    }

    private void a(d dVar) {
        if (dVar.gHq == 0) {
            dVar.gHq = this.gHa.aot();
        }
        switch (dVar.gHq) {
            case 1:
                boolean a2 = a(dVar, !dVar.gHs);
                if (!a2 && dVar.gHs) {
                    a2 = b(dVar, false);
                }
                if (!a2 && dVar.gHs) {
                    c(dVar, true);
                }
                if (!a2 && dVar.gHs) {
                    d(dVar, true);
                    return;
                }
                return;
            case 2:
                boolean b2 = b(dVar, !dVar.gHs);
                if (!b2 && dVar.gHs) {
                    b2 = a(dVar, false);
                }
                if (!b2 && dVar.gHs) {
                    c(dVar, true);
                }
                if (!b2 && dVar.gHs) {
                    d(dVar, true);
                    return;
                }
                return;
            case 3:
                boolean c2 = c(dVar, !dVar.gHs);
                if (!c2 && dVar.gHs) {
                    c2 = b(dVar, false);
                }
                if (!c2 && dVar.gHs) {
                    a(dVar, true);
                }
                if (!c2 && dVar.gHs) {
                    d(dVar, true);
                    return;
                }
                return;
            case 4:
                boolean d2 = d(dVar, !dVar.gHs);
                if (!d2 && dVar.gHs) {
                    d2 = b(dVar, false);
                }
                if (!d2 && dVar.gHs) {
                    a(dVar, true);
                }
                if (!d2 && dVar.gHs) {
                    c(dVar, true);
                    return;
                }
                return;
            default:
                boolean b3 = b(dVar, false);
                if (!b3) {
                    b3 = a(dVar, false);
                }
                if (!b3) {
                    c(dVar, true);
                }
                if (!b3) {
                    d(dVar, true);
                    return;
                }
                return;
        }
    }

    private void a(f fVar) {
        if (fVar.gHq == 0) {
            fVar.gHq = this.gHa.aot();
        }
        switch (fVar.gHq) {
            case 1:
                String str = fVar.gHr;
                if (TextUtils.isEmpty(str)) {
                    str = this.gHa.aog();
                }
                String pW = pW(str);
                if (!TextUtils.isEmpty(pW)) {
                    fVar.gHq = 1;
                    fVar.gHr = pW;
                    b(0, "http://w.aq.qq.com/cn/mbtoken3/mbtoken3_get_photo_v2?uin=" + pW);
                    return;
                }
                b(255, (Object) null);
                return;
            case 2:
                String str2 = fVar.gHr;
                if (TextUtils.isEmpty(str2)) {
                    str2 = this.gHa.aoi();
                }
                m qf = qf(str2);
                if (qf != null && !TextUtils.isEmpty(qf.gHH)) {
                    String str3 = qf.gHH;
                    fVar.gHq = 1;
                    fVar.gHr = str2;
                    b(0, str3);
                    return;
                }
                b(255, (Object) null);
                return;
            default:
                b(255, (Object) null);
                return;
        }
    }

    public boolean anm() {
        String[] split;
        int i2;
        int i3;
        int i4;
        sd e2 = ((qz) this.gGY.kH().gf(12)).e("com.tencent.qqpimsecure", 512);
        if (e2 == null) {
            return false;
        }
        String version = e2.getVersion();
        if (TextUtils.isEmpty(version) || version.toLowerCase().contains("mini") || (split = version.split("\\.")) == null || split.length < 2) {
            return false;
        }
        try {
            i2 = Integer.parseInt(split[0]);
            try {
                int parseInt = Integer.parseInt(split[1]);
                i3 = i2;
                i4 = parseInt;
            } catch (Exception e3) {
                i3 = i2;
                i4 = 0;
                return i3 <= 6 || (i3 == 6 && i4 >= 3);
            }
        } catch (Exception e4) {
            i2 = 0;
        }
        return i3 <= 6 || (i3 == 6 && i4 >= 3);
    }

    public boolean ann() {
        ArrayList<String> arrayList = new ArrayList<>();
        arrayList.add("/usr_info");
        Bundle bundle = new Bundle();
        bundle.putString("app_id", SQLiteDatabase.KeyEmpty);
        bundle.putStringArrayList(azr.b.dCx, arrayList);
        bundle.putString("state", "qqpimsecure");
        bundle.putInt(meri.pluginsdk.d.bss, azr.c.dCA);
        this.gGY.a(ayn.eom, 100, bundle, PiAccount.apL(), 600);
        return true;
    }

    public boolean b(Bundle bundle, a aVar) {
        i iVar = new i();
        iVar.gHz = 3;
        iVar.gHy = bundle;
        iVar.gHx = aVar;
        Message obtain = Message.obtain();
        obtain.what = 100;
        obtain.obj = iVar;
        a(this.gGU.getAndIncrement(), obtain, 0L);
        return true;
    }

    private void a(i iVar) {
        Bundle bundle = iVar.gHy;
        int i2 = bundle.getInt("result");
        String string = bundle.getString(azr.b.dCz);
        if (i2 != 0) {
            b(i2, (Object) null);
            return;
        }
        bdr bdrVar = new bdr();
        bdrVar.appId = SQLiteDatabase.KeyEmpty;
        bdrVar.ftS = SQLiteDatabase.KeyEmpty;
        bdrVar.ftT = string;
        gu a2 = brh.a((aic) this.gGY.kH().gf(5), "AccountAuthService", hv.bDf, bdrVar, hv.ciS, new bdy(), 30000L);
        if (a2 == null) {
            b(2, (Object) null);
            return;
        }
        if (!(a2 instanceof bdy)) {
            b(2, (Object) null);
            return;
        }
        bdy bdyVar = (bdy) a2;
        int sI = brr.sI(bdyVar.csk);
        if (sI != 0) {
            b(sI, (Object) null);
            return;
        }
        m mVar = new m();
        mVar.gHD = bdyVar.dnw;
        mVar.gHE = mVar.gHD;
        mVar.gHG = bdyVar.frn;
        mVar.fzS = bdyVar.fuh;
        mVar.gHF = bdyVar.fro;
        b(mVar);
        b(0, mVar);
    }

    private void a(final int i2, i iVar, Object obj) {
        m mVar = (m) obj;
        final String str = mVar != null ? mVar.gHD : SQLiteDatabase.KeyEmpty;
        final a aVar = iVar.gHx;
        if (aVar != null) {
            this.gGZ.post(new Runnable() {
                @Override
                public void run() {
                    aVar.h(i2, str, 4);
                }
            });
        }
        this.gGV = null;
    }

    private void qg(String str) {
        meri.pluginsdk.h kI = this.gGY.kI();
        if (!TextUtils.isEmpty(str)) {
            new File(kI.getFilesDir(), "qqpim_face/" + str).delete();
            return;
        }
        File[] listFiles = new File(kI.getFilesDir(), "qqpim_face").listFiles();
        if (listFiles != null) {
            for (File file : listFiles) {
                file.delete();
            }
        }
    }

    private boolean d(d dVar, boolean z) {
        String str = dVar.gHr;
        if (TextUtils.isEmpty(str)) {
            str = this.gHa.aol();
        }
        meri.pluginsdk.h kI = this.gGY.kI();
        File file = new File(kI.getFilesDir(), "qqpim_face/" + str);
        Object ae = brh.ae(file);
        if (ae != null) {
            dVar.gHq = 4;
            dVar.gHr = str;
            b(0, ae);
            return true;
        }
        m qm = qm(str);
        if (qm == null) {
            if (z) {
                b(3, (Object) null);
            }
            return false;
        }
        byte[] ay = brc.ay(kI, qm.gHH);
        if (ay != null) {
            brh.b(file, ay);
            dVar.gHq = 4;
            dVar.gHr = str;
            b(0, ay);
            return true;
        }
        if (z) {
            b(2, (Object) null);
        }
        return false;
    }

    private void c(l lVar) {
        m qm = qm(lVar.gHr);
        if (qm == null) {
            b(255, (Object) null);
            return;
        }
        bds bdsVar = new bds();
        bdsVar.appId = SQLiteDatabase.KeyEmpty;
        bdsVar.ftS = SQLiteDatabase.KeyEmpty;
        bdsVar.fro = qm.gHF;
        gu a2 = brh.a((aic) this.gGY.kH().gf(5), "AccountAuthService", hv.bDh, bdsVar, hv.ciV, new bdz(), 30000L);
        if (a2 == null) {
            b(2, (Object) null);
            return;
        }
        if (!(a2 instanceof bdy)) {
            b(2, (Object) null);
            return;
        }
        bdz bdzVar = (bdz) a2;
        int sI = brr.sI(bdzVar.csk);
        if (sI != 0) {
            b(sI, (Object) null);
            return;
        }
        qm.gHD = bdzVar.dnw;
        qm.gHE = qm.gHD;
        qm.gHG = bdzVar.frn;
        qm.fzS = bdzVar.fuh;
        qm.gHF = bdzVar.fro;
        b(qm);
        b(0, qm.gHG);
    }

    public String qh(String str) {
        if (TextUtils.isEmpty(str)) {
            str = this.gHa.aol();
        }
        AccountInfo aj = aj(str, 4);
        if (aj == null) {
            return SQLiteDatabase.KeyEmpty;
        }
        return aj.name;
    }

    private int b(m mVar) {
        ContentValues contentValues = new ContentValues();
        contentValues.put("openid", mVar.gHD);
        contentValues.put("unionid", mVar.gHE);
        contentValues.put("refresh_token", mVar.gHF);
        contentValues.put("access_token", mVar.gHG);
        contentValues.put("expires_in", Long.valueOf(mVar.fzS));
        contentValues.put("nickname", mVar.fql);
        contentValues.put("headimgurl", mVar.gHH);
        if (this.alA.b("qqpim_user_info_table", contentValues) > 0) {
            return 0;
        }
        return -1;
    }

    public int qk(String str) {
        qg(str);
        if (this.alA.delete("qqpim_user_info_table", !TextUtils.isEmpty(str) ? "openid='" + str + "'" : null, null) > 0) {
            return 0;
        }
        return -1;
    }

    public m qm(String str) {
        Cursor cursor;
        Exception e2;
        m mVar;
        Cursor cursor2 = null;
        try {
            cursor = this.alA.a("qqpim_user_info_table", null, "openid='" + str + "'", null, null);
        } catch (Exception e3) {
            e2 = e3;
            mVar = null;
        } catch (Throwable th) {
            th = th;
            cursor = null;
        }
        if (cursor != null) {
            try {
                try {
                } catch (Throwable th2) {
                    th = th2;
                    brh.P(cursor);
                    throw th;
                }
            } catch (Exception e4) {
                e2 = e4;
                mVar = null;
                cursor2 = cursor;
            }
            if (cursor.moveToFirst()) {
                int columnIndex = cursor.getColumnIndex("unionid");
                int columnIndex2 = cursor.getColumnIndex("refresh_token");
                int columnIndex3 = cursor.getColumnIndex("access_token");
                int columnIndex4 = cursor.getColumnIndex("expires_in");
                int columnIndex5 = cursor.getColumnIndex("nickname");
                int columnIndex6 = cursor.getColumnIndex("headimgurl");
                String string = cursor.getString(columnIndex);
                String string2 = cursor.getString(columnIndex2);
                String string3 = cursor.getString(columnIndex3);
                long j2 = cursor.getLong(columnIndex4);
                String string4 = cursor.getString(columnIndex5);
                String string5 = cursor.getString(columnIndex6);
                mVar = new m();
                try {
                    mVar.gHD = str;
                    mVar.gHE = string;
                    mVar.gHF = string2;
                    mVar.gHG = string3;
                    mVar.fzS = j2;
                    mVar.fql = string4;
                    mVar.gHH = string5;
                    brh.P(cursor);
                } catch (Exception e5) {
                    e2 = e5;
                    cursor2 = cursor;
                    try {
                        e2.printStackTrace();
                        brh.P(cursor2);
                        return mVar;
                    } catch (Throwable th3) {
                        th = th3;
                        cursor = cursor2;
                        brh.P(cursor);
                        throw th;
                    }
                }
                return mVar;
            }
        }
        mVar = null;
        brh.P(cursor);
        return mVar;
    }

    public m qn(String str) {
        m mVar;
        Exception e2;
        try {
            String pW = pW(str);
            Ticket GetLocalTicket = anf().GetLocalTicket(str, 526017603L, 64);
            String b2 = b(GetLocalTicket);
            long j2 = GetLocalTicket._expire_time * 1000;
            WloginSimpleInfo wloginSimpleInfo = new WloginSimpleInfo();
            anf().GetBasicUserInfo(str, wloginSimpleInfo);
            String str2 = new String(wloginSimpleInfo._nick);
            String str3 = "http://w.aq.qq.com/cn/mbtoken3/mbtoken3_get_photo_v2?uin=" + str;
            mVar = new m();
            try {
                mVar.gHD = str;
                mVar.gHE = pW;
                mVar.gHF = b2;
                mVar.gHG = b2;
                mVar.fzS = j2;
                mVar.fql = str2;
                mVar.gHH = str3;
            } catch (Exception e3) {
                e2 = e3;
                e2.printStackTrace();
                return mVar;
            }
        } catch (Exception e4) {
            mVar = null;
            e2 = e4;
        }
        return mVar;
    }

    public void ano() {
        ((ahi) bqn.and().kH().gf(8)).a(ayn.eom, 17498115, new Bundle());
        ans.xW().as(this.gHa.aon() != 0);
        if (this.gHa.aon() != 0) {
            brv.apw().c(null);
        }
        Bundle bundle = new Bundle();
        bundle.putInt(meri.pluginsdk.d.bss, asn.b.eWD);
        bundle.putBoolean(asn.a.eWn, true);
        if (this.gGY != null) {
            this.gGY.b(ayn.eZV, bundle, (d.z) null);
        }
    }
}