jimu-decompiled/sources/com/tencent/mm/opensdk/diffdev/a/f.java
2025-05-13 19:24:51 +02:00

147 lines
6.2 KiB
Java

package com.tencent.mm.opensdk.diffdev.a;
import android.os.AsyncTask;
import com.tencent.mm.opensdk.diffdev.OAuthErrCode;
import com.tencent.mm.opensdk.diffdev.OAuthListener;
import com.tencent.mm.opensdk.utils.Log;
import org.json.JSONObject;
/* loaded from: classes.dex */
final class f extends AsyncTask<Void, Void, a> {
private OAuthListener ai;
private String al;
private int ar;
private String url;
static class a {
public OAuthErrCode ak;
public String as;
/* renamed from: at, reason: collision with root package name */
public int f2at;
a() {
}
public static a d(byte[] bArr) {
OAuthErrCode oAuthErrCode;
String format;
OAuthErrCode oAuthErrCode2;
a aVar = new a();
if (bArr == null || bArr.length == 0) {
Log.e("MicroMsg.SDK.NoopingResult", "parse fail, buf is null");
oAuthErrCode = OAuthErrCode.WechatAuth_Err_NetworkErr;
} else {
try {
try {
JSONObject jSONObject = new JSONObject(new String(bArr, "utf-8"));
aVar.f2at = jSONObject.getInt("wx_errcode");
Log.d("MicroMsg.SDK.NoopingResult", String.format("nooping uuidStatusCode = %d", Integer.valueOf(aVar.f2at)));
int i = aVar.f2at;
if (i == 408) {
oAuthErrCode2 = OAuthErrCode.WechatAuth_Err_OK;
} else if (i != 500) {
switch (i) {
case 402:
oAuthErrCode2 = OAuthErrCode.WechatAuth_Err_Timeout;
break;
case 403:
oAuthErrCode2 = OAuthErrCode.WechatAuth_Err_Cancel;
break;
case 404:
oAuthErrCode2 = OAuthErrCode.WechatAuth_Err_OK;
break;
case 405:
aVar.ak = OAuthErrCode.WechatAuth_Err_OK;
aVar.as = jSONObject.getString("wx_code");
return aVar;
default:
oAuthErrCode2 = OAuthErrCode.WechatAuth_Err_NormalErr;
break;
}
} else {
oAuthErrCode2 = OAuthErrCode.WechatAuth_Err_NormalErr;
}
aVar.ak = oAuthErrCode2;
return aVar;
} catch (Exception e) {
format = String.format("parse json fail, ex = %s", e.getMessage());
Log.e("MicroMsg.SDK.NoopingResult", format);
oAuthErrCode = OAuthErrCode.WechatAuth_Err_NormalErr;
aVar.ak = oAuthErrCode;
return aVar;
}
} catch (Exception e2) {
format = String.format("parse fail, build String fail, ex = %s", e2.getMessage());
}
}
aVar.ak = oAuthErrCode;
return aVar;
}
}
public f(String str, OAuthListener oAuthListener) {
this.al = str;
this.ai = oAuthListener;
this.url = String.format("https://long.open.weixin.qq.com/connect/l/qrconnect?f=json&uuid=%s", str);
}
@Override // android.os.AsyncTask
protected final /* synthetic */ a doInBackground(Void[] voidArr) {
a aVar;
OAuthErrCode oAuthErrCode;
String str;
String str2 = this.al;
if (str2 == null || str2.length() == 0) {
Log.e("MicroMsg.SDK.NoopingTask", "run fail, uuid is null");
aVar = new a();
oAuthErrCode = OAuthErrCode.WechatAuth_Err_NormalErr;
} else {
while (!isCancelled()) {
StringBuilder sb = new StringBuilder();
sb.append(this.url);
if (this.ar == 0) {
str = "";
} else {
str = "&last=" + this.ar;
}
sb.append(str);
String sb2 = sb.toString();
long currentTimeMillis = System.currentTimeMillis();
byte[] b = e.b(sb2, 60000);
long currentTimeMillis2 = System.currentTimeMillis();
a d = a.d(b);
Log.d("MicroMsg.SDK.NoopingTask", String.format("nooping, url = %s, errCode = %s, uuidStatusCode = %d, time consumed = %d(ms)", sb2, d.ak.toString(), Integer.valueOf(d.f2at), Long.valueOf(currentTimeMillis2 - currentTimeMillis)));
OAuthErrCode oAuthErrCode2 = d.ak;
if (oAuthErrCode2 != OAuthErrCode.WechatAuth_Err_OK) {
Log.e("MicroMsg.SDK.NoopingTask", String.format("nooping fail, errCode = %s, uuidStatusCode = %d", oAuthErrCode2.toString(), Integer.valueOf(d.f2at)));
return d;
}
int i = d.f2at;
this.ar = i;
if (i == g.UUID_SCANED.getCode()) {
this.ai.onQrcodeScanned();
} else if (d.f2at != g.UUID_KEEP_CONNECT.getCode() && d.f2at == g.UUID_CONFIRM.getCode()) {
String str3 = d.as;
if (str3 == null || str3.length() == 0) {
Log.e("MicroMsg.SDK.NoopingTask", "nooping fail, confirm with an empty code!!!");
d.ak = OAuthErrCode.WechatAuth_Err_NormalErr;
}
return d;
}
}
Log.i("MicroMsg.SDK.NoopingTask", "IDiffDevOAuth.stopAuth / detach invoked");
aVar = new a();
oAuthErrCode = OAuthErrCode.WechatAuth_Err_Auth_Stopped;
}
aVar.ak = oAuthErrCode;
return aVar;
}
@Override // android.os.AsyncTask
protected final /* synthetic */ void onPostExecute(a aVar) {
a aVar2 = aVar;
this.ai.onAuthFinish(aVar2.ak, aVar2.as);
}
}