整点视频 v3.3.0版本的 MD5 值为:cba0457dc37421eed445b30f92de25d3
以下内容为反编译后的 JavaScriptInterface.java 源代码,内容仅作参考
package com.beizi.ad.alipay.js;
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.text.TextUtils;
import android.view.View;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
import com.beizi.ad.a.a.k;
import com.beizi.ad.alipay.RedPackageManager;
import com.beizi.ad.alipay.RedPackageUtil;
import com.beizi.ad.alipay.inter.ResultListener;
import com.beizi.ad.alipay.inter.UserInfoListener;
import com.beizi.ad.alipay.inter.WelfareListener;
import com.bytedance.sdk.openadsdk.api.plugin.PluginConstants;
import java.io.Serializable;
import java.util.Map;
import org.json.JSONObject;
public class JavaScriptInterface {
private static final String TAG = "JavaScriptInterface";
private WebView webView;
public class JsInnerInterfaceBean implements Serializable {
private String data;
private String handlerName;
private JsInnerInterfaceBean() {
}
public String getData() {
return this.data;
}
public String getHandlerName() {
return this.handlerName;
}
public void setData(String str) {
this.data = str;
}
public void setHandlerName(String str) {
this.handlerName = str;
}
public String toString() {
return "{\"handlerName\":\"" + this.handlerName + "\", \"data\":\"" + this.data + "\"}";
}
}
public JavaScriptInterface(WebView webView) {
this.webView = webView;
}
private void authAliPayWithParams(JsInnerInterfaceBean jsInnerInterfaceBean) {
k.b(TAG, "welfareAliPayWithParams : bean " + jsInnerInterfaceBean.toString());
try {
final JSONObject jSONObject = new JSONObject();
jSONObject.put("handlerName", jsInnerInterfaceBean.getHandlerName());
if (TextUtils.isEmpty(jsInnerInterfaceBean.getData())) {
return;
}
Map<String, String> convertJsonToMap = RedPackageUtil.convertJsonToMap(jsInnerInterfaceBean.getData());
Activity activityFromView = getActivityFromView(this.webView);
if (activityFromView != null) {
RedPackageManager.getInstance().authAliPayWithParams(activityFromView, convertJsonToMap, new UserInfoListener() {
@Override
public void failCallback(int i, String str) {
k.b(JavaScriptInterface.TAG, "authAliPayWithParams failCallback code : " + i + " , msg : " + str);
JavaScriptInterface javaScriptInterface = JavaScriptInterface.this;
JSONObject jSONObject2 = jSONObject;
JSONObject convertJsonObject = javaScriptInterface.convertJsonObject(jSONObject2, i + "", str, "");
k.b(JavaScriptInterface.TAG, "authAliPayWithParams failCallback jsonObjectResult : " + convertJsonObject);
JavaScriptInterface.this.sendResultMessage(convertJsonObject);
}
@Override
public void successCallBack(Map<String, Object> map) {
k.b(JavaScriptInterface.TAG, "authAliPayWithParams successCallBack map : " + map);
JSONObject convertJsonObject = JavaScriptInterface.this.convertJsonObject(jSONObject, "200", "success call", RedPackageUtil.convertMapToJson(map));
k.b(JavaScriptInterface.TAG, "authAliPayWithParams successCallBack jsonObjectResult : " + convertJsonObject);
JavaScriptInterface.this.sendResultMessage(convertJsonObject);
}
});
}
} catch (Exception e) {
k.b(TAG, "authAliPayWithParams : exception " + e);
e.printStackTrace();
}
}
private void authInfo(JsInnerInterfaceBean jsInnerInterfaceBean) {
k.b(TAG, "authInfo : bean " + jsInnerInterfaceBean.toString());
try {
final JSONObject jSONObject = new JSONObject();
jSONObject.put("handlerName", jsInnerInterfaceBean.getHandlerName());
if (TextUtils.isEmpty(jsInnerInterfaceBean.getData())) {
return;
}
RedPackageManager.getInstance().authInfo(RedPackageUtil.convertJsonToMap(jsInnerInterfaceBean.getData()), new UserInfoListener() {
@Override
public void failCallback(int i, String str) {
k.b(JavaScriptInterface.TAG, "authInfo failCallback code : " + i + " ,msg : " + str);
JavaScriptInterface javaScriptInterface = JavaScriptInterface.this;
JSONObject jSONObject2 = jSONObject;
JSONObject convertJsonObject = javaScriptInterface.convertJsonObject(jSONObject2, i + "", str, "");
k.b(JavaScriptInterface.TAG, "authInfo failCallback jsonObjectResult : " + convertJsonObject);
JavaScriptInterface.this.sendResultMessage(convertJsonObject);
}
@Override
public void successCallBack(Map<String, Object> map) {
k.b(JavaScriptInterface.TAG, "authInfo successCallBack map : " + map);
JSONObject convertJsonObject = JavaScriptInterface.this.convertJsonObject(jSONObject, "200", "success call", RedPackageUtil.convertMapToJson(map));
k.b(JavaScriptInterface.TAG, "authInfo successCallBack jsonObjectResult : " + convertJsonObject);
JavaScriptInterface.this.sendResultMessage(convertJsonObject);
}
});
} catch (Exception e) {
k.b(TAG, "authInfo : exception " + e);
e.printStackTrace();
}
}
public JSONObject convertJsonObject(JSONObject jSONObject, String str, String str2, String str3) {
try {
jSONObject.put(PluginConstants.KEY_ERROR_CODE, str);
jSONObject.put("msg", str2);
jSONObject.put("data", str3);
} catch (Exception e) {
e.printStackTrace();
}
return jSONObject;
}
private void rtaUser(JsInnerInterfaceBean jsInnerInterfaceBean) {
k.b(TAG, "rtaUser : bean " + jsInnerInterfaceBean.toString());
try {
final JSONObject jSONObject = new JSONObject();
jSONObject.put("handlerName", jsInnerInterfaceBean.getHandlerName());
final JSONObject jSONObject2 = new JSONObject();
RedPackageManager.getInstance().rtaUser(new ResultListener() {
@Override
public void onFail(int i, String str) {
k.b(JavaScriptInterface.TAG, "rtaUser onFail errorCode : " + i + " , msg : " + str);
JavaScriptInterface javaScriptInterface = JavaScriptInterface.this;
JSONObject jSONObject3 = jSONObject;
JSONObject convertJsonObject = javaScriptInterface.convertJsonObject(jSONObject3, i + "", str, "");
k.b(JavaScriptInterface.TAG, "rtaUser onFail jsonObjectResult : " + convertJsonObject);
JavaScriptInterface.this.sendResultMessage(convertJsonObject);
}
@Override
public void onSuccess(boolean z) {
k.b(JavaScriptInterface.TAG, "rtaUser successCallBack map : " + z);
try {
jSONObject2.put("requiredFlow", z);
JSONObject convertJsonObject = JavaScriptInterface.this.convertJsonObject(jSONObject, "200", "success call", jSONObject2.toString());
k.b(JavaScriptInterface.TAG, "rtaUser successCallBack jsonObjectResult : " + convertJsonObject);
JavaScriptInterface.this.sendResultMessage(convertJsonObject);
} catch (Exception e) {
e.printStackTrace();
}
}
});
} catch (Exception e) {
k.b(TAG, "rtaUser : exception " + e);
e.printStackTrace();
}
}
public void sendResultMessage(JSONObject jSONObject) {
final String jSONObject2 = jSONObject.toString();
this.webView.post(new Runnable() {
@Override
public void run() {
WebView webView = JavaScriptInterface.this.webView;
webView.loadUrl("javascript:handleMessageFromNative(" + jSONObject2 + ")");
}
});
}
private void welfareAliPayWithParams(JsInnerInterfaceBean jsInnerInterfaceBean) {
k.b(TAG, "welfareAliPayWithParams : bean " + jsInnerInterfaceBean.toString());
try {
final JSONObject jSONObject = new JSONObject();
jSONObject.put("handlerName", jsInnerInterfaceBean.getHandlerName());
if (TextUtils.isEmpty(jsInnerInterfaceBean.getData())) {
return;
}
RedPackageManager.getInstance().welfareAliPayWithParams(RedPackageUtil.convertJsonToMap(jsInnerInterfaceBean.getData()), new WelfareListener() {
@Override
public void failCallback(int i, String str) {
k.b(JavaScriptInterface.TAG, "welfareAliPayWithParams failCallback code : " + i + " , msg : " + str);
JavaScriptInterface javaScriptInterface = JavaScriptInterface.this;
JSONObject jSONObject2 = jSONObject;
JSONObject convertJsonObject = javaScriptInterface.convertJsonObject(jSONObject2, i + "", str, "");
k.b(JavaScriptInterface.TAG, "welfareAliPayWithParams failCallback jsonObjectResult : " + convertJsonObject);
JavaScriptInterface.this.sendResultMessage(convertJsonObject);
}
@Override
public void successCallBack(Map<String, Object> map) {
k.b(JavaScriptInterface.TAG, "welfareAliPayWithParams successCallBack map : " + map);
JSONObject convertJsonObject = JavaScriptInterface.this.convertJsonObject(jSONObject, "200", "success call", RedPackageUtil.convertMapToJson(map));
k.b(JavaScriptInterface.TAG, "welfareAliPayWithParams successCallBack jsonObjectResult : " + convertJsonObject);
JavaScriptInterface.this.sendResultMessage(convertJsonObject);
}
});
} catch (Exception e) {
k.b(TAG, "welfareAliPayWithParams : exception " + e);
e.printStackTrace();
}
}
@JavascriptInterface
public void callNativeHandler(String str) {
k.b(TAG, "jsCode: " + str);
try {
JsInnerInterfaceBean jsInnerInterfaceBean = new JsInnerInterfaceBean();
if (!TextUtils.isEmpty(str)) {
JSONObject jSONObject = new JSONObject(str);
if (jSONObject.has("handlerName") && !TextUtils.isEmpty(jSONObject.optString("handlerName"))) {
jsInnerInterfaceBean.setHandlerName(jSONObject.optString("handlerName"));
}
if (jSONObject.has("data") && !TextUtils.isEmpty(jSONObject.optString("data"))) {
jsInnerInterfaceBean.setData(jSONObject.optString("data"));
}
}
if ("rtaUser".equals(jsInnerInterfaceBean.getHandlerName())) {
rtaUser(jsInnerInterfaceBean);
} else if ("authInfo".equals(jsInnerInterfaceBean.getHandlerName())) {
authInfo(jsInnerInterfaceBean);
} else if ("authAliPayWithParams".equals(jsInnerInterfaceBean.getHandlerName())) {
authAliPayWithParams(jsInnerInterfaceBean);
} else if ("welfareAliPayWithParams".equals(jsInnerInterfaceBean.getHandlerName())) {
welfareAliPayWithParams(jsInnerInterfaceBean);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public Activity getActivityFromView(View view) {
for (Context context = view.getContext(); context instanceof ContextWrapper; context = ((ContextWrapper) context).getBaseContext()) {
if (context instanceof Activity) {
return (Activity) context;
}
}
return null;
}
}