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

import android.annotation.SuppressLint;
import android.content.Context;
import android.webkit.WebSettings;
import android.webkit.WebView;
import com.bytedance.sdk.component.utils.wey;
import java.lang.ref.WeakReference;

/* JADX INFO: loaded from: classes2.dex */
public class yz {
    private final WeakReference<Context> fm;
    private boolean ro = true;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private final boolean f7341lb = true;
    private final boolean yz = true;
    private final boolean jnr = false;
    private final boolean ajl = true;
    private boolean wsy = true;

    private yz(Context context) {
        this.fm = new WeakReference<>(context);
    }

    public yz fm(boolean z10) {
        this.wsy = z10;
        return this;
    }

    public yz ro(boolean z10) {
        this.ro = z10;
        return this;
    }

    public static yz fm(Context context) {
        return new yz(context);
    }

    public static void ro(WebView webView) {
        if (webView == null) {
            return;
        }
        try {
            webView.removeJavascriptInterface("searchBoxJavaBridge_");
            webView.removeJavascriptInterface("accessibility");
            webView.removeJavascriptInterface("accessibilityTraversal");
        } catch (Throwable th) {
            wey.lb(th.toString(), new Object[0]);
        }
    }

    @SuppressLint({"SetJavaScriptEnabled"})
    public void fm(WebView webView) {
        if (webView == null || this.fm.get() == null) {
            return;
        }
        ro(webView);
        WebSettings settings = webView.getSettings();
        fm(settings);
        if (settings == null) {
            return;
        }
        try {
            settings.setJavaScriptEnabled(true);
        } catch (Exception e10) {
            wey.lb("SSWebSettings", e10.getMessage());
        }
        try {
            if (this.ro) {
                settings.setSupportZoom(true);
                settings.setBuiltInZoomControls(true);
            } else {
                settings.setSupportZoom(false);
            }
        } catch (Throwable th) {
            wey.lb("SSWebSettings", th.getMessage());
        }
        settings.setLoadWithOverviewMode(true);
        settings.setUseWideViewPort(true);
        settings.setDomStorageEnabled(true);
        settings.setAllowFileAccess(false);
        settings.setBlockNetworkImage(false);
        settings.setSavePassword(false);
        try {
            if (this.wsy) {
                webView.setLayerType(2, null);
            } else {
                webView.setLayerType(0, null);
            }
        } catch (Throwable th2) {
            wey.lb("SSWebSettings", th2.getMessage());
        }
    }

    private void fm(WebSettings webSettings) {
        try {
            webSettings.setMediaPlaybackRequiresUserGesture(false);
        } catch (Throwable th) {
            wey.lb(th.toString(), new Object[0]);
        }
    }

    public static void fm(com.bytedance.sdk.component.ef.wsy wsyVar) {
        if (wsyVar == null) {
            return;
        }
        int iFm = com.bytedance.sdk.openadsdk.hlt.jnr.fm("clear_web_cache_new", 0);
        if (iFm == 0) {
            wsyVar.fm(true);
        } else if (iFm == 1) {
            wsyVar.fm(false);
        }
    }
}
