健保快易通 v3.0.34版本的 MD5 值为:4d9ad09519a307acf9624fde22a12daa

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


package com.nhiApp.v1.jsbridge;

import android.util.Log;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
import com.nhiApp.v1.jsbridge.JsBridgeHelper;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.json.JSONException;
import org.json.JSONObject;
public final class JsBridgeHelper {
    private final Map<String, RequestCallback> mCallbacks;
    private final String mClassPackage;
    private final WebView mWebView;

    public interface RequestCallback {
        void onError();

        void onSuccess();
    }

    private static String getPackageName() {
        Package r0 = JsBridgeHelper.class.getPackage();
        return r0 != null ? r0.getName() : "";
    }

    public JsBridgeHelper(WebView webView) {
        this(webView, getPackageName());
    }

    public JsBridgeHelper(WebView webView, String str) {
        this.mCallbacks = new HashMap();
        StringBuilder sb = new StringBuilder();
        sb.append(str);
        sb.append(".");
        this.mClassPackage = sb.toString();
        this.mWebView = webView;
        webView.getSettings().setJavaScriptEnabled(true);
        webView.addJavascriptInterface(new PontoProtocol(), PontoProtocol.TAG);
    }

    public final void invoke(String str, String str2, String str3, RequestCallback requestCallback) {
        String obj = UUID.randomUUID().toString();
        if (requestCallback != null) {
            this.mCallbacks.put(obj, requestCallback);
        }
        StringBuilder sb = new StringBuilder();
        sb.append("javascript:Ponto.request('{\"target\": \"");
        sb.append(str);
        sb.append("\", \"method\": \"");
        sb.append(str2);
        sb.append("\", \"params\": ");
        sb.append(str3);
        sb.append(", \"callbackId\": \"");
        sb.append(obj);
        sb.append("\"}');");
        this.mWebView.loadUrl(sb.toString());
    }

    public class PontoProtocol {
        private static final String KEY_MESSAGE = "message";
        private static final String NULL_STRING = "null";
        private static final int RESPONSE_COMPLETE = 0;
        private static final int RESPONSE_ERROR = 1;
        public static final String TAG = "PontoProtocol";
        private static final String UNDEFINED_STRING = "undefined";
        public static final byte[] dispatchDisplayHint = {25, 14, 104, -19, 21, -2, 22, 5, 2, 3, -46, 61, 20, 7, 14, -7, 17, 14, -62, 29, 52, 7, 14, -7, 27, 4};
        public static final int cancel = 92;

        private PontoProtocol() {
        }

