package hb;

import android.text.TextUtils;
import com.google.android.gms.internal.atv_ads_framework.d1;
import com.google.android.gms.measurement.internal.u1;
import com.google.firebase.installations.FirebaseInstallationsException;
import com.google.firebase.installations.local.PersistedInstallation$RegistrationStatus;
import java.io.IOException;
import java.util.Iterator;

/* JADX INFO: loaded from: classes2.dex */
public final /* synthetic */ class c implements Runnable {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f26454a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final /* synthetic */ com.google.firebase.installations.a f26455b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final /* synthetic */ boolean f26456c;

    public /* synthetic */ c(com.google.firebase.installations.a aVar, boolean z10, int i10) {
        this.f26454a = i10;
        this.f26455b = aVar;
        this.f26456c = z10;
    }

    /* JADX WARN: Finally extract failed */
    @Override // java.lang.Runnable
    public final void run() {
        ib.b bVarO;
        ib.e eVarB;
        switch (this.f26454a) {
            case 0:
                com.google.firebase.installations.a aVar = this.f26455b;
                boolean z10 = this.f26456c;
                aVar.getClass();
                Object obj = com.google.firebase.installations.a.f24091m;
                synchronized (obj) {
                    try {
                        ua.g gVar = aVar.f24092a;
                        gVar.a();
                        d1 d1VarC = d1.c(gVar.f33401a);
                        try {
                            bVarO = aVar.f24094c.O();
                            if (d1VarC != null) {
                                d1VarC.o();
                            }
                        } catch (Throwable th) {
                            if (d1VarC != null) {
                                d1VarC.o();
                            }
                            throw th;
                        }
                    } finally {
                    }
                }
                try {
                    PersistedInstallation$RegistrationStatus persistedInstallation$RegistrationStatus = PersistedInstallation$RegistrationStatus.f24108e;
                    PersistedInstallation$RegistrationStatus persistedInstallation$RegistrationStatus2 = bVarO.f26600c;
                    if (persistedInstallation$RegistrationStatus2 == persistedInstallation$RegistrationStatus || persistedInstallation$RegistrationStatus2 == PersistedInstallation$RegistrationStatus.f24106c) {
                        eVarB = aVar.g(bVarO);
                    } else {
                        if (!z10 && !aVar.f24095d.b(bVarO)) {
                            return;
                        }
                        eVarB = aVar.b(bVarO);
                    }
                    synchronized (obj) {
                        try {
                            ua.g gVar2 = aVar.f24092a;
                            gVar2.a();
                            d1 d1VarC2 = d1.c(gVar2.f33401a);
                            try {
                                aVar.f24094c.H(eVarB);
                                if (d1VarC2 != null) {
                                    d1VarC2.o();
                                }
                            } catch (Throwable th2) {
                                if (d1VarC2 != null) {
                                    d1VarC2.o();
                                }
                                throw th2;
                            }
                        } finally {
                        }
                    }
                    synchronized (aVar) {
                        if (aVar.f24102k.size() != 0 && !TextUtils.equals(bVarO.getFirebaseInstallationId(), eVarB.getFirebaseInstallationId())) {
                            Iterator it = aVar.f24102k.iterator();
                            if (it.hasNext()) {
                                u1.x(it.next());
                                eVarB.getFirebaseInstallationId();
                                throw null;
                            }
                        }
                    }
                    eVarB.getClass();
                    ib.b bVar = (ib.b) eVarB;
                    if (bVar.f26600c == PersistedInstallation$RegistrationStatus.f24107d) {
                        String firebaseInstallationId = eVarB.getFirebaseInstallationId();
                        synchronized (aVar) {
                            aVar.f24101j = firebaseInstallationId;
                        }
                    }
                    PersistedInstallation$RegistrationStatus persistedInstallation$RegistrationStatus3 = bVar.f26600c;
                    if (persistedInstallation$RegistrationStatus3 == persistedInstallation$RegistrationStatus) {
                        aVar.h(new FirebaseInstallationsException());
                        return;
                    } else if (persistedInstallation$RegistrationStatus3 == PersistedInstallation$RegistrationStatus.f24105b || persistedInstallation$RegistrationStatus3 == PersistedInstallation$RegistrationStatus.f24104a) {
                        aVar.h(new IOException("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."));
                        return;
                    } else {
                        aVar.i(eVarB);
                        return;
                    }
                } catch (FirebaseInstallationsException e10) {
                    aVar.h(e10);
                    return;
                }
            default:
                this.f26455b.a(this.f26456c);
                return;
        }
    }
}
