Cyber Surfer v5.2.5版本的 MD5 值为:db13c5fce988de393e52d2679f934b22
以下内容为反编译后的 SafeDK.java 源代码,内容仅作参考
package com.safedk.android;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import androidx.webkit.ProxyConfig;
import com.appsflyer.internal.referrer.Payload;
import com.mbridge.msdk.foundation.download.core.DownloadCommon;
import com.safedk.android.analytics.AppLovinBridge;
import com.safedk.android.analytics.StatsCollector;
import com.safedk.android.analytics.StatsReporter;
import com.safedk.android.analytics.brandsafety.BannerFinder;
import com.safedk.android.analytics.brandsafety.BrandSafetyUtils;
import com.safedk.android.analytics.brandsafety.InterstitialFinder;
import com.safedk.android.analytics.brandsafety.NativeFinder;
import com.safedk.android.analytics.brandsafety.b;
import com.safedk.android.analytics.brandsafety.creatives.CreativeInfoManager;
import com.safedk.android.analytics.brandsafety.g;
import com.safedk.android.analytics.brandsafety.i;
import com.safedk.android.analytics.brandsafety.k;
import com.safedk.android.analytics.brandsafety.q;
import com.safedk.android.analytics.reporters.CrashReporter;
import com.safedk.android.internal.DeviceData;
import com.safedk.android.internal.d;
import com.safedk.android.utils.Logger;
import com.safedk.android.utils.annotations.Api;
import com.safedk.android.utils.j;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import net.pubnative.lite.sdk.analytics.Reporting;
import org.json.JSONObject;
public class SafeDK {
public static final String f9158a = "com.safedk";
private static final String c = "SafeDKMain";
private static final String d = "SafeDK";
private static final String e = "https://config.safedk.com/";
private static final String f = "com.safedk.AppID";
private static final String g = "com.safedk.ConfigPrefix";
private static final String h = "com.safedk.APIPrefix";
private static final String i = "com.safedk.DebugMode";
private static final String j = "com.safedk.MaximumStatsSetSize";
private static final String k = "com.safedk.AggregationThreshold";
private static String n;
private static String o;
private static String p;
private static int q;
private static boolean r;
private static boolean t;
private static Context v;
private j B;
private boolean s;
private DeviceData z;
private static final List<String> l = Arrays.asList("com.android.vending", "com.amazon.venezia", "com.sec.android.app.samsungapps");
private static boolean m = false;
private static SafeDK u = null;
private static d w = new d();
private static AtomicBoolean x = new AtomicBoolean(false);
private static AtomicBoolean F = new AtomicBoolean(false);
private static AtomicBoolean G = new AtomicBoolean(false);
private static Boolean H = false;
private static Boolean I = false;
private static Boolean J = false;
private String y = null;
private final Map<BrandSafetyUtils.AdType, b> A = new HashMap();
private AtomicBoolean C = new AtomicBoolean(false);
private int D = 0;
private int E = 0;
i f9159b = null;
private SafeDK(Context context) {
Logger.d(c, "SafeDK ctor started");
v = context;
AppLovinBridge.init(context);
if (c()) {
Logger.d(c, "Before reading shared prefs");
this.z = new DeviceData(context, this.B);
}
}
public static boolean P() {
return a.f9160a.contains(DownloadCommon.DOWNLOAD_REPORT_RETRY_COUNT);
}
public static boolean Z() {
return H.booleanValue();
}
public static synchronized SafeDK a(Context context) {
SafeDK safeDK;
synchronized (SafeDK.class) {
Logger.d(c, "start started");
if (u == null) {
u = new SafeDK(context);
u.a(false);
if (w.x()) {
Logger.i("SafeDK", "SafeDK Device ID: " + u.y);
Logger.i("SafeDK", "SafeDK version: " + getVersion());
}
u.b(true);
} else {
Logger.d(c, "SafeDK already started");
}
safeDK = u;
}
return safeDK;
}
public static void a(Application application) {
if (getInstance().o() && Build.VERSION.SDK_INT >= 14) {
application.registerActivityLifecycleCallbacks(com.safedk.android.internal.b.getInstance());
}
}
private void a(ApplicationInfo applicationInfo) {
try {
try {
PackageInfo packageInfo = v.getPackageManager().getPackageInfo(v.getPackageName(), 0);
Logger.d(c, "package is: " + packageInfo.packageName + ", Installer Package Name is " + v.getPackageManager().getInstallerPackageName(packageInfo.packageName));
t = l.contains(v.getPackageManager().getInstallerPackageName(packageInfo.packageName));
r = (applicationInfo.flags & 2) != 0;
p = extractAppIdentifier(applicationInfo.metaData);
Uri.Builder appendQueryParameter = new Uri.Builder().appendPath("apps").appendPath("cfg").appendPath(p).appendPath(String.valueOf(packageInfo.versionCode)).appendQueryParameter(Payload.TYPE_STORE, String.valueOf(t));
if (t) {
appendQueryParameter = appendQueryParameter.appendQueryParameter(com.byfen.archiver.sdk.a.i, packageInfo.versionName);
}
String uri = appendQueryParameter.build().toString();
o = extractUrlPrefix(applicationInfo.metaData);
if (o == null || o.length() <= 0) {
Logger.d(c, "no apiURL Value in manifest");
} else {
Logger.d(c, "apiURL Value from manifest is " + o + ". Setting new edge urls");
AppLovinBridge.receiveEdgeUrls(o, o);
}
q = packageInfo.versionCode;
String string = applicationInfo.metaData.getString(g);
if (string == null) {
n = getDefaultConfig() + uri;
return;
}
if (!string.endsWith(File.separator)) {
string = string + File.separator;
}
if (uri.startsWith(File.separator)) {
uri = uri.substring(1);
}
n = string + uri;
Logger.d(c, "basePrefix != null, configUrl:" + n);
} catch (PackageManager.NameNotFoundException e2) {
Logger.d(c, "Bad URL; won't update toggles");
}
} catch (Throwable th) {
Logger.e(c, "Caught exception", th);
new CrashReporter().caughtException(th);
}
}
private void a(Bundle bundle) {
if (this.B != null) {
Logger.d(c, "Writing to shared preferences: " + bundle.toString());
this.B.a(bundle);
}
}
public static boolean a() {
return t;
}
public static void aa() {
H = true;
if (!b()) {
ag();
}
if (I.booleanValue()) {
return;
}
CreativeInfoManager.b();
I = true;
}
private synchronized void ab() {
Logger.d(c, Reporting.EventType.SDK_INIT);
if (!r()) {
for (b bVar : this.A.values()) {
bVar.a((String) null);
}
this.A.clear();
}
}
private void ac() {
try {
ApplicationInfo applicationInfo = v.getPackageManager().getApplicationInfo(v.getPackageName(), 128);
if (applicationInfo.metaData != null) {
a(applicationInfo);
b(applicationInfo);
c(applicationInfo);
d(applicationInfo);
} else {
Logger.e(c, "SafeDK meta data is missing from manifest file");
}
} catch (PackageManager.NameNotFoundException e2) {
Logger.d(c, "Couldn't get application's meta data");
}
}
private void ad() {
if (this.B != null) {
this.y = UUID.randomUUID().toString();
this.B.a(this.y);
}
}
private void ae() {
try {
Logger.d(c, "setIsFirstSession started");
if (G.get() || this.B == null) {
Logger.d(c, "setIsFirstSession already executed, value is " + this.s);
return;
}
String p2 = this.B.p();
Logger.d(c, "setIsFirstSession Current safedk version : 5.0.3 , stored version is " + p2);
if (p2 == null || !a.f9160a.equals(p2)) {
Logger.d(c, "setIsFirstSession setting is_first_session to true");
this.s = true;
}
this.B.c(a.f9160a);
G.set(true);
} catch (Throwable th) {
Logger.d(c, "setIsFirstSession Exception : " + th.getMessage(), th);
}
}
private synchronized void af() {
if (!this.A.containsKey(BrandSafetyUtils.AdType.INTERSTITIAL)) {
this.A.put(BrandSafetyUtils.AdType.INTERSTITIAL, new InterstitialFinder());
}
if (!this.A.containsKey(BrandSafetyUtils.AdType.BANNER) && p()) {
this.A.put(BrandSafetyUtils.AdType.BANNER, new BannerFinder(getInstance().W()));
}
if (!this.A.containsKey(BrandSafetyUtils.AdType.MREC) && p()) {
this.A.put(BrandSafetyUtils.AdType.MREC, new q(getInstance().W()));
}
if (!this.A.containsKey(BrandSafetyUtils.AdType.NATIVE)) {
this.A.put(BrandSafetyUtils.AdType.NATIVE, new NativeFinder(getInstance().W()));
}
}
private static void ag() {
if (x.get()) {
Logger.d(c, "Reporter thread already initialized, skipping");
return;
}
Logger.d(c, "Starting reporter thread");
StatsCollector.a(true);
int z = w.z();
int C = w.C();
StatsReporter.a();
StatsCollector.c().a(z, com.safedk.android.internal.b.getInstance().isInBackground(), C, StatsReporter.b());
StatsCollector.a(false);
StatsCollector.b(getInstance().r());
x.set(true);
Logger.d(c, "Reporter thread started");
}
private boolean ah() {
try {
Set<String> G2 = w.G();
if (!G2.contains(ProxyConfig.MATCH_ALL_SCHEMES)) {
if (!G2.contains(this.y)) {
return false;
}
}
return true;
} catch (Throwable th) {
Logger.e(c, "Caught exception", th);
new CrashReporter().caughtException(th);
return false;
}
}
private void b(ApplicationInfo applicationInfo) {
boolean z = false;
if (w.x() && (applicationInfo.metaData.getBoolean(i, false) || ah())) {
z = true;
}
Logger.setDebugMode(z);
}
private void b(boolean z) {
boolean r2 = r();
Logger.d(c, "notifyMonitorUserActivityUpdate shouldMonitorUser is " + r2);
CreativeInfoManager.a(r2);
com.safedk.android.internal.b.setActiveMode(r2);
i.a(r2);
if (z) {
ab();
}
}
public static synchronized boolean b() {
boolean z;
synchronized (SafeDK.class) {
z = x.get();
}
return z;
}
private void c(ApplicationInfo applicationInfo) {
w.a(applicationInfo.metaData.getInt(j, 5000));
}
private void d(ApplicationInfo applicationInfo) {
w.b(applicationInfo.metaData.getInt(k, d.c));
}
private static String extractAppIdentifier(Bundle bundle) {
return bundle.getString(f);
}
private static String extractUrlPrefix(Bundle bundle) {
return bundle.getString(h, "https://edge.safedk.com");
}
private static String getDefaultConfig() {
return e;
}
public static SafeDK getInstance() {
return u;
}
public static String getProguardMD5() {
return "";
}
public static String getSdkKey() {
return "PKpWwCI7SEHTR8p3heicRqC5gmsBqFZ4RPFeRcOhZ3_IK0i49A642RvpsV13V-X398hccGIHNhckiAuGeSBTkw";
}
public static String getVersion() {
return a.f9160a;
}
public static int k() {
return q;
}
public static boolean t() {
return w.B();
}
public q A() {
return (q) a(BrandSafetyUtils.AdType.MREC);
}
public NativeFinder B() {
return (NativeFinder) a(BrandSafetyUtils.AdType.NATIVE);
}
public int C() {
return this.E;
}
public int D() {
return this.D;
}
public int E() {
return w.d();
}
public int F() {
return w.e();
}
public float G() {
return w.f();
}
public float H() {
return w.g();
}
public boolean I() {
return w.h();
}
public int J() {
return w.i();
}
public long K() {
return w.j();
}
public int L() {
return w.k();
}
public int M() {
return w.l();
}
public int N() {
return w.m();
}
public JSONObject O() {
if (this.B == null) {
return null;
}
return this.B.j();
}
public long Q() {
return w.J();
}
public int R() {
return w.K();
}
public int S() {
return w.L();
}
public ArrayList<String> T() {
return w.M();
}
public float U() {
return w.n();
}
public float V() {
return w.o();
}
public int W() {
return w.p();
}
public int X() {
return w.q();
}
public int Y() {
return w.r();
}
public synchronized com.safedk.android.analytics.brandsafety.a a(BrandSafetyUtils.AdType adType) {
return this.A.get(adType);
}
public synchronized void a(Activity activity) {
Logger.d(c, "Starting interstitial finder in activity " + activity.getClass().getName());
InterstitialFinder interstitialFinder = (InterstitialFinder) a(BrandSafetyUtils.AdType.INTERSTITIAL);
if (interstitialFinder != null) {
interstitialFinder.c(activity);
}
}
public void a(Bundle bundle, boolean z) {
Logger.d(c, "Updating configuration");
boolean a2 = w.a(bundle, true);
if (a2) {
a(bundle);
}
a(a2, z);
}
public synchronized void a(String str) {
for (b bVar : this.A.values()) {
bVar.b(str);
}
}
public void a(boolean z) {
Logger.d(c, "Reading configuration from shared preferences");
try {
if (this.B != null) {
this.y = this.B.a();
if (this.y == null) {
ad();
}
Bundle e2 = this.B.e();
Logger.d(c, "configurationBundle loaded : " + e2.toString());
if (e2 == null || e2.isEmpty()) {
Logger.d(c, "Configuration bundle from storage is empty");
} else {
Logger.d(c, "Parsing configuration from shared preferences");
w.a(e2, false);
}
a(false, z);
}
} catch (Throwable th) {
Logger.e(c, "Caught exception", th);
new CrashReporter().caughtException(th);
}
}
public synchronized void a(boolean z, boolean z2) {
try {
if (u == null) {
Logger.d(c, "instance is null, existing");
} else {
u.b(false);
if (w.x()) {
ac();
if (ah()) {
Logger.setDebugMode(true);
}
Logger.d(c, "Configuration download completed, configurationDownloadedSuccessfully=" + z);
Logger.d(c, "configurationDownloadCompleted isMaxProcess " + z2);
Logger.d(c, "configurationDownloadCompleted isActive " + w.x() + ", packageId = " + getInstance().l().getPackageName());
if (w.x() && z2 && !F.get()) {
F.set(true);
CreativeInfoManager.k();
CreativeInfoManager.e();
ag();
if (z) {
Logger.d(c, "Will attempt to load events from storage");
StatsCollector.c().d();
} else {
ae();
}
ae();
Logger.d(c, "Loading singletons");
g.a();
k.a();
if (this.f9159b == null) {
this.f9159b = i.a();
}
af();
}
this.C.set(true);
} else {
Logger.d(c, "SafeDK is disabled.");
Logger.setDebugMode(false);
com.safedk.android.internal.b.getInstance().clearBackgroundForegroundListeners();
}
}
} catch (Throwable th) {
Logger.e(c, "Exception handling configuration event", th);
new CrashReporter().caughtException(th);
}
}
public String b(String str) {
JSONObject jSONObject;
String str2 = null;
if (this.B != null) {
Logger.d(c, "getSdkVersion getSdkVersion: " + str);
JSONObject j2 = this.B.j();
if (j2 != null) {
Logger.d(c, "getSdkVersion sdkVersionsJson=" + j2.toString());
}
try {
jSONObject = j2.getJSONObject(str);
} catch (Throwable th) {
}
if (jSONObject == null) {
Logger.d(c, "getSdkVersion sdkData is null");
} else {
Logger.d(c, "getSdkVersion sdkData : " + jSONObject.toString());
str2 = jSONObject.getString("sdk_version");
Logger.d(c, "getSdkVersion version : " + str2);
Logger.d(c, "return sdk version: " + str2);
}
}
return str2;
}
public synchronized void b(Activity activity) {
Logger.d(c, "Stopping interstitial finder in activity " + activity.getClass().getName());
InterstitialFinder interstitialFinder = (InterstitialFinder) a(BrandSafetyUtils.AdType.INTERSTITIAL);
if (interstitialFinder != null) {
interstitialFinder.e(activity);
}
}
public synchronized void c(Activity activity) {
Logger.d(c, "Starting redirect monitoring in activity " + activity.getClass().getName());
for (b bVar : this.A.values()) {
bVar.a(activity);
}
}
public boolean c() {
try {
if (!J.booleanValue() && F != null && !F.get()) {
Logger.d(c, "loading config from prefs");
this.B = new j(v.getSharedPreferences("SafeDKToggles", 0), m);
}
J = true;
} catch (IllegalStateException e2) {
Logger.d(c, "IllegalStateException caught during loading of configuration from prefs, device may be locked", e2);
} catch (Throwable th) {
Logger.d(c, "Exception during loading of configuration from prefs : " + th.getMessage(), th);
}
return J.booleanValue();
}
public synchronized void d(Activity activity) {
if (o()) {
Logger.d(c, "onForegroundActivity " + activity.getClass().getName());
if (getInstance().c() && this.z == null) {
Logger.d(c, "Before reading shared prefs");
this.z = new DeviceData(v, this.B);
}
}
}
public boolean d() {
try {
ApplicationInfo applicationInfo = SafeDKApplication.getAppContext().getPackageManager().getApplicationInfo(v.getPackageName(), 128);
if (w.x()) {
return applicationInfo.metaData.getBoolean(i, false) || ah();
}
return false;
} catch (PackageManager.NameNotFoundException e2) {
return false;
}
}
public synchronized void e(Activity activity) {
if (o()) {
Logger.d(c, "onBackgroundActivity " + activity.getClass().getName());
}
}
public boolean e() {
return this.s;
}
public int f() {
return w.a();
}
public int g() {
return w.b();
}
@Api
public String getUserId() {
return this.y;
}
public boolean h() {
return w.c();
}
public synchronized void i() {
F.set(true);
CreativeInfoManager.k();
ag();
ae();
Logger.d(c, "Loading singletons");
g.a();
k.a();
if (this.f9159b == null) {
this.f9159b = i.a();
}
af();
this.C.set(true);
}
public synchronized void j() {
if (StatsCollector.b()) {
for (b bVar : this.A.values()) {
if (bVar.b() > 0) {
bVar.c();
}
}
}
}
public Context l() {
return v;
}
public boolean m() {
return w.y() || ah();
}
public boolean n() {
return r;
}
public boolean o() {
return w.x();
}
public boolean p() {
return w.s();
}
public boolean q() {
return w.t();
}
public boolean r() {
return !s() && w.x();
}
public boolean s() {
if (this.B == null) {
return true;
}
return this.B.b();
}
public List<String> u() {
return w.u();
}
public List<String> v() {
return w.v();
}
public DeviceData w() {
return this.z;
}
public Map<BrandSafetyUtils.AdType, b> x() {
return this.A;
}
public InterstitialFinder y() {
return (InterstitialFinder) a(BrandSafetyUtils.AdType.INTERSTITIAL);
}
public BannerFinder z() {
return (BannerFinder) a(BrandSafetyUtils.AdType.BANNER);
}
}