导航菜单

页面标题

页面副标题

万能钥匙 v1.1.23 - WebViewEngine.java 源代码

正在查看: 万能钥匙 v1.1.23 应用的 WebViewEngine.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.finogeeks.lib.applet.service;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.webkit.ConsoleMessage;
import android.webkit.ValueCallback;
import android.webkit.WebResourceResponse;
import androidx.fragment.app.FragmentActivity;
import com.finogeeks.lib.applet.client.FinAppConfig;
import com.finogeeks.lib.applet.debugger.client.RemoteDebugManager;
import com.finogeeks.lib.applet.i.ext.PackageManager;
import com.finogeeks.lib.applet.main.MeasureManager;
import com.finogeeks.lib.applet.main.host.AppHost;
import com.finogeeks.lib.applet.model.DebugInfo;
import com.finogeeks.lib.applet.modules.log.FLog;
import com.finogeeks.lib.applet.page.view.webview.FinWebView;
import com.finogeeks.lib.applet.rest.model.Package;
import com.finogeeks.lib.applet.utils.FinFileResourceUtil;
import com.finogeeks.lib.applet.utils.a1;
import com.finogeeks.lib.applet.utils.b1;
import com.finogeeks.lib.applet.utils.r;
import com.finogeeks.lib.applet.webview.IWebView;
import com.finogeeks.lib.applet.webview.WebChromeClient;
import com.finogeeks.lib.applet.webview.WebViewClient;
import hh0.l;
import java.io.File;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import kotlin.Metadata;
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.q;
import mg0.x;
import org.json.JSONArray;
import org.json.JSONObject;
import tj0.t;
import tj0.u;