        @JavascriptInterface
        public void request(String str, String str2, String str3, String str4, String str5, String str6) {
            PontoProtocol pontoProtocol;
            int i;
            String str7;
            PontoProtocol pontoProtocol2;
            String str8;
            PontoProtocol pontoProtocol3;
            String str9;
            JSONObject noSuchMethodParams;
            int i2;
            Class<?> cls;
            Class<?>[] clsArr;
            byte[] bArr;
            byte[] bArr2;
            byte b2;
            byte b3;
            byte[] bArr3;
            byte[] bArr4;
            int i3;
            byte b4;
            int i4;
            Class<?> cls2;
            Class<?>[] clsArr2;
            Class<?>[] clsArr3;
            String str10;
            int i5;
            Object newInstance;
            int i6;
            JSONObject jSONObject = new JSONObject();
            try {
                StringBuilder sb = new StringBuilder();
                pontoProtocol = this;
                try {
                    try {
                        sb.append(JsBridgeHelper.this.mClassPackage);
                        str9 = str2;
                    } catch (ClassNotFoundException e) {
                        e = e;
                        str9 = str2;
                        i = 1;
                        str7 = str5;
                        pontoProtocol3 = pontoProtocol;
                        Log.e(TAG, "ClassNotFoundException while executing ponto request", e);
                        noSuchMethodParams = pontoProtocol3.getClassNotFoundParams(str9);
                        i2 = i;
                        if (str7 == null) {
                        }
                    }
                    try {
                        sb.append(str9);
                        cls = Class.forName(sb.toString());
                        clsArr = new Class[1];
                        bArr = dispatchDisplayHint;
                        bArr2 = new byte[23];
                        b2 = 3;
                        b3 = 97;
                    } catch (ClassNotFoundException e2) {
                        e = e2;
                        i = 1;
                        str7 = str5;
                        pontoProtocol3 = pontoProtocol;
                        Log.e(TAG, "ClassNotFoundException while executing ponto request", e);
                        noSuchMethodParams = pontoProtocol3.getClassNotFoundParams(str9);
                        i2 = i;
                        if (str7 == null) {
                        }
                    }
                } catch (IllegalAccessException e3) {
                    e = e3;
                    i = 1;
                    str7 = str5;
                    pontoProtocol2 = pontoProtocol;
                    Log.e(TAG, "IllegalAccessException while executing ponto request", e);
                    noSuchMethodParams = jSONObject;
                    pontoProtocol3 = pontoProtocol2;
                    i2 = i;
                    if (str7 == null) {
                    }
                } catch (IllegalArgumentException e4) {
                    e = e4;
                    i = 1;
                    str7 = str5;
                    pontoProtocol2 = pontoProtocol;
                    Log.e(TAG, "IllegalArgumentException while executing ponto request", e);
                    noSuchMethodParams = jSONObject;
                    pontoProtocol3 = pontoProtocol2;
                    i2 = i;
                    if (str7 == null) {
                    }
                } catch (InstantiationException e5) {
                    e = e5;
                    i = 1;
                    str7 = str5;
                    pontoProtocol2 = pontoProtocol;
                    Log.e(TAG, "InstantiationException while executing ponto request", e);
                    noSuchMethodParams = jSONObject;
                    pontoProtocol3 = pontoProtocol2;
                    i2 = i;
                    if (str7 == null) {
                    }
                } catch (NoSuchMethodException e6) {
                    e = e6;
                    i = 1;
                    str8 = str3;
                    str7 = str5;
                    pontoProtocol3 = pontoProtocol;
                    Log.e(TAG, "NoSuchMethodException while executing ponto request", e);
                    noSuchMethodParams = pontoProtocol3.getNoSuchMethodParams(str8);
                    i2 = i;
                    if (str7 == null) {
                    }
                } catch (InvocationTargetException e7) {
                    e = e7;
                    i = 1;
                    str7 = str5;
                    pontoProtocol2 = pontoProtocol;
                    Log.e(TAG, "InvocationTargetException while executing ponto request", e);
                    noSuchMethodParams = jSONObject;
                    pontoProtocol3 = pontoProtocol2;
                    i2 = i;
                    if (str7 == null) {
                    }
                }
            } catch (ClassNotFoundException e8) {
                e = e8;
                pontoProtocol = this;
            } catch (IllegalAccessException e9) {
                e = e9;
                pontoProtocol = this;
            } catch (IllegalArgumentException e10) {
                e = e10;
                pontoProtocol = this;
            } catch (InstantiationException e11) {
                e = e11;
                pontoProtocol = this;
            } catch (NoSuchMethodException e12) {
                e = e12;
                pontoProtocol = this;
            } catch (InvocationTargetException e13) {
                e = e13;
                pontoProtocol = this;
            }
            if (bArr == null) {
                PontoProtocol pontoProtocol4 = pontoProtocol;
                Class<?>[] clsArr4 = clsArr;
                Class<?>[] clsArr5 = clsArr4;
                byte[] bArr5 = bArr;
                byte[] bArr6 = bArr2;
                i3 = 3;
                i4 = 0;
                str7 = str5;
                noSuchMethodParams = jSONObject;
                cls2 = cls;
                str8 = str3;
                str10 = str4;
                try {
                    try {
                        clsArr3 = clsArr5;
                        bArr3 = bArr5;
                        bArr4 = bArr6;
                        pontoProtocol2 = pontoProtocol4;
                        b4 = (b2 + b3) - 8;
                        clsArr2 = clsArr4;
                        bArr4[i4] = b4;
                        i3++;
                    } catch (ClassNotFoundException e14) {
                        e = e14;
                        pontoProtocol3 = pontoProtocol2;
                    } catch (NoSuchMethodException e15) {
                        e = e15;
                        pontoProtocol3 = pontoProtocol2;
                    }
                } catch (IllegalAccessException e16) {
                    e = e16;
                    i = 1;
                } catch (IllegalArgumentException e17) {
                    e = e17;
                    i = 1;
                } catch (InstantiationException e18) {
                    e = e18;
                    i = 1;
                } catch (InvocationTargetException e19) {
                    e = e19;
                    i = 1;
                }
                if (i4 == 22) {
                    try {
                        clsArr2[0] = Class.forName(new String(bArr4, 0));
                        Constructor<?> constructor = cls2.getConstructor(clsArr3);
                        try {
                            Object[] objArr = new Object[1];
                            pontoProtocol3 = pontoProtocol2;
                            try {
                                objArr[0] = JsBridgeHelper.this.mWebView.getContext();
                                newInstance = constructor.newInstance(objArr);
                            } catch (ClassNotFoundException e20) {
                                e = e20;
                                i = 1;
                                Log.e(TAG, "ClassNotFoundException while executing ponto request", e);
                                noSuchMethodParams = pontoProtocol3.getClassNotFoundParams(str9);
                                i2 = i;
                                if (str7 == null) {
                                }
                            } catch (IllegalAccessException e21) {
                                e = e21;
                                pontoProtocol2 = pontoProtocol3;
                                jSONObject = noSuchMethodParams;
                                i = 1;
                                Log.e(TAG, "IllegalAccessException while executing ponto request", e);
                                noSuchMethodParams = jSONObject;
                                pontoProtocol3 = pontoProtocol2;
                                i2 = i;
                                if (str7 == null) {
                                }
                            } catch (IllegalArgumentException e22) {
                                e = e22;
                                pontoProtocol2 = pontoProtocol3;
                                jSONObject = noSuchMethodParams;
                                i = 1;
                                Log.e(TAG, "IllegalArgumentException while executing ponto request", e);
                                noSuchMethodParams = jSONObject;
                                pontoProtocol3 = pontoProtocol2;
                                i2 = i;
                                if (str7 == null) {
                                }
                            } catch (InstantiationException e23) {
                                e = e23;
                                pontoProtocol2 = pontoProtocol3;
                                jSONObject = noSuchMethodParams;
                                i = 1;
                                Log.e(TAG, "InstantiationException while executing ponto request", e);
                                noSuchMethodParams = jSONObject;
                                pontoProtocol3 = pontoProtocol2;
                                i2 = i;
                                if (str7 == null) {
                                }
                            } catch (NoSuchMethodException e24) {
                                e = e24;
                                i = 1;
                                Log.e(TAG, "NoSuchMethodException while executing ponto request", e);
                                noSuchMethodParams = pontoProtocol3.getNoSuchMethodParams(str8);
                                i2 = i;
                                if (str7 == null) {
                                }
                            } catch (InvocationTargetException e25) {
                                e = e25;
                                pontoProtocol2 = pontoProtocol3;
                                jSONObject = noSuchMethodParams;
                                i = 1;
                                Log.e(TAG, "InvocationTargetException while executing ponto request", e);
                                noSuchMethodParams = jSONObject;
                                pontoProtocol3 = pontoProtocol2;
                                i2 = i;
                                if (str7 == null) {
                                }
                            }
                            try {
                            } catch (ClassNotFoundException e26) {
                                e = e26;
                                i = i5;
                                Log.e(TAG, "ClassNotFoundException while executing ponto request", e);
                                noSuchMethodParams = pontoProtocol3.getClassNotFoundParams(str9);
                                i2 = i;
                                if (str7 == null) {
                                }
                            } catch (IllegalAccessException e27) {
                                e = e27;
                                pontoProtocol2 = pontoProtocol3;
                                jSONObject = noSuchMethodParams;
                                i = i5;
                                Log.e(TAG, "IllegalAccessException while executing ponto request", e);
                                noSuchMethodParams = jSONObject;
                                pontoProtocol3 = pontoProtocol2;
                                i2 = i;
                                if (str7 == null) {
                                }
                            } catch (IllegalArgumentException e28) {
                                e = e28;
                                pontoProtocol2 = pontoProtocol3;
                                jSONObject = noSuchMethodParams;
                                i = i5;
                                Log.e(TAG, "IllegalArgumentException while executing ponto request", e);
                                noSuchMethodParams = jSONObject;
                                pontoProtocol3 = pontoProtocol2;
                                i2 = i;
                                if (str7 == null) {
                                }
                            } catch (InstantiationException e29) {
                                e = e29;
                                pontoProtocol2 = pontoProtocol3;
                                jSONObject = noSuchMethodParams;
                                i = i5;
                                Log.e(TAG, "InstantiationException while executing ponto request", e);
                                noSuchMethodParams = jSONObject;
                                pontoProtocol3 = pontoProtocol2;
                                i2 = i;
                                if (str7 == null) {
                                }
                            } catch (NoSuchMethodException e30) {
                                e = e30;
                                i = i5;
                                Log.e(TAG, "NoSuchMethodException while executing ponto request", e);
                                noSuchMethodParams = pontoProtocol3.getNoSuchMethodParams(str8);
                                i2 = i;
                                if (str7 == null) {
                                }
                            } catch (InvocationTargetException e31) {
                                e = e31;
                                pontoProtocol2 = pontoProtocol3;
                                jSONObject = noSuchMethodParams;
                                i = i5;
                                Log.e(TAG, "InvocationTargetException while executing ponto request", e);
                                noSuchMethodParams = jSONObject;
                                pontoProtocol3 = pontoProtocol2;
                                i2 = i;
                                if (str7 == null) {
                                }
                            }
                        } catch (ClassNotFoundException e32) {
                            e = e32;
                            i5 = 1;
                            pontoProtocol3 = pontoProtocol2;
                        } catch (IllegalAccessException e33) {
                            e = e33;
                            i5 = 1;
                        } catch (IllegalArgumentException e34) {
                            e = e34;
                            i5 = 1;
                        } catch (InstantiationException e35) {
                            e = e35;
                            i5 = 1;
                        } catch (NoSuchMethodException e36) {
                            e = e36;
                            i5 = 1;
                            pontoProtocol3 = pontoProtocol2;
                        } catch (InvocationTargetException e37) {
                            e = e37;
                            i5 = 1;
                        }
                    } catch (IllegalAccessException e38) {
                        e = e38;
                    } catch (IllegalArgumentException e39) {
                        e = e39;
                    } catch (InstantiationException e40) {
                        e = e40;
                    } catch (InvocationTargetException e41) {
                        e = e41;
                    }
                    if (str10 != null) {
                        if (!str10.equalsIgnoreCase(NULL_STRING)) {
                            i5 = 1;
                            cls2.getDeclaredMethod(str8, String.class).invoke(newInstance, str10);
                            i6 = 0;
                            i2 = i6;
                            if (str7 == null || str7.equalsIgnoreCase(UNDEFINED_STRING)) {
                                return;
                            }
                            pontoProtocol3.javascriptCallback(str7, i2, noSuchMethodParams.toString());
                            return;
                        }
                    }
                    i5 = 1;
                    i6 = 0;
                    cls2.getDeclaredMethod(str8, new Class[0]).invoke(newInstance, new Object[0]);
                    i2 = i6;
                    if (str7 == null) {
                        return;
                    }
                    return;
                }
                pontoProtocol3 = pontoProtocol2;
                i = 1;
                i4++;
                try {
                    byte b5 = bArr3[i3];
                    pontoProtocol4 = pontoProtocol3;
                    clsArr4 = clsArr2;
                    b2 = b4;
                    bArr6 = bArr4;
                    bArr5 = bArr3;
                    clsArr5 = clsArr3;
                    b3 = b5;
                    clsArr3 = clsArr5;
                    bArr3 = bArr5;
                    bArr4 = bArr6;
                    pontoProtocol2 = pontoProtocol4;
                    b4 = (b2 + b3) - 8;
                    clsArr2 = clsArr4;
                    bArr4[i4] = b4;
                    i3++;
                    if (i4 == 22) {
                    }
                } catch (ClassNotFoundException e42) {
                    e = e42;
                    Log.e(TAG, "ClassNotFoundException while executing ponto request", e);
                    noSuchMethodParams = pontoProtocol3.getClassNotFoundParams(str9);
                    i2 = i;
                    if (str7 == null) {
                    }
                } catch (IllegalAccessException e43) {
                    e = e43;
                    pontoProtocol2 = pontoProtocol3;
                    jSONObject = noSuchMethodParams;
                    Log.e(TAG, "IllegalAccessException while executing ponto request", e);
                    noSuchMethodParams = jSONObject;
                    pontoProtocol3 = pontoProtocol2;
                    i2 = i;
                    if (str7 == null) {
                    }
                } catch (IllegalArgumentException e44) {
                    e = e44;
                    pontoProtocol2 = pontoProtocol3;
                    jSONObject = noSuchMethodParams;
                    Log.e(TAG, "IllegalArgumentException while executing ponto request", e);
                    noSuchMethodParams = jSONObject;
                    pontoProtocol3 = pontoProtocol2;
                    i2 = i;
                    if (str7 == null) {
                    }
                } catch (InstantiationException e45) {
                    e = e45;
                    pontoProtocol2 = pontoProtocol3;
                    jSONObject = noSuchMethodParams;
                    Log.e(TAG, "InstantiationException while executing ponto request", e);
                    noSuchMethodParams = jSONObject;
                    pontoProtocol3 = pontoProtocol2;
                    i2 = i;
                    if (str7 == null) {
                    }
                } catch (NoSuchMethodException e46) {
                    e = e46;
                    Log.e(TAG, "NoSuchMethodException while executing ponto request", e);
                    noSuchMethodParams = pontoProtocol3.getNoSuchMethodParams(str8);
                    i2 = i;
                    if (str7 == null) {
                    }
                } catch (InvocationTargetException e47) {
                    e = e47;
                    pontoProtocol2 = pontoProtocol3;
                    jSONObject = noSuchMethodParams;
                    Log.e(TAG, "InvocationTargetException while executing ponto request", e);
                    noSuchMethodParams = jSONObject;
                    pontoProtocol3 = pontoProtocol2;
                    i2 = i;
                    if (str7 == null) {
                    }
                }
            } else {
                pontoProtocol2 = pontoProtocol;
                bArr3 = bArr;
                bArr4 = bArr2;
                i3 = 3;
                b4 = 97;
                i4 = 0;
                noSuchMethodParams = jSONObject;
                cls2 = cls;
                clsArr2 = clsArr;
                clsArr3 = clsArr2;
                str8 = str3;
                str10 = str4;
                str7 = str5;
                bArr4[i4] = b4;
                i3++;
                if (i4 == 22) {
                }
            }
        }

