手机管家 v6.0.0版本的 MD5 值为:bf0bca2cb03f766137fe9ecf7383a634

以下内容为反编译后的 bjy.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 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.auv;
import tcs.azr;
import tmsdk.fg.tcc.LoginUtil;

public class bjy extends bkf {
    private static final int[] eXd = {64, 128, 4096, 131072, 32, 524288};
    private static bjy eXo = null;
    private final aha alA;
    private final List<g> eXe;
    private final AtomicInteger eXf;
    private g eXg;
    private final WtloginHelper eXh;
    private final IWXAPI eXi;
    private final String eXj;
    private final String eXk;
    private final meri.pluginsdk.c eXl;
    private final Handler eXm;
    public b eXn;
    private oicq.wlogin_sdk.request.b eXp;

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

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

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

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

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

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

    public static class g {
        public int eXH;

        private g() {
        }
    }

    public static class f extends g {
        public String UU;
        public long eXD;
        public String eXE;
        public Intent eXF;
        public c eXG;

        private f() {
            super();
        }
    }

    public static class k extends g {
        public c eXG;
        public Bundle eXL;

        private k() {
            super();
        }
    }

    public static class i extends g {
        public String eXA;
        public int eXB;
        public int eXI;
        public boolean eXJ;
        public h eXK;

        private i() {
            super();
        }
    }

    public static class e extends g {
        public String eXA;
        public int eXB;
        public d eXC;

        private e() {
            super();
        }
    }

    public static class l {
        public String eXM;
        public String eXN;
        public String eXO;
        public String eXP;
        public long eXQ;
        public String eXR;
        public String ewd;

        l() {
        }
    }

    public static synchronized void b(meri.pluginsdk.c cVar) {
        synchronized (bjy.class) {
            if (eXo == null) {
                eXo = new bjy(cVar);
            }
        }
    }

    public static synchronized void destroy() {
        synchronized (bjy.class) {
            eXo = null;
        }
    }

    public static synchronized bjy PK() {
        bjy bjyVar;
        synchronized (bjy.class) {
            if (eXo == null) {
                throw new RuntimeException("You should call init first!!!");
            }
            bjyVar = eXo;
        }
        return bjyVar;
    }

