PhotoRoom v4.8.2版本的 MD5 值为:c40a01bb3380c0f75c0cb6ac6760f295
以下内容为反编译后的 ShakeNetworkInterceptor.java 源代码,内容仅作参考
package com.shakebugs.shake.network;
import android.net.ConnectivityManager;
import android.net.NetworkCapabilities;
import androidx.annotation.Keep;
import com.shakebugs.shake.internal.a;
import com.shakebugs.shake.internal.domain.models.NetworkRequest;
import com.shakebugs.shake.internal.q2;
import com.shakebugs.shake.internal.s3;
import com.shakebugs.shake.internal.utils.d;
import com.shakebugs.shake.internal.utils.e;
import com.shakebugs.shake.internal.utils.m;
import com.shakebugs.shake.internal.utils.p;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;
import k.o0;
import m20.c;
import w10.b0;
import w10.c0;
import w10.d0;
import w10.u;
import w10.w;
import w10.x;
@Keep
public class ShakeNetworkInterceptor implements w {
private boolean bodyHasUnknownEncoding(u uVar) {
String c11 = uVar.c("Content-Encoding");
return (c11 == null || c11.equalsIgnoreCase("identity") || c11.equalsIgnoreCase("gzip")) ? false : true;
}
private NetworkRequest generateNetworkRequest(b0 b0Var, d0 d0Var, String str, long j11, String str2, String str3) {
String h11 = b0Var.h();
if (d0Var != null) {
str2 = String.valueOf(d0Var.h());
} else if ("".equals(str2)) {
str2 = "";
}
String vVar = b0Var.k().toString();
String stringifyRequestBody = stringifyRequestBody(b0Var);
Map<String, String> a11 = p.a(b0Var.f().t());
if (d0Var != null) {
str3 = stringifyResponseBody(d0Var);
} else if ("".equals(str3)) {
str3 = "";
}
Map<String, String> hashMap = new HashMap<>();
if (d0Var != null) {
hashMap = p.a(d0Var.o().t());
}
NetworkRequest networkRequest = new NetworkRequest();
networkRequest.setMethod(h11);
networkRequest.setStatusCode(str2);
networkRequest.setUrl(vVar);
networkRequest.setRequestBody(stringifyRequestBody);
networkRequest.setRequestHeaders(a11);
networkRequest.setResponseBody(str3);
networkRequest.setResponseHeaders(hashMap);
networkRequest.setTimestamp(str);
networkRequest.setDuration((float) (System.currentTimeMillis() - j11));
return networkRequest;
}
private void insertNetworkRequest(NetworkRequest networkRequest) {
s3 s11 = com.shakebugs.shake.internal.w.s();
if (s11 != null) {
s11.a(networkRequest, true);
}
}
private Boolean isConnectionOn() {
if (a.b() == null) {
return Boolean.FALSE;
}
ConnectivityManager connectivityManager = (ConnectivityManager) a.b().getSystemService("connectivity");
NetworkCapabilities networkCapabilities = connectivityManager.getNetworkCapabilities(connectivityManager.getActiveNetwork());
boolean z11 = false;
if (networkCapabilities != null && (networkCapabilities.hasTransport(1) || networkCapabilities.hasTransport(0))) {
z11 = true;
}
return Boolean.valueOf(z11);
}
private Boolean isInternetAvailable() {
try {
Socket socket = new Socket();
socket.connect(new InetSocketAddress("8.8.8.8", 53), 1500);
socket.close();
return Boolean.TRUE;
} catch (IOException unused) {
return Boolean.FALSE;
}
}
private boolean isShakeInitialized() {
q2 k11 = com.shakebugs.shake.internal.w.k();
if (k11 != null) {
return k11.m();
}
return false;
}
private String stringifyRequestBody(b0 b0Var) {
c0 a11 = b0Var.a();
Charset charset = StandardCharsets.UTF_8;
if (a11 != null) {
if (bodyHasUnknownEncoding(b0Var.f())) {
return "UNKNOWN ENCODING";
}
c cVar = new c();
try {
a11.writeTo(cVar);
} catch (Exception e11) {
m.a("Failed to write request body buffer", e11);
}
x contentType = a11.contentType();
if (contentType != null) {
charset = contentType.c(charset);
}
return (!d.a(cVar) || charset == null) ? "BINARY DATA" : cVar.D1(charset);
}
return "";
}
private String stringifyResponseBody(d0 d0Var) {
if (d0Var.a() != null) {
try {
return d0Var.t(1048576L).n();
} catch (IOException e11) {
m.a("Failed retrieving response body", e11);
}
}
return "";
}
@Override
@o0
public d0 intercept(@o0 w.a aVar) {
if (isShakeInitialized()) {
b0 request = aVar.request();
String a11 = e.a();
long currentTimeMillis = System.currentTimeMillis();
try {
d0 a12 = aVar.a(request);
insertNetworkRequest(generateNetworkRequest(request, a12, a11, currentTimeMillis, "", ""));
return a12;
} catch (SocketTimeoutException e11) {
m.a("Network request error", e11);
insertNetworkRequest(generateNetworkRequest(request, null, a11, currentTimeMillis, "t/o", "The request timed out."));
throw e11;
} catch (InterruptedIOException e12) {
m.a("Network request error", e12);
insertNetworkRequest(generateNetworkRequest(request, null, a11, currentTimeMillis, "t/o", "The request was interrupted."));
throw e12;
} catch (IOException e13) {
m.a("Network request error", e13);
insertNetworkRequest(!aVar.call().isCanceled() ? isConnectionOn().booleanValue() ? !isInternetAvailable().booleanValue() ? generateNetworkRequest(request, null, a11, currentTimeMillis, "n/r", "No internet available.") : generateNetworkRequest(request, null, a11, currentTimeMillis, "n/r", String.valueOf(e13.getLocalizedMessage())) : generateNetworkRequest(request, null, a11, currentTimeMillis, "n/r", "No network connection.") : generateNetworkRequest(request, null, a11, currentTimeMillis, "n/r", "The request was canceled."));
throw e13;
} catch (NoSuchElementException e14) {
m.a("Network request error", e14);
insertNetworkRequest(generateNetworkRequest(request, null, a11, currentTimeMillis, "t/o", "No route available."));
throw e14;
} catch (Exception e15) {
m.a("Network request error", e15);
insertNetworkRequest(generateNetworkRequest(request, null, a11, currentTimeMillis, "t/o", String.valueOf(e15.getLocalizedMessage())));
throw e15;
}
}
return aVar.a(aVar.request());
}
}