正在查看: Easycash v3.75.13 应用的 DefaultConnection.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Easycash v3.75.13 应用的 DefaultConnection.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.ipification.mobile.sdk.android.connection;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Build;
import com.ipification.mobile.sdk.android.callback.CellularCallback;
import com.ipification.mobile.sdk.android.model.ResponseBody;
import com.ipification.mobile.sdk.android.model.SIMOperator;
import com.ipification.mobile.sdk.android.request.API_TYPE;
import com.ipification.mobile.sdk.android.request.AuthRequest;
import com.ipification.mobile.sdk.android.ssl.TLSSocketFactory;
import com.ipification.mobile.sdk.android.utils.DeviceUtils;
import com.ipification.mobile.sdk.android.utils.LogUtils;
import com.ipification.mobile.sdk.android.utils.LogUtilsKt;
import com.ipification.mobile.sdk.android.utils.NetworkUtils;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.net.ssl.HttpsURLConnection;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.io.TextStreamsKt;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import org.apache.http.conn.ssl.AllowAllHostnameVerifier;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@Metadata
public final class DefaultConnection<T> extends AsyncTask<Unit, Unit, ResponseBody> {
private Context a;
@Nullable
private Exception b;
private int c;
private boolean d;
private boolean e;
private DeviceUtils f;
private AuthRequest g;
private CellularCallback<T> h;
private URL i;
@Metadata
public class WhenMappings {
public static final int[] a;
static {
int[] iArr = new int[API_TYPE.values().length];
iArr[API_TYPE.COVERAGE.ordinal()] = 1;
iArr[API_TYPE.AUTH.ordinal()] = 2;
a = iArr;
}
}
public DefaultConnection() {
}
public DefaultConnection(boolean z, @NotNull Context context, @NotNull AuthRequest authRequest, @NotNull CellularCallback<T> cellularCallback) {
this();
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(authRequest, "request");
Intrinsics.checkNotNullParameter(cellularCallback, "cellularCallback");
this.d = z;
this.a = context;
this.g = authRequest;
this.h = cellularCallback;
this.f = DeviceUtils.c.a(context);
}
private final void b(com.ipification.mobile.sdk.android.model.ResponseBody r13) {
throw new UnsupportedOperationException("Method not decompiled: com.ipification.mobile.sdk.android.connection.DefaultConnection.b(com.ipification.mobile.sdk.android.model.ResponseBody):void");
}
private final ResponseBody c(URL url) {
HttpURLConnection httpURLConnection;
String m2;
URLConnection openConnection;
LogUtils.Companion companion = LogUtils.a;
AuthRequest authRequest = this.g;
if (authRequest == null) {
Intrinsics.v("request");
authRequest = null;
}
Context context = this.a;
if (context == null) {
Intrinsics.v("context");
context = null;
}
LogUtilsKt.a(companion, Intrinsics.m("openConnection ", authRequest.m(context)));
boolean z = false;
HttpURLConnection.setFollowRedirects(false);
HttpURLConnection.setFollowRedirects(false);
try {
openConnection = url.openConnection();
} catch (Exception unused) {
URLConnection openConnection2 = url.openConnection();
if (openConnection2 == null) {
throw new NullPointerException("null cannot be cast to non-null type java.net.HttpURLConnection");
}
httpURLConnection = (HttpURLConnection) openConnection2;
}
if (openConnection == null) {
throw new NullPointerException("null cannot be cast to non-null type javax.net.ssl.HttpsURLConnection");
}
httpURLConnection = (HttpsURLConnection) openConnection;
if (httpURLConnection instanceof HttpsURLConnection) {
HttpsURLConnection.setDefaultHostnameVerifier(new AllowAllHostnameVerifier());
((HttpsURLConnection) httpURLConnection).setSSLSocketFactory(new TLSSocketFactory());
}
AuthRequest authRequest2 = this.g;
if (authRequest2 == null) {
Intrinsics.v("request");
authRequest2 = null;
}
httpURLConnection.setReadTimeout((int) authRequest2.i());
AuthRequest authRequest3 = this.g;
if (authRequest3 == null) {
Intrinsics.v("request");
authRequest3 = null;
}
httpURLConnection.setConnectTimeout((int) authRequest3.b());
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setDoInput(true);
httpURLConnection.setRequestProperty("charset", "utf-8");
httpURLConnection.setRequestProperty("Accept", "*/*");
AuthRequest authRequest4 = this.g;
if (authRequest4 == null) {
Intrinsics.v("request");
authRequest4 = null;
}
HashMap<String, String> d = authRequest4.d();
if (d != null && !this.d) {
for (Map.Entry<String, String> entry : d.entrySet()) {
httpURLConnection.setRequestProperty(entry.getKey(), entry.getValue());
}
}
AuthRequest authRequest5 = this.g;
if (authRequest5 == null) {
Intrinsics.v("request");
authRequest5 = null;
}
authRequest5.c();
if (!this.d) {
AuthRequest authRequest6 = this.g;
if (authRequest6 == null) {
Intrinsics.v("request");
authRequest6 = null;
}
if (authRequest6.a() != API_TYPE.OTHER) {
httpURLConnection.setRequestProperty("ip-sdk-version", "2.0.14.1");
httpURLConnection.setRequestProperty("device-type", "android");
httpURLConnection.setRequestProperty("device-name", ((Object) Build.MANUFACTURER) + " - " + ((Object) Build.MODEL));
httpURLConnection.setRequestProperty("os-version", Build.VERSION.RELEASE);
httpURLConnection.setRequestProperty("os-sdk", String.valueOf(Build.VERSION.SDK_INT));
AuthRequest authRequest7 = this.g;
if (authRequest7 == null) {
Intrinsics.v("request");
authRequest7 = null;
}
if (authRequest7.c()) {
DeviceUtils deviceUtils = this.f;
if (deviceUtils == null) {
Intrinsics.v("deviceInfo");
deviceUtils = null;
}
boolean f = deviceUtils.f();
DeviceUtils deviceUtils2 = this.f;
if (deviceUtils2 == null) {
Intrinsics.v("deviceInfo");
deviceUtils2 = null;
}
SIMOperator c = deviceUtils2.c();
httpURLConnection.setRequestProperty("mcc-1", c.b());
httpURLConnection.setRequestProperty("mnc-1", c.c());
httpURLConnection.setRequestProperty("mnc-1-error-msg", c.a());
httpURLConnection.setRequestProperty("dual-sim-phone", f ? "yes" : "no");
if (f) {
DeviceUtils deviceUtils3 = this.f;
if (deviceUtils3 == null) {
Intrinsics.v("deviceInfo");
deviceUtils3 = null;
}
SIMOperator d2 = deviceUtils3.d();
httpURLConnection.setRequestProperty("mcc-2", d2.b());
httpURLConnection.setRequestProperty("mnc-2", d2.c());
httpURLConnection.setRequestProperty("mnc-2-error-msg", d2.a());
DeviceUtils deviceUtils4 = this.f;
if (deviceUtils4 == null) {
Intrinsics.v("deviceInfo");
deviceUtils4 = null;
}
SIMOperator e = deviceUtils4.e();
String b = e == null ? null : e.b();
if (b == null) {
DeviceUtils deviceUtils5 = this.f;
if (deviceUtils5 == null) {
Intrinsics.v("deviceInfo");
deviceUtils5 = null;
}
b = deviceUtils5.a().b();
}
DeviceUtils deviceUtils6 = this.f;
if (deviceUtils6 == null) {
Intrinsics.v("deviceInfo");
deviceUtils6 = null;
}
SIMOperator e2 = deviceUtils6.e();
String c2 = e2 == null ? null : e2.c();
if (c2 == null) {
DeviceUtils deviceUtils7 = this.f;
if (deviceUtils7 == null) {
Intrinsics.v("deviceInfo");
deviceUtils7 = null;
}
c2 = deviceUtils7.a().c();
}
NetworkUtils.Companion companion2 = NetworkUtils.a;
Context context2 = this.a;
if (context2 == null) {
Intrinsics.v("context");
context2 = null;
}
boolean isMobileDataEnabled$ipification_auth_release = companion2.isMobileDataEnabled$ipification_auth_release(context2);
m2 = Intrinsics.m(b, c2);
if (!isMobileDataEnabled$ipification_auth_release) {
httpURLConnection.setRequestProperty("last-active-data-session-sim", m2);
}
} else {
m2 = Intrinsics.m(c.b(), c.c());
}
httpURLConnection.setRequestProperty("active-data-session-sim", m2);
}
}
}
try {
httpURLConnection.connect();
LogUtilsKt.a(LogUtils.a, httpURLConnection.getHeaderFields() + " - " + ((Object) httpURLConnection.getResponseMessage()));
this.c = httpURLConnection.getResponseCode();
try {
if (httpURLConnection.getResponseCode() == 200) {
try {
String e3 = e(new BufferedInputStream(httpURLConnection.getInputStream()));
Map<String, List<String>> headerFields = httpURLConnection.getHeaderFields();
Intrinsics.checkNotNullExpressionValue(headerFields, "httpClient.headerFields");
return new ResponseBody(e3, headerFields);
} catch (Exception e4) {
String message = e4.getMessage();
if (message != null) {
LogUtilsKt.b(LogUtils.a, message);
}
this.b = e4;
return null;
}
}
int responseCode = httpURLConnection.getResponseCode();
if (300 <= responseCode && responseCode <= 310) {
z = true;
}
if (z) {
String headerField = httpURLConnection.getHeaderField("Location");
if (headerField == null) {
headerField = httpURLConnection.getHeaderField("location");
}
Map<String, List<String>> headerFields2 = httpURLConnection.getHeaderFields();
Intrinsics.checkNotNullExpressionValue(headerFields2, "httpClient.headerFields");
return new ResponseBody(headerField, headerFields2);
}
String str = httpURLConnection.getResponseCode() + " - " + ((Object) httpURLConnection.getResponseMessage());
Map<String, List<String>> headerFields3 = httpURLConnection.getHeaderFields();
Intrinsics.checkNotNullExpressionValue(headerFields3, "httpClient.headerFields");
return new ResponseBody(str, headerFields3);
} finally {
httpURLConnection.disconnect();
}
} catch (Exception e5) {
this.b = e5;
String message2 = e5.getMessage();
if (message2 != null) {
LogUtilsKt.b(LogUtils.a, message2);
}
return null;
}
}
private final String e(BufferedInputStream bufferedInputStream) {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(bufferedInputStream));
final StringBuilder sb = new StringBuilder();
TextStreamsKt.c(bufferedReader, new Function1<String, Unit>() {
{
super(1);
}
public final void b(@NotNull String str) {
Intrinsics.checkNotNullParameter(str, "it");
sb.append(str);
}
public Object invoke(Object obj) {
b((String) obj);
return Unit.a;
}
});
String sb2 = sb.toString();
Intrinsics.checkNotNullExpressionValue(sb2, "stringBuilder.toString()");
return sb2;
}
@Override
@Nullable
public ResponseBody doInBackground(@NotNull Unit... unitArr) {
Intrinsics.checkNotNullParameter(unitArr, "params");
AuthRequest authRequest = this.g;
Context context = null;
if (authRequest == null) {
Intrinsics.v("request");
authRequest = null;
}
Context context2 = this.a;
if (context2 == null) {
Intrinsics.v("context");
} else {
context = context2;
}
URL url = new URL(authRequest.m(context).toString());
this.i = url;
return c(url);
}
@Override
public void onPostExecute(@Nullable ResponseBody responseBody) {
super.onPostExecute(responseBody);
LogUtilsKt.a(LogUtils.a, "onPostExecute " + this.c + ' ' + responseBody);
b(responseBody);
}
public final void f(boolean z) {
this.e = z;
}
}