    private bjy(meri.pluginsdk.c cVar) {
        super(cVar, "AccountAuthService");
        this.eXp = 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();
                }
                bjy.this.b(mn(i3), (Object) null);
            }

            @Override
            public void OnGetStWithPasswd(String str, long j2, int i2, long j3, String str2, WUserSigInfo wUserSigInfo, int i3, ErrMsg errMsg) {
                if (errMsg != null) {
                    errMsg.getMessage();
                }
                int mn = mn(i3);
                Bitmap f2 = f(str, null);
                if (f2 != null) {
                    mn = LoginUtil.EM_LOGIN_RES_SYSTEM_MAINTENANCE;
                }
                bjy.this.b(mn, new Object[]{str, f2});
            }

            @Override
            public void OnCheckPictureAndGetSt(String str, byte[] bArr, WUserSigInfo wUserSigInfo, int i2, ErrMsg errMsg) {
                Bitmap bitmap = null;
                if (errMsg != null) {
                    errMsg.getMessage();
                }
                int mn = mn(i2);
                String str2 = SQLiteDatabase.KeyEmpty;
                if (i2 == 2) {
                    bitmap = f(str, null);
                } else if (i2 == 0) {
                    str2 = bjy.this.b(bjy.this.eXh.GetLocalTicket(str, 526017603L, 64));
                }
                if (bitmap != null) {
                    mn = LoginUtil.EM_LOGIN_RES_SYSTEM_MAINTENANCE;
                }
                bjy.this.b(mn, new Object[]{str, str2, bitmap});
            }

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

            @Override
            public void OnException(ErrMsg errMsg, int i2, WUserSigInfo wUserSigInfo) {
                if (errMsg != null) {
                    errMsg.getMessage();
                }
                bjy.this.b(255, (Object) null);
            }

            private Bitmap f(String str, byte[] bArr) {
                if (bArr == null) {
                    bArr = bjy.this.eXh.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 mn(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;
                }
            }
        };
        this.eXh = new WtloginHelper(cVar.kI());
        this.eXh.SetImgType(1);
        this.eXh.SetListener(this.eXp);
        if (bkm.TW()) {
            this.eXj = "wx3b9e739bed0974ca";
            this.eXk = "69f513653bdf12991ffa150a7d5e0b7b";
        } else {
            this.eXj = zb.cZd;
            this.eXk = "c9765f85f7a5093fa660c16618d5a1dd";
        }
        this.eXi = WXAPIFactory.createWXAPI(cVar.kI(), this.eXj, true);
        try {
            this.eXi.registerApp(this.eXj);
        } catch (Exception e2) {
            e2.printStackTrace();
        }
        this.eXe = new ArrayList();
        this.eXf = new AtomicInteger(0);
        this.eXg = null;
        this.eXl = cVar;
        this.alA = ((aid) cVar.kH().gf(9)).dG("QQSecureProvider");
        this.eXm = new Handler(Looper.getMainLooper());
    }

    public void a(b bVar, int i2, int i3, String str, boolean z, String str2, String str3, String str4, boolean z2, int i4) {
        int i5;
        this.eXn = bVar;
        if (i3 == 0) {
            i5 = 17498213;
        } else if (i3 == 1) {
            i5 = Z(str, i2);
        } else if (i3 == 2) {
            i5 = 17498221;
        } else if (i3 == 3) {
            if (!PN() && isWXAppInstalled()) {
                i5 = 17498221;
            } else {
                i5 = Z(str, i2);
            }
        } else if (i3 == 4) {
            if (isWXAppInstalled()) {
                i5 = 17498221;
            } else {
                i5 = Z(str, i2);
            }
        } else if (i3 == 5) {
            if (le(str) == 1) {
                i5 = Z(str, i2);
            } else {
                i5 = 17498221;
            }
        } else if (i3 == 6) {
            i5 = 17498216;
        } else if (i3 == 7) {
            i5 = Z(str, i2);
        } else if (i3 == 8) {
            i5 = 17498214;
        } 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, str);
        bundle.putString("title", str2);
        bundle.putString(azr.b.ejV, str3);
        bundle.putString("source", str4);
        bundle.putBoolean("use_cache_token", z);
        pluginIntent.putExtra("args", bundle);
        if (i5 == 17498215 || i5 == 17498221) {
            pluginIntent.putExtra(PluginIntent.csC, 1);
        }
        if (z2) {
            pluginIntent.addFlags(402653184);
        }
        if (i4 == 0) {
            ((meri.pluginsdk.b) this.eXl).a(pluginIntent, false);
        } else {
            ((meri.pluginsdk.b) this.eXl).a(pluginIntent, i4, false);
        }
    }

    private int Z(String str, int i2) {
        MainAccountInfo PQ;
        if (!TextUtils.isEmpty(str) || i2 == 0 || i2 == 3 || i2 == 6 || !PN()) {
            return 17498214;
        }
        return (i2 != 1 || (PQ = PK().PQ()) == null || PQ.dxY == null || TextUtils.isEmpty(PQ.dxY.dxP)) ? 17498215 : 17498214;
    }

    public void a(String str, int i2, d dVar) {
        e eVar = new e();
        eVar.eXH = 4;
        eVar.eXA = str;
        eVar.eXB = i2;
        eVar.eXC = dVar;
        Message obtain = Message.obtain();
        obtain.what = 100;
        obtain.obj = eVar;
        a(this.eXf.getAndIncrement(), obtain, 0L);
    }

    public void a(String str, int i2, int i3, boolean z, h hVar) {
        i iVar = new i();
        iVar.eXH = 3;
        iVar.eXA = str;
        iVar.eXB = i2;
        iVar.eXI = i3;
        iVar.eXJ = z;
        iVar.eXK = hVar;
        Message obtain = Message.obtain();
        obtain.what = 100;
        obtain.obj = iVar;
        a(this.eXf.getAndIncrement(), obtain, 0L);
    }

    public String l(String str, int i2, int i3) {
        if (TextUtils.isEmpty(str)) {
            return SQLiteDatabase.KeyEmpty;
        }
        if (i2 == 1) {
            return b(this.eXh.GetLocalTicket(str, 526017603L, i3));
        }
        l lh = lh(str);
        return lh != null ? lh.eXP : SQLiteDatabase.KeyEmpty;
    }

    @Override
    protected void K(Object obj) {
        Message message = (Message) obj;
        switch (message.what) {
            case 100:
                a((g) message.obj);
                return;
            case 101:
                PM();
                return;
            case 102:
                c(message.arg1, message.obj);
                return;
            case 103:
                this.eXh.RefreshPictureData((String) message.obj, new WUserSigInfo());
                return;
            case 104:
                String[] strArr = (String[]) message.obj;
                this.eXh.CheckPictureAndGetSt(strArr[0], strArr[1].getBytes(), new WUserSigInfo());
                return;
            case 105:
                this.eXg = null;
                PL();
                return;
            default:
                return;
        }
    }

    private void a(g gVar) {
        this.eXe.add(gVar);
        if (this.eXe.size() == 1 && this.eXg == null) {
            PL();
        }
    }

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

    private void PM() {
        if (this.eXe.size() != 0) {
            g remove = this.eXe.remove(0);
            this.eXg = remove;
            switch (remove.eXH) {
                case 1:
                    a((f) remove);
                    return;
                case 2:
                    a((k) remove);
                    return;
                case 3:
                    if (((i) remove).eXB == 1) {
                        a((i) remove);
                        return;
                    } else {
                        b((i) remove);
                        return;
                    }
                case 4:
                    e eVar = (e) remove;
                    if (eVar.eXB == 0) {
                        eVar.eXB = bkd.RL().SM();
                    }
                    if (eVar.eXB == 1) {
                        a(eVar);
                        return;
                    } else {
                        b(eVar);
                        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.eXf.getAndIncrement(), obtain, 0L);
    }

    private void c(int i2, Object obj) {
        if (this.eXg == null) {
            PL();
            return;
        }
        g gVar = this.eXg;
        switch (gVar.eXH) {
            case 1:
                a(i2, (f) gVar, obj);
                break;
            case 2:
                a(i2, (k) gVar, obj);
                break;
            case 3:
                a(i2, (i) gVar, obj);
                break;
            case 4:
                a(i2, (e) gVar, obj);
                break;
        }
        if (this.eXg == null) {
            PL();
        }
    }

    private void a(final int i2, e eVar, Object obj) {
        final String str = eVar.eXA;
        final int i3 = eVar.eXB;
        final byte[] bArr = (byte[]) obj;
        final d dVar = eVar.eXC;
        if (dVar != null) {
            this.eXm.post(new Runnable() {
                @Override
                public void run() {
                    dVar.a(i2, str, i3, bArr);
                }
            });
        }
        this.eXg = null;
    }

    private void a(f fVar) {
        long j2 = fVar.eXD;
        if (fVar.eXF != null) {
            WUserSigInfo ResolveQloginIntent = this.eXh.ResolveQloginIntent(fVar.eXF);
            this.eXh.GetStWithPasswd(ResolveQloginIntent.cTF, j2, 1L, 659680, SQLiteDatabase.KeyEmpty, ResolveQloginIntent);
        } else {
            WUserSigInfo wUserSigInfo = new WUserSigInfo();
            this.eXh.GetStWithPasswd(fVar.UU, j2, 1L, 659680, fVar.eXE, wUserSigInfo);
        }
    }

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

    private void a(e eVar) {
        String str;
        JSONObject jSONObject;
        if (TextUtils.isEmpty(eVar.eXA)) {
            eVar.eXA = bkd.RL().RP().eXA;
        }
        String kZ = kZ(eVar.eXA);
        meri.pluginsdk.h kI = this.eXl.kI();
        File file = new File(kI.getFilesDir(), "qq_face/" + kZ);
        Object H = bkm.H(file);
        if (H != null) {
            b(0, H);
            return;
        }
        Object H2 = bkm.H(new File(kI.getCacheDir(), tmsdk.common.internal.utils.q.iG(kZ)));
        if (H2 != null) {
            b(0, H2);
            return;
        }
        byte[] at = bkj.at(kI, "http://w.aq.qq.com/cn/mbtoken3/mbtoken3_get_photo_v2?uin=" + kZ);
        if (at == null) {
            b(2, (Object) null);
            return;
        }
        try {
            jSONObject = new JSONObject(new String(at));
        } catch (JSONException e2) {
        }
        if (jSONObject.getInt("err") == 0) {
            str = jSONObject.getString(ang.a.dUI);
            if (str != null) {
                b(2, (Object) null);
                return;
            }
            if (str.endsWith("&t=0")) {
                str = str.replace("&s=100", "&s=40");
            }
            byte[] at2 = bkj.at(kI, str);
            if (at2 != null) {
                bkm.a(file, at2);
                b(0, at2);
                return;
            } else {
                b(2, (Object) null);
                return;
            }
        }
        str = null;
        if (str != null) {
        }
    }

    private void a(i iVar) {
        String str = iVar.eXA;
        int i2 = iVar.eXI;
        boolean z = iVar.eXJ;
        if (TextUtils.isEmpty(str)) {
            b(4, (Object) null);
            return;
        }
        WUserSigInfo GetLocalSig = this.eXh.GetLocalSig(str, 526017603L);
        if (GetLocalSig == null) {
            b(3, (Object) null);
            return;
        }
        boolean z2 = false;
        for (int i3 : eXd) {
            if ((i2 & i3) != 0) {
                Ticket GetLocalTicket = this.eXh.GetLocalTicket(str, 526017603L, 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.eXh.GetStWithoutPasswd(str, 526017603L, 526017603L, 1L, i2, GetLocalSig) != -1001) {
            b(4, (Object) null);
        }
    }

    private void a(ArrayList<Bundle> arrayList, int i2, String str) {
        for (int i3 : eXd) {
            if ((i2 & i3) != 0) {
                String b2 = b(this.eXh.GetLocalTicket(str, 526017603L, 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, i iVar, Object obj) {
        final String str = iVar.eXA;
        final int i3 = iVar.eXB;
        int i4 = iVar.eXI;
        final ArrayList<Bundle> arrayList = new ArrayList<>();
        if (i2 == 0) {
            a(arrayList, i4, str);
        }
        final h hVar = iVar.eXK;
        if (hVar != null) {
            this.eXm.post(new Runnable() {
                @Override
                public void run() {
                    hVar.a(i2, str, i3, arrayList);
                }
            });
        }
        this.eXg = null;
    }

    private void a(final int i2, f fVar, Object obj) {
        Object[] objArr = (Object[]) obj;
        final String str = (String) objArr[0];
        final Bitmap bitmap = (Bitmap) objArr[1];
        final c cVar = fVar.eXG;
        if (cVar != null) {
            this.eXm.post(new Runnable() {
                @Override
                public void run() {
                    cVar.a(i2, str, 1, bitmap);
                }
            });
        }
        if (bitmap == null) {
            this.eXg = null;
        }
    }

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

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

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

    public boolean kX(String str) {
        return a(this.eXh.GetLocalTicket(str, 526017603L, 64));
    }

    public boolean kY(String str) {
        return a(this.eXh.GetLocalTicket(str, 526017603L, 64), 1296000000L);
    }

    public String kZ(String str) {
        if (TextUtils.isEmpty(str)) {
            return SQLiteDatabase.KeyEmpty;
        }
        WloginSimpleInfo wloginSimpleInfo = new WloginSimpleInfo();
        if (this.eXh.GetBasicUserInfo(str, wloginSimpleInfo).booleanValue()) {
            return Long.toString(wloginSimpleInfo._uin);
        }
        return str;
    }

    public boolean PN() {
        return this.eXh.PrepareQloginIntent(526017603L, 1L, "1") != null;
    }

    public boolean a(Activity activity, long j2, int i2) {
        Intent PrepareQloginIntent = this.eXh.PrepareQloginIntent(j2, 1L, "1");
        if (PrepareQloginIntent == null) {
            return false;
        }
        try {
            activity.startActivityForResult(PrepareQloginIntent, i2);
            return true;
        } catch (Exception e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public void a(long j2, String str, String str2, Intent intent, c cVar) {
        f fVar = new f();
        fVar.eXH = 1;
        fVar.eXD = j2;
        fVar.UU = str;
        fVar.eXE = str2;
        fVar.eXF = intent;
        fVar.eXG = cVar;
        Message obtain = Message.obtain();
        obtain.what = 100;
        obtain.obj = fVar;
        a(this.eXf.getAndIncrement(), obtain, 0L);
        TextUtils.isEmpty(str);
    }

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

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

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

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

    public boolean a(Bundle bundle, c cVar) {
        if (bundle.getInt(auv.f.a.ERROR_CODE) != 0) {
            return false;
        }
        k kVar = new k();
        kVar.eXH = 2;
        kVar.eXL = bundle;
        kVar.eXG = cVar;
        Message obtain = Message.obtain();
        obtain.what = 100;
        obtain.obj = kVar;
        a(this.eXf.getAndIncrement(), obtain, 0L);
        return true;
    }

    private void a(k kVar) {
        Bundle bundle = kVar.eXL;
        int i2 = bundle.getInt(auv.f.a.ERROR_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("authorization_code");
        meri.pluginsdk.h kI = this.eXl.kI();
        l a2 = a(new String(bkj.at(kI, lc(string))), new l());
        if (a2 == null) {
            b(2, (Object) null);
            return;
        }
        l b2 = b(new String(bkj.at(kI, aB(a2.eXM, a2.eXP))), a2);
        if (b2 == null) {
            b(2, (Object) null);
        } else {
            a(b2);
            b(0, b2);
        }
    }

    private void a(final int i2, k kVar, Object obj) {
        final String str = ((l) obj).eXM;
        final c cVar = kVar.eXG;
        if (cVar != null) {
            this.eXm.post(new Runnable() {
                @Override
                public void run() {
                    cVar.a(i2, str, 2, null);
                }
            });
        }
        this.eXg = null;
    }

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

    private void b(e eVar) {
        if (TextUtils.isEmpty(eVar.eXA)) {
            eVar.eXA = bkd.RL().RT().eXA;
        }
        String str = eVar.eXA;
        meri.pluginsdk.h kI = this.eXl.kI();
        File file = new File(kI.getFilesDir(), "wx_face/" + str);
        Object H = bkm.H(file);
        if (H != null) {
            b(0, H);
            return;
        }
        l lh = lh(str);
        if (lh == null) {
            b(3, (Object) null);
            return;
        }
        byte[] at = bkj.at(kI, lh.eXR);
        if (at != null) {
            bkm.a(file, at);
            b(0, at);
        } else {
            b(2, (Object) null);
        }
    }

    private String b(i iVar) {
        meri.pluginsdk.h kI = this.eXl.kI();
        l lh = lh(iVar.eXA);
        if (lh == null) {
            return SQLiteDatabase.KeyEmpty;
        }
        l a2 = a(new String(bkj.at(kI, ld(lh.eXO))), lh);
        if (a2 != null) {
            a(a2);
        }
        return a2 != null ? a2.eXP : SQLiteDatabase.KeyEmpty;
    }

    private String lc(String str) {
        return "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + this.eXj + "&secret=" + this.eXk + "&code=" + str + "&grant_type=authorization_code";
    }

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

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

    private l a(String str, l lVar) {
        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");
            lVar.eXM = string;
            lVar.eXO = string2;
            lVar.eXP = string3;
            lVar.eXQ = j2;
            return lVar;
        } catch (Exception e2) {
            e2.printStackTrace();
            return null;
        }
    }

    private l b(String str, l lVar) {
        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");
            lVar.eXM = string;
            lVar.eXN = string2;
            lVar.ewd = string3;
            lVar.eXR = string4;
            return lVar;
        } catch (Exception e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public boolean isWXAppInstalled() {
        return this.eXi.isWXAppInstalled();
    }

    public MainAccountInfo PQ() {
        long SJ = bkk.TT().SJ();
        if (SJ == 0) {
            return null;
        }
        MainAccountInfo mainAccountInfo = new MainAccountInfo();
        mainAccountInfo.dxX = SJ;
        mainAccountInfo.dxY = aa(bkd.RL().RP().eXA, 1);
        mainAccountInfo.dxZ = aa(bkd.RL().RT().eXA, 2);
        mainAccountInfo.dya = bkd.RL().RX();
        mainAccountInfo.an = bkd.RL().RZ();
        return mainAccountInfo;
    }

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

    public AccountInfo aa(String str, int i2) {
        AccountInfo accountInfo = null;
        if (!TextUtils.isEmpty(str)) {
            if (i2 == 1) {
                a RP = bkd.RL().RP();
                accountInfo = new AccountInfo();
                accountInfo.type = 1;
                accountInfo.dxP = str;
                WloginSimpleInfo wloginSimpleInfo = new WloginSimpleInfo();
                if (!this.eXh.GetBasicUserInfo(str, wloginSimpleInfo).booleanValue()) {
                    accountInfo.dxQ = kZ(str);
                    if (str.equals(RP.eXA)) {
                        accountInfo.name = RP.name;
                    } else {
                        accountInfo.name = SQLiteDatabase.KeyEmpty;
                    }
                    accountInfo.status = 1;
                } else {
                    accountInfo.dxQ = kZ(str);
                    accountInfo.name = new String(wloginSimpleInfo._nick);
                    if (kX(str)) {
                        accountInfo.status = 2;
                    } else {
                        accountInfo.status = 0;
                    }
                }
                if (str.equals(RP.eXA)) {
                    accountInfo.dxW = RP.dxW;
                } else {
                    accountInfo.dxW = false;
                }
            } else if (i2 == 2) {
                a RT = bkd.RL().RT();
                accountInfo = new AccountInfo();
                accountInfo.type = 2;
                accountInfo.dxP = str;
                l lh = lh(str);
                if (lh == null) {
                    accountInfo.dxQ = SQLiteDatabase.KeyEmpty;
                    if (str.equals(RT.eXA)) {
                        accountInfo.name = RT.name;
                    } else {
                        accountInfo.name = SQLiteDatabase.KeyEmpty;
                    }
                    accountInfo.status = 1;
                } else {
                    accountInfo.dxQ = lh.eXN;
                    accountInfo.name = lh.ewd;
                    accountInfo.status = 0;
                }
                if (str.equals(RT.eXA)) {
                    accountInfo.dxW = RT.dxW;
                } else {
                    accountInfo.dxW = false;
                }
            }
        }
        return accountInfo;
    }

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

    private int a(l lVar) {
        ContentValues contentValues = new ContentValues();
        contentValues.put("openid", lVar.eXM);
        contentValues.put("unionid", lVar.eXN);
        contentValues.put("refresh_token", lVar.eXO);
        contentValues.put("access_token", lVar.eXP);
        contentValues.put("expires_in", Long.valueOf(lVar.eXQ));
        contentValues.put("nickname", lVar.ewd);
        contentValues.put("headimgurl", lVar.eXR);
        if (this.alA.b("wx_user_info_table", contentValues) > 0) {
            return 0;
        }
        return -1;
    }

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

    public int lg(String str) {
        kW(str);
        return this.eXh.ClearUserLoginData(str, 526017603L).booleanValue() ? 0 : -1;
    }

    public l lh(String str) {
        Cursor cursor;
        Exception e2;
        l lVar;
        Cursor cursor2 = null;
        try {
            cursor = this.alA.a("wx_user_info_table", null, "openid='" + str + "'", null, null);
        } catch (Exception e3) {
            e2 = e3;
            lVar = null;
        } catch (Throwable th) {
            th = th;
            cursor = null;
        }
        if (cursor != null) {
            try {
                try {
                } catch (Throwable th2) {
                    th = th2;
                    bkm.L(cursor);
                    throw th;
                }
            } catch (Exception e4) {
                e2 = e4;
                lVar = 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);
                lVar = new l();
                try {
                    lVar.eXM = str;
                    lVar.eXN = string;
                    lVar.eXO = string2;
                    lVar.eXP = string3;
                    lVar.eXQ = j2;
                    lVar.ewd = string4;
                    lVar.eXR = string5;
                    bkm.L(cursor);
                } catch (Exception e5) {
                    e2 = e5;
                    cursor2 = cursor;
                    try {
                        e2.printStackTrace();
                        bkm.L(cursor2);
                        return lVar;
                    } catch (Throwable th3) {
                        th = th3;
                        cursor = cursor2;
                        bkm.L(cursor);
                        throw th;
                    }
                }
                return lVar;
            }
        }
        lVar = null;
        bkm.L(cursor);
        return lVar;
    }
}