Apk Done v1.0版本的 MD5 值为:44cfb8e1ce639995aa7f0de6a3a6388b
以下内容为反编译后的 g.java 源代码,内容仅作参考
package com.appnext.core;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Process;
import android.text.TextUtils;
import android.util.Pair;
import com.appnext.base.a.a.a;
import com.appodeal.ads.utils.LogConstants;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.PushbackInputStream;
import java.io.StringWriter;
import java.net.CookieHandler;
import java.net.CookieManager;
import java.net.HttpRetryException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.zip.GZIPInputStream;
import org.json.JSONArray;
import org.json.JSONObject;
public final class g {
private static double cT;
private static String cU;
private static String cV;
private static String cW;
static {
CookieHandler.setDefault(new CookieManager());
cT = -1.0d;
cU = "";
cV = "";
cW = "";
}
public static String b(Context context, boolean z) {
if (context == null || context.getApplicationContext() == null) {
return "";
}
try {
String a = AdsIDHelper.a(context.getApplicationContext(), z);
cV = a;
return a;
}
}
public static String V() {
try {
return URLEncoder.encode("android " + Build.VERSION.SDK_INT + " " + Build.MANUFACTURER + " " + Build.MODEL, "UTF-8");
} catch (Throwable th) {
com.appnext.base.a.a("AppnextHelperClass$getDevice", th);
return "android";
}
}
public static String a(Context context, String str, HashMap<String, String> hashMap) throws IOException {
return a(context, str, hashMap, true, 16000);
}
public static String a(Context context, String str, HashMap<String, String> hashMap, boolean z, int i) throws IOException {
return new String(a(context, str, hashMap, z, i, a.EnumC0047a.HashMap), "UTF-8");
}
public static String a(Context context, String str, ArrayList<Pair<String, String>> arrayList, int i) throws IOException {
return new String(a(context, str, arrayList, true, 16000, a.EnumC0047a.ArrayList), "UTF-8");
}
public static byte[] a(Context context, String str, Object obj, boolean z, int i, a.EnumC0047a enumC0047a) throws IOException {
HttpURLConnection httpURLConnection;
URL url = new URL(str);
new StringBuilder("performURLCall ").append(str);
InputStream inputStream = null;
try {
httpURLConnection = (HttpURLConnection) url.openConnection();
try {
httpURLConnection.setReadTimeout(i);
httpURLConnection.setConnectTimeout(i);
httpURLConnection.setRequestProperty("Accept-Encoding", "gzip");
httpURLConnection.setRequestProperty("User-Agent", q.ad().j(context));
if (obj != null) {
httpURLConnection.setDoOutput(true);
httpURLConnection.setRequestMethod("POST");
if (enumC0047a == a.EnumC0047a.JSONObject || enumC0047a == a.EnumC0047a.JSONArray) {
httpURLConnection.setRequestProperty("Content-Type", "application/json");
new StringBuilder("report params ").append(obj.toString());
}
OutputStream outputStream = httpURLConnection.getOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
if (enumC0047a == a.EnumC0047a.JSONArray) {
bufferedWriter.write(((JSONArray) obj).toString());
} else if (enumC0047a == a.EnumC0047a.JSONObject) {
bufferedWriter.write(((JSONObject) obj).toString());
} else if (enumC0047a == a.EnumC0047a.HashMap) {
ArrayList arrayList = new ArrayList();
for (Map.Entry entry : ((HashMap) obj).entrySet()) {
arrayList.add(new Pair((String) entry.getKey(), (String) entry.getValue()));
}
bufferedWriter.write(a(arrayList, z));
} else if (enumC0047a == a.EnumC0047a.ArrayList) {
bufferedWriter.write(a((ArrayList) obj, z));
}
bufferedWriter.flush();
bufferedWriter.close();
outputStream.close();
}
int responseCode = httpURLConnection.getResponseCode();
if (responseCode == 200) {
InputStream inputStream2 = httpURLConnection.getInputStream();
byte[] b = b(a(inputStream2));
if (inputStream2 != null) {
inputStream2.close();
}
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return b;
} else if (responseCode == 301 || responseCode == 302 || responseCode == 303) {
byte[] a = a(context, httpURLConnection.getHeaderField(LogConstants.EVENT_LOCATION), obj, z, i, enumC0047a);
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return a;
} else {
InputStream errorStream = httpURLConnection.getErrorStream();
throw new HttpRetryException(errorStream != null ? new String(b(errorStream), "UTF-8") : "", responseCode);
}
} catch (Throwable th) {
th = th;
if (0 != 0) {
inputStream.close();
}
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
throw th;
}
} catch (Throwable th2) {
th = th2;
httpURLConnection = null;
}
}
public static InputStream a(InputStream inputStream) throws IOException {
PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream, 2);
byte[] bArr = new byte[2];
try {
pushbackInputStream.unread(bArr, 0, pushbackInputStream.read(bArr));
return (bArr[0] == 31 && bArr[1] == -117) ? new GZIPInputStream(pushbackInputStream) : pushbackInputStream;
} catch (Throwable unused) {
return inputStream;
}
}
private static byte[] b(InputStream inputStream) throws IOException {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] bArr = new byte[1024];
while (true) {
int read = inputStream.read(bArr);
if (read != -1) {
byteArrayOutputStream.write(bArr, 0, read);
} else {
inputStream.close();
return byteArrayOutputStream.toByteArray();
}
}
}
public static Bitmap p(String str) {
HttpURLConnection httpURLConnection;
try {
URL url = new URL(str);
new StringBuilder("performURLCall ").append(str);
httpURLConnection = (HttpURLConnection) url.openConnection();
try {
httpURLConnection.setDoInput(true);
httpURLConnection.connect();
InputStream inputStream = httpURLConnection.getInputStream();
Bitmap decodeStream = BitmapFactory.decodeStream(inputStream);
inputStream.close();
if (decodeStream == null) {
return null;
}
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return decodeStream;
} catch (Throwable th) {
th = th;
try {
com.appnext.base.a.a("AppnextHelperClass$getBitmapFromURL", th);
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return null;
} finally {
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
}
}
} catch (Throwable th2) {
th = th2;
httpURLConnection = null;
}
}
private static String a(List<Pair<String, String>> list, boolean z) {
StringBuilder sb = new StringBuilder();
boolean z2 = true;
for (Pair<String, String> pair : list) {
try {
if (pair.first != null && pair.second != null) {
StringBuilder sb2 = new StringBuilder();
if (z2) {
z2 = false;
} else {
sb2.append("&");
}
if (z) {
sb2.append(URLEncoder.encode(URLDecoder.decode((String) pair.first, "UTF-8"), "UTF-8"));
sb2.append("=");
sb2.append(URLEncoder.encode(URLDecoder.decode((String) pair.second, "UTF-8"), "UTF-8"));
} else {
sb2.append(URLEncoder.encode((String) pair.first, "UTF-8"));
sb2.append("=");
sb2.append(URLEncoder.encode((String) pair.second, "UTF-8"));
}
StringBuilder sb3 = new StringBuilder("params: key: ");
sb3.append((String) pair.first);
sb3.append(" value: ");
sb3.append((String) pair.second);
sb.append((CharSequence) sb2);
}
} catch (Throwable th) {
com.appnext.base.a.a("AppnextHelperClass$getPostDataString", th);
}
}
new StringBuilder("raw params: ").append(sb.toString());
return sb.toString();
}
public static int a(Context context, float f) {
return (int) (f * (context.getResources().getDisplayMetrics().densityDpi / 160.0f));
}
public static void a(final Context context, final String str, final String str2, final String str3, final String str4, final String str5, final String str6, final String str7, final String str8, final String str9) {
try {
if (TextUtils.isEmpty(str6)) {
return;
}
if (str6.equals("video_started") || str6.equals("video_ended")) {
n.aa().a(new Runnable() {
@Override
public final void run() {
String str10;
String str11 = "";
try {
str10 = URLEncoder.encode(str5.replace(" ", "_"), "UTF-8");
} catch (Throwable unused) {
str10 = "";
}
try {
str11 = URLEncoder.encode(str6.replace(" ", "_"), "UTF-8");
} catch (Throwable unused2) {
}
Object[] objArr = new Object[10];
objArr[0] = str;
objArr[1] = str2;
objArr[2] = "100";
objArr[3] = str3;
objArr[4] = str10;
objArr[5] = str4;
objArr[6] = str11;
objArr[7] = str7;
objArr[8] = TextUtils.isEmpty(str8) ? "0" : str8;
objArr[9] = TextUtils.isEmpty(str9) ? "0" : str9;
String format = String.format("https://admin.appnext.com/tp12.aspx?tid=%s&vid=%s&osid=%s&auid=%s&session_id=%s&pid=%s&ref=%s&ads_type=%s&bid=%s&cid=%s", objArr);
try {
new StringBuilder("report: ").append(format);
g.a(context, format, null);
} catch (Throwable th) {
new StringBuilder("report error: ").append(th.getMessage());
}
}
});
}
} catch (Throwable th) {
com.appnext.base.a.a("AppnextHelperClass$report", th);
}
}
public static void a(final Ad ad, final AppnextAd appnextAd, final String str, final String str2, final SettingsManager settingsManager) {
n.aa().a(new Runnable() {
@Override
public final void run() {
try {
if (AppnextAd.this != null && Boolean.parseBoolean(settingsManager.t("stp_flag"))) {
ArrayList arrayList = new ArrayList();
StringBuilder sb = new StringBuilder();
sb.append(System.currentTimeMillis());
arrayList.add(new Pair("client_date", sb.toString()));
arrayList.add(new Pair("did", g.b(ad.getContext(), true)));
arrayList.add(new Pair("session_id", AppnextAd.this.getSession()));
arrayList.add(new Pair("tid", ad.getTID()));
arrayList.add(new Pair("vid", ad.getVID()));
arrayList.add(new Pair("auid", ad.getAUID()));
arrayList.add(new Pair("osid", "100"));
arrayList.add(new Pair("tem_id", str2));
arrayList.add(new Pair("pid", ad.getPlacementID()));
arrayList.add(new Pair("banner_id", AppnextAd.this.getBannerID()));
arrayList.add(new Pair("cm_id", AppnextAd.this.getCampaignID()));
arrayList.add(new Pair("event_name", str));
arrayList.add(new Pair("package_id", ad.getContext().getPackageName()));
g.a(ad.context, "https://global.appnext.com/stp.aspx", arrayList, 16000);
}
} catch (Throwable th) {
com.appnext.base.a.a("AppnextHelperClass$tpReport", th);
}
}
});
}
public static boolean b(Context context, String str) {
try {
context.getPackageManager().getPackageInfo(str, 128);
return true;
} catch (Throwable unused) {
return false;
}
}
public static String e(String str, String str2) {
String[] split;
String cookie = android.webkit.CookieManager.getInstance().getCookie(str);
if (cookie == null) {
return "";
}
String str3 = "";
for (String str4 : cookie.split(";")) {
if (str4.contains(str2)) {
String[] split2 = str4.split("=");
if (split2.length <= 1) {
return "";
}
str3 = split2[1];
}
}
return str3;
}
public static String c(Context context) {
if (context != null && context.checkPermission("android.permission.ACCESS_NETWORK_STATE", Process.myPid(), Process.myUid()) == 0) {
NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
if (activeNetworkInfo == null || !activeNetworkInfo.isConnected()) {
return "-";
}
if (activeNetworkInfo.getType() == 1) {
return "wifi";
}
if (activeNetworkInfo.getType() == 0) {
switch (activeNetworkInfo.getSubtype()) {
case 1:
case 2:
case 4:
case 7:
case 11:
return "2G";
case 3:
case 5:
case 6:
case 8:
case 9:
case 10:
case 12:
case 14:
case 15:
return "3G";
case 13:
return "4G";
default:
return LogConstants.KEY_UNKNOWN;
}
}
return LogConstants.KEY_UNKNOWN;
}
return LogConstants.KEY_UNKNOWN;
}
public static int q(String str) {
char c;
String lowerCase = str.toLowerCase(Locale.US);
int hashCode = lowerCase.hashCode();
if (hashCode == 1653) {
if (lowerCase.equals("2g")) {
c = 0;
}
c = 65535;
} else if (hashCode == 1684) {
if (lowerCase.equals("3g")) {
c = 1;
}
c = 65535;
} else if (hashCode != 1715) {
if (hashCode == 3649301 && lowerCase.equals("wifi")) {
c = 3;
}
c = 65535;
} else {
if (lowerCase.equals("4g")) {
c = 2;
}
c = 65535;
}
if (c != 0) {
if (c != 1) {
if (c != 2) {
return c != 3 ? -1 : 3;
}
return 2;
}
return 1;
}
return 0;
}
public static String a(Throwable th) {
StringWriter stringWriter = new StringWriter();
th.printStackTrace(new PrintWriter(stringWriter));
String obj = stringWriter.toString();
return obj.length() > 512 ? obj.substring(0, 512) : obj;
}
public static boolean c(Context context, String str) {
return (context == null || TextUtils.isEmpty(str) || context.checkPermission(str, Process.myPid(), Process.myUid()) != 0) ? false : true;
}
public static String d(Context context) {
if (TextUtils.isEmpty(cW)) {
synchronized ("2.6.6.473") {
if (TextUtils.isEmpty(cW)) {
cW = e(context);
}
}
}
return cW;
}
private static String r(String str) {
try {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
messageDigest.reset();
messageDigest.update(str.getBytes());
byte[] digest = messageDigest.digest();
int length = digest.length;
StringBuilder sb = new StringBuilder(length << 1);
for (int i = 0; i < length; i++) {
sb.append(Character.forDigit((digest[i] & 240) >> 4, 16));
sb.append(Character.forDigit(digest[i] & 15, 16));
}
return sb.toString();
} catch (NoSuchAlgorithmException e) {
com.appnext.base.a.a("AppnextHelperClass$md5", e);
return c(32);
}
}
private static String c(int i) {
char[] charArray = "0123456789abcdef".toCharArray();
Random random = new Random();
StringBuilder sb = new StringBuilder();
for (int i2 = 0; i2 < 32; i2++) {
sb.append(charArray[random.nextInt(charArray.length)]);
}
return sb.toString();
}
public static String b(String str) {
String substring = str.substring(str.lastIndexOf("/") + 1);
if (substring.contains("?")) {
substring = substring.substring(0, substring.indexOf("?"));
}
try {
String queryParameter = Uri.parse(str).getQueryParameter("rnd");
if (queryParameter == null || queryParameter.equals("")) {
return substring;
}
return substring.substring(0, substring.lastIndexOf(46)) + "_" + queryParameter + substring.substring(substring.lastIndexOf(46));
} catch (Throwable th) {
com.appnext.base.a.a("AppnextHelperClass$extractFileNameFromPath", th);
return substring;
}
}
public static String e(AppnextAd appnextAd) {
String str;
StringBuilder sb = new StringBuilder("https://www.appnext.com/privacy_policy/index.html?z=");
sb.append(new Random().nextInt(10));
sb.append(appnextAd.getZoneID());
sb.append(new Random().nextInt(10));
if (appnextAd.isGdpr()) {
str = "&edda=1&geo=" + appnextAd.getCountry();
} else {
str = "";
}
sb.append(str);
return sb.toString();
}
public static boolean f(Context context) {
try {
if (context.checkPermission("android.permission.ACCESS_NETWORK_STATE", Process.myPid(), Process.myUid()) != 0) {
a(context, "http://www.appnext.com/myid.html", null);
return true;
}
NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
if (activeNetworkInfo == null || !activeNetworkInfo.isConnected()) {
throw new IOException();
}
return true;
} catch (Throwable th) {
com.appnext.base.a.a("AppnextHelperClass$checkConnection", th);
return false;
}
}
public static String W() {
String[] split = "2.6.6.473".split("\\.");
if (split.length < 4) {
return "2.6.6.473";
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 3; i++) {
sb.append(split[i]);
if (i < 2) {
sb.append(".");
}
}
return sb.toString();
}
public static void a(File file) {
if (file.isDirectory()) {
for (File file2 : file.listFiles()) {
a(file2);
}
}
file.delete();
}
public static String f(String str, String str2) {
try {
String[] split = str.split("&");
HashMap hashMap = new HashMap();
for (String str3 : split) {
String[] split2 = str3.split("=");
String str4 = split2[0];
String str5 = "";
if (split2.length == 2) {
str5 = split2[1];
}
hashMap.put(str4, str5);
}
return (String) hashMap.get(str2);
} catch (Throwable th) {
com.appnext.base.a.a("AppnextHelperClass$getQueryMap", th);
return null;
}
}
public static boolean g(Context context) {
try {
NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
if (activeNetworkInfo != null) {
if (activeNetworkInfo.isConnected()) {
return true;
}
}
} catch (Exception unused) {
}
return false;
}
public static String e(Context context) {
String b = b(context, true);
if (TextUtils.isEmpty(b)) {
return c(32);
}
return r(b + "_" + (System.currentTimeMillis() / 1000));
}
}