@Metadata(d1 = {"\u0000X\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0010 \n\u0002\b\r\n\u0002\u0018\u0002\n\u0002\b\u0017\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u000b\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0007\u0018\u00002\u00020\u00012\u00020\u0002:\u0002PQB\u000f\u0012\u0006\u0010\u0004\u001a\u00020\u0003¢\u0006\u0004\b\u0005\u0010\u0006J)\u0010\f\u001a\u00020\u000b2\u0006\u0010\b\u001a\u00020\u00072\u0010\u0010\n\u001a\f\u0012\u0006\u0012\u0004\u0018\u00010\u0007\u0018\u00010\tH\u0016¢\u0006\u0004\b\f\u0010\rJ\u000f\u0010\u000e\u001a\u00020\u000bH\u0016¢\u0006\u0004\b\u000e\u0010\u000fJ\u0019\u0010\u0011\u001a\u00020\u000b2\b\u0010\u0010\u001a\u0004\u0018\u00010\u0007H\u0002¢\u0006\u0004\b\u0011\u0010\u0012J\u000f\u0010\u0013\u001a\u00020\u000bH\u0002¢\u0006\u0004\b\u0013\u0010\u000fJ-\u0010\u0016\u001a\u00020\u00072\f\u0010\u0015\u001a\b\u0012\u0004\u0012\u00020\u00070\u00142\u000e\u0010\n\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00070\tH\u0002¢\u0006\u0004\b\u0016\u0010\u0017J-\u0010\u0018\u001a\u00020\u000b2\f\u0010\u0015\u001a\b\u0012\u0004\u0012\u00020\u00070\u00142\u000e\u0010\n\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00070\tH\u0002¢\u0006\u0004\b\u0018\u0010\u0019J\u0017\u0010\u001b\u001a\u00020\u000b2\u0006\u0010\u001a\u001a\u00020\u0007H\u0002¢\u0006\u0004\b\u001b\u0010\u0012J\u000f\u0010\u001c\u001a\u00020\u0007H\u0016¢\u0006\u0004\b\u001c\u0010\u001dJ\u000f\u0010\u001e\u001a\u00020\u000bH\u0016¢\u0006\u0004\b\u001e\u0010\u000fJ\u0017\u0010 \u001a\u00020\u00072\u0006\u0010\u001f\u001a\u00020\u0007H\u0002¢\u0006\u0004\b \u0010!J\u001d\u0010$\u001a\u00020\u000b2\f\u0010#\u001a\b\u0012\u0004\u0012\u00020\"0\u0014H\u0016¢\u0006\u0004\b$\u0010%J5\u0010'\u001a\u00020\u000b2\f\u0010\u0015\u001a\b\u0012\u0004\u0012\u00020\u00070\u00142\u0006\u0010&\u001a\u00020\u00072\u000e\u0010\n\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00070\tH\u0002¢\u0006\u0004\b'\u0010(J+\u0010,\u001a\u00020\u000b2\b\u0010)\u001a\u0004\u0018\u00010\u00072\b\u0010*\u001a\u0004\u0018\u00010\u00072\u0006\u0010+\u001a\u00020\u0007H\u0016¢\u0006\u0004\b,\u0010-J\u000f\u0010.\u001a\u00020\u000bH\u0016¢\u0006\u0004\b.\u0010\u000fJ\u0019\u00100\u001a\u0004\u0018\u00010\u00072\u0006\u0010/\u001a\u00020\u0007H\u0016¢\u0006\u0004\b0\u0010!J-\u00102\u001a\u00020\u000b2\f\u00101\u001a\b\u0012\u0004\u0012\u00020\"0\u00142\u000e\u0010\n\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00070\tH\u0016¢\u0006\u0004\b2\u0010\u0019J\u000f\u00103\u001a\u00020\u000bH\u0016¢\u0006\u0004\b3\u0010\u000fJ\u000f\u00104\u001a\u00020\u000bH\u0016¢\u0006\u0004\b4\u0010\u000fJ\u0019\u00105\u001a\u00020\u000b2\b\u0010\u0010\u001a\u0004\u0018\u00010\u0007H\u0002¢\u0006\u0004\b5\u0010\u0012J\r\u00106\u001a\u00020\u000b¢\u0006\u0004\b6\u0010\u000fR\u001a\u00107\u001a\u00020\u00078\u0016X\u0096D¢\u0006\f\n\u0004\b7\u00108\u001a\u0004\b9\u0010\u001dR7\u0010A\u001a\u001e\u0012\u0004\u0012\u00020\u0007\u0012\u0004\u0012\u00020;0:j\u000e\u0012\u0004\u0012\u00020\u0007\u0012\u0004\u0012\u00020;`<8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b=\u0010>\u001a\u0004\b?\u0010@R\u0014\u0010C\u001a\u00020B8BX\u0082\u0004¢\u0006\u0006\u001a\u0004\bC\u0010DR7\u0010G\u001a\u001e\u0012\u0004\u0012\u00020\u0007\u0012\u0004\u0012\u00020;0:j\u000e\u0012\u0004\u0012\u00020\u0007\u0012\u0004\u0012\u00020;`<8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\bE\u0010>\u001a\u0004\bF\u0010@R\u001b\u0010J\u001a\u00020\u00078BX\u0082\u0084\u0002¢\u0006\f\n\u0004\bH\u0010>\u001a\u0004\bI\u0010\u001dR\u001b\u0010O\u001a\u00020K8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\bL\u0010>\u001a\u0004\bM\u0010N¨\u0006R"}, d2 = {"Lcom/finogeeks/lib/applet/service/WebViewEngine;", "Lcom/finogeeks/lib/applet/service/AbsJSEngine;", "Lcom/finogeeks/lib/applet/service/IWebViewEngine;", "Lcom/finogeeks/lib/applet/service/AppService;", "appService", "<init>", "(Lcom/finogeeks/lib/applet/service/AppService;)V", "", "script", "Landroid/webkit/ValueCallback;", "valueCallback", "Llg0/e0;", "executeJavaScript", "(Ljava/lang/String;Landroid/webkit/ValueCallback;)V", "destroy", "()V", "paramsString", "checkInjectHtmlRecords", "(Ljava/lang/String;)V", "checkPendingInjectPackageJsRecords", "", "packageJss", "createInjectHtmlRecord", "(Ljava/util/List;Landroid/webkit/ValueCallback;)Ljava/lang/String;", "createPendingInjectPackageJsRecord", "(Ljava/util/List;Landroid/webkit/ValueCallback;)V", "serviceHtmlFilePath", "generateServiceHtmlByServiceJs", "getEngineId", "()Ljava/lang/String;", "init", "html", "injectJSToHTML", "(Ljava/lang/String;)Ljava/lang/String;", "Lcom/finogeeks/lib/applet/rest/model/Package;", "result", "injectPackageJSs", "(Ljava/util/List;)V", "js", "injectPackagesJs", "(Ljava/util/List;Ljava/lang/String;Landroid/webkit/ValueCallback;)V", FinFileResourceUtil.KEY_EVENT, "params", "callbackId", "invoke", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", "loadGameService", "path", "loadJSFile", "packages", "loadPackageJS", "loadSubpackagesService", "loadWholePackageService", "onInjectHtmlCallback", "setWebViewBackgroundTransparent", "bridgeTag", "Ljava/lang/String;", "getBridgeTag", "Ljava/util/HashMap;", "Lcom/finogeeks/lib/applet/service/ServiceInjectPackageJSRecord;", "Lkotlin/collections/HashMap;", "injectHtmlRecords$delegate", "Llg0/h;", "getInjectHtmlRecords", "()Ljava/util/HashMap;", "injectHtmlRecords", "", "isSubpackagesLoad", "()Z", "pendingInjectPackageJsRecords$delegate", "getPendingInjectPackageJsRecords", "pendingInjectPackageJsRecords", "serviceHtmlContent$delegate", "getServiceHtmlContent", "serviceHtmlContent", "Lcom/finogeeks/lib/applet/service/WebViewEngine$ServiceWebView;", "serviceWebView$delegate", "getServiceWebView", "()Lcom/finogeeks/lib/applet/service/WebViewEngine$ServiceWebView;", "serviceWebView", "Companion", "ServiceWebView", "finapplet_release"}, k = 1, mv = {1, 4, 0})
public final class WebViewEngine extends AbsJSEngine implements com.finogeeks.lib.applet.service.c {
    static final l[] j = {g0.j(new y(g0.b(WebViewEngine.class), "serviceWebView", "getServiceWebView()Lcom/finogeeks/lib/applet/service/WebViewEngine$ServiceWebView;")), g0.j(new y(g0.b(WebViewEngine.class), "serviceHtmlContent", "getServiceHtmlContent()Ljava/lang/String;")), g0.j(new y(g0.b(WebViewEngine.class), "injectHtmlRecords", "getInjectHtmlRecords()Ljava/util/HashMap;")), g0.j(new y(g0.b(WebViewEngine.class), "pendingInjectPackageJsRecords", "getPendingInjectPackageJsRecords()Ljava/util/HashMap;"))};
    private final lg0.h e;
    private final lg0.h f;
    private final lg0.h g;
    private final lg0.h h;
    private final String i;

    public static final class a {
        private a() {
        }

        public a(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }
    }

    public static final class b extends FinWebView {
        private HashMap a;

        public b(Context context, FinAppConfig finAppConfig, Boolean bool) {
            super(context, finAppConfig, false, bool);
            n.j(context, "context");
            n.j(finAppConfig, "finAppConfig");
        }

        @Override
        public void _$_clearFindViewByIdCache() {
            HashMap hashMap = this.a;
            if (hashMap != null) {
                hashMap.clear();
            }
        }

        @Override
        public View _$_findCachedViewById(int i) {
            if (this.a == null) {
                this.a = new HashMap();
            }
            View view = (View) this.a.get(Integer.valueOf(i));
            if (view != null) {
                return view;
            }
            View findViewById = findViewById(i);
            this.a.put(Integer.valueOf(i), findViewById);
            return findViewById;
        }

        @Override
        public String tag() {
            return "ServiceWebView";
        }
    }

    public static final class c extends WebChromeClient {
        final boolean b;

        public c(boolean z10) {
            this.b = z10;
        }

        @Override
        public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
            n.j(consoleMessage, "consoleMessage");
            ConsoleMessage.MessageLevel messageLevel = consoleMessage.messageLevel();
            if (messageLevel == ConsoleMessage.MessageLevel.ERROR) {
                FLog.d$default("WebViewEngine", "onConsoleMessage " + consoleMessage.lineNumber() + ", " + messageLevel + ", " + consoleMessage.message() + ", " + consoleMessage.sourceId(), null, 4, null);
            }
            return super.onConsoleMessage(consoleMessage);
        }

        @Override
        public void onProgressChanged(IWebView iWebView, int i) {
            n.j(iWebView, "webView");
            FLog.d$default("WebViewEngine", "onProgressChanged " + i, null, 4, null);
        }

        @Override
        public void onReceivedTitle(IWebView iWebView, String str) {
            n.j(iWebView, "webView");
            if (this.b) {
                String p = WebViewEngine.this.p();
                if (n.d(str, p)) {
                    return;
                }
                iWebView.executeJavaScript("document.title = '" + p + '\'', null);
            }
        }
    }

    public static final class d extends WebViewClient {
        public d() {
        }

        @Override
        public void onPageFinished(IWebView iWebView, String str) {
            n.j(iWebView, "webView");
            if (!WebViewEngine.this.w() || WebViewEngine.this.i().isGame()) {
                return;
            }
            WebViewEngine.this.o();
        }

        @Override
        public WebResourceResponse shouldInterceptRequest(IWebView iWebView, String str) {
            n.j(iWebView, "webView");
            FLog.d$default("WebViewEngine", "shouldInterceptRequest " + str, null, 4, null);
            WebResourceResponse finFileResource = FinFileResourceUtil.getFinFileResource(WebViewEngine.this.getA(), str);
            if (finFileResource != null) {
                return finFileResource;
            }
            if (str != null) {
                File frameworkDir = WebViewEngine.this.f().getFrameworkDir(WebViewEngine.this.d());
                n.e(frameworkDir, "appConfig.getFrameworkDir(activity)");
                String absolutePath = frameworkDir.getAbsolutePath();
                n.e(absolutePath, "appConfig.getFrameworkDir(activity).absolutePath");
                String miniAppSourcePath = WebViewEngine.this.f().getMiniAppSourcePath(WebViewEngine.this.d());
                n.e(miniAppSourcePath, "appConfig.getMiniAppSourcePath(activity)");
                boolean a = b1.a(WebViewEngine.this.i(), (Context) WebViewEngine.this.d());
                if (u.Q(str, absolutePath, false, 2, (Object) null) && !t.u(str, "service.html", false, 2, (Object) null) && a) {
                    File streamLoadFrameworkFile = WebViewEngine.this.f().getStreamLoadFrameworkFile(WebViewEngine.this.d());
                    n.e(streamLoadFrameworkFile, "appConfig.getStreamLoadFrameworkFile(activity)");
                    return (!streamLoadFrameworkFile.exists() || streamLoadFrameworkFile.length() <= 0) ? super.shouldInterceptRequest(iWebView, str) : b1.b((Context) WebViewEngine.this.d(), str, WebViewEngine.this.f());
                }
                if (u.Q(str, miniAppSourcePath, false, 2, (Object) null) && com.finogeeks.lib.applet.m.a.a.a(WebViewEngine.this.f().getAppId())) {
                    return b1.a(WebViewEngine.this.getA(), str, WebViewEngine.this.f());
                }
                super.shouldInterceptRequest(iWebView, str);
            }
            return super.shouldInterceptRequest(iWebView, str);
        }
    }

    public static final class e extends p implements ah0.a<HashMap<String, com.finogeeks.lib.applet.service.e>> {
        public static final e a = new e();

        public e() {
            super(0);
        }

        public final HashMap<String, com.finogeeks.lib.applet.service.e> invoke() {
            return new HashMap<>();
        }
    }

    public static final class f<T> implements ValueCallback<String> {
        public static final f a = new f();

        @Override
        public final void onReceiveValue(String str) {
            FLog.d$default("WebViewEngine", "injectPackageJss value: " + str, null, 4, null);
        }
    }

    @Metadata(d1 = {"\u0000\u000e\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\u0010\u0005\u001a\u00020\u00022\b\u0010\u0001\u001a\u0004\u0018\u00010\u0000H\n¢\u0006\u0004\b\u0003\u0010\u0004"}, d2 = {"", "value", "Llg0/e0;", "onReceiveValue", "(Ljava/lang/String;)V", "<anonymous>"}, k = 3, mv = {1, 4, 0})
    public static final class g<T> implements ValueCallback<String> {
        final String b;
        final List c;
        final ValueCallback d;

        public static final class a implements Runnable {
            public a() {
            }

            @Override
            public final void run() {
                WebViewEngine.this.m().c(g.this.c);
                WebViewEngine.this.r();
                g.this.d.onReceiveValue(null);
            }
        }

        public g(String str, List list, ValueCallback valueCallback) {
            this.b = str;
            this.c = list;
            this.d = valueCallback;
        }

        @Override
        public final void onReceiveValue(String str) {
            String t0;
            String str2 = null;
            FLog.d$default("WebViewEngine", "injectPackagesJs " + this.b + ", " + str, null, 4, null);
            if (str != null && (t0 = u.t0(str, "\"")) != null) {
                str2 = u.u0(t0, "\"");
            }
            if (str2 == null || t.y(str2)) {
                WebViewEngine.this.v().postDelayed(new a(), 200L);
            }
        }
    }

    public static final class h extends p implements ah0.l<String, String> {
        final String a;

        public h(String str) {
            super(1);
            this.a = str;
        }

        public final String invoke(String str) {
            n.j(str, "packageJs");
            return "<script charset=\"utf-8\" src=\"" + this.a + '/' + str + "\" type=\"text/javascript\"></script>\n";
        }
    }

    public static final class i extends p implements ah0.a<HashMap<String, com.finogeeks.lib.applet.service.e>> {
        public static final i a = new i();

        public i() {
            super(0);
        }

        public final HashMap<String, com.finogeeks.lib.applet.service.e> invoke() {
            return new HashMap<>();
        }
    }

    public static final class j extends p implements ah0.a<String> {
        public static final j a = new j();

        public j() {
            super(0);
        }

        public final String invoke() {
            return "<!DOCTYPE html>\n<html>\n<head>\n  <meta name=\"content-type\" content=\"text/html; charset=utf-8\">\n  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n  <script charset=\"utf-8\" src=\"../script/service.js\" type=\"text/javascript\"></script>\n</head>\n<body>\n</body>\n</html>";
        }
    }

    public static final class k extends p implements ah0.a<b> {
        final AppService b;

        public k(AppService appService) {
            super(0);
            this.b = appService;
        }

        public final b m766invoke() {
            Context context = this.b.getContext();
            n.e(context, "appService.context");
            b bVar = new b(context, WebViewEngine.this.h(), WebViewEngine.this.i().isDisableTbs());
            bVar.setVisibility(8);
            return bVar;
        }
    }

    static {
        new a(null);
    }

    public WebViewEngine(AppService appService) {
        super(appService);
        n.j(appService, "appService");
        this.e = lg0.i.a(new k(appService));
        this.f = lg0.i.a(j.a);
        this.g = lg0.i.a(e.a);
        this.h = lg0.i.a(i.a);
        this.i = "WebViewEngine";
    }

    private final void a(List<String> list, String str, ValueCallback<String> valueCallback) {
        FLog.d$default("WebViewEngine", "injectPackagesJs " + str, null, 4, null);
        v().executeJavaScript(str, new g(str, list, valueCallback));
    }

    private final String b(List<String> list, ValueCallback<String> valueCallback) {
        String uuid = UUID.randomUUID().toString();
        n.e(uuid, "UUID.randomUUID().toString()");
        com.finogeeks.lib.applet.service.e eVar = new com.finogeeks.lib.applet.service.e(uuid, list, valueCallback);
        s().put(uuid, eVar);
        FLog.d$default("WebViewEngine", "createInjectHtmlRecord: " + eVar, null, 4, null);
        return uuid;
    }

    private final void b(String str) {
        JSONObject jSONObject;
        String optString;
        FLog.d$default("WebViewEngine", "checkInjectHtmlRecords paramsString: " + str, null, 4, null);
        if (str == null || t.y(str)) {
            return;
        }
        try {
            jSONObject = new JSONObject(str);
        } catch (Exception e2) {
            e2.printStackTrace();
            jSONObject = null;
        }
        if (jSONObject == null || (optString = jSONObject.optString("callbackId")) == null || t.y(optString)) {
            return;
        }
        FLog.d$default("WebViewEngine", "checkInjectHtmlRecords injectHtmlCallbacks: " + s(), null, 4, null);
        com.finogeeks.lib.applet.service.e eVar = s().get(optString);
        FLog.d$default("WebViewEngine", "checkInjectHtmlRecords serviceInjectPackageJsRecord: " + eVar, null, 4, null);
        if (eVar == null) {
            return;
        }
        m().c(eVar.a());
        eVar.b().onReceiveValue(optString);
        s().remove(optString);
    }

    private final void c(String str) {
        yg0.l.o(new File(str), u(), (Charset) null, 2, (Object) null);
    }

    private final void c(List<String> list, ValueCallback<String> valueCallback) {
        String uuid = UUID.randomUUID().toString();
        n.e(uuid, "UUID.randomUUID().toString()");
        com.finogeeks.lib.applet.service.e eVar = new com.finogeeks.lib.applet.service.e(uuid, list, valueCallback);
        t().put(uuid, eVar);
        FLog.d$default("WebViewEngine", "createPendingInjectPackageJsRecord: " + eVar, null, 4, null);
    }

    private final String d(String str) {
        String str2;
        boolean a2;
        JSONObject c2;
        FragmentActivity d2;
        FinAppConfig.UIConfig uiConfig;
        MeasureManager x;
        try {
            a2 = com.finogeeks.lib.applet.i.a.c.a(d(), getA().getFinAppConfig(), i());
            c2 = (!(getA() instanceof AppHost) || (x = ((AppHost) getA()).getX()) == null) ? null : x.c();
            d2 = d();
            uiConfig = h().getUiConfig();
            n.e(uiConfig, "finAppConfig.uiConfig");
            str2 = str;
        } catch (Exception e2) {
            e = e2;
            str2 = str;
        }
        try {
            return com.finogeeks.lib.applet.service.d.a(d2, str2, uiConfig.isUseNativeLiveComponent(), null, h().getPageCountLimit(), a2, k().getStartParams(), f(), c2, com.finogeeks.lib.applet.service.d.a(getA()), com.finogeeks.lib.applet.service.d.a(i()));
        } catch (Exception e3) {
            e = e3;
            FLog.e("WebViewEngine", "injectJSToHTML error", e);
            return str2;
        }
    }

    private final void e(String str) {
        FLog.d$default("WebViewEngine", "onInjectHtmlCallback " + str, null, 4, null);
        b(str);
        r();
    }

    public final void r() {
        FLog.d$default("WebViewEngine", "checkPendingInjectPackageJsRecords start: " + t(), null, 4, null);
        if (!t().isEmpty()) {
            Iterator<Map.Entry<String, com.finogeeks.lib.applet.service.e>> it = t().entrySet().iterator();
            while (it.hasNext()) {
                com.finogeeks.lib.applet.service.e value = it.next().getValue();
                if (m().a(value.a())) {
                    value.b().onReceiveValue(null);
                    it.remove();
                }
            }
        }
        FLog.d$default("WebViewEngine", "checkPendingInjectPackageJsRecords end: " + t(), null, 4, null);
    }

    private final HashMap<String, com.finogeeks.lib.applet.service.e> s() {
        lg0.h hVar = this.g;
        l lVar = j[2];
        return (HashMap) hVar.getValue();
    }

    private final HashMap<String, com.finogeeks.lib.applet.service.e> t() {
        lg0.h hVar = this.h;
        l lVar = j[3];
        return (HashMap) hVar.getValue();
    }

    private final String u() {
        lg0.h hVar = this.f;
        l lVar = j[1];
        return (String) hVar.getValue();
    }

    public final b v() {
        lg0.h hVar = this.e;
        l lVar = j[0];
        return (b) hVar.getValue();
    }

    public final boolean w() {
        return m().d();
    }

    @Override
    public String a(String str) {
        n.j(str, "path");
        String miniAppSourcePath = f().getMiniAppSourcePath(d());
        if (com.finogeeks.lib.applet.m.a.a.a(f().getAppId())) {
            byte[] a2 = b1.a(getA(), str, miniAppSourcePath);
            if (a2 != null) {
                return new String(a2, tj0.c.b);
            }
            return null;
        }
        File file = new File(miniAppSourcePath, str);
        if (file.exists()) {
            return r.e(file);
        }
        return null;
    }

    @Override
    public void a() {
        File parentFile;
        File h2 = a1.h(d(), i().getFinStoreConfig().getStoreName(), i().getFrameworkVersion());
        if (!h2.exists()) {
            n.e(h2, "serviceHtmlFile");
            File parentFile2 = h2.getParentFile();
            Boolean valueOf = parentFile2 != null ? Boolean.valueOf(parentFile2.exists()) : null;
            if (valueOf == null) {
                n.t();
            }
            if (!valueOf.booleanValue() && (parentFile = h2.getParentFile()) != null) {
                parentFile.mkdirs();
            }
            h2.createNewFile();
        }
        n.e(h2, "serviceHtmlFile");
        String absolutePath = h2.getAbsolutePath();
        n.e(absolutePath, "serviceHtmlFile.absolutePath");
        c(absolutePath);
        v().loadDataWithBaseURL(r.f(h2.getParentFile()) + File.separator, d(yg0.l.l(h2, (Charset) null, 1, (Object) null)), "text/html", "UTF-8", null);
    }

    @Override
    public void a(List<Package> list, ValueCallback<String> valueCallback) {
        List j2;
        String l;
        List<String> a2;
        n.j(list, "packages");
        n.j(valueCallback, "valueCallback");
        PackageManager m = m();
        File b2 = m.b();
        String f2 = r.f(b2);
        boolean isLazyLoading = i().isLazyLoading();
        int i2 = 10;
        ArrayList arrayList = new ArrayList(q.u(list, 10));
        for (Package r0 : list) {
            try {
                String a3 = com.finogeeks.lib.applet.m.a.a.a(f().getAppId()) ? PackageManager.i.a() : PackageManager.i.b(r0);
                if (com.finogeeks.lib.applet.m.a.a.a(f().getAppId())) {
                    byte[] a4 = com.finogeeks.lib.applet.m.a.a.a(com.finogeeks.lib.applet.m.a.a.b(b2.getAbsolutePath() + File.separator + r0.getName() + a1.a), a3);
                    n.e(a4, "byteContent");
                    l = new String(a4, tj0.c.b);
                } else {
                    l = yg0.l.l(new File(b2 + '/' + a3), (Charset) null, 1, (Object) null);
                }
                JSONObject jSONObject = new JSONObject(l);
                String str = isLazyLoading ? "lazyCodes" : "links";
                JSONArray optJSONArray = jSONObject.optJSONArray(str);
                if (optJSONArray == null || (a2 = com.finogeeks.lib.applet.modules.ext.p.a(optJSONArray)) == null) {
                    j2 = null;
                } else {
                    j2 = new ArrayList(q.u(a2, i2));
                    for (String str2 : a2) {
                        if (n.d(str2, "appservice.app.js")) {
                            str2 = PackageManager.i.a(r0);
                        }
                        j2.add(str2);
                    }
                }
                FLog.d$default("WebViewEngine", "loadPackageJs " + str + " : " + j2, null, 4, null);
                if (j2 == null) {
                    j2 = mg0.p.j();
                }
            } catch (Exception e2) {
                e2.printStackTrace();
                j2 = mg0.p.j();
            }
            arrayList.add(j2);
            i2 = 10;
        }
        List<String> w = q.w(arrayList);
        FLog.d$default("WebViewEngine", "loadPackageJs allPackageJss: " + w, null, 4, null);
        if (w.isEmpty()) {
            FLog.d$default("WebViewEngine", "loadPackageJs allPackageJss is empty", null, 4, null);
            valueCallback.onReceiveValue(null);
            return;
        }
        ArrayList arrayList2 = new ArrayList();
        for (Object obj : w) {
            if (!m.f((String) obj)) {
                arrayList2.add(obj);
            }
        }
        FLog.d$default("WebViewEngine", "loadPackageJs packageJss: " + arrayList2, null, 4, null);
        if (arrayList2.isEmpty()) {
            FLog.d$default("WebViewEngine", "loadPackageJs packageJss is empty", null, 4, null);
            if (!m.a(w)) {
                c(w, valueCallback);
                return;
            } else {
                FLog.d$default("WebViewEngine", "loadPackageJs all packages js is load completed", null, 4, null);
                valueCallback.onReceiveValue(null);
                return;
            }
        }
        m.b(arrayList2);
        String u0 = x.u0(arrayList2, "\n", (CharSequence) null, (CharSequence) null, 0, (CharSequence) null, new h(f2), 30, (Object) null);
        FLog.d$default("WebViewEngine", "loadPackageJs content: " + u0, null, 4, null);
        String jSONObject2 = new JSONObject().put("content", u0).toString();
        n.e(jSONObject2, "JSONObject().put(\"content\", content).toString()");
        a(arrayList2, "javascript:window.injectHtml(document.head, " + jSONObject2 + ", \"" + b(arrayList2, valueCallback) + "\")", valueCallback);
    }

    @Override
    public void b() {
        if (n.d(i().getAppType(), "remoteDebug")) {
            DebugInfo debugInfo = i().getDebugInfo();
            RemoteDebugManager.B.a((Activity) d(), getA(), debugInfo.getChannelId(), debugInfo.getUrl());
        }
        v().clearHistory();
        v().clearFormData();
        v().clearCache(true);
        boolean d2 = n.d(getA().getB().getAppType(), "remoteDebug");
        if (d2) {
            v().executeJavaScript("document.title = '" + p() + '\'', null);
        }
        v().setJSBridge(getA(), this);
        v().setWebChromeClient(new c(d2));
        v().setWebViewClient(new d());
        getC().addView(v(), -1, -1);
    }

    @Override
    public void b(String str, String str2, String str3) {
        n.j(str3, "callbackId");
        if (str != null && str.hashCode() == -1170219711 && str.equals("injectHtmlCallback")) {
            e(str2);
        } else {
            super.b(str, str2, str3);
        }
    }

    @Override
    public void c() {
        File file = new File(f().getMiniAppSourcePath(d()), "service.html");
        v().loadDataWithBaseURL(r.f(file.getParentFile()) + File.separator, d(yg0.l.l(file, (Charset) null, 1, (Object) null)), "text/html", "UTF-8", null);
    }

    @Override
    public void c(List<Package> list) {
        File file;
        Iterator it;
        List j2;
        JSONObject jSONObject;
        List<String> a2;
        n.j(list, "result");
        File b2 = m().b();
        String f2 = r.f(b2);
        ArrayList arrayList = new ArrayList();
        boolean isLazyLoading = i().isLazyLoading();
        String str = "";
        if (isLazyLoading) {
            if (!m().f("common.app.js")) {
                m().g("common.app.js");
                arrayList.add("common.app.js");
                str = "<script charset=\"utf-8\" src=\"" + f2 + "/common.app.js\" type=\"text/javascript\"></script>\n";
            }
        } else if (!m().f("pageframe.js")) {
            m().g("pageframe.js");
            arrayList.add("pageframe.js");
            str = "<script charset=\"utf-8\" src=\"" + f2 + "/pageframe.js\" type=\"text/javascript\"></script>\n";
        }
        ArrayList arrayList2 = new ArrayList(q.u(list, 10));
        Iterator it2 = list.iterator();
        while (it2.hasNext()) {
            Package r0 = (Package) it2.next();
            try {
                if (com.finogeeks.lib.applet.m.a.a.a(f().getAppId())) {
                    try {
                        it = it2;
                    } catch (Exception e2) {
                        e = e2;
                        it = it2;
                    }
                    try {
                        byte[] a3 = com.finogeeks.lib.applet.m.a.a.a(com.finogeeks.lib.applet.m.a.a.b(b2.getAbsolutePath() + File.separator + r0.getName() + a1.a), PackageManager.i.a());
                        n.e(a3, "bytes");
                        jSONObject = new JSONObject(new String(a3, tj0.c.b));
                    } catch (Exception e3) {
                        e = e3;
                        file = b2;
                        e.printStackTrace();
                        j2 = mg0.p.j();
                        arrayList2.add(j2);
                        it2 = it;
                        b2 = file;
                    }
                } else {
                    it = it2;
                    jSONObject = new JSONObject(yg0.l.l(new File(b2 + '/' + PackageManager.i.b(r0)), (Charset) null, 1, (Object) null));
                }
                String str2 = isLazyLoading ? "lazyCodes" : "links";
                JSONArray optJSONArray = jSONObject.optJSONArray(str2);
                if (optJSONArray == null || (a2 = com.finogeeks.lib.applet.modules.ext.p.a(optJSONArray)) == null) {
                    file = b2;
                    j2 = null;
                } else {
                    file = b2;
                    try {
                        j2 = new ArrayList(q.u(a2, 10));
                        for (String str3 : a2) {
                            if (n.d(str3, "appservice.app.js")) {
                                str3 = PackageManager.i.a(r0);
                            }
                            j2.add(str3);
                        }
                    } catch (Exception e4) {
                        e = e4;
                        e.printStackTrace();
                        j2 = mg0.p.j();
                        arrayList2.add(j2);
                        it2 = it;
                        b2 = file;
                    }
                }
                FLog.d$default("WebViewEngine", "loadPackageJs " + str2 + " : " + j2, null, 4, null);
                if (j2 == null) {
                    j2 = mg0.p.j();
                }
            } catch (Exception e5) {
                e = e5;
                file = b2;
                it = it2;
            }
            arrayList2.add(j2);
            it2 = it;
            b2 = file;
        }
        for (String str4 : q.w(arrayList2)) {
            if (!m().f(str4)) {
                m().g(str4);
                arrayList.add(str4);
                str = str + "<script charset=\"utf-8\" src=\"" + f2 + '/' + str4 + "\" type=\"text/javascript\"></script>\n";
            }
        }
        FLog.d$default("WebViewEngine", "injectPackageJss content: " + str, null, 4, null);
        if (t.y(str)) {
            return;
        }
        String jSONObject2 = new JSONObject().put("content", str).toString();
        n.e(jSONObject2, "JSONObject().put(\"content\", content).toString()");
        ValueCallback<String> valueCallback = f.a;
        a(arrayList, "javascript:window.injectHtml(document.head, " + jSONObject2 + ", \"" + b(arrayList, valueCallback) + "\")", valueCallback);
    }

    @Override
    public void destroy() {
        v().destroy();
    }

    @Override
    public void executeJavaScript(String script, ValueCallback<String> valueCallback) {
        n.j(script, "script");
        v().executeJavaScript(script, valueCallback);
    }

    @Override
    public String getN() {
        return this.i;
    }

    public String p() {
        return "webview:" + String.valueOf(v().getViewId());
    }

    public final void q() {
        v().setBackgroundColor(0);
    }
}