思特奇智慧酒店云平台 v0.0.5版本的 MD5 值为:dedb172bb322639d79d7e0e26262fb5c

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


package com.sitech.oncon.widget;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Picture;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Environment;
import android.os.Message;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewParent;
import android.webkit.JavascriptInterface;
import android.webkit.URLUtil;
import android.widget.Toast;
import androidx.annotation.RequiresApi;
import com.androidyuan.lib.screenshot.ScreenShotActivity;
import com.bumptech.glide.load.data.HttpUrlFetcher;
import com.bumptech.glide.load.model.LazyHeaders;
import com.huawei.hms.framework.common.ContainerUtils;
import com.sitech.core.util.Log;
import com.sitech.core.util.js.DownloadBlobFileJSInterface;
import com.sitech.core.util.js.JSApi;
import com.sitech.core.util.js.JSNative;
import com.sitech.core.util.js.VideoJSInterface;
import com.sitech.oncon.R;
import com.sitech.oncon.activity.BaseActivity;
import com.sitech.oncon.application.MyApplication;
import com.sitech.oncon.data.HeadBitmapData;
import com.sitech.oncon.widget.webview.MyWebView;
import com.sitech.photoedit.activity.PhotoEditActivity;
import com.taobao.weex.el.parse.Operators;
import com.tencent.smtt.export.external.interfaces.HttpAuthHandler;
import com.tencent.smtt.export.external.interfaces.SslError;
import com.tencent.smtt.export.external.interfaces.SslErrorHandler;
import com.tencent.smtt.export.external.interfaces.WebResourceError;
import com.tencent.smtt.export.external.interfaces.WebResourceRequest;
import com.tencent.smtt.export.external.interfaces.WebResourceResponse;
import com.tencent.smtt.sdk.CookieManager;
import com.tencent.smtt.sdk.CookieSyncManager;
import com.tencent.smtt.sdk.DownloadListener;
import com.tencent.smtt.sdk.WebChromeClient;
import com.tencent.smtt.sdk.WebSettings;
import com.tencent.smtt.sdk.WebView;
import com.tencent.smtt.sdk.WebViewClient;
import defpackage.bk0;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.commons.codec.language.bm.Rule;
public class WebViewUI extends WebView implements View.OnTouchListener {
    public static final String R0 = "http://yixin/h5/img/src/";
    public String A;
    public MyWebView A0;
    public Context B;
    public boolean B0;
    public ProgressDialog C;
    public List<Integer> C0;
    public String D;
    public float D0;
    public float E0;
    public float F0;
    public float G0;
    public float H0;
    public float I0;
    public float J0;
    public float K0;
    public float L0;
    public float M0;
    public float N0;
    public float O0;
    public boolean P0;
    public gk1 Q0;
    public String e0;
    public k f0;
    public h g0;
    public j h0;
    public i i0;
    public boolean j0;
    public JSApi k0;
    public JSNative l0;
    public DownloadBlobFileJSInterface m0;
    public boolean n0;
    public String o0;
    public String p0;
    public long q0;
    public long r0;
    public boolean s0;
    public np1 t0;
    public boolean u0;
    public WebChromeClient v0;
    public ln1 w0;
    public boolean x0;
    public String y0;
    public String z0;

    public class a implements DownloadListener {

        public class RunnableC0169a implements Runnable {
            public final String a;

            public class RunnableC0170a implements Runnable {
                public final String a;

                public RunnableC0170a(String str) {
                    this.a = str;
                }

                @Override
                public void run() {
                    try {
                        WebViewUI.this.b(RunnableC0169a.this.a, this.a);
                        if (WebViewUI.this.t0.isShowing()) {
                            return;
                        }
                        WebViewUI.this.t0.show();
                    } catch (Exception e) {
                        Log.a((Throwable) e);
                    }
                }
            }

            public RunnableC0169a(String str) {
                this.a = str;
            }

            @Override
            public void run() {
                String str;
                try {
                    Thread.sleep(1000L);
                    str = WebViewUI.a(this.a, WebViewUI.this.e0);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                    str = "";
                }
                ((Activity) WebViewUI.this.getContext()).runOnUiThread(new RunnableC0170a(str));
            }
        }

        public a() {
        }

        @Override
        public void onDownloadStart(String str, String str2, String str3, String str4, long j) {
            WebViewUI.this.z0 = str;
            if (!Environment.getExternalStorageState().equals("mounted")) {
                Toast.makeText(WebViewUI.this.B, WebViewUI.this.B.getResources().getString(R.string.moreapp_sdcard_not_exist), 0).show();
                return;
            }
            CookieSyncManager.createInstance(WebViewUI.this.B).sync();
            WebViewUI.this.e0 = CookieManager.getInstance().getCookie(str);
            if (TextUtils.isEmpty(str3)) {
                new Thread(new RunnableC0169a(str)).start();
                return;
            }
            String[] split = str3.split(ContainerUtils.KEY_VALUE_DELIMITER);
            String replace = ((split == null || split.length < 2) ? "" : split[1]).replace(Rule.DOUBLE_QUOTE, "");
            if (replace.equals("")) {
                WebViewUI.this.b(str, URLUtil.guessFileName(str, str3, str4));
            } else {
                try {
                    replace = URLDecoder.decode(replace);
                } catch (Throwable th) {
                    Log.a(th);
                }
                WebViewUI.this.b(str, replace);
            }
            if (WebViewUI.this.t0.isShowing()) {
                return;
            }
            WebViewUI.this.t0.show();
        }
    }

    public class b implements DialogInterface.OnClickListener {
        public final String a;
        public final String b;

