GoooBet v1.0版本的 MD5 值为:ff9748f16167bfd7735b669c0a9931c5

以下内容为反编译后的 DTBAdUtil.java 源代码,内容仅作参考


package com.amazon.device.ads;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RectShape;
import android.net.Uri;
import android.os.Bundle;
import android.os.Looper;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import com.amazon.device.ads.SDKUtilities;
import com.appodeal.ads.utils.LogConstants;
import com.google.android.gms.ads.doubleclick.PublisherAdRequest;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

public class DTBAdUtil {
    private static final String CUSTOM_EVENT = "amazon_custom_event";
    static final String LOG_TAG = DTBAdUtil.class.getSimpleName();
    public static final DTBAdUtil INSTANCE = new DTBAdUtil();

    private DTBAdUtil() {
    }

    public PublisherAdRequest loadDTBParams(PublisherAdRequest publisherAdRequest, DTBAdResponse dTBAdResponse) {
        if (dTBAdResponse.getAdCount() == 0) {
            return publisherAdRequest;
        }
        PublisherAdRequest.Builder builder = new PublisherAdRequest.Builder();
        builder.setManualImpressionsEnabled(publisherAdRequest.getManualImpressionsEnabled());
        if (publisherAdRequest.getBirthday() != null) {
            builder.setBirthday(publisherAdRequest.getBirthday());
        }
        if (publisherAdRequest.getContentUrl() != null) {
            builder.setContentUrl(publisherAdRequest.getContentUrl());
        }
        if (publisherAdRequest.getGender() != 0) {
            builder.setGender(publisherAdRequest.getGender());
        }
        if (publisherAdRequest.getKeywords() != null) {
            builder.setGender(publisherAdRequest.getGender());
        }
        if (publisherAdRequest.getLocation() != null) {
            builder.setLocation(publisherAdRequest.getLocation());
        }
        if (publisherAdRequest.getPublisherProvidedId() != null) {
            builder.setPublisherProvidedId(publisherAdRequest.getPublisherProvidedId());
        }
        loadDTBParameters(dTBAdResponse, builder);
        return builder.build();
    }

    public void loadDTBParams(PublisherAdRequest.Builder builder, DTBAdResponse dTBAdResponse) {
        if (dTBAdResponse.getAdCount() > 0) {
            loadDTBParameters(dTBAdResponse, builder);
        }
    }

    public PublisherAdRequest.Builder createPublisherAdRequestBuilder(DTBAdResponse dTBAdResponse) {
        PublisherAdRequest.Builder builder = new PublisherAdRequest.Builder();
        if (dTBAdResponse.getAdCount() > 0) {
            loadDTBParameters(dTBAdResponse, builder);
        }
        return builder;
    }

    private void loadDTBParameters(DTBAdResponse dTBAdResponse, PublisherAdRequest.Builder builder) {
        for (Map.Entry<String, List<String>> entry : dTBAdResponse.getDefaultDisplayAdsRequestCustomParams().entrySet()) {
            builder.addCustomTargeting(entry.getKey(), entry.getValue());
        }
    }

    public static List<View> findViewsOfType(ViewGroup viewGroup, Class cls) {
        ArrayList arrayList = new ArrayList();
        findViewsOfType(viewGroup, cls, arrayList);
        return arrayList;
    }

    public static View findAncestorOfType(View view, Class cls) {
        while (!cls.isInstance(view)) {
            Object parent = view.getParent();
            if (parent == null || !(parent instanceof View)) {
                return null;
            }
            view = (View) parent;
        }
        return view;
    }

    static void findViewsOfType(ViewGroup viewGroup, Class cls, List<View> list) {
        int childCount = viewGroup.getChildCount();
        for (int i = 0; i < childCount; i++) {
            View childAt = viewGroup.getChildAt(i);
            if (cls.isInstance(childAt)) {
                list.add(childAt);
            }
            if (childAt instanceof ViewGroup) {
                findViewsOfType((ViewGroup) childAt, cls, list);
            }
        }
    }

