Skip to content

Commit

Permalink
👷🏻update android on token handle
Browse files Browse the repository at this point in the history
  • Loading branch information
Kangkang committed Feb 2, 2023
1 parent b3282b0 commit 1858586
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@


import android.text.TextUtils;
import android.util.Log;

import androidx.annotation.Nullable;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.mobile.auth.gatewayauth.ResultCode;
import com.mobile.auth.gatewayauth.model.TokenRet;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -68,7 +72,7 @@ public static AuthResponseModel tokenDecodeFailed() {
return authResponseModel;
}

public static AuthResponseModel onCustomViewBlocTap(Integer viewId){
public static AuthResponseModel onCustomViewBlocTap(Integer viewId) {
String now = Long.toString(System.currentTimeMillis());
AuthResponseModel authResponseModel = new AuthResponseModel();
authResponseModel.setResultCode("700010");
Expand All @@ -94,8 +98,15 @@ public static AuthResponseModel fromTokenRect(TokenRet tokenRet) throws JSONExce
if (Objects.nonNull(token) && !TextUtils.isEmpty(token) && !String.valueOf(token).equals("null")) {
authResponseModel.setToken(token);
}
JSONObject carrierFailedResultData = new JSONObject(tokenRet.getCarrierFailedResultData());
Map<String, Object> carrierFailedResultData = null;
if(Objects.nonNull(tokenRet.getCarrierFailedResultData()) && !TextUtils.isEmpty(tokenRet.getCarrierFailedResultData()) && !String.valueOf(tokenRet.getCarrierFailedResultData()).equals("null") ){
Gson gson = new Gson();
String failedJsonString = gson.toJson(tokenRet.getCarrierFailedResultData());
carrierFailedResultData = gson.fromJson(failedJsonString, new TypeToken<Map<String, Object>>() { }.getType()); //反序列化
Log.d(AuthResponseModel.class.getSimpleName(), "获取Token失败,此为运营商消息,carrierFailedResultData: " + carrierFailedResultData);
}
if (Objects.nonNull(carrierFailedResultData)) {
assert carrierFailedResultData != null;
if (Objects.nonNull(carrierFailedResultData.get("innerCode"))) {
authResponseModel.setInnerCode((String) carrierFailedResultData.get("innerCode"));
}
Expand Down

0 comments on commit 1858586

Please sign in to comment.