导航菜单

页面标题

页面副标题

CallApp v2.226 - MRAIDView.java 源代码

正在查看: CallApp v2.226 应用的 MRAIDView.java JAVA 源代码文件

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


package net.pubnative.lite.sdk.mraid;

import a1.d0;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.location.Location;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Base64;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.ClientCertRequest;
import android.webkit.ConsoleMessage;
import android.webkit.HttpAuthHandler;
import android.webkit.JsPromptResult;
import android.webkit.JsResult;
import android.webkit.PermissionRequest;
import android.webkit.RenderProcessGoneDetail;
import android.webkit.SslErrorHandler;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebStorage;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.applovin.impl.j8;
import com.iab.omid.library.pubnativenet.adsession.FriendlyObstructionPurpose;
import io.bidmachine.iab.mraid.f;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import net.pubnative.lite.sdk.CountdownStyle;
import net.pubnative.lite.sdk.DeviceInfo;
import net.pubnative.lite.sdk.HyBid;
import net.pubnative.lite.sdk.analytics.Reporting;
import net.pubnative.lite.sdk.core.R;
import net.pubnative.lite.sdk.location.HyBidLocationManager;
import net.pubnative.lite.sdk.models.RemoteConfigFeature;
import net.pubnative.lite.sdk.mraid.internal.MRAIDHtmlProcessor;
import net.pubnative.lite.sdk.mraid.internal.MRAIDLog;
import net.pubnative.lite.sdk.mraid.internal.MRAIDNativeFeatureManager;
import net.pubnative.lite.sdk.mraid.properties.MRAIDOrientationProperties;
import net.pubnative.lite.sdk.mraid.properties.MRAIDResizeProperties;
import net.pubnative.lite.sdk.utils.Logger;
import net.pubnative.lite.sdk.utils.svgparser.utils.SVGParserImpl;
import net.pubnative.lite.sdk.viewability.HyBidViewabilityFriendlyObstruction;
import net.pubnative.lite.sdk.viewability.HyBidViewabilityWebAdSession;
import net.pubnative.lite.sdk.views.PNWebView;
import net.pubnative.lite.sdk.vpaid.enums.EventConstants;
import net.pubnative.lite.sdk.vpaid.helpers.BitmapHelper;
import net.pubnative.lite.sdk.vpaid.helpers.SimpleTimer;
import net.pubnative.lite.sdk.vpaid.widget.CountDownView;
import net.pubnative.lite.sdk.vpaid.widget.CountDownViewFactory;
import org.json.JSONException;
import org.json.JSONObject;

public class MRAIDView extends FrameLayout {
    private static final int CLOSE_REGION_SIZE = 50;
    private static final int LANDING_PAGE_CLOSE_DELAY = 30000;
    private static final String MRAID_LOG_TAG = "MRAIDView";
    private static final String MRAID_VERSION = "3.0";
    public static final int STATE_DEFAULT = 1;
    public static final int STATE_EXPANDED = 2;
    public static final int STATE_HIDDEN = 4;
    public static final int STATE_LOADING = 0;
    public static final int STATE_RESIZED = 3;
    private int activityInitialOrientation;
    private final String baseUrl;
    private MRAIDViewCloseLayoutListener closeLayoutListener;
    private ImageButton closeRegion;
    private final ViewGroup contentInfo;
    private boolean contentInfoAdded;
    private int contentViewTop;
    private final Context context;
    private Rect currentPosition;
    private WebView currentWebView;
    private Rect defaultPosition;
    private final DisplayMetrics displayMetrics;
    private RelativeLayout expandedView;
    private final GestureDetector gestureDetector;
    protected final Handler handler;
    private final int injections;
    private boolean isActionBarShowing;
    private Boolean isBackClickable;
    private boolean isClosing;
    private final boolean isExpandEnabled;
    private boolean isExpanded;
    private boolean isExpandingFromDefault;
    private boolean isExpandingPart2;
    private boolean isFinalPage;
    private boolean isForceNotFullScreen;
    private boolean isForcingFullScreen;
    private boolean isFullScreen;
    private final boolean isInterstitial;
    protected boolean isLaidOut;
    private boolean isLandingPageEnabled;
    protected boolean isPageFinished;
    protected boolean isViewabilityConfirmed;
    protected boolean isViewable;
    private String landingBehaviourString;
    private Integer landingPageDelay;
    protected final MRAIDViewListener listener;
    private SimpleTimer mAntilockTimer;
    private Integer mClickCounter;
    private SimpleTimer mExpirationTimer;
    private boolean mIsExpanding;
    private Integer mNativeCloseButtonDelay;
    private SimpleTimer mNativeCloseButtonTimer;
    private CountDownView mSkipCountdownView;
    private Integer mSkipTimeMillis;
    private HyBidViewabilityWebAdSession mViewabilityAdSession;
    private final List<HyBidViewabilityFriendlyObstruction> mViewabilityFriendlyObstructions;
    private final Size maxSize;
    private String mraidJs;
    private final MRAIDWebChromeClient mraidWebChromeClient;
    private final MRAIDWebViewClient mraidWebViewClient;
    private final MRAIDNativeFeatureListener nativeFeatureListener;
    private final MRAIDNativeFeatureManager nativeFeatureManager;
    private final MRAIDOrientationProperties orientationProperties;
    private int origTitleBarVisibility;
    private final int originalRequestedOrientation;
    private final MRAIDResizeProperties resizeProperties;
    private RelativeLayout resizedView;
    private final Size screenSize;
    private String setCustomisationString;
    private Activity showActivity;
    private final Boolean showTimerBeforeEndCard;
    protected int state;
    private View titleBar;
    private boolean useCustomClose;
    private boolean wasTouched;
    protected final WebView webView;
    private boolean webViewLoaded;
    private WebView webViewPart2;
    private static final CountdownStyle COUNTDOWN_STYLE_DEFAULT = CountdownStyle.PIE_CHART;
    private static final String[] COMMANDS_WITH_NO_PARAM = {EventConstants.CLOSE, "resize"};
    private static final String[] COMMANDS_WITH_STRING = {"createCalendarEvent", "expand", "open", "playVideo", MRAIDNativeFeature.STORE_PICTURE, "useCustomClose"};
    private static final String[] COMMANDS_WITH_MAP = {"setOrientationProperties", "setResizeProperties"};

    @Retention(RetentionPolicy.SOURCE)
    public @interface MRAIDState {
    }

    public class MRAIDWebChromeClient extends WebChromeClient {
        public MRAIDWebChromeClient(MRAIDView mRAIDView, int i) {
            this();
        }

        private boolean handlePopups(JsResult jsResult) {
            jsResult.cancel();
            return true;
        }

        @Override
        public void onCloseWindow(WebView webView) {
            MRAIDLog.d("hz-m MRAIDView ChromeClient - onCloseWindow");
        }

        @Override
        public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
            String str;
            if (consoleMessage == null || consoleMessage.message() == null) {
                return false;
            }
            StringBuilder sb = new StringBuilder();
            sb.append(consoleMessage.message());
            if (consoleMessage.sourceId() == null) {
                str = "";
            } else {
                str = " at " + consoleMessage.sourceId();
            }
            sb.append(str);
            sb.append(":");
            sb.append(consoleMessage.lineNumber());
            MRAIDLog.i("JS console", sb.toString());
            return true;
        }

        @Override
        public void onExceededDatabaseQuota(String str, String str2, long j, long j2, long j3, WebStorage.QuotaUpdater quotaUpdater) {
            MRAIDLog.d("hz-m MRAIDView WebViewClient - onExceededDatabaseQuota");
            quotaUpdater.updateQuota(j);
        }

        @Override
        public boolean onJsAlert(WebView webView, String str, String str2, JsResult jsResult) {
            MRAIDLog.d("JS alert", str2);
            return handlePopups(jsResult);
        }

        @Override
        public boolean onJsBeforeUnload(WebView webView, String str, String str2, JsResult jsResult) {
            MRAIDLog.d("hz-m MRAIDView ChromeClient - onJsBeforeUnload");
            return true;
        }

        @Override
        public boolean onJsConfirm(WebView webView, String str, String str2, JsResult jsResult) {
            MRAIDLog.d("JS confirm", str2);
            return handlePopups(jsResult);
        }

        @Override
        public boolean onJsPrompt(WebView webView, String str, String str2, String str3, JsPromptResult jsPromptResult) {
            MRAIDLog.d("JS prompt", str2);
            return handlePopups(jsPromptResult);
        }

        @Override
        public boolean onJsTimeout() {
            MRAIDLog.d("hz-m MRAIDView WebViewClient - onJsTimeout");
            return true;
        }

        @Override
        public void onPermissionRequest(PermissionRequest permissionRequest) {
            MRAIDLog.d("hz-m MRAIDView WebViewClient - onPermissionRequest");
        }

        @Override
        public void onProgressChanged(WebView webView, int i) {
            StringBuilder w = d0.w(i, "hz-m MRAIDView ChromeClient - onProgressChanged ", " wv: ");
            w.append(MRAIDView.this.webView);
            w.append(" view: ");
            w.append(MRAIDView.this);
            MRAIDLog.d(w.toString());
        }

        public void onReachedMaxAppCacheSize(long j, long j2, WebStorage.QuotaUpdater quotaUpdater) {
            MRAIDLog.d("hz-m MRAIDView WebViewClient - onReachedMaxAppCacheSize");
            quotaUpdater.updateQuota(j2);
        }

        @Override
        public void onShowCustomView(View view, WebChromeClient.CustomViewCallback customViewCallback) {
            MRAIDLog.d("hz-m MRAIDView ChromeClient - showCustomView");
        }

