GoooBet v1.0版本的 MD5 值为:ff9748f16167bfd7735b669c0a9931c5
以下内容为反编译后的 DTBAdView.java 源代码,内容仅作参考
package com.amazon.device.ads;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.webkit.CookieManager;
import android.webkit.JavascriptInterface;
import android.webkit.ValueCallback;
import android.webkit.WebView;
import android.widget.ScrollView;
import com.amazon.device.ads.DTBAdView;
import com.google.android.exoplayer2.C;
import com.integralads.avid.library.mopub.video.AvidVideoPlaybackListenerImpl;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Date;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
public class DTBAdView extends WebView {
public static final String AMAZON_AD_INFO = "amazon_ad_info";
static final String AMAZON_BRIDGE = "amzn_bridge";
public static final String BID_HTML = "bid_html_template";
public static final String BID_IDENTIFIER = "bid_identifier";
private static final String ENV_TEMPLATE = "window.MRAID_ENV={version:'%s',sdk:'%s',sdkVersion:'%s',appId:'%s',ifa:'%s',limitAdTracking:%b,coppa:%b,impFired:true};";
private static final String ENV_TEMPLATE_INFO = "window.MRAID_ENV={version:'%s',sdk:'%s',sdkVersion:'%s',appId:'%s',ifa:'%s',limitAdTracking:%b,coppa:%b,amznAdInfo:%s,impFired:true};";
public static final String EVENT_SERVER_PARAMETER = "event_server_parameter";
public static final String EXPECTED_HEIGHT = "expected_height";
public static final String EXPECTED_WIDTH = "expected_width";
public static final String HOSTNAME_IDENTIFIER = "hostname_identifier";
static final String LOG_TAG = DTBAdView.class.getSimpleName();
static final String MRAID_IDENTIFIER = "MRAID_ENV";
public static final String REQUEST_QUEUE = "amazon_request_queue";
public static final String SMARTBANNER_STATE = "smart_banner_state";
public static final String START_LOAD_TIME = "start_load_time";
private String bidId;
private DTBAdMRAIDController controller;
private int exposurePercent;
ViewTreeObserver.OnGlobalFocusChangeListener focusChangeListener;
ViewTreeObserver.OnGlobalLayoutListener globalLayoutListener;
private String hostname;
private boolean ignoreDetachment;
private boolean isFirstDisplay;
private boolean isVisible;
private boolean localOnly;
Rect position;
ViewTreeObserver.OnScrollChangedListener scrollChangeListener;
private boolean scrollEnabled;
private long startTime;
DTBAdViewSupportClient supportClient;
private long timeClicked;
private long timePressed;
private WebBridge webBridge;
private void markAsInvisible() {
}
public DTBAdView(Context context, DTBAdInterstitialListener dTBAdInterstitialListener) {
super(context);
this.scrollEnabled = true;
this.ignoreDetachment = false;
this.isFirstDisplay = true;
this.isVisible = false;
this.exposurePercent = -1;
this.localOnly = WebResourceOptions.isLocalSourcesOnly();
CookieManager.getInstance().setAcceptCookie(true);
this.controller = new DTBAdMRAIDInterstitialController(this, dTBAdInterstitialListener);
commonInit();
}
public DTBAdView(Context context, DTBAdBannerListener dTBAdBannerListener) {
super(context);
this.scrollEnabled = true;
this.ignoreDetachment = false;
this.isFirstDisplay = true;
this.isVisible = false;
this.exposurePercent = -1;
this.localOnly = WebResourceOptions.isLocalSourcesOnly();
CookieManager.getInstance().setAcceptCookie(true);
this.controller = new DTBAdMRAIDBannerController(this, dTBAdBannerListener);
commonInit();
}
public DTBAdView(Context context, DTBAdExpandedListener dTBAdExpandedListener) {
this(context, dTBAdExpandedListener, 0);
}
public DTBAdView(Context context, DTBAdExpandedListener dTBAdExpandedListener, int i) {
super(context);
this.scrollEnabled = true;
this.ignoreDetachment = false;
this.isFirstDisplay = true;
this.isVisible = false;
this.exposurePercent = -1;
this.localOnly = WebResourceOptions.isLocalSourcesOnly();
CookieManager.getInstance().setAcceptCookie(true);
DTBAdMRAIDExpandedController dTBAdMRAIDExpandedController = new DTBAdMRAIDExpandedController(this);
this.controller = dTBAdMRAIDExpandedController;
dTBAdMRAIDExpandedController.setMasterController(DTBAdMRAIDBannerController.findControllerByIndex(i));
dTBAdExpandedListener.onCreateExpandedController((DTBAdMRAIDExpandedController) this.controller);
commonInit();
}
public void setIgnoreDetachment() {
this.ignoreDetachment = true;
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
getViewTreeObserver().removeOnGlobalLayoutListener(this.globalLayoutListener);
getViewTreeObserver().removeOnScrollChangedListener(this.scrollChangeListener);
getViewTreeObserver().removeOnGlobalFocusChangeListener(this.focusChangeListener);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
getViewTreeObserver().addOnGlobalLayoutListener(this.globalLayoutListener);
getViewTreeObserver().addOnGlobalFocusChangeListener(this.focusChangeListener);
getViewTreeObserver().addOnScrollChangedListener(this.scrollChangeListener);
getController().onAdOpened(this);
}
public void cleanup() {
removeJavascriptInterface(AMAZON_BRIDGE);
this.controller.adView = null;
this.controller.customButtonListener = null;
this.controller = null;
}
private void commonInit() {
getSettings().setJavaScriptEnabled(true);
getSettings().setAllowContentAccess(true);
getSettings().setDomStorageEnabled(true);
getSettings().setAppCacheEnabled(true);
getSettings().setAllowFileAccess(false);
getSettings().setLoadsImagesAutomatically(true);
if (AdRegistration.isTestMode() && Build.VERSION.SDK_INT >= 19) {
WebView.setWebContentsDebuggingEnabled(true);
}
getSettings().setBlockNetworkImage(false);
DTBAdViewSupportClient dTBAdViewSupportClient = new DTBAdViewSupportClient(getContext(), this.controller);
this.supportClient = dTBAdViewSupportClient;
setWebViewClient(dTBAdViewSupportClient);
setScrollEnabled(false);
WebBridge webBridge = new WebBridge();
this.webBridge = webBridge;
addJavascriptInterface(webBridge, AMAZON_BRIDGE);
WebResourceService.init();
this.globalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
DTBAdView.this.verifyIsVisible();
}
};
getViewTreeObserver().addOnGlobalLayoutListener(this.globalLayoutListener);
this.focusChangeListener = new ViewTreeObserver.OnGlobalFocusChangeListener() {
@Override
public void onGlobalFocusChanged(View view, View view2) {
DTBAdView.this.verifyIsVisible();
}
};
getViewTreeObserver().addOnGlobalFocusChangeListener(this.focusChangeListener);
this.scrollChangeListener = new ViewTreeObserver.OnScrollChangedListener() {
@Override
public void onScrollChanged() {
DTBAdView.this.verifyIsVisible();
}
};
getViewTreeObserver().addOnScrollChangedListener(this.scrollChangeListener);
setOnTouchListener(new View.OnTouchListener() {
@Override
public final boolean onTouch(View view, MotionEvent motionEvent) {
return DTBAdView.this.lambda$commonInit$0$DTBAdView(view, motionEvent);
}
});
}
public boolean lambda$commonInit$0$DTBAdView(View view, MotionEvent motionEvent) {
int action = motionEvent.getAction();
long time = new Date().getTime();
if (action == 0) {
this.timePressed = time;
return false;
}
if (action != 1) {
this.timePressed = 0L;
return false;
}
if (time - this.timeClicked < 1000) {
return false;
}
if (time - this.timePressed < 500) {
this.timeClicked = time;
this.controller.onAdClicked();
}
this.timePressed = 0L;
return false;
}
public boolean isVisible() {
return this.isVisible;
}
private void loadLocalFile(String str, StringBuilder sb) {
if (!this.localOnly) {
try {
String loadFile = WebResourceService.getInstance().loadFile(str);
if (loadFile != null) {
sb.append("<script>");
sb.append(loadFile);
sb.append("</script>");
return;
}
} catch (Exception unused) {
DtbLog.error(LOG_TAG, "Failed to read local file");
}
}
sb.append("<script>");
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(getContext().getAssets().open(str + ".js")));
while (true) {
String readLine = bufferedReader.readLine();
if (readLine == null) {
break;
}
sb.append(readLine.trim());
sb.append("\n");
}
} catch (Exception unused2) {
DtbLog.error("Error reading file:" + str);
}
sb.append("</script>");
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (this.isFirstDisplay) {
if (DTBTimeTrace.getInstance() != null && AdRegistration.isTestMode()) {
DTBTimeTrace.getInstance().addPhase(DTBTimeTrace.TIMETRACE_AD_DISPLAY_SUCCEEDED);
DTBTimeTrace.getInstance().logTrace();
}
DTBActivityListener dTBActivityListener = this.controller;
if (dTBActivityListener instanceof DTBAdViewDisplayListener) {
((DTBAdViewDisplayListener) dTBActivityListener).onInitialDisplay();
}
this.isFirstDisplay = false;
}
}
public void verifyIsVisible() {
if (getParent() == null || getVisibility() != 0) {
if (this.isVisible) {
DTBAdMRAIDController dTBAdMRAIDController = this.controller;
if (dTBAdMRAIDController != null) {
dTBAdMRAIDController.onViewabilityChanged(false);
}
setIsVisible(false);
return;
}
return;
}
Activity currentActivity = AdRegistration.getCurrentActivity();
if (currentActivity == null) {
if (this.isVisible) {
DTBAdMRAIDController dTBAdMRAIDController2 = this.controller;
if (dTBAdMRAIDController2 != null) {
dTBAdMRAIDController2.onViewabilityChanged(false);
}
setIsVisible(false);
return;
}
return;
}
ViewGroup viewGroup = (ViewGroup) currentActivity.findViewById(android.R.id.content);
int[] iArr = new int[2];
viewGroup.getLocationInWindow(iArr);
Rect rect = new Rect(iArr[0], iArr[1], iArr[0] + viewGroup.getWidth(), iArr[1] + viewGroup.getHeight());
int[] iArr2 = new int[2];
getLocationInWindow(iArr2);
Rect rect2 = new Rect(iArr2[0], iArr2[1], iArr2[0] + getWidth(), iArr2[1] + getHeight());
if (!rect.contains(rect2) && !Rect.intersects(rect, rect2)) {
if (this.isVisible) {
DTBAdMRAIDController dTBAdMRAIDController3 = this.controller;
if (dTBAdMRAIDController3 != null) {
dTBAdMRAIDController3.onViewabilityChanged(false);
}
setIsVisible(false);
DtbLog.debug("SET MRAID Visible false because of root");
}
} else {
ScrollView scrollViewParent = getScrollViewParent();
if (scrollViewParent != null) {
int[] iArr3 = new int[2];
scrollViewParent.getLocationInWindow(iArr3);
Rect rect3 = new Rect(iArr3[0], iArr3[1], iArr3[0] + scrollViewParent.getWidth(), iArr3[1] + scrollViewParent.getHeight());
if (!Rect.intersects(rect2, rect3) && this.isVisible) {
DTBAdMRAIDController dTBAdMRAIDController4 = this.controller;
if (dTBAdMRAIDController4 != null) {
dTBAdMRAIDController4.onViewabilityChanged(false);
}
setIsVisible(false);
DtbLog.debug("SET MRAID Visible false because of scroll ");
} else if (Rect.intersects(rect2, rect3) && !this.isVisible) {
DTBAdMRAIDController dTBAdMRAIDController5 = this.controller;
if (dTBAdMRAIDController5 != null) {
dTBAdMRAIDController5.onViewabilityChanged(true);
}
setIsVisible(true);
DtbLog.debug("SET MRAID Visible true because of scroll ");
}
} else {
DTBAdMRAIDController dTBAdMRAIDController6 = this.controller;
if (dTBAdMRAIDController6 != null && !this.isVisible) {
dTBAdMRAIDController6.onViewabilityChanged(true);
}
setIsVisible(true);
}
}
if (this.isVisible) {
computeExposure();
}
}
void computeExposure() {
computeExposure(false);
}
public void computeExposure(boolean z) {
ScrollView scrollViewParent = getScrollViewParent();
if (scrollViewParent != null) {
computeExposureInScrollView(scrollViewParent, z);
return;
}
int[] iArr = new int[2];
getLocationInWindow(iArr);
Rect rect = new Rect(iArr[0], iArr[1], iArr[0] + getWidth(), iArr[1] + getHeight());
if (this.controller != null) {
computeExposureInRootView(z);
this.controller.onPositionChanged(rect);
}
}
void computeExposureInRootView() {
computeExposureInRootView(false);
}
void computeExposureInRootView(boolean z) {
View view = (View) getParent();
Activity activity = view != null ? DTBAdUtil.getActivity(view) : DTBAdUtil.getActivity(this);
if (activity == null) {
return;
}
ViewGroup viewGroup = (ViewGroup) activity.findViewById(android.R.id.content);
int[] iArr = new int[2];
viewGroup.getLocationInWindow(iArr);
Rect rect = new Rect(iArr[0], iArr[1], iArr[0] + viewGroup.getWidth(), iArr[1] + viewGroup.getHeight());
int[] iArr2 = new int[2];
getLocationOnScreen(iArr2);
Rect rect2 = new Rect(iArr2[0], iArr2[1], iArr2[0] + getWidth(), iArr2[1] + getHeight());
float width = getWidth() * getHeight();
if (rect2.intersect(rect)) {
Double.isNaN(r5);
double d = width;
Double.isNaN(d);
int i = (int) (((r5 * 100.0d) / d) + 0.5d);
if (i != this.exposurePercent || z) {
this.exposurePercent = i;
this.controller.fireExposureChange(i, rect2);
return;
}
return;
}
if (this.exposurePercent != 0 || z) {
this.exposurePercent = 0;
rect2.top = rect2.bottom;
this.controller.fireExposureChange(this.exposurePercent, rect2);
}
}
public long getStartTime() {
return this.startTime;
}
private ScrollView getScrollViewParent() {
View view = this;
while (true) {
Object parent = view.getParent();
if (!(parent instanceof ViewGroup)) {
return null;
}
if (parent instanceof ScrollView) {
return (ScrollView) parent;
}
view = (View) parent;
}
}
private void computeExposureInScrollView(ScrollView scrollView, boolean z) {
ViewGroup viewGroup = (ViewGroup) DTBAdUtil.getActivity((View) getParent()).findViewById(android.R.id.content);
int[] iArr = new int[2];
viewGroup.getLocationInWindow(iArr);
Rect rect = new Rect(iArr[0], iArr[1], iArr[0] + viewGroup.getWidth(), iArr[1] + viewGroup.getHeight());
int[] iArr2 = new int[2];
getLocationInWindow(iArr2);
float width = getWidth() * getHeight();
Rect rect2 = new Rect(iArr2[0], iArr2[1], iArr2[0] + getWidth(), iArr2[1] + getHeight());
if (scrollView == null) {
rect2.intersect(rect);
} else {
int[] iArr3 = new int[2];
scrollView.getLocationInWindow(iArr3);
Rect rect3 = new Rect(iArr3[0], iArr3[1], iArr3[0] + scrollView.getWidth(), iArr3[1] + scrollView.getHeight());
rect3.intersect(rect);
rect2.intersect(rect3);
}
int i = width != 0.0f ? (int) ((((rect2.right - rect2.left) * (rect2.bottom - rect2.top)) * 100.0f) / width) : 0;
if (i != this.exposurePercent || z) {
this.exposurePercent = i;
this.controller.fireExposureChange(i, rect2);
this.controller.setCurrentPositionProperty();
}
}
private void setIsVisible(boolean z) {
this.isVisible = z;
if (z) {
return;
}
this.exposurePercent = -1;
DTBAdMRAIDController dTBAdMRAIDController = this.controller;
if (dTBAdMRAIDController != null) {
dTBAdMRAIDController.fireExposureChange(0, new Rect(0, 0, 0, 0));
}
}
public void fetchAd(Map<String, Object> map) {
fetchAd((String) null, map);
}
public void fetchAd(String str, Map<String, Object> map) {
Bundle bundle = new Bundle();
for (Map.Entry<String, Object> entry : map.entrySet()) {
Object value = entry.getValue();
if (value instanceof String) {
bundle.putString(entry.getKey(), (String) value);
} else if (value instanceof Boolean) {
bundle.putBoolean(entry.getKey(), ((Boolean) value).booleanValue());
}
if (value instanceof Integer) {
bundle.putInt(entry.getKey(), ((Integer) value).intValue());
}
if (value instanceof Long) {
bundle.putLong(entry.getKey(), ((Long) value).longValue());
}
}
fetchAd(str, bundle);
}
public String getBidId() {
return this.bidId;
}
public String getHostname() {
return this.hostname;
}
public void fetchAd(String str) {
fetchAd(str, (Bundle) null);
}
public void fetchAd(Bundle bundle) {
fetchAd((String) null, bundle);
}
public void fetchAd(String str, Bundle bundle) {
if (str == null) {
str = bundle.getString(BID_HTML, null);
}
if (bundle != null) {
DTBAdMRAIDController dTBAdMRAIDController = this.controller;
if (dTBAdMRAIDController instanceof DTBAdMRAIDBannerController) {
DTBAdBannerListener dTBAdBannerListener = ((DTBAdMRAIDBannerController) dTBAdMRAIDController).bannerListener;
int i = bundle.getInt(EXPECTED_WIDTH, 0);
int i2 = bundle.getInt(EXPECTED_HEIGHT, 0);
if (i2 > 0 && i > 0 && (dTBAdBannerListener instanceof DTBExpectedSizeProvider)) {
DTBExpectedSizeProvider dTBExpectedSizeProvider = (DTBExpectedSizeProvider) dTBAdBannerListener;
dTBExpectedSizeProvider.setExpectedWidth(i);
dTBExpectedSizeProvider.setExpectedHeight(i2);
}
}
}
if (bundle != null) {
this.bidId = bundle.getString(BID_IDENTIFIER);
this.hostname = bundle.getString(HOSTNAME_IDENTIFIER);
}
this.startTime = new Date().getTime();
StringBuilder sb = new StringBuilder();
sb.append("<!DOCTYPE html><html><head>");
sb.append("<script>");
sb.append(getEnvironment(bundle));
sb.append("</script>");
loadLocalFile("aps-mraid", sb);
loadLocalFile("dtb-m", sb);
sb.append("</head>");
sb.append("<body style='margin:0;padding:0;'>");
sb.append(str);
sb.append("</body></html>");
loadDataWithBaseURL("https://c.amazon-adsystem.com/", sb.toString(), "text/html", C.UTF8_NAME, null);
}
public void fetchAdWithLocation(String str) {
StringBuilder sb = new StringBuilder();
sb.append("<script>");
sb.append(getEnvironment(null));
sb.append("</script>");
loadLocalFile("aps-mraid", sb);
sb.append("<script>");
sb.append("window.location=\"");
sb.append(str);
sb.append("\";");
sb.append("</script>");
loadDataWithBaseURL("https://c.amazon-adsystem.com/", sb.toString(), "text/html", C.UTF8_NAME, null);
}
@Override
public void evaluateJavascript(String str, ValueCallback<String> valueCallback) {
super.evaluateJavascript(str, valueCallback);
}
public class WebBridge {
Exception execException;
WebBridge() {
}
Exception getExecutionException() {
return this.execException;
}
@JavascriptInterface
public void postMessage(String str) {
try {
JSONObject jSONObject = new JSONObject(str);
if (jSONObject.has("type")) {
String string = jSONObject.getString("type");
if ("service".equals(string)) {
handleServiceCall(jSONObject);
return;
} else {
if ("mraid".equals(string)) {
handleMraidCommand(jSONObject);
return;
}
return;
}
}
DtbLog.error("Unrecognized bridge call");
} catch (JSONException e) {
DtbLog.debug(DTBAdView.LOG_TAG, "JSON conversion failed:" + e);
}
}
void handleServiceCall(JSONObject jSONObject) throws JSONException {
if ("log".equals(jSONObject.getString("subtype"))) {
logFromJavasScript(jSONObject.getJSONObject("arguments").getString(AvidVideoPlaybackListenerImpl.MESSAGE));
}
}
void handleMraidCommand(JSONObject jSONObject) throws JSONException {
this.execException = null;
String string = jSONObject.getString("subtype");
Class<MraidCommand> findMraidCommandByName = MraidCommand.findMraidCommandByName(string);
if (findMraidCommandByName == null) {
DtbLog.error("MRAID Command:" + string + " is not found");
DTBAdView.this.controller.fireErrorEvent(string, string + " is not supported");
DTBAdView.this.controller.commandCompleted(string);
return;
}
try {
MraidCommand newInstance = findMraidCommandByName.newInstance();
DtbLog.debug(DTBAdView.LOG_TAG, "execute command " + newInstance.getName());
newInstance.execute(jSONObject.getJSONObject("arguments"), DTBAdView.this.controller);
} catch (JSONException e) {
throw e;
} catch (Exception e2) {
this.execException = e2;
DtbLog.debug("Error execution command " + string + " " + e2.getLocalizedMessage());
}
}
private void logFromJavasScript(String str) {
DtbLog.debug("mraid:JSNative", str);
}
void echo(JSONObject jSONObject) {
try {
final String format = String.format("window.promiseResolve(%d, '%s');", Integer.valueOf(jSONObject.getInt("promiseId")), jSONObject.getJSONObject("arguments").getString("greeting") + " Returned");
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public final void run() {
DTBAdView.WebBridge.this.lambda$echo$0$DTBAdView$WebBridge(format);
}
});
} catch (JSONException e) {
DtbLog.debug(DTBAdView.LOG_TAG, "JSON conversion failed:" + e);
}
}
public void lambda$echo$0$DTBAdView$WebBridge(String str) {
DTBAdView.this.evaluateJavascript(str, null);
}
}
String getEnvironment(Bundle bundle) {
String string = bundle != null ? bundle.getString(AMAZON_AD_INFO) : null;
Context context = getContext();
String str = (String) context.getPackageManager().getApplicationLabel(context.getApplicationInfo());
String idfa = DtbSharedPreferences.getInstance().getIdfa();
if (DtbCommonUtils.isNullOrEmpty(idfa)) {
idfa = DtbDeviceDataRetriever.ORIENTATION_UNKNOWN;
}
boolean optOut = DtbSharedPreferences.getInstance().getOptOut();
if (optOut == null) {
optOut = false;
}
return string == null ? String.format(ENV_TEMPLATE, "3.0", DtbCommonUtils.getSDKMRAIDVersion(), io.bidmachine.ads.networks.amazon.BuildConfig.ADAPTER_SDK_VERSION_NAME, str, idfa, optOut, false) : String.format(ENV_TEMPLATE_INFO, "3.0", DtbCommonUtils.getSDKMRAIDVersion(), io.bidmachine.ads.networks.amazon.BuildConfig.ADAPTER_SDK_VERSION_NAME, str, idfa, optOut, false, string);
}
@Override
protected void onScrollChanged(int i, int i2, int i3, int i4) {
if (this.scrollEnabled) {
super.onScrollChanged(i, i2, i4, i3);
} else {
scrollTo(0, 0);
}
}
public DTBAdMRAIDController getController() {
return this.controller;
}
public void setScrollEnabled(boolean z) {
this.scrollEnabled = z;
setVerticalScrollBarEnabled(z);
setHorizontalScrollBarEnabled(z);
}
public void finalize() {
getViewTreeObserver().removeOnGlobalLayoutListener(this.globalLayoutListener);
getViewTreeObserver().removeOnScrollChangedListener(this.scrollChangeListener);
getViewTreeObserver().removeOnGlobalFocusChangeListener(this.focusChangeListener);
}
public void onAdRemoved() {
this.controller.onAdRemoved();
}
}