Aqara Home v2.4.1版本的 MD5 值为:529779ac2bc0131db52a1fc3098d2b35
以下内容为反编译后的 b.java 源代码,内容仅作参考
package k.g0.a.a.a.d;
import android.content.Context;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import com.umeng.socialize.handler.UMTencentSSOHandler;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.util.concurrent.TimeUnit;
import okhttp3.Cache;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Dispatcher;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONObject;
public class b {
public static int a = 0;
public static int b = 3000;
public static int c = 1500;
public static Context f16681f = null;
public static final String f16682g = "网络请求失败";
public static OkHttpClient d = new OkHttpClient();
public static int f16680e = 603;
public static char f16683h = 0;
public static Class f16684i = null;
public static class a implements Callback {
public final i a;
public a(i iVar) {
this.a = iVar;
}
@Override
public void onFailure(Call call, IOException iOException) {
if (this.a == null) {
return;
}
String message = iOException.getMessage();
if (TextUtils.isEmpty(message)) {
message = b.f16682g;
}
this.a.a(604, message);
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (this.a == null) {
response.body().close();
return;
}
if (b.c()) {
if (response.code() >= 400) {
String c = new c(response).c();
if (!TextUtils.isEmpty(c) && c.contains(UMTencentSSOHandler.RET)) {
this.a.a(response.code(), c);
} else {
i iVar = this.a;
int code = response.code();
iVar.a(code, "网络请求失败(" + response.code() + ")");
}
} else {
this.a.a(response);
}
} else {
this.a.a(response);
}
response.body().close();
}
}
public static class C0325b implements Callback {
public final i a;
public C0325b(i iVar) {
this.a = iVar;
}
@Override
public void onFailure(Call call, IOException iOException) {
if (this.a == null) {
return;
}
String message = iOException.getMessage();
if (TextUtils.isEmpty(message)) {
message = b.f16682g;
}
boolean z2 = true;
if (call != null && call.request() != null && call.request().url() != null && !TextUtils.isEmpty(call.request().url().toString()) && (call.request().url().toString().contains("http://xdcs-collector.ximalaya.com/") || call.request().url().toString().contains("http://xdcs-collector.test.ximalaya.com/"))) {
z2 = false;
}
if (b.c() && z2) {
StringBuffer stringBuffer = new StringBuffer();
if (call != null && call.request() != null && call.request().headers() != null) {
stringBuffer.append(iOException.getMessage());
stringBuffer.append(" ");
stringBuffer.append(call.request().headers().toString());
if (call.request().url() != null && !TextUtils.isEmpty(call.request().url().toString())) {
stringBuffer.append(call.request().url().toString());
}
}
k.g0.a.a.a.g.b.a("BaseCall", stringBuffer.toString());
}
this.a.a(604, message);
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (this.a == null) {
response.body().close();
return;
}
if (b.c()) {
if (response.code() >= 400) {
String c = new c(response).c();
if (!TextUtils.isEmpty(c) && c.contains(UMTencentSSOHandler.RET)) {
this.a.a(response.code(), c);
} else {
i iVar = this.a;
int code = response.code();
iVar.a(code, "网络请求失败(" + response.code() + ")");
}
} else {
this.a.a(response);
}
} else {
this.a.a(response);
}
response.body().close();
}
}
public static synchronized void a(OkHttpClient okHttpClient) {
synchronized (b.class) {
d = okHttpClient;
}
}
public static synchronized OkHttpClient b() {
OkHttpClient okHttpClient;
synchronized (b.class) {
okHttpClient = d;
}
return okHttpClient;
}
public static synchronized void c(Interceptor interceptor) {
synchronized (b.class) {
OkHttpClient.Builder newBuilder = b().newBuilder();
newBuilder.interceptors().remove(interceptor);
a(newBuilder.build());
}
}
public static synchronized void b(Interceptor interceptor) {
synchronized (b.class) {
OkHttpClient.Builder newBuilder = b().newBuilder();
newBuilder.addNetworkInterceptor(interceptor);
a(newBuilder.build());
}
}
public static void a(Context context) {
f16681f = context;
}
public static void a(d dVar) {
k.g0.a.a.a.d.a.a(dVar);
OkHttpClient.Builder newBuilder = d.newBuilder();
newBuilder.connectTimeout(dVar.f16688f, TimeUnit.MILLISECONDS);
newBuilder.readTimeout(dVar.f16688f, TimeUnit.MILLISECONDS);
if (dVar.a) {
if (!TextUtils.isEmpty(dVar.c) && dVar.d > 0) {
newBuilder.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(dVar.c, dVar.d)));
}
} else {
newBuilder.proxy(null);
}
if (f16681f != null) {
newBuilder.cache(new Cache(new File(f16681f.getCacheDir(), "request_cache"), 52428800L));
}
d = newBuilder.build();
}
public static boolean c() {
if (f16683h == 0) {
try {
Class.forName("com.ximalaya.ting.android.host.manager.request.CommonRequestM");
f16683h = (char) 1;
} catch (ClassNotFoundException unused) {
f16683h = (char) 2;
} catch (Exception unused2) {
f16683h = (char) 2;
}
}
char c2 = f16683h;
return c2 == 1 || c2 != 2;
}
public static synchronized void a(Proxy proxy) {
synchronized (b.class) {
OkHttpClient.Builder newBuilder = b().newBuilder();
newBuilder.proxy(proxy);
a(newBuilder.build());
}
}
public static synchronized void a(Interceptor interceptor) {
synchronized (b.class) {
OkHttpClient.Builder newBuilder = b().newBuilder();
newBuilder.addInterceptor(interceptor);
a(newBuilder.build());
}
}
public static Response a(OkHttpClient okHttpClient, Request request) throws Exception {
return okHttpClient.newCall(request).execute();
}
public static Response a(Request request) throws Exception {
return b().newCall(request).execute();
}
public static void a(Request request, i iVar, int i2) {
OkHttpClient okHttpClient;
if (i2 != a) {
OkHttpClient.Builder newBuilder = b().newBuilder();
long j2 = i2;
newBuilder.connectTimeout(j2, TimeUnit.MILLISECONDS);
newBuilder.readTimeout(j2, TimeUnit.MILLISECONDS);
newBuilder.writeTimeout(j2, TimeUnit.MILLISECONDS);
d i3 = k.g0.a.a.a.c.c.u().i();
if (i3 != null && i3.a && !TextUtils.isEmpty(i3.c) && i3.d > 0) {
newBuilder.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(i3.c, i3.d)));
}
okHttpClient = newBuilder.build();
k.g0.a.a.a.d.a.a(i3);
} else {
okHttpClient = null;
}
a(okHttpClient, request, iVar);
}
public static void a(OkHttpClient okHttpClient, Request request, i iVar) {
if (okHttpClient == null) {
a(request, iVar);
return;
}
try {
okHttpClient.newCall(request).enqueue(new a(iVar));
} catch (Exception unused) {
if (iVar != null) {
iVar.a(604, f16682g);
}
}
}
public static void a(Request request, i iVar) {
try {
b().newCall(request).enqueue(new C0325b(iVar));
} catch (Exception unused) {
if (iVar != null) {
iVar.a(604, f16682g);
}
}
}
public static String a(Response response, String str) {
try {
JSONObject jSONObject = new JSONObject(response.body().toString());
return jSONObject.has("msg") ? jSONObject.getString("msg") : str;
} catch (Exception e2) {
e2.printStackTrace();
return str;
}
}
@Nullable
public static Class a() {
Class cls = f16684i;
if (cls != null) {
return cls;
}
try {
Class<?> cls2 = Class.forName("com.ximalaya.ting.android.host.manager.request.CommonRequestM");
f16684i = cls2;
return cls2;
} catch (ClassNotFoundException e2) {
e2.printStackTrace();
return null;
} catch (Exception e3) {
e3.printStackTrace();
return null;
}
}
public static synchronized void a(String str) {
Dispatcher dispatcher;
synchronized (b.class) {
if (TextUtils.isEmpty(str)) {
return;
}
OkHttpClient b2 = b();
if (b2 != null && (dispatcher = b2.dispatcher()) != null) {
for (Call call : dispatcher.runningCalls()) {
Request request = call.request();
if (request != null && str.equals(request.tag())) {
call.cancel();
return;
}
}
for (Call call2 : dispatcher.queuedCalls()) {
Request request2 = call2.request();
if (request2 != null && str.equals(request2.tag())) {
call2.cancel();
return;
}
}
}
}
}
}