    public static String buildMopubTargeting(String str, Map<String, String> map) {
        StringBuilder sb = new StringBuilder(str);
        if (map != null) {
            for (Map.Entry<String, String> entry : map.entrySet()) {
                sb.append(",");
                sb.append(entry.getKey());
                sb.append(':');
                sb.append(entry.getValue());
            }
        }
        DtbLog.debug(LOG_TAG, "Targeting String:" + sb.toString());
        return sb.toString();
    }

    public static boolean isInstalledFromAppStore(Context context) {
        String installerPackageName = context.getPackageManager().getInstallerPackageName(context.getPackageName());
        return installerPackageName != null && installerPackageName.length() > 0;
    }

    public static Activity getActivity(View view) {
        for (Context context = view.getContext(); context instanceof ContextWrapper; context = ((ContextWrapper) context).getBaseContext()) {
            if (context instanceof Activity) {
                return (Activity) context;
            }
        }
        return null;
    }

    public static int sizeToDevicePixels(int i) {
        return (int) ((i * AdRegistration.getContext().getResources().getDisplayMetrics().density) + 0.5f);
    }

    static int sizeToDevicePixels(Context context, int i) {
        return (int) ((i * context.getResources().getDisplayMetrics().density) + 0.5f);
    }

    public static int pixelsToDeviceIndependenPixels(int i) {
        return (int) ((i / AdRegistration.getContext().getResources().getDisplayMetrics().density) + 0.5f);
    }

    public static ViewGroup getRootView(View view) {
        Activity activity = getActivity(view);
        if (activity == null) {
            return null;
        }
        return (ViewGroup) activity.findViewById(android.R.id.content);
    }

    public static SDKUtilities.SimpleSize getMaxSize(View view) {
        ViewGroup rootView = getRootView(view);
        if (rootView == null) {
            return getScreenSize();
        }
        return new SDKUtilities.SimpleSize(pixelsToDeviceIndependenPixels(rootView.getWidth()), pixelsToDeviceIndependenPixels(rootView.getHeight()));
    }

    public static SDKUtilities.SimpleSize getScreenSize() {
        return getScreenSize(null);
    }

    public static SDKUtilities.SimpleSize getScreenSize(View view) {
        int i;
        int i2;
        int i3 = AdRegistration.getContext().getResources().getConfiguration().orientation;
        Activity activity = view != null ? getActivity(view) : null;
        if (activity != null) {
            Point point = new Point();
            activity.getWindowManager().getDefaultDisplay().getRealSize(point);
            i2 = point.x;
            i = point.y;
        } else {
            DisplayMetrics displayMetrics = new DisplayMetrics();
            ((WindowManager) AdRegistration.getContext().getSystemService("window")).getDefaultDisplay().getMetrics(displayMetrics);
            int i4 = displayMetrics.widthPixels;
            i = displayMetrics.heightPixels;
            i2 = i4;
        }
        int pixelsToDeviceIndependenPixels = pixelsToDeviceIndependenPixels(i2);
        int pixelsToDeviceIndependenPixels2 = pixelsToDeviceIndependenPixels(i);
        if (i3 == 1) {
            return new SDKUtilities.SimpleSize(pixelsToDeviceIndependenPixels, pixelsToDeviceIndependenPixels2);
        }
        return new SDKUtilities.SimpleSize(pixelsToDeviceIndependenPixels2, pixelsToDeviceIndependenPixels);
    }

    public static void setRectShape(View view) {
        setRectShape(view, -16711936, 3.0f);
    }

    public static void setRectShape(View view, int i, float f) {
        ShapeDrawable shapeDrawable = new ShapeDrawable();
        shapeDrawable.setShape(new RectShape());
        shapeDrawable.getPaint().setColor(i);
        shapeDrawable.getPaint().setStrokeWidth(f);
        shapeDrawable.getPaint().setStyle(Paint.Style.STROKE);
        view.setBackground(shapeDrawable);
    }

