package L1;

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: L1.p1, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class RunnableC0127p1 implements Runnable {

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

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

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

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final /* synthetic */ e2 f1958n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final /* synthetic */ boolean f1959o;
    public final /* synthetic */ C0153y1 p;
    public final /* synthetic */ Object q;

    public RunnableC0127p1(C0153y1 c0153y1, String str, String str2, e2 e2Var, boolean z5, com.google.android.gms.internal.measurement.L l5) {
        this.f1956l = str;
        this.f1957m = str2;
        this.f1958n = e2Var;
        this.f1959o = z5;
        this.q = l5;
        this.p = c0153y1;
    }

    @Override // java.lang.Runnable
    public final void run() throws Throwable {
        Bundle bundle;
        RemoteException e2;
        c2 c2Var;
        I i;
        String str;
        C0146w0 c0146w0;
        AtomicReference atomicReference;
        C0153y1 c0153y1;
        I i5;
        switch (this.f1955k) {
            case 0:
                String str2 = this.f1956l;
                com.google.android.gms.internal.measurement.L l5 = (com.google.android.gms.internal.measurement.L) this.q;
                C0153y1 c0153y12 = this.p;
                Bundle bundle2 = new Bundle();
                try {
                    try {
                        i = c0153y12.f2064n;
                        str = this.f1957m;
                        c0146w0 = (C0146w0) c0153y12.f29k;
                    } catch (Throwable th) {
                        th = th;
                        bundle2 = bundle;
                        c2 c2Var2 = ((C0146w0) c0153y12.f29k).f2038s;
                        C0146w0.j(c2Var2);
                        c2Var2.X(l5, bundle2);
                        throw th;
                    }
                } catch (RemoteException e6) {
                    bundle = bundle2;
                    e2 = e6;
                } catch (Throwable th2) {
                    th = th2;
                    c2 c2Var22 = ((C0146w0) c0153y12.f29k).f2038s;
                    C0146w0.j(c2Var22);
                    c2Var22.X(l5, bundle2);
                    throw th;
                }
                if (i == null) {
                    X x5 = c0146w0.p;
                    C0146w0.l(x5);
                    x5.p.d(str2, str, "Failed to get user properties; not connected to service");
                    c2 c2Var3 = c0146w0.f2038s;
                    C0146w0.j(c2Var3);
                    c2Var3.X(l5, bundle2);
                    return;
                }
                List<Z1> listS = i.s(str2, str, this.f1959o, this.f1958n);
                bundle = new Bundle();
                if (listS != null) {
                    for (Z1 z12 : listS) {
                        String str3 = z12.f1657o;
                        String str4 = z12.f1654l;
                        if (str3 != null) {
                            bundle.putString(str4, str3);
                        } else {
                            Long l6 = z12.f1656n;
                            if (l6 != null) {
                                bundle.putLong(str4, l6.longValue());
                            } else {
                                Double d3 = z12.q;
                                if (d3 != null) {
                                    bundle.putDouble(str4, d3.doubleValue());
                                }
                            }
                        }
                    }
                }
                try {
                    c0153y12.x();
                    c2Var = c0146w0.f2038s;
                } catch (RemoteException e7) {
                    e2 = e7;
                    X x6 = ((C0146w0) c0153y12.f29k).p;
                    C0146w0.l(x6);
                    x6.p.d(str2, e2, "Failed to get user properties; remote exception");
                    c2Var = ((C0146w0) c0153y12.f29k).f2038s;
                }
                C0146w0.j(c2Var);
                c2Var.X(l5, bundle);
                return;
            default:
                AtomicReference atomicReference2 = (AtomicReference) this.q;
                synchronized (atomicReference2) {
                    try {
                        try {
                            c0153y1 = this.p;
                            i5 = c0153y1.f2064n;
                        } catch (RemoteException e8) {
                            X x7 = ((C0146w0) this.p.f29k).p;
                            C0146w0.l(x7);
                            x7.p.e("(legacy) Failed to get user properties; remote exception", null, this.f1956l, e8);
                            ((AtomicReference) this.q).set(Collections.EMPTY_LIST);
                            atomicReference = (AtomicReference) this.q;
                        }
                        if (i5 == null) {
                            X x8 = ((C0146w0) c0153y1.f29k).p;
                            C0146w0.l(x8);
                            x8.p.e("(legacy) Failed to get user properties; not connected to service", null, this.f1956l, this.f1957m);
                            atomicReference2.set(Collections.EMPTY_LIST);
                            atomicReference2.notify();
                            return;
                        }
                        if (TextUtils.isEmpty(null)) {
                            atomicReference2.set(i5.s(this.f1956l, this.f1957m, this.f1959o, this.f1958n));
                        } else {
                            atomicReference2.set(i5.j(null, this.f1956l, this.f1957m, this.f1959o));
                        }
                        c0153y1.x();
                        atomicReference = (AtomicReference) this.q;
                        atomicReference.notify();
                        return;
                    } catch (Throwable th3) {
                        ((AtomicReference) this.q).notify();
                        throw th3;
                    }
                }
        }
    }

    public RunnableC0127p1(C0153y1 c0153y1, AtomicReference atomicReference, String str, String str2, e2 e2Var, boolean z5) {
        this.q = atomicReference;
        this.f1956l = str;
        this.f1957m = str2;
        this.f1958n = e2Var;
        this.f1959o = z5;
        this.p = c0153y1;
    }
}
