星辰影院解锁vip v1.0.4版本的 MD5 值为:3d99bbcbb0d5d5e568b9f6134424c24e

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


package com.iqiyi.qyverificationcenter.webview;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Build;
import android.util.AttributeSet;
import android.webkit.JavascriptInterface;
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 androidx.annotation.Keep;
import com.iqiyi.biologicalprobe.LogMgr;
import com.iqiyi.biologicalprobe.utils.Utils;
import com.iqiyi.qyverificationcenter.bean.QYVerifyConstants;
import com.iqiyi.qyverificationcenter.util.VerifyPingBackManager;
import com.iqiyi.webcontainer.webview.QYWebviewCoreCallback;
import com.sensorsdata.analytics.android.sdk.SensorsDataAutoTrackHelper;
import com.sensorsdata.analytics.android.sdk.data.adapter.DbParams;
import com.sensorsdata.analytics.android.sdk.util.Base64Coder;
import java.util.HashMap;
import org.json.JSONException;
import org.json.JSONObject;

@Keep
public class JSWebView extends WebView {
    private static com.iqiyi.qyverificationcenter.interfaces.b mJSResponseCallback;
    private com.iqiyi.qyverificationcenter.interfaces.c mCallBackUrlLoad;

    public class a extends WebViewClient {
        a() {
        }

        @Override
        public void onPageFinished(WebView webView, String str) {
            super.onPageFinished(webView, str);
            if (JSWebView.this.mCallBackUrlLoad != null) {
                JSWebView.this.mCallBackUrlLoad.a();
            }
            webView.setBackgroundColor(0);
            webView.loadUrl("javascript:document.body.style.backgroundColor = 'transparent';void(0);");
            SensorsDataAutoTrackHelper.loadUrl2(webView, "javascript:document.body.style.backgroundColor = 'transparent';void(0);");
        }

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

        @Override
        public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) {
            super.onReceivedError(webView, webResourceRequest, webResourceError);
            if (JSWebView.this.mCallBackUrlLoad == null || Build.VERSION.SDK_INT < 23) {
                return;
            }
            JSWebView.this.mCallBackUrlLoad.a(webResourceError.getErrorCode() + webResourceError.getDescription().toString() + webResourceRequest.getUrl().toString());
        }

