淘歌音乐 v2.0.49版本的 MD5 值为:49b2dab2d28afd9ea0c9c8648d644406
以下内容为反编译后的 AccessTokenTask.java 源代码,内容仅作参考
package com.uzmap.pkg.uzmodules.uzWx.tasks;
import android.os.AsyncTask;
import com.uzmap.pkg.uzcore.uzmodule.UZModuleContext;
import com.uzmap.pkg.uzkit.request.APICloudHttpClient;
import com.uzmap.pkg.uzkit.request.HttpGet;
import com.uzmap.pkg.uzkit.request.HttpResult;
import com.uzmap.pkg.uzkit.request.RequestCallback;
import com.uzmap.pkg.uzmodules.uzWx.tasks.AccessTokenResult;
import org.json.JSONException;
import org.json.JSONObject;
public class AccessTokenTask extends AsyncTask<Void, Void, Void> {
private static final String GET_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code";
private static final String REFRESH_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=%s&grant_type=refresh_token&refresh_token=%s";
private AccessTokenType mAccessTokenType;
private String mAppId;
private String mCode;
private UZModuleContext mModuleContext;
private String mRefreshToken;
private String mSecret;
public enum AccessTokenType {
GET_TOKEN,
REFRESH_TOKEN
}
public int parseErrCode(int i) {
switch (i) {
case -1:
case 40013:
return 1;
case 40029:
case 40030:
return 3;
case 40125:
case 41003:
return 2;
case 41008:
return 3;
case 42002:
return 4;
case 42003:
return 3;
default:
return -1;
}
}
public void initParams(UZModuleContext uZModuleContext, AccessTokenType accessTokenType, String str, String str2, String str3) {
this.mModuleContext = uZModuleContext;
this.mAccessTokenType = accessTokenType;
this.mAppId = str;
this.mSecret = str2;
this.mCode = str3;
}
public void initParams(UZModuleContext uZModuleContext, AccessTokenType accessTokenType, String str, String str2) {
this.mModuleContext = uZModuleContext;
this.mAccessTokenType = accessTokenType;
this.mAppId = str;
this.mRefreshToken = str2;
}
@Override
public Void doInBackground(Void... voidArr) {
final AccessTokenResult accessTokenResult = new AccessTokenResult();
HttpGet httpGet = new HttpGet(this.mAccessTokenType == AccessTokenType.GET_TOKEN ? String.format(GET_TOKEN_URL, this.mAppId, this.mSecret, this.mCode) : String.format(REFRESH_TOKEN_URL, this.mAppId, this.mRefreshToken));
httpGet.setCallback(new RequestCallback() {
@Override
public void onFinish(HttpResult httpResult) {
if (!httpResult.success()) {
AccessTokenTask.this.failCallBack(httpResult.statusCode);
return;
}
accessTokenResult.parseFrom(httpResult.data);
if (accessTokenResult.getLocalRetCode() == AccessTokenResult.LocalRetCode.ERR_OK) {
AccessTokenTask.this.successCallBack(accessTokenResult);
return;
}
int errCode = accessTokenResult.getErrCode();
System.out.println("getTokenErrcode:" + errCode);
AccessTokenTask accessTokenTask = AccessTokenTask.this;
accessTokenTask.failCallBack(accessTokenTask.parseErrCode(errCode));
}
});
APICloudHttpClient.createInstance(this.mModuleContext.getContext()).request(httpGet);
return null;
}
public void successCallBack(AccessTokenResult accessTokenResult) {
JSONObject jSONObject = new JSONObject();
JSONObject jSONObject2 = new JSONObject();
String accessToken = accessTokenResult.getAccessToken();
String refreshToken = accessTokenResult.getRefreshToken();
int expiresIn = accessTokenResult.getExpiresIn();
String openId = accessTokenResult.getOpenId();
try {
jSONObject.put("accessToken", accessToken);
jSONObject.put("dynamicToken", refreshToken);
jSONObject.put("openId", openId);
jSONObject.put("expires", expiresIn);
jSONObject.put("status", true);
jSONObject2.put("code", 0);
this.mModuleContext.error(jSONObject, jSONObject2, false);
} catch (JSONException e) {
e.printStackTrace();
}
}
public void failCallBack(int i) {
JSONObject jSONObject = new JSONObject();
JSONObject jSONObject2 = new JSONObject();
try {
jSONObject.put("status", false);
jSONObject2.put("code", i);
this.mModuleContext.error(jSONObject, jSONObject2, false);
} catch (JSONException e) {
e.printStackTrace();
}
}
}