正在查看: Moneyman v2.316.0.0 应用的 Utils.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Moneyman v2.316.0.0 应用的 Utils.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.singular.sdk.internal;
import B.g;
import J6.e;
import J6.h;
import J6.i;
import J6.j;
import a7.f;
import a7.v;
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.os.Looper;
import android.provider.Settings;
import b6.a;
import b6.d;
import bl.AbstractC0752b;
import com.google.android.gms.common.Feature;
import com.google.android.gms.common.api.ApiException;
import com.google.android.gms.common.api.Status;
import com.singular.sdk.BuildConfig;
import com.singular.sdk.SingularLinkHandler;
import com.singular.sdk.SingularLinkParams;
import e.b;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Method;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import m6.t;
public class Utils {
private static int asidScope;
private static double asidTimeinterval;
private static String encryptedApiKey;
private static final SingularLog logger = SingularLog.getLogger("Utils");
private static String wrapperName = null;
private static String wrapperVersion = null;
private static String imei = null;
private Utils() {
}
public static boolean appMovedToBackground() {
SingularInstance.getInstance().getSingularConfig().isOpenedWithDeepLink = false;
return false;
}
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 & 15];
}
return new String(cArr2);
}
private static UUID createSingularId(SharedPreferences sharedPreferences) {
UUID randomUUID = UUID.randomUUID();
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putString(Constants.PREF_SINGULAR_ID_KEY, randomUUID.toString());
edit.commit();
return randomUUID;
}
public static String extractDeepLink(Uri uri) {
if (uri == null) {
return null;
}
if (!isESPLink(uri) && !isSingularLinkDomain(uri)) {
return null;
}
String queryParameter = uri.getQueryParameter(Constants.QUERY_ANDROID_DEEPLINK);
return queryParameter != null ? queryParameter : uri.getQueryParameter(Constants.QUERY_DEEPLINK);
}
public static String extractPassthroughFromSingularLink(Uri uri) {
return uri.getQueryParameter(Constants.QUERY_DEEPLINK_PASSTHROUGH);
}
public static String findAndRemoveSuffixFromEncryptedKeys(String str, String str2) {
return (isEmptyOrNull(str) || isEmptyOrNull(str2) || str.length() < str2.length() || !str.endsWith(str2)) ? str : str.substring(0, str.length() - str2.length());
}
public static String formatException(Throwable th2) {
return "Exception: \n" + th2.getMessage() + "\nStack trace: \n" + getStackTrace(th2);
}
public static String formatTimestamp(long j) {
return new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z").format(Long.valueOf(j));
}
private static String generateKeyForRetryCountWithKey(String str) {
return g.l("rc-", str);
}
public static int getASIDScope() {
return asidScope;
}
public static double getASIDTimeInterval() {
return asidTimeinterval;
}
public static long getAdmonEventIndex(Context context) {
SharedPreferences sharedPreferences = context.getSharedPreferences(Constants.PREF_ADMON_EVENT_INDEX, 0);
return increaseAdmonEventIndex(sharedPreferences, sharedPreferences.getLong(Constants.PREF_ADMON_EVENT_INDEX_KEY, -1L));
}
private static Object getAdvertisingInfoObject(Context context) throws Exception {
return SLReflectionUtils.invokeStaticMethod("com.google.android.gms.ads.identifier.AdvertisingIdClient", "getAdvertisingIdInfo", new Class[]{Context.class}, context);
}
public static String getAmazonId(Context context) {
try {
return Settings.Secure.getString(context.getContentResolver(), Constants.AMAZON_ADVERTISING_ID);
} catch (Throwable unused) {
return null;
}
}
public static int getAndIncrementRetryCountForKey(Context context, String str) {
int i = context.getSharedPreferences(Constants.PREF_REQUEST_RETRY_COUNT, 0).getInt(generateKeyForRetryCountWithKey(str), 0);
saveRetryCountForKey(str, context, i + 1);
return i;
}
public static String getAndroidId(Context context) {
String string = Settings.Secure.getString(context.getContentResolver(), "android_id");
return !getInvalidDeviceIds().contains(string) ? string : "None";
}
public static String getAppSetId(Context context) {
v B;
try {
j jVar = new j(context);
h hVar = jVar.a;
if (hVar.l.b(hVar.k, 212800000) == 0) {
A7.h a = t.a();
a.e = new Feature[]{d.a};
a.d = new e(hVar);
a.c = false;
a.b = 27601;
B = hVar.c(0, a.a());
} else {
B = AbstractC0752b.B(new ApiException(new Status(17)));
}
i iVar = new i(jVar);
B.getClass();
a7.h g = B.g(a7.j.a, iVar);
final LinkedBlockingQueue linkedBlockingQueue = new LinkedBlockingQueue();
final long currentTimeMillis = getCurrentTimeMillis();
g.d(new f() {
public void onSuccess(a aVar) {
int unused = Utils.asidScope = aVar.b;
linkedBlockingQueue.offer(aVar.a);
double unused2 = Utils.asidTimeinterval = Utils.lagSince(currentTimeMillis);
}
});
String str = (String) linkedBlockingQueue.poll(1L, TimeUnit.SECONDS);
if (isEmptyOrNull(str)) {
return null;
}
return str;
} catch (Throwable unused) {
return null;
}
}
public static long getBatchSendId(Context context) {
return context.getSharedPreferences(Constants.PREF_BATCH_SEND_ID, 0).getLong("sendId", 0L);
}
public static String getCSIReferrer(Context context) {
return context.getSharedPreferences(Constants.PREF_INSTALL_REFERRER, 0).getString(Constants.PREF_CSI_REFERRER_KEY, null);
}
public static String getConnectionType(Context context) {
if (isConnectedMobile(context)) {
return Constants.WWAN;
}
isConnectedWifi(context);
return Constants.WIFI;
}
public static String getCpuAbi() {
return SLReflectionUtils.getCpuAbi();
}
public static long getCurrentTimeMillis() {
return System.currentTimeMillis();
}
public static Method getDeclaredMethod(Object obj, String str, Class<?>... clsArr) {
try {
return obj.getClass().getDeclaredMethod(str, clsArr);
} catch (NoSuchMethodException unused) {
SingularLog singularLog = logger;
StringBuilder p = b.p("Method ", str, " was not found in ");
p.append(obj != null ? obj.getClass().getName() : null);
singularLog.debug(p.toString());
return null;
} catch (SecurityException e) {
logger.debug("Security violation occured ", e);
return null;
}
}
public static String getEncryptedApiKey() {
return encryptedApiKey;
}
public static long getEventIndex(Context context) {
SharedPreferences sharedPreferences = context.getSharedPreferences(Constants.PREF_EVENT_INDEX, 0);
return increaseEventIndex(sharedPreferences, sharedPreferences.getLong(Constants.PREF_EVENT_INDEX_KEY, -1L));
}
public static String getImei() {
return imei;
}
public static Set<String> getInvalidDeviceIds() {
HashSet hashSet = new HashSet();
hashSet.add(BuildConfig.FLAVOR);
hashSet.add("9774d56d682e549c");
hashSet.add(Constants.UNKNOWN);
hashSet.add("000000000000000");
hashSet.add(Constants.PLATFORM);
hashSet.add("DEFACE");
hashSet.add("00000000-0000-0000-0000-000000000000");
hashSet.add("0000-0000");
return hashSet;
}
public static Locale getLocale(Configuration configuration) {
Locale localeFromLocaleList = SLReflectionUtils.getLocaleFromLocaleList(configuration);
return localeFromLocaleList != null ? localeFromLocaleList : SLReflectionUtils.getLocaleFromField(configuration);
}
public static NetworkInfo getNetworkInfo(Context context) {
return ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
}
public static String getPlayStoreAdId(Context context) {
String str;
try {
str = (String) SLReflectionUtils.invokeInstanceMethod(getAdvertisingInfoObject(context), "getId", null, new Object[0]);
} catch (Throwable unused) {
}
if (isInvalidDeviceId(str)) {
return null;
}
return str;
}
public static String getPlayStoreAdIdByBackupMethod(Context context) {
String aifa;
try {
aifa = ExternalAIFAHelper.getAIFA(context);
} catch (Throwable unused) {
}
if (isInvalidDeviceId(aifa)) {
return null;
}
return aifa;
}
public static String getSdkVersion(SingularInstance singularInstance) {
String str;
String str2 = singularInstance.getDeviceInfo().sdkVersion;
String str3 = wrapperName;
if (str3 == null || (str = wrapperVersion) == null) {
return str2;
}
return str2 + "-" + str3 + "/" + str;
}
public static UUID getSingularId(Context context) {
SharedPreferences sharedPreferences = context.getSharedPreferences(Constants.PREF_SINGULAR_ID, 0);
String string = sharedPreferences.getString(Constants.PREF_SINGULAR_ID_KEY, null);
return string != null ? UUID.fromString(string) : createSingularId(sharedPreferences);
}
public static String getStackTrace(Throwable th2) {
StringWriter stringWriter = new StringWriter();
th2.printStackTrace(new PrintWriter(stringWriter));
return stringWriter.toString();
}
public static String[] getSupportedAbis() {
return SLReflectionUtils.getSupportedAbis();
}
public static String getWrapperName() {
return wrapperName;
}
public static boolean handleDeepLink(final SingularLinkParams singularLinkParams) {
final SingularLinkHandler singularLinkHandler = SingularInstance.getInstance().getSingularConfig().linkCallback;
if (singularLinkParams.getDeeplink() == null || singularLinkHandler == null) {
return false;
}
new Runnable() {
@Override
public void run() {
SingularLinkHandler.this.onResolved(singularLinkParams);
}
}.run();
return true;
}
public static void handleSingularLink(Uri uri) {
String extractDeepLink = extractDeepLink(uri);
if (extractDeepLink != null) {
handleDeepLink(new SingularLinkParams(extractDeepLink, extractPassthroughFromSingularLink(uri), false, uri));
}
}
private static byte[] hexStringToByteArray(String str) {
try {
int length = str.length();
byte[] bArr = new byte[length / 2];
for (int i = 0; i < length; i += 2) {
bArr[i / 2] = (byte) ((Character.digit(str.charAt(i), 16) << 4) + Character.digit(str.charAt(i + 1), 16));
}
return bArr;
} catch (Throwable th2) {
formatException(th2);
return null;
}
}
public static long incBatchSendId(Context context) {
long batchSendId = getBatchSendId(context) + 1;
try {
SharedPreferences.Editor edit = context.getSharedPreferences(Constants.PREF_BATCH_SEND_ID, 0).edit();
edit.putLong("sendId", batchSendId);
edit.commit();
return batchSendId;
} catch (Throwable th2) {
logger.error(formatException(th2));
return batchSendId;
}
}
private static long increaseAdmonEventIndex(SharedPreferences sharedPreferences, long j) {
long j2 = j + 1;
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putLong(Constants.PREF_ADMON_EVENT_INDEX_KEY, j2);
edit.commit();
return j2;
}
private static long increaseEventIndex(SharedPreferences sharedPreferences, long j) {
long j2 = j + 1;
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putLong(Constants.PREF_EVENT_INDEX_KEY, j2);
edit.commit();
return j2;
}
public static boolean isAmazonAvailable(Context context) {
try {
Settings.Secure.getInt(context.getContentResolver(), Constants.AMAZON_LIMIT_AD_TRACKING);
return true;
} catch (Settings.SettingNotFoundException unused) {
return false;
}
}
public static boolean isAmazonLimitAdTracking(Context context) {
return Settings.Secure.getInt(context.getContentResolver(), Constants.AMAZON_LIMIT_AD_TRACKING) != 0;
}
public static boolean isConnected(Context context) {
NetworkInfo networkInfo = getNetworkInfo(context);
return networkInfo != null && networkInfo.isConnected();
}
public static boolean isConnectedMobile(Context context) {
NetworkInfo networkInfo = getNetworkInfo(context);
return networkInfo != null && networkInfo.isConnected() && networkInfo.getType() == 0;
}
public static boolean isConnectedWifi(Context context) {
NetworkInfo networkInfo = getNetworkInfo(context);
return networkInfo != null && networkInfo.isConnected() && networkInfo.getType() == 1;
}
public static boolean isESPLink(Uri uri) {
if (uri == null || SingularInstance.getInstance() == null || SingularInstance.getInstance().getSingularConfig() == null || SingularInstance.getInstance().getSingularConfig().espDomains == null || SingularInstance.getInstance().getSingularConfig().espDomains.size() == 0) {
return false;
}
if (uri.getScheme() == null) {
uri = Uri.parse("https://" + uri.toString());
}
return isUrlInDomains(uri, SingularInstance.getInstance().getSingularConfig().espDomains);
}
public static boolean isEmptyOrNull(String str) {
return str == null || str.trim().length() == 0;
}
public static boolean isFirstInstall(Context context) {
if (context.getSharedPreferences(Constants.PREF_FIRST_INSTALL, 0).getBoolean(Constants.WAS_OPENED_AFTER_INSTALL, false)) {
return false;
}
saveFirstInstallInfo(context);
return true;
}
public static boolean isGooglePlayServicesAvailable() {
return SLReflectionUtils.forName("com.google.android.gms.ads.identifier.AdvertisingIdClient") != null;
}
public static boolean isInvalidDeviceId(String str) {
if (isEmptyOrNull(str)) {
return false;
}
return getInvalidDeviceIds().contains(str) || Pattern.compile("^[0-]+$").matcher(str).matches();
}
public static boolean isLicenseRetrieved(Context context, String str) {
return context.getSharedPreferences(Constants.LICENSING_API_KEY, 0).getBoolean(str, false);
}
public static boolean isLimitedTrackingEnabled(Context context) {
try {
return ((Boolean) SLReflectionUtils.invokeInstanceMethod(getAdvertisingInfoObject(context), "isLimitAdTrackingEnabled", null, new Object[0])).booleanValue();
} catch (Throwable unused) {
return false;
}
}
public static boolean isMainThread() {
return Looper.getMainLooper().getThread() == Thread.currentThread();
}
public static boolean isOpenedWithDeeplink() {
return SingularInstance.getInstance().getSingularConfig().isOpenedWithDeepLink;
}
public static boolean isShortLink(Uri uri) {
return (isESPLink(uri) || isSingularLinkDomain(uri)) && extractDeepLink(uri) == null;
}
public static boolean isSingularLinkDomain(Uri uri) {
return (uri == null || uri.getHost() == null || !uri.getHost().endsWith(Constants.DEFAULT_SINGULAR_LINK_DOMAIN)) ? false : true;
}
private static boolean isUrlInDomains(Uri uri, List<String> list) {
for (String str : list) {
if (uri.getHost() != null && uri.getHost().equals(str)) {
return true;
}
}
return false;
}
public static double lagSince(long j) {
return (getCurrentTimeMillis() - j) * 0.001d;
}
public static void resetRetryCountForKey(Context context, String str) {
SharedPreferences sharedPreferences = context.getSharedPreferences(Constants.PREF_REQUEST_RETRY_COUNT, 0);
sharedPreferences.edit().remove(generateKeyForRetryCountWithKey(str)).commit();
}
public static Uri resolveESPLink(Uri uri) {
try {
URL url = new URL(uri.toString());
HttpURLConnection httpsConnection = url.getProtocol().equalsIgnoreCase("https") ? SingularRequestHandler.getHttpsConnection(url) : SingularRequestHandler.getHttpConnection(url);
httpsConnection.setInstanceFollowRedirects(false);
httpsConnection.connect();
String headerField = httpsConnection.getHeaderField("Location");
if (headerField == null) {
return null;
}
return Uri.parse(headerField);
} catch (IOException unused) {
return null;
}
}
public static void saveCSIReferrer(Context context, String str) {
SharedPreferences.Editor edit = context.getSharedPreferences(Constants.PREF_INSTALL_REFERRER, 0).edit();
edit.putString(Constants.PREF_CSI_REFERRER_KEY, str);
edit.commit();
}
private static void saveFirstInstallInfo(Context context) {
SharedPreferences.Editor edit = context.getSharedPreferences(Constants.PREF_FIRST_INSTALL, 0).edit();
edit.putBoolean(Constants.WAS_OPENED_AFTER_INSTALL, true);
edit.commit();
}
public static void saveLicenseInfo(Context context, String str) {
SharedPreferences.Editor edit = context.getSharedPreferences(Constants.LICENSING_API_KEY, 0).edit();
edit.putBoolean(str, true);
edit.commit();
}
public static void saveRetryCountForKey(String str, Context context, int i) {
try {
String generateKeyForRetryCountWithKey = generateKeyForRetryCountWithKey(str);
SharedPreferences.Editor edit = context.getSharedPreferences(Constants.PREF_REQUEST_RETRY_COUNT, 0).edit();
edit.putInt(generateKeyForRetryCountWithKey, i);
edit.commit();
} catch (Throwable th2) {
logger.error(formatException(th2));
}
}
public static void setEncryptedApiKey(String str) {
encryptedApiKey = str;
}
public static void setImei(String str) {
imei = str;
}
public static void setWrapperNameAndVersion(String str, String str2) {
wrapperName = str;
wrapperVersion = str2;
}
public static String sha1Hash(String str, String str2) {
try {
MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
messageDigest.update(str2.getBytes(Constants.ENCODING));
messageDigest.update(str.getBytes(Constants.ENCODING));
return bytesToHexString(messageDigest.digest());
} catch (Throwable th2) {
logger.error("error in sha1Hash()", th2);
return null;
}
}
public static boolean validateSingularLink(Uri uri) {
if (uri == null) {
return false;
}
if (uri.getScheme() == null) {
uri = Uri.parse("https://" + uri.toString());
}
return uri.getHost() != null;
}
public static String xorDecrypt(String str) {
try {
byte[] hexStringToByteArray = hexStringToByteArray(str);
byte[] bArr = new byte[4];
int length = hexStringToByteArray.length - 4;
byte[] bArr2 = new byte[length];
System.arraycopy(hexStringToByteArray, 0, bArr, 0, 4);
System.arraycopy(hexStringToByteArray, 4, bArr2, 0, length);
byte[] bArr3 = new byte[length];
for (int i = 0; i < length; i++) {
bArr3[i] = (byte) (bArr2[i] ^ bArr[i % 4]);
}
return new String(bArr3);
} catch (Throwable th2) {
formatException(th2);
return null;
}
}
}