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

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


package com.sitech.oncon.activity;

import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Build;
import android.os.Bundle;
import android.os.Message;
import android.text.TextUtils;
import android.view.View;
import android.webkit.CookieManager;
import android.webkit.HttpAuthHandler;
import android.webkit.JavascriptInterface;
import android.webkit.SslErrorHandler;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import androidx.annotation.RequiresApi;
import com.sitech.core.util.Log;
import com.sitech.oncon.R;
import defpackage.bk0;
import java.io.BufferedInputStream;
import java.io.FileNotFoundException;
public class ProtocolViewActivity extends BaseActivity {
    public WebView a;
    public ProgressBar c;

    public class b extends WebChromeClient {
        public b() {
        }

        @Override
        public void onProgressChanged(WebView webView, int i) {
            try {
                super.onProgressChanged(webView, i);
                if (ProtocolViewActivity.this.c != null) {
                    ProtocolViewActivity.this.c.setProgress(i);
                }
                if (i < 100 && ProtocolViewActivity.this.c != null) {
                    ProtocolViewActivity.this.c.setVisibility(0);
                }
                if (i != 100 || ProtocolViewActivity.this.c == null) {
                    return;
                }
                ProtocolViewActivity.this.c.setVisibility(8);
            } catch (Throwable th) {
                Log.a(th);
            }
        }
    }

