- 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
228 lines
7.8 KiB
Java
228 lines
7.8 KiB
Java
package com.google.firebase.perf.config;
|
|
|
|
import android.content.Context;
|
|
import android.content.SharedPreferences;
|
|
import com.google.firebase.FirebaseApp;
|
|
import com.google.firebase.perf.logging.AndroidLogger;
|
|
import com.google.firebase.perf.util.Optional;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.Executors;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public class DeviceCacheManager {
|
|
public static DeviceCacheManager instance;
|
|
public static final AndroidLogger logger = AndroidLogger.getInstance();
|
|
public final ExecutorService serialExecutor;
|
|
public volatile SharedPreferences sharedPref;
|
|
|
|
public DeviceCacheManager(ExecutorService executorService) {
|
|
this.serialExecutor = executorService;
|
|
}
|
|
|
|
public static synchronized DeviceCacheManager getInstance() {
|
|
DeviceCacheManager deviceCacheManager;
|
|
synchronized (DeviceCacheManager.class) {
|
|
try {
|
|
if (instance == null) {
|
|
instance = new DeviceCacheManager(Executors.newSingleThreadExecutor());
|
|
}
|
|
deviceCacheManager = instance;
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
return deviceCacheManager;
|
|
}
|
|
|
|
public synchronized void setContext(final Context context) {
|
|
if (this.sharedPref == null && context != null) {
|
|
this.serialExecutor.execute(new Runnable() { // from class: com.google.firebase.perf.config.DeviceCacheManager$$ExternalSyntheticLambda0
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
DeviceCacheManager.this.lambda$setContext$0(context);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
public final /* synthetic */ void lambda$setContext$0(Context context) {
|
|
if (this.sharedPref != null || context == null) {
|
|
return;
|
|
}
|
|
this.sharedPref = context.getSharedPreferences("FirebasePerfSharedPrefs", 0);
|
|
}
|
|
|
|
public Optional getBoolean(String str) {
|
|
if (str == null) {
|
|
logger.debug("Key is null when getting boolean value on device cache.");
|
|
return Optional.absent();
|
|
}
|
|
if (this.sharedPref == null) {
|
|
setContext(getFirebaseApplicationContext());
|
|
if (this.sharedPref == null) {
|
|
return Optional.absent();
|
|
}
|
|
}
|
|
if (!this.sharedPref.contains(str)) {
|
|
return Optional.absent();
|
|
}
|
|
try {
|
|
return Optional.of(Boolean.valueOf(this.sharedPref.getBoolean(str, false)));
|
|
} catch (ClassCastException e) {
|
|
logger.debug("Key %s from sharedPreferences has type other than long: %s", str, e.getMessage());
|
|
return Optional.absent();
|
|
}
|
|
}
|
|
|
|
public void clear(String str) {
|
|
if (str == null) {
|
|
logger.debug("Key is null. Cannot clear nullable key");
|
|
} else {
|
|
this.sharedPref.edit().remove(str).apply();
|
|
}
|
|
}
|
|
|
|
public boolean setValue(String str, boolean z) {
|
|
if (str == null) {
|
|
logger.debug("Key is null when setting boolean value on device cache.");
|
|
return false;
|
|
}
|
|
if (this.sharedPref == null) {
|
|
setContext(getFirebaseApplicationContext());
|
|
if (this.sharedPref == null) {
|
|
return false;
|
|
}
|
|
}
|
|
this.sharedPref.edit().putBoolean(str, z).apply();
|
|
return true;
|
|
}
|
|
|
|
public Optional getString(String str) {
|
|
if (str == null) {
|
|
logger.debug("Key is null when getting String value on device cache.");
|
|
return Optional.absent();
|
|
}
|
|
if (this.sharedPref == null) {
|
|
setContext(getFirebaseApplicationContext());
|
|
if (this.sharedPref == null) {
|
|
return Optional.absent();
|
|
}
|
|
}
|
|
if (!this.sharedPref.contains(str)) {
|
|
return Optional.absent();
|
|
}
|
|
try {
|
|
return Optional.of(this.sharedPref.getString(str, ""));
|
|
} catch (ClassCastException e) {
|
|
logger.debug("Key %s from sharedPreferences has type other than String: %s", str, e.getMessage());
|
|
return Optional.absent();
|
|
}
|
|
}
|
|
|
|
public boolean setValue(String str, String str2) {
|
|
if (str == null) {
|
|
logger.debug("Key is null when setting String value on device cache.");
|
|
return false;
|
|
}
|
|
if (this.sharedPref == null) {
|
|
setContext(getFirebaseApplicationContext());
|
|
if (this.sharedPref == null) {
|
|
return false;
|
|
}
|
|
}
|
|
if (str2 == null) {
|
|
this.sharedPref.edit().remove(str).apply();
|
|
return true;
|
|
}
|
|
this.sharedPref.edit().putString(str, str2).apply();
|
|
return true;
|
|
}
|
|
|
|
public Optional getDouble(String str) {
|
|
if (str == null) {
|
|
logger.debug("Key is null when getting double value on device cache.");
|
|
return Optional.absent();
|
|
}
|
|
if (this.sharedPref == null) {
|
|
setContext(getFirebaseApplicationContext());
|
|
if (this.sharedPref == null) {
|
|
return Optional.absent();
|
|
}
|
|
}
|
|
if (!this.sharedPref.contains(str)) {
|
|
return Optional.absent();
|
|
}
|
|
try {
|
|
try {
|
|
return Optional.of(Double.valueOf(Double.longBitsToDouble(this.sharedPref.getLong(str, 0L))));
|
|
} catch (ClassCastException unused) {
|
|
return Optional.of(Double.valueOf(Float.valueOf(this.sharedPref.getFloat(str, 0.0f)).doubleValue()));
|
|
}
|
|
} catch (ClassCastException e) {
|
|
logger.debug("Key %s from sharedPreferences has type other than double: %s", str, e.getMessage());
|
|
return Optional.absent();
|
|
}
|
|
}
|
|
|
|
public boolean setValue(String str, double d) {
|
|
if (str == null) {
|
|
logger.debug("Key is null when setting double value on device cache.");
|
|
return false;
|
|
}
|
|
if (this.sharedPref == null) {
|
|
setContext(getFirebaseApplicationContext());
|
|
if (this.sharedPref == null) {
|
|
return false;
|
|
}
|
|
}
|
|
this.sharedPref.edit().putLong(str, Double.doubleToRawLongBits(d)).apply();
|
|
return true;
|
|
}
|
|
|
|
public Optional getLong(String str) {
|
|
if (str == null) {
|
|
logger.debug("Key is null when getting long value on device cache.");
|
|
return Optional.absent();
|
|
}
|
|
if (this.sharedPref == null) {
|
|
setContext(getFirebaseApplicationContext());
|
|
if (this.sharedPref == null) {
|
|
return Optional.absent();
|
|
}
|
|
}
|
|
if (!this.sharedPref.contains(str)) {
|
|
return Optional.absent();
|
|
}
|
|
try {
|
|
return Optional.of(Long.valueOf(this.sharedPref.getLong(str, 0L)));
|
|
} catch (ClassCastException e) {
|
|
logger.debug("Key %s from sharedPreferences has type other than long: %s", str, e.getMessage());
|
|
return Optional.absent();
|
|
}
|
|
}
|
|
|
|
public boolean setValue(String str, long j) {
|
|
if (str == null) {
|
|
logger.debug("Key is null when setting long value on device cache.");
|
|
return false;
|
|
}
|
|
if (this.sharedPref == null) {
|
|
setContext(getFirebaseApplicationContext());
|
|
if (this.sharedPref == null) {
|
|
return false;
|
|
}
|
|
}
|
|
this.sharedPref.edit().putLong(str, j).apply();
|
|
return true;
|
|
}
|
|
|
|
public final Context getFirebaseApplicationContext() {
|
|
try {
|
|
FirebaseApp.getInstance();
|
|
return FirebaseApp.getInstance().getApplicationContext();
|
|
} catch (IllegalStateException unused) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|