Initial commit
This commit is contained in:
191
sources/com/unity3d/ads/device/AdvertisingId.java
Normal file
191
sources/com/unity3d/ads/device/AdvertisingId.java
Normal file
@@ -0,0 +1,191 @@
|
||||
package com.unity3d.ads.device;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.os.IInterface;
|
||||
import android.os.Parcel;
|
||||
import android.os.RemoteException;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
@TargetApi(9)
|
||||
/* loaded from: classes2.dex */
|
||||
public class AdvertisingId {
|
||||
private static final String ADVERTISING_ID_SERVICE_NAME = "com.google.android.gms.ads.identifier.internal.IAdvertisingIdService";
|
||||
private static AdvertisingId instance;
|
||||
private String advertisingIdentifier = null;
|
||||
private boolean limitedAdvertisingTracking = false;
|
||||
|
||||
private interface GoogleAdvertisingInfo extends IInterface {
|
||||
|
||||
public static abstract class GoogleAdvertisingInfoBinder extends Binder implements GoogleAdvertisingInfo {
|
||||
|
||||
private static class GoogleAdvertisingInfoImplementation implements GoogleAdvertisingInfo {
|
||||
private final IBinder _binder;
|
||||
|
||||
GoogleAdvertisingInfoImplementation(IBinder iBinder) {
|
||||
this._binder = iBinder;
|
||||
}
|
||||
|
||||
@Override // android.os.IInterface
|
||||
public IBinder asBinder() {
|
||||
return this._binder;
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.device.AdvertisingId.GoogleAdvertisingInfo
|
||||
public boolean getEnabled(boolean z) throws RemoteException {
|
||||
Parcel obtain = Parcel.obtain();
|
||||
Parcel obtain2 = Parcel.obtain();
|
||||
try {
|
||||
obtain.writeInterfaceToken(AdvertisingId.ADVERTISING_ID_SERVICE_NAME);
|
||||
obtain.writeInt(z ? 1 : 0);
|
||||
this._binder.transact(2, obtain, obtain2, 0);
|
||||
obtain2.readException();
|
||||
return obtain2.readInt() != 0;
|
||||
} finally {
|
||||
obtain2.recycle();
|
||||
obtain.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.device.AdvertisingId.GoogleAdvertisingInfo
|
||||
public String getId() throws RemoteException {
|
||||
Parcel obtain = Parcel.obtain();
|
||||
Parcel obtain2 = Parcel.obtain();
|
||||
try {
|
||||
obtain.writeInterfaceToken(AdvertisingId.ADVERTISING_ID_SERVICE_NAME);
|
||||
this._binder.transact(1, obtain, obtain2, 0);
|
||||
obtain2.readException();
|
||||
return obtain2.readString();
|
||||
} finally {
|
||||
obtain2.recycle();
|
||||
obtain.recycle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static GoogleAdvertisingInfo create(IBinder iBinder) {
|
||||
if (iBinder == null) {
|
||||
return null;
|
||||
}
|
||||
IInterface queryLocalInterface = iBinder.queryLocalInterface(AdvertisingId.ADVERTISING_ID_SERVICE_NAME);
|
||||
return (queryLocalInterface == null || !(queryLocalInterface instanceof GoogleAdvertisingInfo)) ? new GoogleAdvertisingInfoImplementation(iBinder) : (GoogleAdvertisingInfo) queryLocalInterface;
|
||||
}
|
||||
|
||||
@Override // android.os.Binder
|
||||
public boolean onTransact(int i, Parcel parcel, Parcel parcel2, int i2) throws RemoteException {
|
||||
if (i == 1) {
|
||||
parcel.enforceInterface(AdvertisingId.ADVERTISING_ID_SERVICE_NAME);
|
||||
String id = getId();
|
||||
parcel2.writeNoException();
|
||||
parcel2.writeString(id);
|
||||
return true;
|
||||
}
|
||||
if (i != 2) {
|
||||
return super.onTransact(i, parcel, parcel2, i2);
|
||||
}
|
||||
parcel.enforceInterface(AdvertisingId.ADVERTISING_ID_SERVICE_NAME);
|
||||
boolean enabled = getEnabled(parcel.readInt() != 0);
|
||||
parcel2.writeNoException();
|
||||
parcel2.writeInt(enabled ? 1 : 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
boolean getEnabled(boolean z) throws RemoteException;
|
||||
|
||||
String getId() throws RemoteException;
|
||||
}
|
||||
|
||||
private class GoogleAdvertisingServiceConnection implements ServiceConnection {
|
||||
private final BlockingQueue<IBinder> _binderQueue;
|
||||
boolean _consumed;
|
||||
|
||||
private GoogleAdvertisingServiceConnection() {
|
||||
this._consumed = false;
|
||||
this._binderQueue = new LinkedBlockingQueue();
|
||||
}
|
||||
|
||||
public IBinder getBinder() throws InterruptedException {
|
||||
if (this._consumed) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
this._consumed = true;
|
||||
return this._binderQueue.take();
|
||||
}
|
||||
|
||||
@Override // android.content.ServiceConnection
|
||||
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
||||
try {
|
||||
this._binderQueue.put(iBinder);
|
||||
} catch (InterruptedException unused) {
|
||||
DeviceLog.debug("Couldn't put service to binder que");
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.content.ServiceConnection
|
||||
public void onServiceDisconnected(ComponentName componentName) {
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchAdvertisingId(Context context) {
|
||||
boolean z;
|
||||
GoogleAdvertisingServiceConnection googleAdvertisingServiceConnection = new GoogleAdvertisingServiceConnection();
|
||||
Intent intent = new Intent("com.google.android.gms.ads.identifier.service.START");
|
||||
intent.setPackage("com.google.android.gms");
|
||||
try {
|
||||
z = context.bindService(intent, googleAdvertisingServiceConnection, 1);
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Couldn't bind to identifier service intent", e);
|
||||
z = false;
|
||||
}
|
||||
try {
|
||||
if (z) {
|
||||
try {
|
||||
GoogleAdvertisingInfo create = GoogleAdvertisingInfo.GoogleAdvertisingInfoBinder.create(googleAdvertisingServiceConnection.getBinder());
|
||||
this.advertisingIdentifier = create.getId();
|
||||
this.limitedAdvertisingTracking = create.getEnabled(true);
|
||||
} catch (Exception e2) {
|
||||
DeviceLog.exception("Couldn't get advertising info", e2);
|
||||
if (!z) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!z) {
|
||||
return;
|
||||
}
|
||||
context.unbindService(googleAdvertisingServiceConnection);
|
||||
} catch (Throwable th) {
|
||||
if (z) {
|
||||
context.unbindService(googleAdvertisingServiceConnection);
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getAdvertisingTrackingId() {
|
||||
return getInstance().advertisingIdentifier;
|
||||
}
|
||||
|
||||
private static AdvertisingId getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new AdvertisingId();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static boolean getLimitedAdTracking() {
|
||||
return getInstance().limitedAdvertisingTracking;
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
getInstance().fetchAdvertisingId(context);
|
||||
}
|
||||
}
|
634
sources/com/unity3d/ads/device/Device.java
Normal file
634
sources/com/unity3d/ads/device/Device.java
Normal file
@@ -0,0 +1,634 @@
|
||||
package com.unity3d.ads.device;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ConfigurationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.Signature;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorManager;
|
||||
import android.media.AudioManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.os.SystemClock;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.TelephonyManager;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.metadata.MediationMetaData;
|
||||
import com.unity3d.ads.misc.Utilities;
|
||||
import com.unity3d.ads.properties.ClientProperties;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Device {
|
||||
|
||||
/* renamed from: com.unity3d.ads.device.Device$1, reason: invalid class name */
|
||||
static /* synthetic */ class AnonymousClass1 {
|
||||
static final /* synthetic */ int[] $SwitchMap$com$unity3d$ads$device$Device$MemoryInfoType = new int[MemoryInfoType.values().length];
|
||||
|
||||
static {
|
||||
try {
|
||||
$SwitchMap$com$unity3d$ads$device$Device$MemoryInfoType[MemoryInfoType.TOTAL_MEMORY.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError unused) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$unity3d$ads$device$Device$MemoryInfoType[MemoryInfoType.FREE_MEMORY.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError unused2) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum MemoryInfoType {
|
||||
TOTAL_MEMORY,
|
||||
FREE_MEMORY
|
||||
}
|
||||
|
||||
public static String getAdvertisingTrackingId() {
|
||||
return AdvertisingId.getAdvertisingTrackingId();
|
||||
}
|
||||
|
||||
@SuppressLint({"DefaultLocale"})
|
||||
public static String getAndroidId() {
|
||||
try {
|
||||
return Settings.Secure.getString(ClientProperties.getApplicationContext().getContentResolver(), "android_id");
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Problems fetching androidId", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getApiLevel() {
|
||||
return Build.VERSION.SDK_INT;
|
||||
}
|
||||
|
||||
public static String getApkDigest() throws Exception {
|
||||
FileInputStream fileInputStream;
|
||||
FileInputStream fileInputStream2 = null;
|
||||
try {
|
||||
fileInputStream = new FileInputStream(new File(ClientProperties.getApplicationContext().getPackageCodePath()));
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
}
|
||||
try {
|
||||
String Sha256 = Utilities.Sha256(fileInputStream);
|
||||
try {
|
||||
fileInputStream.close();
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
return Sha256;
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
fileInputStream2 = fileInputStream;
|
||||
if (fileInputStream2 != null) {
|
||||
try {
|
||||
fileInputStream2.close();
|
||||
} catch (IOException unused2) {
|
||||
}
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
public static float getBatteryLevel() {
|
||||
Intent registerReceiver;
|
||||
if (ClientProperties.getApplicationContext() == null || (registerReceiver = ClientProperties.getApplicationContext().registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED"))) == null) {
|
||||
return -1.0f;
|
||||
}
|
||||
return registerReceiver.getIntExtra("level", -1) / registerReceiver.getIntExtra("scale", -1);
|
||||
}
|
||||
|
||||
public static int getBatteryStatus() {
|
||||
Intent registerReceiver;
|
||||
if (ClientProperties.getApplicationContext() == null || (registerReceiver = ClientProperties.getApplicationContext().registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED"))) == null) {
|
||||
return -1;
|
||||
}
|
||||
return registerReceiver.getIntExtra(FileDownloadModel.STATUS, -1);
|
||||
}
|
||||
|
||||
public static String getBoard() {
|
||||
return Build.BOARD;
|
||||
}
|
||||
|
||||
public static String getBootloader() {
|
||||
return Build.BOOTLOADER;
|
||||
}
|
||||
|
||||
public static String getBrand() {
|
||||
return Build.BRAND;
|
||||
}
|
||||
|
||||
public static String getBuildId() {
|
||||
return Build.ID;
|
||||
}
|
||||
|
||||
public static String getBuildVersionIncremental() {
|
||||
return Build.VERSION.INCREMENTAL;
|
||||
}
|
||||
|
||||
public static long getCPUCount() {
|
||||
return Runtime.getRuntime().availableProcessors();
|
||||
}
|
||||
|
||||
public static String getCertificateFingerprint() {
|
||||
try {
|
||||
Signature[] signatureArr = ClientProperties.getApplicationContext().getPackageManager().getPackageInfo(ClientProperties.getApplicationContext().getPackageName(), 64).signatures;
|
||||
if (signatureArr == null || signatureArr.length < 1) {
|
||||
return null;
|
||||
}
|
||||
return Utilities.toHexString(MessageDigest.getInstance("SHA-1").digest(((X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(signatureArr[0].toByteArray()))).getEncoded()));
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Exception when signing certificate fingerprint", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDevice() {
|
||||
return Build.DEVICE;
|
||||
}
|
||||
|
||||
public static long getElapsedRealtime() {
|
||||
return SystemClock.elapsedRealtime();
|
||||
}
|
||||
|
||||
public static String getFingerprint() {
|
||||
return Build.FINGERPRINT;
|
||||
}
|
||||
|
||||
public static long getFreeMemory() {
|
||||
return getMemoryInfo(MemoryInfoType.FREE_MEMORY);
|
||||
}
|
||||
|
||||
public static long getFreeSpace(File file) {
|
||||
if (file == null || !file.exists()) {
|
||||
return -1L;
|
||||
}
|
||||
return Math.round(file.getFreeSpace() / 1024);
|
||||
}
|
||||
|
||||
public static String getGLVersion() {
|
||||
ActivityManager activityManager;
|
||||
ConfigurationInfo deviceConfigurationInfo;
|
||||
if (ClientProperties.getApplicationContext() == null || (activityManager = (ActivityManager) ClientProperties.getApplicationContext().getSystemService("activity")) == null || (deviceConfigurationInfo = activityManager.getDeviceConfigurationInfo()) == null) {
|
||||
return null;
|
||||
}
|
||||
return deviceConfigurationInfo.getGlEsVersion();
|
||||
}
|
||||
|
||||
public static String getHardware() {
|
||||
return Build.HARDWARE;
|
||||
}
|
||||
|
||||
public static String getHost() {
|
||||
return Build.HOST;
|
||||
}
|
||||
|
||||
public static List<Map<String, Object>> getInstalledPackages(boolean z) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
if (ClientProperties.getApplicationContext() != null) {
|
||||
PackageManager packageManager = ClientProperties.getApplicationContext().getPackageManager();
|
||||
for (PackageInfo packageInfo : packageManager.getInstalledPackages(0)) {
|
||||
HashMap hashMap = new HashMap();
|
||||
if (z) {
|
||||
hashMap.put(MediationMetaData.KEY_NAME, Utilities.Sha256(packageInfo.packageName));
|
||||
} else {
|
||||
hashMap.put(MediationMetaData.KEY_NAME, packageInfo.packageName);
|
||||
}
|
||||
long j = packageInfo.firstInstallTime;
|
||||
if (j > 0) {
|
||||
hashMap.put("time", Long.valueOf(j));
|
||||
}
|
||||
String installerPackageName = packageManager.getInstallerPackageName(packageInfo.packageName);
|
||||
if (installerPackageName != null && !installerPackageName.isEmpty()) {
|
||||
hashMap.put("installer", installerPackageName);
|
||||
}
|
||||
arrayList.add(hashMap);
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public static String getManufacturer() {
|
||||
return Build.MANUFACTURER;
|
||||
}
|
||||
|
||||
private static long getMemoryInfo(MemoryInfoType memoryInfoType) {
|
||||
int i = AnonymousClass1.$SwitchMap$com$unity3d$ads$device$Device$MemoryInfoType[memoryInfoType.ordinal()];
|
||||
int i2 = 2;
|
||||
if (i == 1) {
|
||||
i2 = 1;
|
||||
} else if (i != 2) {
|
||||
i2 = -1;
|
||||
}
|
||||
RandomAccessFile randomAccessFile = null;
|
||||
String str = null;
|
||||
RandomAccessFile randomAccessFile2 = null;
|
||||
try {
|
||||
try {
|
||||
RandomAccessFile randomAccessFile3 = new RandomAccessFile("/proc/meminfo", "r");
|
||||
for (int i3 = 0; i3 < i2; i3++) {
|
||||
try {
|
||||
str = randomAccessFile3.readLine();
|
||||
} catch (IOException e) {
|
||||
e = e;
|
||||
randomAccessFile = randomAccessFile3;
|
||||
DeviceLog.exception("Error while reading memory info: " + memoryInfoType, e);
|
||||
try {
|
||||
randomAccessFile.close();
|
||||
return -1L;
|
||||
} catch (IOException e2) {
|
||||
DeviceLog.exception("Error closing RandomAccessFile", e2);
|
||||
return -1L;
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
randomAccessFile2 = randomAccessFile3;
|
||||
try {
|
||||
randomAccessFile2.close();
|
||||
} catch (IOException e3) {
|
||||
DeviceLog.exception("Error closing RandomAccessFile", e3);
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
long memoryValueFromString = getMemoryValueFromString(str);
|
||||
try {
|
||||
randomAccessFile3.close();
|
||||
} catch (IOException e4) {
|
||||
DeviceLog.exception("Error closing RandomAccessFile", e4);
|
||||
}
|
||||
return memoryValueFromString;
|
||||
} catch (IOException e5) {
|
||||
e = e5;
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
}
|
||||
}
|
||||
|
||||
private static long getMemoryValueFromString(String str) {
|
||||
if (str == null) {
|
||||
return -1L;
|
||||
}
|
||||
Matcher matcher = Pattern.compile("(\\d+)").matcher(str);
|
||||
String str2 = "";
|
||||
while (matcher.find()) {
|
||||
str2 = matcher.group(1);
|
||||
}
|
||||
return Long.parseLong(str2);
|
||||
}
|
||||
|
||||
public static String getModel() {
|
||||
return Build.MODEL;
|
||||
}
|
||||
|
||||
public static boolean getNetworkMetered() {
|
||||
ConnectivityManager connectivityManager;
|
||||
if (ClientProperties.getApplicationContext() == null || Build.VERSION.SDK_INT < 16 || (connectivityManager = (ConnectivityManager) ClientProperties.getApplicationContext().getSystemService("connectivity")) == null) {
|
||||
return false;
|
||||
}
|
||||
return connectivityManager.isActiveNetworkMetered();
|
||||
}
|
||||
|
||||
public static String getNetworkOperator() {
|
||||
return ClientProperties.getApplicationContext() != null ? ((TelephonyManager) ClientProperties.getApplicationContext().getSystemService("phone")).getNetworkOperator() : "";
|
||||
}
|
||||
|
||||
public static String getNetworkOperatorName() {
|
||||
return ClientProperties.getApplicationContext() != null ? ((TelephonyManager) ClientProperties.getApplicationContext().getSystemService("phone")).getNetworkOperatorName() : "";
|
||||
}
|
||||
|
||||
public static int getNetworkType() {
|
||||
if (ClientProperties.getApplicationContext() != null) {
|
||||
return ((TelephonyManager) ClientProperties.getApplicationContext().getSystemService("phone")).getNetworkType();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
private static ArrayList<String> getNewAbiList() {
|
||||
ArrayList<String> arrayList = new ArrayList<>();
|
||||
arrayList.addAll(Arrays.asList(Build.SUPPORTED_ABIS));
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private static ArrayList<String> getOldAbiList() {
|
||||
ArrayList<String> arrayList = new ArrayList<>();
|
||||
arrayList.add(Build.CPU_ABI);
|
||||
arrayList.add(Build.CPU_ABI2);
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public static String getOsVersion() {
|
||||
return Build.VERSION.RELEASE;
|
||||
}
|
||||
|
||||
/* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:49:0x0021 -> B:7:0x0034). Please report as a decompilation issue!!! */
|
||||
public static Map<String, String> getProcessInfo() {
|
||||
RandomAccessFile randomAccessFile;
|
||||
IOException e;
|
||||
RandomAccessFile randomAccessFile2;
|
||||
HashMap hashMap = new HashMap();
|
||||
try {
|
||||
try {
|
||||
randomAccessFile = new RandomAccessFile("/proc/self/stat", "r");
|
||||
} catch (IOException e2) {
|
||||
randomAccessFile = null;
|
||||
e = e2;
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
randomAccessFile = null;
|
||||
try {
|
||||
randomAccessFile.close();
|
||||
} catch (IOException e3) {
|
||||
DeviceLog.exception("Error closing RandomAccessFile", e3);
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
} catch (IOException e4) {
|
||||
DeviceLog.exception("Error closing RandomAccessFile", e4);
|
||||
}
|
||||
try {
|
||||
try {
|
||||
hashMap.put("stat", randomAccessFile.readLine());
|
||||
randomAccessFile.close();
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
randomAccessFile.close();
|
||||
throw th;
|
||||
}
|
||||
} catch (IOException e5) {
|
||||
e = e5;
|
||||
DeviceLog.exception("Error while reading processor info: ", e);
|
||||
randomAccessFile.close();
|
||||
try {
|
||||
try {
|
||||
randomAccessFile2 = new RandomAccessFile("/proc/uptime", "r");
|
||||
try {
|
||||
hashMap.put("uptime", randomAccessFile2.readLine());
|
||||
randomAccessFile2.close();
|
||||
} catch (IOException e6) {
|
||||
e = e6;
|
||||
randomAccessFile = randomAccessFile2;
|
||||
DeviceLog.exception("Error while reading processor info: ", e);
|
||||
randomAccessFile.close();
|
||||
return hashMap;
|
||||
} catch (Throwable th3) {
|
||||
th = th3;
|
||||
randomAccessFile = randomAccessFile2;
|
||||
try {
|
||||
randomAccessFile.close();
|
||||
} catch (IOException e7) {
|
||||
DeviceLog.exception("Error closing RandomAccessFile", e7);
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
} catch (Throwable th4) {
|
||||
th = th4;
|
||||
}
|
||||
} catch (IOException e8) {
|
||||
e = e8;
|
||||
}
|
||||
return hashMap;
|
||||
}
|
||||
try {
|
||||
randomAccessFile2 = new RandomAccessFile("/proc/uptime", "r");
|
||||
hashMap.put("uptime", randomAccessFile2.readLine());
|
||||
randomAccessFile2.close();
|
||||
} catch (IOException e9) {
|
||||
DeviceLog.exception("Error closing RandomAccessFile", e9);
|
||||
}
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
public static String getProduct() {
|
||||
return Build.PRODUCT;
|
||||
}
|
||||
|
||||
public static int getRingerMode() {
|
||||
if (ClientProperties.getApplicationContext() == null) {
|
||||
return -1;
|
||||
}
|
||||
AudioManager audioManager = (AudioManager) ClientProperties.getApplicationContext().getSystemService("audio");
|
||||
if (audioManager != null) {
|
||||
return audioManager.getRingerMode();
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
|
||||
public static int getScreenBrightness() {
|
||||
if (ClientProperties.getApplicationContext() != null) {
|
||||
return Settings.System.getInt(ClientProperties.getApplicationContext().getContentResolver(), "screen_brightness", -1);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int getScreenDensity() {
|
||||
if (ClientProperties.getApplicationContext() != null) {
|
||||
return ClientProperties.getApplicationContext().getResources().getDisplayMetrics().densityDpi;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int getScreenHeight() {
|
||||
if (ClientProperties.getApplicationContext() != null) {
|
||||
return ClientProperties.getApplicationContext().getResources().getDisplayMetrics().heightPixels;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int getScreenLayout() {
|
||||
if (ClientProperties.getApplicationContext() != null) {
|
||||
return ClientProperties.getApplicationContext().getResources().getConfiguration().screenLayout;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int getScreenWidth() {
|
||||
if (ClientProperties.getApplicationContext() != null) {
|
||||
return ClientProperties.getApplicationContext().getResources().getDisplayMetrics().widthPixels;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static List<Sensor> getSensorList() {
|
||||
if (ClientProperties.getApplicationContext() != null) {
|
||||
return ((SensorManager) ClientProperties.getApplicationContext().getSystemService("sensor")).getSensorList(-1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getStreamMaxVolume(int i) {
|
||||
if (ClientProperties.getApplicationContext() == null) {
|
||||
return -1;
|
||||
}
|
||||
AudioManager audioManager = (AudioManager) ClientProperties.getApplicationContext().getSystemService("audio");
|
||||
if (audioManager != null) {
|
||||
return audioManager.getStreamMaxVolume(i);
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
|
||||
public static int getStreamVolume(int i) {
|
||||
if (ClientProperties.getApplicationContext() == null) {
|
||||
return -1;
|
||||
}
|
||||
AudioManager audioManager = (AudioManager) ClientProperties.getApplicationContext().getSystemService("audio");
|
||||
if (audioManager != null) {
|
||||
return audioManager.getStreamVolume(i);
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
|
||||
public static ArrayList<String> getSupportedAbis() {
|
||||
return getApiLevel() < 21 ? getOldAbiList() : getNewAbiList();
|
||||
}
|
||||
|
||||
public static String getSystemProperty(String str, String str2) {
|
||||
return str2 != null ? System.getProperty(str, str2) : System.getProperty(str);
|
||||
}
|
||||
|
||||
public static long getTotalMemory() {
|
||||
return getMemoryInfo(MemoryInfoType.TOTAL_MEMORY);
|
||||
}
|
||||
|
||||
public static long getTotalSpace(File file) {
|
||||
if (file == null || !file.exists()) {
|
||||
return -1L;
|
||||
}
|
||||
return Math.round(file.getTotalSpace() / 1024);
|
||||
}
|
||||
|
||||
public static String getUniqueEventId() {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public static long getUptime() {
|
||||
return SystemClock.uptimeMillis();
|
||||
}
|
||||
|
||||
public static boolean isActiveNetworkConnected() {
|
||||
ConnectivityManager connectivityManager;
|
||||
NetworkInfo activeNetworkInfo;
|
||||
return (ClientProperties.getApplicationContext() == null || (connectivityManager = (ConnectivityManager) ClientProperties.getApplicationContext().getSystemService("connectivity")) == null || (activeNetworkInfo = connectivityManager.getActiveNetworkInfo()) == null || !activeNetworkInfo.isConnected()) ? false : true;
|
||||
}
|
||||
|
||||
public static Boolean isAdbEnabled() {
|
||||
return getApiLevel() < 17 ? oldAdbStatus() : newAdbStatus();
|
||||
}
|
||||
|
||||
public static boolean isAppInstalled(String str) {
|
||||
if (ClientProperties.getApplicationContext() != null) {
|
||||
try {
|
||||
PackageInfo packageInfo = ClientProperties.getApplicationContext().getPackageManager().getPackageInfo(str, 0);
|
||||
if (packageInfo != null && packageInfo.packageName != null) {
|
||||
if (str.equals(packageInfo.packageName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException unused) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isLimitAdTrackingEnabled() {
|
||||
return AdvertisingId.getLimitedAdTracking();
|
||||
}
|
||||
|
||||
public static boolean isRooted() {
|
||||
try {
|
||||
return searchPathForBinary("su");
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Rooted check failed", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isUSBConnected() {
|
||||
Intent registerReceiver;
|
||||
if (ClientProperties.getApplicationContext() == null || (registerReceiver = ClientProperties.getApplicationContext().registerReceiver(null, new IntentFilter("android.hardware.usb.action.USB_STATE"))) == null) {
|
||||
return false;
|
||||
}
|
||||
return registerReceiver.getBooleanExtra("connected", false);
|
||||
}
|
||||
|
||||
public static boolean isUsingWifi() {
|
||||
ConnectivityManager connectivityManager;
|
||||
if (ClientProperties.getApplicationContext() == null || (connectivityManager = (ConnectivityManager) ClientProperties.getApplicationContext().getSystemService("connectivity")) == null) {
|
||||
return false;
|
||||
}
|
||||
TelephonyManager telephonyManager = (TelephonyManager) ClientProperties.getApplicationContext().getSystemService("phone");
|
||||
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
|
||||
return activeNetworkInfo != null && connectivityManager.getBackgroundDataSetting() && connectivityManager.getActiveNetworkInfo().isConnected() && telephonyManager != null && activeNetworkInfo.getType() == 1 && activeNetworkInfo.isConnected();
|
||||
}
|
||||
|
||||
public static boolean isWiredHeadsetOn() {
|
||||
if (ClientProperties.getApplicationContext() != null) {
|
||||
return ((AudioManager) ClientProperties.getApplicationContext().getSystemService("audio")).isWiredHeadsetOn();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@TargetApi(17)
|
||||
private static Boolean newAdbStatus() {
|
||||
try {
|
||||
boolean z = true;
|
||||
if (1 != Settings.Global.getInt(ClientProperties.getApplicationContext().getContentResolver(), "adb_enabled", 0)) {
|
||||
z = false;
|
||||
}
|
||||
return Boolean.valueOf(z);
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Problems fetching adb enabled status", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Boolean oldAdbStatus() {
|
||||
try {
|
||||
boolean z = true;
|
||||
if (1 != Settings.Secure.getInt(ClientProperties.getApplicationContext().getContentResolver(), "adb_enabled", 0)) {
|
||||
z = false;
|
||||
}
|
||||
return Boolean.valueOf(z);
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Problems fetching adb enabled status", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean searchPathForBinary(String str) {
|
||||
File[] listFiles;
|
||||
for (String str2 : System.getenv("PATH").split(":")) {
|
||||
File file = new File(str2);
|
||||
if (file.exists() && file.isDirectory() && (listFiles = file.listFiles()) != null) {
|
||||
for (File file2 : listFiles) {
|
||||
if (file2.getName().equals(str)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
15
sources/com/unity3d/ads/device/DeviceError.java
Normal file
15
sources/com/unity3d/ads/device/DeviceError.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.unity3d.ads.device;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum DeviceError {
|
||||
APPLICATION_CONTEXT_NULL,
|
||||
APPLICATION_INFO_NOT_AVAILABLE,
|
||||
AUDIOMANAGER_NULL,
|
||||
INVALID_STORAGETYPE,
|
||||
COULDNT_GET_STORAGE_LOCATION,
|
||||
COULDNT_GET_GL_VERSION,
|
||||
JSON_ERROR,
|
||||
COULDNT_GET_DIGEST,
|
||||
COULDNT_GET_FINGERPRINT,
|
||||
COULDNT_GET_ADB_STATUS
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package com.unity3d.ads.device;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface IVolumeChangeListener {
|
||||
int getStreamType();
|
||||
|
||||
void onVolumeChanged(int i);
|
||||
}
|
68
sources/com/unity3d/ads/device/Storage.java
Normal file
68
sources/com/unity3d/ads/device/Storage.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package com.unity3d.ads.device;
|
||||
|
||||
import com.unity3d.ads.device.StorageManager;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.misc.JsonStorage;
|
||||
import com.unity3d.ads.misc.Utilities;
|
||||
import com.unity3d.ads.webview.WebViewApp;
|
||||
import com.unity3d.ads.webview.WebViewEventCategory;
|
||||
import java.io.File;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Storage extends JsonStorage {
|
||||
private String _targetFileName;
|
||||
private StorageManager.StorageType _type;
|
||||
|
||||
public Storage(String str, StorageManager.StorageType storageType) {
|
||||
this._targetFileName = str;
|
||||
this._type = storageType;
|
||||
}
|
||||
|
||||
public synchronized boolean clearStorage() {
|
||||
clearData();
|
||||
return new File(this._targetFileName).delete();
|
||||
}
|
||||
|
||||
public StorageManager.StorageType getType() {
|
||||
return this._type;
|
||||
}
|
||||
|
||||
public synchronized boolean initStorage() {
|
||||
readStorage();
|
||||
super.initData();
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized boolean readStorage() {
|
||||
File file = new File(this._targetFileName);
|
||||
if (Utilities.readFile(file) == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
setData(new JSONObject(Utilities.readFile(file)));
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error creating storage JSON", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void sendEvent(StorageEvent storageEvent, Object obj) {
|
||||
if (!(WebViewApp.getCurrentApp() != null ? WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.STORAGE, storageEvent, this._type.name(), obj) : false)) {
|
||||
DeviceLog.debug("Couldn't send storage event to WebApp");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized boolean storageFileExists() {
|
||||
return new File(this._targetFileName).exists();
|
||||
}
|
||||
|
||||
public synchronized boolean writeStorage() {
|
||||
File file = new File(this._targetFileName);
|
||||
if (getData() == null) {
|
||||
return false;
|
||||
}
|
||||
return Utilities.writeFile(file, getData().toString());
|
||||
}
|
||||
}
|
11
sources/com/unity3d/ads/device/StorageError.java
Normal file
11
sources/com/unity3d/ads/device/StorageError.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.unity3d.ads.device;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum StorageError {
|
||||
COULDNT_SET_VALUE,
|
||||
COULDNT_GET_VALUE,
|
||||
COULDNT_WRITE_STORAGE_TO_CACHE,
|
||||
COULDNT_CLEAR_STORAGE,
|
||||
COULDNT_GET_STORAGE,
|
||||
COULDNT_DELETE_VALUE
|
||||
}
|
11
sources/com/unity3d/ads/device/StorageEvent.java
Normal file
11
sources/com/unity3d/ads/device/StorageEvent.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.unity3d.ads.device;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum StorageEvent {
|
||||
SET,
|
||||
DELETE,
|
||||
CLEAR,
|
||||
WRITE,
|
||||
READ,
|
||||
INIT
|
||||
}
|
108
sources/com/unity3d/ads/device/StorageManager.java
Normal file
108
sources/com/unity3d/ads/device/StorageManager.java
Normal file
@@ -0,0 +1,108 @@
|
||||
package com.unity3d.ads.device;
|
||||
|
||||
import android.content.Context;
|
||||
import com.unity3d.ads.properties.SdkProperties;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class StorageManager {
|
||||
protected static final Map<StorageType, String> _storageFileMap = new HashMap();
|
||||
protected static final List<Storage> _storages = new ArrayList();
|
||||
|
||||
public enum StorageType {
|
||||
PRIVATE,
|
||||
PUBLIC
|
||||
}
|
||||
|
||||
public static synchronized void addStorageLocation(StorageType storageType, String str) {
|
||||
synchronized (StorageManager.class) {
|
||||
if (!_storageFileMap.containsKey(storageType)) {
|
||||
_storageFileMap.put(storageType, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Storage getStorage(StorageType storageType) {
|
||||
List<Storage> list = _storages;
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
for (Storage storage : list) {
|
||||
if (storage.getType().equals(storageType)) {
|
||||
return storage;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean hasStorage(StorageType storageType) {
|
||||
List<Storage> list = _storages;
|
||||
if (list == null) {
|
||||
return false;
|
||||
}
|
||||
Iterator<Storage> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
if (it.next().getType().equals(storageType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean init(Context context) {
|
||||
File filesDir;
|
||||
if (context == null || (filesDir = context.getFilesDir()) == null) {
|
||||
return false;
|
||||
}
|
||||
addStorageLocation(StorageType.PUBLIC, filesDir + "/" + SdkProperties.getLocalStorageFilePrefix() + "public-data.json");
|
||||
if (!setupStorage(StorageType.PUBLIC)) {
|
||||
return false;
|
||||
}
|
||||
addStorageLocation(StorageType.PRIVATE, filesDir + "/" + SdkProperties.getLocalStorageFilePrefix() + "private-data.json");
|
||||
return setupStorage(StorageType.PRIVATE);
|
||||
}
|
||||
|
||||
public static void initStorage(StorageType storageType) {
|
||||
if (hasStorage(storageType)) {
|
||||
Storage storage = getStorage(storageType);
|
||||
if (storage != null) {
|
||||
storage.initStorage();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (_storageFileMap.containsKey(storageType)) {
|
||||
Storage storage2 = new Storage(_storageFileMap.get(storageType), storageType);
|
||||
storage2.initStorage();
|
||||
_storages.add(storage2);
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void removeStorage(StorageType storageType) {
|
||||
synchronized (StorageManager.class) {
|
||||
if (getStorage(storageType) != null) {
|
||||
_storages.remove(getStorage(storageType));
|
||||
}
|
||||
if (_storageFileMap != null) {
|
||||
_storageFileMap.remove(storageType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean setupStorage(StorageType storageType) {
|
||||
if (hasStorage(storageType)) {
|
||||
return true;
|
||||
}
|
||||
initStorage(storageType);
|
||||
Storage storage = getStorage(storageType);
|
||||
if (storage != null && !storage.storageFileExists()) {
|
||||
storage.writeStorage();
|
||||
}
|
||||
return storage != null;
|
||||
}
|
||||
}
|
93
sources/com/unity3d/ads/device/VolumeChange.java
Normal file
93
sources/com/unity3d/ads/device/VolumeChange.java
Normal file
@@ -0,0 +1,93 @@
|
||||
package com.unity3d.ads.device;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
import com.unity3d.ads.properties.ClientProperties;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class VolumeChange {
|
||||
private static ContentObserver _contentObserver;
|
||||
private static ArrayList<IVolumeChangeListener> _listeners;
|
||||
|
||||
public static void clearAllListeners() {
|
||||
ArrayList<IVolumeChangeListener> arrayList = _listeners;
|
||||
if (arrayList != null) {
|
||||
arrayList.clear();
|
||||
}
|
||||
stopObservering();
|
||||
_listeners = null;
|
||||
}
|
||||
|
||||
public static void registerListener(IVolumeChangeListener iVolumeChangeListener) {
|
||||
if (_listeners == null) {
|
||||
_listeners = new ArrayList<>();
|
||||
}
|
||||
if (_listeners.contains(iVolumeChangeListener)) {
|
||||
return;
|
||||
}
|
||||
startObserving();
|
||||
_listeners.add(iVolumeChangeListener);
|
||||
}
|
||||
|
||||
public static void startObserving() {
|
||||
ContentResolver contentResolver;
|
||||
if (_contentObserver == null) {
|
||||
_contentObserver = new ContentObserver(new Handler(Looper.getMainLooper())) { // from class: com.unity3d.ads.device.VolumeChange.1
|
||||
@Override // android.database.ContentObserver
|
||||
public boolean deliverSelfNotifications() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // android.database.ContentObserver
|
||||
public void onChange(boolean z, Uri uri) {
|
||||
VolumeChange.triggerListeners();
|
||||
}
|
||||
};
|
||||
Context applicationContext = ClientProperties.getApplicationContext();
|
||||
if (applicationContext == null || (contentResolver = applicationContext.getContentResolver()) == null) {
|
||||
return;
|
||||
}
|
||||
contentResolver.registerContentObserver(Settings.System.CONTENT_URI, true, _contentObserver);
|
||||
}
|
||||
}
|
||||
|
||||
public static void stopObservering() {
|
||||
ContentResolver contentResolver;
|
||||
if (_contentObserver != null) {
|
||||
Context applicationContext = ClientProperties.getApplicationContext();
|
||||
if (applicationContext != null && (contentResolver = applicationContext.getContentResolver()) != null) {
|
||||
contentResolver.unregisterContentObserver(_contentObserver);
|
||||
}
|
||||
_contentObserver = null;
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static void triggerListeners() {
|
||||
ArrayList<IVolumeChangeListener> arrayList = _listeners;
|
||||
if (arrayList != null) {
|
||||
Iterator<IVolumeChangeListener> it = arrayList.iterator();
|
||||
while (it.hasNext()) {
|
||||
IVolumeChangeListener next = it.next();
|
||||
next.onVolumeChanged(Device.getStreamVolume(next.getStreamType()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void unregisterListener(IVolumeChangeListener iVolumeChangeListener) {
|
||||
if (_listeners.contains(iVolumeChangeListener)) {
|
||||
_listeners.remove(iVolumeChangeListener);
|
||||
}
|
||||
ArrayList<IVolumeChangeListener> arrayList = _listeners;
|
||||
if (arrayList == null || arrayList.size() == 0) {
|
||||
stopObservering();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user