BRXT v5.6.8版本的 MD5 值为:caa0615cd5f4a3ae4ac8e2f0f9e0bebe
以下内容为反编译后的 ADHandler.java 源代码,内容仅作参考
package io.dcloud.feature.ad.dcloud;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Looper;
import android.support.v4.content.LocalBroadcastManager;
import android.telephony.TelephonyManager;
import android.telephony.cdma.CdmaCellLocation;
import android.telephony.gsm.GsmCellLocation;
import android.text.TextUtils;
import android.util.Base64;
import android.view.MotionEvent;
import android.webkit.WebView;
import io.dcloud.application.DCLoudApplicationImpl;
import io.dcloud.common.DHInterface.DAI;
import io.dcloud.common.DHInterface.IApp;
import io.dcloud.common.DHInterface.IWebview;
import io.dcloud.common.adapter.io.DHFile;
import io.dcloud.common.adapter.util.DeviceInfo;
import io.dcloud.common.adapter.util.Logger;
import io.dcloud.common.adapter.util.PlatformUtil;
import io.dcloud.common.adapter.util.SP;
import io.dcloud.common.constant.AbsoluteConst;
import io.dcloud.common.util.ADUtils;
import io.dcloud.common.util.AESUtil;
import io.dcloud.common.util.BaseInfo;
import io.dcloud.common.util.CreateShortResultReceiver;
import io.dcloud.common.util.JSUtil;
import io.dcloud.common.util.NetTool;
import io.dcloud.common.util.NetworkTypeUtil;
import io.dcloud.common.util.PdrUtil;
import io.dcloud.common.util.TelephonyUtil;
import io.dcloud.common.util.TestUtil;
import io.dcloud.common.util.ThreadPool;
import io.dcloud.common.util.ZipUtils;
import io.dcloud.common.util.hostpicker.HostPicker;
import io.dcloud.feature.ad.AdSplashUtil;
import io.dcloud.feature.nativeObj.BannerLayout;
import io.dcloud.g.a;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class ADHandler {
private static final String File_Data = "data.json";
private static final String File_Gif = "img.gif";
private static final String File_Img = "img.png";
private static final String File_S = "s.txt";
private static final String File_Tid = "tid.txt";
static boolean sNeedShowSkipView = false;
static long sPullBeginTime;
public static final String AdTag = "_ad" + ADHandler.class.getName();
static boolean isPullFor360 = false;
private static LinkedList<File> expiresFileList = null;
public static class ADReceiver implements IADReceiver {
Context mContext;
long mStartTime = System.currentTimeMillis();
public ADReceiver(Context context) {
this.mContext = null;
this.mContext = context;
}
private void broadcastADReceive() {
Intent intent = new Intent();
intent.setAction("ad_receive");
intent.putExtra("begin", this.mStartTime);
intent.putExtra("end", System.currentTimeMillis());
this.mContext.sendBroadcast(intent);
ADHandler.log("ADReceive", "broadcastADReceive");
}
private Boolean pap(JSONObject jSONObject) {
if (jSONObject != null && Boolean.valueOf(jSONObject.has("pap")).booleanValue()) {
ADHandler.handleSplashAdEnable(this.mContext, Boolean.valueOf(jSONObject.optInt("pap") == 1));
}
return Boolean.TRUE;
}
@Override
public void onError(String str, String str2) {
broadcastADReceive();
}
@Override
public void onReceiver(JSONObject jSONObject) {
pap(jSONObject);
JSONArray optJSONArray = jSONObject.optJSONArray("psas");
boolean z = jSONObject.optInt("pap", 0) == 1;
if (optJSONArray != null && z) {
long currentTimeMillis = System.currentTimeMillis();
int length = optJSONArray.length();
ADHandler.log("ADReceiver", "onReceiver psas.length = " + length + "; data=" + jSONObject);
for (int i = 0; i < length; i++) {
ADHandler.handleAdData(this.mContext, optJSONArray.optJSONObject(i), currentTimeMillis);
}
} else {
ADHandler.log("ADReceiver", "onReceiver no data = " + jSONObject);
}
if (ADHandler.isPullFor360) {
return;
}
broadcastADReceive();
}
}
public static class AdData {
public Object mImgData;
String mImgPath;
String mImgSrc;
JSONObject mJsonData;
MotionEvent mMotionEvent_down;
MotionEvent mMotionEvent_up;
String mOriginalAppid;
String mProvider;
int mEShow = 0;
int mEClick = 0;
public boolean check() {
return (this.mJsonData == null || this.mImgData == null) ? false : true;
}
public JSONObject data() {
return this.mJsonData.optJSONObject(AbsoluteConst.JSON_KEY_DATA);
}
public JSONObject full() {
return this.mJsonData;
}
public boolean isEClick() {
return this.mEClick == 1;
}
boolean isEShow() {
return this.mEShow == 1;
}
public void listenADReceive(Context context, final IADReceiver iADReceiver) {
if (iADReceiver != null) {
BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context2, Intent intent) {
try {
long longExtra = intent.getLongExtra("end", 0L) - intent.getLongExtra("begin", 0L);
ADHandler.log("ADReceive", "useTime=" + longExtra);
if (longExtra <= 3000) {
iADReceiver.onReceiver(null);
}
ADHandler.log("ADReceive", "unregisterReceiver");
context2.unregisterReceiver(this);
} catch (Exception e) {
e.printStackTrace();
}
}
};
try {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("ad_receive");
context.registerReceiver(broadcastReceiver, intentFilter);
ADHandler.log("ADReceive", "registerReceiver");
} catch (Exception e) {
e.printStackTrace();
}
}
}
public JSONObject report() {
return this.mJsonData.optJSONObject("report");
}
}
public interface AdDataWatcher<E> {
boolean find();
void operate(E e);
}
public interface ThreadTask {
void execute();
}
public static Boolean SplashAdIsEnable(Context context) {
try {
String papEnable = papEnable(context);
if (papEnable == null) {
return defAdConfig(context);
}
return Boolean.valueOf("1".equals(papEnable.replaceAll("\n", "")));
} catch (Exception e) {
e.printStackTrace();
return Boolean.TRUE;
}
}
private static void addThreadTask(final ThreadTask threadTask) {
if (threadTask != null) {
if (Thread.currentThread() == Looper.getMainLooper().getThread()) {
ThreadPool.self().addThreadTask(new Runnable() {
@Override
public void run() {
ThreadTask.this.execute();
}
});
} else {
threadTask.execute();
}
}
}
public static boolean allReady(Context context) {
return !TextUtils.isEmpty(get(context, "appid"));
}
public static void analysisPullData(byte[] bArr, IADReceiver... iADReceiverArr) throws JSONException {
long j;
if (bArr == null) {
return;
}
String str = new String(bArr);
log(AdTag, "pull data=" + str);
JSONObject jSONObject = new JSONObject(str);
int optInt = jSONObject.optInt("ret", -1);
int i = 0;
if (optInt == 0) {
if (jSONObject.has("time")) {
try {
j = Long.parseLong(get("servertime"));
} catch (Exception unused) {
j = 0;
}
long optLong = jSONObject.optLong("time");
SP.setBundleData(AdTag, "servertime", String.valueOf(optLong));
if (j > 0 && optLong > 0 && !PdrUtil.isSameDay(j * 1000, optLong * 1000)) {
SP.clearBundle(AdSplashUtil.showCountADReward);
}
}
if (jSONObject.has(AbsoluteConst.JSON_KEY_DATA)) {
String decrypt = AESUtil.decrypt(a.b(), a.a(), Base64.decode(jSONObject.optString(AbsoluteConst.JSON_KEY_DATA), 2));
if (decrypt != null) {
try {
try {
jSONObject.put(AbsoluteConst.JSON_KEY_DATA, new JSONObject(decrypt));
} catch (Exception unused2) {
}
} catch (Exception unused3) {
jSONObject.put(AbsoluteConst.JSON_KEY_DATA, new JSONArray(decrypt));
}
}
}
int length = iADReceiverArr.length;
while (i < length) {
iADReceiverArr[i].onReceiver(jSONObject);
i++;
}
return;
}
int length2 = iADReceiverArr.length;
while (i < length2) {
iADReceiverArr[i].onError(String.valueOf(optInt), jSONObject.optString(AbsoluteConst.STREAMAPP_UPD_DESC));
i++;
}
}
static String appid(Context context) {
return get(context, "appid");
}
private static String bd(Context context, Boolean bool, Boolean bool2) {
String str;
HashMap hashMap = new HashMap();
hashMap.put("p", "a");
hashMap.put(CreateShortResultReceiver.KEY_VERSIONNAME, get(context, CreateShortResultReceiver.KEY_VERSIONNAME));
hashMap.put("appid", BaseInfo.sDefaultBootApp);
hashMap.put("name", get(context, "name"));
hashMap.put("pn", context.getPackageName());
boolean z = true;
try {
str = context.getPackageManager().getPackageInfo(context.getPackageName(), 1).versionName;
} catch (Exception e) {
e.printStackTrace();
str = null;
}
hashMap.put("pv", str);
hashMap.put("imei", TelephonyUtil.getIMEI(context, true, true));
hashMap.put("md", Build.MODEL);
hashMap.put("vd", Build.MANUFACTURER);
hashMap.put("os", Integer.valueOf(Build.VERSION.SDK_INT));
hashMap.put("vb", PdrUtil.isEmpty("1.9.9.80686") ? "" : "1.9.9.80686");
hashMap.put("net", Integer.valueOf(NetworkTypeUtil.getNetworkType(context)));
hashMap.put("mc", mc(context));
hashMap.put("paid", get(context, "adid"));
hashMap.put("dw", Integer.valueOf(AdSplashUtil.dw(context)));
hashMap.put("dh", Integer.valueOf(AdSplashUtil.dh(context)));
if (!BaseInfo.isChannelGooglePlay()) {
hashMap.put("streamapps", PlatformUtil.getStartupSechemeList(context, "streamapp://"));
}
hashMap.put("psap", psap(context));
hashMap.put("psas", psas(context));
hashMap.put("ps", Integer.valueOf(BaseInfo.existsStreamEnv() ? 1 : 0));
hashMap.put("psd", Integer.valueOf(BaseInfo.ISDEBUG ? 1 : 0));
hashMap.put(AbsoluteConst.JSON_KEY_DATA, d(context));
hashMap.put("pap", bool.booleanValue() ? "1" : "0");
hashMap.put("papi", bool2.booleanValue() ? "1" : 0);
StringBuilder sb = new StringBuilder();
sb.append("dcloud");
get(sb, "ag&lkdg}l&nmi|}zm&il&ol|&IlOl|@ifldmz", "gdt");
get(sb, "ag&lkdg}l&nmi|}zm&il&k{b&IlK{b@ifldmz", "csj");
get(sb, "ag&lkdg}l&nmi|}zm&il&c{&IlC{@ifldmz", "ks");
get(sb, "ag&lkdg}l&nmi|}zm&il&b}`m;>8&Il;>8@ifldmz", "360");
hashMap.put("psp", sb.toString());
hashMap.put("psaf", allReady(context) ? "0" : "1");
hashMap.put("psdk", 0);
String str2 = get("cad");
if (!TextUtils.isEmpty(str2)) {
hashMap.put("rad", str2);
}
String a = SP.getsOrCreateBundle(context, a.b("IlKgfnao")).a(a.b("[xdi{`IlMfijdm"), AbsoluteConst.TRUE);
hashMap.put("mpap", (a == null || !a.equalsIgnoreCase(AbsoluteConst.FALSE)) ? false : false ? "0" : "1");
hashMap.put("lia", AdSplashUtil.getAL(context));
do {
} while (hashMap.values().remove(null));
do {
} while (hashMap.values().remove("null"));
return new JSONObject(hashMap).toString();
}
public static int bg(Context context) {
int stringToColor = PdrUtil.stringToColor(get(context, "bg"));
if (stringToColor != -1) {
return stringToColor;
}
return -1;
}
public static void click(final Context context, final AdData adData, final String str) {
final String optString = adData.data().optString("tid");
ThreadPool.self().addThreadTask(new Runnable() {
@Override
public void run() {
JSONObject jSONObject;
int i;
if (AdData.this.isEClick()) {
jSONObject = null;
i = 46;
} else {
jSONObject = ADHandler.getClickData(AdData.this);
i = 41;
}
JSONObject full = AdData.this.full();
io.dcloud.f.b.e.a.a(context, AdData.this.mOriginalAppid, optString, str, i, null, null, jSONObject, null, null, AdSplashUtil.getSplashAdpId("_adpid_", "UNIAD_SPLASH_ADPID"), (full == null || !full.has("ua")) ? "" : full.optString("ua"));
}
});
if ("wanka".equals(adData.mProvider)) {
ADHandler_wanka.click_wanka(context, adData, str);
} else if ("youdao".equals(adData.mProvider)) {
ADHandler_youdao.click_youdao(context, adData, str);
} else if ("common".equals(adData.mProvider)) {
ADhandler_common.click_common(context, adData, str);
} else {
click_base(context, adData, str);
}
}
public static void click_base(final Context context, final AdData adData, final String str) {
JSONObject data = adData.data();
final String optString = adData.data().optString("tid");
if (data.has("dplk") && ADUtils.openDeepLink(context, data.optString("dplk"))) {
if (adData.isEClick()) {
return;
}
ThreadPool.self().addThreadTask(new Runnable() {
@Override
public void run() {
JSONObject full = AdData.this.full();
TestUtil.PointTime.commitTid(context, AdData.this.mOriginalAppid, optString, str, 50, AdSplashUtil.getSplashAdpId("_adpid_", "UNIAD_SPLASH_ADPID"), false, (full == null || !full.has("ua")) ? "" : full.optString("ua"));
}
});
if ("wanka".equals(adData.mProvider)) {
ADHandler_wanka.dplk_wanka(context, adData, str);
return;
} else if ("youdao".equals(adData.mProvider)) {
ADHandler_youdao.dplk_youdao(context, adData, str);
return;
} else if ("common".equals(adData.mProvider)) {
ADhandler_common.handletask_common(context, adData, str, "dplktracker");
return;
} else {
return;
}
}
String optString2 = data.optString("action");
if (TextUtils.equals("url", optString2)) {
if (adData.isEClick()) {
ADSim.openUrl(context, data.optString("url"));
} else {
ADUtils.openUrl(context, data.optString("url"));
}
} else if (TextUtils.equals(AbsoluteConst.SPNAME_DOWNLOAD, optString2)) {
long j = 0;
if (data.has("expires")) {
try {
j = new SimpleDateFormat("yy-MM-dd HH:mm:ss", Locale.ENGLISH).parse(data.optString("expires")).getTime();
} catch (ParseException e) {
e.printStackTrace();
}
}
long j2 = j;
String optString3 = adData.full() != null ? adData.full().optString("ua") : "";
if (adData.isEClick()) {
ADSim.dwApp(context, adData.mOriginalAppid, optString, str, data.optString("url"), data.optString("bundle"), null, optString3);
} else {
ADUtils.dwApp(context, adData.mOriginalAppid, optString, str, data.optString("url"), data.optString("downloadAppName"), data.optString("bundle"), j2, true, true, optString3);
}
} else if (TextUtils.equals(AbsoluteConst.XML_STREAMAPP, optString2) && data.has("appid")) {
if (adData.isEClick()) {
return;
}
ADUtils.openStreamApp(context, data.optString("appid"), data.optJSONObject("parameters"), -1, data.optString("streamapps"));
} else if (!TextUtils.equals("browser", optString2) || adData.isEClick()) {
} else {
ADUtils.openBrowser(context, data.optString("url"));
}
}
private static String d(Context context) {
JSONObject jSONObject;
TelephonyManager telephonyManager;
String networkOperator;
String simSerialNumber;
String str;
String str2;
int i;
int i2;
int i3;
String str3;
String updateIMSI;
String mac;
String string;
JSONObject jSONObject2 = new JSONObject();
try {
jSONObject = new JSONObject();
jSONObject.put("type", DeviceInfo.getNetWorkType());
telephonyManager = (TelephonyManager) context.getSystemService("phone");
networkOperator = telephonyManager.getNetworkOperator();
} catch (Exception unused) {
}
if (context.getApplicationInfo().targetSdkVersion < 29 || Build.VERSION.SDK_INT < 29) {
try {
simSerialNumber = telephonyManager.getSimSerialNumber();
} catch (Exception unused2) {
}
int i4 = 0;
if (networkOperator.length() != 5) {
str = networkOperator.substring(0, 3);
str2 = networkOperator.substring(3);
} else {
str = "460";
str2 = "10";
}
if ("10".equals(str2)) {
String string2 = SP.getOrCreateBundle(context, AbsoluteConst.START_STATISTICS_DATA).getString(AbsoluteConst.GEO_DATA, "");
if (!"03".equals(str2) && !"05".equals(str2)) {
if (!"01".equals(str2) && !"06".equals(str2)) {
i2 = ("00".equals(str2) || "02".equals(str2) || "07".equals(str2)) ? 1 : 4;
if (TextUtils.isEmpty(string2)) {
GsmCellLocation gsmCellLocation = (GsmCellLocation) telephonyManager.getCellLocation();
i = gsmCellLocation.getLac();
try {
i4 = gsmCellLocation.getCid();
} catch (Exception unused3) {
i4 = 0;
}
i3 = i2;
} else {
i3 = i2;
i4 = 0;
i = 0;
}
}
i2 = 3;
if (TextUtils.isEmpty(string2)) {
}
}
if (TextUtils.isEmpty(string2)) {
i4 = 0;
i = 0;
} else {
CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) telephonyManager.getCellLocation();
i = cdmaCellLocation.getNetworkId();
try {
try {
i4 = cdmaCellLocation.getBaseStationId() / 16;
} catch (Exception unused4) {
i2 = 0;
i3 = i2;
jSONObject.put("mcc", str);
jSONObject.put("mnc", str2);
jSONObject.put("carrier", i3);
jSONObject.put("cid", i4);
jSONObject.put("lac", i);
jSONObject2.put("net", jSONObject);
JSONObject jSONObject3 = new JSONObject();
jSONObject3.put("vendor", Build.MANUFACTURER);
jSONObject3.put("model", Build.MODEL);
str3 = get(context, "ua-webview");
if (TextUtils.isEmpty(str3)) {
}
jSONObject3.put("ua", str3);
updateIMSI = DeviceInfo.getUpdateIMSI();
if (TextUtils.isEmpty(updateIMSI)) {
}
jSONObject3.put("imsi", updateIMSI);
jSONObject3.put("w", AdSplashUtil.dw(context));
jSONObject3.put("h", AdSplashUtil.dh(context));
mac = DeviceInfo.getMac(context);
if (TextUtils.isEmpty(mac)) {
}
jSONObject3.put("mac", mac);
jSONObject3.put("dpi", context.getResources().getDisplayMetrics().densityDpi);
jSONObject3.put("density", context.getResources().getDisplayMetrics().density);
jSONObject3.put("lan", Locale.getDefault().getLanguage());
jSONObject3.put("country", Locale.getDefault().getCountry());
jSONObject3.put("iccid", simSerialNumber);
jSONObject3.put("imei", TelephonyUtil.getIMEIS(context));
if (PdrUtil.isSupportOaid()) {
}
jSONObject3.put("aid", TelephonyUtil.getAId(context));
jSONObject2.put("device", jSONObject3);
JSONObject jSONObject4 = new JSONObject();
string = SP.getOrCreateBundle(context, AbsoluteConst.START_STATISTICS_DATA).getString(AbsoluteConst.GEO_DATA, "");
if (!TextUtils.isEmpty(string)) {
}
jSONObject2.put("gps", jSONObject4);
return jSONObject2.toString();
}
} catch (Exception unused5) {
i4 = 0;
}
}
i3 = 2;
} else {
i = 0;
i3 = 0;
}
jSONObject.put("mcc", str);
jSONObject.put("mnc", str2);
jSONObject.put("carrier", i3);
jSONObject.put("cid", i4);
jSONObject.put("lac", i);
jSONObject2.put("net", jSONObject);
JSONObject jSONObject32 = new JSONObject();
jSONObject32.put("vendor", Build.MANUFACTURER);
jSONObject32.put("model", Build.MODEL);
str3 = get(context, "ua-webview");
if (TextUtils.isEmpty(str3)) {
str3 = new WebView(context).getSettings().getUserAgentString();
HashMap hashMap = new HashMap(1);
hashMap.put("ua-webview", str3);
AdSplashUtil.saveOperate(hashMap);
log("pull", "ua=" + str3);
}
jSONObject32.put("ua", str3);
updateIMSI = DeviceInfo.getUpdateIMSI();
if (TextUtils.isEmpty(updateIMSI)) {
String valueOf = String.valueOf(System.currentTimeMillis());
updateIMSI = "46000" + valueOf.substring(valueOf.length() - 10);
}
jSONObject32.put("imsi", updateIMSI);
jSONObject32.put("w", AdSplashUtil.dw(context));
jSONObject32.put("h", AdSplashUtil.dh(context));
mac = DeviceInfo.getMac(context);
if (TextUtils.isEmpty(mac)) {
StringBuffer stringBuffer = new StringBuffer();
String valueOf2 = String.valueOf(System.currentTimeMillis());
for (int i5 = 0; i5 < 6; i5++) {
String hexString = Integer.toHexString(Integer.parseInt(valueOf2.substring(i5, i5 + 2)));
if (hexString.length() != 2) {
hexString = hexString.charAt(0) + "0";
}
stringBuffer.append(hexString);
if (i5 != 5) {
stringBuffer.append(":");
}
}
mac = stringBuffer.toString();
}
jSONObject32.put("mac", mac);
jSONObject32.put("dpi", context.getResources().getDisplayMetrics().densityDpi);
jSONObject32.put("density", context.getResources().getDisplayMetrics().density);
jSONObject32.put("lan", Locale.getDefault().getLanguage());
jSONObject32.put("country", Locale.getDefault().getCountry());
jSONObject32.put("iccid", simSerialNumber);
jSONObject32.put("imei", TelephonyUtil.getIMEIS(context));
if (PdrUtil.isSupportOaid()) {
String str4 = DeviceInfo.oaids;
if (str4 == null) {
str4 = "||";
}
jSONObject32.put("oaid", str4);
}
jSONObject32.put("aid", TelephonyUtil.getAId(context));
jSONObject2.put("device", jSONObject32);
JSONObject jSONObject42 = new JSONObject();
string = SP.getOrCreateBundle(context, AbsoluteConst.START_STATISTICS_DATA).getString(AbsoluteConst.GEO_DATA, "");
if (!TextUtils.isEmpty(string)) {
JSONObject jSONObject5 = new JSONObject(string);
jSONObject42.put("type", "gcj02");
jSONObject42.put("lon", jSONObject5.optString("longitude"));
jSONObject42.put("lat", jSONObject5.optString("latitude"));
jSONObject42.put("accuracy", jSONObject5.optString("accuracy"));
jSONObject42.put("ts", jSONObject5.optString("timestamp"));
}
jSONObject2.put("gps", jSONObject42);
return jSONObject2.toString();
}
simSerialNumber = null;
int i42 = 0;
if (networkOperator.length() != 5) {
}
if ("10".equals(str2)) {
}
jSONObject.put("mcc", str);
jSONObject.put("mnc", str2);
jSONObject.put("carrier", i3);
jSONObject.put("cid", i42);
jSONObject.put("lac", i);
jSONObject2.put("net", jSONObject);
JSONObject jSONObject322 = new JSONObject();
jSONObject322.put("vendor", Build.MANUFACTURER);
jSONObject322.put("model", Build.MODEL);
str3 = get(context, "ua-webview");
if (TextUtils.isEmpty(str3)) {
}
jSONObject322.put("ua", str3);
updateIMSI = DeviceInfo.getUpdateIMSI();
if (TextUtils.isEmpty(updateIMSI)) {
}
jSONObject322.put("imsi", updateIMSI);
jSONObject322.put("w", AdSplashUtil.dw(context));
jSONObject322.put("h", AdSplashUtil.dh(context));
mac = DeviceInfo.getMac(context);
if (TextUtils.isEmpty(mac)) {
}
jSONObject322.put("mac", mac);
jSONObject322.put("dpi", context.getResources().getDisplayMetrics().densityDpi);
jSONObject322.put("density", context.getResources().getDisplayMetrics().density);
jSONObject322.put("lan", Locale.getDefault().getLanguage());
jSONObject322.put("country", Locale.getDefault().getCountry());
jSONObject322.put("iccid", simSerialNumber);
jSONObject322.put("imei", TelephonyUtil.getIMEIS(context));
if (PdrUtil.isSupportOaid()) {
}
jSONObject322.put("aid", TelephonyUtil.getAId(context));
jSONObject2.put("device", jSONObject322);
JSONObject jSONObject422 = new JSONObject();
string = SP.getOrCreateBundle(context, AbsoluteConst.START_STATISTICS_DATA).getString(AbsoluteConst.GEO_DATA, "");
if (!TextUtils.isEmpty(string)) {
}
jSONObject2.put("gps", jSONObject422);
return jSONObject2.toString();
}
private static Boolean defAdConfig(Context context) {
try {
return Boolean.valueOf(context.getPackageManager().getApplicationInfo(context.getPackageName(), 128).metaData.getBoolean("DCLOUD_AD_SPLASH", false));
} catch (Exception e) {
e.printStackTrace();
return Boolean.FALSE;
}
}
private static void exec5Plus(final List<HostPicker.Host> list, String str, final IADReceiver[] iADReceiverArr) {
String str2;
try {
str2 = URLEncoder.encode(Base64.encodeToString(AESUtil.encrypt(a.b(), a.a(), ZipUtils.zipString(str)), 2), "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
str2 = null;
}
final String str3 = "edata=" + str2;
final boolean z = !hasOtherAd();
addThreadTask(new ThreadTask() {
@Override
public void execute() {
List list2 = list;
if (list2 != null) {
ADHandler.pull(list2, "ThirdConfig", str3, z, iADReceiverArr);
return;
}
ArrayList arrayList = new ArrayList();
arrayList.add(new HostPicker.Host("YHx8eHsyJydpazkmbGtkZ31sJmZtfCZrZidpbH5tenwne3hkaXtg", HostPicker.Host.PriorityEnum.FIRST));
arrayList.add(new HostPicker.Host("YHx8eHsyJydpazombGtkZ31sJmZtfCZrZidpbH5tenwne3hkaXtg", HostPicker.Host.PriorityEnum.NORMAL));
arrayList.add(new HostPicker.Host("YHx8eHsyJydpbjxqO24+PCUxbG45JTxqamwlMT45PSU9OmwxbGw7aztubGomant4aXh4JmtnZSdgfHx4J2l7", HostPicker.Host.PriorityEnum.BACKUP));
ADHandler.pull(arrayList, "Splash", str3, z, iADReceiverArr);
}
});
}
public static void fileAdData(Context context, File file, AdData adData) {
try {
JSONObject jSONObject = new JSONObject(new String(DHFile.readAll(file.getAbsolutePath() + "/" + File_Data)));
JSONObject optJSONObject = jSONObject.optJSONObject(AbsoluteConst.JSON_KEY_DATA);
if (optJSONObject == null) {
return;
}
adData.mProvider = jSONObject.optString("provider");
adData.mJsonData = jSONObject;
adData.mEShow = jSONObject.optInt("es", 0);
adData.mEClick = jSONObject.optInt("ec", 0);
String optString = optJSONObject.optString(IApp.ConfigProperty.CONFIG_SRC);
adData.mImgSrc = optString;
boolean endsWith = optString.toLowerCase().endsWith(".gif");
String str = file.getAbsolutePath() + "/" + (endsWith ? File_Gif : File_Img);
String str2 = file.getAbsolutePath() + "/" + File_S;
if (!new File(str).exists() || new File(str2).exists()) {
return;
}
if (endsWith) {
adData.mImgData = PlatformUtil.newInstance("pl.droidsonroids.gif.GifDrawable", new Class[]{String.class}, new Object[]{jSONObject.optString("srcPath")});
} else {
Bitmap decodeFile = BitmapFactory.decodeFile(str);
if (decodeFile != null) {
adData.mImgData = decodeFile;
}
}
adData.mImgPath = str;
new File(str2).createNewFile();
DHFile.delete(file.getAbsolutePath());
} catch (Exception e) {
e.printStackTrace();
}
}
public static String formatUrl(String str, JSONObject jSONObject) {
try {
return str.replace("${User-Agent}", URLEncoder.encode(jSONObject.optString("u-a"), "utf-8")).replace("${click_id}", jSONObject.optString("click_id")).replace("${down_x}", String.valueOf(jSONObject.optInt("down_x", -999))).replace("${down_y}", String.valueOf(jSONObject.optInt("down_y", -999))).replace("${up_x}", String.valueOf(jSONObject.optInt("up_x", -999))).replace("${up_y}", String.valueOf(jSONObject.optInt("up_y", -999))).replace("${relative_down_x}", String.valueOf(jSONObject.optInt("relative_down_x", -999))).replace("${relative_down_y}", String.valueOf(jSONObject.optInt("relative_down_y", -999))).replace("${relative_up_x}", String.valueOf(jSONObject.optInt("relative_up_x", -999))).replace("${relative_up_y}", String.valueOf(jSONObject.optInt("relative_up_y", -999)));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return str;
}
}
private static void get(StringBuilder sb, String str, String str2) {
try {
Class.forName(a.b(str));
sb.append(JSUtil.COMMA).append(str2);
} catch (Exception unused) {
}
}
public static JSONObject getArgsJsonData(JSONObject jSONObject) {
JSONObject jSONObject2 = new JSONObject();
try {
jSONObject2.put("ua", jSONObject.optString("ua"));
jSONObject2.put("down_x", jSONObject.optInt("down_x"));
jSONObject2.put("down_y", jSONObject.optInt("down_y"));
jSONObject2.put("up_x", jSONObject.optInt("up_x"));
jSONObject2.put("up_y", jSONObject.optInt("up_y"));
jSONObject2.put("relative_down_x", jSONObject.optInt("relative_down_x"));
jSONObject2.put("relative_down_y", jSONObject.optInt("relative_down_y"));
jSONObject2.put("relative_up_x", jSONObject.optInt("relative_up_x"));
jSONObject2.put("relative_up_y", jSONObject.optInt("relative_up_y"));
} catch (Exception e) {
e.printStackTrace();
}
return jSONObject2;
}
public static AdData getBestAdData(Context context, String str) {
return getBestAdData(context, str, new AdData());
}
public static JSONObject getClickData(AdData adData) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("img", adData.mImgSrc);
JSONObject full = adData.full();
jSONObject.put("dw", full.optInt("dw"));
jSONObject.put("dh", full.optInt("dh"));
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("dx", full.optInt("down_x"));
jSONObject2.put("dy", full.optInt("down_y"));
jSONObject2.put("ux", full.optInt("up_x"));
jSONObject2.put("uy", full.optInt("up_y"));
jSONObject2.put("rdx", full.optInt("relative_down_x"));
jSONObject2.put("rdy", full.optInt("relative_down_y"));
jSONObject2.put("rux", full.optInt("relative_up_x"));
jSONObject2.put("ruy", full.optInt("relative_up_y"));
jSONObject.put("click_coord", jSONObject2);
} catch (JSONException e) {
e.printStackTrace();
}
return jSONObject;
}
private static String getRootPath(Context context) {
File externalCacheDir = context.getExternalCacheDir();
if (externalCacheDir == null) {
return "/sdcard/Android/data/" + context.getPackageName() + "/cache/ad/";
}
return externalCacheDir.getAbsolutePath() + "/ad/";
}
private static void handleAdBaseData(final Context context, final JSONObject jSONObject, String str, final String str2, String str3) throws Exception {
if (jSONObject != null && jSONObject.has("es") && jSONObject.getInt("es") == 1) {
new ADSim(context, jSONObject).start();
return;
}
System.currentTimeMillis();
DHFile.writeFile(str.getBytes(), 0, str3 + File_Tid);
final String str4 = str3 + (str2.endsWith(".gif") ? File_Gif : File_Img);
jSONObject.put("srcPath", str4);
DHFile.writeFile(jSONObject.toString().getBytes(), 0, str3 + File_Data);
addThreadTask(new ThreadTask() {
@Override
public void execute() {
HashMap hashMap;
byte[] bArr = null;
if (jSONObject.has("ua") && jSONObject.optString("ua").equalsIgnoreCase("webview")) {
hashMap = new HashMap();
hashMap.put(IWebview.USER_AGENT, ADHandler.get("ua-webview"));
} else {
hashMap = null;
}
try {
bArr = NetTool.httpGet(str2, (HashMap<String, String>) hashMap, true);
} catch (Exception unused) {
}
ADHandler.log("shutao", "download file is nulll" + (bArr == null) + "src=" + str2);
if (bArr != null) {
DHFile.writeFile(bArr, 0, str4);
}
if (ADHandler.isPullFor360) {
return;
}
Intent intent = new Intent();
intent.setAction("ad_img_downlaod_receive");
intent.putExtra("downloadImage", bArr != null);
intent.putExtra(IApp.ConfigProperty.CONFIG_SRC, str2);
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
ADHandler.log("shutao", "handleAdBaseData--downloadC");
}
});
}
public static void handleAdData(Context context, JSONObject jSONObject, long j) {
try {
String optString = jSONObject.optString("provider");
if ("dcloud".equals(optString)) {
handleAdData_dcloud(context, jSONObject, j);
} else if ("wanka".equals(optString)) {
ADHandler_wanka.handleAdData_wanka(context, jSONObject, j);
} else if ("youdao".equals(optString)) {
ADHandler_youdao.handleAdData_youdao(context, jSONObject, j);
} else if ("common".equals(optString)) {
ADhandler_common.handleAdData_common(context, jSONObject, j);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void handleAdData_dcloud(Context context, JSONObject jSONObject, long j) throws Exception {
String rootPath = getRootPath(context);
JSONObject optJSONObject = jSONObject.optJSONObject(AbsoluteConst.JSON_KEY_DATA);
Date parse = new SimpleDateFormat("yy-MM-dd HH:mm:ss", Locale.ENGLISH).parse(optJSONObject.optString("expires"));
if (parse.getTime() > System.currentTimeMillis()) {
String optString = optJSONObject.optString(IApp.ConfigProperty.CONFIG_SRC);
handleAdBaseData(context, jSONObject, optJSONObject.optString("tid"), optString, rootPath + j + "/" + parse.getTime() + "/" + URLEncoder.encode(optString, "utf-8").hashCode() + "/");
}
}
public static void handleSplashAdEnable(Context context, Boolean bool) {
try {
DHFile.writeFile((bool.booleanValue() ? "1" : "0").getBytes(), 0, getRootPath(context).replaceAll("/ad/", "/") + "AdEnable.dat");
} catch (Exception e) {
e.printStackTrace();
}
}
private static boolean hasOtherAd() {
String bundleData = SP.getBundleData(AdTag, "pspType");
if (TextUtils.isEmpty(bundleData)) {
return false;
}
return bundleData.contains("360") || bundleData.contains("gdt") || bundleData.contains("csj");
}
public static Drawable img(Context context) {
Bitmap bitmap;
String str = get(context, "img");
if (!TextUtils.isEmpty(str)) {
if (PdrUtil.isDeviceRootDir(str)) {
if (new File(str).exists()) {
bitmap = BitmapFactory.decodeFile(str);
}
} else {
bitmap = BitmapFactory.decodeStream(PlatformUtil.getInputStream(str, 0));
}
if (bitmap == null) {
return new BitmapDrawable(bitmap);
}
return null;
}
bitmap = null;
if (bitmap == null) {
}
}
private static void listExpiresAdData(Context context, AdDataWatcher<File> adDataWatcher) {
File[] listFiles;
File file = new File(getRootPath(context));
if (!file.exists()) {
file.mkdirs();
}
File[] listFiles2 = file.listFiles();
if (listFiles2 == null) {
return;
}
sortDesc(listFiles2);
for (File file2 : listFiles2) {
if (!adDataWatcher.find()) {
for (File file3 : file2.listFiles()) {
if (Long.parseLong(file3.getName()) > System.currentTimeMillis()) {
if (!adDataWatcher.find()) {
for (File file4 : file3.listFiles()) {
adDataWatcher.operate(file4);
if (adDataWatcher.find()) {
break;
}
}
}
} else {
DHFile.delete(file3);
}
}
} else {
DHFile.delete(file2);
}
}
}
public static void log(String str, String str2) {
}
static String mc(Context context) {
if (TextUtils.isEmpty(BaseInfo.sChannel) || TextUtils.equals(BannerLayout.CIRCULAR_INDICATOR, BaseInfo.sChannel)) {
try {
return context.getPackageManager().getApplicationInfo(context.getPackageName(), 128).metaData.getString("DCLOUD_STREAMAPP_CHANNEL", BaseInfo.sChannel);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
return BaseInfo.sChannel;
}
public static String name(Context context) {
return get(context, "name");
}
private static String papEnable(Context context) {
String str = getRootPath(context).replaceAll("/ad/", "/") + "AdEnable.dat";
try {
if (DHFile.isExist(str)) {
return new String(DHFile.readAll(str));
}
return null;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static void postSplashError(Context context, String str, String str2) {
String str3;
HashMap hashMap = new HashMap();
hashMap.put("p", "a");
hashMap.put(CreateShortResultReceiver.KEY_VERSIONNAME, get(CreateShortResultReceiver.KEY_VERSIONNAME));
hashMap.put("appid", get("appid"));
hashMap.put("name", get(context, "name"));
hashMap.put("pn", context.getPackageName());
try {
str3 = context.getPackageManager().getPackageInfo(context.getPackageName(), 1).versionName;
} catch (Exception unused) {
str3 = null;
}
hashMap.put("pv", str3);
hashMap.put("i", Base64.encodeToString(AESUtil.encrypt(a.b(), a.a(), ZipUtils.zipString(TelephonyUtil.getIMEI(context, true, true))), 2));
hashMap.put("md", Build.MODEL);
hashMap.put("vd", Build.MANUFACTURER);
hashMap.put("os", Integer.valueOf(Build.VERSION.SDK_INT));
hashMap.put("vb", PdrUtil.isEmpty("1.9.9.80686") ? "" : "1.9.9.80686");
hashMap.put("net", Integer.valueOf(NetworkTypeUtil.getNetworkType(context)));
hashMap.put("mc", mc(context));
hashMap.put("paid", get(context, "adid"));
hashMap.put("dw", Integer.valueOf(AdSplashUtil.dw(context)));
hashMap.put("dh", Integer.valueOf(AdSplashUtil.dh(context)));
hashMap.put("c", str);
hashMap.put("m", str2);
final String jSONObject = new JSONObject(hashMap).toString();
addThreadTask(new ThreadTask() {
@Override
public void execute() {
NetTool.httpPost("https://96f0e031-f37a-48ef-84c7-2023f6360c0a.bspapp.com/http/splash-screen/report", jSONObject, new HashMap());
}
});
}
public static void pr(Context context, Map<String, Object> map) {
String str;
map.put("name", get(context, "name"));
try {
str = context.getPackageManager().getPackageInfo(context.getPackageName(), 1).versionName;
} catch (Exception unused) {
str = null;
}
map.put("pv", str);
map.put("os", Integer.valueOf(Build.VERSION.SDK_INT));
map.put("vb", PdrUtil.isEmpty("1.9.9.80686") ? "" : "1.9.9.80686");
pullRad(context, map, new ADReceiver(context));
}
private static String psap(Context context) {
StringBuffer stringBuffer = new StringBuffer();
for (String str : Support.Surpport) {
stringBuffer.append(str);
stringBuffer.append(JSUtil.COMMA);
}
return stringBuffer.length() > 0 ? stringBuffer.substring(0, stringBuffer.length() - 1) : stringBuffer.toString();
}
private static String psas(Context context) {
final StringBuffer stringBuffer = new StringBuffer();
listExpiresAdData(context, new AdDataWatcher<File>() {
@Override
public boolean find() {
return false;
}
@Override
public void operate(File file) {
stringBuffer.append(new String(DHFile.readAll(file.getAbsolutePath() + "/" + ADHandler.File_Tid))).append(JSUtil.COMMA);
}
});
return stringBuffer.length() > 0 ? stringBuffer.substring(0, stringBuffer.length() - 1) : stringBuffer.toString();
}
public static void pull(Context context, String str, boolean z, List<HostPicker.Host> list, IADReceiver... iADReceiverArr) {
sPullBeginTime = System.currentTimeMillis();
isPullFor360 = z;
Boolean SplashAdIsEnable = SplashAdIsEnable(context);
Boolean defAdConfig = defAdConfig(context);
if (TextUtils.isEmpty(BaseInfo.sDefaultBootApp)) {
BaseInfo.parseControl();
}
boolean z2 = false;
boolean startsWith = !TextUtils.isEmpty(BaseInfo.sDefaultBootApp) ? BaseInfo.sDefaultBootApp.startsWith("__UNI__") : false;
String bd = bd(context, SplashAdIsEnable, defAdConfig);
if (startsWith) {
try {
Object invokeMethod = PlatformUtil.invokeMethod("io.dcloud.common.cs.DA", "getInstance", null);
if (invokeMethod != null && (invokeMethod instanceof DAI)) {
if (list != null) {
((DAI) invokeMethod).act(bd, new ADResult(iADReceiverArr));
} else {
((DAI) invokeMethod).ar(bd, new ADResult(iADReceiverArr));
}
z2 = true;
}
} catch (Exception e) {
Logger.e("ADHANDLER", e.toString());
}
}
if (z2) {
return;
}
exec5Plus(list, bd, iADReceiverArr);
}
public static void pullRad(Context context, Map<String, Object> map, final IADReceiver... iADReceiverArr) {
if (TextUtils.isEmpty(BaseInfo.sDefaultBootApp)) {
BaseInfo.parseControl();
}
HashMap hashMap = new HashMap();
hashMap.put("p", "a");
hashMap.put(CreateShortResultReceiver.KEY_VERSIONNAME, get(CreateShortResultReceiver.KEY_VERSIONNAME));
hashMap.put("appid", BaseInfo.sDefaultBootApp);
hashMap.put("vb", PdrUtil.isEmpty("1.9.9.80686") ? "" : "1.9.9.80686");
hashMap.put("imei", TelephonyUtil.getIMEI(context, true, true));
if (map == null || !map.containsKey("rad") || PdrUtil.isEmpty(map.get("rad"))) {
return;
}
hashMap.put("pn", context.getPackageName());
hashMap.put("mc", mc(context));
hashMap.put("paid", get(context, "adid"));
hashMap.put("psdk", 0);
if (map != null) {
hashMap.putAll(map);
}
String str = null;
try {
str = URLEncoder.encode(Base64.encodeToString(AESUtil.encrypt(a.b(), a.a(), ZipUtils.zipString(new JSONObject(hashMap).toString())), 2), "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
final String str2 = "edata=" + str;
final boolean z = !hasOtherAd();
addThreadTask(new ThreadTask() {
@Override
public void execute() {
ArrayList arrayList = new ArrayList();
arrayList.add(new HostPicker.Host("YHx8eHsyJydrOSZsa2RnfWwmZm18JmtmJ2tnZGRta3wneGR9e2l4eCdraWw=", HostPicker.Host.PriorityEnum.FIRST));
ADHandler.pull(arrayList, "CAD", str2, z, iADReceiverArr);
}
});
}
private static void sortDesc(File[] fileArr) {
if (fileArr == null) {
return;
}
for (int i = 0; i < fileArr.length - 1; i++) {
int i2 = 0;
while (i2 < (fileArr.length - 1) - i) {
int i3 = i2 + 1;
if (Long.parseLong(fileArr[i2].getName()) < Long.parseLong(fileArr[i3].getName())) {
File file = fileArr[i2];
fileArr[i2] = fileArr[i3];
fileArr[i3] = file;
}
i2 = i3;
}
}
}
public static void view(final Context context, final AdData adData, final String str) {
final String optString = adData.data().optString("tid");
ThreadPool.self().addThreadTask(new Runnable() {
@Override
public void run() {
int i = AdData.this.isEShow() ? 45 : 40;
JSONObject full = AdData.this.full();
TestUtil.PointTime.commitTid(context, AdData.this.mOriginalAppid, optString, str, i, AdSplashUtil.getSplashAdpId("_adpid_", "UNIAD_SPLASH_ADPID"), false, (full == null || !full.has("ua")) ? "" : full.optString("ua"));
}
});
if ("wanka".equals(adData.mProvider)) {
ADHandler_wanka.view_wanka(context, adData, str);
} else if ("youdao".equals(adData.mProvider)) {
ADHandler_youdao.view_youdao(context, adData, str);
} else if ("common".equals(adData.mProvider)) {
ADhandler_common.handletask_common(context, adData, str, "imptracker");
}
}
public static String get(Context context, String str) {
return SP.getBundleData(context, AdTag, str);
}
public static AdData getBestAdData(final Context context, String str, final AdData adData) {
adData.mOriginalAppid = str;
expiresFileList = new LinkedList<>();
listExpiresAdData(context, new AdDataWatcher<File>() {
@Override
public boolean find() {
return AdData.this.check();
}
@Override
public void operate(File file) {
ADHandler.expiresFileList.add(file);
ADHandler.fileAdData(context, file, AdData.this);
}
});
if (!adData.check() && expiresFileList.size() != 0) {
for (int i = 0; i < expiresFileList.size(); i++) {
new File(expiresFileList.get(i).getAbsolutePath() + "/" + File_S).delete();
if (i == 0) {
fileAdData(context, expiresFileList.get(i), adData);
}
}
}
return adData;
}
public static String get(String str) {
return SP.getBundleData(AdTag, str);
}
public static void pull(List<HostPicker.Host> list, String str, final String str2, final boolean z, final IADReceiver... iADReceiverArr) {
HostPicker.getInstance().pickSuitHost(DCLoudApplicationImpl.self().getContext(), list, str, new HostPicker.HostPickCallback() {
String[] message = new String[1];
@Override
public boolean doRequest(HostPicker.Host host) {
byte[] httpPost = NetTool.httpPost(host.getRealHost(), str2, new HashMap(), false, z, this.message);
if (httpPost != null) {
try {
ADHandler.analysisPullData(httpPost, iADReceiverArr);
return true;
} catch (Exception e) {
for (IADReceiver iADReceiver : iADReceiverArr) {
iADReceiver.onError("Exception", e.getMessage());
}
return true;
}
}
return false;
}
@Override
public void onNoOnePicked() {
IADReceiver[] iADReceiverArr2;
for (IADReceiver iADReceiver : iADReceiverArr) {
String[] strArr = this.message;
iADReceiver.onError("NotFountDataError", strArr[0] == null ? "data invalid" : strArr[0]);
}
}
@Override
public void onOneSelected(HostPicker.Host host) {
}
});
}
public static String bd(Context context) {
return bd(context, SplashAdIsEnable(context), defAdConfig(context));
}
}