Cyber Surfer v5.2.5版本的 MD5 值为:db13c5fce988de393e52d2679f934b22
以下内容为反编译后的 VungleWebClient.java 源代码,内容仅作参考
package com.vungle.warren.ui.view;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.webkit.RenderProcessGoneDetail;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.webkit.WebViewRenderProcess;
import android.webkit.WebViewRenderProcessClient;
import androidx.webkit.ProxyConfig;
import com.facebook.appevents.internal.ViewHierarchyConstants;
import com.google.firebase.remoteconfig.RemoteConfigConstants;
import com.google.gson.JsonObject;
import com.safedk.android.analytics.brandsafety.creatives.CreativeInfoManager;
import com.safedk.android.utils.Logger;
import com.safedk.android.utils.h;
import com.vungle.warren.BuildConfig;
import com.vungle.warren.model.Advertisement;
import com.vungle.warren.model.Placement;
import com.vungle.warren.omsdk.WebViewObserver;
import com.vungle.warren.ui.view.WebViewAPI;
import java.util.concurrent.ExecutorService;
import net.pubnative.lite.sdk.mraid.MRAIDNativeFeature;
public class VungleWebClient extends WebViewClient implements WebViewAPI {
public static final String TAG = "VungleWebClient";
private WebViewAPI.MRAIDDelegate MRAIDDelegate;
private Advertisement advertisement;
private boolean collectConsent;
private WebViewAPI.WebClientErrorHandler errorHandler;
private String gdprAccept;
private String gdprBody;
private String gdprDeny;
private String gdprTitle;
private Boolean isViewable;
private WebView loadedWebView;
private ExecutorService offloadExecutor;
private Placement placement;
private boolean ready;
private WebViewObserver webViewObserver;
public static class VungleWebViewRenderProcessClient extends WebViewRenderProcessClient {
WebViewAPI.WebClientErrorHandler errorHandler;
VungleWebViewRenderProcessClient(WebViewAPI.WebClientErrorHandler webClientErrorHandler) {
this.errorHandler = webClientErrorHandler;
}
@Override
public void onRenderProcessResponsive(WebView webView, WebViewRenderProcess webViewRenderProcess) {
}
@Override
public void onRenderProcessUnresponsive(WebView webView, WebViewRenderProcess webViewRenderProcess) {
String str = VungleWebClient.TAG;
StringBuilder sb = new StringBuilder("onRenderProcessUnresponsive(Title = ");
sb.append(webView.getTitle());
sb.append(", URL = ");
sb.append(webView.getOriginalUrl());
sb.append(", (webViewRenderProcess != null) = ");
sb.append(webViewRenderProcess != null);
Log.w(str, sb.toString());
WebViewAPI.WebClientErrorHandler webClientErrorHandler = this.errorHandler;
if (webClientErrorHandler != null) {
webClientErrorHandler.onRenderProcessUnresponsive(webView, webViewRenderProcess);
}
}
}
public VungleWebClient(Advertisement advertisement, Placement placement, ExecutorService executorService) {
this.advertisement = advertisement;
this.placement = placement;
this.offloadExecutor = executorService;
}
private void handleWebViewError(String str, String str2) {
boolean isCriticalAsset = isCriticalAsset(str2);
String str3 = str2 + " " + str;
WebViewAPI.WebClientErrorHandler webClientErrorHandler = this.errorHandler;
if (webClientErrorHandler != null) {
webClientErrorHandler.onReceivedError(str3, isCriticalAsset);
}
}
private boolean isCriticalAsset(String str) {
Advertisement advertisement;
if (TextUtils.isEmpty(str) || (advertisement = this.advertisement) == null) {
return false;
}
return advertisement.getDownloadableUrls().containsValue(str);
}
public void runJavascriptOnWebView(WebView webView, String str) {
webView.evaluateJavascript(str, null);
}
private void safedk_webviewclient_VungleWebClient_WebViewClientOnReceivedError_5654c4814f58183e4b54c41f823e8f20(WebView webView, int i, String str, String str2) {
Logger.d("VungleNetwork|SafeDK: Partial-Network> Lcom/vungle/warren/ui/view/VungleWebClient;->safedk_webviewclient_VungleWebClient_WebViewClientOnReceivedError_5654c4814f58183e4b54c41f823e8f20(Landroid/webkit/WebView;ILjava/lang/String;Ljava/lang/String;)V");
Logger.d("SafeDKNetwork", "WebViewClientOnReceivedError view: " + webView + ", errorCode: " + i + ", description: " + str + ", failingUrl: " + str2);
super.onReceivedError(webView, i, str, str2);
}
@Override
public void notifyPropertiesChange(boolean z) {
if (this.loadedWebView != null) {
JsonObject jsonObject = new JsonObject();
JsonObject jsonObject2 = new JsonObject();
jsonObject2.addProperty(ViewHierarchyConstants.DIMENSION_WIDTH_KEY, Integer.valueOf(this.loadedWebView.getWidth()));
jsonObject2.addProperty(ViewHierarchyConstants.DIMENSION_HEIGHT_KEY, Integer.valueOf(this.loadedWebView.getHeight()));
JsonObject jsonObject3 = new JsonObject();
jsonObject3.addProperty("x", (Number) 0);
jsonObject3.addProperty("y", (Number) 0);
jsonObject3.addProperty(ViewHierarchyConstants.DIMENSION_WIDTH_KEY, Integer.valueOf(this.loadedWebView.getWidth()));
jsonObject3.addProperty(ViewHierarchyConstants.DIMENSION_HEIGHT_KEY, Integer.valueOf(this.loadedWebView.getHeight()));
JsonObject jsonObject4 = new JsonObject();
jsonObject4.addProperty(MRAIDNativeFeature.SMS, (Boolean) false);
jsonObject4.addProperty(MRAIDNativeFeature.TEL, (Boolean) false);
jsonObject4.addProperty(MRAIDNativeFeature.CALENDAR, (Boolean) false);
jsonObject4.addProperty(MRAIDNativeFeature.STORE_PICTURE, (Boolean) false);
jsonObject4.addProperty(MRAIDNativeFeature.INLINE_VIDEO, (Boolean) false);
jsonObject.add("maxSize", jsonObject2);
jsonObject.add("screenSize", jsonObject2);
jsonObject.add("defaultPosition", jsonObject3);
jsonObject.add("currentPosition", jsonObject3);
jsonObject.add("supports", jsonObject4);
jsonObject.addProperty("placementType", this.advertisement.getTemplateType());
Boolean bool = this.isViewable;
if (bool != null) {
jsonObject.addProperty("isViewable", bool);
}
jsonObject.addProperty("os", "android");
jsonObject.addProperty("osVersion", Integer.toString(Build.VERSION.SDK_INT));
jsonObject.addProperty("incentivized", Boolean.valueOf(this.placement.isIncentivized()));
jsonObject.addProperty("enableBackImmediately", Boolean.valueOf(this.advertisement.getShowCloseDelay(this.placement.isIncentivized()) == 0));
jsonObject.addProperty("version", "1.0");
if (this.collectConsent) {
jsonObject.addProperty("consentRequired", (Boolean) true);
jsonObject.addProperty("consentTitleText", this.gdprTitle);
jsonObject.addProperty("consentBodyText", this.gdprBody);
jsonObject.addProperty("consentAcceptButtonText", this.gdprAccept);
jsonObject.addProperty("consentDenyButtonText", this.gdprDeny);
} else {
jsonObject.addProperty("consentRequired", (Boolean) false);
}
jsonObject.addProperty(RemoteConfigConstants.RequestFieldKey.SDK_VERSION, BuildConfig.VERSION_NAME);
String str = TAG;
Log.d(str, "loadJsjavascript:window.vungle.mraidBridge.notifyPropertiesChange(" + jsonObject + "," + z + ")");
runJavascriptOnWebView(this.loadedWebView, "window.vungle.mraidBridge.notifyPropertiesChange(" + jsonObject + "," + z + ")");
}
}
@Override
public void onLoadResource(WebView webView, String str) {
super.onLoadResource(webView, str);
CreativeInfoManager.onResourceLoaded(h.d, webView, str);
}
@Override
public void onPageFinished(WebView webView, String str) {
Logger.d("Vungle|SafeDK: Execution> Lcom/vungle/warren/ui/view/VungleWebClient;->onPageFinished(Landroid/webkit/WebView;Ljava/lang/String;)V");
CreativeInfoManager.onWebViewPageFinished(h.d, webView, str);
safedk_VungleWebClient_onPageFinished_b59ae6084bf7a6b22f98173df3158f6d(webView, str);
}
@Override
public void onReceivedError(WebView webView, int i, String str, String str2) {
safedk_webviewclient_VungleWebClient_WebViewClientOnReceivedError_5654c4814f58183e4b54c41f823e8f20(webView, i, str, str2);
if (Build.VERSION.SDK_INT < 23) {
String str3 = TAG;
Log.e(str3, "Error desc " + str);
Log.e(str3, "Error for URL " + str2);
handleWebViewError(str, str2);
}
}
@Override
public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) {
super.onReceivedError(webView, webResourceRequest, webResourceError);
if (Build.VERSION.SDK_INT >= 23) {
String str = TAG;
Log.e(str, "Error desc " + webResourceError.getDescription().toString());
Log.e(str, "Error for URL " + webResourceRequest.getUrl().toString());
handleWebViewError(webResourceError.getDescription().toString(), webResourceRequest.getUrl().toString());
}
}
@Override
public void onReceivedHttpError(WebView webView, WebResourceRequest webResourceRequest, WebResourceResponse webResourceResponse) {
super.onReceivedHttpError(webView, webResourceRequest, webResourceResponse);
String str = TAG;
Log.e(str, "Error desc " + webResourceResponse.getStatusCode());
Log.e(str, "Error for URL " + webResourceRequest.getUrl().toString());
handleWebViewError(String.valueOf(webResourceResponse.getStatusCode()), webResourceRequest.getUrl().toString());
}
@Override
public boolean onRenderProcessGone(WebView webView, RenderProcessGoneDetail renderProcessGoneDetail) {
String str = TAG;
Log.w(str, "onRenderProcessGone url: " + webView.getUrl() + ", did crash: " + renderProcessGoneDetail.didCrash());
this.loadedWebView = null;
WebViewAPI.WebClientErrorHandler webClientErrorHandler = this.errorHandler;
return webClientErrorHandler != null ? webClientErrorHandler.onWebRenderingProcessGone(webView, renderProcessGoneDetail.didCrash()) : super.onRenderProcessGone(webView, renderProcessGoneDetail);
}
public void safedk_VungleWebClient_onPageFinished_b59ae6084bf7a6b22f98173df3158f6d(WebView webView, String str) {
super.onPageFinished(webView, str);
int adType = this.advertisement.getAdType();
if (adType == 0) {
runJavascriptOnWebView(webView, "function actionClicked(action){Android.performAction(action);};");
} else if (adType != 1) {
throw new IllegalArgumentException("Unknown Client Type!");
} else {
this.loadedWebView = webView;
webView.setVisibility(0);
notifyPropertiesChange(true);
}
if (Build.VERSION.SDK_INT >= 29) {
webView.setWebViewRenderProcessClient(new VungleWebViewRenderProcessClient(this.errorHandler));
}
WebViewObserver webViewObserver = this.webViewObserver;
if (webViewObserver != null) {
webViewObserver.onPageFinished(webView);
}
}
public boolean safedk_VungleWebClient_shouldOverrideUrlLoading_341add94f1e3fe777de963a4de54a5b5(final WebView webView, String str) {
String str2 = TAG;
Log.d(str2, "MRAID Command " + str);
if (TextUtils.isEmpty(str)) {
Log.e(str2, "Invalid URL ");
return false;
}
Uri parse = Uri.parse(str);
if (parse.getScheme() != null) {
String scheme = parse.getScheme();
if (scheme.equals("mraid")) {
final String host = parse.getHost();
if (host != null) {
if ("propertiesChangeCompleted".equals(host) && !this.ready) {
JsonObject createMRAIDArgs = this.advertisement.createMRAIDArgs();
runJavascriptOnWebView(webView, "window.vungle.mraidBridge.notifyReadyEvent(" + createMRAIDArgs + ")");
this.ready = true;
} else if (this.MRAIDDelegate != null) {
final JsonObject jsonObject = new JsonObject();
for (String str3 : parse.getQueryParameterNames()) {
jsonObject.addProperty(str3, parse.getQueryParameter(str3));
}
final Handler handler = new Handler();
this.offloadExecutor.submit(new Runnable() {
@Override
public void run() {
if (VungleWebClient.this.MRAIDDelegate.processCommand(host, jsonObject)) {
handler.post(new Runnable() {
@Override
public void run() {
VungleWebClient.this.runJavascriptOnWebView(webView, "window.vungle.mraidBridge.notifyCommandComplete()");
}
});
}
}
});
}
return true;
}
return false;
} else if ("http".equalsIgnoreCase(scheme) || ProxyConfig.MATCH_HTTPS.equalsIgnoreCase(scheme)) {
Log.d(str2, "Open URL" + str);
if (this.MRAIDDelegate != null) {
JsonObject jsonObject2 = new JsonObject();
jsonObject2.addProperty("url", str);
this.MRAIDDelegate.processCommand("openNonMraid", jsonObject2);
}
return true;
}
}
return false;
}
@Override
public void setAdVisibility(boolean z) {
this.isViewable = Boolean.valueOf(z);
notifyPropertiesChange(false);
}
@Override
public void setConsentStatus(boolean z, String str, String str2, String str3, String str4) {
this.collectConsent = z;
this.gdprTitle = str;
this.gdprBody = str2;
this.gdprAccept = str3;
this.gdprDeny = str4;
}
@Override
public void setErrorHandler(WebViewAPI.WebClientErrorHandler webClientErrorHandler) {
this.errorHandler = webClientErrorHandler;
}
@Override
public void setMRAIDDelegate(WebViewAPI.MRAIDDelegate mRAIDDelegate) {
this.MRAIDDelegate = mRAIDDelegate;
}
@Override
public void setWebViewObserver(WebViewObserver webViewObserver) {
this.webViewObserver = webViewObserver;
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
return CreativeInfoManager.onWebViewResponseWithHeaders(h.d, webView, webResourceRequest, super.shouldInterceptRequest(webView, webResourceRequest));
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView webView, String str) {
return CreativeInfoManager.onWebViewResponse(h.d, webView, str, super.shouldInterceptRequest(webView, str));
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
Logger.d("Vungle|SafeDK: Execution> Lcom/vungle/warren/ui/view/VungleWebClient;->shouldOverrideUrlLoading(Landroid/webkit/WebView;Ljava/lang/String;)Z");
boolean safedk_VungleWebClient_shouldOverrideUrlLoading_341add94f1e3fe777de963a4de54a5b5 = safedk_VungleWebClient_shouldOverrideUrlLoading_341add94f1e3fe777de963a4de54a5b5(webView, str);
CreativeInfoManager.onOverrideUrlLoading(h.d, webView, str, safedk_VungleWebClient_shouldOverrideUrlLoading_341add94f1e3fe777de963a4de54a5b5);
return safedk_VungleWebClient_shouldOverrideUrlLoading_341add94f1e3fe777de963a4de54a5b5;
}
}