安全中心 v4.9.2版本的 MD5 值为:d64c0ec7920c532fa6e6d9bb001cf9bf

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


package tcs;

import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
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 oicq.wlogin_sdk.request.Ticket;
import oicq.wlogin_sdk.request.WUserSigInfo;
import oicq.wlogin_sdk.request.WtloginHelper;
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.azr;
import tmsdk.fg.tcc.LoginUtil;

public class boh extends bop {
    private static final int[] gjQ = {64, 128, 4096, 131072, 32, 524288};
    private static boh gkc = null;
    private final aha alA;
    private final List<l> gjR;
    private final AtomicInteger gjS;
    private l gjT;
    private final WtloginHelper gjU;
    private Intent gjV;
    private final IWXAPI gjW;
    private final meri.pluginsdk.c gjX;
    private final Handler gjY;
    private final boo gjZ;
    public b gka;
    public c gkb;
    private oicq.wlogin_sdk.request.b gkd;

    public static class a {
        public boolean dxW;
        public String gkq;
        public String name;
        public int type;
    }

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

    public interface c {
        void h(int i, String str, String str2);
    }

    public interface d {
        void a(int i, String str, int i2, Bitmap bitmap);
    }

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

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

    public interface j {
        boolean at(Bundle bundle);
    }

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

    public interface p {
        boolean au(Bundle bundle);
    }

    public static class l {
        public int gkA;

        private l() {
        }
    }

    public static class i extends l {
        public String UU;
        public long gkv;
        public String gkw;
        public Intent gkx;
        public d gky;

        private i() {
            super();
        }
    }

    public static class q extends l {
        public d gky;
        public Bundle gkz;

        private q() {
            super();
        }
    }

    public static class k extends l {
        public d gky;
        public Bundle gkz;

        private k() {
            super();
        }
    }

    public static class n extends l {
        public int gkB;
        public boolean gkC;
        public m gkD;
        public String gkq;
        public int gkr;

        private n() {
            super();
        }
    }

    public static class f extends l {
        public String gkq;
        public int gkr;
        public boolean gks;
        public e gkt;

        private f() {
            super();
        }
    }

    public static class h extends l {
        public String gkq;
        public int gkr;
        public g gku;

        private h() {
            super();
        }
    }

    public static class o {
        public String eRK;
        public long fah;
        public String gkE;
        public String gkF;
        public String gkG;
        public String gkH;
        public String gkI;

        o() {
        }
    }

    public static synchronized void f(meri.pluginsdk.c cVar) {
        synchronized (boh.class) {
            if (gkc == null) {
                gkc = new boh(cVar);
            }
        }
    }

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

    public static synchronized boh amP() {
        boh bohVar;
        synchronized (boh.class) {
            if (gkc == null) {
                throw new RuntimeException("You should call init first!!!");
            }
            bohVar = gkc;
        }
        return bohVar;
    }

    private boh(meri.pluginsdk.c cVar) {
        super(cVar, "AccountAuthService");
        this.gkd = new oicq.wlogin_sdk.request.b() {
            @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();
                }
                boh.this.b(qM(i3), (Object) null);
            }

            @Override
            public void OnGetStWithPasswd(String str, long j2, int i2, long j3, String str2, WUserSigInfo wUserSigInfo, int i3, ErrMsg errMsg) {
                String str3 = "no err msg";
                if (errMsg != null) {
                    str3 = errMsg.getMessage();
                }
                int qM = qM(i3);
                Bitmap f2 = f(str, null);
                if (f2 != null) {
                    qM = LoginUtil.EM_LOGIN_RES_SYSTEM_MAINTENANCE;
                }
                boh.this.b(qM, new Object[]{str, f2});
                adj.f(11, "[OnGetStWithPasswd] ret = " + i3 + ", msg = " + str3 + ", qq = " + str);
            }

            @Override
            public void OnCheckPictureAndGetSt(String str, byte[] bArr, WUserSigInfo wUserSigInfo, int i2, ErrMsg errMsg) {
                if (errMsg != null) {
                    errMsg.getMessage();
                }
                int qM = qM(i2);
                Bitmap f2 = i2 == 2 ? f(str, null) : null;
                if (f2 != null) {
                    qM = LoginUtil.EM_LOGIN_RES_SYSTEM_MAINTENANCE;
                }
                boh.this.b(qM, new Object[]{str, f2});
            }

            @Override
            public void OnRefreshPictureData(String str, WUserSigInfo wUserSigInfo, byte[] bArr, int i2, ErrMsg errMsg) {
                if (errMsg != null) {
                    errMsg.getMessage();
                }
                int qM = qM(i2);
                Bitmap f2 = f(str, bArr);
                if (f2 != null) {
                    qM = LoginUtil.EM_LOGIN_RES_SYSTEM_MAINTENANCE;
                }
                boh.this.b(qM, new Object[]{str, f2});
            }

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

            private Bitmap f(String str, byte[] bArr) {
                if (bArr == null) {
                    bArr = boh.this.gjU.GetPictureData(str);
                }
                if (bArr == null) {
                    return null;
                }
                Bitmap decodeByteArray = BitmapFactory.decodeByteArray(bArr, 0, bArr.length);
                if (decodeByteArray != null) {
                    decodeByteArray.setDensity(160);
                    return decodeByteArray;
                }
                return decodeByteArray;
            }

