LoanStar v1.0.2版本的 MD5 值为:1398d05dc1f37bf19dbc6092ea5b471d
以下内容为反编译后的 AdjustBridgeUtil.java 源代码,内容仅作参考
package com.adjust.sdk.webbridge;
import android.net.Uri;
import android.util.Log;
import android.webkit.WebView;
import com.adjust.sdk.AdjustAttribution;
import com.adjust.sdk.AdjustEventFailure;
import com.adjust.sdk.AdjustEventSuccess;
import com.adjust.sdk.AdjustFactory;
import com.adjust.sdk.AdjustSessionFailure;
import com.adjust.sdk.AdjustSessionSuccess;
import com.adjust.sdk.ILogger;
import com.adjust.sdk.network.UtilNetworking;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.json.JSONArray;
import org.json.JSONObject;
public class AdjustBridgeUtil {
public static String byte2HexFormatted(byte[] bArr) {
StringBuilder sb = new StringBuilder(bArr.length * 2);
for (byte b : bArr) {
String hexString = Integer.toHexString(b);
int length = hexString.length();
if (length == 1) {
hexString = "0" + hexString;
}
if (length > 2) {
hexString = hexString.substring(length - 2, length);
}
sb.append(hexString.toUpperCase());
}
return sb.toString();
}
public static void execAttributionCallbackCommand(final WebView webView, final String str, final AdjustAttribution adjustAttribution) {
if (webView == null || adjustAttribution == null) {
return;
}
webView.post(new Runnable() {
@Override
public void run() {
double d2;
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("trackerName", AdjustAttribution.this.trackerName == null ? JSONObject.NULL : AdjustAttribution.this.trackerName);
jSONObject.put("trackerToken", AdjustAttribution.this.trackerToken == null ? JSONObject.NULL : AdjustAttribution.this.trackerToken);
jSONObject.put("campaign", AdjustAttribution.this.campaign == null ? JSONObject.NULL : AdjustAttribution.this.campaign);
jSONObject.put("network", AdjustAttribution.this.network == null ? JSONObject.NULL : AdjustAttribution.this.network);
jSONObject.put("creative", AdjustAttribution.this.creative == null ? JSONObject.NULL : AdjustAttribution.this.creative);
jSONObject.put("adgroup", AdjustAttribution.this.adgroup == null ? JSONObject.NULL : AdjustAttribution.this.adgroup);
jSONObject.put("clickLabel", AdjustAttribution.this.clickLabel == null ? JSONObject.NULL : AdjustAttribution.this.clickLabel);
jSONObject.put("adid", AdjustAttribution.this.adid == null ? JSONObject.NULL : AdjustAttribution.this.adid);
jSONObject.put("costType", AdjustAttribution.this.costType == null ? JSONObject.NULL : AdjustAttribution.this.costType);
if (AdjustAttribution.this.costAmount != null && !AdjustAttribution.this.costAmount.isNaN()) {
d2 = AdjustAttribution.this.costAmount.doubleValue();
jSONObject.put("costAmount", d2);
jSONObject.put("costCurrency", AdjustAttribution.this.costCurrency != null ? JSONObject.NULL : AdjustAttribution.this.costCurrency);
jSONObject.put("fbInstallReferrer", AdjustAttribution.this.fbInstallReferrer != null ? JSONObject.NULL : AdjustAttribution.this.fbInstallReferrer);
webView.loadUrl("javascript:" + str + "(" + jSONObject.toString() + ");");
}
d2 = 0.0d;
jSONObject.put("costAmount", d2);
jSONObject.put("costCurrency", AdjustAttribution.this.costCurrency != null ? JSONObject.NULL : AdjustAttribution.this.costCurrency);
jSONObject.put("fbInstallReferrer", AdjustAttribution.this.fbInstallReferrer != null ? JSONObject.NULL : AdjustAttribution.this.fbInstallReferrer);
webView.loadUrl("javascript:" + str + "(" + jSONObject.toString() + ");");
} catch (Exception e2) {
e2.printStackTrace();
}
}
});
}
public static void execEventFailureCallbackCommand(final WebView webView, final String str, final AdjustEventFailure adjustEventFailure) {
if (webView == null || adjustEventFailure == null) {
return;
}
webView.post(new Runnable() {
@Override
public void run() {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("eventToken", AdjustEventFailure.this.eventToken == null ? JSONObject.NULL : AdjustEventFailure.this.eventToken);
jSONObject.put("message", AdjustEventFailure.this.message == null ? JSONObject.NULL : AdjustEventFailure.this.message);
jSONObject.put("adid", AdjustEventFailure.this.adid == null ? JSONObject.NULL : AdjustEventFailure.this.adid);
jSONObject.put("timestamp", AdjustEventFailure.this.timestamp == null ? JSONObject.NULL : AdjustEventFailure.this.timestamp);
jSONObject.put("willRetry", AdjustEventFailure.this.willRetry ? String.valueOf(true) : String.valueOf(false));
jSONObject.put("callbackId", AdjustEventFailure.this.callbackId == null ? JSONObject.NULL : AdjustEventFailure.this.callbackId);
jSONObject.put("jsonResponse", AdjustEventFailure.this.jsonResponse == null ? JSONObject.NULL : AdjustEventFailure.this.jsonResponse);
webView.loadUrl("javascript:" + str + "(" + jSONObject.toString() + ");");
} catch (Exception e2) {
e2.printStackTrace();
}
}
});
}
public static void execEventSuccessCallbackCommand(final WebView webView, final String str, final AdjustEventSuccess adjustEventSuccess) {
if (webView == null || adjustEventSuccess == null) {
return;
}
webView.post(new Runnable() {
@Override
public void run() {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("eventToken", AdjustEventSuccess.this.eventToken == null ? JSONObject.NULL : AdjustEventSuccess.this.eventToken);
jSONObject.put("message", AdjustEventSuccess.this.message == null ? JSONObject.NULL : AdjustEventSuccess.this.message);
jSONObject.put("adid", AdjustEventSuccess.this.adid == null ? JSONObject.NULL : AdjustEventSuccess.this.adid);
jSONObject.put("timestamp", AdjustEventSuccess.this.timestamp == null ? JSONObject.NULL : AdjustEventSuccess.this.timestamp);
jSONObject.put("callbackId", AdjustEventSuccess.this.callbackId == null ? JSONObject.NULL : AdjustEventSuccess.this.callbackId);
jSONObject.put("jsonResponse", AdjustEventSuccess.this.jsonResponse == null ? JSONObject.NULL : AdjustEventSuccess.this.jsonResponse);
webView.loadUrl("javascript:" + str + "(" + jSONObject.toString() + ");");
} catch (Exception e2) {
e2.printStackTrace();
}
}
});
}
public static void execSessionFailureCallbackCommand(final WebView webView, final String str, final AdjustSessionFailure adjustSessionFailure) {
if (webView == null || adjustSessionFailure == null) {
return;
}
webView.post(new Runnable() {
@Override
public void run() {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("message", AdjustSessionFailure.this.message == null ? JSONObject.NULL : AdjustSessionFailure.this.message);
jSONObject.put("adid", AdjustSessionFailure.this.adid == null ? JSONObject.NULL : AdjustSessionFailure.this.adid);
jSONObject.put("timestamp", AdjustSessionFailure.this.timestamp == null ? JSONObject.NULL : AdjustSessionFailure.this.timestamp);
jSONObject.put("willRetry", AdjustSessionFailure.this.willRetry ? String.valueOf(true) : String.valueOf(false));
jSONObject.put("jsonResponse", AdjustSessionFailure.this.jsonResponse == null ? JSONObject.NULL : AdjustSessionFailure.this.jsonResponse);
webView.loadUrl("javascript:" + str + "(" + jSONObject.toString() + ");");
} catch (Exception e2) {
e2.printStackTrace();
}
}
});
}
public static void execSessionSuccessCallbackCommand(final WebView webView, final String str, final AdjustSessionSuccess adjustSessionSuccess) {
if (webView == null || adjustSessionSuccess == null) {
return;
}
webView.post(new Runnable() {
@Override
public void run() {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("message", AdjustSessionSuccess.this.message == null ? JSONObject.NULL : AdjustSessionSuccess.this.message);
jSONObject.put("adid", AdjustSessionSuccess.this.adid == null ? JSONObject.NULL : AdjustSessionSuccess.this.adid);
jSONObject.put("timestamp", AdjustSessionSuccess.this.timestamp == null ? JSONObject.NULL : AdjustSessionSuccess.this.timestamp);
jSONObject.put("jsonResponse", AdjustSessionSuccess.this.jsonResponse == null ? JSONObject.NULL : AdjustSessionSuccess.this.jsonResponse);
webView.loadUrl("javascript:" + str + "(" + jSONObject.toString() + ");");
} catch (Exception e2) {
e2.printStackTrace();
}
}
});
}
public static void execSingleValueCallback(final WebView webView, final String str, final String str2) {
if (webView == null) {
return;
}
webView.post(new Runnable() {
@Override
public void run() {
webView.loadUrl("javascript:" + str + "('" + str2 + "');");
}
});
}
public static Boolean fieldToBoolean(Object obj) {
if (obj == null) {
return null;
}
String obj2 = obj.toString();
if (obj2.equalsIgnoreCase("true")) {
return Boolean.TRUE;
}
if (obj2.equalsIgnoreCase("false")) {
return Boolean.FALSE;
}
return null;
}
public static Double fieldToDouble(Object obj) {
if (obj == null) {
return null;
}
try {
return Double.valueOf(Double.parseDouble(obj.toString()));
} catch (Exception unused) {
return null;
}
}
public static Long fieldToLong(Object obj) {
if (obj == null) {
return null;
}
try {
return Long.valueOf(Long.parseLong(obj.toString()));
} catch (Exception unused) {
return null;
}
}
public static String fieldToString(Object obj) {
if (obj == null) {
return null;
}
String obj2 = obj.toString();
if (obj2.equals("null")) {
return null;
}
return obj2;
}
public static ILogger getLogger() {
return AdjustFactory.getLogger();
}
public static String[] jsonArrayToArray(JSONArray jSONArray) {
if (jSONArray != null) {
String[] strArr = new String[jSONArray.length()];
for (int i2 = 0; i2 < jSONArray.length(); i2++) {
strArr[i2] = jSONArray.get(i2).toString();
}
return strArr;
}
return null;
}
public static void sendDeeplinkToWebView(final WebView webView, final Uri uri) {
if (webView != null) {
webView.post(new Runnable() {
@Override
public void run() {
webView.loadUrl("javascript:adjust_deeplink('" + uri.toString() + "');");
}
});
}
}
public static UtilNetworking.IConnectionOptions testConnectionOptions() {
return new UtilNetworking.IConnectionOptions() {
@Override
public void applyConnectionOptions(HttpsURLConnection httpsURLConnection, String str) {
UtilNetworking.createDefaultConnectionOptions().applyConnectionOptions(httpsURLConnection, str);
try {
SSLContext sSLContext = SSLContext.getInstance("TLS");
sSLContext.init(null, new TrustManager[]{new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] x509CertificateArr, String str2) {
Log.d("TestApp", "checkClientTrusted ");
}
@Override
public void checkServerTrusted(X509Certificate[] x509CertificateArr, String str2) {
Log.d("TestApp", "checkServerTrusted ");
try {
if (AdjustBridgeUtil.byte2HexFormatted(MessageDigest.getInstance("SHA1").digest(x509CertificateArr[0].getEncoded())).equalsIgnoreCase("7BCFF44099A35BC093BB48C5A6B9A516CDFDA0D1")) {
return;
}
throw new CertificateException();
} catch (NoSuchAlgorithmException e2) {
Log.e("TestApp", "testingMode error " + e2.getMessage());
} catch (CertificateEncodingException e3) {
Log.e("TestApp", "testingMode error " + e3.getMessage());
}
}
@Override
public X509Certificate[] getAcceptedIssuers() {
Log.d("TestApp", "getAcceptedIssuers");
return null;
}
}}, new SecureRandom());
httpsURLConnection.setSSLSocketFactory(sSLContext.getSocketFactory());
httpsURLConnection.setHostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String str2, SSLSession sSLSession) {
Log.d("TestApp", "verify hostname ");
return true;
}
});
} catch (Exception e2) {
Log.e("TestApp", "testingMode error " + e2.getMessage());
}
}
};
}
}