    private void init() {
        WebSettings settings = this.a.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setGeolocationEnabled(true);
        settings.setGeolocationDatabasePath(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);
            } else {
                settings.setAllowFileAccessFromFileURLs(false);
                settings.setAllowUniversalAccessFromFileURLs(false);
            }
        }
        if (bk0.w2) {
            CookieManager cookieManager = CookieManager.getInstance();
            cookieManager.setAcceptCookie(true);
            cookieManager.setAcceptThirdPartyCookies(this.a, true);
        }
        settings.setAllowFileAccess(true);
        settings.setSupportZoom(true);
        settings.setSavePassword(bk0.v2);
        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
        settings.setLoadWithOverviewMode(true);
        settings.setUseWideViewPort(true);
        settings.setTextZoom(bk0.e3);
        String userAgentString = settings.getUserAgentString();
        if (!TextUtils.isEmpty(bk0.l3)) {
            settings.setUserAgentString(userAgentString + " " + bk0.l3);
            StringBuilder sb = new StringBuilder();
            sb.append("webSettings.getUserAgentString():");
            sb.append(settings.getUserAgentString());
            Log.d(sb.toString());
        }
        settings.setCacheMode(2);
        settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
        settings.setDatabaseEnabled(true);
        settings.setDatabasePath(getDir("database", 0).getPath());
        settings.setDomStorageEnabled(true);
        getDir(rm0.a, 0).getPath();
        settings.setCacheMode(2);
        settings.setLoadsImagesAutomatically(true);
        settings.setBlockNetworkImage(false);
        this.a.setSaveEnabled(false);
        this.a.setWebViewClient(new a());
        this.a.setWebChromeClient(new b());
    }

    @Override
    public void onClick(View view) {
        super.onClick(view);
        if (view.getId() == R.id.common_title_TV_left) {
            finish();
        }
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_protocol_view);
        this.a = (WebView) findViewById(R.id.webview);
        this.c = (ProgressBar) findViewById(R.id.pbar);
        init();
        this.a.loadUrl(getIntent().getStringExtra("url"));
    }

    public class a extends WebViewClient {

        public class DialogInterface$OnClickListenerC0102a implements DialogInterface.OnClickListener {
            public final SslErrorHandler a;

            public DialogInterface$OnClickListenerC0102a(SslErrorHandler sslErrorHandler) {
                this.a = sslErrorHandler;
            }

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

        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.proceed();
            }
        }

        public a() {
        }

        @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) {
            try {
                Log.d("WebView onPageFinished:" + str);
                super.onPageFinished(webView, str);
            } catch (Throwable th) {
                Log.a(th);
            }
        }

        @Override
        public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
            try {
                Log.d("WebView onPageStarted:" + str);
                if (Build.VERSION.SDK_INT < 19) {
                    WebView webView2 = ProtocolViewActivity.this.a;
                    webView2.loadUrl("javascript:navigator.languages=['" + BaseActivity.getLang() + "']");
                    WebView webView3 = ProtocolViewActivity.this.a;
                    webView3.loadUrl("javascript:navigator.languages[0]='" + BaseActivity.getLang() + "'");
                } else {
                    WebView webView4 = ProtocolViewActivity.this.a;
                    webView4.evaluateJavascript("javascript:navigator.languages=['" + BaseActivity.getLang() + "']", null);
                    WebView webView5 = ProtocolViewActivity.this.a;
                    webView5.evaluateJavascript("javascript:navigator.languages[0]='" + BaseActivity.getLang() + "'", null);
                }
            } catch (Throwable th) {
                Log.a(th);
            }
        }

        @Override
        public void onReceivedError(WebView webView, int i, String str, String str2) {
            try {
                if (str2.startsWith("yixin://")) {
                    return;
                }
                Log.d(i + ":" + 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]);
            }
        }

        @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());
            } catch (Throwable th) {
                Log.a(th);
            }
        }

        @Override
        public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
            String str;
            int i;
            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) {
                    i = R.string.webview_ssl_error_0_msg;
                } else if (primaryError == 1) {
                    i = R.string.webview_ssl_error_1_msg;
                } else if (primaryError == 2) {
                    i = R.string.webview_ssl_error_2_msg;
                } else if (primaryError == 3) {
                    i = R.string.webview_ssl_error_3_msg;
                } else if (primaryError == 4) {
                    i = R.string.webview_ssl_error_4_msg;
                } else if (primaryError != 5) {
                    i = R.string.webview_ssl_error_max_msg;
                } else {
                    i = R.string.webview_ssl_error_5_msg;
                }
                new AlertDialog.Builder(ProtocolViewActivity.this).setMessage(i).setPositiveButton(R.string.accept, new b(sslErrorHandler)).setNegativeButton(R.string.cancel, new DialogInterface$OnClickListenerC0102a(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 e) {
                    e.printStackTrace();
                }
            }
            return super.shouldInterceptRequest(webView, webResourceRequest);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView webView, String str) {
            if (str.startsWith("mailto:")) {
                try {
                    ProtocolViewActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
                } catch (Exception e) {
                    ProtocolViewActivity.this.toastToMessage(R.string.no_right_mail);
                    Log.a((Throwable) e);
                }
                return true;
            } else if (str.startsWith(com.tencent.smtt.sdk.WebView.SCHEME_TEL)) {
                try {
                    ProtocolViewActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
                } catch (Exception e2) {
                    ProtocolViewActivity.this.toastToMessage(R.string.no_right_tel);
                    Log.a((Throwable) e2);
                }
                return true;
            } else if (str.startsWith("sms:")) {
                try {
                    ProtocolViewActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
                } catch (Exception e3) {
                    ProtocolViewActivity.this.toastToMessage(R.string.no_right_sendsms);
                    Log.a((Throwable) e3);
                }
                return true;
            } else {
                if (str.contains("alipays://platformapi")) {
                    try {
                        ProtocolViewActivity.this.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://")) {
                    try {
                        ProtocolViewActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
                    } catch (ActivityNotFoundException e4) {
                        boolean z = false;
                        try {
                            if (str.toLowerCase().startsWith("weixin://") && !em0.b(ProtocolViewActivity.this)) {
                                ProtocolViewActivity.this.toastToMessage(ProtocolViewActivity.this.getResources().getString(R.string.app_not_install_wechat) + "," + ProtocolViewActivity.this.getResources().getString(R.string.can_not_open) + ":" + str);
                                z = true;
                            }
                        } catch (Throwable th) {
                            Log.a(th);
                        }
                        if (!z) {
                            Log.a((Throwable) e4);
                        }
                    } catch (Exception e5) {
                        Log.a((Throwable) e5);
                    }
                    return true;
                }
                return super.shouldOverrideUrlLoading(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());
                if (Build.VERSION.SDK_INT >= 23) {
                    stringBuffer.append(";error:");
                    if (webResourceError != null) {
                        str = webResourceError.getErrorCode() + "-" + ((Object) webResourceError.getDescription());
                    }
                    stringBuffer.append(str);
                }
                Log.d(stringBuffer.toString());
            }
        }

        @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 e) {
                    e.printStackTrace();
                }
            }
            return super.shouldInterceptRequest(webView, str);
        }
    }
}