package com.bytedance.bdturing;

import X.0HH;
import X.3GT;
import X.9Vv;
import X.9Vw;
import X.9Wn;
import X.9dN;
import X.C1302KaT;
import X.C1303KaU;
import X.C1304KaV;
import android.graphics.Bitmap;
import android.net.http.SslError;
import android.os.Build;
import android.webkit.RenderProcessGoneDetail;
import android.webkit.SslErrorHandler;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
import com.bytedance.bdturing.twiceverify.TwiceVerifyWebActivity;
import com.bytedance.covode.number.Covode;
import java.io.InputStream;
import org.json.JSONObject;

public class VerifyWebView$4 extends WebViewClient {
    public final /* synthetic */ C1303KaU LIZ;

    static {
        Covode.recordClassIndex(24381);
    }

    public final boolean onRenderProcessGone(WebView webView, RenderProcessGoneDetail renderProcessGoneDetail) {
        return 9Wn.LIZ(webView, renderProcessGoneDetail);
    }

    public VerifyWebView$4(C1303KaU kaU) {
        this.LIZ = kaU;
    }

    public final void onLoadResource(WebView webView, String str) {
        super.onLoadResource(webView, str);
    }

    private WebResourceResponse LIZ(WebView webView, String str) {
        if (str.toLowerCase().contains("/favicon.ico")) {
            try {
                return new WebResourceResponse("image/png", (String) null, (InputStream) null);
            } catch (Exception e) {
                0HH.LIZ(e);
            }
        }
        return super.shouldInterceptRequest(webView, str);
    }

    public final void onPageFinished(WebView webView, String str) {
        if (!this.LIZ.LIZIZ && !this.LIZ.LIZJ) {
            this.LIZ.LIZJ = true;
            this.LIZ.LIZ.LIZ();
        }
        super.onPageFinished(webView, str);
    }

    public final WebResourceResponse shouldInterceptRequest(WebView webView, String str) {
        9Vv LJIILIIL = 9dN.LJ.LJIILIIL(new 9Vv(str, webView, (JSONObject) null, 9Vw.CONTINUE));
        if (LJIILIIL.LJFF == 9Vw.INTERCEPT && LJIILIIL.LIZIZ != null) {
            return (WebResourceResponse) LJIILIIL.LIZIZ;
        }
        if (LJIILIIL.LJFF != 9Vw.EXCEPTION || LJIILIIL.LJ == null) {
            return LIZ(LJIILIIL.LIZJ, (String) LJIILIIL.LIZ);
        }
        throw LJIILIIL.LJ;
    }

    public final void onPageStarted(WebView webView, String str, Bitmap bitmap) {
        super.onPageStarted(webView, str, bitmap);
    }

    public final void onReceivedHttpError(WebView webView, WebResourceRequest webResourceRequest, WebResourceResponse webResourceResponse) {
        if (C1304KaV.LIZ()) {
            this.LIZ.getContext();
        }
        if (this.LIZ.LIZLLL != null && (this.LIZ.LIZLLL instanceof TwiceVerifyWebActivity)) {
            int i = 0;
            try {
                i = webResourceResponse.getStatusCode();
            } catch (Throwable unused) {
            }
            ((TwiceVerifyWebActivity) this.LIZ.LIZLLL).LIZ(i);
        }
        super.onReceivedHttpError(webView, webResourceRequest, webResourceResponse);
        try {
            boolean contains = webResourceRequest.getUrl().toString().toLowerCase().contains("/favicon.ico");
        } catch (Exception e) {
            C1304KaV.LIZ(e);
        }
    }

    public final void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
        if (C1304KaV.LIZ()) {
            Toast makeText = Toast.makeText(this.LIZ.getContext(), "onReceivedSslError : ".concat(String.valueOf(sslError)), 1);
            if (Build.VERSION.SDK_INT == 25) {
                3GT.LIZ(makeText);
            }
            makeText.show();
        }
        if (this.LIZ.LIZLLL != null && (this.LIZ.LIZLLL instanceof TwiceVerifyWebActivity)) {
            int i = 0;
            try {
                i = sslError.getPrimaryError();
            } catch (Throwable unused) {
            }
            ((TwiceVerifyWebActivity) this.LIZ.LIZLLL).LIZ(i);
        }
        super.onReceivedSslError(webView, sslErrorHandler, sslError);
    }

    public final void onReceivedError(WebView webView, int i, String str, String str2) {
        this.LIZ.LIZIZ = true;
        C1302KaT kaT = this.LIZ.LIZ;
        kaT.LIZ(i, str + "|" + str2);
        if (this.LIZ.LIZLLL != null && (this.LIZ.LIZLLL instanceof TwiceVerifyWebActivity)) {
            ((TwiceVerifyWebActivity) this.LIZ.LIZLLL).LIZ(i);
        }
        super.onReceivedError(webView, i, str, str2);
    }
}
