atsameip v0.1版本的 MD5 值为:28547cf98b0a2d02acb37969dcfb83e9
以下内容为反编译后的 d.java 源代码,内容仅作参考
package com.appnext.core;
import android.accounts.AccountManager;
import android.content.Context;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Pair;
import com.applovin.impl.sdk.utils.JsonUtils;
import com.appnext.core.d;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Random;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public abstract class d {
private Context aM;
protected final int ce = 0;
protected final int cf = 1;
protected final int cg = 2;
protected final int ch = 3;
private final HashMap<b, com.appnext.core.a> ci = new HashMap<>();
public interface a {
<T> void a(T t);
void error(String str);
}
protected abstract int a(Context context, h hVar);
protected abstract String a(Context context, Ad ad, String str, ArrayList<Pair<String, String>> arrayList);
protected abstract void a(Context context, Ad ad, com.appnext.core.a aVar) throws Exception;
protected abstract void a(Ad ad, String str, String str2);
protected abstract <T> void a(String str, Ad ad, T t);
protected abstract SettingsManager c(Ad ad);
public final void a(Context context, Ad ad, String str, a aVar) {
a(context, ad, str, aVar, true);
}
public final void a(Context context, Ad ad, String str, a aVar, boolean z) {
try {
this.aM = context.getApplicationContext();
if (g.g(context)) {
b(context, ad, str, aVar, z);
} else if (aVar != null) {
aVar.error(AppnextError.CONNECTION_ERROR);
}
} catch (Throwable th) {
com.appnext.base.a.a("AdsManager$getAdList", th);
if (aVar != null) {
aVar.error(AppnextError.NO_ADS);
}
}
}
public String b(Context context, Ad ad, String str, ArrayList<Pair<String, String>> arrayList) {
String str2;
StringBuilder sb = new StringBuilder("https://global.appnext.com/offerWallApi.aspx?ext=t&pimp=1&igroup=sdk&m=1&osid=100&s2s=1&type=json&id=");
sb.append(str);
sb.append("&cnt=50");
sb.append("&tid=");
sb.append(ad != null ? ad.getTID() : "301");
sb.append("&vid=");
sb.append(ad != null ? ad.getVID() : "2.6.6.473");
sb.append("&cat=");
String str3 = "";
sb.append(ad != null ? ad.getCategories() : "");
sb.append("&lockcat=");
sb.append(ad != null ? ad.getSpecificCategories() : "");
sb.append("&did=");
sb.append(g.b(context, false));
sb.append("&devn=");
sb.append(g.V());
sb.append("&dosv=");
sb.append(Build.VERSION.SDK_INT);
sb.append("&dct=");
sb.append(g.q(g.c(context)));
sb.append("&lang=");
sb.append(Locale.getDefault().getLanguage());
sb.append("&dcc=");
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
if (telephonyManager.getSimState() == 5) {
String simOperator = telephonyManager.getSimOperator();
str2 = simOperator.substring(0, 3) + "_" + simOperator.substring(3);
} else {
str2 = "";
}
sb.append(str2);
sb.append("&dds=0");
sb.append("&packageId=");
sb.append(context.getPackageName());
sb.append("&g=");
sb.append(a(context));
sb.append("&opt=");
sb.append(AdsIDHelper.isOptOut(context) ? 1 : 0);
sb.append("&rnd=");
sb.append(new Random().nextInt());
if (!TextUtils.isEmpty(ad.getPackageName())) {
str3 = "&sp=" + ad.getPackageName();
}
sb.append(str3);
return sb.toString();
}
private void b(final Context context, final Ad ad, final String str, final a aVar, final boolean z) {
try {
n.aa().a(new Runnable() {
@Override
public final void run() {
try {
ad.setSessionId(g.e(context));
} catch (Throwable unused) {
}
try {
synchronized (d.this.ci) {
if (d.this.j(ad) != null && d.this.j(ad).P() == 1) {
if (aVar != null) {
d.this.j(ad).a(aVar);
}
return;
}
com.appnext.core.a aVar2 = new com.appnext.core.a();
aVar2.a(aVar);
aVar2.setPlacementID(str);
aVar2.b(1);
d.this.ci.remove(new b(ad));
d.this.a(ad, aVar2);
ArrayList<Pair<String, String>> arrayList = new ArrayList<>();
String str2 = d.this.b(context, ad, str, arrayList) + d.this.a(context, ad, str, arrayList);
new StringBuilder("AdsManager request url: ").append(str2);
e.R();
String a2 = e.a(context, str, ad.getAUID(), d.this.a(ad, "ads_caching_time_minutes"), str2, ad.getSpecificCategories(), ad.getCategories());
if (TextUtils.isEmpty(a2) || a2.equals("{\"apps\":[]}") || a2.equals(JsonUtils.EMPTY_JSON) || d.m(a2)) {
d.this.a(AppnextError.NO_ADS, a2, ad);
return;
}
if (!TextUtils.isEmpty(ad.getPostback())) {
a2 = a2.replaceAll("&q=", "&q=" + ad.getPostback());
}
ArrayList<AppnextAd> a3 = d.a(context, d.this.a(context, ad, a2, 50), str, ad.getAUID());
if (a3 != null && !a3.isEmpty()) {
d.this.j(ad).c(a3);
if (z) {
try {
d.this.a(context, ad, d.this.j(ad));
} catch (Throwable unused2) {
}
}
d.this.j(ad).b(2);
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public final void run() {
try {
final com.appnext.core.a j = d.this.j(ad);
final ArrayList<?> ads = d.this.j(ad).getAds();
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public final void run() {
try {
synchronized (a.this.bV) {
ListIterator listIterator = a.this.bV.listIterator();
while (listIterator.hasNext()) {
((d.a) listIterator.next()).a(ads);
listIterator.remove();
}
}
} catch (Throwable th) {
com.appnext.base.a.a("AdContainer$notifyListenersSuccess", th);
}
}
});
d.this.a(str, ad, (Ad) d.this.j(ad).getAds());
} catch (Throwable unused3) {
d.this.a(AppnextError.INTERNAL_ERROR, ad);
}
}
});
return;
}
d.this.a(AppnextError.NO_ADS, a2, ad);
}
} catch (Throwable th) {
com.appnext.base.a.a("AdsManager$updateAdList", th);
d.this.a(th.getMessage(), ad);
}
}
});
} catch (Throwable unused) {
a(AppnextError.INTERNAL_ERROR, ad);
}
}
public boolean a(Ad ad) {
try {
if (h(ad)) {
if (i(ad)) {
return true;
}
}
return false;
} catch (Throwable th) {
com.appnext.base.a.a("AdsManager$isLoadedAndUpdated", th);
return false;
}
}
public final boolean h(Ad ad) {
try {
if (this.ci != null && j(ad) != null && j(ad).P() == 2) {
if (j(ad).getAds() != null) {
return true;
}
}
} catch (Throwable unused) {
}
return false;
}
protected final boolean i(Ad ad) {
try {
if (this.ci != null && j(ad) != null && j(ad).getAds().size() == 0) {
if (j(ad).O().longValue() + 60000 > System.currentTimeMillis()) {
return true;
}
}
} catch (Throwable unused) {
}
return false;
}
public long a(Ad ad, String str) {
try {
return Long.valueOf(c(ad).t(str)).longValue();
} catch (Throwable unused) {
return 0L;
}
}
public static ArrayList<AppnextAd> a(Context context, ArrayList<AppnextAd> arrayList, String str, String str2) {
try {
if (arrayList == null) {
return new ArrayList<>();
}
List<String> w = com.appnext.core.adswatched.a.l(context).w(str2);
if (w != null && !w.isEmpty()) {
arrayList.size();
ArrayList<AppnextAd> arrayList2 = new ArrayList<>();
ListIterator<AppnextAd> listIterator = arrayList.listIterator();
while (listIterator.hasNext()) {
AppnextAd next = listIterator.next();
if (next != null && !w.contains(next.getBannerID())) {
arrayList2.add(next);
listIterator.remove();
}
}
if (arrayList2.isEmpty()) {
com.appnext.core.adswatched.a.l(context).k(str, str2);
}
arrayList2.addAll(arrayList);
new StringBuilder("Result filtered by watched ads - ").append(arrayList.toString());
return arrayList2;
}
return arrayList;
} catch (Throwable unused) {
return new ArrayList<>();
}
}
public ArrayList<AppnextAd> a(Context context, Ad ad, String str, int i) throws JSONException {
j(ad).k(str);
ArrayList<AppnextAd> arrayList = new ArrayList<>();
StringBuilder sb = new StringBuilder();
JSONArray jSONArray = new JSONObject(str).getJSONArray("apps");
int i2 = 0;
int i3 = 0;
int i4 = 0;
int i5 = 0;
for (int i6 = 0; i6 < jSONArray.length(); i6++) {
try {
AppnextAd appnextAd = (AppnextAd) parseAd(jSONArray.getJSONObject(i6).toString());
appnextAd.setAdID(arrayList.size());
appnextAd.setPlacementID(ad.getPlacementID());
int a2 = a(context, appnextAd);
if (a2 == 0) {
AppnextAd a3 = a(arrayList, appnextAd);
if (a3 != null) {
arrayList.remove(a3);
if (!TextUtils.isEmpty(a3.getRevenueType()) && a3.getRevenueType().equals(appnextAd.getRevenueType())) {
if (Float.parseFloat(a3.getRevenueRate()) >= Float.parseFloat(appnextAd.getRevenueRate())) {
appnextAd = a3;
}
i5++;
} else {
if (!TextUtils.isEmpty(a3.getRevenueType())) {
}
i5++;
}
} else {
i2++;
}
arrayList.add(appnextAd);
} else {
sb.append(appnextAd.getBannerID());
sb.append(",");
if (a2 == 1) {
i3++;
} else if (a2 == 2) {
i4++;
} else if (a2 == 3) {
i5++;
}
}
} catch (Throwable unused) {
}
if (arrayList.size() == 50) {
break;
}
}
StringBuilder sb2 = new StringBuilder("Filtering values {count = ");
sb2.append(i2);
sb2.append(", new filtered = ");
sb2.append(i3);
sb2.append(", existing filtered = ");
sb2.append(i4);
sb2.append(", other = ");
sb2.append(i5);
return arrayList;
}
private static AppnextAd a(ArrayList<AppnextAd> arrayList, AppnextAd appnextAd) {
try {
Iterator<AppnextAd> it = arrayList.iterator();
while (it.hasNext()) {
AppnextAd next = it.next();
if (next.getAdPackage().equals(appnextAd.getAdPackage())) {
return next;
}
}
return null;
} catch (Throwable unused) {
return null;
}
}
protected static boolean m(String str) {
try {
return new JSONObject(str).has("rnd");
} catch (Throwable unused) {
return true;
}
}
public String a(ArrayList<AppnextAd> arrayList) {
try {
JSONArray jSONArray = new JSONArray();
Iterator<AppnextAd> it = arrayList.iterator();
while (it.hasNext()) {
jSONArray.put(new JSONObject(it.next().getAdJSON()));
}
JSONObject jSONObject = new JSONObject();
jSONObject.put("apps", jSONArray);
return jSONObject.toString().replace("\u2028", "\\u2028").replace("\u2029", "\\u2029");
} catch (Throwable unused) {
return "";
}
}
protected final void a(String str, Ad ad) {
a(str, "", ad);
}
protected final void a(String str, String str2, Ad ad) {
a(str, str2, ad, 2);
}
protected final void a(final String str, final String str2, final Ad ad, final int i) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public final void run() {
try {
com.appnext.core.a j = d.this.j(ad);
if (j != null) {
if (j.getAds() == null) {
j.c(new ArrayList<>());
} else {
j.c(j.getAds());
}
j.b(i);
j.l(str);
d dVar = d.this;
Ad ad2 = ad;
dVar.a(ad2, str + " " + str2, j.getPlacementID());
}
} catch (Throwable th) {
com.appnext.base.a.a("AdKey$notifyError", th);
}
}
});
}
public final com.appnext.core.a j(Ad ad) {
return this.ci.get(new b(ad));
}
public final HashMap<b, com.appnext.core.a> Q() {
return this.ci;
}
protected final void a(Ad ad, com.appnext.core.a aVar) {
this.ci.put(new b(ad), aVar);
}
public static String c(AppnextAd appnextAd) {
return appnextAd.getAdJSON();
}
public final String k(Ad ad) {
return j(ad).w();
}
public static h parseAd(String str) {
try {
JSONObject jSONObject = new JSONObject(str);
AppnextAd appnextAd = (AppnextAd) k.a(AppnextAd.class, jSONObject);
if (appnextAd != null) {
appnextAd.setAdJSON(jSONObject.toString());
if (jSONObject.has("sid")) {
appnextAd.setSession(jSONObject.getString("sid"));
}
if (TextUtils.isEmpty(appnextAd.getStoreRating())) {
appnextAd.setStoreRating("0");
}
}
return appnextAd;
} catch (Throwable unused) {
return null;
}
}
public void a(final Context context, final String str, final Ad ad) {
n.aa().a(new Runnable() {
@Override
public final void run() {
try {
com.appnext.core.adswatched.a.l(context).j(str, ad.getAUID());
} catch (Throwable unused) {
}
}
});
}
protected static int a(Context context) {
try {
if (g.c(context, "android.permission.READ_CONTACTS") && g.c(context, "android.permission.GET_ACCOUNTS")) {
return AccountManager.get(context).getAccountsByType("com.google").length > 0 ? 0 : 1;
}
} catch (Throwable unused) {
}
return 2;
}
public final Context getContext() {
return this.aM;
}
}