package com.google.android.gms.measurement.internal;

import android.util.SparseArray;

/* JADX INFO: loaded from: classes2.dex */
public final class a implements com.google.common.util.concurrent.t {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Object f21466b;

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

    public /* synthetic */ a(Object obj, Object obj2, int i10) {
        this.f21465a = i10;
        this.f21467c = obj;
        this.f21466b = obj2;
    }

    public final void a() {
        int i10 = this.f21465a;
        Object obj = this.f21467c;
        switch (i10) {
            case 2:
                g2 g2Var = (g2) obj;
                SparseArray sparseArrayG = g2Var.u().G();
                t3 t3Var = (t3) this.f21466b;
                sparseArrayG.put(t3Var.f21913c, Long.valueOf(t3Var.f21912b));
                g2Var.u().A(sparseArrayG);
                break;
            default:
                m3 m3Var = (m3) obj;
                m3Var.w();
                p3 p3Var = (p3) this.f21466b;
                if (p3Var != null) {
                    m3Var.f21777c.removeCallbacks(p3Var);
                }
                m3Var.u().f22002t.a(false);
                m3Var.w();
                m3Var.f21778d = false;
                if (m3Var.s().J(null, z.K0) && m3Var.z().f21628m) {
                    m3Var.zzj().f21842n.c("Retrying trigger URI registration in foreground");
                    m3Var.z().Z();
                    break;
                }
                break;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:26:0x0073  */
    @Override // com.google.common.util.concurrent.t
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void onFailure(Throwable th) {
        int i10;
        g2 g2Var = (g2) this.f21467c;
        g2Var.w();
        int i11 = 0;
        g2Var.f21624i = false;
        if (!g2Var.s().J(null, z.M0)) {
            g2Var.Z();
            g2Var.zzj().f21834f.b(th, "registerTriggerAsync failed with throwable");
            return;
        }
        if (g2Var.s().J(null, z.K0)) {
            String message = th.getMessage();
            g2Var.f21628m = false;
            if (message == null) {
                i10 = 2;
            } else if ((th instanceof IllegalStateException) || message.contains("garbage collected") || th.getClass().getSimpleName().equals("ServiceUnavailableException")) {
                if (message.contains("Background")) {
                    g2Var.f21628m = true;
                }
                i10 = 1;
            } else if ((th instanceof SecurityException) && !message.endsWith("READ_DEVICE_CONFIG")) {
                i10 = 3;
            }
        }
        int i12 = i10 - 1;
        if (i12 == 0) {
            g2Var.zzj().f21837i.a(p0.A(g2Var.x().G()), p0.A(th.toString()), "registerTriggerAsync failed with retriable error. Will try later. App ID, throwable");
            g2Var.f21625j = 1;
            g2Var.U().add((t3) this.f21466b);
            return;
        }
        if (i12 != 1) {
            if (i12 != 2) {
                return;
            }
            g2Var.zzj().f21834f.a(p0.A(g2Var.x().G()), th, "registerTriggerAsync failed. Dropping URI. App ID, Throwable");
            a();
            g2Var.f21625j = 1;
            g2Var.Z();
            return;
        }
        g2Var.U().add((t3) this.f21466b);
        if (g2Var.f21625j > 32) {
            g2Var.f21625j = 1;
            g2Var.zzj().f21837i.a(p0.A(g2Var.x().G()), p0.A(th.toString()), "registerTriggerAsync failed. May try later. App ID, throwable");
            return;
        }
        g2Var.zzj().f21837i.d("registerTriggerAsync failed. App ID, delay in seconds, throwable", p0.A(g2Var.x().G()), p0.A(String.valueOf(g2Var.f21625j)), p0.A(th.toString()));
        int i13 = g2Var.f21625j;
        if (g2Var.f21626k == null) {
            g2Var.f21626k = new m2(g2Var, (m1) g2Var.f31277a, i11);
        }
        g2Var.f21626k.b(i13 * 1000);
        g2Var.f21625j <<= 1;
    }

    @Override // com.google.common.util.concurrent.t
    public final void onSuccess(Object obj) {
        g2 g2Var = (g2) this.f21467c;
        g2Var.w();
        if (!g2Var.s().J(null, z.M0)) {
            g2Var.f21624i = false;
            g2Var.Z();
            p0 p0VarZzj = g2Var.zzj();
            p0VarZzj.f21841m.b(((t3) this.f21466b).f21911a, "registerTriggerAsync ran. uri");
            return;
        }
        a();
        g2Var.f21624i = false;
        g2Var.f21625j = 1;
        p0 p0VarZzj2 = g2Var.zzj();
        p0VarZzj2.f21841m.b(((t3) this.f21466b).f21911a, "Successfully registered trigger URI");
        g2Var.Z();
    }

    public a(m3 m3Var) {
        this.f21465a = 3;
        this.f21467c = m3Var;
    }
}
