what-the-bank/sources/com/google/firebase/internal/DataCollectionConfigStorage...

59 lines
2.5 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.firebase.internal;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageItemInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import com.google.firebase.events.Publisher;
import o.nMh;
/* loaded from: classes.dex */
public class DataCollectionConfigStorage {
private boolean dataCollectionDefaultEnabled;
private final Context deviceProtectedContext;
private final Publisher publisher;
private final SharedPreferences sharedPreferences;
public DataCollectionConfigStorage(Context context, String str, Publisher publisher) {
Context directBootSafe = directBootSafe(context);
this.deviceProtectedContext = directBootSafe;
this.sharedPreferences = directBootSafe.getSharedPreferences("com.google.firebase.common.prefs:".concat(String.valueOf(str)), 0);
this.publisher = publisher;
this.dataCollectionDefaultEnabled = readAutoDataCollectionEnabled();
}
private static Context directBootSafe(Context context) {
return nMh.createDeviceProtectedStorageContext(context);
}
public boolean isEnabled() {
boolean z;
synchronized (this) {
z = this.dataCollectionDefaultEnabled;
}
return z;
}
private boolean readManifestDataCollectionEnabled() {
ApplicationInfo applicationInfo;
try {
PackageManager packageManager = this.deviceProtectedContext.getPackageManager();
if (packageManager == null || (applicationInfo = packageManager.getApplicationInfo(this.deviceProtectedContext.getPackageName(), 128)) == null || PackageItemInfo.class.getField("metaData").get(applicationInfo) == null || !((Bundle) PackageItemInfo.class.getField("metaData").get(applicationInfo)).containsKey("firebase_data_collection_default_enabled")) {
return true;
}
return ((Bundle) PackageItemInfo.class.getField("metaData").get(applicationInfo)).getBoolean("firebase_data_collection_default_enabled");
} catch (PackageManager.NameNotFoundException unused) {
return true;
}
}
private boolean readAutoDataCollectionEnabled() {
if (this.sharedPreferences.contains("firebase_data_collection_default_enabled")) {
return this.sharedPreferences.getBoolean("firebase_data_collection_default_enabled", true);
}
return readManifestDataCollectionEnabled();
}
}