同程有借 v1.0.0版本的 MD5 值为:e33397cdbab33543d0c134ec96d77fb8

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


package com.moture.plugin.core;

import android.content.Context;
import android.webkit.WebView;
import com.sensorsdata.analytics.android.sdk.jsbridge.JSHookAop;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class BridgeUtil {
    public static final String CALLBACK_ID_FORMAT = "JAVA_CB_%s";
    public static final String JAVASCRIPT_STR = "javascript:%s";
    public static final String JS_HANDLE_MESSAGE_FROM_JAVA = "javascript:_handleMessageFromNative('%s');";
    public static final String UNDERLINE_STR = "_";

    public static String assetFile2Str(Context context, String str) {
        InputStream inputStream;
        String readLine;
        ?? r02 = 0;
        try {
            try {
                inputStream = context.getAssets().open(str);
                try {
                    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
                    StringBuilder sb = new StringBuilder();
                    do {
                        readLine = bufferedReader.readLine();
                        if (readLine != null && !readLine.matches("^\\s*\\/\\/.*")) {
                            sb.append(readLine);
                            continue;
                        }
                    } while (readLine != null);
                    bufferedReader.close();
                    inputStream.close();
                    String sb2 = sb.toString();
                    try {
                        inputStream.close();
                    } catch (IOException e9) {
                        e9.printStackTrace();
                    }
                    return sb2;
                } catch (Exception e10) {
                    e = e10;
                    e.printStackTrace();
                    if (inputStream != null) {
                        try {
                            inputStream.close();
                        } catch (IOException e11) {
                            e11.printStackTrace();
                        }
                    }
                    return null;
                }
            } catch (Throwable th) {
                th = th;
                r02 = context;
                if (r02 != 0) {
                    try {
                        r02.close();
                    } catch (IOException e12) {
                        e12.printStackTrace();
                    }
                }
                throw th;
            }
        } catch (Exception e13) {
            e = e13;
            inputStream = null;
        } catch (Throwable th2) {
            th = th2;
            if (r02 != 0) {
            }
            throw th;
        }
    }

    @Deprecated
    public static void webViewLoadJs(WebView webView, String str) {
        String str2 = "javascript:" + (("var newscript = document.createElement(\"script\");newscript.src=\"" + str + "\";") + "document.scripts[0].parentNode.insertBefore(newscript,document.scripts[0]);");
        webView.loadUrl(str2);
        JSHookAop.loadUrl(webView, str2);
    }

    @Deprecated
    public static void webViewLoadLocalJs(WebView webView, String str) {
        String str2 = "javascript:" + assetFile2Str(webView.getContext(), str);
        webView.loadUrl(str2);
        JSHookAop.loadUrl(webView, str2);
    }
}