Initial commit
This commit is contained in:
212
sources/com/tencent/mm/opensdk/diffdev/a/d.java
Normal file
212
sources/com/tencent/mm/opensdk/diffdev/a/d.java
Normal file
@@ -0,0 +1,212 @@
|
||||
package com.tencent.mm.opensdk.diffdev.a;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.util.Base64;
|
||||
import com.tencent.mm.opensdk.diffdev.OAuthErrCode;
|
||||
import com.tencent.mm.opensdk.diffdev.OAuthListener;
|
||||
import com.tencent.mm.opensdk.utils.Log;
|
||||
import com.ubt.jimu.diy.view.fragment.BuildStepFragment;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class d extends AsyncTask<Void, Void, a> {
|
||||
private static final boolean ad;
|
||||
private static final String ae;
|
||||
private static String af;
|
||||
private String ag;
|
||||
private String ah;
|
||||
private OAuthListener ai;
|
||||
private f aj;
|
||||
private String appId;
|
||||
private String scope;
|
||||
private String signature;
|
||||
|
||||
static class a {
|
||||
public OAuthErrCode ak;
|
||||
public String al;
|
||||
public String am;
|
||||
public String an;
|
||||
public int ao;
|
||||
public String ap;
|
||||
public byte[] aq;
|
||||
|
||||
private a() {
|
||||
}
|
||||
|
||||
private static boolean a(String str, byte[] bArr) {
|
||||
FileOutputStream fileOutputStream = null;
|
||||
try {
|
||||
try {
|
||||
FileOutputStream fileOutputStream2 = new FileOutputStream(str);
|
||||
try {
|
||||
fileOutputStream2.write(bArr);
|
||||
fileOutputStream2.flush();
|
||||
try {
|
||||
fileOutputStream2.close();
|
||||
} catch (IOException e) {
|
||||
Log.e("MicroMsg.SDK.GetQRCodeResult", "fout.close() exception:" + e.getMessage());
|
||||
}
|
||||
Log.d("MicroMsg.SDK.GetQRCodeResult", "writeToFile ok!");
|
||||
return true;
|
||||
} catch (Exception e2) {
|
||||
e = e2;
|
||||
fileOutputStream = fileOutputStream2;
|
||||
Log.w("MicroMsg.SDK.GetQRCodeResult", "write to file error, exception:" + e.getMessage());
|
||||
if (fileOutputStream == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
fileOutputStream.close();
|
||||
return false;
|
||||
} catch (IOException e3) {
|
||||
Log.e("MicroMsg.SDK.GetQRCodeResult", "fout.close() exception:" + e3.getMessage());
|
||||
return false;
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
fileOutputStream = fileOutputStream2;
|
||||
if (fileOutputStream != null) {
|
||||
try {
|
||||
fileOutputStream.close();
|
||||
} catch (IOException e4) {
|
||||
Log.e("MicroMsg.SDK.GetQRCodeResult", "fout.close() exception:" + e4.getMessage());
|
||||
}
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
} catch (Exception e5) {
|
||||
e = e5;
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
}
|
||||
}
|
||||
|
||||
public static a c(byte[] bArr) {
|
||||
OAuthErrCode oAuthErrCode;
|
||||
String format;
|
||||
a aVar = new a();
|
||||
if (bArr == null || bArr.length == 0) {
|
||||
Log.e("MicroMsg.SDK.GetQRCodeResult", "parse fail, buf is null");
|
||||
oAuthErrCode = OAuthErrCode.WechatAuth_Err_NetworkErr;
|
||||
} else {
|
||||
try {
|
||||
try {
|
||||
JSONObject jSONObject = new JSONObject(new String(bArr, "utf-8"));
|
||||
int i = jSONObject.getInt("errcode");
|
||||
if (i != 0) {
|
||||
Log.e("MicroMsg.SDK.GetQRCodeResult", String.format("resp errcode = %d", Integer.valueOf(i)));
|
||||
aVar.ak = OAuthErrCode.WechatAuth_Err_NormalErr;
|
||||
aVar.ao = i;
|
||||
aVar.ap = jSONObject.optString("errmsg");
|
||||
return aVar;
|
||||
}
|
||||
String string = jSONObject.getJSONObject("qrcode").getString("qrcodebase64");
|
||||
if (string != null && string.length() != 0) {
|
||||
byte[] decode = Base64.decode(string, 0);
|
||||
if (decode != null && decode.length != 0) {
|
||||
if (!d.ad) {
|
||||
aVar.ak = OAuthErrCode.WechatAuth_Err_OK;
|
||||
aVar.aq = decode;
|
||||
aVar.al = jSONObject.getString(BuildStepFragment.UUID);
|
||||
aVar.am = jSONObject.getString("appname");
|
||||
Log.d("MicroMsg.SDK.GetQRCodeResult", String.format("parse succ, save in memory, uuid = %s, appname = %s, imgBufLength = %d", aVar.al, aVar.am, Integer.valueOf(aVar.aq.length)));
|
||||
return aVar;
|
||||
}
|
||||
File file = new File(d.ae);
|
||||
file.mkdirs();
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
if (!a(d.ae, decode)) {
|
||||
Log.e("MicroMsg.SDK.GetQRCodeResult", String.format("writeToFile fail, qrcodeBuf length = %d", Integer.valueOf(decode.length)));
|
||||
aVar.ak = OAuthErrCode.WechatAuth_Err_NormalErr;
|
||||
return aVar;
|
||||
}
|
||||
aVar.ak = OAuthErrCode.WechatAuth_Err_OK;
|
||||
aVar.an = d.ae;
|
||||
aVar.al = jSONObject.getString(BuildStepFragment.UUID);
|
||||
aVar.am = jSONObject.getString("appname");
|
||||
Log.d("MicroMsg.SDK.GetQRCodeResult", String.format("parse succ, save in external storage, uuid = %s, appname = %s, imgPath = %s", aVar.al, aVar.am, aVar.an));
|
||||
return aVar;
|
||||
}
|
||||
Log.e("MicroMsg.SDK.GetQRCodeResult", "parse fail, qrcodeBuf is null");
|
||||
aVar.ak = OAuthErrCode.WechatAuth_Err_JsonDecodeErr;
|
||||
return aVar;
|
||||
}
|
||||
Log.e("MicroMsg.SDK.GetQRCodeResult", "parse fail, qrcodeBase64 is null");
|
||||
aVar.ak = OAuthErrCode.WechatAuth_Err_JsonDecodeErr;
|
||||
return aVar;
|
||||
} catch (Exception e) {
|
||||
format = String.format("parse json fail, ex = %s", e.getMessage());
|
||||
Log.e("MicroMsg.SDK.GetQRCodeResult", 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;
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
ad = Environment.getExternalStorageState().equals("mounted") && new File(Environment.getExternalStorageDirectory().getAbsolutePath()).canWrite();
|
||||
ae = Environment.getExternalStorageDirectory().getAbsolutePath() + "/tencent/MicroMsg/oauth_qrcode.png";
|
||||
af = null;
|
||||
af = "http://open.weixin.qq.com/connect/sdk/qrconnect?appid=%s&noncestr=%s×tamp=%s&scope=%s&signature=%s";
|
||||
}
|
||||
|
||||
public d(String str, String str2, String str3, String str4, String str5, OAuthListener oAuthListener) {
|
||||
this.appId = str;
|
||||
this.scope = str2;
|
||||
this.ag = str3;
|
||||
this.ah = str4;
|
||||
this.signature = str5;
|
||||
this.ai = oAuthListener;
|
||||
}
|
||||
|
||||
@Override // android.os.AsyncTask
|
||||
protected final /* synthetic */ a doInBackground(Void[] voidArr) {
|
||||
Log.i("MicroMsg.SDK.GetQRCodeTask", "external storage available = " + ad);
|
||||
String format = String.format(af, this.appId, this.ag, this.ah, this.scope, this.signature);
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
byte[] b = e.b(format, -1);
|
||||
Log.d("MicroMsg.SDK.GetQRCodeTask", String.format("doInBackground, url = %s, time consumed = %d(ms)", format, Long.valueOf(System.currentTimeMillis() - currentTimeMillis)));
|
||||
return a.c(b);
|
||||
}
|
||||
|
||||
@Override // android.os.AsyncTask
|
||||
protected final /* synthetic */ void onPostExecute(a aVar) {
|
||||
a aVar2 = aVar;
|
||||
OAuthErrCode oAuthErrCode = aVar2.ak;
|
||||
if (oAuthErrCode != OAuthErrCode.WechatAuth_Err_OK) {
|
||||
Log.e("MicroMsg.SDK.GetQRCodeTask", String.format("onPostExecute, get qrcode fail, OAuthErrCode = %s", oAuthErrCode));
|
||||
this.ai.onAuthFinish(aVar2.ak, null);
|
||||
return;
|
||||
}
|
||||
Log.d("MicroMsg.SDK.GetQRCodeTask", "onPostExecute, get qrcode success");
|
||||
this.ai.onAuthGotQrcode(aVar2.an, aVar2.aq);
|
||||
this.aj = new f(aVar2.al, this.ai);
|
||||
f fVar = this.aj;
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
fVar.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
|
||||
} else {
|
||||
fVar.execute(new Void[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean q() {
|
||||
Log.i("MicroMsg.SDK.GetQRCodeTask", "cancelTask");
|
||||
f fVar = this.aj;
|
||||
return fVar == null ? cancel(true) : fVar.cancel(true);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user