package com.bytedance.sdk.openadsdk.core.widget.YFl;

import android.content.Context;
import android.webkit.WebSettings;
import android.webkit.WebView;
import com.bytedance.sdk.component.utils.YoT;
import java.lang.ref.WeakReference;
/* loaded from: classes2.dex */
public class tN {
    private final WeakReference<Context> YFl;
    private boolean Sg = true;
    private final boolean tN = true;
    private final boolean AlY = true;
    private final boolean wN = false;
    private final boolean vc = true;
    private boolean DSW = true;

    public tN Sg(boolean z) {
        this.Sg = z;
        return this;
    }

    public tN YFl(boolean z) {
        this.DSW = z;
        return this;
    }

    public static tN YFl(Context context) {
        return new tN(context);
    }

    private tN(Context context) {
        this.YFl = new WeakReference<>(context);
    }

    public void YFl(WebView webView) {
        if (webView == null || this.YFl.get() == null) {
            return;
        }
        Sg(webView);
        WebSettings settings = webView.getSettings();
        YFl(settings);
        if (settings == null) {
            return;
        }
        try {
            settings.setJavaScriptEnabled(true);
        } catch (Exception e) {
            YoT.YFl("SSWebSettings", e.getMessage());
        }
        try {
            if (this.Sg) {
                settings.setSupportZoom(true);
                settings.setBuiltInZoomControls(true);
            } else {
                settings.setSupportZoom(false);
            }
        } catch (Throwable th) {
            YoT.YFl("SSWebSettings", th.getMessage());
        }
        settings.setLoadWithOverviewMode(true);
        settings.setUseWideViewPort(true);
        settings.setDomStorageEnabled(true);
        settings.setAllowFileAccess(false);
        settings.setBlockNetworkImage(false);
        settings.setSavePassword(false);
        try {
            if (this.DSW) {
                webView.setLayerType(2, null);
            } else {
                webView.setLayerType(0, null);
            }
        } catch (Throwable th2) {
            YoT.YFl("SSWebSettings", th2.getMessage());
        }
    }

    public static void Sg(WebView webView) {
        try {
            webView.removeJavascriptInterface("searchBoxJavaBridge_");
            webView.removeJavascriptInterface("accessibility");
            webView.removeJavascriptInterface("accessibilityTraversal");
        } catch (Throwable th) {
            YoT.Sg(th.toString());
        }
    }

    private void YFl(WebSettings webSettings) {
        try {
            webSettings.setMediaPlaybackRequiresUserGesture(false);
        } catch (Throwable th) {
            YoT.Sg(th.toString());
        }
    }
}
