VegeFruits v7.1版本的 MD5 值为:2ff167dfba698c783e879938fe00b9ce
以下内容为反编译后的 ac.java 源代码,内容仅作参考
package com.appodeal.ads.networks;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.support.annotation.VisibleForTesting;
import android.util.DisplayMetrics;
import com.amazon.device.ads.AdWebViewClient;
import com.amazon.device.ads.WebRequest;
import com.appodeal.ads.Appodeal;
import com.appodeal.ads.UserSettings;
import com.appodeal.ads.az;
import com.facebook.ads.AdError;
import com.mopub.common.GpsHelper;
import com.tapjoy.TJAdUnitConstants;
import com.tapjoy.TapjoyConstants;
import com.vk.sdk.api.VKApiConst;
import java.io.DataOutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.Locale;
import org.json.JSONArray;
import org.json.JSONObject;
public class ac implements Runnable {
private final a b;
private final int c;
private final int d;
private final int e;
private final String f;
private final String g;
private final Handler h;
@VisibleForTesting
String a = "http://bid.adx.yumimobi.com/adx";
private final int i = 0;
private final int j = 1;
public interface a {
void a(int i, int i2);
void a(JSONObject jSONObject, int i, int i2, int i3);
}
public ac(Activity activity, a aVar, int i, int i2, String str, int i3, String str2, int i4, int i5, float f, String str3, String str4, int i6) {
this.b = aVar;
this.c = i;
this.d = i2;
this.e = i6;
UserSettings u = az.u(activity);
this.f = u.c();
this.g = a(str, i3, str2, i4, i5, f, activity, str3, str4, u).toString();
this.h = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(Message message) {
if (ac.this.b != null) {
switch (message.what) {
case 0:
ac.this.b.a(ac.this.c, ac.this.d);
return;
case 1:
JSONObject jSONObject = (JSONObject) message.obj;
if (jSONObject == null) {
ac.this.b.a(ac.this.c, ac.this.d);
return;
} else {
ac.this.b.a(jSONObject, ac.this.c, ac.this.d, ac.this.e);
return;
}
default:
return;
}
}
}
};
}
private String a(Context context) {
return az.b(context).a;
}
private JSONObject a(int i, String str, int i2, int i3, float f) {
JSONObject jSONObject = new JSONObject();
jSONObject.put("type", i);
jSONObject.put(VKApiConst.PLACE_ID, str);
jSONObject.put("pos", i == 1 ? 7 : 0);
jSONObject.put("w", i2);
jSONObject.put("h", i3);
jSONObject.put("floor_price", f);
JSONArray jSONArray = new JSONArray();
switch (i) {
case 0:
case 1:
jSONArray.put(1);
jSONArray.put(2);
break;
case 3:
jSONArray.put(6);
break;
}
jSONObject.put("inventory_types", jSONArray);
if (i == 3) {
jSONObject.put(TapjoyConstants.TJC_PLUGIN_NATIVE, b());
}
return jSONObject;
}
private JSONObject a(Context context, UserSettings userSettings) {
JSONObject jSONObject = new JSONObject();
jSONObject.put("plmn", az.c(context));
jSONObject.put("adt", 1);
if (!com.appodeal.ads.f.h) {
jSONObject.put("model", Build.MODEL);
jSONObject.put("make", Build.MANUFACTURER);
jSONObject.put(TapjoyConstants.TJC_CONNECTION_TYPE, a(context));
}
jSONObject.put("carrier", 4);
jSONObject.put("orientation", b(context));
String c = c(context);
jSONObject.put(TapjoyConstants.TJC_ANDROID_ID, c);
jSONObject.put("android_adid", c);
jSONObject.put("local", Locale.getDefault().getLanguage());
jSONObject.put("os_type", TapjoyConstants.TJC_DEVICE_PLATFORM_TYPE);
jSONObject.put(TapjoyConstants.TJC_DEVICE_OS_VERSION_NAME, Build.VERSION.RELEASE);
jSONObject.put("screen", d(context));
if (!com.appodeal.ads.f.h) {
jSONObject.put(AdWebViewClient.GEO, b(context, userSettings));
}
return jSONObject;
}
private JSONObject a(Context context, String str, String str2) {
JSONObject jSONObject = new JSONObject();
jSONObject.put("app_key", str);
jSONObject.put("id", str2);
jSONObject.put("name", com.appodeal.ads.f.a);
jSONObject.put(TJAdUnitConstants.String.BUNDLE, context.getPackageName());
jSONObject.put("ver", az.v(context));
jSONObject.put("cat", com.appodeal.ads.f.g);
return jSONObject;
}
private JSONObject a(UserSettings userSettings) {
JSONObject jSONObject = new JSONObject();
jSONObject.put("gender", b(userSettings));
jSONObject.put("age", userSettings.getAge());
String b = userSettings.b();
if (b != null) {
jSONObject.put("keywords", new JSONArray().put(b));
}
return jSONObject;
}
private JSONObject a(String str, int i, String str2, int i2, int i3, float f, Context context, String str3, String str4, UserSettings userSettings) {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("ad", a(i, str2, i2, i3, f));
jSONObject.put("app", a(context, str3, str4));
jSONObject.put("device", a(context, userSettings));
jSONObject.put("user", a(userSettings));
jSONObject.put("ver", "1.0");
jSONObject.put("ssp_token", str);
jSONObject.put("is_tail", 0);
jSONObject.put("is_test", 0);
} catch (Exception e) {
Appodeal.a(e);
}
return jSONObject;
}
private int b(Context context) {
String q = az.q(context);
return (q == null || !q.equals("Landscape")) ? 1 : 3;
}
private Integer b(UserSettings userSettings) {
UserSettings.Gender gender = userSettings.getGender();
if (gender == null) {
return null;
}
switch (gender) {
case MALE:
return 1;
case FEMALE:
return 0;
default:
return null;
}
}
private JSONObject b() {
return new JSONObject("{\"native\":{ \"assets\":[ { \"id\":0, \"required\":1, \"title\":{ \"len\":40 } }, { \"id\":1, \"img\":{ \"h\":160, \"type\":1, \"w\":160 }, \"required\":1 }, { \"id\":2, \"img\":{ \"h\":1200, \"type\":1, \"w\":627 }, \"required\":1 }, { \"data\":{ \"len\":150, \"type\":2 }, \"id\":3, \"required\":1 }, { \"data\":{ \"type\":3 }, \"id\":4, \"required\":0 }, { \"data\":{ \"type\":12 }, \"id\":5, \"required\":1 } ], \"layout\":6 }}");
}
private JSONObject b(Context context, UserSettings userSettings) {
JSONObject jSONObject = new JSONObject();
Location e = az.e(context);
if (e != null) {
jSONObject.put("lat", e.getLatitude());
jSONObject.put("lon", e.getLongitude());
} else {
if (userSettings.g() != null) {
jSONObject.put("lat", userSettings.g());
}
if (userSettings.h() != null) {
jSONObject.put("lon", userSettings.h());
}
}
return jSONObject;
}
private String c(Context context) {
String string = context.getSharedPreferences("appodeal", 0).getString(GpsHelper.ADVERTISING_ID_KEY, null);
return string == null ? az.l(context) : string;
}
private JSONObject d(Context context) {
JSONObject jSONObject = new JSONObject();
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
jSONObject.put("w", displayMetrics.widthPixels);
jSONObject.put("h", displayMetrics.heightPixels);
jSONObject.put("dpi", displayMetrics.densityDpi);
return jSONObject;
}
public void a() {
com.appodeal.ads.utils.r.a.execute(this);
}
@Override
public void run() {
HttpURLConnection httpURLConnection;
String a2;
?? r1 = 0;
r1 = 0;
try {
try {
httpURLConnection = (HttpURLConnection) new URL(this.a).openConnection();
} catch (Throwable th) {
th = th;
}
} catch (Exception e) {
e = e;
}
try {
httpURLConnection.setConnectTimeout(20000);
httpURLConnection.setReadTimeout(20000);
httpURLConnection.setRequestProperty("User-Agent", System.getProperty("http.agent"));
httpURLConnection.setRequestProperty("Content-Type", WebRequest.CONTENT_TYPE_JSON);
if (this.f != null) {
httpURLConnection.setRequestProperty("X-Forwarded-For", this.f);
}
httpURLConnection.setConnectTimeout(AdError.SERVER_ERROR_CODE);
httpURLConnection.setReadTimeout(AdError.SERVER_ERROR_CODE);
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
new DataOutputStream(httpURLConnection.getOutputStream()).write(this.g.getBytes(Charset.forName("UTF-8")));
a2 = az.a(httpURLConnection.getInputStream());
} catch (Exception e2) {
r1 = httpURLConnection;
e = e2;
Appodeal.a(e);
this.h.sendEmptyMessage(0);
if (r1 != 0) {
r1.disconnect();
}
} catch (Throwable th2) {
r1 = httpURLConnection;
th = th2;
if (r1 != 0) {
r1.disconnect();
}
throw th;
}
if (a2 == null || a2.isEmpty() || a2.equals(" ")) {
Handler handler = this.h;
handler.sendEmptyMessage(0);
r1 = handler;
} else {
JSONObject jSONObject = new JSONObject(a2);
int i = jSONObject.getInt("result");
JSONObject optJSONObject = jSONObject.optJSONObject("ad");
if (optJSONObject == null) {
r1 = this.h;
r1.sendEmptyMessage(0);
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
}
int i2 = optJSONObject.getInt("action");
if (i == 0 && (i2 == 1 || i2 == 2)) {
Message obtainMessage = this.h.obtainMessage(1, optJSONObject);
this.h.sendMessage(obtainMessage);
r1 = obtainMessage;
} else {
Handler handler2 = this.h;
handler2.sendEmptyMessage(0);
r1 = handler2;
}
}
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
}
}