正在查看: 万能钥匙 v1.1.23 应用的 UploadModule.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 万能钥匙 v1.1.23 应用的 UploadModule.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.finogeeks.lib.applet.api.network;
import android.content.Context;
import android.text.TextUtils;
import android.webkit.URLUtil;
import com.finogeeks.lib.applet.api.BaseApi;
import com.finogeeks.lib.applet.api.CallbackHandlerKt;
import com.finogeeks.lib.applet.appletdir.AbsAppletDirProvider;
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.b0;
import com.finogeeks.lib.applet.f.c.c0;
import com.finogeeks.lib.applet.f.c.d0;
import com.finogeeks.lib.applet.f.c.s;
import com.finogeeks.lib.applet.f.c.u;
import com.finogeeks.lib.applet.f.c.v;
import com.finogeeks.lib.applet.f.c.w;
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.ProgressRequestBody;
import com.finogeeks.lib.applet.utils.RefererUtil;
import com.finogeeks.lib.applet.utils.b1;
import com.finogeeks.lib.applet.utils.l0;
import com.finogeeks.lib.applet.utils.m;
import com.finogeeks.lib.applet.utils.q0;
import hh0.l;
import java.io.File;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.net.URLConnection;
import java.net.UnknownHostException;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
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.g0;
import kotlin.jvm.internal.n;
import kotlin.jvm.internal.p;
import kotlin.jvm.internal.y;
import mg0.k0;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import tj0.t;
@Metadata(d1 = {"\u0000z\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0011\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010$\n\u0002\u0010 \n\u0002\b\u0005\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\u0018\u00002\u00020\u0001:\u0001>B\u0017\u0012\u0006\u0010\u0003\u001a\u00020\u0002\u0012\u0006\u0010\u0005\u001a\u00020\u0004¢\u0006\u0004\b\u0006\u0010\u0007J\u0015\u0010\n\u001a\b\u0012\u0004\u0012\u00020\t0\bH\u0016¢\u0006\u0004\b\n\u0010\u000bJ(\u0010\u0012\u001a\u00020\u00112\u0006\u0010\f\u001a\u00020\t2\u0006\u0010\u000e\u001a\u00020\r2\u0006\u0010\u0010\u001a\u00020\u000fH\u0096\u0002¢\u0006\u0004\b\u0012\u0010\u0013J\u000f\u0010\u0014\u001a\u00020\u0011H\u0016¢\u0006\u0004\b\u0014\u0010\u0015J\u0017\u0010\u0017\u001a\u00020\t2\u0006\u0010\u0016\u001a\u00020\tH\u0002¢\u0006\u0004\b\u0017\u0010\u0018JA\u0010\u001e\u001a\u00020\u00112\u0006\u0010\u000e\u001a\u00020\r2\u0006\u0010\u0016\u001a\u00020\t2\u0006\u0010\u001a\u001a\u00020\u00192\u0006\u0010\u001c\u001a\u00020\u001b2\b\u0010\u001d\u001a\u0004\u0018\u00010\t2\u0006\u0010\u0010\u001a\u00020\u000fH\u0002¢\u0006\u0004\b\u001e\u0010\u001fJ!\u0010\"\u001a\u0004\u0018\u00010\u00192\u0006\u0010\f\u001a\u00020\t2\u0006\u0010!\u001a\u00020 H\u0002¢\u0006\u0004\b\"\u0010#JM\u0010*\u001a\u00020\u00112\u0006\u0010%\u001a\u00020$2\b\u0010&\u001a\u0004\u0018\u00010\t2\u0018\u0010)\u001a\u0014\u0012\u0004\u0012\u00020\t\u0012\n\u0012\b\u0012\u0004\u0012\u00020\t0(0'2\b\u0010\u001d\u001a\u0004\u0018\u00010\t2\u0006\u0010\u0010\u001a\u00020\u000fH\u0002¢\u0006\u0004\b*\u0010+J\u0015\u0010,\u001a\u00020\u00112\u0006\u0010\u001d\u001a\u00020\t¢\u0006\u0004\b,\u0010-J\u0017\u00101\u001a\u0002002\u0006\u0010/\u001a\u00020.H\u0002¢\u0006\u0004\b1\u00102R\u0014\u0010\u0005\u001a\u00020\u00048\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0005\u00103R#\u00109\u001a\n 4*\u0004\u0018\u000100008BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b5\u00106\u001a\u0004\b7\u00108R \u0010<\u001a\u000e\u0012\u0004\u0012\u00020\t\u0012\u0004\u0012\u00020;0:8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b<\u0010=¨\u0006?"}, d2 = {"Lcom/finogeeks/lib/applet/api/network/UploadModule;", "Lcom/finogeeks/lib/applet/api/BaseApi;", "Landroid/content/Context;", "context", "Lcom/finogeeks/lib/applet/main/host/Host;", "host", "<init>", "(Landroid/content/Context;Lcom/finogeeks/lib/applet/main/host/Host;)V", "", "", "apis", "()[Ljava/lang/String;", FinFileResourceUtil.KEY_EVENT, "Lorg/json/JSONObject;", "param", "Lcom/finogeeks/lib/applet/interfaces/ICallback;", "callback", "Llg0/e0;", "invoke", "(Ljava/lang/String;Lorg/json/JSONObject;Lcom/finogeeks/lib/applet/interfaces/ICallback;)V", "onDestroy", "()V", ImageEditeActivity.EXTRA_FILE_PATH, "convertFilePath", "(Ljava/lang/String;)Ljava/lang/String;", "Lcom/finogeeks/lib/applet/sdk/api/IAppletNetWorkRequestHandler;", "requestHandler", "Lcom/finogeeks/lib/applet/client/FinAppInfo;", "finAppInfo", "taskId", "delegateUploadFile", "(Lorg/json/JSONObject;Ljava/lang/String;Lcom/finogeeks/lib/applet/sdk/api/IAppletNetWorkRequestHandler;Lcom/finogeeks/lib/applet/client/FinAppInfo;Ljava/lang/String;Lcom/finogeeks/lib/applet/interfaces/ICallback;)V", "Lcom/finogeeks/lib/applet/client/FinAppConfig;", "finAppConfig", "getUploadFileDelegate", "(Ljava/lang/String;Lcom/finogeeks/lib/applet/client/FinAppConfig;)Lcom/finogeeks/lib/applet/sdk/api/IAppletNetWorkRequestHandler;", "", "statusCode", "respData", "", "", "headers", "handleResponse", "(ILjava/lang/String;Ljava/util/Map;Ljava/lang/String;Lcom/finogeeks/lib/applet/interfaces/ICallback;)V", "onAbort", "(Ljava/lang/String;)V", "", "timeout", "Lcom/finogeeks/lib/applet/externallib/okhttp3/OkHttpClient;", "timeOutConfig", "(J)Lcom/finogeeks/lib/applet/externallib/okhttp3/OkHttpClient;", "Lcom/finogeeks/lib/applet/main/host/Host;", "kotlin.jvm.PlatformType", "okHttpClient$delegate", "Llg0/h;", "getOkHttpClient", "()Lcom/finogeeks/lib/applet/externallib/okhttp3/OkHttpClient;", "okHttpClient", "Ljava/util/concurrent/ConcurrentHashMap;", "Lcom/finogeeks/lib/applet/externallib/okhttp3/Call;", "requests", "Ljava/util/concurrent/ConcurrentHashMap;", "Companion", "finapplet_release"}, k = 1, mv = {1, 4, 0})
public final class UploadModule extends BaseApi {
static final l[] d = {g0.j(new y(g0.b(UploadModule.class), "okHttpClient", "getOkHttpClient()Lcom/finogeeks/lib/applet/externallib/okhttp3/OkHttpClient;"))};
private final lg0.h a;
private final ConcurrentHashMap<String, com.finogeeks.lib.applet.f.c.e> b;
private final Host c;
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;
public b(ICallback iCallback, String str) {
this.b = iCallback;
this.c = str;
}
@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;
}
UploadModule uploadModule = UploadModule.this;
if (map == null) {
map = k0.h();
}
uploadModule.a(i, str, map, this.c, this.b);
}
}
@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/UploadModule$delegateUploadFile$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() {
UploadModule.this.c.sendToServiceJSBridge("onTaskProgressUpdate", CommonKt.getGSon().toJson(this.b), 0, null);
}
}
public c() {
}
@Override
public void dispatchProgress(Map<String, ? extends Object> progressInfo) {
n.j(progressInfo, "progressInfo");
((BaseApi) UploadModule.this).handler.post(new a(progressInfo));
}
}
public static final class d implements Runnable {
final int b;
final String c;
final JSONObject d;
final JSONArray e;
public d(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()");
UploadModule.this.c.sendToServiceJSBridge("onTaskHeadersReceived", jSONObject, 0, null);
}
}
public static final class e implements Runnable {
final ICallback a;
final JSONObject b;
public e(ICallback iCallback, JSONObject jSONObject) {
this.a = iCallback;
this.b = jSONObject;
}
@Override
public final void run() {
this.a.onSuccess(this.b);
}
}
public static final class f implements Runnable {
final ICallback a;
public f(ICallback iCallback) {
this.a = iCallback;
}
@Override
public final void run() {
this.a.onFail();
}
}
@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/UploadModule$invoke$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 g implements com.finogeeks.lib.applet.f.c.f {
final ICallback b;
final String c;
final String d;
final String e;
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(g.this.b, "uploadFile:fail upload fail:");
} else if (this.c.b()) {
CallbackHandlerKt.fail(g.this.b, "abort");
} else {
IOException iOException = this.b;
if (iOException instanceof SocketTimeoutException) {
CallbackHandlerKt.fail(g.this.b, "fail:time out");
} else if (iOException instanceof SSLPeerUnverifiedException) {
g gVar = g.this;
gVar.b.onFail(CallbackHandlerKt.apiFail(gVar.c, iOException));
} else {
ICallback iCallback = g.this.b;
String message = iOException.getMessage();
if (message == null) {
message = "";
}
CallbackHandlerKt.fail(iCallback, message);
}
}
FLog.e$default("UploadModule", "upload onFailure : " + this.b.getLocalizedMessage(), null, 4, null);
}
}
public g(ICallback iCallback, String str, String str2, String str3) {
this.b = iCallback;
this.c = str;
this.d = str2;
this.e = str3;
}
@Override
public void onFailure(com.finogeeks.lib.applet.f.c.e eVar, IOException iOException) {
n.j(eVar, "call");
n.j(iOException, "e");
((BaseApi) UploadModule.this).handler.post(new a(iOException, eVar));
UploadModule.this.b.remove(this.d);
}
@Override
public void onResponse(com.finogeeks.lib.applet.f.c.e eVar, c0 c0Var) {
n.j(eVar, "call");
n.j(c0Var, "response");
int d = c0Var.d();
d0 a2 = c0Var.a();
String r = a2 != null ? a2.r() : null;
NetWorkConfig netWorkConfig = NetWorkConfig.a;
s q = c0Var.q();
n.e(q, "response.headers()");
UploadModule.this.a(d, r, netWorkConfig.a(q), this.e, this.b);
UploadModule.this.b.remove(this.d);
}
}
public static final class h implements u {
final String a;
public h(String str) {
this.a = str;
}
@Override
public final c0 a(u.a aVar) {
return aVar.a(aVar.a().f().b("Cookie", this.a).a());
}
}
@Metadata(d1 = {"\u0000\u001f\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\t\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\t*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J'\u0010\b\u001a\u00020\u00072\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0004\u001a\u00020\u00022\u0006\u0010\u0006\u001a\u00020\u0005H\u0016¢\u0006\u0004\b\b\u0010\tR\"\u0010\n\u001a\u00020\u00028\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\b\n\u0010\u000b\u001a\u0004\b\f\u0010\r\"\u0004\b\u000e\u0010\u000f¨\u0006\u0010"}, d2 = {"com/finogeeks/lib/applet/api/network/UploadModule$invoke$request$1", "Lcom/finogeeks/lib/applet/utils/ProgressRequestListener;", "", "bytesWritten", "contentLength", "", "done", "Llg0/e0;", "onRequestProgress", "(JJZ)V", "lastNotify", "J", "getLastNotify", "()J", "setLastNotify", "(J)V", "finapplet_release"}, k = 1, mv = {1, 4, 0})
public static final class i implements q0 {
private long a;
final String c;
public static final class a implements Runnable {
final Map b;
public a(Map map) {
this.b = map;
}
@Override
public final void run() {
UploadModule.this.c.sendToServiceJSBridge("onTaskProgressUpdate", CommonKt.getGSon().toJson(this.b), 0, null);
}
}
public i(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 (UploadModule.this.b.containsKey(this.c)) {
Map l = k0.l(new Pair[]{lg0.s.a("taskId", this.c)});
l.put("progress", Long.valueOf((100 * j) / j2));
l.put("totalBytesSent", Long.valueOf(j));
l.put("totalBytesExpectedToSend", Long.valueOf(j2));
((BaseApi) UploadModule.this).handler.post(new a(l));
}
}
}
}
public static final class j extends p implements ah0.a<x> {
public j() {
super(0);
}
public final x m149invoke() {
FinAppConfig finAppConfig = UploadModule.this.c.getFinAppConfig();
x.b t = UploadModule.this.c.r().getOkHttpUtil().b().t();
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
x.b b = t.a(60000L, timeUnit).c(60000L, timeUnit).d(60000L, timeUnit).b(new com.finogeeks.lib.applet.debugger.b());
n.e(b, "host.finContext.okHttpUt…ptor(StethoInterceptor())");
x.b a = l0.a(b, finAppConfig, NetWorkAPI.UploadFile);
if (finAppConfig.isIgnoreWebviewCertAuth()) {
r.a(a);
}
return a.a();
}
}
static {
new a(null);
}
public UploadModule(Context context, Host host) {
super(context);
n.j(context, "context");
n.j(host, "host");
this.c = host;
this.a = lg0.i.a(new j());
this.b = new ConcurrentHashMap<>();
}
private final x a(long j2) {
if (j2 <= 0 || j2 == 60000) {
x b2 = b();
n.e(b2, "okHttpClient");
return b2;
}
x.b t = b().t();
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
x a2 = t.a(j2, timeUnit).c(j2, timeUnit).d(j2, timeUnit).a();
n.e(a2, "okHttpClient.newBuilder(…nit.MILLISECONDS).build()");
return a2;
}
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, "uploadFile") && a2 != null && a2.isAPIDelegated(IAppletNetWorkRequestHandler.DelegateNetWorkAPI.UploadFile)) {
return a2;
}
return null;
}
public final void a(int i2, String str, Map<String, ? extends List<String>> map, String str2, ICallback iCallback) {
UploadModule uploadModule;
JSONObject b2;
JSONArray a2;
try {
com.finogeeks.lib.applet.api.network.i a3 = NetWorkConfig.a.a(map);
b2 = a3.b();
a2 = a3.a();
uploadModule = this;
} catch (JSONException unused) {
uploadModule = this;
}
try {
this.handler.post(uploadModule.new d(i2, str2, b2, a2));
JSONObject put = new JSONObject().put("header", b2).put("cookies", a2).put("statusCode", i2);
if (str == null) {
str = "";
}
uploadModule.handler.post(new e(iCallback, put.put("data", str)));
} catch (JSONException unused2) {
FLog.e$default("UploadModule", "uploadFile assemble result exception!", null, 4, null);
uploadModule.handler.post(new f(iCallback));
}
}
private final void a(JSONObject jSONObject, String str, IAppletNetWorkRequestHandler iAppletNetWorkRequestHandler, FinAppInfo finAppInfo, String str2, ICallback iCallback) {
jSONObject.put(ImageEditeActivity.EXTRA_FILE_PATH, str);
iAppletNetWorkRequestHandler.getUploadFileResult(finAppInfo, jSONObject, new b(iCallback, str2), new c());
}
private final x b() {
lg0.h hVar = this.a;
l lVar = d[0];
return (x) hVar.getValue();
}
private final String b(String str) {
String str2;
if (t.L(str, FinFileResourceUtil.SCHEME, false, 2, (Object) null)) {
AbsAppletDirProvider.Companion companion = AbsAppletDirProvider.INSTANCE;
Context context = getContext();
n.e(context, "context");
str2 = companion.convertFinFilePath(context, this.c.getAppConfig(), str);
} else if (t.L(str, "file:", false, 2, (Object) null)) {
if (str == null) {
throw new lg0.t("null cannot be cast to non-null type java.lang.String");
}
str2 = str.substring(5);
n.e(str2, "(this as java.lang.String).substring(startIndex)");
} else if (com.finogeeks.lib.applet.m.a.a.a(this.c.getAppId())) {
File c2 = b1.c(this.c, str);
n.e(c2, "StreamLoadUtil.getStream…etResPath(host, filePath)");
str2 = c2.getAbsolutePath();
} else {
str2 = this.c.getAppConfig().getMiniAppSourcePath(getContext()) + str;
}
n.e(str2, "realFilePath");
return str2;
}
public final void a(String str) {
n.j(str, "taskId");
com.finogeeks.lib.applet.f.c.e eVar = this.b.get(str);
if (eVar != null) {
eVar.cancel();
}
this.b.remove(str);
}
@Override
public String[] apis() {
return new String[]{"uploadFile"};
}
@Override
public void invoke(String event, JSONObject param, ICallback callback) {
n.j(event, FinFileResourceUtil.KEY_EVENT);
n.j(param, "param");
n.j(callback, "callback");
FLog.d$default("UploadModule", "invoke " + param, null, 4, null);
String optString = param.optString(ImageEditeActivity.EXTRA_FILE_PATH);
String optString2 = param.optString("taskId");
String optString3 = param.optString("name");
if (TextUtils.isEmpty(optString) || TextUtils.isEmpty(optString3)) {
callback.onFail();
return;
}
n.e(optString, ImageEditeActivity.EXTRA_FILE_PATH);
String b2 = b(optString);
FinAppConfig finAppConfig = this.c.getFinAppConfig();
FinAppInfo b3 = this.c.getB();
IAppletNetWorkRequestHandler a2 = a(event, finAppConfig);
if (a2 != null) {
a(param, b2, a2, b3, optString2, callback);
return;
}
String optString4 = param.optString("url");
DomainChecker domainChecker = this.c.r().getDomainChecker();
if (domainChecker == null) {
callback.onFail();
return;
}
if (optString4 == null || optString4.length() == 0) {
CallbackHandlerKt.fail(callback, "url is null or nil");
return;
}
if (!URLUtil.isValidUrl(optString4)) {
callback.onFail(CallbackHandlerKt.apiFail(event, "Not a web url(" + optString4 + ')'));
return;
}
com.finogeeks.lib.applet.i.domain.b e2 = domainChecker.e(optString4);
if (!e2.b()) {
CallbackHandlerKt.illegalDomain(callback, event, e2);
return;
}
JSONObject optJSONObject = param.optJSONObject("header");
JSONObject optJSONObject2 = param.optJSONObject("formData");
long optLong = param.optLong("timeout");
OkHttpUtil.a aVar = OkHttpUtil.d;
Map<String, String> a3 = aVar.a(optJSONObject2);
Map l = k0.l(new Pair[]{lg0.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(aVar.a(optJSONObject));
String a4 = RefererUtil.a(b3);
if (!m.a(l, "Referer") && a4.length() > 0) {
l.put("Referer", a4);
}
s a5 = s.a((Map<String, String>) l);
File file = new File(b2);
String guessContentTypeFromName = URLConnection.guessContentTypeFromName(b2);
if (guessContentTypeFromName == null) {
guessContentTypeFromName = "application/octet-stream";
}
w.a aVar2 = new w.a();
aVar2.a(w.f);
for (Map.Entry<String, String> entry : a3.entrySet()) {
aVar2.a(entry.getKey(), entry.getValue());
}
aVar2.a(optString3, file.getName(), b0.a(v.b(guessContentTypeFromName), file));
a0.a b4 = new a0.a().a(a5).b(optString4);
w a6 = aVar2.a();
n.e(a6, "bodyBuilder.build()");
a0 a7 = b4.b(new ProgressRequestBody(a6, new i(optString2))).a();
x a8 = a(optLong);
String a9 = a5.a("Cookie");
if (a9 != null && a9.length() != 0) {
a8 = a8.t().b(new h(a9)).a();
}
com.finogeeks.lib.applet.f.c.e a10 = a8.a(a7);
String valueOf = (optString2 == null || optString2.length() == 0) ? String.valueOf(System.currentTimeMillis()) : optString2;
ConcurrentHashMap<String, com.finogeeks.lib.applet.f.c.e> concurrentHashMap = this.b;
n.e(a10, "call");
concurrentHashMap.put(valueOf, a10);
a10.a(new g(callback, event, valueOf, optString2));
}
@Override
public void onDestroy() {
Collection<com.finogeeks.lib.applet.f.c.e> values = this.b.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.b.clear();
}
}