    public static Bundle getBidFromFetchManager(Bundle bundle) {
        DTBFetchManager fetchManager;
        if (bundle == null) {
            return null;
        }
        boolean z = bundle.getBoolean(DTBAdView.SMARTBANNER_STATE, false);
        String string = bundle.getString(DTBAdView.REQUEST_QUEUE, null);
        if (!DtbCommonUtils.isNullOrEmpty(string) && (fetchManager = DTBFetchFactory.getInstance().getFetchManager(string)) != null) {
            DtbLog.debug("RELOAD CUSTOM EVENT", "QUEUE:" + string);
            DTBAdResponse peek = fetchManager.peek();
            if (peek != null) {
                DtbLog.debug("RELOAD CUSTOM EVENT: " + peek.getRenderingBundle().getString(DTBAdView.AMAZON_AD_INFO));
                return peek.getRenderingBundle(z);
            }
        }
        DtbLog.debug("RELOAD CUSTOM EVENT", "NO QUEUE");
        return bundle;
    }

    public static boolean validateAdMobCustomEvent(String str, Bundle bundle) {
        DtbLog.debug(CUSTOM_EVENT, "Amazon Custom Event was hit with server parameter:" + str);
        if (bundle != null) {
            String string = bundle.getString(DTBAdView.EVENT_SERVER_PARAMETER, LogConstants.KEY_UNKNOWN);
            String string2 = bundle.getString(DTBAdView.BID_HTML, null);
            if (string != null && str != null && str.equals(string) && string2 != null) {
                String string3 = bundle.getString(DTBAdView.BID_IDENTIFIER, null);
                String string4 = bundle.getString(DTBAdView.HOSTNAME_IDENTIFIER, null);
                if (string3 != null && DTBBidInspector.getInstance().wasUsed(string3)) {
                    DtbLog.debug(CUSTOM_EVENT, "Amazon Banner Custom Event ignored (attempt to reuse bidId)");
                } else {
                    long j = bundle.getLong(DTBAdView.START_LOAD_TIME);
                    if (j > 0) {
                        DTBMetricsProcessor.getInstance().submitLatencyReportBidId(DTBMetricReport.addBid(string3, string4), DTBMetricsProcessor.REPORT_MEDIATION_LATENCY, (int) (new Date().getTime() - j));
                    }
                    DtbLog.debug(CUSTOM_EVENT, "Amazon Banner Custom Completed/Accepted");
                    return true;
                }
            } else if (string == null) {
                DtbLog.debug(CUSTOM_EVENT, "Amazon Banner Custom Event ignored (expected server parameter is null");
            } else if (str == null) {
                DtbLog.debug(CUSTOM_EVENT, "Amazon Banner Custom Event ignored (server parameter is null");
            } else if (!str.equals(string)) {
                DtbLog.debug(CUSTOM_EVENT, "Amazon Banner Custom Event ignored (server " + str + " is not equal to expected parameter " + string + ")");
            } else if (string2 == null) {
                DtbLog.debug(CUSTOM_EVENT, "Amazon Banner Custom Event ignored (payload is not defined)");
            }
        }
        DtbLog.debug(CUSTOM_EVENT, "Amazon Banner Custom Event Completed/Ignored ");
        return false;
    }

