正在查看: 万能钥匙 v1.1.23 应用的 WebViewContainer.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 万能钥匙 v1.1.23 应用的 WebViewContainer.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.finogeeks.lib.applet.main.game;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.ValueCallback;
import android.webkit.WebResourceResponse;
import android.widget.FrameLayout;
import androidx.appcompat.app.AppCompatActivity;
import com.finogeeks.lib.applet.config.AppConfig;
import com.finogeeks.lib.applet.jsbridge.IJSExecutor;
import com.finogeeks.lib.applet.lifecycle.LifecycleObserverAdapter;
import com.finogeeks.lib.applet.main.FinAppHomeActivity;
import com.finogeeks.lib.applet.main.GameManager;
import com.finogeeks.lib.applet.main.MeasureManager;
import com.finogeeks.lib.applet.main.host.AppHost;
import com.finogeeks.lib.applet.model.Event;
import com.finogeeks.lib.applet.model.GameConfig;
import com.finogeeks.lib.applet.modules.common.CommonKt;
import com.finogeeks.lib.applet.modules.log.FLog;
import com.finogeeks.lib.applet.modules.request.BitmapCallback;
import com.finogeeks.lib.applet.modules.request.ImageLoader;
import com.finogeeks.lib.applet.utils.FinFileResourceUtil;
import com.finogeeks.lib.applet.utils.b1;
import com.finogeeks.lib.applet.utils.d1;
import com.finogeeks.lib.applet.utils.r;
import com.finogeeks.lib.applet.utils.x0;
import com.finogeeks.lib.applet.webview.IWebView;
import com.finogeeks.lib.applet.webview.WebViewClient;
import hh0.l;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.nio.charset.Charset;
import java.util.HashMap;
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 lg0.e0;
import lg0.h;
import lg0.i;
import org.json.JSONObject;
import tj0.t;
import tj0.u;
@Metadata(d1 = {"\u0000^\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\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\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u000f\n\u0002\b\u0003\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0007*\u0002$'\u0018\u00002\u00020\u0001:\u00015B\u001f\u0012\u0006\u0010\u0003\u001a\u00020\u0002\u0012\u0006\u0010\u0005\u001a\u00020\u0004\u0012\u0006\u0010\u0007\u001a\u00020\u0006¢\u0006\u0004\b\b\u0010\tJ)\u0010\u000f\u001a\u00020\u000e2\u0006\u0010\u000b\u001a\u00020\n2\u0010\u0010\r\u001a\f\u0012\u0006\u0012\u0004\u0018\u00010\n\u0018\u00010\fH\u0016¢\u0006\u0004\b\u000f\u0010\u0010J-\u0010\u0016\u001a\u00020\u000e2\u0006\u0010\u0012\u001a\u00020\u00112\u0014\u0010\u0015\u001a\u0010\u0012\u0006\u0012\u0004\u0018\u00010\u0014\u0012\u0004\u0012\u00020\u000e0\u0013H\u0016¢\u0006\u0004\b\u0016\u0010\u0017J\u000f\u0010\u0018\u001a\u00020\u000eH\u0002¢\u0006\u0004\b\u0018\u0010\u0019J\u000f\u0010\u001a\u001a\u00020\u000eH\u0002¢\u0006\u0004\b\u001a\u0010\u0019J\u000f\u0010\u001b\u001a\u00020\u0011H\u0002¢\u0006\u0004\b\u001b\u0010\u001cJ\u000f\u0010\u001d\u001a\u00020\u0011H\u0016¢\u0006\u0004\b\u001d\u0010\u001cJ\u000f\u0010\u001e\u001a\u00020\u000eH\u0016¢\u0006\u0004\b\u001e\u0010\u0019J\u000f\u0010\u001f\u001a\u00020\u000eH\u0016¢\u0006\u0004\b\u001f\u0010\u0019R\u0014\u0010\u0007\u001a\u00020\u00068\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0007\u0010 R\u0014\u0010\u0005\u001a\u00020\u00048\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0005\u0010!R\u0016\u0010\"\u001a\u00020\u00118\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\"\u0010#R\u0014\u0010%\u001a\u00020$8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b%\u0010&R\u0014\u0010(\u001a\u00020'8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b(\u0010)R\u001a\u0010+\u001a\u00020*8\u0016X\u0096\u0004¢\u0006\f\n\u0004\b+\u0010,\u001a\u0004\b-\u0010.R\u001b\u00104\u001a\u00020/8FX\u0086\u0084\u0002¢\u0006\f\n\u0004\b0\u00101\u001a\u0004\b2\u00103¨\u00066"}, d2 = {"Lcom/finogeeks/lib/applet/main/game/WebViewContainer;", "Lcom/finogeeks/lib/applet/main/game/AbsGameContainer;", "Lcom/finogeeks/lib/applet/main/FinAppHomeActivity;", "activity", "Lcom/finogeeks/lib/applet/main/host/AppHost;", "appHost", "Lcom/finogeeks/lib/applet/api/ApisManager;", "apisManager", "<init>", "(Lcom/finogeeks/lib/applet/main/FinAppHomeActivity;Lcom/finogeeks/lib/applet/main/host/AppHost;Lcom/finogeeks/lib/applet/api/ApisManager;)V", "", "script", "Landroid/webkit/ValueCallback;", "valueCallback", "Llg0/e0;", "executeJavaScript", "(Ljava/lang/String;Landroid/webkit/ValueCallback;)V", "", "full", "Lkotlin/Function1;", "Landroid/graphics/Bitmap;", "onGet", "getBitmap", "(ZLah0/l;)V", "initWebView", "()V", "injectGameJsWithHtml", "injectGameJson", "()Z", "isStartedUp", "onGameServiceReady", "startup", "Lcom/finogeeks/lib/applet/api/ApisManager;", "Lcom/finogeeks/lib/applet/main/host/AppHost;", "isGameLoaded", "Z", "com/finogeeks/lib/applet/main/game/WebViewContainer$jsBridge$1", "jsBridge", "Lcom/finogeeks/lib/applet/main/game/WebViewContainer$jsBridge$1;", "com/finogeeks/lib/applet/main/game/WebViewContainer$lifecycleObserver$1", "lifecycleObserver", "Lcom/finogeeks/lib/applet/main/game/WebViewContainer$lifecycleObserver$1;", "Landroid/view/ViewGroup;", "playground", "Landroid/view/ViewGroup;", "getPlayground", "()Landroid/view/ViewGroup;", "Lcom/finogeeks/lib/applet/page/view/webview/FinPageWebView;", "webView$delegate", "Llg0/h;", "getWebView", "()Lcom/finogeeks/lib/applet/page/view/webview/FinPageWebView;", "webView", "Companion", "finapplet_release"}, k = 1, mv = {1, 4, 0})
public final class WebViewContainer extends com.finogeeks.lib.applet.main.game.a {
static final l[] i = {g0.j(new y(g0.b(WebViewContainer.class), "webView", "getWebView()Lcom/finogeeks/lib/applet/page/view/webview/FinPageWebView;"))};
private final ViewGroup c;
private final h d;
private final d e;
private final e f;
private final AppHost g;
private final com.finogeeks.lib.applet.api.d h;
public static final class a {
private a() {
}
public a(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
public static final class b implements BitmapCallback {
final ah0.l a;
public b(ah0.l lVar) {
this.a = lVar;
}
@Override
public void onLoadSuccess(Bitmap bitmap) {
n.j(bitmap, "r");
this.a.invoke(bitmap);
}
@Override
public void onLoadFailure() {
this.a.invoke((Object) null);
}
}
public static final class c extends WebViewClient {
public c() {
}
private final WebResourceResponse a(File file) {
if (!file.exists() || !file.isFile()) {
FLog.e$default("WebViewContainer", "file is not exists:" + file.getAbsolutePath(), null, 4, null);
return null;
}
try {
WebResourceResponse webResourceResponse = new WebResourceResponse(r.g(file.getAbsolutePath()), "UTF-8", new FileInputStream(file));
HashMap hashMap = new HashMap();
hashMap.put("Access-Control-Allow-Origin", "*");
hashMap.put("Access-Control-Allow-Headers", "Content-Type");
hashMap.put("Cache-Control", "no-store, no-cache");
webResourceResponse.setResponseHeaders(hashMap);
return webResourceResponse;
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
}
}
@Override
public void onPageFinished(IWebView iWebView, String str) {
n.j(iWebView, "webView");
super.onPageFinished(iWebView, str);
WebViewContainer.this.g.q().a((String) null, false);
}
@Override
public WebResourceResponse shouldInterceptRequest(IWebView iWebView, String str) {
n.j(iWebView, "webView");
WebResourceResponse finFileResource = FinFileResourceUtil.getFinFileResource(WebViewContainer.this.g, str);
if (finFileResource != null) {
return finFileResource;
}
AppConfig appConfig = WebViewContainer.this.g.getAppConfig();
if (n.d(str != null ? Boolean.valueOf(t.L(str, FinFileResourceUtil.SCHEME, false, 2, (Object) null)) : null, Boolean.TRUE)) {
AppCompatActivity a = WebViewContainer.this.a();
if (str == null) {
n.t();
}
return a(new File(appConfig.getLocalFileAbsolutePath(a, str)));
}
if (str != null) {
File frameworkDir = appConfig.getFrameworkDir(WebViewContainer.this.a());
n.e(frameworkDir, "appConfig.getFrameworkDir(activity)");
String absolutePath = frameworkDir.getAbsolutePath();
n.e(absolutePath, "appConfig.getFrameworkDir(activity).absolutePath");
String miniAppSourcePath = appConfig.getMiniAppSourcePath(WebViewContainer.this.a());
n.e(miniAppSourcePath, "appConfig.getMiniAppSourcePath(activity)");
boolean a2 = b1.a(WebViewContainer.this.g.getB(), (Context) WebViewContainer.this.a());
if (u.Q(str, absolutePath, false, 2, (Object) null) && a2) {
File streamLoadFrameworkFile = appConfig.getStreamLoadFrameworkFile(WebViewContainer.this.a());
return (!streamLoadFrameworkFile.exists() || streamLoadFrameworkFile.length() <= 0) ? super.shouldInterceptRequest(iWebView, str) : b1.b((Context) WebViewContainer.this.a(), str, appConfig);
}
if (u.Q(str, miniAppSourcePath, false, 2, (Object) null) && com.finogeeks.lib.applet.m.a.a.a(WebViewContainer.this.g.getAppId())) {
return b1.a(WebViewContainer.this.g, str, appConfig);
}
super.shouldInterceptRequest(iWebView, str);
}
return super.shouldInterceptRequest(iWebView, str);
}
}
public static final class d extends com.finogeeks.lib.applet.jsbridge.a {
private final String a = "WebViewContainer";
public d() {
}
@Override
public String a(String str, String str2) {
return WebViewContainer.this.h.a(new Event(str, str2));
}
@Override
public void b(String str, String str2, String str3) {
n.j(str3, "callbackId");
WebViewContainer.this.h.b(new Event(str, str2, str3), this);
}
@Override
public void c(String str, String str2) {
IJSExecutor.a.a(WebViewContainer.this.c(), "javascript:ServiceJSBridge.invokeCallbackHandler(" + str + ',' + str2 + ')', null, 2, null);
}
@Override
public void d(String str, String str2, String str3) {
if (str == null) {
return;
}
int hashCode = str.hashCode();
if (hashCode == -1784860848) {
str.equals("custom_event_gameConfigUpdate");
} else if (hashCode == -1690071917 && str.equals("custom_event_gameServiceReady")) {
WebViewContainer.this.b().g();
}
}
@Override
public String getN() {
return this.a;
}
}
public static final class e extends LifecycleObserverAdapter {
public e() {
}
@Override
public void onDestroy() {
WebViewContainer.this.c().destroy();
super.onDestroy();
}
@Override
public void onPause() {
WebViewContainer.this.c().onPause();
}
@Override
public void onResume() {
WebViewContainer.this.c().onResume();
}
}
@Metadata(d1 = {"\u0000'\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005*\u0001\u0000\b\n\u0018\u00002\u00020\u0001JY\u0010\u000e\u001a\u00020\r2\b\u0010\u0003\u001a\u0004\u0018\u00010\u00022\u0006\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u0006\u001a\u00020\u00042\u0006\u0010\u0007\u001a\u00020\u00042\u0006\u0010\b\u001a\u00020\u00042\u0006\u0010\t\u001a\u00020\u00042\u0006\u0010\n\u001a\u00020\u00042\u0006\u0010\u000b\u001a\u00020\u00042\u0006\u0010\f\u001a\u00020\u0004H\u0016¢\u0006\u0004\b\u000e\u0010\u000fR\u0017\u0010\u0011\u001a\u00020\u00108\u0006¢\u0006\f\n\u0004\b\u0011\u0010\u0012\u001a\u0004\b\u0013\u0010\u0014¨\u0006\u0015"}, d2 = {"com/finogeeks/lib/applet/main/game/WebViewContainer$onGameServiceReady$onLayout$1", "Landroid/view/View$OnLayoutChangeListener;", "Landroid/view/View;", "v", "", "left", "top", "right", "bottom", "oldLeft", "oldTop", "oldRight", "oldBottom", "Llg0/e0;", "onLayoutChange", "(Landroid/view/View;IIIIIIII)V", "Ljava/lang/Runnable;", "guaranteeInjectTask", "Ljava/lang/Runnable;", "getGuaranteeInjectTask", "()Ljava/lang/Runnable;", "finapplet_release"}, k = 1, mv = {1, 4, 0})
public static final class f implements View.OnLayoutChangeListener {
private final Runnable a = new a();
final x0 c;
public static final class a implements Runnable {
public a() {
}
@Override
public final void run() {
WebViewContainer.this.i();
WebViewContainer.this.getC().removeOnLayoutChangeListener(f.this);
}
}
public f(x0 x0Var) {
this.c = x0Var;
}
public final Runnable getA() {
return this.a;
}
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
Configuration configuration = WebViewContainer.this.a().getResources().getConfiguration();
if (n.d(new x0(configuration.screenWidthDp, configuration.screenHeightDp), this.c)) {
d1.a().removeCallbacks(this.a);
d1.a().postDelayed(this.a, 100L);
} else {
WebViewContainer.this.getC().removeOnLayoutChangeListener(this);
d1.a().removeCallbacks(this.a);
WebViewContainer.this.i();
}
}
}
public static final class g extends p implements ah0.a<com.finogeeks.lib.applet.page.view.webview.h> {
public g() {
super(0);
}
public final com.finogeeks.lib.applet.page.view.webview.h m452invoke() {
return WebViewContainer.this.g.r().getWebViewManager().b(WebViewContainer.this.g.getB());
}
}
static {
new a(null);
}
public WebViewContainer(FinAppHomeActivity finAppHomeActivity, AppHost appHost, com.finogeeks.lib.applet.api.d dVar) {
super(finAppHomeActivity);
n.j(finAppHomeActivity, "activity");
n.j(appHost, "appHost");
n.j(dVar, "apisManager");
this.g = appHost;
this.h = dVar;
this.c = new FrameLayout(finAppHomeActivity);
this.d = i.a(new g());
this.e = new d();
this.f = new e();
}
private final void h() {
c().setOverScrollMode(2);
c().setScrollBarStyle(0);
c().setScrollBarEnabled(false, false);
c().getSettings().setAllowFileAccessFromFileURLs(true);
c().getSettings().setAllowUniversalAccessFromFileURLs(true);
c().getSettings().setJavaScriptEnabled(true);
c().setJSBridge(this.g, this.e);
c().setWebViewClient(new c());
}
public final void i() {
if (com.finogeeks.lib.applet.m.a.a.a(this.g.getAppId())) {
b1.c(this.g, "game.js");
}
File gameJsFile = this.g.getAppConfig().getGameJsFile(a());
if (!gameJsFile.exists()) {
FLog.d$default("WebViewContainer", "injectGameJsWithHtml onSuccess gameJsFile not found", null, 4, null);
return;
}
StringBuilder sb = new StringBuilder();
sb.append("javascript:window.injectHtml(document.body,{content:'<script charset=\"utf-8\" ");
sb.append("src=\"");
n.e(gameJsFile, "gameJsFile");
sb.append(gameJsFile.getAbsolutePath());
sb.append("\"></script>'})");
IJSExecutor.a.a(c(), sb.toString(), null, 2, null);
b().k();
}
private final boolean j() {
if (com.finogeeks.lib.applet.m.a.a.a(this.g.getAppId())) {
b1.c(this.g, "game.json");
}
File gameJsonFile = this.g.getAppConfig().getGameJsonFile(a());
if (gameJsonFile.exists()) {
n.e(gameJsonFile, "gameJsonFile");
try {
GameConfig gameConfig = (GameConfig) CommonKt.getGSon().fromJson(yg0.l.l(gameJsonFile, (Charset) null, 1, (Object) null), GameConfig.class);
GameManager b2 = b();
n.e(gameConfig, "gameConfig");
return GameManager.a(b2, gameConfig, (ah0.l) null, 2, (Object) null);
} catch (Throwable th2) {
th2.printStackTrace();
}
}
return false;
}
@Override
public void a(boolean z10, ah0.l<? super Bitmap, e0> lVar) {
n.j(lVar, "onGet");
String appAvatar = this.g.getB().getAppAvatar();
if (appAvatar == null || appAvatar.length() == 0) {
lVar.invoke((Object) null);
} else {
ImageLoader.INSTANCE.get(a()).load(appAvatar, new b(lVar));
}
}
public final com.finogeeks.lib.applet.page.view.webview.h c() {
h hVar = this.d;
l lVar = i[0];
return (com.finogeeks.lib.applet.page.view.webview.h) hVar.getValue();
}
@Override
public boolean d() {
return getC().indexOfChild(c()) >= 0;
}
@Override
public ViewGroup getC() {
return this.c;
}
@Override
public void executeJavaScript(String script, ValueCallback<String> valueCallback) {
n.j(script, "script");
c().executeJavaScript(script, valueCallback);
}
@Override
public void f() {
String l;
if (d()) {
return;
}
h();
this.g.getLifecycleRegistry().addObserver(this.f);
AppConfig appConfig = this.g.getAppConfig();
String miniAppSourcePath = appConfig.getMiniAppSourcePath(a());
byte[] a2 = b1.a((Context) a(), this.g.getB(), "script/game-frame.html");
if (a2 != null) {
l = new String(a2, tj0.c.b);
} else {
File frameworkGameFrameHtml = appConfig.getFrameworkGameFrameHtml(a());
n.e(frameworkGameFrameHtml, "appConfig.getFrameworkGameFrameHtml(activity)");
l = yg0.l.l(frameworkGameFrameHtml, (Charset) null, 1, (Object) null);
}
String str = r.k(miniAppSourcePath) + File.separator;
JSONObject a3 = com.finogeeks.lib.applet.service.d.a(this.g);
MeasureManager x = this.g.getX();
String a4 = c().a(l, x != null ? x.c() : null, a3, (JSONObject) null);
com.finogeeks.lib.applet.page.view.webview.h c2 = c();
n.e(a4, "newHTML");
c2.loadDataWithBaseURL(str, a4, "text/html", "UTF-8", null);
getC().addView(c());
}
@Override
public void g() {
if (!j()) {
i();
return;
}
Configuration configuration = a().getResources().getConfiguration();
f fVar = new f(new x0(configuration.screenWidthDp, configuration.screenHeightDp));
getC().addOnLayoutChangeListener(fVar);
d1.a().postDelayed(fVar.getA(), 200L);
}
}