package d3;

import android.os.Bundle;
import android.os.RemoteException;
import android.text.TextUtils;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

/* JADX INFO: renamed from: d3.l1, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class RunnableC0801l1 implements Runnable {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final /* synthetic */ int f12040q = 0;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final /* synthetic */ String f12041r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final /* synthetic */ String f12042s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public final /* synthetic */ X1 f12043t;

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

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public final /* synthetic */ C0824t1 f12045v;

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

    public RunnableC0801l1(C0824t1 c0824t1, String str, String str2, X1 x12, boolean z8, com.google.android.gms.internal.measurement.L l8) {
        this.f12041r = str;
        this.f12042s = str2;
        this.f12043t = x12;
        this.f12044u = z8;
        this.f12046w = l8;
        this.f12045v = c0824t1;
    }

    @Override // java.lang.Runnable
    public final void run() throws Throwable {
        W1 w12;
        K k8;
        String str;
        AtomicReference atomicReference;
        C0824t1 c0824t1;
        K k9;
        switch (this.f12040q) {
            case n4.u0.f15495q /* 0 */:
                String str2 = this.f12041r;
                com.google.android.gms.internal.measurement.L l8 = (com.google.android.gms.internal.measurement.L) this.f12046w;
                C0824t1 c0824t12 = this.f12045v;
                C0817r0 c0817r0 = (C0817r0) c0824t12.f5146q;
                Bundle bundle = new Bundle();
                try {
                    try {
                        k8 = c0824t12.f12179t;
                        str = this.f12042s;
                    } catch (RemoteException e8) {
                        e = e8;
                    }
                    if (k8 == null) {
                        Z z8 = c0817r0.f12150y;
                        C0817r0.k(z8);
                        z8.f11875v.d("Failed to get user properties; not connected to service", str2, str);
                        w12 = c0817r0.f12122B;
                        C0817r0.i(w12);
                        w12.c0(l8, bundle);
                        return;
                    }
                    List<T1> listU = k8.u(str2, str, this.f12044u, this.f12043t);
                    Bundle bundle2 = new Bundle();
                    if (listU != null) {
                        for (T1 t12 : listU) {
                            String str3 = t12.f11726u;
                            String str4 = t12.f11723r;
                            if (str3 != null) {
                                bundle2.putString(str4, str3);
                            } else {
                                Long l9 = t12.f11725t;
                                if (l9 != null) {
                                    bundle2.putLong(str4, l9.longValue());
                                } else {
                                    Double d8 = t12.f11728w;
                                    if (d8 != null) {
                                        bundle2.putDouble(str4, d8.doubleValue());
                                    }
                                }
                            }
                        }
                    }
                    try {
                        c0824t12.U();
                        W1 w13 = c0817r0.f12122B;
                        C0817r0.i(w13);
                        w13.c0(l8, bundle2);
                        return;
                    } catch (RemoteException e9) {
                        e = e9;
                        bundle = bundle2;
                        Z z9 = c0817r0.f12150y;
                        C0817r0.k(z9);
                        z9.f11875v.d("Failed to get user properties; remote exception", str2, e);
                        w12 = c0817r0.f12122B;
                        C0817r0.i(w12);
                        w12.c0(l8, bundle);
                        return;
                    } catch (Throwable th) {
                        th = th;
                        bundle = bundle2;
                        W1 w14 = c0817r0.f12122B;
                        C0817r0.i(w14);
                        w14.c0(l8, bundle);
                        throw th;
                    }
                } catch (Throwable th2) {
                    th = th2;
                }
                break;
            default:
                AtomicReference atomicReference2 = (AtomicReference) this.f12046w;
                synchronized (atomicReference2) {
                    try {
                        try {
                            c0824t1 = this.f12045v;
                            k9 = c0824t1.f12179t;
                        } catch (RemoteException e10) {
                            Z z10 = ((C0817r0) this.f12045v.f5146q).f12150y;
                            C0817r0.k(z10);
                            z10.f11875v.e("(legacy) Failed to get user properties; remote exception", null, this.f12041r, e10);
                            ((AtomicReference) this.f12046w).set(Collections.EMPTY_LIST);
                            atomicReference = (AtomicReference) this.f12046w;
                        }
                        if (k9 == null) {
                            Z z11 = ((C0817r0) c0824t1.f5146q).f12150y;
                            C0817r0.k(z11);
                            z11.f11875v.e("(legacy) Failed to get user properties; not connected to service", null, this.f12041r, this.f12042s);
                            atomicReference2.set(Collections.EMPTY_LIST);
                            atomicReference2.notify();
                            return;
                        }
                        if (TextUtils.isEmpty(null)) {
                            atomicReference2.set(k9.u(this.f12041r, this.f12042s, this.f12044u, this.f12043t));
                        } else {
                            atomicReference2.set(k9.J(null, this.f12041r, this.f12042s, this.f12044u));
                        }
                        c0824t1.U();
                        atomicReference = (AtomicReference) this.f12046w;
                        atomicReference.notify();
                        return;
                    } catch (Throwable th3) {
                        ((AtomicReference) this.f12046w).notify();
                        throw th3;
                    }
                }
        }
    }

    public RunnableC0801l1(C0824t1 c0824t1, AtomicReference atomicReference, String str, String str2, X1 x12, boolean z8) {
        this.f12046w = atomicReference;
        this.f12041r = str;
        this.f12042s = str2;
        this.f12043t = x12;
        this.f12044u = z8;
        this.f12045v = c0824t1;
    }
}