            private int qM(int i2) {
                switch (i2) {
                    case util.E_INPUT:
                        return 4;
                    case -1000:
                        return 2;
                    case 0:
                        return 0;
                    case 1:
                        return 3;
                    case 2:
                        return LoginUtil.EM_LOGIN_RES_SYSTEM_MAINTENANCE;
                    default:
                        return 255;
                }
            }
        };
        meri.pluginsdk.h kI = cVar.kI();
        this.gjU = new WtloginHelper(kI);
        this.gjU.SetImgType(1);
        this.gjU.SetListener(this.gkd);
        this.gjW = WXAPIFactory.createWXAPI(kI, SQLiteDatabase.KeyEmpty, true);
        try {
            this.gjW.registerApp(SQLiteDatabase.KeyEmpty);
        } catch (Exception e2) {
            e2.printStackTrace();
        }
        this.gjR = new ArrayList();
        this.gjS = new AtomicInteger(0);
        this.gjT = null;
        this.gjX = cVar;
        this.alA = ((aid) cVar.kH().gf(9)).dG("QQSecureProvider");
        this.gjY = new Handler(Looper.getMainLooper());
        this.gjZ = boo.anJ();
    }

    public void a(String str, ArrayList<String> arrayList, String str2, String str3, String str4, c cVar) {
        this.gkb = cVar;
        PluginIntent pluginIntent = new PluginIntent(17498225);
        Bundle bundle = new Bundle();
        bundle.putString("app_id", str);
        bundle.putStringArrayList(azr.b.dCx, arrayList);
        bundle.putString("state", str2);
        bundle.putString("app_pkg", str3);
        bundle.putString("source", str4);
        pluginIntent.putExtra("args", bundle);
        pluginIntent.putExtra(PluginIntent.csC, 1);
        pluginIntent.gg(17);
        ((meri.pluginsdk.b) this.gjX).a(pluginIntent, false);
    }

    public void a(b bVar, int i2, int i3, String str, boolean z, String str2, String str3, String str4, boolean z2, boolean z3, boolean z4, int i4) {
        int i5;
        if (n(i2, i3, str)) {
            pQ(str);
            if (bVar != null) {
                bVar.g(0, str, 1);
                return;
            }
            return;
        }
        String o2 = o(i2, i3, str);
        this.gka = bVar;
        if (i3 == 0) {
            i5 = 17498213;
        } else if (i3 == 1) {
            i5 = ac(o2, i2);
        } else if (i3 == 2) {
            i5 = 17498221;
        } else if (i3 == 3) {
            if (!amS() && isWXAppSupportAPI()) {
                i5 = 17498221;
            } else {
                i5 = ac(o2, i2);
            }
        } else if (i3 == 4) {
            if (isWXAppSupportAPI()) {
                i5 = 17498221;
            } else {
                i5 = ac(o2, i2);
            }
        } else if (i3 == 5) {
            if (pO(o2) == 1) {
                i5 = ac(o2, i2);
            } else {
                i5 = 17498221;
            }
        } else if (i3 == 6) {
            i5 = 17498216;
        } else if (i3 == 7) {
            i5 = ac(o2, i2);
        } else if (i3 == 8) {
            i5 = 17498214;
        } 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 = 17498226;
        } else {
            i5 = 17498213;
        }
        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, o2);
        bundle.putString("title", str2);
        bundle.putString(azr.b.ejV, str3);
        bundle.putString("source", str4);
        bundle.putBoolean(azr.b.ejT, z3);
        bundle.putBoolean(azr.b.dFc, z4);
        bundle.putBoolean("use_cache_token", z);
        pluginIntent.putExtra("args", bundle);
        if (i5 == 17498215 || i5 == 17498221 || i5 == 17498217 || i5 == 17498222 || i5 == 17498223 || i5 == 17498224 || i5 == 17498226) {
            pluginIntent.putExtra(PluginIntent.csC, 1);
        }
        if (z2) {
            pluginIntent.addFlags(402653184);
        }
        if (i4 == 0) {
            ((meri.pluginsdk.b) this.gjX).a(pluginIntent, false);
        } else {
            ((meri.pluginsdk.b) this.gjX).a(pluginIntent, i4, false);
        }
    }

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

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

    private int ac(String str, int i2) {
        return (i2 != 0 && amS() && TextUtils.isEmpty(str)) ? 17498215 : 17498214;
    }

    public void a(String str, int i2, boolean z, e eVar) {
        f fVar = new f();
        fVar.gkA = 5;
        fVar.gkq = str;
        fVar.gkr = i2;
        fVar.gks = z;
        fVar.gkt = eVar;
        Message obtain = Message.obtain();
        obtain.what = 100;
        obtain.obj = fVar;
        a(this.gjS.getAndIncrement(), obtain, 0L);
    }

    public void a(String str, int i2, g gVar) {
        h hVar = new h();
        hVar.gkA = 6;
        hVar.gkq = str;
        hVar.gkr = i2;
        hVar.gku = gVar;
        Message obtain = Message.obtain();
        obtain.what = 100;
        obtain.obj = hVar;
        a(this.gjS.getAndIncrement(), obtain, 0L);
    }

    public void a(String str, int i2, int i3, boolean z, m mVar) {
        n nVar = new n();
        nVar.gkA = 4;
        nVar.gkq = str;
        nVar.gkr = i2;
        nVar.gkB = i3;
        nVar.gkC = z;
        nVar.gkD = mVar;
        Message obtain = Message.obtain();
        obtain.what = 100;
        obtain.obj = nVar;
        a(this.gjS.getAndIncrement(), obtain, 0L);
    }

    public String o(String str, int i2, int i3) {
        if (TextUtils.isEmpty(str)) {
            return SQLiteDatabase.KeyEmpty;
        }
        if (i2 == 1) {
            if (!str.equals(this.gjZ.anM().gkq)) {
            }
            return b(this.gjU.GetLocalTicket(str, 0L, i3));
        }
        if (i2 == 2) {
            o pR = pR(str);
            return pR != null ? pR.gkH : SQLiteDatabase.KeyEmpty;
        }
        if (i2 == 4) {
            o pV = pV(str);
            return pV != null ? pV.gkH : SQLiteDatabase.KeyEmpty;
        }
        return SQLiteDatabase.KeyEmpty;
    }

    @Override
    protected void O(Object obj) {
        Message message = (Message) obj;
        switch (message.what) {
            case 100:
                a((l) message.obj);
                return;
            case 101:
                amR();
                return;
            case 102:
                c(message.arg1, message.obj);
                return;
            case 103:
                this.gjU.RefreshPictureData((String) message.obj, new WUserSigInfo());
                return;
            case 104:
                String[] strArr = (String[]) message.obj;
                this.gjU.CheckPictureAndGetSt(strArr[0], strArr[1].getBytes(), new WUserSigInfo());
                return;
            case 105:
                this.gjT = null;
                amQ();
                return;
            default:
                return;
        }
    }

    private void a(l lVar) {
        this.gjR.add(lVar);
        if (this.gjR.size() == 1 && this.gjT == null) {
            amQ();
        }
    }

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

    private void amR() {
        if (this.gjR.size() != 0) {
            l remove = this.gjR.remove(0);
            this.gjT = remove;
            switch (remove.gkA) {
                case 1:
                    a((i) remove);
                    return;
                case 2:
                    a((q) remove);
                    return;
                case 3:
                    a((k) remove);
                    return;
                case 4:
                    n nVar = (n) remove;
                    if (nVar.gkr == 1) {
                        a((n) remove);
                        return;
                    } else if (nVar.gkr == 2) {
                        b((n) remove);
                        return;
                    } else {
                        if (nVar.gkr == 4) {
                            c((n) remove);
                            return;
                        }
                        return;
                    }
                case 5:
                    a((f) remove);
                    return;
                case 6:
                    a((h) 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.gjS.getAndIncrement(), obtain, 0L);
    }

    private void c(int i2, Object obj) {
        if (this.gjT == null) {
            amQ();
            return;
        }
        l lVar = this.gjT;
        switch (lVar.gkA) {
            case 1:
                a(i2, (i) lVar, obj);
                break;
            case 2:
                a(i2, (q) lVar, obj);
                break;
            case 3:
                a(i2, (k) lVar, obj);
                break;
            case 4:
                a(i2, (n) lVar, obj);
                break;
            case 5:
                a(i2, (f) lVar, obj);
                break;
            case 6:
                a(i2, (h) lVar, obj);
                break;
        }
        if (this.gjT == null) {
            amQ();
        }
    }

    private void a(final int i2, f fVar, Object obj) {
        final String str = fVar.gkq;
        final int i3 = fVar.gkr;
        final byte[] bArr = (byte[]) obj;
        final e eVar = fVar.gkt;
        if (eVar != null) {
            this.gjY.post(new Runnable() {
                @Override
                public void run() {
                    eVar.a(i2, str, i3, bArr);
                }
            });
        }
        this.gjT = null;
    }

    private void a(final int i2, h hVar, Object obj) {
        final String str = hVar.gkq;
        final int i3 = hVar.gkr;
        final String str2 = (String) obj;
        final g gVar = hVar.gku;
        if (gVar != null) {
            this.gjY.post(new Runnable() {
                @Override
                public void run() {
                    gVar.a(i2, str, i3, str2);
                }
            });
        }
        this.gjT = null;
    }

    private void a(i iVar) {
        long j2 = iVar.gkv;
        if (iVar.gkx != null) {
            WUserSigInfo ResolveQloginIntent = this.gjU.ResolveQloginIntent(iVar.gkx);
            this.gjU.GetStWithPasswd(ResolveQloginIntent.cTF, j2, 1L, 659680, SQLiteDatabase.KeyEmpty, ResolveQloginIntent);
            adj.f(11, "[doQQAuth] quick");
        } else {
            this.gjU.GetStWithPasswd(iVar.UU, j2, 1L, 659680, iVar.gkw, new WUserSigInfo());
            adj.f(11, "[doQQAuth] password");
        }
    }

    private void pD(String str) {
        String pG = pG(str);
        meri.pluginsdk.h kI = this.gjX.kI();
        new File(kI.getFilesDir(), "qq_face/" + pG).delete();
        new File(kI.getCacheDir(), tmsdk.common.internal.utils.q.iG(pG)).delete();
    }

    private boolean a(f fVar, boolean z) {
        String str;
        JSONObject jSONObject;
        String str2 = fVar.gkq;
        if (TextUtils.isEmpty(str2)) {
            str2 = this.gjZ.anM().gkq;
        }
        String pG = pG(str2);
        meri.pluginsdk.h kI = this.gjX.kI();
        File file = new File(kI.getFilesDir(), "qq_face/" + pG);
        Object X = boy.X(file);
        if (X != null) {
            fVar.gkr = 1;
            fVar.gkq = pG;
            b(0, X);
            return true;
        }
        Object X2 = boy.X(new File(kI.getCacheDir(), tmsdk.common.internal.utils.q.iG(pG)));
        if (X2 != null) {
            fVar.gkr = 1;
            fVar.gkq = pG;
            b(0, X2);
            return true;
        }
        byte[] az = bot.az(kI, "http://w.aq.qq.com/cn/mbtoken3/mbtoken3_get_photo_v2?uin=" + pG);
        if (az == null) {
            if (z) {
                b(2, (Object) null);
            }
            return false;
        }
        try {
            jSONObject = new JSONObject(new String(az));
        } 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[] az2 = bot.az(kI, str);
            if (az2 != null) {
                boy.b(file, az2);
                fVar.gkr = 1;
                fVar.gkq = pG;
                b(0, az2);
                return true;
            }
            if (z) {
                b(2, (Object) null);
            }
            return false;
        }
        str = null;
        if (str != null) {
        }
    }

    private void a(n nVar) {
        String str = nVar.gkq;
        int i2 = nVar.gkB;
        boolean z = nVar.gkC;
        if (TextUtils.isEmpty(str)) {
            b(4, (Object) null);
            return;
        }
        long j2 = 0;
        if (!str.equals(this.gjZ.anM().gkq)) {
            j2 = 0;
        }
        WUserSigInfo GetLocalSig = this.gjU.GetLocalSig(str, j2);
        if (GetLocalSig == null) {
            b(3, (Object) null);
            return;
        }
        boolean z2 = false;
        for (int i3 : gjQ) {
            if ((i2 & i3) != 0) {
                Ticket GetLocalTicket = this.gjU.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 (this.gjU.GetStWithoutPasswd(str, j2, j2, 1L, i2, GetLocalSig) != -1001) {
            b(4, (Object) null);
        }
    }

    private void a(ArrayList<Bundle> arrayList, int i2, String str) {
        if (!str.equals(this.gjZ.anM().gkq)) {
        }
        for (int i3 : gjQ) {
            if ((i2 & i3) != 0) {
                String b2 = b(this.gjU.GetLocalTicket(str, 0L, 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, n nVar, Object obj) {
        final String str = nVar.gkq;
        final int i3 = nVar.gkr;
        int i4 = nVar.gkB;
        final ArrayList<Bundle> arrayList = new ArrayList<>();
        if (i2 == 0) {
            if (nVar.gkr == 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 m mVar = nVar.gkD;
        if (mVar != null) {
            this.gjY.post(new Runnable() {
                @Override
                public void run() {
                    mVar.a(i2, str, i3, arrayList);
                }
            });
        }
        this.gjT = null;
    }

    private void a(final int i2, i iVar, Object obj) {
        Object[] objArr = (Object[]) obj;
        final String str = (String) objArr[0];
        final Bitmap bitmap = (Bitmap) objArr[1];
        final d dVar = iVar.gky;
        if (dVar != null) {
            this.gjY.post(new Runnable() {
                @Override
                public void run() {
                    dVar.a(i2, str, 1, bitmap);
                }
            });
        }
        if (bitmap == null) {
            this.gjT = null;
        }
    }

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

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

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

    public boolean pE(String str) {
        return a(this.gjU.GetLocalTicket(str, 0L, 64));
    }

    public boolean pF(String str) {
        return a(this.gjU.GetLocalTicket(str, 0L, 64), 1296000000L);
    }

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

    public boolean amS() {
        this.gjV = this.gjU.PrepareQloginIntent(0L, 0L, "0");
        return this.gjV != null;
    }

    public boolean a(Activity activity, long j2, int i2) {
        Bundle bundleExtra;
        Intent intent = this.gjV;
        if (intent == null || (bundleExtra = intent.getBundleExtra("key_params")) == null) {
            return false;
        }
        bundleExtra.putLong("dstAppid", j2);
        bundleExtra.putLong("subDstAppid", 1L);
        bundleExtra.putByteArray("dstAppVer", "1".getBytes());
        try {
            activity.startActivityForResult(intent, i2);
            return true;
        } catch (Exception e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public void a(long j2, String str, String str2, Intent intent, d dVar) {
        i iVar = new i();
        iVar.gkA = 1;
        iVar.gkv = j2;
        iVar.UU = str;
        iVar.gkw = str2;
        iVar.gkx = intent;
        iVar.gky = dVar;
        Message obtain = Message.obtain();
        obtain.what = 100;
        obtain.obj = iVar;
        a(this.gjS.getAndIncrement(), obtain, 0L);
        if (TextUtils.isEmpty(str)) {
            adj.f(11, "[qqAuth] quick");
        } else {
            adj.f(11, "[qqAuth] password");
        }
    }

    public void pH(String str) {
        Message obtain = Message.obtain();
        obtain.what = 103;
        obtain.obj = str;
        a(this.gjS.getAndIncrement(), obtain, 0L);
    }

    public void ba(String str, String str2) {
        Message obtain = Message.obtain();
        obtain.what = 104;
        obtain.obj = new String[]{str, str2};
        a(this.gjS.getAndIncrement(), obtain, 0L);
    }

    public void amT() {
        Message obtain = Message.obtain();
        obtain.what = 105;
        a(this.gjS.getAndIncrement(), obtain, 0L);
    }

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

    public boolean a(Bundle bundle, d dVar) {
        if (bundle.getInt("err_code") != 0) {
            return false;
        }
        q qVar = new q();
        qVar.gkA = 2;
        qVar.gkz = bundle;
        qVar.gky = dVar;
        Message obtain = Message.obtain();
        obtain.what = 100;
        obtain.obj = qVar;
        a(this.gjS.getAndIncrement(), obtain, 0L);
        return true;
    }

    private void a(q qVar) {
        Bundle bundle = qVar.gkz;
        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.gjX.kI();
        o pK = pK(string);
        if (pK == null) {
            b(2, (Object) null);
            return;
        }
        o b2 = b(new String(bot.az(kI, bb(pK.gkE, pK.gkH))), pK);
        if (b2 == null) {
            b(2, (Object) null);
        } else {
            a(b2);
            b(0, b2);
        }
    }

    private void a(final int i2, q qVar, Object obj) {
        o oVar = (o) obj;
        final String str = oVar != null ? oVar.gkE : SQLiteDatabase.KeyEmpty;
        final d dVar = qVar.gky;
        if (dVar != null) {
            this.gjY.post(new Runnable() {
                @Override
                public void run() {
                    dVar.a(i2, str, 2, null);
                }
            });
        }
        this.gjT = null;
    }

    private void pI(String str) {
        new File(this.gjX.kI().getFilesDir(), "wx_face/" + str).delete();
    }

    private boolean b(f fVar, boolean z) {
        String str = fVar.gkq;
        if (TextUtils.isEmpty(str)) {
            str = this.gjZ.anN().gkq;
        }
        meri.pluginsdk.h kI = this.gjX.kI();
        File file = new File(kI.getFilesDir(), "wx_face/" + str);
        Object X = boy.X(file);
        if (X != null) {
            fVar.gkr = 2;
            fVar.gkq = str;
            b(0, X);
            return true;
        }
        o pR = pR(str);
        if (pR == null) {
            if (z) {
                b(3, (Object) null);
            }
            return false;
        }
        byte[] az = bot.az(kI, pR.gkI);
        if (az != null) {
            boy.b(file, az);
            fVar.gkr = 2;
            fVar.gkq = str;
            b(0, az);
            return true;
        }
        if (z) {
            b(2, (Object) null);
        }
        return false;
    }

    private void b(n nVar) {
        meri.pluginsdk.h kI = this.gjX.kI();
        o pR = pR(nVar.gkq);
        if (pR == null) {
            b(255, (Object) null);
            return;
        }
        o a2 = a(new String(bot.az(kI, pJ(pR.gkG))), pR);
        if (a2 != null) {
            a(a2);
        }
        if (a2 != null && !TextUtils.isEmpty(a2.gkH)) {
            b(0, a2.gkH);
        } else {
            b(255, (Object) null);
        }
    }

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

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

    private o a(String str, o oVar) {
        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");
            oVar.gkE = string;
            oVar.gkG = string2;
            oVar.gkH = string3;
            oVar.fah = j2;
            return oVar;
        } catch (Exception e2) {
            e2.printStackTrace();
            return null;
        }
    }

    private o pK(String str) {
        bby bbyVar = new bby();
        bbyVar.dsE = str;
        bbyVar.O = 3;
        gu a2 = boy.a((aic) this.gjX.kH().gf(5), "AccountAuthService", 3530, bbyVar, 13530, new bbz(), 30000L);
        if (a2 != null && (a2 instanceof bbz)) {
            bbz bbzVar = (bbz) a2;
            if (bbzVar.result != 0) {
                return null;
            }
            o oVar = new o();
            oVar.gkE = bbzVar.dnw;
            oVar.gkH = bbzVar.eSF;
            oVar.fah = bbzVar.fah;
            oVar.gkG = bbzVar.eSG;
            return oVar;
        }
        return null;
    }

    private o b(String str, o oVar) {
        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");
            oVar.gkE = string;
            oVar.gkF = string2;
            oVar.eRK = string3;
            oVar.gkI = string4;
            return oVar;
        } catch (Exception e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public boolean isWXAppSupportAPI() {
        return this.gjW.isWXAppSupportAPI();
    }

    public MainAccountInfo amV() {
        long anQ = this.gjZ.anQ();
        if (anQ == 0) {
            return null;
        }
        MainAccountInfo mainAccountInfo = new MainAccountInfo();
        mainAccountInfo.dxX = anQ;
        a anM = this.gjZ.anM();
        if (anM != null && anM.dxW) {
            mainAccountInfo.dxY = ae(anM.gkq, 1);
        }
        a anN = this.gjZ.anN();
        if (anN != null && anN.dxW) {
            mainAccountInfo.dxZ = ae(anN.gkq, 2);
        }
        a anP = this.gjZ.anP();
        if (anP != null && anP.dxW) {
            mainAccountInfo.epX = ae(anP.gkq, 4);
        }
        mainAccountInfo.dya = this.gjZ.anO();
        mainAccountInfo.an = this.gjZ.anR();
        return mainAccountInfo;
    }

    public String pL(String str) {
        if (TextUtils.isEmpty(str)) {
            str = this.gjZ.anM().gkq;
        }
        AccountInfo ae = ae(str, 1);
        if (ae == null) {
            return SQLiteDatabase.KeyEmpty;
        }
        String str2 = ae.name;
        if (TextUtils.isEmpty(str2)) {
            return boy.qv(ae.dxP);
        }
        return str2;
    }

    public String pM(String str) {
        if (TextUtils.isEmpty(str)) {
            str = this.gjZ.anN().gkq;
        }
        AccountInfo ae = ae(str, 2);
        if (ae == null) {
            return SQLiteDatabase.KeyEmpty;
        }
        return ae.name;
    }

    public String pN(String str) {
        if (TextUtils.isEmpty(str)) {
            str = this.gjZ.anO();
        }
        return boy.qw(str);
    }

    public String ad(String str, int i2) {
        switch (i2) {
            case 1:
                return pL(str);
            case 2:
                return pM(str);
            case 3:
                return pN(str);
            case 4:
                return pT(str);
            default:
                String pM = pM(str);
                if (TextUtils.isEmpty(pM)) {
                    pM = pL(str);
                }
                if (TextUtils.isEmpty(pM)) {
                    pM = pN(str);
                }
                if (TextUtils.isEmpty(pM)) {
                    return pT(str);
                }
                return pM;
        }
    }

    public int pO(String str) {
        if (this.gjU.GetBasicUserInfo(str, new WloginSimpleInfo()).booleanValue()) {
            return 1;
        }
        if (pR(str) != null) {
            return 2;
        }
        return 0;
    }

    public AccountInfo ae(String str, int i2) {
        boolean z;
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        if (i2 == 1) {
            a anM = this.gjZ.anM();
            String pG = pG(str);
            AccountInfo accountInfo = new AccountInfo();
            accountInfo.type = 1;
            accountInfo.dxP = pG;
            accountInfo.dxQ = pG;
            WloginSimpleInfo wloginSimpleInfo = new WloginSimpleInfo();
            try {
                z = this.gjU.GetBasicUserInfo(str, wloginSimpleInfo).booleanValue();
            } catch (Exception e2) {
                e2.printStackTrace();
                z = false;
            }
            if (!z) {
                if (str.equals(anM.gkq)) {
                    accountInfo.name = anM.name;
                } else {
                    accountInfo.name = SQLiteDatabase.KeyEmpty;
                }
                accountInfo.status = 1;
            } else {
                accountInfo.name = new String(wloginSimpleInfo._nick);
                if (pE(str)) {
                    accountInfo.status = 2;
                } else {
                    accountInfo.status = 0;
                }
            }
            if (str.equals(anM.gkq)) {
                accountInfo.dxW = anM.dxW;
                return accountInfo;
            }
            accountInfo.dxW = false;
            return accountInfo;
        }
        if (i2 == 2) {
            a anN = this.gjZ.anN();
            AccountInfo accountInfo2 = new AccountInfo();
            accountInfo2.type = 2;
            accountInfo2.dxP = str;
            o pR = pR(str);
            if (pR == null) {
                accountInfo2.dxQ = SQLiteDatabase.KeyEmpty;
                if (str.equals(anN.gkq)) {
                    accountInfo2.name = anN.name;
                } else {
                    accountInfo2.name = SQLiteDatabase.KeyEmpty;
                }
                accountInfo2.status = 1;
            } else {
                accountInfo2.dxQ = pR.gkF;
                accountInfo2.name = pR.eRK;
                accountInfo2.status = 0;
            }
            if (str.equals(anN.gkq)) {
                accountInfo2.dxW = anN.dxW;
                return accountInfo2;
            }
            accountInfo2.dxW = false;
            return accountInfo2;
        }
        if (i2 == 3) {
            String anO = this.gjZ.anO();
            AccountInfo accountInfo3 = new AccountInfo();
            accountInfo3.type = 3;
            accountInfo3.dxP = str;
            accountInfo3.dxQ = str;
            accountInfo3.name = SQLiteDatabase.KeyEmpty;
            if (str.equals(anO)) {
                accountInfo3.dxW = true;
                accountInfo3.status = 0;
                return accountInfo3;
            }
            accountInfo3.dxW = false;
            accountInfo3.status = 1;
            return accountInfo3;
        }
        if (i2 == 4) {
            a anP = this.gjZ.anP();
            AccountInfo accountInfo4 = new AccountInfo();
            accountInfo4.type = 4;
            accountInfo4.dxP = str;
            o pV = pV(str);
            if (pV == null) {
                accountInfo4.dxQ = SQLiteDatabase.KeyEmpty;
                if (str.equals(anP.gkq)) {
                    accountInfo4.name = anP.name;
                } else {
                    accountInfo4.name = SQLiteDatabase.KeyEmpty;
                }
                accountInfo4.status = 1;
            } else {
                accountInfo4.dxQ = pV.gkF;
                accountInfo4.name = pV.eRK;
                accountInfo4.status = 0;
            }
            if (str.equals(anP.gkq)) {
                accountInfo4.dxW = anP.dxW;
                return accountInfo4;
            }
            accountInfo4.dxW = false;
            return accountInfo4;
        }
        return null;
    }

    public ArrayList<AccountInfo> amW() {
        ArrayList<AccountInfo> arrayList = new ArrayList<>();
        List<WloginLoginInfo> GetAllLoginInfo = this.gjU.GetAllLoginInfo();
        if (GetAllLoginInfo == null) {
            return arrayList;
        }
        for (WloginLoginInfo wloginLoginInfo : GetAllLoginInfo) {
            if (wloginLoginInfo.mAppid == 0) {
                arrayList.add(ae(wloginLoginInfo.cuC, 1));
            }
        }
        return arrayList;
    }

    private int a(o oVar) {
        ContentValues contentValues = new ContentValues();
        contentValues.put("openid", oVar.gkE);
        contentValues.put("unionid", oVar.gkF);
        contentValues.put("refresh_token", oVar.gkG);
        contentValues.put("access_token", oVar.gkH);
        contentValues.put("expires_in", Long.valueOf(oVar.fah));
        contentValues.put("nickname", oVar.eRK);
        contentValues.put("headimgurl", oVar.gkI);
        if (this.alA.b("wx_user_info_table", contentValues) > 0) {
            return 0;
        }
        return -1;
    }

    public int pP(String str) {
        pI(str);
        if (this.alA.delete("wx_user_info_table", "openid='" + str + "'", null) > 0) {
            return 0;
        }
        return -1;
    }

    public int pQ(String str) {
        pD(str);
        return this.gjU.ClearUserLoginData(str, 0L).booleanValue() ? 0 : -1;
    }

    public o pR(String str) {
        Cursor cursor;
        Exception e2;
        o oVar;
        Cursor cursor2 = null;
        try {
            cursor = this.alA.a("wx_user_info_table", null, "openid='" + str + "'", null, null);
        } catch (Exception e3) {
            e2 = e3;
            oVar = null;
        } catch (Throwable th) {
            th = th;
            cursor = null;
        }
        if (cursor != null) {
            try {
                try {
                } catch (Throwable th2) {
                    th = th2;
                    boy.P(cursor);
                    throw th;
                }
            } catch (Exception e4) {
                e2 = e4;
                oVar = 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);
                oVar = new o();
                try {
                    oVar.gkE = str;
                    oVar.gkF = string;
                    oVar.gkG = string2;
                    oVar.gkH = string3;
                    oVar.fah = j2;
                    oVar.eRK = string4;
                    oVar.gkI = string5;
                    boy.P(cursor);
                } catch (Exception e5) {
                    e2 = e5;
                    cursor2 = cursor;
                    try {
                        e2.printStackTrace();
                        boy.P(cursor2);
                        return oVar;
                    } catch (Throwable th3) {
                        th = th3;
                        cursor = cursor2;
                        boy.P(cursor);
                        throw th;
                    }
                }
                return oVar;
            }
        }
        oVar = null;
        boy.P(cursor);
        return oVar;
    }

    private boolean c(f fVar, boolean z) {
        String str = fVar.gkq;
        if (TextUtils.isEmpty(str)) {
            str = this.gjZ.anO();
        }
        byte[] aoD = boy.aoD();
        if (aoD != null) {
            fVar.gkr = 3;
            fVar.gkq = str;
            b(0, aoD);
            return true;
        }
        if (z) {
            b(2, (Object) null);
        }
        return false;
    }

    private void a(f fVar) {
        if (fVar.gkr == 0) {
            fVar.gkr = this.gjZ.anW();
        }
        switch (fVar.gkr) {
            case 1:
                boolean a2 = a(fVar, !fVar.gks);
                if (!a2 && fVar.gks) {
                    a2 = b(fVar, false);
                }
                if (!a2 && fVar.gks) {
                    c(fVar, true);
                }
                if (!a2 && fVar.gks) {
                    d(fVar, true);
                    return;
                }
                return;
            case 2:
                boolean b2 = b(fVar, !fVar.gks);
                if (!b2 && fVar.gks) {
                    b2 = a(fVar, false);
                }
                if (!b2 && fVar.gks) {
                    c(fVar, true);
                }
                if (!b2 && fVar.gks) {
                    d(fVar, true);
                    return;
                }
                return;
            case 3:
                boolean c2 = c(fVar, !fVar.gks);
                if (!c2 && fVar.gks) {
                    c2 = b(fVar, false);
                }
                if (!c2 && fVar.gks) {
                    a(fVar, true);
                }
                if (!c2 && fVar.gks) {
                    d(fVar, true);
                    return;
                }
                return;
            case 4:
                boolean d2 = d(fVar, !fVar.gks);
                if (!d2 && fVar.gks) {
                    d2 = b(fVar, false);
                }
                if (!d2 && fVar.gks) {
                    a(fVar, true);
                }
                if (!d2 && fVar.gks) {
                    c(fVar, true);
                    return;
                }
                return;
            default:
                boolean b3 = b(fVar, false);
                if (!b3) {
                    b3 = a(fVar, false);
                }
                if (!b3) {
                    c(fVar, true);
                }
                if (!b3) {
                    d(fVar, true);
                    return;
                }
                return;
        }
    }

    private void a(h hVar) {
        if (hVar.gkr == 0) {
            hVar.gkr = this.gjZ.anW();
        }
        switch (hVar.gkr) {
            case 1:
                String str = hVar.gkq;
                if (TextUtils.isEmpty(str)) {
                    str = this.gjZ.anM().gkq;
                }
                String pG = pG(str);
                if (!TextUtils.isEmpty(pG)) {
                    hVar.gkr = 1;
                    hVar.gkq = pG;
                    b(0, "http://w.aq.qq.com/cn/mbtoken3/mbtoken3_get_photo_v2?uin=" + pG);
                    return;
                }
                b(255, (Object) null);
                return;
            case 2:
                String str2 = hVar.gkq;
                if (TextUtils.isEmpty(str2)) {
                    str2 = this.gjZ.anN().gkq;
                }
                o pR = pR(str2);
                if (pR != null && !TextUtils.isEmpty(pR.gkI)) {
                    String str3 = pR.gkI;
                    hVar.gkr = 1;
                    hVar.gkq = str2;
                    b(0, str3);
                    return;
                }
                b(255, (Object) null);
                return;
            default:
                b(255, (Object) null);
                return;
        }
    }

    public boolean amX() {
        String[] split;
        int i2;
        int i3;
        int i4;
        sd e2 = ((qz) this.gjX.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 amY() {
        ArrayList<String> arrayList = new ArrayList<>();
        arrayList.add("/usr_info");
        Bundle bundle = new Bundle();
        bundle.putString("app_id", "80");
        bundle.putStringArrayList(azr.b.dCx, arrayList);
        bundle.putString("state", "qqpimsecure");
        bundle.putInt(meri.pluginsdk.d.bss, azr.c.dCA);
        this.gjX.a(ayn.eom, 100, bundle, PiAccount.apn(), 600);
        return true;
    }

    public boolean b(Bundle bundle, d dVar) {
        k kVar = new k();
        kVar.gkA = 3;
        kVar.gkz = bundle;
        kVar.gky = dVar;
        Message obtain = Message.obtain();
        obtain.what = 100;
        obtain.obj = kVar;
        a(this.gjS.getAndIncrement(), obtain, 0L);
        return true;
    }

    private void a(k kVar) {
        Bundle bundle = kVar.gkz;
        int i2 = bundle.getInt("result");
        String string = bundle.getString(azr.b.dCz);
        if (i2 != 0) {
            b(i2, (Object) null);
            return;
        }
        axm axmVar = new axm();
        axmVar.appId = "80";
        axmVar.eUA = SQLiteDatabase.KeyEmpty;
        axmVar.eUB = string;
        gu a2 = boy.a((aic) this.gjX.kH().gf(5), "AccountAuthService", hv.bDf, axmVar, hv.ciS, new axt(), 30000L);
        if (a2 == null) {
            b(2, (Object) null);
            return;
        }
        if (!(a2 instanceof axt)) {
            b(2, (Object) null);
            return;
        }
        axt axtVar = (axt) a2;
        int rC = bph.rC(axtVar.csk);
        if (rC != 0) {
            b(rC, (Object) null);
            return;
        }
        o oVar = new o();
        oVar.gkE = axtVar.dnw;
        oVar.gkF = oVar.gkE;
        oVar.gkH = axtVar.eSF;
        oVar.fah = axtVar.eUP;
        oVar.gkG = axtVar.eSG;
        b(oVar);
        b(0, oVar);
    }

    private void a(final int i2, k kVar, Object obj) {
        o oVar = (o) obj;
        final String str = oVar != null ? oVar.gkE : SQLiteDatabase.KeyEmpty;
        final d dVar = kVar.gky;
        if (dVar != null) {
            this.gjY.post(new Runnable() {
                @Override
                public void run() {
                    dVar.a(i2, str, 4, null);
                }
            });
        }
        this.gjT = null;
    }

    private void pS(String str) {
        new File(this.gjX.kI().getFilesDir(), "qqpim_face/" + str).delete();
    }

    private boolean d(f fVar, boolean z) {
        String str = fVar.gkq;
        if (TextUtils.isEmpty(str)) {
            str = this.gjZ.anP().gkq;
        }
        meri.pluginsdk.h kI = this.gjX.kI();
        File file = new File(kI.getFilesDir(), "qqpim_face/" + str);
        Object X = boy.X(file);
        if (X != null) {
            fVar.gkr = 4;
            fVar.gkq = str;
            b(0, X);
            return true;
        }
        o pV = pV(str);
        if (pV == null) {
            if (z) {
                b(3, (Object) null);
            }
            return false;
        }
        byte[] az = bot.az(kI, pV.gkI);
        if (az != null) {
            boy.b(file, az);
            fVar.gkr = 4;
            fVar.gkq = str;
            b(0, az);
            return true;
        }
        if (z) {
            b(2, (Object) null);
        }
        return false;
    }

    private void c(n nVar) {
        o pV = pV(nVar.gkq);
        if (pV == null) {
            b(255, (Object) null);
            return;
        }
        axn axnVar = new axn();
        axnVar.appId = "80";
        axnVar.eUA = SQLiteDatabase.KeyEmpty;
        axnVar.eSG = pV.gkG;
        gu a2 = boy.a((aic) this.gjX.kH().gf(5), "AccountAuthService", hv.bDh, axnVar, hv.ciV, new axv(), 30000L);
        if (a2 == null) {
            b(2, (Object) null);
            return;
        }
        if (!(a2 instanceof axt)) {
            b(2, (Object) null);
            return;
        }
        axv axvVar = (axv) a2;
        int rC = bph.rC(axvVar.csk);
        if (rC != 0) {
            b(rC, (Object) null);
            return;
        }
        pV.gkE = axvVar.dnw;
        pV.gkF = pV.gkE;
        pV.gkH = axvVar.eSF;
        pV.fah = axvVar.eUP;
        pV.gkG = axvVar.eSG;
        b(pV);
        b(0, pV.gkH);
    }

    public String pT(String str) {
        if (TextUtils.isEmpty(str)) {
            str = this.gjZ.anP().gkq;
        }
        AccountInfo ae = ae(str, 4);
        if (ae == null) {
            return SQLiteDatabase.KeyEmpty;
        }
        return ae.name;
    }

    private int b(o oVar) {
        ContentValues contentValues = new ContentValues();
        contentValues.put("openid", oVar.gkE);
        contentValues.put("unionid", oVar.gkF);
        contentValues.put("refresh_token", oVar.gkG);
        contentValues.put("access_token", oVar.gkH);
        contentValues.put("expires_in", Long.valueOf(oVar.fah));
        contentValues.put("nickname", oVar.eRK);
        contentValues.put("headimgurl", oVar.gkI);
        if (this.alA.b("qqpim_user_info_table", contentValues) > 0) {
            return 0;
        }
        return -1;
    }

    public int pU(String str) {
        pS(str);
        if (this.alA.delete("qqpim_user_info_table", "openid='" + str + "'", null) > 0) {
            return 0;
        }
        return -1;
    }

    public o pV(String str) {
        Cursor cursor;
        Exception e2;
        o oVar;
        Cursor cursor2 = null;
        try {
            cursor = this.alA.a("qqpim_user_info_table", null, "openid='" + str + "'", null, null);
        } catch (Exception e3) {
            e2 = e3;
            oVar = null;
        } catch (Throwable th) {
            th = th;
            cursor = null;
        }
        if (cursor != null) {
            try {
                try {
                } catch (Throwable th2) {
                    th = th2;
                    boy.P(cursor);
                    throw th;
                }
            } catch (Exception e4) {
                e2 = e4;
                oVar = 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);
                oVar = new o();
                try {
                    oVar.gkE = str;
                    oVar.gkF = string;
                    oVar.gkG = string2;
                    oVar.gkH = string3;
                    oVar.fah = j2;
                    oVar.eRK = string4;
                    oVar.gkI = string5;
                    boy.P(cursor);
                } catch (Exception e5) {
                    e2 = e5;
                    cursor2 = cursor;
                    try {
                        e2.printStackTrace();
                        boy.P(cursor2);
                        return oVar;
                    } catch (Throwable th3) {
                        th = th3;
                        cursor = cursor2;
                        boy.P(cursor);
                        throw th;
                    }
                }
                return oVar;
            }
        }
        oVar = null;
        boy.P(cursor);
        return oVar;
    }

    public o pW(String str) {
        o oVar;
        Exception e2;
        String pG;
        String b2;
        long j2;
        String str2;
        String str3;
        try {
            pG = pG(str);
            Ticket GetLocalTicket = this.gjU.GetLocalTicket(str, 0L, 64);
            b2 = b(GetLocalTicket);
            j2 = GetLocalTicket.hKn * 1000;
            WloginSimpleInfo wloginSimpleInfo = new WloginSimpleInfo();
            this.gjU.GetBasicUserInfo(str, wloginSimpleInfo);
            str2 = new String(wloginSimpleInfo._nick);
            str3 = "http://w.aq.qq.com/cn/mbtoken3/mbtoken3_get_photo_v2?uin=" + str;
            oVar = new o();
        } catch (Exception e3) {
            oVar = null;
            e2 = e3;
        }
        try {
            oVar.gkE = str;
            oVar.gkF = pG;
            oVar.gkG = b2;
            oVar.gkH = b2;
            oVar.fah = j2;
            oVar.eRK = str2;
            oVar.gkI = str3;
        } catch (Exception e4) {
            e2 = e4;
            e2.printStackTrace();
            return oVar;
        }
        return oVar;
    }

    public void amZ() {
        ((ahi) bof.amO().kH().gf(8)).a(ayn.eom, 17498115, new Bundle());
        ans.xW().as(this.gjZ.anQ() != 0);
        if (this.gjZ.anQ() != 0) {
            bpl.aoX().c(null);
        }
    }
}