- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
381 lines
14 KiB
Java
381 lines
14 KiB
Java
package com.singular.sdk.internal;
|
|
|
|
import android.content.Context;
|
|
import android.content.SharedPreferences;
|
|
import android.content.res.Configuration;
|
|
import android.net.ConnectivityManager;
|
|
import android.net.NetworkInfo;
|
|
import android.net.Uri;
|
|
import android.provider.Settings;
|
|
import com.applovin.exoplayer2.common.base.Ascii;
|
|
import com.ironsource.v8;
|
|
import com.singular.sdk.SingularLinkParams;
|
|
import com.unity3d.ads.core.data.datasource.AndroidStaticDeviceInfoDataSource;
|
|
import java.io.File;
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Method;
|
|
import java.security.MessageDigest;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.HashSet;
|
|
import java.util.Iterator;
|
|
import java.util.Locale;
|
|
import java.util.Set;
|
|
import java.util.UUID;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public abstract class Utils {
|
|
public static final SingularLog logger = SingularLog.getLogger(Utils.class.getSimpleName());
|
|
public static String wrapperName = null;
|
|
public static String wrapperVersion = null;
|
|
|
|
public static boolean isEmptyOrNull(String str) {
|
|
return str == null || str.trim().length() == 0;
|
|
}
|
|
|
|
public static long getCurrentTimeMillis() {
|
|
return System.currentTimeMillis();
|
|
}
|
|
|
|
public static double lagSince(long j) {
|
|
return (getCurrentTimeMillis() - j) * 0.001d;
|
|
}
|
|
|
|
public static String sha1Hash(String str, String str2) {
|
|
try {
|
|
MessageDigest messageDigest = MessageDigest.getInstance(AndroidStaticDeviceInfoDataSource.ALGORITHM_SHA1);
|
|
messageDigest.update(str2.getBytes("UTF-8"));
|
|
messageDigest.update(str.getBytes("UTF-8"));
|
|
return bytesToHexString(messageDigest.digest());
|
|
} catch (Exception e) {
|
|
logger.error("error in sha1Hash()", e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static String bytesToHexString(byte[] bArr) {
|
|
char[] cArr = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
|
char[] cArr2 = new char[bArr.length * 2];
|
|
for (int i = 0; i < bArr.length; i++) {
|
|
byte b = bArr[i];
|
|
int i2 = i * 2;
|
|
cArr2[i2] = cArr[(b & 255) >>> 4];
|
|
cArr2[i2 + 1] = cArr[b & Ascii.SI];
|
|
}
|
|
return new String(cArr2);
|
|
}
|
|
|
|
public static String formatTimestamp(long j) {
|
|
return new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z").format(Long.valueOf(j));
|
|
}
|
|
|
|
public static boolean isGooglePlayServicesAvailable() {
|
|
return Reflection.forName("com.google.android.gms.ads.identifier.AdvertisingIdClient") != null;
|
|
}
|
|
|
|
public static Object getAdvertisingInfoObject(Context context) {
|
|
return Reflection.invokeStaticMethod("com.google.android.gms.ads.identifier.AdvertisingIdClient", "getAdvertisingIdInfo", new Class[]{Context.class}, context);
|
|
}
|
|
|
|
public static String getPlayStoreAdId(Context context) {
|
|
try {
|
|
return (String) Reflection.invokeInstanceMethod(getAdvertisingInfoObject(context), "getId", null, new Object[0]);
|
|
} catch (Throwable unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static boolean isLimitedTrackingEnabled(Context context) {
|
|
try {
|
|
return ((Boolean) Reflection.invokeInstanceMethod(getAdvertisingInfoObject(context), v8.i.M, null, new Object[0])).booleanValue();
|
|
} catch (Throwable unused) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static String getAndroidId(Context context) {
|
|
String string = Settings.Secure.getString(context.getContentResolver(), "android_id");
|
|
return !getInvalidDeviceIds().contains(string) ? string : "None";
|
|
}
|
|
|
|
public static Set getInvalidDeviceIds() {
|
|
HashSet hashSet = new HashSet();
|
|
hashSet.add("");
|
|
hashSet.add("9774d56d682e549c");
|
|
hashSet.add("unknown");
|
|
hashSet.add("000000000000000");
|
|
hashSet.add(v8.d);
|
|
hashSet.add("DEFACE");
|
|
hashSet.add("00000000-0000-0000-0000-000000000000");
|
|
return hashSet;
|
|
}
|
|
|
|
public static NetworkInfo getNetworkInfo(Context context) {
|
|
return ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
|
|
}
|
|
|
|
public static boolean isConnected(Context context) {
|
|
NetworkInfo networkInfo = getNetworkInfo(context);
|
|
return networkInfo != null && networkInfo.isConnected();
|
|
}
|
|
|
|
public static boolean isConnectedWifi(Context context) {
|
|
NetworkInfo networkInfo = getNetworkInfo(context);
|
|
return networkInfo != null && networkInfo.isConnected() && networkInfo.getType() == 1;
|
|
}
|
|
|
|
public static boolean isConnectedMobile(Context context) {
|
|
NetworkInfo networkInfo = getNetworkInfo(context);
|
|
return networkInfo != null && networkInfo.isConnected() && networkInfo.getType() == 0;
|
|
}
|
|
|
|
public static String getConnectionType(Context context) {
|
|
if (isConnectedMobile(context)) {
|
|
return "wwan";
|
|
}
|
|
isConnectedWifi(context);
|
|
return "wifi";
|
|
}
|
|
|
|
public static Locale getLocale(Configuration configuration) {
|
|
Locale localeFromLocaleList = Reflection.getLocaleFromLocaleList(configuration);
|
|
return localeFromLocaleList != null ? localeFromLocaleList : Reflection.getLocaleFromField(configuration);
|
|
}
|
|
|
|
public static String[] getSupportedAbis() {
|
|
return Reflection.getSupportedAbis();
|
|
}
|
|
|
|
public static String getCpuAbi() {
|
|
return Reflection.getCpuAbi();
|
|
}
|
|
|
|
public static void saveCSIReferrer(Context context, String str) {
|
|
SharedPreferences.Editor edit = context.getSharedPreferences("install-openUri", 0).edit();
|
|
edit.putString("openUri", str);
|
|
edit.commit();
|
|
}
|
|
|
|
public static String getCSIReferrer(Context context) {
|
|
return context.getSharedPreferences("install-openUri", 0).getString("openUri", null);
|
|
}
|
|
|
|
public static void signalAsyncReferrerAllowed(Context context) {
|
|
SharedPreferences.Editor edit = context.getSharedPreferences("install-openUri", 0).edit();
|
|
edit.putBoolean("asyncReferrerAllowed", true);
|
|
edit.commit();
|
|
}
|
|
|
|
public static boolean isAsyncReferrerAllowed(Context context) {
|
|
return context.getSharedPreferences("install-openUri", 0).getBoolean("asyncReferrerAllowed", false);
|
|
}
|
|
|
|
public static boolean isFirstInstall(Context context) {
|
|
File file = new File(context.getFilesDir(), "appInstallInfo");
|
|
if (file.exists()) {
|
|
saveFirstInstallInfo(context);
|
|
file.delete();
|
|
return false;
|
|
}
|
|
if (context.getSharedPreferences("singular-first-install", 0).getBoolean("wasOpenedAfterInstall", false)) {
|
|
return false;
|
|
}
|
|
saveFirstInstallInfo(context);
|
|
return true;
|
|
}
|
|
|
|
public static void saveFirstInstallInfo(Context context) {
|
|
SharedPreferences.Editor edit = context.getSharedPreferences("singular-first-install", 0).edit();
|
|
edit.putBoolean("wasOpenedAfterInstall", true);
|
|
edit.commit();
|
|
}
|
|
|
|
public static UUID getSingularId(Context context) {
|
|
SharedPreferences sharedPreferences = context.getSharedPreferences("pref-singular-id", 0);
|
|
String string = sharedPreferences.getString("singular-id", null);
|
|
if (string != null) {
|
|
return UUID.fromString(string);
|
|
}
|
|
return createSingularId(sharedPreferences);
|
|
}
|
|
|
|
public static UUID createSingularId(SharedPreferences sharedPreferences) {
|
|
UUID randomUUID = UUID.randomUUID();
|
|
SharedPreferences.Editor edit = sharedPreferences.edit();
|
|
edit.putString("singular-id", randomUUID.toString());
|
|
edit.commit();
|
|
return randomUUID;
|
|
}
|
|
|
|
public static long getEventIndex(Context context) {
|
|
SharedPreferences sharedPreferences = context.getSharedPreferences("pref-event-index", 0);
|
|
return increaseEventIndex(sharedPreferences, sharedPreferences.getLong("event-index", -1L));
|
|
}
|
|
|
|
public static long increaseEventIndex(SharedPreferences sharedPreferences, long j) {
|
|
long j2 = j + 1;
|
|
SharedPreferences.Editor edit = sharedPreferences.edit();
|
|
edit.putLong("event-index", j2);
|
|
edit.commit();
|
|
return j2;
|
|
}
|
|
|
|
public static boolean isLicenseRetrieved(Context context, String str) {
|
|
return context.getSharedPreferences("singular-licensing-api", 0).getBoolean(str, false);
|
|
}
|
|
|
|
public static void saveLicenseInfo(Context context, String str) {
|
|
SharedPreferences.Editor edit = context.getSharedPreferences("singular-licensing-api", 0).edit();
|
|
edit.putBoolean(str, true);
|
|
edit.commit();
|
|
}
|
|
|
|
public static class Reflection {
|
|
public static String[] getSupportedAbis() {
|
|
try {
|
|
return (String[]) readField("android.os.Build", "SUPPORTED_ABIS");
|
|
} catch (Throwable unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static String getCpuAbi() {
|
|
try {
|
|
return (String) readField("android.os.Build", "CPU_ABI");
|
|
} catch (Throwable unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static Locale getLocaleFromLocaleList(Configuration configuration) {
|
|
try {
|
|
Object invokeInstanceMethod = invokeInstanceMethod(configuration, "getLocales", null, new Object[0]);
|
|
if (invokeInstanceMethod == null) {
|
|
return null;
|
|
}
|
|
return (Locale) invokeInstanceMethod(invokeInstanceMethod, "get", new Class[]{Integer.TYPE}, 0);
|
|
} catch (Throwable unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static Locale getLocaleFromField(Configuration configuration) {
|
|
try {
|
|
return (Locale) readField("android.content.res.Configuration", "locale", configuration);
|
|
} catch (Throwable unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static Object invokeInstanceMethod(Object obj, String str, Class[] clsArr, Object... objArr) {
|
|
return invokeMethod(obj.getClass(), str, obj, clsArr, objArr);
|
|
}
|
|
|
|
public static Object invokeStaticMethod(String str, String str2, Class[] clsArr, Object... objArr) {
|
|
return invokeMethod(Class.forName(str), str2, null, clsArr, objArr);
|
|
}
|
|
|
|
public static Object invokeMethod(Class cls, String str, Object obj, Class[] clsArr, Object... objArr) {
|
|
Method method = cls.getMethod(str, clsArr);
|
|
if (method == null) {
|
|
return null;
|
|
}
|
|
return method.invoke(obj, objArr);
|
|
}
|
|
|
|
public static Object readField(String str, String str2) {
|
|
return readField(str, str2, null);
|
|
}
|
|
|
|
public static Object readField(String str, String str2, Object obj) {
|
|
Field field;
|
|
Class forName = forName(str);
|
|
if (forName == null || (field = forName.getField(str2)) == null) {
|
|
return null;
|
|
}
|
|
return field.get(obj);
|
|
}
|
|
|
|
public static Class forName(String str) {
|
|
try {
|
|
return Class.forName(str);
|
|
} catch (Throwable unused) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public static String getPlayStoreAdIdByBackupMethod(Context context) {
|
|
try {
|
|
return ExternalAIFAHelper.getAIFA(context);
|
|
} catch (Throwable unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static boolean isShortLink(Uri uri) {
|
|
return extractDeepLink(uri) == null;
|
|
}
|
|
|
|
public static String extractDeepLink(Uri uri) {
|
|
if (uri == null) {
|
|
return null;
|
|
}
|
|
String queryParameter = uri.getQueryParameter("_android_dl");
|
|
return queryParameter != null ? queryParameter : uri.getQueryParameter("_dl");
|
|
}
|
|
|
|
public static String extractPassthroughFromSingularLink(Uri uri) {
|
|
return uri.getQueryParameter("_p");
|
|
}
|
|
|
|
public static void handleSingularLink(Uri uri) {
|
|
String extractDeepLink = extractDeepLink(uri);
|
|
if (extractDeepLink != null) {
|
|
handleDeepLink(new SingularLinkParams(extractDeepLink, extractPassthroughFromSingularLink(uri), false));
|
|
}
|
|
}
|
|
|
|
public static boolean handleDeepLink(SingularLinkParams singularLinkParams) {
|
|
SingularInstance.getInstance().getSingularConfig().getClass();
|
|
singularLinkParams.getDeeplink();
|
|
return false;
|
|
}
|
|
|
|
public static boolean validateSingularLink(Uri uri) {
|
|
if (uri == null) {
|
|
return false;
|
|
}
|
|
if (uri.getScheme() == null) {
|
|
uri = Uri.parse("https://" + uri.toString());
|
|
}
|
|
if (uri.getHost() != null && uri.getHost().endsWith("sng.link")) {
|
|
return true;
|
|
}
|
|
if (SingularInstance.getInstance() != null && SingularInstance.getInstance().getSingularConfig() != null && SingularInstance.getInstance().getSingularConfig().approvedDomains != null) {
|
|
Iterator it = SingularInstance.getInstance().getSingularConfig().approvedDomains.iterator();
|
|
while (it.hasNext()) {
|
|
if (uri.getHost().equals((String) it.next())) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static boolean isOpenedWithDeeplink() {
|
|
return SingularInstance.getInstance().getSingularConfig().isOpenedWithDeepLink;
|
|
}
|
|
|
|
public static boolean appMovedToBackground() {
|
|
SingularInstance.getInstance().getSingularConfig().isOpenedWithDeepLink = false;
|
|
return false;
|
|
}
|
|
|
|
public static String getSdkVersion() {
|
|
String str;
|
|
String str2 = SingularInstance.getInstance().getDeviceInfo().sdkVersion;
|
|
String str3 = wrapperName;
|
|
return (str3 == null || (str = wrapperVersion) == null) ? str2 : String.format("%s-%s/%s", str2, str3, str);
|
|
}
|
|
}
|