Initial commit
This commit is contained in:
113
sources/com/unity3d/ads/properties/ClientProperties.java
Normal file
113
sources/com/unity3d/ads/properties/ClientProperties.java
Normal file
@@ -0,0 +1,113 @@
|
||||
package com.unity3d.ads.properties;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.Signature;
|
||||
import com.unity3d.ads.IUnityAdsListener;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.X509Certificate;
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class ClientProperties {
|
||||
private static final X500Principal DEBUG_CERT = new X500Principal("CN=Android Debug,O=Android,C=US");
|
||||
private static WeakReference<Activity> _activity;
|
||||
private static Application _application;
|
||||
private static Context _applicationContext;
|
||||
private static String _gameId;
|
||||
private static IUnityAdsListener _listener;
|
||||
|
||||
public static Activity getActivity() {
|
||||
return _activity.get();
|
||||
}
|
||||
|
||||
public static String getAppName() {
|
||||
return _applicationContext.getPackageName();
|
||||
}
|
||||
|
||||
public static String getAppVersion() {
|
||||
try {
|
||||
return getApplicationContext().getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0).versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
DeviceLog.exception("Error getting package info", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Application getApplication() {
|
||||
return _application;
|
||||
}
|
||||
|
||||
public static Context getApplicationContext() {
|
||||
return _applicationContext;
|
||||
}
|
||||
|
||||
public static String getGameId() {
|
||||
return _gameId;
|
||||
}
|
||||
|
||||
public static IUnityAdsListener getListener() {
|
||||
return _listener;
|
||||
}
|
||||
|
||||
public static boolean isAppDebuggable() {
|
||||
boolean z;
|
||||
if (getApplicationContext() == null) {
|
||||
return false;
|
||||
}
|
||||
PackageManager packageManager = getApplicationContext().getPackageManager();
|
||||
String packageName = getApplicationContext().getPackageName();
|
||||
try {
|
||||
ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName, 0);
|
||||
int i = applicationInfo.flags & 2;
|
||||
applicationInfo.flags = i;
|
||||
z = i != 0;
|
||||
r4 = false;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
DeviceLog.exception("Could not find name", e);
|
||||
z = false;
|
||||
}
|
||||
if (r4) {
|
||||
try {
|
||||
for (Signature signature : packageManager.getPackageInfo(packageName, 64).signatures) {
|
||||
z = ((X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(signature.toByteArray()))).getSubjectX500Principal().equals(DEBUG_CERT);
|
||||
if (z) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e2) {
|
||||
DeviceLog.exception("Could not find name", e2);
|
||||
} catch (CertificateException e3) {
|
||||
DeviceLog.exception("Certificate exception", e3);
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
public static void setActivity(Activity activity) {
|
||||
_activity = new WeakReference<>(activity);
|
||||
}
|
||||
|
||||
public static void setApplication(Application application) {
|
||||
_application = application;
|
||||
}
|
||||
|
||||
public static void setApplicationContext(Context context) {
|
||||
_applicationContext = context;
|
||||
}
|
||||
|
||||
public static void setGameId(String str) {
|
||||
_gameId = str;
|
||||
}
|
||||
|
||||
public static void setListener(IUnityAdsListener iUnityAdsListener) {
|
||||
_listener = iUnityAdsListener;
|
||||
}
|
||||
}
|
129
sources/com/unity3d/ads/properties/SdkProperties.java
Normal file
129
sources/com/unity3d/ads/properties/SdkProperties.java
Normal file
@@ -0,0 +1,129 @@
|
||||
package com.unity3d.ads.properties;
|
||||
|
||||
import android.content.Context;
|
||||
import com.unity3d.ads.BuildConfig;
|
||||
import com.unity3d.ads.cache.CacheDirectory;
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class SdkProperties {
|
||||
private static final String CACHE_DIR_NAME = "UnityAdsCache";
|
||||
private static final String LOCAL_CACHE_FILE_PREFIX = "UnityAdsCache-";
|
||||
private static final String LOCAL_STORAGE_FILE_PREFIX = "UnityAdsStorage-";
|
||||
private static String _configUrl = getDefaultConfigUrl("release");
|
||||
private static CacheDirectory _cacheDirectory = null;
|
||||
private static int _showTimeout = 5000;
|
||||
private static long _initializationTime = 0;
|
||||
private static boolean _initialized = false;
|
||||
private static boolean _reinitialized = false;
|
||||
private static boolean _testMode = false;
|
||||
|
||||
public static File getCacheDirectory() {
|
||||
return getCacheDirectory(ClientProperties.getApplicationContext());
|
||||
}
|
||||
|
||||
public static String getCacheDirectoryName() {
|
||||
return CACHE_DIR_NAME;
|
||||
}
|
||||
|
||||
public static CacheDirectory getCacheDirectoryObject() {
|
||||
return _cacheDirectory;
|
||||
}
|
||||
|
||||
public static String getCacheFilePrefix() {
|
||||
return LOCAL_CACHE_FILE_PREFIX;
|
||||
}
|
||||
|
||||
public static String getConfigUrl() {
|
||||
return _configUrl;
|
||||
}
|
||||
|
||||
public static String getDefaultConfigUrl(String str) {
|
||||
return "https://config.unityads.unity3d.com/webview/" + getWebViewBranch() + "/" + str + "/config.json";
|
||||
}
|
||||
|
||||
public static long getInitializationTime() {
|
||||
return _initializationTime;
|
||||
}
|
||||
|
||||
public static String getLocalStorageFilePrefix() {
|
||||
return LOCAL_STORAGE_FILE_PREFIX;
|
||||
}
|
||||
|
||||
public static String getLocalWebViewFile() {
|
||||
return getCacheDirectory().getAbsolutePath() + "/UnityAdsWebApp.html";
|
||||
}
|
||||
|
||||
public static int getShowTimeout() {
|
||||
return _showTimeout;
|
||||
}
|
||||
|
||||
public static int getVersionCode() {
|
||||
return BuildConfig.VERSION_CODE;
|
||||
}
|
||||
|
||||
public static String getVersionName() {
|
||||
return "2.3.0";
|
||||
}
|
||||
|
||||
private static String getWebViewBranch() {
|
||||
return getVersionName();
|
||||
}
|
||||
|
||||
public static boolean isInitialized() {
|
||||
return _initialized;
|
||||
}
|
||||
|
||||
public static boolean isReinitialized() {
|
||||
return _reinitialized;
|
||||
}
|
||||
|
||||
public static boolean isTestMode() {
|
||||
return _testMode;
|
||||
}
|
||||
|
||||
public static void setCacheDirectory(CacheDirectory cacheDirectory) {
|
||||
_cacheDirectory = cacheDirectory;
|
||||
}
|
||||
|
||||
public static void setConfigUrl(String str) throws URISyntaxException, MalformedURLException {
|
||||
if (str == null) {
|
||||
throw new MalformedURLException();
|
||||
}
|
||||
if (!str.startsWith("http://") && !str.startsWith("https://")) {
|
||||
throw new MalformedURLException();
|
||||
}
|
||||
new URL(str).toURI();
|
||||
_configUrl = str;
|
||||
}
|
||||
|
||||
public static void setInitializationTime(long j) {
|
||||
_initializationTime = j;
|
||||
}
|
||||
|
||||
public static void setInitialized(boolean z) {
|
||||
_initialized = z;
|
||||
}
|
||||
|
||||
public static void setReinitialized(boolean z) {
|
||||
_reinitialized = z;
|
||||
}
|
||||
|
||||
public static void setShowTimeout(int i) {
|
||||
_showTimeout = i;
|
||||
}
|
||||
|
||||
public static void setTestMode(boolean z) {
|
||||
_testMode = z;
|
||||
}
|
||||
|
||||
public static File getCacheDirectory(Context context) {
|
||||
if (_cacheDirectory == null) {
|
||||
setCacheDirectory(new CacheDirectory(CACHE_DIR_NAME));
|
||||
}
|
||||
return _cacheDirectory.getCacheDirectory(context);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user