    public static boolean validateMopubCustomEvent(Map<String, Object> map, Map<String, String> map2) {
        DtbLog.debug(CUSTOM_EVENT, "Amazon Banner Custom Event was hit");
        String str = (String) map.get(DTBAdView.EVENT_SERVER_PARAMETER);
        if (str != null) {
            if (map2.get(str) != null) {
                String str2 = (String) map.get(DTBAdView.BID_IDENTIFIER);
                String str3 = (String) map.get(DTBAdView.BID_HTML);
                String str4 = (String) map.get(DTBAdView.HOSTNAME_IDENTIFIER);
                if (str3 != null) {
                    if (str2 != null && DTBBidInspector.getInstance().wasUsed(str2)) {
                        DtbLog.debug(CUSTOM_EVENT, "Amazon Banner Custom ignored (attempt to reuse bidId)");
                        return false;
                    }
                    Object obj = map.get(DTBAdView.START_LOAD_TIME);
                    if (obj instanceof Long) {
                        Long l = (Long) obj;
                        if (l.longValue() > 0) {
                            DTBMetricsProcessor.getInstance().submitLatencyReportBidId(DTBMetricReport.addBid(str2, str4), DTBMetricsProcessor.REPORT_MEDIATION_LATENCY, (int) (new Date().getTime() - l.longValue()));
                        }
                    }
                    DtbLog.debug(CUSTOM_EVENT, "Amazon Banner Custom Completed/Accepted");
                    return true;
                }
                DtbLog.debug(CUSTOM_EVENT, "Amazon Banner Custom ignored ( payload is not defined ");
            } else {
                DtbLog.debug(CUSTOM_EVENT, "Amazon Banner Custom ignored ( serverExtras does not have expected key event_server_parameter)");
            }
        } else {
            DtbLog.debug(CUSTOM_EVENT, "Amazon Banner Custom ignored ( localExtras does not have expected key event_server_parameter)");
        }
        DtbLog.debug(CUSTOM_EVENT, "Amazon Banner Custom Completed/Ignored");
        return false;
    }

    public static boolean isMainThread() {
        return Looper.myLooper() == Looper.getMainLooper();
    }

    public static ViewGroup getAdViewWrapper(View view, int i, int i2, int i3, int i4) {
        AdContainer adContainer = new AdContainer(view.getContext());
        if (i4 != 0 && i3 != 0) {
            adContainer.addView(view, sizeToDevicePixels(i3), sizeToDevicePixels(i4));
        } else {
            adContainer.addView(view, sizeToDevicePixels(i), sizeToDevicePixels(i2));
        }
        adContainer.setAdView(view);
        return adContainer;
    }

    public static void directAppStoreLinkToBrowser(DTBAdMRAIDController dTBAdMRAIDController, Uri uri) throws ActivityNotFoundException {
        String str;
        if ("amzn".equals(uri.getScheme())) {
            DtbLog.debug(LOG_TAG, "Amazon app store unavailable in the device");
            str = "https://www.amazon.com/gp/mas/dl/android?" + uri.getQuery();
        } else {
            DtbLog.debug(LOG_TAG, "App store unavailable in the device");
            str = "https://play.google.com/store/apps/" + uri.getHost() + "?" + uri.getQuery();
        }
        Uri parse = Uri.parse(str);
        Intent intent = new Intent("android.intent.action.VIEW");
        intent.setData(parse);
        AdRegistration.getCurrentActivity().startActivity(intent);
        dTBAdMRAIDController.onAdLeftApplication();
    }

    public static synchronized String loadFile(String str, String str2) throws IOException {
        synchronized (DTBAdUtil.class) {
            Context context = AdRegistration.getContext();
            if (context == null) {
                return null;
            }
            File file = new File(context.getFilesDir().getAbsolutePath() + "/" + str2 + "/" + str);
            if (!file.exists()) {
                return null;
            }
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
            StringBuilder sb = new StringBuilder();
            while (true) {
                String readLine = bufferedReader.readLine();
                if (readLine != null) {
                    sb.append(readLine.trim());
                    sb.append("\n");
                } else {
                    return sb.toString();
                }
            }
        }
    }

    public static void createDirIfDoesNotExist(String str) {
        Context context = AdRegistration.getContext();
        if (context != null) {
            File file = new File(context.getFilesDir().getAbsolutePath() + "/" + str);
            if (file.isDirectory() || file.exists()) {
                return;
            }
            file.mkdir();
        }
    }

    public static String loadFromAssets(String str) throws IOException {
        StringBuilder sb = new StringBuilder();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(AdRegistration.getContext().getAssets().open(str)));
        while (true) {
            String readLine = bufferedReader.readLine();
            if (readLine != null) {
                sb.append(readLine.trim());
                sb.append("\n");
            } else {
                return sb.toString();
            }
        }
    }
}