导航菜单

页面标题

页面副标题

Aplazo v2.4.68 - DebugView.java 源代码

正在查看: Aplazo v2.4.68 应用的 DebugView.java JAVA 源代码文件

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


package com.statsig.androidsdk;

import Di.A;
import Di.x;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.KeyEvent;
import android.view.ViewGroup;
import android.view.Window;
import android.webkit.ConsoleMessage;
import android.webkit.CookieManager;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.google.gson.j;
import com.statsig.androidsdk.DebugView;
import gd.AbstractC0117a;
import hi.z;
import java.util.List;
import java.util.Map;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.l;

public final class DebugView {
    public static final Companion Companion = new Companion(null);

    public static final class Companion {
        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        private final WebView getConfiguredWebView(Context context, DebugWebViewClient debugWebViewClient, DebugWebChromeClient debugWebChromeClient) {
            WebView webView = new WebView(context);
            webView.setWebViewClient(debugWebViewClient);
            webView.setWebChromeClient(debugWebChromeClient);
            webView.setSystemUiVisibility(2);
            WebSettings settings = webView.getSettings();
            settings.setJavaScriptCanOpenWindowsAutomatically(true);
            settings.setJavaScriptEnabled(true);
            settings.setDatabaseEnabled(true);
            settings.setDomStorageEnabled(true);
            webView.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
            CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);
            return webView;
        }

        public static final boolean m423show$lambda0(WebView webView, Dialog dialog, DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
            String str;
            l.e(webView, "$webView");
            l.e(dialog, "$dialog");
            if (i != 4 || keyEvent.getAction() != 1 || !webView.canGoBack()) {
                return false;
            }
            webView.goBack();
            String url = webView.getUrl();
            Boolean bool = null;
            List P = url == null ? null : A.P(url, new String[]{"/"}, 0, 6);
            if (P != null && (str = (String) z.L(P)) != null) {
                bool = Boolean.valueOf(x.p(str, "client_sdk_debugger", false));
            }
            if (l.a(bool, Boolean.TRUE)) {
                dialog.dismiss();
            }
            return true;
        }

        public final void show(Context context, String str, Map<String, ? extends Object> map, Function1 function1) {
            l.e(context, "context");
            l.e(str, "sdkKey");
            l.e(map, "state");
            final Dialog dialog = new Dialog(context, android.R.style.Theme.Black.NoTitleBar.Fullscreen);
            String j = new j().j(map);
            l.d(j, "Gson().toJson(state)");
            final WebView configuredWebView = getConfiguredWebView(context, new DebugWebViewClient(j), new DebugWebChromeClient(dialog, function1));
            dialog.requestWindowFeature(1);
            dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
                @Override
                public final boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
                    boolean m423show$lambda0;
                    m423show$lambda0 = DebugView.Companion.m423show$lambda0(configuredWebView, dialog, dialogInterface, i, keyEvent);
                    return m423show$lambda0;
                }
            });
            configuredWebView.loadUrl(l.i(str, "https://console.statsig.com/client_sdk_debugger_redirect?sdkKey="));
            dialog.setContentView(configuredWebView);
            dialog.show();
            Window window = dialog.getWindow();
            if (window == null) {
                return;
            }
            window.setLayout(-1, -1);
        }

        private Companion() {
        }
    }

    public static final class DebugWebChromeClient extends WebChromeClient {
        private final Function1 callback;
        private final String closeAction;
        private final Dialog dialog;
        private final String reloadRequired;

        public DebugWebChromeClient(Dialog dialog, Function1 function1) {
            l.e(dialog, "dialog");
            this.dialog = dialog;
            this.callback = function1;
            this.closeAction = "STATSIG_ANDROID_DEBUG_CLOSE_DIALOG";
            this.reloadRequired = "STATSIG_ANDROID_DEBUG_RELOAD_REQUIRED";
        }

        @Override
        public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
            String message;
            Function1 function1;
            if (consoleMessage != null && (message = consoleMessage.message()) != null) {
                if (x.h(this.closeAction, message)) {
                    this.dialog.dismiss();
                }
                if (x.h(this.reloadRequired, message) && (function1 = this.callback) != null) {
                    function1.invoke(Boolean.TRUE);
                }
            }
            return super.onConsoleMessage(consoleMessage);
        }
    }

    public static final class DebugWebViewClient extends WebViewClient {
        private final String json;

        public DebugWebViewClient(String str) {
            l.e(str, "json");
            this.json = str;
        }

        @Override
        public void onPageFinished(WebView webView, String str) {
            super.onPageFinished(webView, str);
            if (webView != null) {
                webView.evaluateJavascript("window.__StatsigAndroidDebug=true;", null);
            }
            String j = AbstractC0117a.j(new StringBuilder("window.__StatsigClientState = "), this.json, ';');
            if (webView == null) {
                return;
            }
            webView.evaluateJavascript(j, null);
        }
    }
}