Aqara Home v2.4.1版本的 MD5 值为:529779ac2bc0131db52a1fc3098d2b35

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


package com.lumiunited.aqara.login.bean;

import android.content.Context;
import androidx.annotation.Keep;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.lumiunited.aqara.application.base.BaseApplication;
import com.lumiunited.aqara.location.bean.AppIdentifyEntity;
import com.lumiunited.aqarahome.R;
import com.tencent.mm.opensdk.modelmsg.SendAuth;
import com.umeng.socialize.handler.UMWXHandler;
import java.util.HashMap;
import java.util.Map;
import k.u.c.d.d.l0;
import k.u.c.d.j.n;
import k.u.c.d.j.o0;
import k.u.c.r.l.c;
import k.u.c.r.l.d;
import k.u.c.s.f.a;
@Keep
public class WxUserInfo implements k.u.c.s.f.a {
    public static final int ERROR_AUTH_FAIL = 2;
    public static final int ERROR_LOGIN_FAIL = 3;
    public static final int ERROR_WITHOUT_WX = 1;
    public static final long Expire = 1296000000;
    public static final WxUserInfo Instance = new WxUserInfo();
    public String AccessToken;
    public String City;
    public String HeadImgUrl;
    public boolean IsAuth;
    public long LastAuthTime;
    public String NickName;
    public String OpenId;
    public String RefreshToken;
    public String UnionId;
    public String WXAuthPayload;
    public a.InterfaceC0724a mListener;

    public class a implements n<String> {
        public final Context a;

        public a(Context context) {
            this.a = context;
        }

        @Override
        public void onSuccess(String str) {
            WxUserInfo.this.getPersonMessage(this.a, str);
        }

        @Override
        public void onFailed(int i2, String str) {
            WxUserInfo.this.mListener.a(2, str);
        }
    }

    public class b implements n<String> {
        public final JSONObject a;
        public final Context b;

        public b(JSONObject jSONObject, Context context) {
            this.a = jSONObject;
            this.b = context;
        }

        @Override
        public void onSuccess(String str) {
            JSONObject parseObject = JSON.parseObject(str);
            for (Map.Entry<String, Object> entry : this.a.entrySet()) {
                parseObject.put(entry.getKey(), entry.getValue());
            }
            WxUserInfo.this.uploadToken(this.b, parseObject.toJSONString(), null);
        }

        @Override
        public void onFailed(int i2, String str) {
            WxUserInfo.this.mListener.a(2, str);
        }
    }

    public void getPersonMessage(Context context, String str) {
        String str2;
        JSONObject parseObject = JSON.parseObject(str);
        if (parseObject != null) {
            String string = parseObject.containsKey("access_token") ? parseObject.getString("access_token") : null;
            str2 = parseObject.containsKey("openid") ? parseObject.getString("openid") : null;
            r0 = string;
        } else {
            str2 = null;
        }
        if (r0 != null && str2 != null) {
            l0.i().a("https://api.weixin.qq.com/sns/userinfo?access_token=" + r0 + "&openid=" + str2, "GET", "", (HashMap<String, String>) null, new b(parseObject, context));
            return;
        }
        this.mListener.a(2, "Can't get access_token");
    }

    private void oAuthLogin(Context context, JSONObject jSONObject, JSONObject jSONObject2) {
    }

    private void startRequestWXCode() {
        SendAuth.Req req = new SendAuth.Req();
        req.scope = "snsapi_userinfo";
        req.state = "wechat_sdk_demo";
        BaseApplication.f8964h.sendReq(req);
    }

    @Override
    public void DoAuth(Context context, a.InterfaceC0724a interfaceC0724a) {
        if (interfaceC0724a != null) {
            this.mListener = interfaceC0724a;
        }
        if (!IsWXAppInstalled()) {
            this.mListener.a(1, context != null ? context.getString(R.string.install_wechat_first) : "请先安装微信客户端");
        } else {
            startRequestWXCode();
        }
    }

    @Override
    public String GetAuthPayload() {
        return null;
    }

    public void GetWXInfo(Context context, String str) {
        if (str != null) {
            l0.i().a("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + k.u.c.a.Q + "&secret=" + k.u.c.a.R + "&code=" + str + "&grant_type=authorization_code", "GET", "", (HashMap<String, String>) null, new a(context));
            return;
        }
        this.mListener.a(2, "code, appid or secret is null");
    }

    public boolean IsWXAppInstalled() {
        return BaseApplication.f8964h.isWXAppInstalled();
    }

    public void fillUser(String str) {
        JSONObject parseObject = JSON.parseObject(str);
        if (parseObject != null) {
            this.OpenId = parseObject.getString("openid");
            this.AccessToken = parseObject.getString("access_token");
            this.RefreshToken = parseObject.getString("refresh_token");
            this.HeadImgUrl = parseObject.getString(UMWXHandler.HEADIMGURL);
            this.NickName = parseObject.getString("nickname");
            this.City = parseObject.getString("city");
            this.UnionId = parseObject.getString("unionid");
        }
    }

    public void uploadToken(Context context, String str, String str2) {
        if (str2 == null) {
            fillUser(str);
            this.LastAuthTime = System.currentTimeMillis();
            this.IsAuth = true;
            o0.b(context, "WXRefreshToken", this.RefreshToken, "wx_token");
            o0.b(context, "WXLoginTime", Long.valueOf(this.LastAuthTime), "wx_token");
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("oauthId", (Object) this.UnionId);
            jSONObject.put("oauthNickName", (Object) this.NickName);
            jSONObject.put("photoUrl", (Object) this.HeadImgUrl);
            jSONObject.put("oauthToken", (Object) this.AccessToken);
            jSONObject.put("source", "wechat");
            JSONObject jSONObject2 = new JSONObject();
            jSONObject2.put("Userid", (Object) this.UnionId);
            jSONObject2.put("Token", (Object) this.RefreshToken);
            AppIdentifyEntity a2 = c.k().a();
            jSONObject2.put("Appid", (Object) a2.getAppId());
            jSONObject2.put("Appkey", (Object) a2.getAppKey());
            jSONObject2.put("Lang", (Object) context.getResources().getConfiguration().locale.getLanguage());
            jSONObject2.put("Area", (Object) d.b(context));
            oAuthLogin(context, jSONObject, jSONObject2);
            return;
        }
        this.mListener.a(2, str2);
    }
}