        private MRAIDWebChromeClient() {
        }
    }

    public class MRAIDWebViewClient extends WebViewClient {
        public MRAIDWebViewClient(MRAIDView mRAIDView, int i) {
            this();
        }

        public void lambda$onPageFinished$1() {
            MRAIDView mRAIDView = MRAIDView.this;
            StringBuilder sb = new StringBuilder("mraid.setPlacementType('");
            sb.append(MRAIDView.this.isInterstitial ? RemoteConfigFeature.AdFormat.INTERSTITIAL : "inline");
            sb.append("');");
            mRAIDView.injectJavaScript(sb.toString());
            MRAIDView.this.setSupportedServices();
            MRAIDView.this.setEnvironmentVariables();
            MRAIDView.this.setLocation();
            MRAIDView.this.setScreenSize();
            MRAIDView.this.setDefaultPosition();
            MRAIDLog.d(MRAIDView.MRAID_LOG_TAG, "calling fireStateChangeEvent 2");
            MRAIDView.this.fireStateChangeEvent();
            MRAIDView.this.fireReadyEvent();
            MRAIDView mRAIDView2 = MRAIDView.this;
            mRAIDView2.setViewable(mRAIDView2.isViewable ? 0 : 8);
        }

        public void lambda$shouldInterceptRequest$2() {
            MRAIDView.injectJavaScript(MRAIDView.this.webView, "mraid.logLevel = mraid.LogLevelEnum.DEBUG;");
        }

        @Override
        public void onPageCommitVisible(WebView webView, String str) {
            MRAIDLog.d("hz-m MRAIDView WebViewClient - onPageCommitVisibile");
        }

        @Override
        public void onPageFinished(WebView webView, String str) {
            super.onPageFinished(webView, str);
            if (MRAIDView.this.hasLandingPage()) {
                MRAIDView.this.handleSetCustomisationInjection();
            }
            MRAIDView.this.cancelAntilockTimer();
            MRAIDLog.d(MRAIDView.MRAID_LOG_TAG, "onPageFinished: " + str);
            MRAIDView mRAIDView = MRAIDView.this;
            if (mRAIDView.state == 0) {
                mRAIDView.isPageFinished = true;
                boolean z = mRAIDView.isExpandEnabled;
                String str2 = RemoteConfigFeature.AdFormat.INTERSTITIAL;
                if (z) {
                    MRAIDView mRAIDView2 = MRAIDView.this;
                    StringBuilder sb = new StringBuilder("mraid.setPlacementType('");
                    if (!MRAIDView.this.isInterstitial) {
                        str2 = "inline";
                    }
                    sb.append(str2);
                    sb.append("');");
                    mRAIDView2.injectJavaScript(sb.toString());
                } else {
                    MRAIDView mRAIDView3 = MRAIDView.this;
                    StringBuilder sb2 = new StringBuilder("mraid.setPlacementType('");
                    if (!MRAIDView.this.isInterstitial) {
                        str2 = "";
                    }
                    sb2.append(str2);
                    sb2.append("');");
                    mRAIDView3.injectJavaScript(sb2.toString());
                }
                MRAIDView.this.setEnvironmentVariables();
                MRAIDView.this.setSupportedServices();
                MRAIDView.this.setLocation();
                MRAIDView mRAIDView4 = MRAIDView.this;
                if (mRAIDView4.isLaidOut) {
                    mRAIDView4.setScreenSize();
                    MRAIDView.this.setMaxSize();
                    MRAIDView.this.setCurrentPosition();
                    MRAIDView.this.setDefaultPosition();
                    if (MRAIDView.this.isInterstitial) {
                        MRAIDView mRAIDView5 = MRAIDView.this;
                        mRAIDView5.showAsInterstitial(mRAIDView5.showActivity, Boolean.FALSE, null);
                    } else {
                        MRAIDView mRAIDView6 = MRAIDView.this;
                        mRAIDView6.state = 1;
                        mRAIDView6.fireStateChangeEvent();
                        MRAIDView.this.fireReadyEvent();
                        MRAIDView mRAIDView7 = MRAIDView.this;
                        mRAIDView7.setViewable(mRAIDView7.isViewable ? 0 : 8);
                    }
                }
                if (!MRAIDView.this.isInterstitial) {
                    MRAIDView mRAIDView8 = MRAIDView.this;
                    mRAIDView8.addContentInfo(mRAIDView8);
                }
                MRAIDView mRAIDView9 = MRAIDView.this;
                if (mRAIDView9.listener != null && !mRAIDView9.webViewLoaded) {
                    if (MRAIDView.this.mViewabilityAdSession != null) {
                        MRAIDView.this.mViewabilityAdSession.initAdSession(webView, false);
                        if (MRAIDView.this.contentInfo != null && MRAIDView.this.contentInfoAdded) {
                            MRAIDView mRAIDView10 = MRAIDView.this;
                            mRAIDView10.addViewabilityFriendlyObstruction(mRAIDView10.contentInfo, FriendlyObstructionPurpose.OTHER, "Content info description for the ad");
                            if (MRAIDView.this.mViewabilityFriendlyObstructions != null) {
                                for (HyBidViewabilityFriendlyObstruction hyBidViewabilityFriendlyObstruction : MRAIDView.this.mViewabilityFriendlyObstructions) {
                                    if (MRAIDView.this.mViewabilityAdSession != null) {
                                        MRAIDView.this.mViewabilityAdSession.addFriendlyObstruction(hyBidViewabilityFriendlyObstruction.getView(), hyBidViewabilityFriendlyObstruction.getPurpose(), hyBidViewabilityFriendlyObstruction.getReason());
                                    }
                                }
                            }
                        }
                        MRAIDView.this.webViewLoaded = true;
                        if (MRAIDView.this.mViewabilityAdSession != null) {
                            MRAIDView.this.mViewabilityAdSession.fireLoaded();
                            MRAIDView.this.mViewabilityAdSession.fireImpression();
                        }
                    }
                    MRAIDView mRAIDView11 = MRAIDView.this;
                    mRAIDView11.listener.mraidViewLoaded(mRAIDView11);
                    MRAIDView.this.mSkipCountdownView = new CountDownViewFactory().createCountdownView(MRAIDView.this.context, MRAIDView.COUNTDOWN_STYLE_DEFAULT, MRAIDView.this);
                    MRAIDView mRAIDView12 = MRAIDView.this;
                    mRAIDView12.addView(mRAIDView12.mSkipCountdownView);
                    MRAIDView.this.mSkipCountdownView.setVisibility(8);
                    MRAIDView mRAIDView13 = MRAIDView.this;
                    mRAIDView13.postDelayed(new c(mRAIDView13, 0), 500L);
                }
            }
            if (MRAIDView.this.isExpandingPart2) {
                MRAIDView.this.isExpandingPart2 = false;
                MRAIDView.this.handler.post(new d(this, 0));
            }
        }

        @Override
        public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
            MRAIDLog.d("hz-m MRAIDView WebViewClient - onPageStarted");
        }

        @Override
        public void onReceivedClientCertRequest(WebView webView, ClientCertRequest clientCertRequest) {
            MRAIDLog.d("hz-m MRAIDView WebViewClient - onReceivedClientCertRequest");
        }

        @Override
        public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) {
            MRAIDLog.d("hz-m MRAIDView WebViewClient - onReceivedError code: " + webResourceError.getErrorCode());
            MRAIDLog.d("hz-m MRAIDView WebViewClient - onReceivedError: " + ((Object) webResourceError.getDescription()));
        }

        @Override
        public void onReceivedHttpAuthRequest(WebView webView, HttpAuthHandler httpAuthHandler, String str, String str2) {
            MRAIDLog.d("hz-m MRAIDView WebViewClient - onReceivedHttpAuthRequest");
            httpAuthHandler.cancel();
        }

        @Override
        public void onReceivedHttpError(WebView webView, WebResourceRequest webResourceRequest, WebResourceResponse webResourceResponse) {
            MRAIDLog.d("hz-m MRAIDView WebViewClient - onReceivedHttpError");
        }

        @Override
        public void onReceivedLoginRequest(WebView webView, String str, String str2, String str3) {
            MRAIDLog.d("hz-m MRAIDView WebViewClient - onReceivedLoginRequest");
        }

        @Override
        public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
            MRAIDLog.d("hz-m MRAIDView WebViewClient - onReceivedSslError");
            if (sslErrorHandler != null) {
                sslErrorHandler.cancel();
            }
        }

        @Override
        public boolean onRenderProcessGone(WebView webView, RenderProcessGoneDetail renderProcessGoneDetail) {
            MRAIDLog.d("hz-m MRAIDView WebViewClient - onRenderProcessGone");
            MRAIDView mRAIDView = MRAIDView.this;
            MRAIDViewListener mRAIDViewListener = mRAIDView.listener;
            if (mRAIDViewListener == null) {
                return true;
            }
            mRAIDViewListener.mraidViewError(mRAIDView);
            return true;
        }

        @Override
        public void onScaleChanged(WebView webView, float f, float f2) {
            MRAIDLog.d("hz-m MRAIDView WebViewClient - onScaleChanged");
        }

        @Override
        public void onTooManyRedirects(WebView webView, Message message, Message message2) {
            message.sendToTarget();
            MRAIDLog.d("hz-m MRAIDView WebViewClient - onTooManyRedirects");
        }

        @Override
        public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
            if (webResourceRequest != null && webResourceRequest.getUrl() != null) {
                String uri = webResourceRequest.getUrl().toString();
                MRAIDLog.d("hz-m shouldInterceptRequest - " + uri);
                if (uri.contains("mraid.js")) {
                    MRAIDLog.d("hz-m shouldInterceptRequest - intercepting mraid - ".concat(uri));
                    MRAIDView.this.handler.post(new d(this, 1));
                    return new WebResourceResponse("application/javascript", "UTF-8", MRAIDView.this.getMraidJsStream());
                }
            }
            return super.shouldInterceptRequest(webView, webResourceRequest);
        }

        @Override
        public boolean shouldOverrideKeyEvent(WebView webView, KeyEvent keyEvent) {
            MRAIDLog.d("hz-m MRAIDView WebViewClient - shouldOverrideKeyEvent");
            return false;
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView webView, String str) {
            MRAIDLog.d(MRAIDView.MRAID_LOG_TAG, "shouldOverrideUrlLoading: " + str);
            if (MRAIDView.this.isFinalPage) {
                MRAIDView.this.cancelLandingPageBehaviour();
            }
            if (str.startsWith("mraid://")) {
                MRAIDView.this.parseCommandUrl(str);
                return true;
            }
            if (str.startsWith("verveadexperience://")) {
                if (MRAIDView.this.isLandingPageEnabled) {
                    MRAIDView.this.parseAdExperienceUrl(str);
                    return true;
                }
            } else {
                if (MRAIDView.this.hasLandingPage() && !MRAIDView.this.isFinalPage) {
                    return false;
                }
                if (MRAIDView.this.isVerveCustomExpand(str)) {
                    MRAIDView.N(MRAIDView.this, str);
                    return true;
                }
                if (MRAIDView.this.isCloseSignal(str)) {
                    MRAIDView.this.closeOnMainThread();
                    return true;
                }
                if (MRAIDView.this.mIsExpanding) {
                    MRAIDView.this.mIsExpanding = false;
                    return false;
                }
                try {
                    MRAIDView.this.open(URLEncoder.encode(str, "UTF-8"));
                    return true;
                } catch (UnsupportedEncodingException e) {
                    Logger.e(MRAIDView.MRAID_LOG_TAG, e.getMessage());
                }
            }
            return true;
        }

        private MRAIDWebViewClient() {
        }

        @Override
        public void onReceivedError(WebView webView, int i, String str, String str2) {
            MRAIDLog.d(MRAIDView.MRAID_LOG_TAG, "onReceivedError: " + str);
            super.onReceivedError(webView, i, str, str2);
        }
    }

    public interface OnExpandCreativeFailListener {
        void onExpandFailed();
    }

    public static class Size {
        public int height;
        public int width;

        public Size(int i) {
            this();
        }

        private Size() {
        }
    }

    public MRAIDView(Context context, String str, String str2, Boolean bool, String[] strArr, MRAIDViewListener mRAIDViewListener, MRAIDNativeFeatureListener mRAIDNativeFeatureListener, ViewGroup viewGroup, boolean z, boolean z2) {
        super(context);
        this.mSkipTimeMillis = -1;
        this.mNativeCloseButtonDelay = -1;
        int i = 0;
        this.mClickCounter = 0;
        this.isBackClickable = Boolean.FALSE;
        this.landingPageDelay = Integer.valueOf(LANDING_PAGE_CLOSE_DELAY);
        this.isFinalPage = false;
        this.activityInitialOrientation = -1;
        this.wasTouched = false;
        this.contentInfoAdded = false;
        this.webViewLoaded = false;
        this.isViewabilityConfirmed = false;
        this.mIsExpanding = false;
        this.injections = 0;
        this.context = context;
        if (context instanceof Activity) {
            Activity activity = (Activity) context;
            this.showActivity = activity;
            this.activityInitialOrientation = activity.getRequestedOrientation();
        }
        String str3 = (str == null || str.isEmpty()) ? "https://example.com" : str;
        this.baseUrl = str3;
        this.isInterstitial = z;
        this.isExpandEnabled = z2;
        this.contentInfo = viewGroup;
        this.state = 0;
        this.isViewable = false;
        this.useCustomClose = false;
        this.orientationProperties = new MRAIDOrientationProperties();
        this.resizeProperties = new MRAIDResizeProperties();
        this.nativeFeatureManager = new MRAIDNativeFeatureManager(context, new ArrayList(Arrays.asList(strArr)));
        this.listener = mRAIDViewListener;
        this.nativeFeatureListener = mRAIDNativeFeatureListener;
        this.showTimerBeforeEndCard = bool;
        WindowManager windowManager = (WindowManager) context.getSystemService("window");
        if (windowManager != null) {
            DisplayMetrics displayMetrics = new DisplayMetrics();
            this.displayMetrics = displayMetrics;
            windowManager.getDefaultDisplay().getMetrics(displayMetrics);
        } else {
            this.displayMetrics = null;
        }
        this.currentPosition = new Rect();
        this.defaultPosition = new Rect();
        this.maxSize = new Size(i);
        this.screenSize = new Size(i);
        if (context instanceof Activity) {
            this.originalRequestedOrientation = ((Activity) context).getRequestedOrientation();
        } else {
            this.originalRequestedOrientation = -1;
        }
        MRAIDLog.d(MRAID_LOG_TAG, "originalRequestedOrientation " + getOrientationString(this.originalRequestedOrientation));
        this.gestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
            @Override
            public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent2, float f, float f2) {
                return true;
            }
        });
        this.handler = new Handler(Looper.getMainLooper());
        this.mViewabilityAdSession = new HyBidViewabilityWebAdSession(HyBid.getViewabilityManager());
        this.mViewabilityFriendlyObstructions = new ArrayList();
        this.mraidWebChromeClient = new MRAIDWebChromeClient(this, i);
        this.mraidWebViewClient = new MRAIDWebViewClient(this, i);
        WebView createWebView = createWebView();
        this.webView = createWebView;
        if (createWebView == null) {
            if (mRAIDViewListener != null) {
                mRAIDViewListener.mraidViewError(this);
                return;
            }
            return;
        }
        createWebView.setId(R.id.mraid_ad_view);
        this.currentWebView = createWebView;
        if (TextUtils.isEmpty(str2)) {
            if (str != null) {
                MRAIDLog.d("hz-m loading mraid from url: ".concat(str));
                createWebView.loadUrl(str);
                return;
            }
            return;
        }
        try {
            String processRawHtml = MRAIDHtmlProcessor.processRawHtml(str2);
            MRAIDLog.d("hz-m loading mraid " + processRawHtml);
            createWebView.loadDataWithBaseURL(str3, processRawHtml, "text/html", "UTF-8", null);
            handleAntilockDelay();
        } catch (Throwable th) {
            HyBid.reportException(th);
            this.listener.mraidViewError(this);
        }
    }

    public static void D(MRAIDView mRAIDView) {
        mRAIDView.isBackClickable = Boolean.TRUE;
    }

    public static void N(MRAIDView mRAIDView, String str) {
        mRAIDView.expandCreative(str, true, Boolean.FALSE, null);
    }

    private void addCloseRegion(View view) {
        ImageButton imageButton = new ImageButton(this.context);
        this.closeRegion = imageButton;
        imageButton.setId(R.id.close_view);
        this.closeRegion.setBackgroundColor(0);
        this.closeRegion.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view2) {
                MRAIDView.this.lambda$addCloseRegion$7(view2);
            }
        });
        if (view == this.expandedView && !this.useCustomClose) {
            showDefaultCloseButton();
        }
        ((ViewGroup) view).addView(this.closeRegion);
    }

    public void addContentInfo(View view) {
        ViewGroup viewGroup = this.contentInfo;
        if (viewGroup == null || this.contentInfoAdded) {
            return;
        }
        ((ViewGroup) view).addView(viewGroup);
        this.contentInfoAdded = true;
    }

    private void calculateMaxSize() {
        if (this.context instanceof Activity) {
            Rect rect = new Rect();
            Window window = ((Activity) this.context).getWindow();
            window.getDecorView().getWindowVisibleDisplayFrame(rect);
            String str = MRAID_LOG_TAG;
            MRAIDLog.d(str, "calculateMaxSize frame [" + rect.left + "," + rect.top + "][" + rect.right + "," + rect.bottom + "] (" + rect.width() + "x" + rect.height() + ")");
            if (window.findViewById(android.R.id.content) != null) {
                this.contentViewTop = window.findViewById(android.R.id.content).getTop();
            } else {
                this.contentViewTop = rect.top;
            }
            int i = rect.top;
            int i2 = this.contentViewTop - i;
            MRAIDLog.d(str, "calculateMaxSize statusHeight " + i);
            MRAIDLog.d(str, "calculateMaxSize titleHeight " + i2);
            MRAIDLog.d(str, "calculateMaxSize contentViewTop " + this.contentViewTop);
            int width = rect.width();
            int i3 = this.screenSize.height - this.contentViewTop;
            MRAIDLog.d(str, "calculateMaxSize max size " + width + "x" + i3);
            Size size = this.maxSize;
            if (width == size.width && i3 == size.height) {
                return;
            }
            size.width = width;
            size.height = i3;
            if (this.isPageFinished) {
                setMaxSize();
            }
        }
    }

    private void calculatePosition(boolean z) {
        View view = z ? this.currentWebView : this;
        String str = z ? "current" : Reporting.Key.END_CARD_TYPE_DEFAULT;
        int[] iArr = new int[2];
        view.getLocationOnScreen(iArr);
        int i = iArr[0];
        int i2 = iArr[1];
        String str2 = MRAID_LOG_TAG;
        StringBuilder x = d0.x(i, "calculatePosition ", str, " locationOnScreen [", ",");
        x.append(i2);
        x.append("]");
        MRAIDLog.d(str2, x.toString());
        MRAIDLog.d(str2, "calculatePosition " + str + " contentViewTop " + this.contentViewTop);
        int i3 = i2 - this.contentViewTop;
        int width = view.getWidth();
        int height = view.getHeight();
        StringBuilder x2 = d0.x(i, "calculatePosition ", str, " position [", ",");
        com.mobilefuse.sdk.assetsmanager.a.x(i3, width, "] (", "x", x2);
        x2.append(height);
        x2.append(")");
        MRAIDLog.d(str2, x2.toString());
        Rect rect = z ? this.currentPosition : this.defaultPosition;
        if (i == rect.left && i3 == rect.top && width == rect.width() && height == rect.height()) {
            return;
        }
        if (z) {
            this.currentPosition = new Rect(i, i3, width + i, height + i3);
        } else {
            this.defaultPosition = new Rect(i, i3, width + i, height + i3);
        }
        if (this.isPageFinished) {
            if (z) {
                setCurrentPosition();
            } else {
                setDefaultPosition();
            }
        }
    }

    private void calculateScreenSize() {
        boolean z = getResources().getConfiguration().orientation == 1;
        String str = MRAID_LOG_TAG;
        MRAIDLog.d(str, "calculateScreenSize orientation ".concat(z ? "portrait" : "landscape"));
        DisplayMetrics displayMetrics = this.displayMetrics;
        if (displayMetrics != null) {
            int i = displayMetrics.widthPixels;
            int i2 = displayMetrics.heightPixels;
            MRAIDLog.d(str, "calculateScreenSize screen size " + i + "x" + i2);
            Size size = this.screenSize;
            if (i == size.width && i2 == size.height) {
                return;
            }
            size.width = i;
            size.height = i2;
            if (this.isPageFinished) {
                setScreenSize();
            }
        }
    }

    public void cancelAntilockTimer() {
        SimpleTimer simpleTimer = this.mAntilockTimer;
        if (simpleTimer != null) {
            simpleTimer.pause();
            this.mAntilockTimer.cancel();
            this.mAntilockTimer = null;
        }
    }

    public void cancelLandingPageBehaviour() {
        CountDownView countDownView = this.mSkipCountdownView;
        if (countDownView != null) {
            countDownView.setVisibility(8);
            this.mSkipCountdownView = null;
        }
        postDelayed(new c(this, 1), 600L);
    }

    public void closeOnMainThread() {
        new Handler(Looper.getMainLooper()).post(new c(this, 4));
    }

    @JavascriptMRAIDCallback
    private void createCalendarEvent(String str) {
        MRAIDLog.d(d0.s(new StringBuilder(), MRAID_LOG_TAG, "-JS callback"), "createCalendarEvent " + str);
        MRAIDNativeFeatureListener mRAIDNativeFeatureListener = this.nativeFeatureListener;
        if (mRAIDNativeFeatureListener != null) {
            mRAIDNativeFeatureListener.mraidNativeFeatureCreateCalendarEvent(str);
        }
    }

    private WebView createWebView() {
        try {
            PNWebView pNWebView = new PNWebView(this.context) {
                private static final String TAG = "MRAIDView-WebView";

                @Override
                public void onConfigurationChanged(Configuration configuration) {
                    super.onConfigurationChanged(configuration);
                    MRAIDLog.d(TAG, "onConfigurationChanged ".concat(configuration.orientation == 1 ? "portrait" : "landscape"));
                    if (MRAIDView.this.isInterstitial) {
                        if (Build.VERSION.SDK_INT >= 30) {
                            if (io.bidmachine.media3.exoplayer.source.chunk.a.h(MRAIDView.this.context) != null) {
                                io.bidmachine.media3.exoplayer.source.chunk.a.h(MRAIDView.this.context).getMetrics(MRAIDView.this.displayMetrics);
                            }
                        } else {
                            WindowManager windowManager = (WindowManager) MRAIDView.this.context.getSystemService("window");
                            if (windowManager != null) {
                                windowManager.getDefaultDisplay().getMetrics(MRAIDView.this.displayMetrics);
                            }
                        }
                    }
                }

                @Override
                public void onLayout(boolean z, int i, int i2, int i3, int i4) {
                    super.onLayout(z, i, i2, i3, i4);
                    MRAIDView.this.onLayoutWebView(this, z, i, i2, i3, i4);
                }

                @Override
                public void onVisibilityChanged(View view, int i) {
                    super.onVisibilityChanged(view, i);
                    MRAIDLog.d(TAG, "onVisibilityChanged " + MRAIDView.getVisibilityString(i));
                    if (MRAIDView.this.isInterstitial) {
                        MRAIDView.this.setViewable(i);
                    }
                }

                @Override
                public void onWindowVisibilityChanged(int i) {
                    super.onWindowVisibilityChanged(i);
                    int visibility = getVisibility();
                    MRAIDLog.d(TAG, "onWindowVisibilityChanged " + MRAIDView.getVisibilityString(i) + " (actual " + MRAIDView.getVisibilityString(visibility) + ')');
                    if (MRAIDView.this.isInterstitial) {
                        MRAIDView.this.setViewable(visibility);
                    }
                }

                @Override
                public boolean performClick() {
                    return super.performClick();
                }
            };
            pNWebView.setScrollContainer(false);
            pNWebView.setVerticalScrollBarEnabled(false);
            pNWebView.setHorizontalScrollBarEnabled(false);
            pNWebView.setScrollBarStyle(33554432);
            pNWebView.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View view, MotionEvent motionEvent) {
                    MRAIDView.this.wasTouched = true;
                    int action = motionEvent.getAction();
                    if ((action != 0 && action != 1) || view.hasFocus()) {
                        return false;
                    }
                    view.requestFocus();
                    return false;
                }
            });
            pNWebView.getSettings().setJavaScriptEnabled(true);
            pNWebView.getSettings().setDomStorageEnabled(true);
            pNWebView.getSettings().setAllowContentAccess(false);
            pNWebView.enablePlugins(true);
            pNWebView.getSettings().setSupportZoom(false);
            pNWebView.setWebChromeClient(this.mraidWebChromeClient);
            pNWebView.setWebViewClient(this.mraidWebViewClient);
            pNWebView.setLayerType(2, null);
            pNWebView.getSettings().setMediaPlaybackRequiresUserGesture(false);
            return pNWebView;
        } catch (RuntimeException e) {
            HyBid.reportException((Exception) e);
            return null;
        }
    }

    private void decodeURL(String str, boolean z) {
        try {
            String decode = URLDecoder.decode(str, "UTF-8");
            if (!decode.startsWith("http://") && !decode.startsWith("https://")) {
                decode = d0.s(new StringBuilder(), this.baseUrl, decode);
            }
            new Thread((Runnable) new j8(this, z, decode, 8), "2-part-content").start();
        } catch (UnsupportedEncodingException e) {
            HyBid.reportException((Exception) e);
            MRAIDLog.d("hz-m MRAIDView - expand - UnsupportedEncodingException " + e);
        }
    }

    private void expandCreative(String str, boolean z, Boolean bool) {
        expandCreative(str, z, bool, null);
    }

    public static void f0(MRAIDView mRAIDView) {
        mRAIDView.startSkipTimer();
    }

    private void forceFullScreen() {
        if (this.context instanceof Activity) {
            MRAIDLog.d(MRAID_LOG_TAG, "forceFullScreen");
            Activity activity = (Activity) this.context;
            int i = activity.getWindow().getAttributes().flags;
            this.isFullScreen = (i & 1024) != 0;
            this.isForceNotFullScreen = (i & 2048) != 0;
            this.origTitleBarVisibility = -9;
            ActionBar actionBar = activity.getActionBar();
            if (actionBar != null) {
                this.isActionBarShowing = actionBar.isShowing();
                actionBar.hide();
            } else {
                this.titleBar = null;
                try {
                    if (activity.findViewById(android.R.id.title) != null) {
                        this.titleBar = (View) activity.findViewById(android.R.id.title).getParent();
                    }
                } catch (NullPointerException e) {
                    HyBid.reportException((Exception) e);
                }
                View view = this.titleBar;
                if (view != null) {
                    this.origTitleBarVisibility = view.getVisibility();
                    this.titleBar.setVisibility(8);
                }
            }
            String str = MRAID_LOG_TAG;
            MRAIDLog.d(str, "isFullScreen " + this.isFullScreen);
            MRAIDLog.d(str, "isForceNotFullScreen " + this.isForceNotFullScreen);
            MRAIDLog.d(str, "isActionBarShowing " + this.isActionBarShowing);
            MRAIDLog.d(str, "origTitleBarVisibility " + getVisibilityString(this.origTitleBarVisibility));
            ((Activity) this.context).getWindow().addFlags(1024);
            ((Activity) this.context).getWindow().clearFlags(2048);
            this.isForcingFullScreen = !this.isFullScreen;
        }
    }

    public InputStream getMraidJsStream() {
        if (TextUtils.isEmpty(this.mraidJs)) {
            this.mraidJs = new String(Base64.decode(Assets.mraidJS, 0));
        }
        return new ByteArrayInputStream(this.mraidJs.getBytes(StandardCharsets.UTF_8));
    }

    private static String getOrientationString(int i) {
        return i != -1 ? i != 0 ? i != 1 ? "UNKNOWN" : "PORTRAIT" : "LANDSCAPE" : "UNSPECIFIED";
    }

    private String getStringFromFileUrl(String str) {
        StringBuilder sb = new StringBuilder();
        String[] split = str.split("/");
        if (!split[3].equals("android_asset")) {
            MRAIDLog.e("Unknown location to fetch file content");
            return "";
        }
        try {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(this.context.getAssets().open(split[4])));
            try {
                String readLine = bufferedReader.readLine();
                sb.append(readLine);
                while (readLine != null) {
                    readLine = bufferedReader.readLine();
                    sb.append(readLine);
                }
                bufferedReader.close();
            } finally {
            }
        } catch (IOException e) {
            MRAIDLog.e("Error fetching file: " + e.getMessage());
            HyBid.reportException((Exception) e);
        }
        return sb.toString();
    }

    private java.lang.String getStringFromUrl(java.lang.String r9) {
        throw new UnsupportedOperationException("Method not decompiled: net.pubnative.lite.sdk.mraid.MRAIDView.getStringFromUrl(java.lang.String):java.lang.String");
    }

    public static String getVisibilityString(int i) {
        return i != 0 ? i != 4 ? i != 8 ? "UNKNOWN" : "GONE" : "INVISIBLE" : "VISIBLE";
    }

    private void handleAntilockDelay() {
        SimpleTimer simpleTimer = new SimpleTimer(5000, new SimpleTimer.Listener() {
            @Override
            public void onFinish() {
                MRAIDViewListener mRAIDViewListener = MRAIDView.this.listener;
                if (mRAIDViewListener != null) {
                    mRAIDViewListener.mraidShowCloseButton();
                }
                MRAIDView.this.showDefaultCloseButton();
                MRAIDView.D(MRAIDView.this);
            }

            @Override
            public void onTick(long j) {
            }
        }, 1000L);
        this.mAntilockTimer = simpleTimer;
        simpleTimer.start();
    }

    private void handleLandingPageBehavior() {
        String str = this.landingBehaviourString;
        if (str == null) {
            CountDownView countDownView = this.mSkipCountdownView;
            if (countDownView != null) {
                countDownView.setVisibility(0);
                return;
            }
            return;
        }
        str.getClass();
        switch (str) {
            case "c":
                CountDownView countDownView2 = this.mSkipCountdownView;
                if (countDownView2 != null) {
                    countDownView2.setVisibility(0);
                    break;
                }
                break;
            case "ic":
                cancelLandingPageBehaviour();
                break;
            case "nc":
                CountDownView countDownView3 = this.mSkipCountdownView;
                if (countDownView3 != null) {
                    countDownView3.setVisibility(8);
                    break;
                }
                break;
        }
    }

    public void handleSetCustomisationInjection() {
        this.webView.evaluateJavascript(this.setCustomisationString, null);
    }

    public boolean hasLandingPage() {
        String str;
        return (!this.isLandingPageEnabled || (str = this.setCustomisationString) == null || str.isEmpty()) ? false : true;
    }

    private void injectMraidJs(WebView webView) {
        if (TextUtils.isEmpty(this.mraidJs)) {
            this.mraidJs = new String(Base64.decode(Assets.mraidJS, 0));
        }
        injectJavaScript(this.mraidJs);
    }

    public boolean isCloseSignal(String str) {
        Uri parse;
        List<String> pathSegments;
        if (!str.contains("https://feedback.verve.com") || (parse = Uri.parse(str)) == null || (pathSegments = parse.getPathSegments()) == null || pathSegments.isEmpty()) {
            return false;
        }
        return parse.getPathSegments().contains(EventConstants.CLOSE);
    }

    public boolean isVerveCustomExpand(String str) {
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        return (str.contains("tags-prod.vrvm.com") || str.contains("ad.vrvm.com")) && str.contains("type=expandable");
    }

    public void lambda$addCloseRegion$7(View view) {
        close();
    }

    public void lambda$close$0() {
        int i = this.state;
        if (i != 1 && i != 2) {
            if (i == 3) {
                closeFromResized();
            }
        } else {
            MRAIDViewCloseLayoutListener mRAIDViewCloseLayoutListener = this.closeLayoutListener;
            if (mRAIDViewCloseLayoutListener != null) {
                mRAIDViewCloseLayoutListener.onClose();
            } else {
                closeFromExpanded();
            }
        }
    }

    public void lambda$closeFromExpanded$4() {
        restoreOriginalOrientation();
        restoreOriginalScreenState();
    }

    public void lambda$closeFromExpanded$5() {
        fireStateChangeEvent();
        MRAIDViewListener mRAIDViewListener = this.listener;
        if (mRAIDViewListener != null) {
            mRAIDViewListener.mraidViewClose(this);
        }
    }

    public void lambda$closeFromResized$6() {
        fireStateChangeEvent();
        MRAIDViewListener mRAIDViewListener = this.listener;
        if (mRAIDViewListener != null) {
            mRAIDViewListener.mraidViewClose(this);
        }
    }

    public void lambda$decodeURL$1(String str) {
        if (this.state == 3) {
            removeResizeView();
            addView(this.webView);
        }
        this.webView.setWebChromeClient(null);
        this.webView.setWebViewClient(null);
        WebView createWebView = createWebView();
        this.webViewPart2 = createWebView;
        createWebView.loadUrl(str);
        MRAIDLog.d("hz-m MRAIDView - expand - switching out currentwebview for " + this.webViewPart2);
        WebView webView = this.webViewPart2;
        this.currentWebView = webView;
        this.isExpandingPart2 = true;
        expandHelper(webView);
    }

    public void lambda$decodeURL$2(String str) {
        if (this.state == 3) {
            removeResizeView();
            addView(this.webView);
        }
        this.webView.setWebChromeClient(null);
        this.webView.setWebViewClient(null);
        WebView createWebView = createWebView();
        this.webViewPart2 = createWebView;
        this.mIsExpanding = true;
        createWebView.loadUrl(str);
        MRAIDLog.d("hz-m MRAIDView - expand - switching out currentwebview for " + this.webViewPart2);
        WebView webView = this.webViewPart2;
        this.currentWebView = webView;
        this.isExpandingPart2 = true;
        expandHelper(webView);
    }

    public void lambda$decodeURL$3(boolean z, final String str) {
        MRAIDLog.d("hz-m MRAIDView - expand - url loading thread");
        if (z) {
            Context context = this.context;
            if (context instanceof Activity) {
                final int i = 1;
                ((Activity) context).runOnUiThread(new Runnable(this) {
                    public final MRAIDView b;

                    {
                        this.b = this;
                    }

                    @Override
                    public final void run() {
                        switch (i) {
                            case 0:
                                this.b.lambda$decodeURL$2(str);
                                break;
                            default:
                                this.b.lambda$decodeURL$1(str);
                                break;
                        }
                    }
                });
                return;
            } else {
                MRAIDLog.e("Could not load part 2 expanded content for URL: " + str);
                return;
            }
        }
        Context context2 = this.context;
        if (context2 instanceof Activity) {
            final int i2 = 0;
            ((Activity) context2).runOnUiThread(new Runnable(this) {
                public final MRAIDView b;

                {
                    this.b = this;
                }

                @Override
                public final void run() {
                    switch (i2) {
                        case 0:
                            this.b.lambda$decodeURL$2(str);
                            break;
                        default:
                            this.b.lambda$decodeURL$1(str);
                            break;
                    }
                }
            });
        } else {
            MRAIDLog.e("Could not load part 2 expanded content for URL: " + str);
        }
    }

    public static void lambda$injectJavaScript$8(String str) {
        MRAIDLog.d("Evaluated JS: " + str);
    }

    public void lambda$setViewable$9(int i) {
        boolean z = i == 0;
        if (z == this.isViewable && this.isViewabilityConfirmed) {
            return;
        }
        this.isViewable = z;
        if (this.isPageFinished && this.isLaidOut) {
            fireViewableChangeEvent();
            fireExposureChangeEvent();
            this.isViewabilityConfirmed = true;
        }
    }

    public void onLayoutWebView(WebView webView, boolean z, int i, int i2, int i3, int i4) {
        boolean z2 = webView == this.currentWebView;
        String str = MRAID_LOG_TAG;
        StringBuilder sb = new StringBuilder("onLayoutWebView ");
        sb.append(webView == this.webView ? "1 " : "2 ");
        sb.append(z2);
        sb.append(" (");
        sb.append(this.state);
        sb.append(") ");
        sb.append(z);
        sb.append(" ");
        com.mobilefuse.sdk.assetsmanager.a.x(i, i2, " ", " ", sb);
        sb.append(i3);
        sb.append(" ");
        sb.append(i4);
        MRAIDLog.w(str, sb.toString());
        if (!z2) {
            MRAIDLog.d(str, "onLayoutWebView ignored, not current");
            return;
        }
        int i5 = this.state;
        if (i5 == 0 || i5 == 1) {
            calculateScreenSize();
            calculateMaxSize();
        }
        if (!this.isClosing) {
            calculatePosition(true);
            if (this.isInterstitial && !this.defaultPosition.equals(this.currentPosition)) {
                this.defaultPosition = new Rect(this.currentPosition);
                setDefaultPosition();
            }
        }
        if (this.isExpandingFromDefault) {
            this.isExpandingFromDefault = false;
            if (this.isInterstitial) {
                this.state = 1;
                this.isLaidOut = true;
            }
            if (!this.isExpandingPart2) {
                MRAIDLog.d(str, "calling fireStateChangeEvent 1");
                fireStateChangeEvent();
            }
            if (this.isInterstitial) {
                fireReadyEvent();
                setViewable(this.isViewable ? 0 : 8);
            }
            MRAIDViewListener mRAIDViewListener = this.listener;
            if (mRAIDViewListener != null) {
                mRAIDViewListener.mraidViewExpand(this);
            }
        }
    }

    @JavascriptMRAIDCallback
    public void open(String str) {
        try {
            String decode = URLDecoder.decode(str, "UTF-8");
            StringBuilder sb = new StringBuilder();
            String str2 = MRAID_LOG_TAG;
            sb.append(str2);
            sb.append("-JS callback");
            MRAIDLog.d(sb.toString(), "open " + decode + " touched: " + this.wasTouched);
            if (!this.wasTouched) {
                MRAIDLog.d(str2 + "- JS callback", "open called, but no touch recorded, aborting");
                return;
            }
            if (this.nativeFeatureListener != null) {
                if (decode.startsWith(MRAIDNativeFeature.SMS)) {
                    this.nativeFeatureListener.mraidNativeFeatureSendSms(decode);
                } else if (decode.startsWith(MRAIDNativeFeature.TEL)) {
                    this.nativeFeatureListener.mraidNativeFeatureCallTel(decode);
                } else {
                    this.nativeFeatureListener.mraidNativeFeatureOpenBrowser(decode);
                }
            }
        } catch (UnsupportedEncodingException e) {
            HyBid.reportException((Exception) e);
            Logger.e(MRAID_LOG_TAG, e.getMessage());
        }
    }

    public void parseAdExperienceUrl(String str) {
        MRAIDLog.d(MRAID_LOG_TAG, "parseAdExperienceUrl " + str);
        try {
            if (str.matches("verveadexperience://setcustomisation\\?text=(.+)")) {
                String str2 = new String(Base64.decode(str.replaceFirst("verveadexperience://setcustomisation\\?text=(.+)", "$1"), 0));
                this.setCustomisationString = str2;
                if (str2.isEmpty()) {
                    return;
                }
                this.useCustomClose = false;
                SimpleTimer simpleTimer = this.mNativeCloseButtonTimer;
                if (simpleTimer != null) {
                    simpleTimer.cancel();
                    this.mNativeCloseButtonTimer = null;
                    postDelayed(new c(this, 3), 1000L);
                    return;
                }
                return;
            }
            if (str.matches("verveadexperience://landingbehaviour\\?text=(.+)")) {
                this.landingBehaviourString = new String(Base64.decode(str.replaceFirst("verveadexperience://landingbehaviour\\?text=(.+)", "$1"), 0));
                return;
            }
            if (str.matches("verveadexperience://closedelay\\?text=(.+)")) {
                try {
                    this.landingPageDelay = Integer.valueOf(Integer.parseInt(new String(Base64.decode(str.replaceFirst("verveadexperience://closedelay\\?text=(.+)", "$1"), 0))));
                } catch (NumberFormatException unused) {
                }
                validateDelay();
            } else if (str.matches("verveadexperience://setfinalpage")) {
                this.isFinalPage = true;
                handleLandingPageBehavior();
            }
        } catch (RuntimeException e) {
            Logger.d(MRAID_LOG_TAG, "Error parsing Ad Experience: " + e);
        }
    }

    public void parseCommandUrl(java.lang.String r8) {
        throw new UnsupportedOperationException("Method not decompiled: net.pubnative.lite.sdk.mraid.MRAIDView.parseCommandUrl(java.lang.String):void");
    }

    @JavascriptMRAIDCallback
    private void playVideo(String str) {
        try {
            String decode = URLDecoder.decode(str, "UTF-8");
            MRAIDLog.d(MRAID_LOG_TAG + "-JS callback", "playVideo " + decode);
            MRAIDNativeFeatureListener mRAIDNativeFeatureListener = this.nativeFeatureListener;
            if (mRAIDNativeFeatureListener != null) {
                mRAIDNativeFeatureListener.mraidNativeFeaturePlayVideo(decode);
            }
        } catch (UnsupportedEncodingException e) {
            HyBid.reportException((Exception) e);
            Logger.e(MRAID_LOG_TAG, e.getMessage());
        }
    }

    private int px2dip(int i) {
        DisplayMetrics displayMetrics = this.displayMetrics;
        return displayMetrics != null ? (i * 160) / displayMetrics.densityDpi : i;
    }

    private void removeDefaultCloseButton() {
        ImageButton imageButton = this.closeRegion;
        if (imageButton != null) {
            imageButton.setImageResource(android.R.color.transparent);
        }
    }

    private void removeResizeView() {
        RelativeLayout relativeLayout = this.resizedView;
        if (relativeLayout != null) {
            relativeLayout.removeAllViews();
            Context context = this.context;
            if (context instanceof Activity) {
                ((FrameLayout) ((Activity) context).findViewById(android.R.id.content)).removeView(this.resizedView);
                this.resizedView = null;
                this.closeRegion = null;
            }
        }
    }

    @JavascriptMRAIDCallback
    private void resize() {
        MRAIDLog.d(MRAID_LOG_TAG + "-JS callback", "resize");
        MRAIDViewListener mRAIDViewListener = this.listener;
        if (mRAIDViewListener == null) {
            return;
        }
        MRAIDResizeProperties mRAIDResizeProperties = this.resizeProperties;
        if (mRAIDViewListener.mraidViewResize(this, mRAIDResizeProperties.width, mRAIDResizeProperties.height, mRAIDResizeProperties.offsetX, mRAIDResizeProperties.offsetY)) {
            this.state = 3;
            if (this.resizedView == null) {
                this.resizedView = new RelativeLayout(this.context);
                removeView(this.webView);
                this.resizedView.addView(this.webView);
                addCloseRegion(this.resizedView);
                ((FrameLayout) getRootView().findViewById(android.R.id.content)).addView(this.resizedView);
            }
            setCloseRegionPosition(this.resizedView);
            setResizedViewSize();
            setResizedViewPosition();
            this.handler.post(new c(this, 5));
        }
    }

    private void restoreOriginalOrientation() {
        if (this.context instanceof Activity) {
            MRAIDLog.d(MRAID_LOG_TAG, "restoreOriginalOrientation");
            Activity activity = (Activity) this.context;
            int requestedOrientation = activity.getRequestedOrientation();
            int i = this.originalRequestedOrientation;
            if (requestedOrientation != i) {
                activity.setRequestedOrientation(i);
            }
        }
    }

    private void restoreOriginalScreenState() {
        Context context = this.context;
        if (context instanceof Activity) {
            Activity activity = (Activity) context;
            if (!this.isFullScreen) {
                activity.getWindow().clearFlags(1024);
            }
            if (this.isForceNotFullScreen) {
                activity.getWindow().addFlags(2048);
            }
            if (this.isActionBarShowing) {
                ActionBar actionBar = activity.getActionBar();
                if (actionBar != null) {
                    actionBar.show();
                    return;
                }
                return;
            }
            View view = this.titleBar;
            if (view != null) {
                view.setVisibility(this.origTitleBarVisibility);
            }
        }
    }

    private void setCloseRegionPosition(View view) {
        DisplayMetrics displayMetrics = this.displayMetrics;
        if (displayMetrics != null) {
            int applyDimension = (int) TypedValue.applyDimension(1, 50.0f, displayMetrics);
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(applyDimension, applyDimension);
            if (view != this.expandedView) {
                if (view == this.resizedView) {
                    switch (this.resizeProperties.customClosePosition) {
                        case 0:
                        case 4:
                            layoutParams.addRule(9);
                            break;
                        case 1:
                        case 3:
                        case 5:
                            layoutParams.addRule(14);
                            break;
                        case 2:
                        case 6:
                            layoutParams.addRule(11);
                            break;
                    }
                    switch (this.resizeProperties.customClosePosition) {
                        case 0:
                        case 1:
                        case 2:
                            layoutParams.addRule(10);
                            break;
                        case 3:
                            layoutParams.addRule(15);
                            break;
                        case 4:
                        case 5:
                        case 6:
                            layoutParams.addRule(12);
                            break;
                    }
                }
            } else {
                layoutParams.addRule(10);
                layoutParams.addRule(20);
            }
            this.closeRegion.setLayoutParams(layoutParams);
        }
    }

    public void setCurrentPosition() {
        Rect rect = this.currentPosition;
        int i = rect.left;
        int i2 = rect.top;
        int width = rect.width();
        int height = this.currentPosition.height();
        String str = MRAID_LOG_TAG;
        StringBuilder r = com.mobilefuse.sdk.assetsmanager.a.r(i, i2, "setCurrentPosition [", ",", "] (");
        r.append(width);
        r.append("x");
        r.append(height);
        r.append(")");
        MRAIDLog.d(str, r.toString());
        injectJavaScript("mraid.setCurrentPosition(" + px2dip(i) + "," + px2dip(i2) + "," + px2dip(width) + "," + px2dip(height) + ");");
    }

    public void setDefaultPosition() {
        Rect rect = this.defaultPosition;
        int i = rect.left;
        int i2 = rect.top;
        int width = rect.width();
        int height = this.defaultPosition.height();
        String str = MRAID_LOG_TAG;
        StringBuilder r = com.mobilefuse.sdk.assetsmanager.a.r(i, i2, "setDefaultPosition [", ",", "] (");
        r.append(width);
        r.append("x");
        r.append(height);
        r.append(")");
        MRAIDLog.d(str, r.toString());
        injectJavaScript("mraid.setDefaultPosition(" + px2dip(i) + "," + px2dip(i2) + "," + px2dip(width) + "," + px2dip(height) + ");");
    }

    public void setEnvironmentVariables() {
        DeviceInfo deviceInfo = HyBid.getDeviceInfo();
        if (getContext() != null && getContext().getApplicationContext() != null && !TextUtils.isEmpty(getContext().getApplicationContext().getPackageName())) {
            injectJavaScript("mraid.setAppId(\"" + getContext().getApplicationContext().getPackageName() + "\");");
        }
        injectJavaScript("mraid.setSdkVersion(\"3.3.0\");");
        injectJavaScript("mraid.setCoppa(" + HyBid.isCoppaEnabled() + ");");
        if (deviceInfo != null) {
            if (!deviceInfo.limitTracking() && !TextUtils.isEmpty(deviceInfo.getAdvertisingId())) {
                injectJavaScript("mraid.setIfa(\"" + deviceInfo.getAdvertisingId() + "\");");
            }
            injectJavaScript("mraid.setLimitAdTracking(" + deviceInfo.limitTracking() + ");");
        }
    }

    public void setLocation() {
        if (!this.nativeFeatureManager.isLocationSupported()) {
            injectJavaScript("mraid.setLocation(-1);");
            return;
        }
        HyBidLocationManager locationManager = HyBid.getLocationManager();
        if (locationManager == null || locationManager.getUserLocation() == null) {
            injectJavaScript("mraid.setLocation(-1);");
            return;
        }
        Location userLocation = locationManager.getUserLocation();
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("lat", Math.round(userLocation.getLatitude() * 100.0d) / 100.0d);
            jSONObject.put("lon", Math.round(userLocation.getLongitude() * 100.0d) / 100.0d);
            jSONObject.put(SVGParserImpl.XML_STYLESHEET_ATTR_TYPE, 1);
            jSONObject.put("accuracy", userLocation.getAccuracy());
            jSONObject.put("lastfix", (SystemClock.elapsedRealtimeNanos() - userLocation.getElapsedRealtimeNanos()) / 1000000000);
            injectJavaScript("mraid.setLocation(" + jSONObject + ");");
        } catch (JSONException e) {
            HyBid.reportException((Exception) e);
            Logger.e(MRAID_LOG_TAG, "Error passing location to MRAID interface");
            injectJavaScript("mraid.setLocation(-1);");
        }
    }

    public void setMaxSize() {
        String str = MRAID_LOG_TAG;
        MRAIDLog.d(str, "setMaxSize");
        Size size = this.maxSize;
        int i = size.width;
        int i2 = size.height;
        MRAIDLog.d(str, "setMaxSize " + i + "x" + i2);
        injectJavaScript("mraid.setMaxSize(" + px2dip(i) + "," + px2dip(i2) + ");");
    }

    private void setOrientationInitialState() {
        Context context = this.context;
        if (context == null || !(context instanceof Activity)) {
            return;
        }
        ((Activity) context).setRequestedOrientation(this.activityInitialOrientation);
    }

    @JavascriptMRAIDCallback
    private void setResizeProperties(Map<String, String> map) {
        int parseInt = Integer.parseInt(map.get("width"));
        int parseInt2 = Integer.parseInt(map.get("height"));
        int parseInt3 = Integer.parseInt(map.get("offsetX"));
        int parseInt4 = Integer.parseInt(map.get("offsetY"));
        String str = map.get("customClosePosition");
        boolean parseBoolean = Boolean.parseBoolean(map.get("allowOffscreen"));
        String s = d0.s(new StringBuilder(), MRAID_LOG_TAG, "-JS callback");
        StringBuilder r = com.mobilefuse.sdk.assetsmanager.a.r(parseInt, parseInt2, "setResizeProperties ", " ", " ");
        com.mobilefuse.sdk.assetsmanager.a.x(parseInt3, parseInt4, " ", " ", r);
        r.append(str);
        r.append(" ");
        r.append(parseBoolean);
        MRAIDLog.d(s, r.toString());
        MRAIDResizeProperties mRAIDResizeProperties = this.resizeProperties;
        mRAIDResizeProperties.width = parseInt;
        mRAIDResizeProperties.height = parseInt2;
        mRAIDResizeProperties.offsetX = parseInt3;
        mRAIDResizeProperties.offsetY = parseInt4;
        mRAIDResizeProperties.customClosePosition = MRAIDResizeProperties.customClosePositionFromString(str);
        this.resizeProperties.allowOffscreen = parseBoolean;
    }

    public void setResizedViewPosition() {
        if (this.displayMetrics != null) {
            MRAIDLog.d(MRAID_LOG_TAG, "setResizedViewPosition");
            if (this.resizedView == null) {
                return;
            }
            MRAIDResizeProperties mRAIDResizeProperties = this.resizeProperties;
            int i = mRAIDResizeProperties.width;
            int i2 = mRAIDResizeProperties.height;
            int i3 = mRAIDResizeProperties.offsetX;
            int i4 = mRAIDResizeProperties.offsetY;
            int applyDimension = (int) TypedValue.applyDimension(1, i, this.displayMetrics);
            int applyDimension2 = (int) TypedValue.applyDimension(1, i2, this.displayMetrics);
            int applyDimension3 = (int) TypedValue.applyDimension(1, i3, this.displayMetrics);
            int applyDimension4 = (int) TypedValue.applyDimension(1, i4, this.displayMetrics);
            Rect rect = this.defaultPosition;
            int i5 = rect.left + applyDimension3;
            int i6 = rect.top + applyDimension4;
            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) this.resizedView.getLayoutParams();
            layoutParams.leftMargin = i5;
            layoutParams.topMargin = i6;
            this.resizedView.setLayoutParams(layoutParams);
            Rect rect2 = this.currentPosition;
            if (i5 == rect2.left && i6 == rect2.top && applyDimension == rect2.width() && applyDimension2 == this.currentPosition.height()) {
                return;
            }
            Rect rect3 = this.currentPosition;
            rect3.left = i5;
            rect3.top = i6;
            rect3.right = i5 + applyDimension;
            rect3.bottom = i6 + applyDimension2;
            setCurrentPosition();
        }
    }

    private void setResizedViewSize() {
        if (this.displayMetrics != null) {
            String str = MRAID_LOG_TAG;
            MRAIDLog.d(str, "setResizedViewSize");
            MRAIDResizeProperties mRAIDResizeProperties = this.resizeProperties;
            int i = mRAIDResizeProperties.width;
            int i2 = mRAIDResizeProperties.height;
            MRAIDLog.d(str, "setResizedViewSize " + i + "x" + i2);
            this.resizedView.setLayoutParams(new FrameLayout.LayoutParams((int) TypedValue.applyDimension(1, (float) i, this.displayMetrics), (int) TypedValue.applyDimension(1, (float) i2, this.displayMetrics)));
        }
    }

    public void setScreenSize() {
        String str = MRAID_LOG_TAG;
        MRAIDLog.d(str, "setScreenSize");
        Size size = this.screenSize;
        int i = size.width;
        int i2 = size.height;
        MRAIDLog.d(str, "setScreenSize " + i + "x" + i2);
        injectJavaScript("mraid.setScreenSize(" + px2dip(i) + "," + px2dip(i2) + ");");
    }

    public void setSupportedServices() {
        MRAIDLog.d(MRAID_LOG_TAG, "setSupportedServices");
        injectJavaScript("mraid.setSupports(mraid.SUPPORTED_FEATURES.CALENDAR, " + this.nativeFeatureManager.isCalendarSupported() + ");");
        injectJavaScript("mraid.setSupports(mraid.SUPPORTED_FEATURES.INLINEVIDEO, " + this.nativeFeatureManager.isInlineVideoSupported() + ");");
        injectJavaScript("mraid.setSupports(mraid.SUPPORTED_FEATURES.SMS, " + this.nativeFeatureManager.isSmsSupported() + ");");
        injectJavaScript("mraid.setSupports(mraid.SUPPORTED_FEATURES.STOREPICTURE, " + this.nativeFeatureManager.isStorePictureSupported() + ");");
        injectJavaScript("mraid.setSupports(mraid.SUPPORTED_FEATURES.TEL, " + this.nativeFeatureManager.isTelSupported() + ");");
        injectJavaScript("mraid.setSupports(mraid.SUPPORTED_FEATURES.LOCATION, " + this.nativeFeatureManager.isLocationSupported() + ");");
    }

    public void showClose() {
        SimpleTimer simpleTimer = this.mNativeCloseButtonTimer;
        if (simpleTimer != null) {
            simpleTimer.onFinish();
            this.mNativeCloseButtonTimer = null;
        }
        MRAIDViewListener mRAIDViewListener = this.listener;
        if (mRAIDViewListener != null) {
            mRAIDViewListener.mraidShowCloseButton();
        }
        showDefaultCloseButton();
        this.isBackClickable = Boolean.TRUE;
    }

    public void showDefaultCloseButton() {
        ImageButton imageButton = this.closeRegion;
        if (imageButton != null) {
            Context context = imageButton.getContext();
            Integer normalCloseXmlResource = HyBid.getNormalCloseXmlResource();
            int i = R.mipmap.close;
            Bitmap bitmap = BitmapHelper.toBitmap(context, normalCloseXmlResource, Integer.valueOf(i));
            if (bitmap != null) {
                this.closeRegion.setImageBitmap(bitmap);
            } else {
                ImageButton imageButton2 = this.closeRegion;
                imageButton2.setImageBitmap(BitmapHelper.decodeResource(imageButton2.getContext(), Integer.valueOf(i)));
            }
            this.closeRegion.setScaleType(ImageView.ScaleType.FIT_CENTER);
        }
    }

    public void startSkipTimer() {
        Integer num;
        if (hasLandingPage()) {
            if (this.landingPageDelay.intValue() >= 1000) {
                this.landingPageDelay = Integer.valueOf(this.landingPageDelay.intValue() - 1000);
            }
            num = this.landingPageDelay;
            this.mNativeCloseButtonDelay = num;
            handleNativeCloseButtonDelay();
            this.useCustomClose = false;
            this.mSkipTimeMillis = this.landingPageDelay;
            CountDownView countDownView = this.mSkipCountdownView;
            if (countDownView != null) {
                countDownView.setVisibility(4);
            }
        } else if (this.useCustomClose) {
            handleNativeCloseButtonDelay();
            num = this.mNativeCloseButtonDelay;
            CountDownView countDownView2 = this.mSkipCountdownView;
            if (countDownView2 != null) {
                countDownView2.setVisibility(8);
            }
        } else {
            num = this.mSkipTimeMillis;
            CountDownView countDownView3 = this.mSkipCountdownView;
            if (countDownView3 != null) {
                countDownView3.setVisibility(0);
            }
        }
        if (num.intValue() > 0 && this.showTimerBeforeEndCard.booleanValue()) {
            SimpleTimer simpleTimer = new SimpleTimer(num.intValue(), new SimpleTimer.Listener() {
                @Override
                public void onFinish() {
                    MRAIDView.this.listener.mraidShowCloseButton();
                    MRAIDView.D(MRAIDView.this);
                    if (MRAIDView.this.mSkipCountdownView != null) {
                        MRAIDView.this.mSkipCountdownView.setVisibility(8);
                    }
                }

                @Override
                public void onTick(long j) {
                    if (MRAIDView.this.mSkipCountdownView != null) {
                        MRAIDView.this.mSkipCountdownView.setProgress((int) (MRAIDView.this.mSkipTimeMillis.intValue() - j), MRAIDView.this.mSkipTimeMillis.intValue());
                    }
                }
            }, 10L);
            this.mExpirationTimer = simpleTimer;
            simpleTimer.start();
        } else if (num.intValue() == 0) {
            this.listener.mraidShowCloseButton();
            this.isBackClickable = Boolean.TRUE;
        }
    }

    @JavascriptMRAIDCallback
    private void storePicture(String str) {
        try {
            String decode = URLDecoder.decode(str, "UTF-8");
            MRAIDLog.d(MRAID_LOG_TAG + "-JS callback", "storePicture " + decode);
            MRAIDNativeFeatureListener mRAIDNativeFeatureListener = this.nativeFeatureListener;
            if (mRAIDNativeFeatureListener != null) {
                mRAIDNativeFeatureListener.mraidNativeFeatureStorePicture(decode);
            }
        } catch (UnsupportedEncodingException e) {
            HyBid.reportException((Exception) e);
            Logger.e(MRAID_LOG_TAG, e.getMessage());
        }
    }

    @JavascriptMRAIDCallback
    @Deprecated
    private void useCustomClose(String str) {
        MRAIDLog.d(d0.s(new StringBuilder(), MRAID_LOG_TAG, "-JS callback"), "useCustomClose " + str);
        boolean parseBoolean = Boolean.parseBoolean(str);
        if (this.useCustomClose != parseBoolean) {
            this.useCustomClose = parseBoolean;
        }
    }

    private void validateDelay() {
        if (this.landingPageDelay.intValue() < 0 || this.landingPageDelay.intValue() > LANDING_PAGE_CLOSE_DELAY) {
            this.landingPageDelay = Integer.valueOf(LANDING_PAGE_CLOSE_DELAY);
        }
    }

    public void addViewabilityFriendlyObstruction(View view, FriendlyObstructionPurpose friendlyObstructionPurpose, String str) {
        if (this.mViewabilityFriendlyObstructions == null || view == null || TextUtils.isEmpty(str)) {
            return;
        }
        this.mViewabilityFriendlyObstructions.add(new HyBidViewabilityFriendlyObstruction(view, friendlyObstructionPurpose, str));
    }

    public void applyOrientationProperties() {
        if (this.context instanceof Activity) {
            String str = MRAID_LOG_TAG;
            MRAIDLog.d(str, "applyOrientationProperties " + this.orientationProperties.allowOrientationChange + " " + this.orientationProperties.forceOrientationString());
            Activity activity = (Activity) this.context;
            int i = 0;
            int i2 = getResources().getConfiguration().orientation == 1 ? 1 : 0;
            MRAIDLog.d(str, "currentOrientation ".concat(i2 != 0 ? "portrait" : "landscape"));
            MRAIDOrientationProperties mRAIDOrientationProperties = this.orientationProperties;
            int i3 = mRAIDOrientationProperties.forceOrientation;
            if (i3 == 0) {
                i = 1;
            } else if (i3 != 1) {
                i = mRAIDOrientationProperties.allowOrientationChange ? -1 : i2;
            }
            activity.setRequestedOrientation(i);
        }
    }

    public void clearView() {
        WebView webView = this.webView;
        if (webView != null) {
            webView.setWebChromeClient(null);
            this.webView.setWebViewClient(null);
            this.webView.loadUrl("about:blank");
        }
    }

    @JavascriptMRAIDCallback
    public void close() {
        MRAIDLog.d(MRAID_LOG_TAG + "-JS callback", EventConstants.CLOSE);
        StringBuilder sb = new StringBuilder("hz-m closing wv: ");
        sb.append(this.webView);
        MRAIDLog.d(sb.toString());
        this.handler.post(new c(this, 9));
    }

    public void closeFromExpanded() {
        FrameLayout frameLayout;
        int i = this.state;
        if (i == 2 || i == 3) {
            this.state = 1;
        }
        MRAIDOrientationProperties mRAIDOrientationProperties = this.orientationProperties;
        if (mRAIDOrientationProperties != null) {
            mRAIDOrientationProperties.allowOrientationChange = true;
        }
        setOrientationInitialState();
        this.isClosing = true;
        this.isExpanded = false;
        RelativeLayout relativeLayout = this.expandedView;
        if (relativeLayout != null) {
            relativeLayout.removeAllViews();
        }
        Context context = this.context;
        if (!(context instanceof Activity) || (frameLayout = (FrameLayout) ((Activity) context).findViewById(android.R.id.content)) == null) {
            return;
        }
        frameLayout.removeView(this.expandedView);
        this.expandedView = null;
        this.closeRegion = null;
        this.handler.post(new c(this, 7));
        WebView webView = this.webViewPart2;
        if (webView == null) {
            if (findViewById(R.id.mraid_ad_view) != null) {
                removeView(this.webView);
            }
            addView(this.webView, 0, new FrameLayout.LayoutParams(-1, -2));
        } else {
            webView.destroy();
            this.webView.setWebChromeClient(this.mraidWebChromeClient);
            this.webView.setWebViewClient(this.mraidWebViewClient);
            MRAIDLog.d("hz-m MRAIDView - closeFromExpanded - setting currentwebview to " + this.webView);
            WebView webView2 = this.webView;
            this.currentWebView = webView2;
            webView2.setLayoutParams(new FrameLayout.LayoutParams(-1, -2));
        }
        this.handler.post(new c(this, 8));
    }

    public void closeFromResized() {
        this.state = 1;
        this.isClosing = true;
        removeResizeView();
        addView(this.webView, 0);
        this.handler.post(new c(this, 6));
    }

    public void destroy() {
        if (this.webView != null) {
            MRAIDLog.i("Destroying Main WebView");
            this.webView.destroy();
        }
        if (this.webViewPart2 != null) {
            MRAIDLog.i("Destroying Secondary WebView");
            this.webViewPart2.destroy();
        }
        RelativeLayout relativeLayout = this.expandedView;
        if (relativeLayout != null) {
            ViewGroup viewGroup = (ViewGroup) relativeLayout.getParent();
            if (viewGroup != null) {
                viewGroup.removeView(this.expandedView);
            }
            this.expandedView = null;
        }
        this.currentWebView = null;
        this.contentInfoAdded = false;
        SimpleTimer simpleTimer = this.mExpirationTimer;
        if (simpleTimer != null) {
            simpleTimer.onFinish();
            this.mExpirationTimer = null;
        }
        SimpleTimer simpleTimer2 = this.mNativeCloseButtonTimer;
        if (simpleTimer2 != null) {
            simpleTimer2.onFinish();
            this.mNativeCloseButtonTimer = null;
        }
    }

    @JavascriptMRAIDCallback
    @Deprecated
    public void expand(String str) {
        if (this.isExpandEnabled && this.wasTouched) {
            expandCreative(str, false, Boolean.FALSE);
        }
    }

    public void expandContentInfo(String str) {
        decodeURL(str, false);
    }

    public void expandHelper(WebView webView) {
        applyOrientationProperties();
        forceFullScreen();
        RelativeLayout relativeLayout = new RelativeLayout(this.context);
        this.expandedView = relativeLayout;
        relativeLayout.addView(webView, new RelativeLayout.LayoutParams(-1, -1));
        if (this.isInterstitial) {
            addContentInfo(this.expandedView);
        }
        addCloseRegion(this.expandedView);
        setCloseRegionPosition(this.expandedView);
        MRAIDLog.d("hz-m MRAIDView - expandHelper - adding contentview to activity " + this.context);
        this.showActivity.addContentView(this.expandedView, new RelativeLayout.LayoutParams(-1, -1));
        this.isExpandingFromDefault = true;
        this.isExpanded = true;
    }

    public void fireExposureChangeEvent() {
        double d = this.isViewable ? 100.0d : 0.0d;
        MRAIDLog.d(MRAID_LOG_TAG, "fireExposureChangeEvent");
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("x", getX());
            jSONObject.put("y", getY());
            jSONObject.put("width", (getWidth() * d) / 100.0d);
            jSONObject.put("height", (getHeight() * d) / 100.0d);
        } catch (JSONException e) {
            HyBid.reportException((Exception) e);
            Logger.e(MRAID_LOG_TAG, e.getMessage());
        }
        injectJavaScript("mraid.fireExposureChangeEvent(" + d + "," + jSONObject + ",null);");
    }

    public void fireReadyEvent() {
        MRAIDLog.d(MRAID_LOG_TAG, "fireReadyEvent");
        injectJavaScript("mraid.fireReadyEvent();");
    }

    public void fireStateChangeEvent() {
        MRAIDLog.d(MRAID_LOG_TAG, "fireStateChangeEvent");
        injectJavaScript("mraid.fireStateChangeEvent('" + new String[]{"loading", Reporting.Key.END_CARD_TYPE_DEFAULT, "expanded", "resized", "hidden"}[this.state] + "');");
    }

    public void fireViewableChangeEvent() {
        MRAIDLog.d(MRAID_LOG_TAG, "fireViewableChangeEvent");
        injectJavaScript("mraid.fireViewableChangeEvent(" + this.isViewable + ");");
    }

    public int getState() {
        return this.state;
    }

    public void handleNativeCloseButtonDelay() {
        SimpleTimer simpleTimer = new SimpleTimer(this.mNativeCloseButtonDelay.intValue(), new SimpleTimer.Listener() {
            @Override
            public void onFinish() {
                MRAIDViewListener mRAIDViewListener = MRAIDView.this.listener;
                if (mRAIDViewListener != null) {
                    mRAIDViewListener.mraidShowCloseButton();
                }
                MRAIDView.this.showDefaultCloseButton();
                MRAIDView.D(MRAIDView.this);
            }

            @Override
            public void onTick(long j) {
            }
        }, 1000L);
        this.mNativeCloseButtonTimer = simpleTimer;
        simpleTimer.start();
    }

    public void injectJavaScript(String str) {
        injectJavaScript(this.currentWebView, str);
    }

    public boolean isExpanded() {
        return this.isExpanded;
    }

    public boolean isLoaded() {
        return this.isPageFinished;
    }

    @Override
    public void onAttachedToWindow() {
        MRAIDLog.d(MRAID_LOG_TAG, "onAttachedToWindow");
        super.onAttachedToWindow();
    }

    public boolean onBackPressed() {
        MRAIDLog.d("hz-m MRAIDView - onBackPressed");
        int i = this.state;
        if (i == 0 || i == 4) {
            MRAIDLog.d("hz-m MRAIDView - onBackPressed - loading or hidden");
            return false;
        }
        if (!this.isBackClickable.booleanValue()) {
            return true;
        }
        close();
        return true;
    }

    @Override
    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        MRAIDLog.d(MRAID_LOG_TAG, "onConfigurationChanged ".concat(configuration.orientation == 1 ? "portrait" : "landscape"));
        WindowManager windowManager = (WindowManager) this.context.getSystemService("window");
        if (windowManager != null) {
            windowManager.getDefaultDisplay().getMetrics(this.displayMetrics);
        }
    }

    @Override
    public void onDetachedFromWindow() {
        MRAIDLog.d(MRAID_LOG_TAG, "onDetachedFromWindow");
        stopAdSession();
        super.onDetachedFromWindow();
    }

    @Override
    public void onLayout(boolean z, int i, int i2, int i3, int i4) {
        super.onLayout(z, i, i2, i3, i4);
        String str = MRAID_LOG_TAG;
        StringBuilder sb = new StringBuilder("onLayout (");
        sb.append(this.state);
        sb.append(") ");
        sb.append(z);
        sb.append(" ");
        com.mobilefuse.sdk.assetsmanager.a.x(i, i2, " ", " ", sb);
        sb.append(i3);
        sb.append(" ");
        sb.append(i4);
        MRAIDLog.w(str, sb.toString());
        if (this.isForcingFullScreen) {
            MRAIDLog.d(str, "onLayout ignored");
            return;
        }
        int i5 = this.state;
        if (i5 == 2 || i5 == 3) {
            calculateScreenSize();
            calculateMaxSize();
        }
        if (this.isClosing) {
            this.isClosing = false;
            this.currentPosition = new Rect(this.defaultPosition);
            setCurrentPosition();
        } else {
            calculatePosition(false);
        }
        if (this.state == 3 && z) {
            this.handler.post(new c(this, 2));
        }
        this.isLaidOut = true;
        onLayoutCompleted();
    }

    public void onLayoutCompleted() {
    }

    @Override
    public boolean onTouchEvent(MotionEvent motionEvent) {
        if (this.gestureDetector.onTouchEvent(motionEvent)) {
            motionEvent.setAction(3);
        }
        return super.onTouchEvent(motionEvent);
    }

    @Override
    public void onVisibilityChanged(View view, int i) {
        super.onVisibilityChanged(view, i);
        MRAIDLog.d(MRAID_LOG_TAG, "onVisibilityChanged " + getVisibilityString(i));
        setViewable(i);
    }

    @Override
    public void onWindowVisibilityChanged(int i) {
        super.onWindowVisibilityChanged(i);
        int visibility = getVisibility();
        MRAIDLog.d(MRAID_LOG_TAG, "onWindowVisibilityChanged " + getVisibilityString(i) + " (actual " + getVisibilityString(visibility) + ")");
        setViewable(visibility);
    }

    public void pause() {
        SimpleTimer simpleTimer = this.mExpirationTimer;
        if (simpleTimer != null) {
            simpleTimer.pause();
        }
        SimpleTimer simpleTimer2 = this.mNativeCloseButtonTimer;
        if (simpleTimer2 != null) {
            simpleTimer2.pause();
        }
        SimpleTimer simpleTimer3 = this.mAntilockTimer;
        if (simpleTimer3 != null) {
            simpleTimer3.pause();
        }
    }

    public void resume() {
        SimpleTimer simpleTimer = this.mExpirationTimer;
        if (simpleTimer != null) {
            simpleTimer.resume();
        }
        SimpleTimer simpleTimer2 = this.mNativeCloseButtonTimer;
        if (simpleTimer2 != null) {
            simpleTimer2.resume();
        }
        SimpleTimer simpleTimer3 = this.mAntilockTimer;
        if (simpleTimer3 != null) {
            simpleTimer3.resume();
        }
    }

    public void setCloseLayoutListener(MRAIDViewCloseLayoutListener mRAIDViewCloseLayoutListener) {
        this.closeLayoutListener = mRAIDViewCloseLayoutListener;
    }

    public void setIsLandingPageEnabled(boolean z) {
        this.isLandingPageEnabled = z;
    }

    public void setNativeCloseButtonDelay(Integer num) {
        this.mNativeCloseButtonDelay = Integer.valueOf(num.intValue() * 1000);
    }

    @JavascriptMRAIDCallback
    public void setOrientationProperties(Map<String, String> map) {
        boolean parseBoolean = Boolean.parseBoolean(map.get("allowOrientationChange"));
        String str = map.get("forceOrientation");
        MRAIDLog.d(d0.s(new StringBuilder(), MRAID_LOG_TAG, "-JS callback"), "setOrientationProperties " + parseBoolean + " " + str);
        MRAIDOrientationProperties mRAIDOrientationProperties = this.orientationProperties;
        mRAIDOrientationProperties.allowOrientationChange = parseBoolean;
        mRAIDOrientationProperties.forceOrientation = MRAIDOrientationProperties.forceOrientationFromString(str);
        if ((this instanceof MRAIDInterstitial) || this.state == 2) {
            applyOrientationProperties();
        }
    }

    public void setSkipOffset(Integer num) {
        this.mSkipTimeMillis = Integer.valueOf(num.intValue() * 1000);
    }

    public void setUseCustomClose(Boolean bool) {
        if (this.useCustomClose != bool.booleanValue()) {
            this.useCustomClose = bool.booleanValue();
        }
    }

    public void setViewable(int i) {
        post(new ab.b(this, i, 14));
    }

    public void showAsInterstitial(Activity activity, Boolean bool, OnExpandCreativeFailListener onExpandCreativeFailListener) {
        MRAIDLog.d("hz-m MRAIDVIEW - showAsInterstitial");
        this.showActivity = activity;
        expand(null, bool, onExpandCreativeFailListener);
    }

    public void stopAdSession() {
        HyBidViewabilityWebAdSession hyBidViewabilityWebAdSession = this.mViewabilityAdSession;
        if (hyBidViewabilityWebAdSession != null) {
            hyBidViewabilityWebAdSession.stopAdSession();
            this.mViewabilityAdSession = null;
        }
    }

    @JavascriptMRAIDCallback
    public void unload() {
        MRAIDLog.d(MRAID_LOG_TAG + "-JS callback", "unload");
        StringBuilder sb = new StringBuilder("hz-m unload wv: ");
        sb.append(this.webView);
        MRAIDLog.d(sb.toString());
        MRAIDViewListener mRAIDViewListener = this.listener;
        if (mRAIDViewListener != null) {
            mRAIDViewListener.mraidViewError(this);
        }
    }

    private void expandCreative(String str, boolean z, Boolean bool, OnExpandCreativeFailListener onExpandCreativeFailListener) {
        MRAIDLog.d("hz-m MRAIDView - expand " + str);
        StringBuilder sb = new StringBuilder();
        String str2 = MRAID_LOG_TAG;
        MRAIDLog.d(d0.s(sb, str2, "-JS callback"), "expand ".concat(str != null ? str : "(1-part)"));
        MRAIDOrientationProperties mRAIDOrientationProperties = this.orientationProperties;
        if (mRAIDOrientationProperties != null) {
            mRAIDOrientationProperties.allowOrientationChange = false;
            applyOrientationProperties();
        }
        if (!this.isExpandEnabled && !bool.booleanValue()) {
            MRAIDLog.d(str2 + "-JS callback", "expand disabled by the developer");
            return;
        }
        if (!TextUtils.isEmpty(str)) {
            decodeURL(str, z);
            return;
        }
        int i = this.state;
        if (i == 0 || i == 1) {
            if (this.webView.getParent() != null) {
                ((ViewGroup) this.webView.getParent()).removeView(this.webView);
            } else {
                removeView(this.webView);
            }
        } else if (i == 3) {
            removeResizeView();
        }
        expandHelper(this.webView);
        MRAIDLog.d("hz-m MRAIDView - expand - empty url");
        if (onExpandCreativeFailListener != null) {
            onExpandCreativeFailListener.onExpandFailed();
        }
    }

    public static void injectJavaScript(WebView webView, String str) {
        if (webView == null || TextUtils.isEmpty(str)) {
            return;
        }
        MRAIDLog.d(MRAID_LOG_TAG, "evaluating js: " + str);
        webView.evaluateJavascript(str, new f(1));
    }

    public void expand(String str, Boolean bool, OnExpandCreativeFailListener onExpandCreativeFailListener) {
        expandCreative(str, false, bool, onExpandCreativeFailListener);
    }

    public void showAsInterstitial(Activity activity, Boolean bool, OnExpandCreativeFailListener onExpandCreativeFailListener, String str) {
        MRAIDLog.d("hz-m MRAIDVIEW - showAsInterstitial");
        this.showActivity = activity;
        expand(str, bool, onExpandCreativeFailListener);
    }
}