        public b(String str, String str2) {
            this.a = str;
            this.b = str2;
        }

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            dialogInterface.dismiss();
            new f(WebViewUI.this, null).execute(this.a, this.b);
        }
    }

    public class c implements DialogInterface.OnClickListener {
        public c() {
        }

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            dialogInterface.dismiss();
        }
    }

    public class d implements DialogInterface.OnDismissListener {
        public d() {
        }

        @Override
        public void onDismiss(DialogInterface dialogInterface) {
            WebViewUI.this.C = null;
        }
    }

    public class e implements gk1 {
        public e() {
        }

        @Override
        public void a(boolean z, String str) {
            if (z) {
                Intent intent = new Intent(WebViewUI.this.getContext(), PhotoEditActivity.class);
                intent.putExtra("BackgroundBitmapPath", str);
                intent.putExtra("finishEvent", PhotoEditActivity.q.SHARE);
                ((Activity) WebViewUI.this.getContext()).startActivityForResult(intent, 10003);
            }
            MyApplication.h().b(bk0.Ia, WebViewUI.this.Q0);
        }
    }

    public class f extends AsyncTask<String, Void, String> {
        public f() {
        }

        @Override
        @SuppressLint({"WrongThread"})
        public String doInBackground(String... strArr) {
            String str = strArr[0];
            String str2 = strArr[1];
            try {
                if (TextUtils.isEmpty(str2)) {
                    str2 = WebViewUI.a(str, WebViewUI.this.e0);
                }
                return WebViewUI.this.a(str, str2, WebViewUI.this.e0, WebViewUI.this.D);
            } catch (Exception e) {
                Log.a((Throwable) e);
                return null;
            }
        }

        @Override
        public void onCancelled() {
            super.onCancelled();
        }

        @Override
        public void onPreExecute() {
            super.onPreExecute();
            WebViewUI.this.q();
        }

        public f(WebViewUI webViewUI, a aVar) {
            this();
        }

        @Override
        public void onPostExecute(String str) {
            super.onPostExecute(str);
            WebViewUI.this.n();
            if (str == null) {
                Toast.makeText(WebViewUI.this.B, WebViewUI.this.B.getResources().getString(R.string.update_networktimeout), 0).show();
                return;
            }
            File file = new File(WebViewUI.this.D, str);
            Log.g("Path=" + file.getAbsolutePath());
            if (!WebViewUI.this.j0) {
                Context context = WebViewUI.this.B;
                Toast.makeText(context, WebViewUI.this.B.getResources().getString(R.string.download) + WebViewUI.this.B.getResources().getString(R.string.finish), 0).show();
            }
            try {
                WebViewUI.this.B.startActivity(tl0.b(file.getAbsolutePath()));
                sk0.a(WebViewUI.this.getContext(), file.getAbsolutePath());
            } catch (Exception unused) {
                Toast.makeText(WebViewUI.this.B, WebViewUI.this.B.getResources().getString(R.string.cant_open_suffix_file), 0).show();
            }
        }

        @Override
        public void onProgressUpdate(Void... voidArr) {
            super.onProgressUpdate(voidArr);
        }
    }

    public interface g {
        void a(WebView webView, String str, Bitmap bitmap);
    }

    public interface h {
        void a(WebView webView, String str);
    }

    public interface i {
        void a();
    }

    public interface j {
        void a(WebView webView, String str, Bitmap bitmap);
    }

    public interface k {
        void a(WebView webView, int i, String str, String str2);

        void a(WebView webView, WebResourceRequest webResourceRequest, WebResourceResponse webResourceResponse);
    }

    public interface l {
        void a(WebView webView, String str, Bitmap bitmap);
    }

    public WebViewUI(Context context) {
        super(context);
        this.n0 = false;
        this.o0 = "";
        this.p0 = "";
        this.s0 = false;
        this.u0 = false;
        this.x0 = bk0.h.Share == bk0.Hc;
        this.y0 = "";
        this.z0 = "";
        this.B0 = true;
        this.C0 = new ArrayList();
        this.Q0 = new e();
        this.B = context;
        init();
    }

    @JavascriptInterface
    @SuppressLint({"JavascriptInterface"})
    private void addJavascriptInterface() {
        if (this.P0) {
            return;
        }
        VideoJSInterface videoJSInterface = new VideoJSInterface();
        videoJSInterface.chromeClient = this.v0;
        addJavascriptInterface(videoJSInterface, "_VideoEnabledWebView");
        this.P0 = true;
    }

    @JavascriptInterface
    @SuppressLint({"SetJavaScriptEnabled", "JavascriptInterface"})
    private void init() {
        this.D = ck0.g();
        this.w0 = new ln1(this.B);
        WebSettings settings = getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setGeolocationEnabled(true);
        settings.setGeolocationDatabasePath(getContext().getFilesDir().getPath());
        settings.setJavaScriptCanOpenWindowsAutomatically(true);
        settings.setSupportMultipleWindows(false);
        if (Build.VERSION.SDK_INT >= 21) {
            settings.setMixedContentMode(0);
            WebView.setWebContentsDebuggingEnabled(true);
        }
        if (Build.VERSION.SDK_INT >= 16) {
            if (bk0.v3) {
                settings.setAllowFileAccessFromFileURLs(true);
                settings.setAllowUniversalAccessFromFileURLs(true);
                settings.setAllowFileAccess(true);
            } else {
                settings.setAllowFileAccessFromFileURLs(false);
                settings.setAllowUniversalAccessFromFileURLs(false);
                settings.setAllowFileAccess(false);
            }
        }
        setOnTouchListener(this);
        if (bk0.w2) {
            CookieManager cookieManager = CookieManager.getInstance();
            cookieManager.setAcceptCookie(true);
            cookieManager.setAcceptThirdPartyCookies(this, true);
        }
        settings.setSupportZoom(true);
        settings.setSavePassword(bk0.v2);
        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
        settings.setLoadWithOverviewMode(true);
        settings.setUseWideViewPort(true);
        settings.setTextZoom(bk0.e3);
        this.y0 = settings.getUserAgentString();
        if (!TextUtils.isEmpty(bk0.l3)) {
            this.y0 += " " + bk0.l3;
            settings.setUserAgentString(this.y0);
            Log.d("webSettings.getUserAgentString():" + settings.getUserAgentString());
        }
        if (!bk0.m1) {
            settings.setCacheMode(2);
            settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
            settings.setDatabaseEnabled(true);
            settings.setDatabasePath(this.B.getDir("database", 0).getPath());
            settings.setDomStorageEnabled(true);
            settings.setAppCacheEnabled(true);
            String path = this.B.getDir(rm0.a, 0).getPath();
            settings.setCacheMode(2);
            settings.setAppCachePath(path);
            settings.setAppCacheMaxSize(8388608L);
        } else {
            if (this.w0.e()) {
                settings.setCacheMode(-1);
            } else {
                settings.setCacheMode(1);
            }
            settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
            settings.setDatabaseEnabled(true);
            settings.setDatabasePath(this.B.getDir("database", 0).getPath());
            settings.setDomStorageEnabled(true);
            settings.setAppCacheEnabled(true);
            settings.setAppCachePath(this.B.getDir(rm0.a, 0).getPath());
            settings.setAppCacheMaxSize(8388608L);
        }
        if (getSettingsExtension() != null) {
            getSettingsExtension().setPicModel(1);
        } else {
            settings.setLoadsImagesAutomatically(true);
            settings.setBlockNetworkImage(false);
        }
        setSaveEnabled(false);
        o();
        setDownloadListener(new a());
        setWebViewClient(new WebViewClient() {

            public class a implements HeadBitmapData.LoadHeadBitmapCallback {
                public final WebResourceResponse[] a;

                public a(WebResourceResponse[] webResourceResponseArr) {
                    this.a = webResourceResponseArr;
                }

                @Override
                public void headBitmapLoaded(String str, Bitmap bitmap) {
                    if (bitmap != null) {
                        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                        bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
                        this.a[0] = new WebResourceResponse("image/png", "UTF-8", new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
                    }
                }
            }

            public class b implements DialogInterface.OnClickListener {
                public final SslErrorHandler a;

                public b(SslErrorHandler sslErrorHandler) {
                    this.a = sslErrorHandler;
                }

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    this.a.cancel();
                }
            }

            public class c implements DialogInterface.OnClickListener {
                public final SslErrorHandler a;

                public c(SslErrorHandler sslErrorHandler) {
                    this.a = sslErrorHandler;
                }

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    this.a.proceed();
                }
            }

            @Override
            public void onFormResubmission(WebView webView, Message message, Message message2) {
                message2.sendToTarget();
            }

            @Override
            public void onLoadResource(WebView webView, String str) {
                super.onLoadResource(webView, str);
                if (str == null || str.startsWith("yixin://")) {
                }
            }

            @Override
            @JavascriptInterface
            public void onPageFinished(WebView webView, String str) {
                WebViewUI.this.d(str);
                try {
                    Log.d("WebView onPageFinished:" + str);
                    super.onPageFinished(webView, str);
                    WebViewUI.this.r0 = System.currentTimeMillis();
                    Context context = WebViewUI.this.getContext();
                    StringBuilder sb = new StringBuilder();
                    sb.append(WebViewUI.this.s0 ? nj0.N1 : nj0.M1);
                    sb.append(":");
                    sb.append(km0.r(WebViewUI.this.k0.mAppId));
                    pg0.a(context, sb.toString(), null, null, WebViewUI.this.r0 - WebViewUI.this.q0);
                    WebViewUI.this.addJavascriptInterface(WebViewUI.this.k0, "JSApi");
                    WebViewUI.this.addJavascriptInterface(WebViewUI.this.l0, "Native");
                    if (!TextUtils.isEmpty(str) && !str.startsWith("yixin://") && !str.equals(WebViewUI.this.o0)) {
                        WebViewUI.this.o0 = str;
                        WebViewUI.this.p();
                    }
                    if (WebViewUI.this.k0 != null && WebViewUI.this.k0.getmTitleView() != null) {
                        if (bk0.Dc && (WebViewUI.this.canGoBack() || WebViewUI.this.canGoForward())) {
                            WebViewUI.this.k0.getmTitleView().b();
                        }
                        if (!TextUtils.isEmpty(WebViewUI.this.k0.getHomePage())) {
                            WebViewUI.this.k0.getmTitleView().setRightImg(R.drawable.btn_back_home);
                        } else if (WebViewUI.this.x0) {
                            WebViewUI.this.k0.getmTitleView().setRightImg(R.drawable.ic_scan);
                            if (!TextUtils.isEmpty(webView.getUrl()) && ((TextUtils.isEmpty(WebViewUI.this.B.getString(R.string.privacy_policy_url)) || !TextUtils.equals(WebViewUI.this.B.getString(R.string.privacy_policy_url), webView.getUrl())) && (TextUtils.isEmpty(WebViewUI.this.B.getString(R.string.service_agreement_url)) || !TextUtils.equals(WebViewUI.this.B.getString(R.string.service_agreement_url), webView.getUrl())))) {
                                WebViewUI.this.k0.getmTitleView().setRightImgVisible(true);
                            }
                            WebViewUI.this.k0.getmTitleView().setRightImgVisible(false);
                        }
                    }
                    if (WebViewUI.this.k0 != null && WebViewUI.this.k0.getmCustomWebTitleView() != null && !WebViewUI.this.u0) {
                        WebViewUI.this.k0.getmCustomWebTitleView().setRightViewOfRightLLVisible(true);
                        if (WebViewUI.this.canGoBack() || WebViewUI.this.canGoForward()) {
                            WebViewUI.this.k0.getmCustomWebTitleView().setLeftViewTVOfLeftLLVisible(true);
                        }
                        if (!TextUtils.isEmpty(WebViewUI.this.k0.getHomePage())) {
                            WebViewUI.this.k0.getmCustomWebTitleView().setRightViewOfRightLL(R.drawable.btn_back_home);
                        } else {
                            WebViewUI.this.k0.getmCustomWebTitleView().setRightViewOfRightLLVisible(false);
                        }
                    }
                    WebViewUI.this.n0 = false;
                    if (WebViewUI.this.g0 != null) {
                        WebViewUI.this.g0.a(webView, str);
                    }
                    if (WebViewUI.this.i0 != null) {
                        WebViewUI.this.i0.a();
                    }
                } catch (Throwable th) {
                    Log.a(th);
                }
            }

            @Override
            public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
                try {
                    Log.d("WebView onPageStarted:" + str);
                    WebViewUI.this.p0 = str;
                    WebViewUI.this.s0 = false;
                    WebViewUI.this.o0 = "";
                    super.onPageStarted(webView, str, bitmap);
                    pg0.a(str);
                    if (WebViewUI.this.h0 != null) {
                        WebViewUI.this.h0.a(webView, str, bitmap);
                    }
                    WebViewUI.this.q0 = System.currentTimeMillis();
                    if (WebViewUI.this.k0 != null && WebViewUI.this.k0.getmTitleView() != null) {
                        if (bk0.Dc && (WebViewUI.this.canGoBack() || WebViewUI.this.canGoForward())) {
                            WebViewUI.this.k0.getmTitleView().b();
                        }
                        if (!TextUtils.isEmpty(WebViewUI.this.k0.getHomePage())) {
                            WebViewUI.this.k0.getmTitleView().setRightImg(R.drawable.btn_back_home);
                        } else if (bk0.h.Share == bk0.Hc) {
                            WebViewUI.this.k0.getmTitleView().setRightImgVisible(false);
                        }
                    }
                    if (WebViewUI.this.k0 != null && WebViewUI.this.k0.getmCustomWebTitleView() != null && !WebViewUI.this.u0) {
                        WebViewUI.this.k0.getmCustomWebTitleView().setRightViewOfRightLLVisible(false);
                        if (WebViewUI.this.canGoBack() || WebViewUI.this.canGoForward()) {
                            WebViewUI.this.k0.getmCustomWebTitleView().setLeftViewTVOfLeftLLVisible(true);
                        }
                        if (!TextUtils.isEmpty(WebViewUI.this.k0.getHomePage())) {
                            WebViewUI.this.k0.getmCustomWebTitleView().setRightViewOfRightLL(R.drawable.btn_back_home);
                        } else {
                            WebViewUI.this.k0.getmCustomWebTitleView().setRightViewOfRightLLVisible(false);
                        }
                    }
                    if (Build.VERSION.SDK_INT < 19) {
                        WebViewUI webViewUI = WebViewUI.this;
                        webViewUI.loadUrl("javascript:navigator.languages=['" + BaseActivity.getLang() + "']");
                        WebViewUI webViewUI2 = WebViewUI.this;
                        webViewUI2.loadUrl("javascript:navigator.languages[0]='" + BaseActivity.getLang() + "'");
                        return;
                    }
                    WebViewUI webViewUI3 = WebViewUI.this;
                    webViewUI3.evaluateJavascript("javascript:navigator.languages=['" + BaseActivity.getLang() + "']", null);
                    WebViewUI webViewUI4 = WebViewUI.this;
                    webViewUI4.evaluateJavascript("javascript:navigator.languages[0]='" + BaseActivity.getLang() + "'", null);
                } catch (Throwable th) {
                    Log.a(th);
                }
            }

            @Override
            public void onReceivedError(WebView webView, int i2, String str, String str2) {
                try {
                    if (str2.startsWith("yixin://")) {
                        return;
                    }
                    Log.d(i2 + ":" + str + "-" + str2);
                    if (bk0.V1) {
                        super.onReceivedError(webView, i2, str, str2);
                        Log.a("jxerr", "failingUrl -- " + str2);
                        WebViewUI webViewUI = WebViewUI.this;
                        Context context = WebViewUI.this.B;
                        int i3 = R.string.open_web_fail;
                        webViewUI.c(context.getString(i3, i2 + " " + str + " " + str2));
                        WebViewUI.this.s0 = true;
                        if (WebViewUI.this.f0 != null) {
                            WebViewUI.this.f0.a(webView, i2, str, str2);
                            return;
                        }
                        return;
                    }
                    if (i2 != 801 && i2 != 805) {
                        if (i2 == -2) {
                            for (String str3 : bk0.Ic) {
                                if (str2.startsWith(str3)) {
                                    return;
                                }
                            }
                        }
                        if (WebViewUI.this.z0.equals(str2)) {
                            WebViewUI.this.z0 = "";
                        } else if (WebViewUI.this.p0.equals(str2)) {
                            super.onReceivedError(webView, i2, str, str2);
                            Log.a("jxerr", "failingUrl -- " + str2);
                            WebViewUI webViewUI2 = WebViewUI.this;
                            Context context2 = WebViewUI.this.B;
                            int i4 = R.string.open_web_fail;
                            webViewUI2.c(context2.getString(i4, i2 + " " + str + " " + str2));
                            WebViewUI.this.s0 = true;
                            if (WebViewUI.this.f0 != null) {
                                WebViewUI.this.f0.a(webView, i2, str, str2);
                            }
                        }
                    }
                } catch (Throwable th) {
                    Log.a(th);
                }
            }

            @Override
            public void onReceivedHttpAuthRequest(WebView webView, HttpAuthHandler httpAuthHandler, String str, String str2) {
                if (bk0.Cc) {
                    String[] httpAuthUsernamePassword = webView.getHttpAuthUsernamePassword(str, str2);
                    webView.setHttpAuthUsernamePassword(str, str2, httpAuthUsernamePassword[0], httpAuthUsernamePassword[1]);
                }
                WebViewUI.this.d(webView.getUrl());
            }

            @Override
            @RequiresApi(api = 23)
            public void onReceivedHttpError(WebView webView, WebResourceRequest webResourceRequest, WebResourceResponse webResourceResponse) {
                try {
                    StringBuffer stringBuffer = new StringBuffer();
                    stringBuffer.append("request:");
                    String str = " is null ";
                    stringBuffer.append(webResourceRequest == null ? " is null " : webResourceRequest.getUrl());
                    stringBuffer.append(";error:");
                    if (webResourceResponse != null) {
                        str = webResourceResponse.getStatusCode() + "-" + webResourceResponse.getReasonPhrase();
                    }
                    stringBuffer.append(str);
                    Log.d(stringBuffer.toString());
                    if (bk0.V1) {
                        if (!webResourceRequest.isForMainFrame() && webResourceRequest.getUrl().getPath().endsWith("/favicon.ico")) {
                            Log.d("favicon.ico 请求错误" + webResourceResponse.getStatusCode() + webResourceResponse.getReasonPhrase());
                            return;
                        }
                        String scheme = webResourceRequest.getUrl().getScheme();
                        if (TextUtils.isEmpty(scheme) && scheme.equals("yixin")) {
                            return;
                        }
                        WebViewUI.this.s0 = true;
                        super.onReceivedHttpError(webView, webResourceRequest, webResourceResponse);
                        Log.a("jxerr", "request.getUrl() = " + webResourceRequest.getUrl());
                        WebViewUI.this.c(WebViewUI.this.B.getString(R.string.open_web_fail, webResourceResponse.getStatusCode() + " " + webResourceResponse.getReasonPhrase() + " " + webResourceRequest.getUrl()));
                        if (WebViewUI.this.f0 != null) {
                            WebViewUI.this.f0.a(webView, webResourceRequest, webResourceResponse);
                        }
                    } else if (WebViewUI.this.p0.equals(webResourceRequest.getUrl().toString())) {
                        String scheme2 = webResourceRequest.getUrl().getScheme();
                        if ((!TextUtils.isEmpty(scheme2) || !scheme2.equals("yixin")) && webResourceResponse.getStatusCode() != 801 && webResourceResponse.getStatusCode() != 805) {
                            if (WebViewUI.this.z0.equals(webResourceRequest.getUrl())) {
                                WebViewUI.this.z0 = "";
                                return;
                            }
                            WebViewUI.this.s0 = true;
                            super.onReceivedHttpError(webView, webResourceRequest, webResourceResponse);
                            Log.a("jxerr", "request.getUrl() = " + webResourceRequest.getUrl());
                            WebViewUI.this.c(WebViewUI.this.B.getString(R.string.open_web_fail, webResourceResponse.getStatusCode() + " " + webResourceResponse.getReasonPhrase() + " " + webResourceRequest.getUrl()));
                            if (WebViewUI.this.f0 != null) {
                                WebViewUI.this.f0.a(webView, webResourceRequest, webResourceResponse);
                            }
                        }
                    }
                } catch (Throwable th) {
                    Log.a(th);
                }
            }

            @Override
            public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
                String str;
                int i2;
                StringBuffer stringBuffer = new StringBuffer();
                stringBuffer.append("error:");
                if (sslError == null) {
                    str = " is null ";
                } else {
                    str = sslError.getUrl() + ", error:" + sslError.getPrimaryError();
                }
                stringBuffer.append(str);
                Log.d(stringBuffer.toString());
                if (bk0.Bc == bk0.g.Proceed) {
                    sslErrorHandler.proceed();
                } else if (bk0.Bc == bk0.g.Show_Dialog) {
                    int primaryError = sslError.getPrimaryError();
                    if (primaryError == 0) {
                        i2 = R.string.webview_ssl_error_0_msg;
                    } else if (primaryError == 1) {
                        i2 = R.string.webview_ssl_error_1_msg;
                    } else if (primaryError == 2) {
                        i2 = R.string.webview_ssl_error_2_msg;
                    } else if (primaryError == 3) {
                        i2 = R.string.webview_ssl_error_3_msg;
                    } else if (primaryError == 4) {
                        i2 = R.string.webview_ssl_error_4_msg;
                    } else if (primaryError != 5) {
                        i2 = R.string.webview_ssl_error_max_msg;
                    } else {
                        i2 = R.string.webview_ssl_error_5_msg;
                    }
                    new AlertDialog.Builder(WebViewUI.this.getContext()).setMessage(i2).setPositiveButton(R.string.accept, new c(sslErrorHandler)).setNegativeButton(R.string.cancel, new b(sslErrorHandler)).show();
                } else {
                    super.onReceivedSslError(webView, sslErrorHandler, sslError);
                }
            }

            @Override
            @RequiresApi(api = 21)
            public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
                if (webResourceRequest != null) {
                    try {
                        if (webResourceRequest.isForMainFrame() && webResourceRequest.getUrl() != null && webResourceRequest.getUrl().getPath() != null && webResourceRequest.getUrl().getPath().endsWith("/favicon.ico")) {
                            return new WebResourceResponse("image/png", null, new BufferedInputStream(webView.getContext().getAssets().open("empty_favicon.ico")));
                        }
                    } catch (Exception e2) {
                        e2.printStackTrace();
                    }
                }
                return super.shouldInterceptRequest(webView, webResourceRequest);
            }

            @Override
            public boolean shouldOverrideUrlLoading(WebView webView, String str) {
                if (str.startsWith("mailto:")) {
                    try {
                        WebViewUI.this.getContext().startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
                    } catch (Exception e2) {
                        ((BaseActivity) WebViewUI.this.getContext()).toastToMessage(R.string.no_right_mail);
                        Log.a((Throwable) e2);
                    }
                    return true;
                } else if (str.startsWith(WebView.SCHEME_TEL)) {
                    try {
                        WebViewUI.this.getContext().startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
                    } catch (Exception e3) {
                        ((BaseActivity) WebViewUI.this.getContext()).toastToMessage(R.string.no_right_tel);
                        Log.a((Throwable) e3);
                    }
                    return true;
                } else if (str.startsWith("sms:")) {
                    try {
                        WebViewUI.this.getContext().startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
                    } catch (Exception e4) {
                        ((BaseActivity) WebViewUI.this.getContext()).toastToMessage(R.string.no_right_sendsms);
                        Log.a((Throwable) e4);
                    }
                    return true;
                } else {
                    if (str.contains("alipays://platformapi")) {
                        try {
                            WebViewUI.this.getContext().startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
                            return true;
                        } catch (Exception unused) {
                        }
                    }
                    String lowerCase = str.toLowerCase();
                    if (!lowerCase.startsWith("yixin://") && !lowerCase.startsWith("http://") && !lowerCase.startsWith("https://") && !lowerCase.startsWith("file://") && !lowerCase.startsWith("ftp://") && !lowerCase.startsWith("rtmp://")) {
                        if (bk0.E0 && WebViewUI.this.getContext().getPackageName().equalsIgnoreCase("com.sitech.conference")) {
                            HashMap hashMap = new HashMap();
                            hashMap.put("Accept-Language", BaseActivity.getLang());
                            webView.loadUrl(str, hashMap);
                            return true;
                        }
                        try {
                            WebViewUI.this.getContext().startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
                        } catch (ActivityNotFoundException e5) {
                            boolean z = false;
                            try {
                                if (str.toLowerCase().startsWith("weixin://") && (WebViewUI.this.getContext() instanceof Activity) && !em0.b((Activity) WebViewUI.this.getContext())) {
                                    zq1.a(WebViewUI.this.getContext(), WebViewUI.this.getResources().getString(R.string.app_not_install_wechat) + "," + WebViewUI.this.getResources().getString(R.string.can_not_open) + ":" + str, 1).b();
                                    z = true;
                                }
                            } catch (Throwable th) {
                                Log.a(th);
                            }
                            if (!z) {
                                Log.a((Throwable) e5);
                            }
                        } catch (Exception e6) {
                            Log.a((Throwable) e6);
                        }
                        return true;
                    }
                    return super.shouldOverrideUrlLoading(webView, str);
                }
            }

            @Override
            public WebResourceResponse shouldInterceptRequest(WebView webView, String str) {
                if (str.toLowerCase().contains("/favicon.ico")) {
                    try {
                        return new WebResourceResponse("image/png", null, new BufferedInputStream(webView.getContext().getAssets().open("empty_favicon.ico")));
                    } catch (FileNotFoundException unused) {
                    } catch (Exception e2) {
                        e2.printStackTrace();
                    }
                }
                if (str.startsWith(WebViewUI.R0)) {
                    WebResourceResponse[] webResourceResponseArr = {null};
                    String replace = str.replace(WebViewUI.R0, "");
                    if (!TextUtils.isEmpty(replace)) {
                        Bitmap loadHeadBitmapFromFile = HeadBitmapData.getInstance().loadHeadBitmapFromFile(replace);
                        if (loadHeadBitmapFromFile == null) {
                            Bitmap a2 = dl0.a(bk0.Hd);
                            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                            a2.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
                            webResourceResponseArr[0] = new WebResourceResponse("image/png", "UTF-8", new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
                            HeadBitmapData.getInstance().loadHeadBitmap(replace, true, new a(webResourceResponseArr));
                        } else {
                            ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
                            loadHeadBitmapFromFile.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream2);
                            webResourceResponseArr[0] = new WebResourceResponse("image/png", "UTF-8", new ByteArrayInputStream(byteArrayOutputStream2.toByteArray()));
                        }
                        return webResourceResponseArr[0];
                    }
                }
                return super.shouldInterceptRequest(webView, str);
            }

            @Override
            public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) {
                super.onReceivedError(webView, webResourceRequest, webResourceError);
                if (webResourceRequest == null || webResourceRequest.getUrl() == null || !webResourceRequest.getUrl().toString().startsWith("yixin://")) {
                    StringBuffer stringBuffer = new StringBuffer();
                    stringBuffer.append("request:");
                    String str = " is null ";
                    stringBuffer.append(webResourceRequest == null ? " is null " : webResourceRequest.getUrl());
                    stringBuffer.append(";error:");
                    if (webResourceError != null) {
                        str = webResourceError.getErrorCode() + "-" + ((Object) webResourceError.getDescription());
                    }
                    stringBuffer.append(str);
                    Log.d(stringBuffer.toString());
                }
            }
        });
        this.k0 = new JSApi(this.B, this);
        addJavascriptInterface(this.k0, "JSApi");
        this.l0 = new JSNative(this.B);
        addJavascriptInterface(this.l0, "Native");
        this.m0 = new DownloadBlobFileJSInterface(this.B);
        addJavascriptInterface(this.m0, "YXDownloadBlob");
    }

    private void l() {
        loadUrl("javascript:(function(){var objs = document.getElementsByTagName(\"img\"); for(var i=0;i<objs.length;i++)  {    objs[i].onclick=function()         {          window.JSApi.openImage(this.src);         }  }})()");
    }

    private Bitmap m() {
        Picture capturePicture = capturePicture();
        Bitmap createBitmap = Bitmap.createBitmap(capturePicture.getWidth(), capturePicture.getHeight(), Bitmap.Config.ARGB_8888);
        capturePicture.draw(new Canvas(createBitmap));
        return createBitmap;
    }

    public void n() {
        ProgressDialog progressDialog = this.C;
        if (progressDialog != null) {
            progressDialog.dismiss();
            this.C = null;
        }
    }

    private void o() {
        Throwable th;
        InputStream inputStream;
        IOException e2;
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        InputStream inputStream2 = null;
        try {
            try {
                inputStream = getResources().getAssets().open("js/yxjs.js");
                try {
                    byte[] bArr = new byte[1024];
                    while (true) {
                        int read = inputStream.read(bArr);
                        if (read <= 0) {
                            break;
                        }
                        byteArrayOutputStream.write(bArr, 0, read);
                    }
                    this.A = byteArrayOutputStream.toString();
                    if (Build.VERSION.SDK_INT < 19) {
                        loadUrl("javascript:" + this.A);
                    } else {
                        evaluateJavascript(this.A, null);
                    }
                } catch (IOException e3) {
                    e2 = e3;
                    Log.a((Throwable) e2);
                }
            } catch (Throwable th2) {
                th = th2;
                if (0 != 0) {
                    try {
                        inputStream2.close();
                    } catch (Exception unused) {
                    }
                }
                try {
                    byteArrayOutputStream.close();
                } catch (Exception unused2) {
                }
                throw th;
            }
        } catch (IOException e4) {
            inputStream = null;
            e2 = e4;
        } catch (Throwable th3) {
            th = th3;
            if (0 != 0) {
            }
            byteArrayOutputStream.close();
            throw th;
        }
        try {
            byteArrayOutputStream.close();
        } catch (Exception unused3) {
        }
    }

    public void p() {
        Log.d("enter");
        try {
            if (!this.n0 && !this.s0) {
                Log.d("deal");
                if (Build.VERSION.SDK_INT < 19) {
                    loadUrl("javascript:" + this.A);
                    loadUrl("javascript:typeof connectYixinJSBridge === 'function' ? connectYixinJSBridge() : false;");
                    loadUrl("javascript:navigator.languages=['" + BaseActivity.getLang() + "']");
                } else {
                    evaluateJavascript(this.A, null);
                    evaluateJavascript("javascript:typeof connectYixinJSBridge === 'function' ? connectYixinJSBridge() : false;", null);
                    evaluateJavascript("javascript:navigator.languages=['" + BaseActivity.getLang() + "']", null);
                }
            }
        } catch (Exception e2) {
            Log.a((Throwable) e2);
        }
    }

    public void q() {
        if (this.C == null) {
            this.C = new ProgressDialog(this.B);
            this.C.setProgressStyle(0);
            this.C.setMessage(getResources().getString(R.string.moreapp_downloading));
            this.C.setIndeterminate(false);
            this.C.setCancelable(true);
            this.C.setCanceledOnTouchOutside(false);
            this.C.setOnDismissListener(new d());
            this.C.show();
        }
    }

    public void a(String str) {
    }

    @Override
    public void destroy() {
        MyApplication.h().b(bk0.Ea, this);
        jb1.a(this);
        super.destroy();
    }

    public JSApi getJsapi() {
        return this.k0;
    }

    public Context getmContext() {
        return this.B;
    }

    public void k() {
        b(ck0.v() + "screenshot_" + System.currentTimeMillis() + ".png");
        MyApplication.h().a(bk0.Ia, this.Q0);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        getScale();
        getContentHeight();
        getWebScrollY();
        getHeight();
        int action = motionEvent.getAction();
        if (action == 0) {
            this.O0 = motionEvent.getX();
            this.N0 = motionEvent.getY();
        } else if (action == 2) {
            this.M0 = this.O0;
            this.L0 = this.N0;
            this.O0 = motionEvent.getX();
            this.N0 = motionEvent.getY();
            if (this.L0 >= getTop() && this.L0 <= getBottom() && this.M0 >= getLeft() && this.M0 <= getRight()) {
                b(true);
                return super.onInterceptTouchEvent(motionEvent);
            }
            b(false);
        }
        return super.onInterceptTouchEvent(motionEvent);
    }

    @Override
    public boolean onTouch(View view, MotionEvent motionEvent) {
        int action = motionEvent.getAction();
        if (action != 2) {
            if (action == 5 && motionEvent.getPointerCount() == 2) {
                for (int i2 = 0; i2 < motionEvent.getPointerCount(); i2++) {
                    if (i2 == 0) {
                        this.D0 = motionEvent.getX(i2);
                        this.E0 = motionEvent.getY(i2);
                    } else if (i2 == 1) {
                        this.F0 = motionEvent.getX(i2);
                        this.G0 = motionEvent.getY(i2);
                    }
                }
            }
        } else if (motionEvent.getPointerCount() == 2) {
            for (int i3 = 0; i3 < motionEvent.getPointerCount(); i3++) {
                if (i3 == 0) {
                    this.H0 = motionEvent.getX(i3);
                    this.I0 = motionEvent.getY(i3);
                } else if (i3 == 1) {
                    this.J0 = motionEvent.getX(i3);
                    this.K0 = motionEvent.getY(i3);
                }
            }
            float sqrt = (float) Math.sqrt(Math.pow(this.F0 - this.D0, 2.0d) + Math.pow(this.G0 - this.E0, 2.0d));
            float sqrt2 = (float) Math.sqrt(Math.pow(this.J0 - this.H0, 2.0d) + Math.pow(this.K0 - this.I0, 2.0d));
            Log.a("onTouch", "disOld=" + sqrt + "|disNew=" + sqrt2);
            if (sqrt - sqrt2 >= 25.0f) {
                zoomOut();
            } else if (sqrt2 - sqrt >= 25.0f) {
                zoomIn();
            }
            this.D0 = this.H0;
            this.F0 = this.J0;
            this.E0 = this.I0;
            this.G0 = this.K0;
        }
        return false;
    }

    public void setMyWebView(MyWebView myWebView) {
        this.A0 = myWebView;
        JSApi jSApi = this.k0;
        if (jSApi != null) {
            jSApi.setMyWebView(myWebView);
        }
    }

    @Override
    public void setWebChromeClient(WebChromeClient webChromeClient) {
        super.setWebChromeClient(webChromeClient);
        this.v0 = webChromeClient;
    }

    public void c(String str) {
        if (this.B0) {
            xp1.a(this.B, str, 17, 0, 0, 0).show();
        }
    }

    public void d(String str) {
        if (!bk0.w2 || TextUtils.isEmpty(str) || TextUtils.equals("about:blank", str)) {
            return;
        }
        CookieManager cookieManager = CookieManager.getInstance();
        String cookie = cookieManager.getCookie(str);
        Log.d("url:" + str);
        if (!TextUtils.isEmpty(cookie)) {
            Log.d("cookie:" + cookie);
            this.e0 = cookie;
        } else if (!TextUtils.isEmpty(this.e0)) {
            Log.d("sessionID:" + this.e0);
            cookieManager.setCookie(str, this.e0);
        } else {
            Log.d("cookie is null && sessionId is null");
        }
        if (Build.VERSION.SDK_INT < 21) {
            CookieSyncManager.getInstance().sync();
        } else {
            CookieManager.getInstance().flush();
        }
    }

    private String e(String str) {
        String a2;
        if (str.indexOf(vb1.j) >= 0) {
            String r = km0.r(MyApplication.h().a.w());
            String b2 = bf1.L().b();
            String k2 = bf1.L().k();
            if (k2.toLowerCase().startsWith("{md5}")) {
                a2 = pk0.a(om0.a(r, b2, k2, bk0.o6));
            } else {
                a2 = pk0.a(om0.a(r, b2, "{MD5}" + om0.a(k2), bk0.o6));
            }
            StringBuilder sb = new StringBuilder();
            sb.append(str);
            String str2 = Operators.CONDITION_IF_STRING;
            if (str.indexOf(Operators.CONDITION_IF_STRING) > 0) {
                str2 = "&";
            }
            sb.append(str2);
            sb.append("code=");
            sb.append(a2);
            return sb.toString();
        }
        return str;
    }

    public void b(String str, String str2) {
        this.t0 = new np1(this.B);
        this.t0.a(8);
        this.t0.a(getResources().getString(R.string.webview_download_tip, str2));
        this.t0.b(R.string.confirm, new b(str, str2));
        this.t0.a(R.string.cancel, new c());
    }

    private void a(String str, InputStream inputStream) {
        File file = new File(this.D, str);
        this.j0 = false;
        try {
            file.getParentFile().mkdirs();
            FileOutputStream fileOutputStream = new FileOutputStream(file);
            byte[] bArr = new byte[2048];
            while (true) {
                int read = inputStream.read(bArr);
                if (read != -1) {
                    fileOutputStream.write(bArr, 0, read);
                } else {
                    fileOutputStream.flush();
                    fileOutputStream.close();
                    return;
                }
            }
        } catch (Throwable th) {
            Log.a(th);
        }
    }

    private void b(boolean z) {
        for (Integer num : this.C0) {
            try {
                ViewParent parent = getParent();
                for (int i2 = 0; i2 < num.intValue() - 1; i2++) {
                    parent = parent.getParent();
                }
                parent.requestDisallowInterceptTouchEvent(z);
            } catch (Throwable th) {
                Log.a(th);
            }
        }
    }

    public WebViewUI(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.n0 = false;
        this.o0 = "";
        this.p0 = "";
        this.s0 = false;
        this.u0 = false;
        this.x0 = bk0.h.Share == bk0.Hc;
        this.y0 = "";
        this.z0 = "";
        this.B0 = true;
        this.C0 = new ArrayList();
        this.Q0 = new e();
        this.B = context;
        init();
    }

    public static String a(String str, String str2) {
        HttpURLConnection httpURLConnection;
        String a2;
        HttpURLConnection httpURLConnection2 = null;
        try {
            try {
                URL url = new URL(str);
                Log.a("fileLog=====1", url.toString());
                httpURLConnection = (HttpURLConnection) url.openConnection();
            } catch (Exception e2) {
                e = e2;
            }
        } catch (Throwable th) {
            th = th;
            httpURLConnection = httpURLConnection2;
        }
        try {
            if (!TextUtils.isEmpty(str2)) {
                httpURLConnection.setRequestProperty("Cookie", str2);
            }
            Log.a("fileLog=====2", httpURLConnection.toString());
            httpURLConnection.connect();
            String headerField = httpURLConnection.getHeaderField("Content-Disposition");
            Log.a("fileLog=====3", headerField);
            String headerField2 = httpURLConnection.getHeaderField("Content-Type");
            Log.a("fileLog=====4", headerField2);
            if (headerField2.contains(";")) {
                String substring = headerField2.substring(0, headerField2.indexOf(";"));
                Log.a("fileLog111=====5", substring);
                a2 = gt1.a(str, headerField, substring);
            } else {
                a2 = gt1.a(str, headerField, headerField2);
            }
            Log.a("fileLog=====6", a2);
            String decode = URLDecoder.decode(a2);
            if (httpURLConnection != null) {
                try {
                    httpURLConnection.disconnect();
                } catch (Exception e3) {
                    e3.printStackTrace();
                }
            }
            return decode;
        } catch (Exception e4) {
            e = e4;
            httpURLConnection2 = httpURLConnection;
            Log.a((Throwable) e);
            if (httpURLConnection2 != null) {
                try {
                    httpURLConnection2.disconnect();
                } catch (Exception e5) {
                    e5.printStackTrace();
                }
            }
            return "";
        } catch (Throwable th2) {
            th = th2;
            if (httpURLConnection != null) {
                try {
                    httpURLConnection.disconnect();
                } catch (Exception e6) {
                    e6.printStackTrace();
                }
            }
            throw th;
        }
    }

    private void b(String str) {
        Intent intent = new Intent(getContext(), ScreenShotActivity.class);
        intent.putExtra("path", str);
        JSApi jSApi = this.k0;
        if (jSApi != null) {
            if (jSApi.getmCustomWebTitleView() != null) {
                if (this.k0.getmCustomWebTitleView().getVisibility() == 8) {
                    intent.putExtra(ScreenShotActivity.e, false);
                }
            } else if (this.k0.getmTitleView() != null && this.k0.getmTitleView().getVisibility() == 8) {
                intent.putExtra(ScreenShotActivity.e, false);
            }
        } else {
            intent.putExtra(ScreenShotActivity.e, true);
        }
        if (sb1.f(getContext())) {
            intent.putExtra(ScreenShotActivity.f, true);
        } else {
            intent.putExtra(ScreenShotActivity.f, false);
        }
        getContext().startActivity(intent);
    }

    public WebViewUI(Context context, AttributeSet attributeSet, int i2) {
        super(context, attributeSet, i2);
        this.n0 = false;
        this.o0 = "";
        this.p0 = "";
        this.s0 = false;
        this.u0 = false;
        this.x0 = bk0.h.Share == bk0.Hc;
        this.y0 = "";
        this.z0 = "";
        this.B0 = true;
        this.C0 = new ArrayList();
        this.Q0 = new e();
        this.B = context;
        init();
    }

    public String a(String str, String str2, String str3, String str4) {
        HttpURLConnection httpURLConnection;
        InputStream inputStream;
        InputStream inputStream2;
        String e2;
        String str5;
        try {
            try {
                e2 = e(str);
                httpURLConnection = (HttpURLConnection) new URL(e2).openConnection();
            } catch (Throwable th) {
                th = th;
            }
            try {
                httpURLConnection.setConnectTimeout(60000);
                httpURLConnection.setReadTimeout(60000);
                httpURLConnection.addRequestProperty(LazyHeaders.Builder.USER_AGENT_HEADER, this.y0);
                httpURLConnection.addRequestProperty("Content-Type", bk0.g8);
                httpURLConnection.addRequestProperty("Referer", this.o0);
                StringBuilder sb = new StringBuilder();
                sb.append(str3);
                if (TextUtils.isEmpty(bk0.yb)) {
                    str5 = "";
                } else {
                    str5 = ";CASTGC=" + bk0.yb + ";Domain=" + vb1.i;
                }
                sb.append(str5);
                String sb2 = sb.toString();
                httpURLConnection.addRequestProperty("Cookie", sb2);
                inputStream2 = httpURLConnection.getInputStream();
                try {
                    int contentLength = httpURLConnection.getContentLength();
                    Log.g("url:" + str + ";urlnew:" + e2 + ";fileName=" + str2 + ";filesize=" + contentLength + ";sessionID:" + sb2 + ";responsecode:" + httpURLConnection.getResponseCode());
                    File file = new File(str4);
                    if (!file.exists() && !file.isDirectory()) {
                        file.mkdir();
                    }
                    File file2 = new File(str4, str2);
                    if (file2.exists()) {
                        if (file2.length() == contentLength) {
                            Log.g("The file has already exists.");
                            if (inputStream2 != null) {
                                try {
                                    inputStream2.close();
                                } catch (Exception e3) {
                                    Log.a((Throwable) e3);
                                }
                            }
                            if (httpURLConnection != null) {
                                try {
                                    httpURLConnection.disconnect();
                                } catch (Exception e4) {
                                    Log.a((Throwable) e4);
                                }
                            }
                            return str2;
                        }
                        Log.g("The file has already exists, but size=" + file2.length() + ";filesize=" + contentLength);
                        file2.delete();
                    }
                    if (200 == httpURLConnection.getResponseCode()) {
                        a(str2, inputStream2);
                        if (inputStream2 != null) {
                            try {
                                inputStream2.close();
                            } catch (Exception e5) {
                                Log.a((Throwable) e5);
                            }
                        }
                        if (httpURLConnection != null) {
                            try {
                                httpURLConnection.disconnect();
                            } catch (Exception e6) {
                                Log.a((Throwable) e6);
                            }
                        }
                        return str2;
                    } else if (302 != httpURLConnection.getResponseCode()) {
                        if (inputStream2 != null) {
                            try {
                                inputStream2.close();
                            } catch (Exception e7) {
                                Log.a((Throwable) e7);
                            }
                        }
                        if (httpURLConnection != null) {
                            try {
                                httpURLConnection.disconnect();
                            } catch (Exception e8) {
                                Log.a((Throwable) e8);
                            }
                        }
                        return null;
                    } else {
                        String a2 = a(httpURLConnection.getHeaderField(HttpUrlFetcher.REDIRECT_HEADER_FIELD), str2, str3, str4);
                        if (inputStream2 != null) {
                            try {
                                inputStream2.close();
                            } catch (Exception e9) {
                                Log.a((Throwable) e9);
                            }
                        }
                        if (httpURLConnection != null) {
                            try {
                                httpURLConnection.disconnect();
                            } catch (Exception e10) {
                                Log.a((Throwable) e10);
                            }
                        }
                        return a2;
                    }
                } catch (Exception e11) {
                    e = e11;
                    Log.a((Throwable) e);
                    if (inputStream2 != null) {
                        try {
                            inputStream2.close();
                        } catch (Exception e12) {
                            Log.a((Throwable) e12);
                        }
                    }
                    if (httpURLConnection != null) {
                        try {
                            httpURLConnection.disconnect();
                        } catch (Exception e13) {
                            Log.a((Throwable) e13);
                        }
                    }
                    return null;
                }
            } catch (Exception e14) {
                e = e14;
                inputStream2 = null;
            } catch (Throwable th2) {
                th = th2;
                inputStream = null;
                if (inputStream != null) {
                    try {
                        inputStream.close();
                    } catch (Exception e15) {
                        Log.a((Throwable) e15);
                    }
                }
                if (httpURLConnection != null) {
                    try {
                        httpURLConnection.disconnect();
                    } catch (Exception e16) {
                        Log.a((Throwable) e16);
                    }
                }
                throw th;
            }
        } catch (Exception e17) {
            e = e17;
            httpURLConnection = null;
            inputStream2 = null;
        } catch (Throwable th3) {
            th = th3;
            httpURLConnection = null;
            inputStream = null;
        }
    }
}