        @JavascriptInterface
        public void response(String str, String str2, String str3) {
            int responseTypeFromParams = getResponseTypeFromParams(str3);
            if (str2 == null || str2.equalsIgnoreCase(UNDEFINED_STRING) || !JsBridgeHelper.this.mCallbacks.containsKey(str2)) {
                return;
            }
            RequestCallback requestCallback = (RequestCallback) JsBridgeHelper.this.mCallbacks.get(str2);
            if (responseTypeFromParams != 0) {
                if (requestCallback != null) {
                    requestCallback.onError();
                }
            } else if (requestCallback != null) {
                requestCallback.onSuccess();
            }
            JsBridgeHelper.this.mCallbacks.remove(str2);
        }

        private void javascriptCallback(final String str, final int i, final String str2) {
            JsBridgeHelper.this.mWebView.post(new Runnable() {
                @Override
                public final void run() {
                    JsBridgeHelper.PontoProtocol.this.m77xfdeb258d(i, str2, str);
                }
            });
        }

        public void m77xfdeb258d(int i, String str, String str2) {
            StringBuilder sb = new StringBuilder();
            sb.append("javascript:Ponto.response('{\"type\": ");
            sb.append(i);
            sb.append(", \"params\": ");
            sb.append(str);
            sb.append(", \"callbackId\": \"");
            sb.append(str2);
            sb.append("\"}');");
            JsBridgeHelper.this.mWebView.loadUrl(sb.toString());
        }

        private int getResponseTypeFromParams(String str) {
            try {
                return new JSONObject(str).optInt("type");
            } catch (JSONException e) {
                Log.e(TAG, "JSONException while parsing messaging data", e);
                return 1;
            }
        }

        private JSONObject getClassNotFoundParams(String str) {
            HashMap hashMap = new HashMap();
            hashMap.put(KEY_MESSAGE, "Class not found");
            hashMap.put("className", str);
            return new JSONObject(hashMap);
        }

        private JSONObject getNoSuchMethodParams(String str) {
            HashMap hashMap = new HashMap();
            hashMap.put(KEY_MESSAGE, "Method not found");
            hashMap.put("methodName", str);
            return new JSONObject(hashMap);
        }
    }
}