- 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
187 lines
5.5 KiB
Java
187 lines
5.5 KiB
Java
package csdk.gluads.util;
|
|
|
|
import android.content.Context;
|
|
import android.content.SharedPreferences;
|
|
import android.os.Handler;
|
|
import android.os.Looper;
|
|
import android.provider.Settings;
|
|
import android.util.Base64;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
|
|
import com.mbridge.msdk.foundation.tools.SameMD5;
|
|
import java.math.BigInteger;
|
|
import java.nio.charset.Charset;
|
|
import java.security.MessageDigest;
|
|
import java.security.NoSuchAlgorithmException;
|
|
import java.util.HashMap;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
import java.util.UUID;
|
|
import java.util.concurrent.Callable;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public class Common {
|
|
private static Handler mainHandler = new Handler(Looper.getMainLooper());
|
|
|
|
public static <T> T or(T t, T t2) {
|
|
return t != null ? t : t2;
|
|
}
|
|
|
|
public static void require(boolean z) {
|
|
if (!z) {
|
|
throw new IllegalArgumentException();
|
|
}
|
|
}
|
|
|
|
public static void require(boolean z, String str) {
|
|
if (z) {
|
|
return;
|
|
}
|
|
if (str != null) {
|
|
throw new IllegalArgumentException(str);
|
|
}
|
|
throw new IllegalArgumentException();
|
|
}
|
|
|
|
public static RuntimeException propagate(Throwable th) {
|
|
if (th instanceof Error) {
|
|
throw ((Error) th);
|
|
}
|
|
if (th instanceof RuntimeException) {
|
|
throw ((RuntimeException) th);
|
|
}
|
|
throw new RuntimeException(th);
|
|
}
|
|
|
|
public static String emptyToNull(String str) {
|
|
if (str == null || str.length() > 0) {
|
|
return str;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static <T> T call(Callable<T> callable) {
|
|
try {
|
|
return callable.call();
|
|
} catch (Exception e) {
|
|
throw propagate(e);
|
|
}
|
|
}
|
|
|
|
public static String uuid() {
|
|
return UUID.randomUUID().toString();
|
|
}
|
|
|
|
public static <K, V> Map<K, V> createMap() {
|
|
return new HashMap();
|
|
}
|
|
|
|
public static <K, V> Map<K, V> shallowClone(Map<K, V> map) {
|
|
if (map == null) {
|
|
return null;
|
|
}
|
|
Map<K, V> createMap = createMap();
|
|
createMap.putAll(map);
|
|
return createMap;
|
|
}
|
|
|
|
public static <K, V> V get(Map<K, V> map, K k, V v) {
|
|
if (map == null || k == null) {
|
|
return v;
|
|
}
|
|
V v2 = map.get(k);
|
|
return (v2 != null || map.containsKey(k)) ? v2 : v;
|
|
}
|
|
|
|
public static <K, V> V get(Map<K, V> map, K k) {
|
|
return (V) get(map, k, null);
|
|
}
|
|
|
|
public static boolean isEmpty(Map<?, ?> map) {
|
|
return map == null || map.isEmpty();
|
|
}
|
|
|
|
public static void runOnUIThread(Runnable runnable) {
|
|
require(runnable != null, "runnable == null");
|
|
if (!mainHandler.post(runnable)) {
|
|
throw new IllegalStateException("Failed to post runnable");
|
|
}
|
|
}
|
|
|
|
public static void runOnUIThreadDelayed(Runnable runnable, long j) {
|
|
require(runnable != null, "runnable == null");
|
|
if (!mainHandler.postDelayed(runnable, j)) {
|
|
throw new IllegalStateException("Failed to post runnable");
|
|
}
|
|
}
|
|
|
|
public static long msTimestamp() {
|
|
return System.nanoTime() / 1000000;
|
|
}
|
|
|
|
public static String getGAID(Context context) {
|
|
try {
|
|
return AdvertisingIdClient.getAdvertisingIdInfo(context).getId();
|
|
} catch (Exception unused) {
|
|
return "";
|
|
}
|
|
}
|
|
|
|
public static String getAdMobTestDeviceID(Context context) {
|
|
return md5(Settings.Secure.getString(context.getContentResolver(), "android_id")).toUpperCase(Locale.US);
|
|
}
|
|
|
|
public static Map<String, Object> getMapFromUserID(String str) {
|
|
try {
|
|
return JsonUtil.parseJsonObject(new String(Base64.decode(str, 0), "UTF-8"));
|
|
} catch (Exception unused) {
|
|
return createMap();
|
|
}
|
|
}
|
|
|
|
public static String getUserIDFromMap(Map<String, Object> map) {
|
|
return Base64.encodeToString(JsonUtil.toJson(map).getBytes(Charset.forName("UTF-8")), 10).trim();
|
|
}
|
|
|
|
public static String removeRevIDAndSessionIDFromUserID(String str) {
|
|
Map<String, Object> mapFromUserID = getMapFromUserID(str);
|
|
mapFromUserID.remove("revId");
|
|
mapFromUserID.remove("sessionId");
|
|
return getUserIDFromMap(mapFromUserID);
|
|
}
|
|
|
|
private static String md5(String str) {
|
|
try {
|
|
return String.format("%032X", new BigInteger(1, MessageDigest.getInstance(SameMD5.TAG).digest(str.getBytes())));
|
|
} catch (NoSuchAlgorithmException unused) {
|
|
return "";
|
|
}
|
|
}
|
|
|
|
public static Map<String, Object> loadMap(SharedPreferences sharedPreferences, String str) {
|
|
try {
|
|
return JsonUtil.parseJsonObject(sharedPreferences.getString(str, ""));
|
|
} catch (Exception unused) {
|
|
return new HashMap();
|
|
}
|
|
}
|
|
|
|
public static void saveMap(SharedPreferences sharedPreferences, String str, Map<String, Object> map) {
|
|
SharedPreferences.Editor edit = sharedPreferences.edit();
|
|
edit.putString(str, JsonUtil.toJson(map));
|
|
edit.apply();
|
|
}
|
|
|
|
@NonNull
|
|
public static Map<String, String> mapSSFromConfig(@Nullable Map<String, Object> map) {
|
|
Map<String, String> createMap = createMap();
|
|
if (map != null) {
|
|
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
|
createMap.put(entry.getKey(), (String) entry.getValue());
|
|
}
|
|
}
|
|
return createMap;
|
|
}
|
|
}
|