调研通 v3.0.3版本的 MD5 值为:fe075d21227d488bdb9f6aa09d3b3f35
以下内容为反编译后的 a.java 源代码,内容仅作参考
package com.yyt.common.plugin.baiduSpeech;
import android.content.Context;
import android.os.Handler;
import androidx.core.content.ContextCompat;
import com.baidu.tts.client.SpeechSynthesizer;
import com.baidu.tts.client.TtsMode;
import com.xiaomi.mipush.sdk.Constants;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.TreeSet;
import org.json.JSONObject;
public class a {
private static a f11354d;
private static Context f11355e;
private LinkedHashMap<String, d> f11356a;
private boolean f11357b = false;
volatile boolean f11358c = false;
class RunnableC0205a implements Runnable {
final com.yyt.common.plugin.baiduSpeech.b f11359a;
final Handler f11360b;
RunnableC0205a(com.yyt.common.plugin.baiduSpeech.b bVar, Handler handler) {
this.f11359a = bVar;
this.f11360b = handler;
}
@Override
public void run() {
a f2 = a.this.f(this.f11359a);
a.this.f11358c = true;
synchronized (f2) {
this.f11360b.sendMessage(this.f11360b.obtainMessage(100, f2));
}
}
}
public static class b extends d {
private String f11362e;
private String f11363f;
private String g;
public b(String str, String str2, String str3) {
this.f11362e = str;
this.f11363f = str2;
this.g = str3;
}
@Override
public void b() {
a("try to check appId " + this.f11362e + " ,appKey=" + this.f11363f + " ,secretKey" + this.g);
String str = this.f11362e;
if (str != null && !str.isEmpty()) {
String str2 = this.f11363f;
if (str2 != null && !str2.isEmpty()) {
String str3 = this.g;
if (str3 == null || str3.isEmpty()) {
this.f11366a = "secretKey 为空";
this.f11367b = "secretKey";
}
} else {
this.f11366a = "appKey 为空";
this.f11367b = "填写appID";
}
} else {
this.f11366a = "appId 为空";
this.f11367b = "填写appID";
}
try {
k();
} catch (UnknownHostException e2) {
this.f11368c = "无网络或者网络不连通,忽略检测 : " + e2.getMessage();
} catch (Exception e3) {
this.f11366a = e3.getClass().getCanonicalName() + Constants.COLON_SEPARATOR + e3.getMessage();
this.f11367b = " 重新检测appId, appKey, appSecret是否正确";
}
}
public void k() throws Exception {
String readLine;
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL("http://openapi.baidu.com/oauth/2.0/token?grant_type=client_credentials&client_id=" + this.f11363f + "&client_secret=" + this.g).openConnection();
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setConnectTimeout(1000);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream()));
StringBuilder sb = new StringBuilder();
do {
readLine = bufferedReader.readLine();
if (readLine != null) {
sb.append(readLine);
}
} while (readLine != null);
String sb2 = sb.toString();
a("openapi return " + sb2);
JSONObject jSONObject = new JSONObject(sb2);
String optString = jSONObject.optString(com.google.android.gcm.a.i);
if (optString != null && !optString.isEmpty()) {
throw new Exception("appkey secretKey 错误, error:" + optString + ", json is" + ((Object) sb));
}
String string = jSONObject.getString(com.tencent.connect.common.Constants.PARAM_ACCESS_TOKEN);
if (string != null) {
if (string.endsWith(Constants.ACCEPT_TIME_SEPARATOR_SERVER + this.f11362e)) {
return;
}
}
throw new Exception("appId 与 appkey及 appSecret 不一致。appId = " + this.f11362e + " ,token = " + string);
}
}
public static class c extends d {
private String f11364e;
private Context f11365f;
public c(Context context, String str) {
this.f11364e = str;
this.f11365f = context;
}
private String k() {
return this.f11365f.getPackageName();
}
@Override
public void b() {
this.f11368c = "如果您集成过程中遇见离线合成初始化问题,请检查网页上appId:" + this.f11364e + " 应用是否开通了合成服务,并且网页上的应用填写了Android包名:" + k();
}
}
public static abstract class d {
protected String f11366a = null;
protected String f11367b = null;
protected String f11368c = null;
protected StringBuilder f11369d = new StringBuilder();
public void a(String str) {
this.f11369d.append(str + "\n");
}
public abstract void b();
public String c() {
return this.f11366a;
}
public String d() {
return this.f11367b;
}
public String e() {
return this.f11368c;
}
public String f() {
return this.f11369d.toString();
}
public boolean g() {
return this.f11366a != null;
}
public boolean h() {
return this.f11367b != null;
}
public boolean i() {
return this.f11368c != null;
}
public boolean j() {
return !this.f11369d.toString().isEmpty();
}
}
public static class e extends d {
private Context f11370e;
private String[] f11371f = {"libbd_etts.so", "libBDSpeechDecoder_V1.so", "libbdtts.so", "libgnustl_shared.so"};
public e(Context context) {
this.f11370e = context;
}
@Override
public void b() {
String str = this.f11370e.getApplicationInfo().nativeLibraryDir;
a("Jni so文件目录 " + str);
File[] listFiles = new File(str).listFiles();
TreeSet treeSet = new TreeSet();
if (listFiles != null) {
for (File file : listFiles) {
if (file.canRead()) {
treeSet.add(file.getName());
}
}
}
a("Jni目录内文件: " + treeSet.toString());
for (String str2 : this.f11371f) {
if (!treeSet.contains(str2)) {
this.f11366a = "Jni目录" + str + " 缺少可读的so文件:" + str2 + ", 该目录文件列表: " + treeSet.toString();
this.f11367b = "如果您的app内没有其它so文件,请复制demo里的src/main/jniLibs至同名目录。 如果app内有so文件,请合并目录放一起(注意目录取交集,多余的目录删除)。";
return;
}
}
}
}
public static class f extends d {
private String f11372e;
private String f11373f = this.f11373f;
private String f11373f = this.f11373f;
public f(String str) {
this.f11372e = str;
}
@Override
public void b() {
File file = new File(this.f11372e);
boolean z = false;
if (!file.exists()) {
this.f11366a = "资源文件不存在:" + this.f11372e;
} else if (file.canRead()) {
z = true;
} else {
this.f11366a = "资源文件不可读:" + this.f11372e;
}
if (z) {
return;
}
this.f11367b = "请将demo中src/main/assets目录下同名文件复制到 " + this.f11372e;
}
}
public static class g extends d {
private Map<String, String> f11374e;
private String f11375f;
private String g;
public g(Map<String, String> map, String str, String str2) {
this.f11374e = map;
this.f11375f = str;
this.g = str2;
}
@Override
public void b() {
Map<String, String> map = this.f11374e;
if (map == null || !map.containsKey(this.f11375f)) {
this.f11366a = this.g + " 参数中没有设置:" + this.f11375f;
this.f11367b = "请参照demo在设置 " + this.f11375f + "参数";
}
}
}
public static class h extends d {
private Context f11376e;
public h(Context context) {
this.f11376e = context;
}
@Override
public void b() {
String[] strArr = {"android.permission.INTERNET", "android.permission.ACCESS_NETWORK_STATE", "android.permission.MODIFY_AUDIO_SETTINGS", "android.permission.READ_PHONE_STATE", "android.permission.ACCESS_WIFI_STATE"};
ArrayList arrayList = new ArrayList();
for (int i = 0; i < 5; i++) {
String str = strArr[i];
if (ContextCompat.checkSelfPermission(this.f11376e, str) != 0) {
arrayList.add(str);
}
}
if (arrayList.isEmpty()) {
return;
}
this.f11366a = "缺少权限:" + arrayList;
this.f11367b = "请从AndroidManifest.xml复制相关权限";
}
}
private a(Context context) {
f11355e = context;
this.f11356a = new LinkedHashMap<>();
}
public static a e(Context context) {
if (f11354d == null || f11355e != context) {
f11354d = new a(context);
}
return f11354d;
}
public a f(com.yyt.common.plugin.baiduSpeech.b bVar) {
this.f11356a.put("检查申请的Android权限", new h(f11355e));
this.f11356a.put("检查4个so文件是否存在", new e(f11355e));
this.f11356a.put("检查AppId AppKey SecretKey", new b(bVar.a(), bVar.b(), bVar.e()));
this.f11356a.put("检查包名", new c(f11355e, bVar.a()));
if (TtsMode.MIX.equals(bVar.f())) {
Map<String, String> d2 = bVar.d();
String str = SpeechSynthesizer.PARAM_TTS_TEXT_MODEL_FILE;
this.f11356a.put("检查离线资TEXT文件参数", new g(d2, str, "SpeechSynthesizer.PARAM_TTS_TEXT_MODEL_FILE未设置 ,"));
this.f11356a.put("检查离线资源TEXT文件", new f(d2.get(str)));
String str2 = SpeechSynthesizer.PARAM_TTS_SPEECH_MODEL_FILE;
this.f11356a.put("检查离线资Speech文件参数", new g(d2, str2, "SpeechSynthesizer.PARAM_TTS_SPEECH_MODEL_FILE未设置 ,"));
this.f11356a.put("检查离线资源Speech文件", new f(d2.get(str2)));
}
Iterator<Map.Entry<String, d>> it = this.f11356a.entrySet().iterator();
while (it.hasNext()) {
d value = it.next().getValue();
value.b();
if (value.g()) {
break;
}
}
return this;
}
public void b(com.yyt.common.plugin.baiduSpeech.b bVar, Handler handler) {
new Thread(new RunnableC0205a(bVar, handler)).start();
}
public void c() {
this.f11356a.clear();
this.f11357b = false;
}
public String d(i iVar) {
StringBuilder sb = new StringBuilder();
this.f11357b = false;
for (Map.Entry<String, d> entry : this.f11356a.entrySet()) {
d value = entry.getValue();
String key = entry.getKey();
if (value.g()) {
if (!this.f11357b) {
this.f11357b = true;
}
sb.append("【错误】【");
sb.append(key);
sb.append(" 】 ");
sb.append(value.c());
sb.append("\n");
if (value.h()) {
sb.append("【修复方法】【");
sb.append(key);
sb.append(" 】 ");
sb.append(value.d());
sb.append("\n");
}
}
if (iVar.f11378b && value.i()) {
sb.append("【请手动检查】【");
sb.append(key);
sb.append("】 ");
sb.append(value.e());
sb.append("\n");
}
if (iVar.f11379c && (iVar.f11380d || this.f11357b)) {
if (value.j()) {
sb.append("【log】:" + value.f());
sb.append("\n");
}
}
}
if (!this.f11357b) {
sb.append("集成自动排查工具: 恭喜没有检测到任何问题\n");
}
return sb.toString();
}
public String g() {
i iVar = new i(null);
iVar.f11379c = true;
iVar.f11378b = true;
return d(iVar);
}
public String h() {
i iVar = new i(null);
iVar.f11378b = true;
return d(iVar);
}
public String i() {
return d(new i(null));
}
public static class i {
public boolean f11377a;
public boolean f11378b;
public boolean f11379c;
public boolean f11380d;
private i() {
this.f11377a = true;
this.f11378b = false;
this.f11379c = false;
this.f11380d = false;
}
i(RunnableC0205a runnableC0205a) {
this();
}
}
}