正在查看: 万能钥匙 v1.1.23 应用的 DownloadModuleHandler.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 万能钥匙 v1.1.23 应用的 DownloadModuleHandler.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.finogeeks.lib.applet.api.network;
import android.text.TextUtils;
import android.webkit.URLUtil;
import com.finogeeks.lib.applet.api.CallbackHandlerKt;
import com.finogeeks.lib.applet.appletdir.AppletTempDirProvider;
import com.finogeeks.lib.applet.appletdir.AppletUsrDirProvider;
import com.finogeeks.lib.applet.client.FinAppConfig;
import com.finogeeks.lib.applet.client.FinAppInfo;
import com.finogeeks.lib.applet.f.c.a0;
import com.finogeeks.lib.applet.f.c.j;
import com.finogeeks.lib.applet.f.c.x;
import com.finogeeks.lib.applet.i.domain.DomainChecker;
import com.finogeeks.lib.applet.interfaces.ICallback;
import com.finogeeks.lib.applet.main.host.Host;
import com.finogeeks.lib.applet.media.video.client.AbsFinMediaPlayer;
import com.finogeeks.lib.applet.modules.common.CommonKt;
import com.finogeeks.lib.applet.modules.ext.r;
import com.finogeeks.lib.applet.modules.log.FLog;
import com.finogeeks.lib.applet.modules.subscaleview.ImageEditeActivity;
import com.finogeeks.lib.applet.sdk.api.DelegateResult;
import com.finogeeks.lib.applet.sdk.api.IAppletNetWorkRequestHandler;
import com.finogeeks.lib.applet.sdk.api.NetWorkAPI;
import com.finogeeks.lib.applet.utils.FinFileResourceUtil;
import com.finogeeks.lib.applet.utils.OkHttpUtil;
import com.finogeeks.lib.applet.utils.RefererUtil;
import com.finogeeks.lib.applet.utils.a0;
import com.finogeeks.lib.applet.utils.d1;
import com.finogeeks.lib.applet.utils.j0;
import com.finogeeks.lib.applet.utils.l0;
import com.finogeeks.lib.applet.utils.m;
import com.finogeeks.lib.applet.utils.s0;
import hh0.l;
import java.io.File;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLPeerUnverifiedException;
import kotlin.Metadata;
import kotlin.Pair;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.f0;
import kotlin.jvm.internal.g0;
import kotlin.jvm.internal.n;
import kotlin.jvm.internal.p;
import kotlin.jvm.internal.y;
import lg0.s;
import mg0.k0;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import tj0.t;
import tj0.u;
@Metadata(d1 = {"\u0000\u0080\u0001\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\b\n\u0000\n\u0002\u0010$\n\u0000\n\u0002\u0018\u0002\n\u0002\b\n\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0006\u0018\u00002\u00020\u0001:\u0001FB\u000f\u0012\u0006\u0010\u0003\u001a\u00020\u0002¢\u0006\u0004\b\u0004\u0010\u0005JG\u0010\u0013\u001a\u00020\u00122\u0006\u0010\u0007\u001a\u00020\u00062\u0006\u0010\t\u001a\u00020\b2\u0006\u0010\u000b\u001a\u00020\n2\u0006\u0010\r\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u000e2\u0006\u0010\u0010\u001a\u00020\u000e2\u0006\u0010\u0011\u001a\u00020\u000eH\u0002¢\u0006\u0004\b\u0013\u0010\u0014J%\u0010\u0016\u001a\u00020\u00122\u0006\u0010\u0015\u001a\u00020\u000e2\u0006\u0010\u000b\u001a\u00020\n2\u0006\u0010\r\u001a\u00020\f¢\u0006\u0004\b\u0016\u0010\u0017J\u0019\u0010\u001a\u001a\u0004\u0018\u00010\u000e2\u0006\u0010\u0019\u001a\u00020\u0018H\u0002¢\u0006\u0004\b\u001a\u0010\u001bJ!\u0010\u001e\u001a\u0004\u0018\u00010\u00062\u0006\u0010\u0015\u001a\u00020\u000e2\u0006\u0010\u001d\u001a\u00020\u001cH\u0002¢\u0006\u0004\b\u001e\u0010\u001fJ!\u0010!\u001a\u00020\u000e2\b\u0010 \u001a\u0004\u0018\u00010\u000e2\u0006\u0010\u0010\u001a\u00020\u000eH\u0002¢\u0006\u0004\b!\u0010\"J#\u0010%\u001a\u0004\u0018\u00010\u000e2\b\u0010$\u001a\u0004\u0018\u00010#2\u0006\u0010\u0010\u001a\u00020\u000eH\u0002¢\u0006\u0004\b%\u0010&JQ\u0010.\u001a\u00020\u00122\b\u0010'\u001a\u0004\u0018\u00010\u000e2\u0006\u0010)\u001a\u00020(2\b\u0010\u0010\u001a\u0004\u0018\u00010\u000e2\u0014\u0010+\u001a\u0010\u0012\u0004\u0012\u00020\u000e\u0012\u0004\u0012\u00020\u0001\u0018\u00010*2\u0006\u0010-\u001a\u00020,2\u0006\u0010\r\u001a\u00020\fH\u0002¢\u0006\u0004\b.\u0010/J'\u00100\u001a\u00020\u00122\u0006\u0010)\u001a\u00020(2\u0006\u0010-\u001a\u00020,2\u0006\u0010\u000f\u001a\u00020\u000eH\u0002¢\u0006\u0004\b0\u00101J\u0015\u00102\u001a\u00020\u00122\u0006\u0010\u000f\u001a\u00020\u000e¢\u0006\u0004\b2\u00103J\r\u00104\u001a\u00020\u0012¢\u0006\u0004\b4\u00105R\u0014\u0010\u0003\u001a\u00020\u00028\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0003\u00106R \u00109\u001a\u000e\u0012\u0004\u0012\u00020\u000e\u0012\u0004\u0012\u000208078\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b9\u0010:R\u001b\u0010@\u001a\u00020;8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b<\u0010=\u001a\u0004\b>\u0010?R\u001b\u0010E\u001a\u00020A8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\bB\u0010=\u001a\u0004\bC\u0010D¨\u0006G"}, d2 = {"Lcom/finogeeks/lib/applet/api/network/DownloadModuleHandler;", "", "Lcom/finogeeks/lib/applet/main/host/Host;", "host", "<init>", "(Lcom/finogeeks/lib/applet/main/host/Host;)V", "Lcom/finogeeks/lib/applet/sdk/api/IAppletNetWorkRequestHandler;", "requestHandler", "Lcom/finogeeks/lib/applet/client/FinAppInfo;", "finAppInfo", "Lorg/json/JSONObject;", "param", "Lcom/finogeeks/lib/applet/interfaces/ICallback;", "callback", "", "taskId", ImageEditeActivity.EXTRA_FILE_PATH, "tempDir", "Llg0/e0;", "delegateDownloadFile", "(Lcom/finogeeks/lib/applet/sdk/api/IAppletNetWorkRequestHandler;Lcom/finogeeks/lib/applet/client/FinAppInfo;Lorg/json/JSONObject;Lcom/finogeeks/lib/applet/interfaces/ICallback;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", FinFileResourceUtil.KEY_EVENT, "downloadFile", "(Ljava/lang/String;Lorg/json/JSONObject;Lcom/finogeeks/lib/applet/interfaces/ICallback;)V", "Lcom/finogeeks/lib/applet/externallib/okhttp3/Response;", "response", "getContentDispositionFileName", "(Lcom/finogeeks/lib/applet/externallib/okhttp3/Response;)Ljava/lang/String;", "Lcom/finogeeks/lib/applet/client/FinAppConfig;", "finAppConfig", "getDownloadFileDelegate", "(Ljava/lang/String;Lcom/finogeeks/lib/applet/client/FinAppConfig;)Lcom/finogeeks/lib/applet/sdk/api/IAppletNetWorkRequestHandler;", "ext", "getSaveFileName", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", "Ljava/io/File;", "tempFile", "getSendTempFileName", "(Ljava/io/File;Ljava/lang/String;)Ljava/lang/String;", "tempFileName", "", "statusCode", "", "profile", "Lcom/finogeeks/lib/applet/api/network/HeaderWrapper;", "headerWrapper", "handleResponse", "(Ljava/lang/String;ILjava/lang/String;Ljava/util/Map;Lcom/finogeeks/lib/applet/api/network/HeaderWrapper;Lcom/finogeeks/lib/applet/interfaces/ICallback;)V", "handleResponseHeader", "(ILcom/finogeeks/lib/applet/api/network/HeaderWrapper;Ljava/lang/String;)V", "onAbort", "(Ljava/lang/String;)V", "onDestroy", "()V", "Lcom/finogeeks/lib/applet/main/host/Host;", "Ljava/util/concurrent/ConcurrentHashMap;", "Lcom/finogeeks/lib/applet/externallib/okhttp3/Call;", "requests", "Ljava/util/concurrent/ConcurrentHashMap;", "Lcom/finogeeks/lib/applet/appletdir/AppletTempDirProvider;", "tempDirProvider$delegate", "Llg0/h;", "getTempDirProvider", "()Lcom/finogeeks/lib/applet/appletdir/AppletTempDirProvider;", "tempDirProvider", "Lcom/finogeeks/lib/applet/appletdir/AppletUsrDirProvider;", "usrDirProvider$delegate", "getUsrDirProvider", "()Lcom/finogeeks/lib/applet/appletdir/AppletUsrDirProvider;", "usrDirProvider", "Companion", "finapplet_release"}, k = 1, mv = {1, 4, 0})
public final class DownloadModuleHandler {
static final l[] e = {g0.j(new y(g0.b(DownloadModuleHandler.class), "tempDirProvider", "getTempDirProvider()Lcom/finogeeks/lib/applet/appletdir/AppletTempDirProvider;")), g0.j(new y(g0.b(DownloadModuleHandler.class), "usrDirProvider", "getUsrDirProvider()Lcom/finogeeks/lib/applet/appletdir/AppletUsrDirProvider;"))};
private final ConcurrentHashMap<String, com.finogeeks.lib.applet.f.c.e> a;
private final lg0.h b;
private final lg0.h c;
private final Host d;
public static final class a {
private a() {
}
public a(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
public static final class b implements IAppletNetWorkRequestHandler.ResultDispatchCallback {
final ICallback b;
final String c;
final String d;
final String e;
public b(ICallback iCallback, String str, String str2, String str3) {
this.b = iCallback;
this.c = str;
this.d = str2;
this.e = str3;
}
@Override
public void dispatchResult(DelegateResult delegateResult, int i, String str, Map<String, ? extends List<String>> map, String str2) {
n.j(delegateResult, "delegateResult");
if (delegateResult != DelegateResult.SUCCESS) {
ICallback iCallback = this.b;
if (str2 == null) {
str2 = "";
}
CallbackHandlerKt.fail(iCallback, str2);
return;
}
if (str == null || str.length() == 0) {
CallbackHandlerKt.fail(this.b, "downloadFile path is not empty");
return;
}
try {
File file = new File(str);
if (!file.exists() || !file.isFile()) {
CallbackHandlerKt.fail(this.b, "downloadFile is not exists");
return;
}
NetWorkConfig netWorkConfig = NetWorkConfig.a;
if (map == null) {
map = k0.h();
}
com.finogeeks.lib.applet.api.network.i a = netWorkConfig.a(map);
DownloadModuleHandler.this.a(i, a, this.c);
File file2 = new File(this.e, DownloadModuleHandler.this.a(com.finogeeks.lib.applet.modules.ext.n.b(file), this.d));
yg0.n.t(file, file2, true, 0, 4, (Object) null);
DownloadModuleHandler.this.a(DownloadModuleHandler.this.a(file2, this.d), i, this.d, null, a, this.b);
} catch (Exception e) {
e.printStackTrace();
ICallback iCallback2 = this.b;
String message = e.getMessage();
CallbackHandlerKt.fail(iCallback2, message != null ? message : "");
}
}
}
@Metadata(d1 = {"\u0000\u001f\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010$\n\u0002\u0010\u000e\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J#\u0010\u0007\u001a\u00020\u00062\u0012\u0010\u0005\u001a\u000e\u0012\u0004\u0012\u00020\u0003\u0012\u0004\u0012\u00020\u00040\u0002H\u0016¢\u0006\u0004\b\u0007\u0010\b¨\u0006\t"}, d2 = {"com/finogeeks/lib/applet/api/network/DownloadModuleHandler$delegateDownloadFile$2", "Lcom/finogeeks/lib/applet/sdk/api/IAppletNetWorkRequestHandler$ProgressDispatchCallback;", "", "", "", "progressInfo", "Llg0/e0;", "dispatchProgress", "(Ljava/util/Map;)V", "finapplet_release"}, k = 1, mv = {1, 4, 0})
public static final class c implements IAppletNetWorkRequestHandler.ProgressDispatchCallback {
public static final class a implements Runnable {
final Map b;
public a(Map map) {
this.b = map;
}
@Override
public final void run() {
DownloadModuleHandler.this.d.sendToServiceJSBridge("onTaskProgressUpdate", CommonKt.getGSon().toJson(this.b), 0, null);
}
}
public c() {
}
@Override
public void dispatchProgress(Map<String, ? extends Object> progressInfo) {
n.j(progressInfo, "progressInfo");
d1.a().post(new a(progressInfo));
}
}
@Metadata(d1 = {"\u0000%\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\u001f\u0010\u0007\u001a\u00020\u00062\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0005\u001a\u00020\u0004H\u0016¢\u0006\u0004\b\u0007\u0010\bJ\u001f\u0010\u000b\u001a\u00020\u00062\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\n\u001a\u00020\tH\u0016¢\u0006\u0004\b\u000b\u0010\f¨\u0006\r"}, d2 = {"com/finogeeks/lib/applet/api/network/DownloadModuleHandler$downloadFile$1", "Lcom/finogeeks/lib/applet/externallib/okhttp3/Callback;", "Lcom/finogeeks/lib/applet/externallib/okhttp3/Call;", "call", "Ljava/io/IOException;", "e", "Llg0/e0;", "onFailure", "(Lcom/finogeeks/lib/applet/externallib/okhttp3/Call;Ljava/io/IOException;)V", "Lcom/finogeeks/lib/applet/externallib/okhttp3/Response;", "response", "onResponse", "(Lcom/finogeeks/lib/applet/externallib/okhttp3/Call;Lcom/finogeeks/lib/applet/externallib/okhttp3/Response;)V", "finapplet_release"}, k = 1, mv = {1, 4, 0})
public static final class d implements com.finogeeks.lib.applet.f.c.f {
final ICallback b;
final String c;
final String d;
final String e;
final String f;
final f0 g;
final boolean h;
final f0 i;
public static final class a implements Runnable {
final IOException b;
final com.finogeeks.lib.applet.f.c.e c;
public a(IOException iOException, com.finogeeks.lib.applet.f.c.e eVar) {
this.b = iOException;
this.c = eVar;
}
@Override
public final void run() {
if (this.b instanceof UnknownHostException) {
CallbackHandlerKt.unknownHost(d.this.b, "downloadFile:fail download fail:");
} else if (this.c.b()) {
CallbackHandlerKt.fail(d.this.b, "abort");
} else {
IOException iOException = this.b;
if (iOException instanceof SocketTimeoutException) {
CallbackHandlerKt.fail(d.this.b, "fail:time out");
} else if (iOException instanceof SSLPeerUnverifiedException) {
d dVar = d.this;
dVar.b.onFail(CallbackHandlerKt.apiFail(dVar.c, iOException));
} else {
ICallback iCallback = d.this.b;
String message = iOException.getMessage();
if (message == null) {
message = "";
}
CallbackHandlerKt.fail(iCallback, message);
}
}
FLog.e$default("DownloadModuleHandler", "download onFailure : " + this.b.getLocalizedMessage(), null, 4, null);
}
}
public d(ICallback iCallback, String str, String str2, String str3, String str4, f0 f0Var, boolean z10, f0 f0Var2) {
this.b = iCallback;
this.c = str;
this.d = str2;
this.e = str3;
this.f = str4;
this.g = f0Var;
this.h = z10;
this.i = f0Var2;
}
@Override
public void onFailure(com.finogeeks.lib.applet.f.c.e eVar, IOException iOException) {
n.j(eVar, "call");
n.j(iOException, "e");
d1.a().post(new a(iOException, eVar));
DownloadModuleHandler.this.a.remove(this.d);
}
@Override
public void onResponse(com.finogeeks.lib.applet.f.c.e r13, com.finogeeks.lib.applet.f.c.c0 r14) {
throw new UnsupportedOperationException("Method not decompiled: com.finogeeks.lib.applet.api.network.DownloadModuleHandler.d.onResponse(com.finogeeks.lib.applet.f.c.e, com.finogeeks.lib.applet.f.c.c0):void");
}
}
public static final class e implements s0 {
private long a;
final String c;
public e(String str) {
this.c = str;
}
@Override
public void a(long j, long j2, boolean z10) {
if (System.currentTimeMillis() - this.a >= AbsFinMediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK || z10) {
this.a = System.currentTimeMillis();
if (DownloadModuleHandler.this.a.containsKey(this.c)) {
Map l = k0.l(new Pair[]{s.a("taskId", this.c)});
long j3 = (100 * j) / (j2 != 0 ? j2 : 1L);
if (j3 < 0) {
j3 = 0;
}
l.put("progress", Long.valueOf(j3));
l.put("totalBytesWritten", Long.valueOf(j));
if (j2 < 0) {
j2 = 0;
}
l.put("totalBytesExpectedToWrite", Long.valueOf(j2));
DownloadModuleHandler.this.d.sendToServiceJSBridge("onTaskProgressUpdate", CommonKt.getGSon().toJson(l), 0, null);
}
}
}
}
public static final class f implements Runnable {
final String a;
final int b;
final com.finogeeks.lib.applet.api.network.i c;
final String d;
final Map e;
final ICallback f;
public f(String str, int i, com.finogeeks.lib.applet.api.network.i iVar, String str2, Map map, ICallback iCallback) {
this.a = str;
this.b = i;
this.c = iVar;
this.d = str2;
this.e = map;
this.f = iCallback;
}
@Override
public final void run() {
String str = this.a;
if (str != null && !t.y(str)) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("statusCode", this.b);
jSONObject.put("header", this.c.b());
jSONObject.put("cookies", this.c.a());
String str2 = this.d;
if (str2 == null || str2.length() == 0) {
jSONObject.put(ImageEditeActivity.EXTRA_TEMP_FILE_PATH, this.a);
} else {
jSONObject.put(ImageEditeActivity.EXTRA_FILE_PATH, this.d);
}
if (this.e != null) {
jSONObject.put("profile", new JSONObject(this.e));
}
this.f.onSuccess(jSONObject);
return;
} catch (JSONException unused) {
FLog.e$default("DownloadModuleHandler", "downloadFile assemble result exception!", null, 4, null);
}
}
this.f.onFail();
}
}
public static final class g implements Runnable {
final int b;
final String c;
final JSONObject d;
final JSONArray e;
public g(int i, String str, JSONObject jSONObject, JSONArray jSONArray) {
this.b = i;
this.c = str;
this.d = jSONObject;
this.e = jSONArray;
}
@Override
public final void run() {
String jSONObject = new JSONObject().put("statusCode", this.b).put("taskId", this.c).put("header", this.d).put("cookies", this.e).toString();
n.e(jSONObject, "JSONObject()\n …kiesJSONArray).toString()");
DownloadModuleHandler.this.d.sendToServiceJSBridge("onTaskHeadersReceived", jSONObject, 0, null);
}
}
public static final class h extends p implements ah0.a<AppletTempDirProvider> {
public h() {
super(0);
}
public final AppletTempDirProvider m144invoke() {
return AppletTempDirProvider.INSTANCE.createByAppConfig(DownloadModuleHandler.this.d.getK(), DownloadModuleHandler.this.d.getAppConfig());
}
}
public static final class i extends p implements ah0.a<AppletUsrDirProvider> {
public i() {
super(0);
}
public final AppletUsrDirProvider m145invoke() {
return AppletUsrDirProvider.INSTANCE.createByAppConfig(DownloadModuleHandler.this.d.getK(), DownloadModuleHandler.this.d.getAppConfig());
}
}
static {
new a(null);
}
public DownloadModuleHandler(Host host) {
n.j(host, "host");
this.d = host;
this.a = new ConcurrentHashMap<>();
this.b = lg0.i.a(new h());
this.c = lg0.i.a(new i());
}
private final IAppletNetWorkRequestHandler a(String str, FinAppConfig finAppConfig) {
IAppletNetWorkRequestHandler a2 = com.finogeeks.lib.applet.api.network.c.b.a(finAppConfig.getNetWorkRequestHandlerClass());
if (n.d(str, "downloadFile") && a2 != null && a2.isAPIDelegated(IAppletNetWorkRequestHandler.DelegateNetWorkAPI.DownloadFile)) {
return a2;
}
return null;
}
public final String a(File file, String str) {
if (file == null || !file.exists()) {
return null;
}
return str.length() > 0 ? str : FinFileResourceUtil.SCHEME + file.getName();
}
public final String a(String str, String str2) {
String uuid = UUID.randomUUID().toString();
n.e(uuid, "UUID.randomUUID().toString()");
return str2.length() > 0 ? u.P0(str2, "finfile://usr/", (String) null, 2, (Object) null) : "tmp_" + a0.a(uuid) + str;
}
public final void a(int i2, com.finogeeks.lib.applet.api.network.i iVar, String str) {
d1.a().post(new g(i2, str, iVar.b(), iVar.a()));
}
private final void a(IAppletNetWorkRequestHandler iAppletNetWorkRequestHandler, FinAppInfo finAppInfo, JSONObject jSONObject, ICallback iCallback, String str, String str2, String str3) {
iAppletNetWorkRequestHandler.getDownloadFileResult(finAppInfo, jSONObject, new b(iCallback, str, str2, str3), new c());
}
public final void a(String str, int i2, String str2, Map<String, ? extends Object> map, com.finogeeks.lib.applet.api.network.i iVar, ICallback iCallback) {
d1.a().post(new f(str, i2, iVar, str2, map, iCallback));
}
private final AppletTempDirProvider b() {
lg0.h hVar = this.b;
l lVar = e[0];
return (AppletTempDirProvider) hVar.getValue();
}
private final AppletUsrDirProvider c() {
lg0.h hVar = this.c;
l lVar = e[1];
return (AppletUsrDirProvider) hVar.getValue();
}
public final void a() {
Collection<com.finogeeks.lib.applet.f.c.e> values = this.a.values();
n.e(values, "requests.values");
Iterator<T> it = values.iterator();
while (it.hasNext()) {
((com.finogeeks.lib.applet.f.c.e) it.next()).cancel();
}
this.a.clear();
}
public final void a(String str) {
n.j(str, "taskId");
com.finogeeks.lib.applet.f.c.e eVar = this.a.get(str);
if (eVar != null) {
eVar.cancel();
}
this.a.remove(str);
}
public final void a(String str, JSONObject jSONObject, ICallback iCallback) {
n.j(str, FinFileResourceUtil.KEY_EVENT);
n.j(jSONObject, "param");
n.j(iCallback, "callback");
FinAppConfig finAppConfig = this.d.getFinAppConfig();
FinAppInfo b2 = this.d.getB();
String optString = jSONObject.optString(ImageEditeActivity.EXTRA_FILE_PATH);
if (optString != null && optString.length() != 0 && !t.L(optString, "finfile://usr/", false, 2, (Object) null)) {
CallbackHandlerKt.fail(iCallback, "permission denied, open " + optString);
return;
}
String optString2 = jSONObject.optString("taskId");
f0 f0Var = new f0();
String absolutePath = b().getDirForWrite().getAbsolutePath();
n.e(absolutePath, "tempDirProvider.getDirForWrite().absolutePath");
f0Var.a = absolutePath;
if (optString != null && optString.length() != 0) {
String absolutePath2 = c().getDirForWrite().getAbsolutePath();
n.e(absolutePath2, "usrDirProvider.getDirForWrite().absolutePath");
f0Var.a = absolutePath2;
}
if (TextUtils.isEmpty((String) f0Var.a)) {
iCallback.onFail();
return;
}
IAppletNetWorkRequestHandler a2 = a(str, finAppConfig);
if (a2 != null) {
n.e(optString2, "taskId");
n.e(optString, ImageEditeActivity.EXTRA_FILE_PATH);
a(a2, b2, jSONObject, iCallback, optString2, optString, (String) f0Var.a);
return;
}
String optString3 = jSONObject.optString("url");
if (optString3 == null || t.y(optString3)) {
iCallback.onFail();
return;
}
long optLong = jSONObject.optLong("timeout");
if (optLong <= 0) {
optLong = 60000;
}
if (!URLUtil.isValidUrl(optString3)) {
iCallback.onFail(CallbackHandlerKt.apiFail(str, "Not a web url(" + optString3 + ')'));
return;
}
DomainChecker domainChecker = this.d.r().getDomainChecker();
if (domainChecker == null) {
iCallback.onFail();
return;
}
com.finogeeks.lib.applet.i.domain.b b3 = domainChecker.b(optString3);
if (!b3.b()) {
CallbackHandlerKt.illegalDomain(iCallback, str, b3);
return;
}
JSONObject optJSONObject = jSONObject.optJSONObject("header");
Map l = k0.l(new Pair[]{s.a(AbsFinMediaPlayer.HEADER_USER_AGENT, RequestModuleHandler.f.a())});
Map<String, String> header = finAppConfig.getHeader();
if (header == null) {
header = k0.h();
}
l.putAll(header);
l.putAll(OkHttpUtil.d.a(optJSONObject));
String a3 = RefererUtil.a(b2);
if (!m.a(l, "Referer") && a3.length() > 0) {
l.put("Referer", a3);
}
boolean optBoolean = jSONObject.optBoolean("enableProfile", true);
f0 f0Var2 = new f0();
f0Var2.a = null;
if (optBoolean) {
f0Var2.a = new com.finogeeks.lib.applet.api.network.f();
}
com.finogeeks.lib.applet.f.c.a0 a4 = new a0.a().a(com.finogeeks.lib.applet.f.c.s.a((Map<String, String>) l)).b(optString3).a();
x.b t = this.d.r().getOkHttpUtil().a().t();
n.e(t, "host.finContext.okHttpUt… .newBuilder()");
x.b a5 = j0.a(t, new e(optString2), null, 2, null);
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
x.b b4 = a5.a(optLong, timeUnit).c(optLong, timeUnit).d(optLong, timeUnit).b(new com.finogeeks.lib.applet.debugger.b());
n.e(b4, "host.finContext.okHttpUt…ptor(StethoInterceptor())");
x.b a6 = l0.a(b4, finAppConfig, NetWorkAPI.DownloadFile);
if (finAppConfig.isIgnoreWebviewCertAuth()) {
r.a(a6);
}
if (optBoolean) {
com.finogeeks.lib.applet.api.network.f fVar = (com.finogeeks.lib.applet.api.network.f) f0Var2.a;
if (fVar == null) {
n.t();
}
a6.a(fVar);
a6.a(new j(1, 5L, TimeUnit.MINUTES));
}
com.finogeeks.lib.applet.f.c.e a7 = a6.a().a(a4);
String valueOf = (optString2 == null || optString2.length() == 0) ? String.valueOf(System.currentTimeMillis()) : optString2;
ConcurrentHashMap<String, com.finogeeks.lib.applet.f.c.e> concurrentHashMap = this.a;
n.e(a7, "call");
concurrentHashMap.put(valueOf, a7);
a7.a(new d(iCallback, str, valueOf, optString2, optString, f0Var, optBoolean, f0Var2));
}
}