what-the-bank/sources/com/google/firebase/crashlytics/internal/common/DataCollectionArbiter.java

154 lines
7.6 KiB
Java

package com.google.firebase.crashlytics.internal.common;
import android.content.SharedPreferences;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.TaskCompletionSource;
import com.google.firebase.FirebaseApp;
/* loaded from: classes.dex */
public class DataCollectionArbiter {
private static final String FIREBASE_CRASHLYTICS_COLLECTION_ENABLED = "firebase_crashlytics_collection_enabled";
private volatile boolean crashlyticsDataCollectionEnabled;
private volatile boolean crashlyticsDataCollectionExplicitlySet;
private final FirebaseApp firebaseApp;
private final SharedPreferences sharedPreferences;
boolean taskResolved;
private Object taskLock = new Object();
TaskCompletionSource<Void> dataCollectionEnabledTask = new TaskCompletionSource<>();
private TaskCompletionSource<Void> dataCollectionExplicitlyApproved = new TaskCompletionSource<>();
/* JADX WARN: Removed duplicated region for block: B:9:0x008f A[EXC_TOP_SPLITTER, SYNTHETIC] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public DataCollectionArbiter(com.google.firebase.FirebaseApp r5) {
/*
r4 = this;
r4.<init>()
java.lang.Object r0 = new java.lang.Object
r0.<init>()
r4.taskLock = r0
com.google.android.gms.tasks.TaskCompletionSource r0 = new com.google.android.gms.tasks.TaskCompletionSource
r0.<init>()
r4.dataCollectionEnabledTask = r0
r0 = 0
r4.taskResolved = r0
com.google.android.gms.tasks.TaskCompletionSource r1 = new com.google.android.gms.tasks.TaskCompletionSource
r1.<init>()
r4.dataCollectionExplicitlyApproved = r1
r4.firebaseApp = r5
android.content.Context r5 = r5.getApplicationContext()
if (r5 == 0) goto La2
android.content.SharedPreferences r1 = com.google.firebase.crashlytics.internal.common.CommonUtils.getSharedPrefs(r5)
r4.sharedPreferences = r1
java.lang.String r2 = "firebase_crashlytics_collection_enabled"
boolean r2 = r1.contains(r2)
r3 = 1
if (r2 == 0) goto L39
java.lang.String r5 = "firebase_crashlytics_collection_enabled"
boolean r5 = r1.getBoolean(r5, r3)
goto L7b
L39:
android.content.pm.PackageManager r1 = r5.getPackageManager() // Catch: android.content.pm.PackageManager.NameNotFoundException -> L7d
if (r1 == 0) goto L87
java.lang.String r5 = r5.getPackageName() // Catch: android.content.pm.PackageManager.NameNotFoundException -> L7d
r2 = 128(0x80, float:1.8E-43)
android.content.pm.ApplicationInfo r5 = r1.getApplicationInfo(r5, r2) // Catch: android.content.pm.PackageManager.NameNotFoundException -> L7d
if (r5 == 0) goto L87
java.lang.Class<android.content.pm.PackageItemInfo> r1 = android.content.pm.PackageItemInfo.class
java.lang.String r2 = "metaData"
java.lang.reflect.Field r1 = r1.getField(r2) // Catch: android.content.pm.PackageManager.NameNotFoundException -> L7d
java.lang.Object r1 = r1.get(r5) // Catch: android.content.pm.PackageManager.NameNotFoundException -> L7d
if (r1 == 0) goto L87
java.lang.Class<android.content.pm.PackageItemInfo> r1 = android.content.pm.PackageItemInfo.class
java.lang.String r2 = "metaData"
java.lang.reflect.Field r1 = r1.getField(r2) // Catch: android.content.pm.PackageManager.NameNotFoundException -> L7d
java.lang.Object r1 = r1.get(r5) // Catch: android.content.pm.PackageManager.NameNotFoundException -> L7d
android.os.Bundle r1 = (android.os.Bundle) r1 // Catch: android.content.pm.PackageManager.NameNotFoundException -> L7d
java.lang.String r2 = "firebase_crashlytics_collection_enabled"
boolean r1 = r1.containsKey(r2) // Catch: android.content.pm.PackageManager.NameNotFoundException -> L7d
if (r1 == 0) goto L87
java.lang.Class<android.content.pm.PackageItemInfo> r1 = android.content.pm.PackageItemInfo.class
java.lang.String r2 = "metaData"
java.lang.reflect.Field r1 = r1.getField(r2) // Catch: android.content.pm.PackageManager.NameNotFoundException -> L7d
r1.get(r5) // Catch: android.content.pm.PackageManager.NameNotFoundException -> L7d
r5 = r3
L7b:
r0 = r3
goto L88
L7d:
r5 = move-exception
com.google.firebase.crashlytics.internal.Logger r1 = com.google.firebase.crashlytics.internal.Logger.getLogger()
java.lang.String r2 = "Unable to get PackageManager. Falling through"
r1.d(r2, r5)
L87:
r5 = r3
L88:
r4.crashlyticsDataCollectionEnabled = r5
r4.crashlyticsDataCollectionExplicitlySet = r0
java.lang.Object r5 = r4.taskLock
monitor-enter(r5)
boolean r0 = r4.isAutomaticDataCollectionEnabled() // Catch: java.lang.Throwable -> L9f
if (r0 == 0) goto L9d
com.google.android.gms.tasks.TaskCompletionSource<java.lang.Void> r0 = r4.dataCollectionEnabledTask // Catch: java.lang.Throwable -> L9f
r1 = 0
r0.trySetResult(r1) // Catch: java.lang.Throwable -> L9f
r4.taskResolved = r3 // Catch: java.lang.Throwable -> L9f
L9d:
monitor-exit(r5)
return
L9f:
r0 = move-exception
monitor-exit(r5)
throw r0
La2:
java.lang.RuntimeException r5 = new java.lang.RuntimeException
java.lang.String r0 = "null context"
r5.<init>(r0)
throw r5
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.firebase.crashlytics.internal.common.DataCollectionArbiter.<init>(com.google.firebase.FirebaseApp):void");
}
public boolean isAutomaticDataCollectionEnabled() {
return this.crashlyticsDataCollectionExplicitlySet ? this.crashlyticsDataCollectionEnabled : this.firebaseApp.isDataCollectionDefaultEnabled();
}
public Task<Void> waitForAutomaticDataCollectionEnabled() {
Task<Void> task;
synchronized (this.taskLock) {
task = this.dataCollectionEnabledTask.getTask();
}
return task;
}
public void setCrashlyticsDataCollectionEnabled(boolean z) {
this.crashlyticsDataCollectionEnabled = z;
this.crashlyticsDataCollectionExplicitlySet = true;
this.sharedPreferences.edit().putBoolean(FIREBASE_CRASHLYTICS_COLLECTION_ENABLED, z).commit();
synchronized (this.taskLock) {
if (z) {
if (!this.taskResolved) {
this.dataCollectionEnabledTask.trySetResult(null);
this.taskResolved = true;
}
} else if (this.taskResolved) {
this.dataCollectionEnabledTask = new TaskCompletionSource<>();
this.taskResolved = false;
}
}
}
public Task<Void> waitForDataCollectionPermission() {
return Utils.race(this.dataCollectionExplicitlyApproved.getTask(), waitForAutomaticDataCollectionEnabled());
}
public void grantDataCollectionPermission(boolean z) {
if (!z) {
throw new IllegalStateException("An invalid data collection token was used.");
}
this.dataCollectionExplicitlyApproved.trySetResult(null);
}
}