- 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
440 lines
22 KiB
Java
440 lines
22 KiB
Java
package com.google.firebase.installations;
|
|
|
|
import android.text.TextUtils;
|
|
import com.amazonaws.handlers.HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0;
|
|
import com.google.android.gms.common.internal.Preconditions;
|
|
import com.google.android.gms.tasks.Task;
|
|
import com.google.android.gms.tasks.TaskCompletionSource;
|
|
import com.google.android.gms.tasks.Tasks;
|
|
import com.google.firebase.FirebaseApp;
|
|
import com.google.firebase.components.Lazy;
|
|
import com.google.firebase.inject.Provider;
|
|
import com.google.firebase.installations.FirebaseInstallationsException;
|
|
import com.google.firebase.installations.local.IidStore;
|
|
import com.google.firebase.installations.local.PersistedInstallation;
|
|
import com.google.firebase.installations.local.PersistedInstallationEntry;
|
|
import com.google.firebase.installations.remote.FirebaseInstallationServiceClient;
|
|
import com.google.firebase.installations.remote.InstallationResponse;
|
|
import com.google.firebase.installations.remote.TokenResult;
|
|
import java.util.ArrayList;
|
|
import java.util.HashSet;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
import java.util.concurrent.Executor;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.ThreadFactory;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public class FirebaseInstallations implements FirebaseInstallationsApi {
|
|
public final ExecutorService backgroundExecutor;
|
|
public String cachedFid;
|
|
public final RandomFidGenerator fidGenerator;
|
|
public Set fidListeners;
|
|
public final FirebaseApp firebaseApp;
|
|
public final Lazy iidStore;
|
|
public final List listeners;
|
|
public final Object lock;
|
|
public final Executor networkExecutor;
|
|
public final PersistedInstallation persistedInstallation;
|
|
public final FirebaseInstallationServiceClient serviceClient;
|
|
public final Utils utils;
|
|
public static final Object lockGenerateFid = new Object();
|
|
public static final ThreadFactory THREAD_FACTORY = new ThreadFactory() { // from class: com.google.firebase.installations.FirebaseInstallations.1
|
|
public final AtomicInteger mCount = new AtomicInteger(1);
|
|
|
|
@Override // java.util.concurrent.ThreadFactory
|
|
public Thread newThread(Runnable runnable) {
|
|
return new Thread(runnable, String.format("firebase-installations-executor-%d", Integer.valueOf(this.mCount.getAndIncrement())));
|
|
}
|
|
};
|
|
|
|
public FirebaseInstallations(final FirebaseApp firebaseApp, Provider provider, ExecutorService executorService, Executor executor) {
|
|
this(executorService, executor, firebaseApp, new FirebaseInstallationServiceClient(firebaseApp.getApplicationContext(), provider), new PersistedInstallation(firebaseApp), Utils.getInstance(), new Lazy(new Provider() { // from class: com.google.firebase.installations.FirebaseInstallations$$ExternalSyntheticLambda2
|
|
@Override // com.google.firebase.inject.Provider
|
|
public final Object get() {
|
|
IidStore lambda$new$0;
|
|
lambda$new$0 = FirebaseInstallations.lambda$new$0(FirebaseApp.this);
|
|
return lambda$new$0;
|
|
}
|
|
}), new RandomFidGenerator());
|
|
}
|
|
|
|
public static /* synthetic */ IidStore lambda$new$0(FirebaseApp firebaseApp) {
|
|
return new IidStore(firebaseApp);
|
|
}
|
|
|
|
public FirebaseInstallations(ExecutorService executorService, Executor executor, FirebaseApp firebaseApp, FirebaseInstallationServiceClient firebaseInstallationServiceClient, PersistedInstallation persistedInstallation, Utils utils, Lazy lazy, RandomFidGenerator randomFidGenerator) {
|
|
this.lock = new Object();
|
|
this.fidListeners = new HashSet();
|
|
this.listeners = new ArrayList();
|
|
this.firebaseApp = firebaseApp;
|
|
this.serviceClient = firebaseInstallationServiceClient;
|
|
this.persistedInstallation = persistedInstallation;
|
|
this.utils = utils;
|
|
this.iidStore = lazy;
|
|
this.fidGenerator = randomFidGenerator;
|
|
this.backgroundExecutor = executorService;
|
|
this.networkExecutor = executor;
|
|
}
|
|
|
|
public final void preConditionChecks() {
|
|
Preconditions.checkNotEmpty(getApplicationId(), "Please set your Application ID. A valid Firebase App ID is required to communicate with Firebase server APIs: It identifies your application with Firebase.Please refer to https://firebase.google.com/support/privacy/init-options.");
|
|
Preconditions.checkNotEmpty(getProjectIdentifier(), "Please set your Project ID. A valid Firebase Project ID is required to communicate with Firebase server APIs: It identifies your application with Firebase.Please refer to https://firebase.google.com/support/privacy/init-options.");
|
|
Preconditions.checkNotEmpty(getApiKey(), "Please set a valid API key. A Firebase API key is required to communicate with Firebase server APIs: It authenticates your project with Google.Please refer to https://firebase.google.com/support/privacy/init-options.");
|
|
Preconditions.checkArgument(Utils.isValidAppIdFormat(getApplicationId()), "Please set your Application ID. A valid Firebase App ID is required to communicate with Firebase server APIs: It identifies your application with Firebase.Please refer to https://firebase.google.com/support/privacy/init-options.");
|
|
Preconditions.checkArgument(Utils.isValidApiKeyFormat(getApiKey()), "Please set a valid API key. A Firebase API key is required to communicate with Firebase server APIs: It authenticates your project with Google.Please refer to https://firebase.google.com/support/privacy/init-options.");
|
|
}
|
|
|
|
public String getProjectIdentifier() {
|
|
return this.firebaseApp.getOptions().getProjectId();
|
|
}
|
|
|
|
public static FirebaseInstallations getInstance() {
|
|
return getInstance(FirebaseApp.getInstance());
|
|
}
|
|
|
|
public static FirebaseInstallations getInstance(FirebaseApp firebaseApp) {
|
|
Preconditions.checkArgument(firebaseApp != null, "Null is not a valid value of FirebaseApp.");
|
|
return (FirebaseInstallations) firebaseApp.get(FirebaseInstallationsApi.class);
|
|
}
|
|
|
|
public String getApplicationId() {
|
|
return this.firebaseApp.getOptions().getApplicationId();
|
|
}
|
|
|
|
public String getApiKey() {
|
|
return this.firebaseApp.getOptions().getApiKey();
|
|
}
|
|
|
|
@Override // com.google.firebase.installations.FirebaseInstallationsApi
|
|
public Task getId() {
|
|
preConditionChecks();
|
|
String cacheFid = getCacheFid();
|
|
if (cacheFid != null) {
|
|
return Tasks.forResult(cacheFid);
|
|
}
|
|
Task addGetIdListener = addGetIdListener();
|
|
this.backgroundExecutor.execute(new Runnable() { // from class: com.google.firebase.installations.FirebaseInstallations$$ExternalSyntheticLambda1
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
FirebaseInstallations.this.lambda$getId$1();
|
|
}
|
|
});
|
|
return addGetIdListener;
|
|
}
|
|
|
|
public final /* synthetic */ void lambda$getId$1() {
|
|
lambda$getToken$2(false);
|
|
}
|
|
|
|
@Override // com.google.firebase.installations.FirebaseInstallationsApi
|
|
public Task getToken(final boolean z) {
|
|
preConditionChecks();
|
|
Task addGetAuthTokenListener = addGetAuthTokenListener();
|
|
this.backgroundExecutor.execute(new Runnable() { // from class: com.google.firebase.installations.FirebaseInstallations$$ExternalSyntheticLambda0
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
FirebaseInstallations.this.lambda$getToken$2(z);
|
|
}
|
|
});
|
|
return addGetAuthTokenListener;
|
|
}
|
|
|
|
public final Task addGetIdListener() {
|
|
TaskCompletionSource taskCompletionSource = new TaskCompletionSource();
|
|
addStateListeners(new GetIdListener(taskCompletionSource));
|
|
return taskCompletionSource.getTask();
|
|
}
|
|
|
|
public final Task addGetAuthTokenListener() {
|
|
TaskCompletionSource taskCompletionSource = new TaskCompletionSource();
|
|
addStateListeners(new GetAuthTokenListener(this.utils, taskCompletionSource));
|
|
return taskCompletionSource.getTask();
|
|
}
|
|
|
|
public final void addStateListeners(StateListener stateListener) {
|
|
synchronized (this.lock) {
|
|
this.listeners.add(stateListener);
|
|
}
|
|
}
|
|
|
|
public final void triggerOnStateReached(PersistedInstallationEntry persistedInstallationEntry) {
|
|
synchronized (this.lock) {
|
|
try {
|
|
Iterator it = this.listeners.iterator();
|
|
while (it.hasNext()) {
|
|
if (((StateListener) it.next()).onStateReached(persistedInstallationEntry)) {
|
|
it.remove();
|
|
}
|
|
}
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
}
|
|
|
|
public final void triggerOnException(Exception exc) {
|
|
synchronized (this.lock) {
|
|
try {
|
|
Iterator it = this.listeners.iterator();
|
|
while (it.hasNext()) {
|
|
if (((StateListener) it.next()).onException(exc)) {
|
|
it.remove();
|
|
}
|
|
}
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
}
|
|
|
|
public final synchronized void updateCacheFid(String str) {
|
|
this.cachedFid = str;
|
|
}
|
|
|
|
public final synchronized String getCacheFid() {
|
|
return this.cachedFid;
|
|
}
|
|
|
|
/* renamed from: doRegistrationOrRefresh, reason: merged with bridge method [inline-methods] */
|
|
public final void lambda$getToken$2(final boolean z) {
|
|
PersistedInstallationEntry prefsWithGeneratedIdMultiProcessSafe = getPrefsWithGeneratedIdMultiProcessSafe();
|
|
if (z) {
|
|
prefsWithGeneratedIdMultiProcessSafe = prefsWithGeneratedIdMultiProcessSafe.withClearedAuthToken();
|
|
}
|
|
triggerOnStateReached(prefsWithGeneratedIdMultiProcessSafe);
|
|
this.networkExecutor.execute(new Runnable() { // from class: com.google.firebase.installations.FirebaseInstallations$$ExternalSyntheticLambda3
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
FirebaseInstallations.this.lambda$doRegistrationOrRefresh$3(z);
|
|
}
|
|
});
|
|
}
|
|
|
|
public final IidStore getIidStore() {
|
|
return (IidStore) this.iidStore.get();
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:17:0x0034 */
|
|
/* JADX WARN: Removed duplicated region for block: B:20:0x0041 */
|
|
/* JADX WARN: Removed duplicated region for block: B:22:0x004c */
|
|
/* renamed from: doNetworkCallIfNecessary, reason: merged with bridge method [inline-methods] */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public final void lambda$doRegistrationOrRefresh$3(boolean r3) {
|
|
/*
|
|
r2 = this;
|
|
com.google.firebase.installations.local.PersistedInstallationEntry r0 = r2.getMultiProcessSafePrefs()
|
|
boolean r1 = r0.isErrored() // Catch: com.google.firebase.installations.FirebaseInstallationsException -> L1d
|
|
if (r1 != 0) goto L24
|
|
boolean r1 = r0.isUnregistered() // Catch: com.google.firebase.installations.FirebaseInstallationsException -> L1d
|
|
if (r1 == 0) goto L11
|
|
goto L24
|
|
L11:
|
|
if (r3 != 0) goto L1f
|
|
com.google.firebase.installations.Utils r3 = r2.utils // Catch: com.google.firebase.installations.FirebaseInstallationsException -> L1d
|
|
boolean r3 = r3.isAuthTokenExpired(r0) // Catch: com.google.firebase.installations.FirebaseInstallationsException -> L1d
|
|
if (r3 == 0) goto L1c
|
|
goto L1f
|
|
L1c:
|
|
return
|
|
L1d:
|
|
r3 = move-exception
|
|
goto L61
|
|
L1f:
|
|
com.google.firebase.installations.local.PersistedInstallationEntry r3 = r2.fetchAuthTokenFromServer(r0) // Catch: com.google.firebase.installations.FirebaseInstallationsException -> L1d
|
|
goto L28
|
|
L24:
|
|
com.google.firebase.installations.local.PersistedInstallationEntry r3 = r2.registerFidWithServer(r0) // Catch: com.google.firebase.installations.FirebaseInstallationsException -> L1d
|
|
L28:
|
|
r2.insertOrUpdatePrefs(r3)
|
|
r2.updateFidListener(r0, r3)
|
|
boolean r0 = r3.isRegistered()
|
|
if (r0 == 0) goto L3b
|
|
java.lang.String r0 = r3.getFirebaseInstallationId()
|
|
r2.updateCacheFid(r0)
|
|
L3b:
|
|
boolean r0 = r3.isErrored()
|
|
if (r0 == 0) goto L4c
|
|
com.google.firebase.installations.FirebaseInstallationsException r3 = new com.google.firebase.installations.FirebaseInstallationsException
|
|
com.google.firebase.installations.FirebaseInstallationsException$Status r0 = com.google.firebase.installations.FirebaseInstallationsException.Status.BAD_CONFIG
|
|
r3.<init>(r0)
|
|
r2.triggerOnException(r3)
|
|
goto L60
|
|
L4c:
|
|
boolean r0 = r3.isNotGenerated()
|
|
if (r0 == 0) goto L5d
|
|
java.io.IOException r3 = new java.io.IOException
|
|
java.lang.String r0 = "Installation ID could not be validated with the Firebase servers (maybe it was deleted). Firebase Installations will need to create a new Installation ID and auth token. Please retry your last request."
|
|
r3.<init>(r0)
|
|
r2.triggerOnException(r3)
|
|
goto L60
|
|
L5d:
|
|
r2.triggerOnStateReached(r3)
|
|
L60:
|
|
return
|
|
L61:
|
|
r2.triggerOnException(r3)
|
|
return
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.google.firebase.installations.FirebaseInstallations.lambda$doRegistrationOrRefresh$3(boolean):void");
|
|
}
|
|
|
|
public final synchronized void updateFidListener(PersistedInstallationEntry persistedInstallationEntry, PersistedInstallationEntry persistedInstallationEntry2) {
|
|
if (this.fidListeners.size() != 0 && !TextUtils.equals(persistedInstallationEntry.getFirebaseInstallationId(), persistedInstallationEntry2.getFirebaseInstallationId())) {
|
|
Iterator it = this.fidListeners.iterator();
|
|
if (it.hasNext()) {
|
|
HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0.m(it.next());
|
|
persistedInstallationEntry2.getFirebaseInstallationId();
|
|
throw null;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Finally extract failed */
|
|
public final void insertOrUpdatePrefs(PersistedInstallationEntry persistedInstallationEntry) {
|
|
synchronized (lockGenerateFid) {
|
|
try {
|
|
CrossProcessLock acquire = CrossProcessLock.acquire(this.firebaseApp.getApplicationContext(), "generatefid.lock");
|
|
try {
|
|
this.persistedInstallation.insertOrUpdatePersistedInstallationEntry(persistedInstallationEntry);
|
|
if (acquire != null) {
|
|
acquire.releaseAndClose();
|
|
}
|
|
} catch (Throwable th) {
|
|
if (acquire != null) {
|
|
acquire.releaseAndClose();
|
|
}
|
|
throw th;
|
|
}
|
|
} catch (Throwable th2) {
|
|
throw th2;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Finally extract failed */
|
|
public final PersistedInstallationEntry getPrefsWithGeneratedIdMultiProcessSafe() {
|
|
PersistedInstallationEntry readPersistedInstallationEntryValue;
|
|
synchronized (lockGenerateFid) {
|
|
try {
|
|
CrossProcessLock acquire = CrossProcessLock.acquire(this.firebaseApp.getApplicationContext(), "generatefid.lock");
|
|
try {
|
|
readPersistedInstallationEntryValue = this.persistedInstallation.readPersistedInstallationEntryValue();
|
|
if (readPersistedInstallationEntryValue.isNotGenerated()) {
|
|
readPersistedInstallationEntryValue = this.persistedInstallation.insertOrUpdatePersistedInstallationEntry(readPersistedInstallationEntryValue.withUnregisteredFid(readExistingIidOrCreateFid(readPersistedInstallationEntryValue)));
|
|
}
|
|
if (acquire != null) {
|
|
acquire.releaseAndClose();
|
|
}
|
|
} catch (Throwable th) {
|
|
if (acquire != null) {
|
|
acquire.releaseAndClose();
|
|
}
|
|
throw th;
|
|
}
|
|
} catch (Throwable th2) {
|
|
throw th2;
|
|
}
|
|
}
|
|
return readPersistedInstallationEntryValue;
|
|
}
|
|
|
|
public final String readExistingIidOrCreateFid(PersistedInstallationEntry persistedInstallationEntry) {
|
|
if ((!this.firebaseApp.getName().equals("CHIME_ANDROID_SDK") && !this.firebaseApp.isDefaultApp()) || !persistedInstallationEntry.shouldAttemptMigration()) {
|
|
return this.fidGenerator.createRandomFid();
|
|
}
|
|
String readIid = getIidStore().readIid();
|
|
return TextUtils.isEmpty(readIid) ? this.fidGenerator.createRandomFid() : readIid;
|
|
}
|
|
|
|
public final PersistedInstallationEntry registerFidWithServer(PersistedInstallationEntry persistedInstallationEntry) {
|
|
InstallationResponse createFirebaseInstallation = this.serviceClient.createFirebaseInstallation(getApiKey(), persistedInstallationEntry.getFirebaseInstallationId(), getProjectIdentifier(), getApplicationId(), (persistedInstallationEntry.getFirebaseInstallationId() == null || persistedInstallationEntry.getFirebaseInstallationId().length() != 11) ? null : getIidStore().readToken());
|
|
int i = AnonymousClass3.$SwitchMap$com$google$firebase$installations$remote$InstallationResponse$ResponseCode[createFirebaseInstallation.getResponseCode().ordinal()];
|
|
if (i == 1) {
|
|
return persistedInstallationEntry.withRegisteredFid(createFirebaseInstallation.getFid(), createFirebaseInstallation.getRefreshToken(), this.utils.currentTimeInSecs(), createFirebaseInstallation.getAuthToken().getToken(), createFirebaseInstallation.getAuthToken().getTokenExpirationTimestamp());
|
|
}
|
|
if (i == 2) {
|
|
return persistedInstallationEntry.withFisError("BAD CONFIG");
|
|
}
|
|
throw new FirebaseInstallationsException("Firebase Installations Service is unavailable. Please try again later.", FirebaseInstallationsException.Status.UNAVAILABLE);
|
|
}
|
|
|
|
public final PersistedInstallationEntry fetchAuthTokenFromServer(PersistedInstallationEntry persistedInstallationEntry) {
|
|
TokenResult generateAuthToken = this.serviceClient.generateAuthToken(getApiKey(), persistedInstallationEntry.getFirebaseInstallationId(), getProjectIdentifier(), persistedInstallationEntry.getRefreshToken());
|
|
int i = AnonymousClass3.$SwitchMap$com$google$firebase$installations$remote$TokenResult$ResponseCode[generateAuthToken.getResponseCode().ordinal()];
|
|
if (i == 1) {
|
|
return persistedInstallationEntry.withAuthToken(generateAuthToken.getToken(), generateAuthToken.getTokenExpirationTimestamp(), this.utils.currentTimeInSecs());
|
|
}
|
|
if (i == 2) {
|
|
return persistedInstallationEntry.withFisError("BAD CONFIG");
|
|
}
|
|
if (i == 3) {
|
|
updateCacheFid(null);
|
|
return persistedInstallationEntry.withNoGeneratedFid();
|
|
}
|
|
throw new FirebaseInstallationsException("Firebase Installations Service is unavailable. Please try again later.", FirebaseInstallationsException.Status.UNAVAILABLE);
|
|
}
|
|
|
|
/* renamed from: com.google.firebase.installations.FirebaseInstallations$3, reason: invalid class name */
|
|
public static /* synthetic */ class AnonymousClass3 {
|
|
public static final /* synthetic */ int[] $SwitchMap$com$google$firebase$installations$remote$InstallationResponse$ResponseCode;
|
|
public static final /* synthetic */ int[] $SwitchMap$com$google$firebase$installations$remote$TokenResult$ResponseCode;
|
|
|
|
static {
|
|
int[] iArr = new int[TokenResult.ResponseCode.values().length];
|
|
$SwitchMap$com$google$firebase$installations$remote$TokenResult$ResponseCode = iArr;
|
|
try {
|
|
iArr[TokenResult.ResponseCode.OK.ordinal()] = 1;
|
|
} catch (NoSuchFieldError unused) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$google$firebase$installations$remote$TokenResult$ResponseCode[TokenResult.ResponseCode.BAD_CONFIG.ordinal()] = 2;
|
|
} catch (NoSuchFieldError unused2) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$google$firebase$installations$remote$TokenResult$ResponseCode[TokenResult.ResponseCode.AUTH_ERROR.ordinal()] = 3;
|
|
} catch (NoSuchFieldError unused3) {
|
|
}
|
|
int[] iArr2 = new int[InstallationResponse.ResponseCode.values().length];
|
|
$SwitchMap$com$google$firebase$installations$remote$InstallationResponse$ResponseCode = iArr2;
|
|
try {
|
|
iArr2[InstallationResponse.ResponseCode.OK.ordinal()] = 1;
|
|
} catch (NoSuchFieldError unused4) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$google$firebase$installations$remote$InstallationResponse$ResponseCode[InstallationResponse.ResponseCode.BAD_CONFIG.ordinal()] = 2;
|
|
} catch (NoSuchFieldError unused5) {
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Finally extract failed */
|
|
public final PersistedInstallationEntry getMultiProcessSafePrefs() {
|
|
PersistedInstallationEntry readPersistedInstallationEntryValue;
|
|
synchronized (lockGenerateFid) {
|
|
try {
|
|
CrossProcessLock acquire = CrossProcessLock.acquire(this.firebaseApp.getApplicationContext(), "generatefid.lock");
|
|
try {
|
|
readPersistedInstallationEntryValue = this.persistedInstallation.readPersistedInstallationEntryValue();
|
|
if (acquire != null) {
|
|
acquire.releaseAndClose();
|
|
}
|
|
} catch (Throwable th) {
|
|
if (acquire != null) {
|
|
acquire.releaseAndClose();
|
|
}
|
|
throw th;
|
|
}
|
|
} catch (Throwable th2) {
|
|
throw th2;
|
|
}
|
|
}
|
|
return readPersistedInstallationEntryValue;
|
|
}
|
|
}
|