Amour v4.6.9版本的 MD5 值为:60db0759ce21a7c5858136dd0821206f

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


package com.just.agentweb;

import android.util.Log;
import android.webkit.WebView;
import java.lang.ref.WeakReference;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class JsCallback {
    private static final String CALLBACK_JS_FORMAT = "javascript:%s.callback(%d, %d %s);";
    private boolean mCouldGoOn = true;
    private int mIndex;
    private String mInjectedName;
    private int mIsPermanent;
    private WeakReference<WebView> mWebViewRef;

    public static class JsCallbackException extends Exception {
        public JsCallbackException(String str) {
            super(str);
        }
    }

    public JsCallback(WebView webView, String str, int i) {
        this.mWebViewRef = new WeakReference<>(webView);
        this.mInjectedName = str;
        this.mIndex = i;
    }

    private boolean isJavaScriptObject(Object obj) {
        if ((obj instanceof JSONObject) || (obj instanceof JSONArray)) {
            return true;
        }
        String obj2 = obj.toString();
        try {
            try {
                new JSONObject(obj2);
            } catch (JSONException unused) {
                new JSONArray(obj2);
            }
            return true;
        } catch (JSONException unused2) {
            return false;
        }
    }

    public void apply(Object... objArr) {
        if (this.mWebViewRef.get() != null) {
            if (this.mCouldGoOn) {
                StringBuilder sb2 = new StringBuilder();
                boolean z10 = false;
                for (Object obj : objArr) {
                    sb2.append(",");
                    boolean z11 = obj instanceof String;
                    boolean isJavaScriptObject = isJavaScriptObject(obj);
                    if (z11 && !isJavaScriptObject) {
                        sb2.append("\"");
                    }
                    sb2.append(String.valueOf(obj));
                    if (z11 && !isJavaScriptObject) {
                        sb2.append("\"");
                    }
                }
                String format = String.format(CALLBACK_JS_FORMAT, this.mInjectedName, Integer.valueOf(this.mIndex), Integer.valueOf(this.mIsPermanent), sb2.toString());
                if (LogUtils.isDebug()) {
                    Log.d("JsCallBack", format);
                }
                this.mWebViewRef.get().loadUrl(format);
                if (this.mIsPermanent > 0) {
                    z10 = true;
                }
                this.mCouldGoOn = z10;
                return;
            }
            throw new JsCallbackException("the JsCallback isn't permanent,cannot be called more than once");
        }
        throw new JsCallbackException("the WebView related to the JsCallback has been recycled");
    }

    public void setPermanent(boolean z10) {
        this.mIsPermanent = z10 ? 1 : 0;
    }
}