- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
312 lines
9.8 KiB
Java
312 lines
9.8 KiB
Java
package com.mbridge.msdk.c;
|
|
|
|
import android.content.Context;
|
|
import android.text.TextUtils;
|
|
import com.ironsource.v8;
|
|
import com.mbridge.msdk.MBridgeConstans;
|
|
import com.mbridge.msdk.foundation.download.core.DownloadCommon;
|
|
import com.mbridge.msdk.foundation.tools.FastKV;
|
|
import com.mbridge.msdk.foundation.tools.af;
|
|
import com.mbridge.msdk.foundation.tools.an;
|
|
import com.mbridge.msdk.foundation.tools.v;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.Map;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public class h {
|
|
public static final String a = "h";
|
|
private static volatile h b;
|
|
private static volatile g c;
|
|
private static HashMap<String, k> d = new HashMap<>();
|
|
|
|
private h() {
|
|
}
|
|
|
|
public static void a(Context context, String str) {
|
|
FastKV fastKV;
|
|
com.mbridge.msdk.foundation.controller.d.a();
|
|
Map<String, Object> map = null;
|
|
try {
|
|
fastKV = new FastKV.Builder(com.mbridge.msdk.foundation.same.b.e.a(com.mbridge.msdk.foundation.same.b.c.MBRIDGE_700_CONFIG), "mbridge").build();
|
|
} catch (Exception unused) {
|
|
fastKV = null;
|
|
}
|
|
if (fastKV != null) {
|
|
try {
|
|
map = fastKV.getAll();
|
|
} catch (Exception unused2) {
|
|
}
|
|
if (map != null) {
|
|
try {
|
|
for (String str2 : map.keySet()) {
|
|
if (str2.startsWith(str + "_")) {
|
|
d.put(str2, k.g((String) map.get(str2)));
|
|
}
|
|
}
|
|
return;
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
return;
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
try {
|
|
Map<String, ?> all = context.getSharedPreferences("mbridge", 0).getAll();
|
|
for (String str3 : all.keySet()) {
|
|
if (str3.startsWith(str + "_")) {
|
|
d.put(str3, k.g((String) all.get(str3)));
|
|
}
|
|
}
|
|
} catch (Exception e2) {
|
|
e2.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public static h a() {
|
|
if (b == null) {
|
|
synchronized (h.class) {
|
|
try {
|
|
if (b == null) {
|
|
b = new h();
|
|
}
|
|
} finally {
|
|
}
|
|
}
|
|
}
|
|
return b;
|
|
}
|
|
|
|
public final g a(String str) {
|
|
try {
|
|
if (!TextUtils.isEmpty(str)) {
|
|
g b2 = b(str);
|
|
return b2 == null ? i.a() : b2;
|
|
}
|
|
return i.a();
|
|
} catch (Exception unused) {
|
|
return i.a();
|
|
}
|
|
}
|
|
|
|
public final g b(String str) {
|
|
if (c == null) {
|
|
try {
|
|
String a2 = com.mbridge.msdk.foundation.a.a.a.a().a(str);
|
|
if (!TextUtils.isEmpty(a2)) {
|
|
JSONObject jSONObject = new JSONObject(a2);
|
|
if (jSONObject.has(DownloadCommon.DOWNLOAD_REPORT_FIND_FILE_RESULT_VALUE_B)) {
|
|
jSONObject.remove(DownloadCommon.DOWNLOAD_REPORT_FIND_FILE_RESULT_VALUE_B);
|
|
}
|
|
if (jSONObject.has("c")) {
|
|
jSONObject.remove("c");
|
|
}
|
|
c = g.e(jSONObject.toString());
|
|
if (c != null) {
|
|
c.aL();
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
return c;
|
|
}
|
|
|
|
public final String c(String str) {
|
|
return com.mbridge.msdk.foundation.a.a.a.a().a("ivreward_" + str);
|
|
}
|
|
|
|
public final k b(String str, String str2) {
|
|
return i(str, str2);
|
|
}
|
|
|
|
private k i(String str, String str2) {
|
|
if (TextUtils.isEmpty(str)) {
|
|
str = com.mbridge.msdk.foundation.controller.c.m().k();
|
|
}
|
|
String str3 = str + "_" + str2;
|
|
if (d.containsKey(str3)) {
|
|
return d.get(str3);
|
|
}
|
|
k kVar = null;
|
|
try {
|
|
kVar = k.g(com.mbridge.msdk.foundation.a.a.a.a().a(str3));
|
|
d.put(str3, kVar);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
return kVar;
|
|
}
|
|
|
|
public final k c(String str, String str2) {
|
|
k d2 = d(str, str2);
|
|
return d2 == null ? k.y() : d2;
|
|
}
|
|
|
|
public final k d(String str, String str2) {
|
|
k i = i(str, str2);
|
|
if (i != null && i.v() == 0) {
|
|
i.a(1);
|
|
}
|
|
return i;
|
|
}
|
|
|
|
public final boolean e(String str, String str2) {
|
|
g b2 = b(str2);
|
|
if (d(str2) && a(str2, 1, str)) {
|
|
new j().b(com.mbridge.msdk.foundation.controller.c.m().c(), str2, com.mbridge.msdk.foundation.controller.c.m().b());
|
|
}
|
|
k d2 = d(str2, str);
|
|
if (b2 != null && d2 != null) {
|
|
long at = b2.at() * 1000;
|
|
long currentTimeMillis = System.currentTimeMillis();
|
|
long i = d2.i() + at;
|
|
if (i > currentTimeMillis) {
|
|
af.c(a, "unit setting nexttime is not ready [settingNextRequestTime= " + i + " currentTime = " + currentTimeMillis + v8.i.e);
|
|
return false;
|
|
}
|
|
}
|
|
af.c(a, "unit setting timeout or not exists");
|
|
return true;
|
|
}
|
|
|
|
public final boolean d(String str) {
|
|
g b2 = b(str);
|
|
if (b2 != null) {
|
|
long H = b2.H() * 1000;
|
|
long currentTimeMillis = System.currentTimeMillis();
|
|
long D = b2.D() + H;
|
|
if (D > currentTimeMillis) {
|
|
af.c(a, "app setting nexttime is not ready [settingNextRequestTime= " + D + " currentTime = " + currentTimeMillis + v8.i.e);
|
|
return false;
|
|
}
|
|
}
|
|
af.c(a, "app setting timeout or not exists");
|
|
return true;
|
|
}
|
|
|
|
public final boolean a(String str, int i, String str2) {
|
|
try {
|
|
Context c2 = com.mbridge.msdk.foundation.controller.c.m().c();
|
|
String str3 = str + "_" + i + "_" + str2;
|
|
long currentTimeMillis = System.currentTimeMillis();
|
|
long j = 0;
|
|
long longValue = ((Long) an.a(c2, str3, 0L)).longValue();
|
|
g b2 = b(str);
|
|
if (b2 == null) {
|
|
a();
|
|
b2 = i.a();
|
|
} else {
|
|
j = longValue;
|
|
}
|
|
if (j + (b2.ao() * 1000) > currentTimeMillis) {
|
|
return false;
|
|
}
|
|
an.b(c2, str3, Long.valueOf(currentTimeMillis));
|
|
return true;
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public final JSONObject a(JSONObject jSONObject, JSONObject jSONObject2) {
|
|
if (jSONObject == null || jSONObject.length() == 0) {
|
|
return jSONObject2;
|
|
}
|
|
if (jSONObject2 != null && jSONObject2.length() != 0) {
|
|
Iterator<String> keys = jSONObject2.keys();
|
|
while (keys.hasNext()) {
|
|
String next = keys.next();
|
|
try {
|
|
if ("unitSetting".equals(next) && jSONObject.has("unitSetting")) {
|
|
JSONArray jSONArray = jSONObject.getJSONArray("unitSetting");
|
|
jSONArray.put(0, a((JSONObject) jSONArray.get(0), (JSONObject) jSONObject2.getJSONArray("unitSetting").get(0)));
|
|
jSONObject.put(next, jSONArray);
|
|
} else {
|
|
jSONObject.put(next, jSONObject2.opt(next));
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
return jSONObject;
|
|
}
|
|
|
|
public final void e(String str) {
|
|
com.mbridge.msdk.foundation.a.a.a.a().c("ivreward_" + str);
|
|
}
|
|
|
|
public final void f(String str, String str2) {
|
|
com.mbridge.msdk.foundation.a.a.a.a().a("ivreward_" + str, str2);
|
|
}
|
|
|
|
public final void f(String str) {
|
|
try {
|
|
String g = g(str);
|
|
if (TextUtils.isEmpty(g)) {
|
|
return;
|
|
}
|
|
JSONObject jSONObject = new JSONObject(g);
|
|
jSONObject.put("current_time", System.currentTimeMillis());
|
|
g(str, jSONObject.toString());
|
|
} catch (Throwable th) {
|
|
af.b(a, th.getMessage());
|
|
}
|
|
}
|
|
|
|
public final String g(String str) {
|
|
if (str == null) {
|
|
return "";
|
|
}
|
|
try {
|
|
String a2 = com.mbridge.msdk.foundation.a.a.a.a().a(str);
|
|
return a2 == null ? "" : a2;
|
|
} catch (Exception e) {
|
|
if (MBridgeConstans.DEBUG) {
|
|
e.printStackTrace();
|
|
}
|
|
return "";
|
|
}
|
|
}
|
|
|
|
public final void g(String str, String str2) {
|
|
com.mbridge.msdk.foundation.a.a.a.a().a(str, str2);
|
|
c = g.e(str2);
|
|
if (c != null) {
|
|
c.aL();
|
|
}
|
|
v.a().a(c.b());
|
|
}
|
|
|
|
public final void h(String str, String str2) {
|
|
try {
|
|
String a2 = com.mbridge.msdk.foundation.a.a.a.a().a(str + "_" + str2);
|
|
if (TextUtils.isEmpty(a2)) {
|
|
return;
|
|
}
|
|
JSONObject jSONObject = new JSONObject(a2);
|
|
jSONObject.put("current_time", System.currentTimeMillis());
|
|
a(str, str2, jSONObject.toString());
|
|
} catch (Throwable th) {
|
|
af.b(a, th.getMessage());
|
|
}
|
|
}
|
|
|
|
public final void a(String str, String str2, String str3) {
|
|
String str4 = str + "_" + str2;
|
|
com.mbridge.msdk.foundation.a.a.a.a().a(str4, str3);
|
|
d.put(str4, k.g(str3));
|
|
}
|
|
|
|
public final k a(String str, String str2) {
|
|
k i = i(str, str2);
|
|
return i == null ? k.y() : i;
|
|
}
|
|
}
|