        @Override
        public void onReceivedHttpError(WebView webView, WebResourceRequest webResourceRequest, WebResourceResponse webResourceResponse) {
            super.onReceivedHttpError(webView, webResourceRequest, webResourceResponse);
            if (JSWebView.this.mCallBackUrlLoad == null || Build.VERSION.SDK_INT < 21) {
                return;
            }
            JSWebView.this.mCallBackUrlLoad.a(webResourceResponse.getReasonPhrase());
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView webView, String str) {
            if (webView == null || str == null) {
                return true;
            }
            webView.loadUrl(str);
            SensorsDataAutoTrackHelper.loadUrl2(webView, str);
            return true;
        }
    }

    public class b implements com.iqiyi.qyverificationcenter.interfaces.a {
        b(JSWebView jSWebView) {
        }

        @Override
        public void a(JSONObject jSONObject, JSWebView jSWebView) {
            if (jSWebView != null) {
                Context context = jSWebView.getContext();
                if (context instanceof Activity) {
                    ((Activity) context).finish();
                }
            }
            String optString = jSONObject != null ? jSONObject.optString(DbParams.KEY_CHANNEL_RESULT) : null;
            if (optString != null && optString.equals("RESULT_OK")) {
                if (JSWebView.mJSResponseCallback != null) {
                    JSWebView.mJSResponseCallback.onSuccess(jSONObject.toString());
                }
            } else if (JSWebView.mJSResponseCallback != null) {
                if (jSONObject != null) {
                    JSWebView.mJSResponseCallback.a(jSONObject.toString());
                } else {
                    JSWebView.mJSResponseCallback.a("");
                }
            }
        }
    }

    class c implements Runnable {
        final String a;

        c(String str) {
            this.a = str;
        }

        @Override
        public void run() {
            JSWebView jSWebView = JSWebView.this;
            String str = this.a;
            jSWebView.loadUrl(str);
            SensorsDataAutoTrackHelper.loadUrl2(jSWebView, str);
            LogMgr.d("", "callJSMethod 3 " + this.a);
        }
    }

    public static class d {
        JSWebView a;

        d(JSWebView jSWebView) {
            this.a = jSWebView;
        }

        @JavascriptInterface
        public void invoke(String str) {
            LogMgr.d("", "IqiyiJSBridge invoke " + str);
            try {
                JSONObject jSONObject = new JSONObject(str);
                String optString = jSONObject.optString("type");
                LogMgr.d("", "IqiyiJSBridge invoke 3 ");
                if (optString.isEmpty()) {
                    return;
                }
                LogMgr.d("", "IqiyiJSBridge invoke 4 " + optString);
                JSONObject optJSONObject = jSONObject.optJSONObject("request");
                com.iqiyi.qyverificationcenter.interfaces.a a = com.iqiyi.qyverificationcenter.webview.a.d().a(optString);
                LogMgr.d("", "IqiyiJSBridge invoke 5");
                if (a != null) {
                    LogMgr.d("", "IqiyiJSBridge invoke 6");
                    a.a(optJSONObject, this.a);
                }
            } catch (JSONException e2) {
                LogMgr.d("", "IqiyiJSBridge invoke 2");
                VerifyPingBackManager.verifyError(QYVerifyConstants.VerifyResponCode.kError10005, "PARSE_DATA_ERROR", e2.getMessage());
            }
        }
    }

    public JSWebView(Context context) {
        super(context);
        init(context);
    }

    public JSWebView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        init(context);
    }

    public JSWebView(Context context, AttributeSet attributeSet, int i2) {
        super(context, attributeSet, i2);
        init(context);
    }

    public static void callJsMethodWithCallback(QYWebviewCoreCallback qYWebviewCoreCallback, String str, int i2, String str2, String str3) {
        LogMgr.d("", "callJsMethodWithCallback 1");
        qYWebviewCoreCallback.invoke(generateResponseJson(str3), true);
        LogMgr.d("", "callJsMethodWithCallback 2");
    }

    public static JSONObject generateResponseJson(String str) {
        JSONObject jSONObject = new JSONObject();
        try {
            LogMgr.d("", "generateResponseJson 1" + str);
            HashMap hashMap = new HashMap();
            hashMap.put("switch", com.iqiyi.qyverificationcenter.clound.b.g().n() ? "1" : "0");
            jSONObject.put("bio_status", Utils.toJson(hashMap));
            jSONObject.put("bio", str);
            LogMgr.d("", "generateResponseJson 2 " + Utils.toJson(jSONObject));
        } catch (JSONException e2) {
            VerifyPingBackManager.verifyError(QYVerifyConstants.VerifyResponCode.kError10005, "PARSE_DATA_ERROR", e2.getMessage());
            LogMgr.d("", "generateResponseJson 3");
        }
        return jSONObject;
    }

    private void init(Context context) {
        initSettings();
        setWebViewClient();
        if (Build.VERSION.SDK_INT < 23) {
            setLayerType(1, null);
        }
        resumeTimers();
        addJavascriptInterface(new d(this), "IqiyiJsBridge");
        registerClosePageCallBack();
        setBackgroundColor(0);
    }

    @SuppressLint({"SetJavaScriptEnabled"})
    private void initSettings() {
        WebSettings.LayoutAlgorithm layoutAlgorithm;
        try {
            WebSettings settings = getSettings();
            settings.setJavaScriptEnabled(true);
            settings.setDefaultTextEncodingName(Base64Coder.CHARSET_UTF8);
            settings.setLoadWithOverviewMode(true);
            settings.setSavePassword(false);
            settings.setSaveFormData(false);
            settings.setCacheMode(-1);
            settings.setAllowFileAccess(false);
            if (Build.VERSION.SDK_INT > 15) {
                try {
                    settings.setAllowFileAccessFromFileURLs(false);
                    settings.setAllowUniversalAccessFromFileURLs(false);
                } catch (Exception e2) {
                    LogMgr.e("", e2);
                }
            }
            int i2 = Build.VERSION.SDK_INT;
            if (i2 >= 14) {
                settings.setPluginState(WebSettings.PluginState.ON);
            }
            if (i2 >= 17) {
                settings.setMediaPlaybackRequiresUserGesture(false);
            }
            if (i2 >= 21) {
                settings.setMixedContentMode(0);
            }
            settings.setLoadsImagesAutomatically(true);
            settings.setDatabaseEnabled(true);
            settings.setDomStorageEnabled(true);
            settings.setUseWideViewPort(true);
            if (i2 < 19) {
                layoutAlgorithm = WebSettings.LayoutAlgorithm.NARROW_COLUMNS;
            } else {
                try {
                    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
                    return;
                } catch (Exception unused) {
                    layoutAlgorithm = WebSettings.LayoutAlgorithm.NORMAL;
                }
            }
            settings.setLayoutAlgorithm(layoutAlgorithm);
        } catch (Exception e3) {
            VerifyPingBackManager.verifyError(QYVerifyConstants.VerifyResponCode.kError10006, "JS_LOAD_ERROR", e3.getMessage());
        }
    }

    private void registerClosePageCallBack() {
        com.iqiyi.qyverificationcenter.webview.a.d().c("JSBRIDGE_CLOSE_PAGE", new b(this));
    }

    public static void setJSResponseCallback(com.iqiyi.qyverificationcenter.interfaces.b bVar) {
        mJSResponseCallback = bVar;
    }

    private void setWebViewClient() {
        setWebViewClient(new a());
    }

    public void callJSMethod(String str, int i2, String str2, String str3) {
        LogMgr.d("", "callJSMethod 1" + str2);
        String str4 = "javascript:window.iqiyi.invoke('" + generateResponseJson(str3).toString() + "')";
        LogMgr.d("", "callJSMethod 2");
        post(new c(str4));
    }

    public void setUrlLoadCallback(com.iqiyi.qyverificationcenter.interfaces.c cVar) {
        this.mCallBackUrlLoad = cVar;
    }
}