正在查看: Cashalo v2.25.0.0 应用的 DebugView.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Cashalo v2.25.0.0 应用的 DebugView.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.statsig.androidsdk;
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.fullstory.FS;
import com.google.gson.Gson;
import com.statsig.androidsdk.DebugView;
import java.util.List;
import java.util.Map;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt;
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0005\u0018\u0000 \u00032\u00020\u0001:\u0003\u0003\u0004\u0005B\u0005¢\u0006\u0002\u0010\u0002¨\u0006\u0006"}, d2 = {"Lcom/statsig/androidsdk/DebugView;", "", "()V", "Companion", "DebugWebChromeClient", "DebugWebViewClient", "android-sdk_release"}, k = 1, mv = {1, 5, 1}, xi = 48)
public final class DebugView {
public static final Companion INSTANCE = new Companion(null);
@Metadata(d1 = {"\u0000D\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\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\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010$\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u000b\n\u0002\u0018\u0002\n\u0000\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J \u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\b2\u0006\u0010\t\u001a\u00020\nH\u0002JH\u0010\u000b\u001a\u00020\f2\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\u000e2\u0014\u0010\u000f\u001a\u0010\u0012\u0004\u0012\u00020\u000e\u0012\u0006\u0012\u0004\u0018\u00010\u00010\u00102\u001a\u0010\u0011\u001a\u0016\u0012\u0004\u0012\u00020\u0013\u0012\u0004\u0012\u00020\f\u0018\u00010\u0012j\u0004\u0018\u0001`\u0014¨\u0006\u0015"}, d2 = {"Lcom/statsig/androidsdk/DebugView$Companion;", "", "()V", "getConfiguredWebView", "Landroid/webkit/WebView;", "context", "Landroid/content/Context;", "client", "Lcom/statsig/androidsdk/DebugView$DebugWebViewClient;", "chromeClient", "Lcom/statsig/androidsdk/DebugView$DebugWebChromeClient;", "show", "", "sdkKey", "", "state", "", "callback", "Lkotlin/Function1;", "", "Lcom/statsig/androidsdk/DebugViewCallback;", "android-sdk_release"}, k = 1, mv = {1, 5, 1}, xi = 48)
public static final class Companion {
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
public final void show(Context context, String sdkKey, Map<String, ? extends Object> state, Function1<? super Boolean, Unit> callback) {
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(sdkKey, "sdkKey");
Intrinsics.checkNotNullParameter(state, "state");
final Dialog dialog = new Dialog(context, android.R.style.Theme.Black.NoTitleBar.Fullscreen);
String json = new Gson().toJson(state);
Intrinsics.checkNotNullExpressionValue(json, "Gson().toJson(state)");
final WebView configuredWebView = getConfiguredWebView(context, new DebugWebViewClient(json), new DebugWebChromeClient(dialog, callback));
dialog.requestWindowFeature(1);
dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
@Override
public final boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
boolean m61show$lambda0;
m61show$lambda0 = DebugView.Companion.m61show$lambda0(configuredWebView, dialog, dialogInterface, i, keyEvent);
return m61show$lambda0;
}
});
String stringPlus = Intrinsics.stringPlus("https://console.statsig.com/client_sdk_debugger_redirect?sdkKey=", sdkKey);
FS.trackWebView(configuredWebView);
configuredWebView.loadUrl(stringPlus);
dialog.setContentView(configuredWebView);
dialog.show();
Window window = dialog.getWindow();
if (window == null) {
return;
}
window.setLayout(-1, -1);
}
public static final boolean m61show$lambda0(WebView webView, Dialog dialog, DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
String str;
Intrinsics.checkNotNullParameter(webView, "$webView");
Intrinsics.checkNotNullParameter(dialog, "$dialog");
if (i != 4 || keyEvent.getAction() != 1 || !webView.canGoBack()) {
return false;
}
webView.goBack();
String url = webView.getUrl();
Boolean bool = null;
List split$default = url == null ? null : StringsKt.split$default(url, new String[]{"/"}, false, 0, 6, (Object) null);
if (split$default != null && (str = (String) CollectionsKt.last(split$default)) != null) {
bool = Boolean.valueOf(StringsKt.startsWith$default(str, "client_sdk_debugger", false, 2, (Object) null));
}
if (Intrinsics.areEqual(bool, true)) {
dialog.dismiss();
}
return true;
}
private final WebView getConfiguredWebView(Context context, DebugWebViewClient client, DebugWebChromeClient chromeClient) {
WebView webView = new WebView(context);
FS.setWebViewClient(webView, client);
webView.setWebChromeClient(chromeClient);
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;
}
}
@Metadata(d1 = {"\u0000 \n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0002\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\u001c\u0010\u0005\u001a\u00020\u00062\b\u0010\u0007\u001a\u0004\u0018\u00010\b2\b\u0010\t\u001a\u0004\u0018\u00010\u0003H\u0016R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\n"}, d2 = {"Lcom/statsig/androidsdk/DebugView$DebugWebViewClient;", "Landroid/webkit/WebViewClient;", "json", "", "(Ljava/lang/String;)V", "onPageFinished", "", "view", "Landroid/webkit/WebView;", "url", "android-sdk_release"}, k = 1, mv = {1, 5, 1}, xi = 48)
private static final class DebugWebViewClient extends WebViewClient {
private final String json;
public DebugWebViewClient(String str) {
Intrinsics.checkNotNullParameter(str, "json");
this.json = str;
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
if (view != null) {
view.evaluateJavascript("window.__StatsigAndroidDebug=true;", null);
}
String str = "window.__StatsigClientState = " + this.json + ';';
if (view == null) {
return;
}
view.evaluateJavascript(str, null);
}
}
@Metadata(d1 = {"\u00002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u000b\n\u0002\u0010\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\b\u0002\u0018\u00002\u00020\u0001B)\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u001a\u0010\u0004\u001a\u0016\u0012\u0004\u0012\u00020\u0006\u0012\u0004\u0012\u00020\u0007\u0018\u00010\u0005j\u0004\u0018\u0001`\b¢\u0006\u0002\u0010\tJ\u0012\u0010\r\u001a\u00020\u00062\b\u0010\u000e\u001a\u0004\u0018\u00010\u000fH\u0016R\"\u0010\u0004\u001a\u0016\u0012\u0004\u0012\u00020\u0006\u0012\u0004\u0012\u00020\u0007\u0018\u00010\u0005j\u0004\u0018\u0001`\bX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u000bX\u0082D¢\u0006\u0002\n\u0000R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\f\u001a\u00020\u000bX\u0082D¢\u0006\u0002\n\u0000¨\u0006\u0010"}, d2 = {"Lcom/statsig/androidsdk/DebugView$DebugWebChromeClient;", "Landroid/webkit/WebChromeClient;", "dialog", "Landroid/app/Dialog;", "callback", "Lkotlin/Function1;", "", "", "Lcom/statsig/androidsdk/DebugViewCallback;", "(Landroid/app/Dialog;Lkotlin/jvm/functions/Function1;)V", "closeAction", "", "reloadRequired", "onConsoleMessage", "consoleMessage", "Landroid/webkit/ConsoleMessage;", "android-sdk_release"}, k = 1, mv = {1, 5, 1}, xi = 48)
private static final class DebugWebChromeClient extends WebChromeClient {
private final Function1<Boolean, Unit> callback;
private final String closeAction;
private final Dialog dialog;
private final String reloadRequired;
public DebugWebChromeClient(Dialog dialog, Function1<? super Boolean, Unit> function1) {
Intrinsics.checkNotNullParameter(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<Boolean, Unit> function1;
if (consoleMessage != null && (message = consoleMessage.message()) != null) {
String str = message;
if (StringsKt.contentEquals(str, this.closeAction, true)) {
this.dialog.dismiss();
}
if (StringsKt.contentEquals(str, this.reloadRequired, true) && (function1 = this.callback) != null) {
function1.invoke(true);
}
}
return super.onConsoleMessage(consoleMessage);
}
}
}