c.java 源代码
package com.mbridge.msdk.b;
import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import com.anythink.expressad.foundation.g.u;
import com.mbridge.msdk.foundation.tools.SameMD5;
import com.mbridge.msdk.foundation.tools.q;
import org.json.JSONArray;
import org.json.JSONObject;
public class c {
private static final String f16388a = "c";
public void b(final Context context, final String str, final String str2) {
if (!com.mbridge.msdk.foundation.same.net.g.d.c().a()) {
try {
if (!com.mbridge.msdk.foundation.same.net.g.d.c().f17040n) {
com.mbridge.msdk.foundation.same.net.g.d.c().f17040n = true;
Long a7 = com.mbridge.msdk.foundation.a.a.a.a().a("mkey_spare_host_ts");
long currentTimeMillis = System.currentTimeMillis();
long longValue = a7.longValue() + 86400000;
if (currentTimeMillis >= longValue) {
String b6 = com.mbridge.msdk.foundation.a.a.a.a().b("mkey_spare_host");
if (!TextUtils.isEmpty(b6)) {
for (String str3 : b6.split("\n")) {
if (!TextUtils.isEmpty(str3.trim()) && !com.mbridge.msdk.foundation.same.net.g.d.c().f17041o.contains(str3.trim())) {
com.mbridge.msdk.foundation.same.net.g.d.c().f17041o.add(str3.trim());
}
}
b(context, str, str2);
return;
}
}
new com.mbridge.msdk.foundation.same.net.h.b(context.getApplicationContext()).a(0, com.mbridge.msdk.foundation.same.net.g.d.c().f17038l, null, new com.mbridge.msdk.foundation.same.net.b.a() {
@Override
public final void a(String str4) {
q.a(c.f16388a, "fetch CNDSettingHost success, content = " + str4);
if (!TextUtils.isEmpty(str4)) {
com.mbridge.msdk.foundation.a.a.a.a().a("mkey_spare_host_ts", System.currentTimeMillis());
com.mbridge.msdk.foundation.a.a.a.a().a("mkey_spare_host", str4);
for (String str5 : str4.split("\n")) {
if (!TextUtils.isEmpty(str5.trim()) && !com.mbridge.msdk.foundation.same.net.g.d.c().f17041o.contains(str5.trim())) {
com.mbridge.msdk.foundation.same.net.g.d.c().f17041o.add(str5.trim());
}
}
c.this.b(context, str, str2);
}
}
@Override
public final void b(String str4) {
q.a(c.f16388a, "fetch CNDSettingHost failed, errorCode = " + str4);
}
});
return;
}
return;
} catch (Throwable th) {
q.d(f16388a, th.getMessage());
return;
}
}
a(context, str, str2);
}
public final void a(final Context context, final String str, final String str2) {
if (context == null) {
return;
}
com.mbridge.msdk.b.a.b bVar = new com.mbridge.msdk.b.a.b(context);
com.mbridge.msdk.foundation.same.net.h.d dVar = new com.mbridge.msdk.foundation.same.net.h.d();
dVar.a("app_id", str);
dVar.a(com.anythink.core.common.g.c.T, SameMD5.getMD5(str + str2));
bVar.a(1, com.mbridge.msdk.foundation.same.net.g.d.c().f17035i, dVar, new com.mbridge.msdk.foundation.same.net.h.c() {
@Override
public final void a(String str3) {
com.mbridge.msdk.foundation.same.report.c cVar = new com.mbridge.msdk.foundation.same.report.c(context);
cVar.a();
cVar.a(str3, com.mbridge.msdk.foundation.same.net.g.d.c().f17029c);
com.mbridge.msdk.foundation.same.net.g.d.c().f17039m++;
c.this.b(context, str, str2);
}
@Override
public final void a(JSONObject jSONObject) {
if (jSONObject != null) {
try {
SharedPreferences.Editor edit = com.mbridge.msdk.foundation.controller.a.e().g().getApplicationContext().getSharedPreferences(u.f4101b, 0).edit();
edit.clear();
edit.commit();
jSONObject.put("current_time", System.currentTimeMillis());
jSONObject.put(com.anythink.expressad.b.a.b.H, com.mbridge.msdk.foundation.same.net.g.d.c().f17029c);
b.a().b(str, jSONObject.toString());
com.mbridge.msdk.foundation.same.net.g.d.c().d();
if (!TextUtils.isEmpty(jSONObject.optString(com.anythink.expressad.b.a.b.bg))) {
com.mbridge.msdk.b.b.a.a().a(context, jSONObject.optString(com.anythink.expressad.b.a.b.bg));
}
if (!TextUtils.isEmpty(jSONObject.optString(com.anythink.expressad.b.a.b.bo))) {
com.mbridge.msdk.b.b.b.a().a(context, jSONObject.optString(com.anythink.expressad.b.a.b.bo));
}
} catch (Exception e6) {
e6.printStackTrace();
return;
}
}
new com.mbridge.msdk.foundation.same.report.c(context).a();
}
});
}
public final void a(Context context, final String str, String str2, final String str3) {
if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) {
str = com.mbridge.msdk.foundation.controller.a.e().h();
str2 = com.mbridge.msdk.foundation.controller.a.e().i();
}
if (b.a().a(str3, str) && b.a().a(str, 2, str3)) {
com.mbridge.msdk.b.a.b bVar = new com.mbridge.msdk.b.a.b(context);
com.mbridge.msdk.foundation.same.net.h.d dVar = new com.mbridge.msdk.foundation.same.net.h.d();
dVar.a("unit_ids", "[" + str3 + "]");
dVar.a("app_id", str);
dVar.a(com.anythink.core.common.g.c.T, SameMD5.getMD5(str + str2));
bVar.a(1, com.mbridge.msdk.foundation.same.net.g.d.c().f17035i, dVar, new com.mbridge.msdk.foundation.same.net.h.c() {
@Override
public final void a(String str4) {
}
@Override
public final void a(JSONObject jSONObject) {
if (jSONObject != null) {
try {
JSONArray optJSONArray = jSONObject.optJSONArray(com.anythink.expressad.videocommon.e.b.f5525d);
if (optJSONArray == null || optJSONArray.length() <= 0) {
return;
}
JSONObject optJSONObject = optJSONArray.optJSONObject(0);
optJSONObject.put("current_time", System.currentTimeMillis());
b.a().a(str, str3, optJSONObject.toString());
} catch (Exception e6) {
e6.printStackTrace();
}
}
}
});
}
}
}