From 5196d4f9263f02c7d61d6138deb666e2aeaffd39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E5=AE=8F=E5=AE=87?= Date: Wed, 20 Jan 2021 19:53:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4passport=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cloud/passport/MoGoAiCloudClient.java | 83 +++++++++++-------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/foudations/mogo-passport/src/main/java/com/mogo/cloud/passport/MoGoAiCloudClient.java b/foudations/mogo-passport/src/main/java/com/mogo/cloud/passport/MoGoAiCloudClient.java index cfa493e..07f2f5e 100644 --- a/foudations/mogo-passport/src/main/java/com/mogo/cloud/passport/MoGoAiCloudClient.java +++ b/foudations/mogo-passport/src/main/java/com/mogo/cloud/passport/MoGoAiCloudClient.java @@ -7,7 +7,6 @@ import androidx.annotation.Keep; import com.mogo.cloud.httpdns.MogoHttpDnsClient; import com.mogo.cloud.httpdns.MogoHttpDnsConfig; -import com.mogo.cloud.httpdns.bean.HttpDnsSimpleLocation; import com.zhidao.tcloginsdk.LoginManager; import com.zhidao.tcloginsdk.model.ThirdLoginParam; import com.zhidao.tcloginsdk.model.TokenData; @@ -68,45 +67,57 @@ public class MoGoAiCloudClient { if (mAiCloudClientConfig != null) { ThirdLoginParam thirdLoginParam = ThirdLoginParam.of( mAiCloudClientConfig.getThirdPartyDeviceId(), - mAiCloudClientConfig.getThirdPartyAppKey(), - mAiCloudClientConfig.getThirdPartySignSecret() + mAiCloudClientConfig.getThirdPartyAppKey() ); + LoginCallback loginCallback = new LoginCallback() { + @Override + public void onSuccess(TokenData.TokenResult result) { + Log.i(TAG, "═════════════════════════════════════"); + Log.i(TAG, "║ MoGo鉴权成功 "); + Log.i(TAG, "║ SN:" + result.sn); + Log.i(TAG, "║ Token:" + result.token); + Log.i(TAG, "═════════════════════════════════════"); + if (tokenCallback != null) { + tokenCallback.onTokenGot(result.token, result.sn); + } + + // 变量赋值 + if (mAiCloudClientConfig != null) { + mAiCloudClientConfig.sn = result.sn; + mAiCloudClientConfig.token = result.token; + } + + // 初始化HttpDNS + mHttpDnsConfig = + new MogoHttpDnsConfig() + .setContext(mContext) + .setSn(mAiCloudClientConfig.sn) + .setEnv(mAiCloudClientConfig.getNetMode()) + .setShowDebugLog(mAiCloudClientConfig.isShowDebugLog()) + .setCurrentLocation(mAiCloudClientConfig.getIHttpDnsCurrentLocation()) + .setLoopCheckDelay(mAiCloudClientConfig.getLoopCheckDelay()); + MogoHttpDnsClient.INSTANCE.init(mHttpDnsConfig); + } + + @Override + public void onFailure(int code, String msg) { + Log.e(TAG, "═════════════════════════════════════"); + Log.e(TAG, "║ MoGo鉴权失败 "); + Log.e(TAG, "║ ErrorCode:" + code); + Log.e(TAG, "║ ErrorMessage:" + msg); + Log.e(TAG, "═════════════════════════════════════"); + if (tokenCallback != null) { + tokenCallback.onError(code, msg); + } + } + }; + + Log.w(TAG, "loginCallback:" + loginCallback); + LoginManager.getInstance(mContext).login( mAiCloudClientConfig.isThirdLogin(), - thirdLoginParam, - new LoginCallback() { - @Override - public void onSuccess(TokenData.TokenResult result) { - if (tokenCallback != null) { - tokenCallback.onTokenGot(result.token, result.sn); - } - - // 变量赋值 - if (mAiCloudClientConfig != null) { - mAiCloudClientConfig.sn = result.sn; - mAiCloudClientConfig.token = result.token; - } - - // 初始化HttpDNS - mHttpDnsConfig = - new MogoHttpDnsConfig() - .setContext(mContext) - .setSn(mAiCloudClientConfig.sn) - .setEnv(mAiCloudClientConfig.getNetMode()) - .setShowDebugLog(mAiCloudClientConfig.isShowDebugLog()) - .setCurrentLocation(mAiCloudClientConfig.getIHttpDnsCurrentLocation()) - .setLoopCheckDelay(mAiCloudClientConfig.getLoopCheckDelay()); - MogoHttpDnsClient.INSTANCE.init(mHttpDnsConfig); - } - - @Override - public void onFailure(int code, String msg) { - if (tokenCallback != null) { - tokenCallback.onError(code, msg); - } - } - }); + thirdLoginParam, loginCallback); } else { Log.e(TAG, "SDK MoGoAiCloudClientConfig 为 null,请检查!"); }