package o;

import android.os.Bundle;
import android.os.RemoteException;
import android.text.TextUtils;
import com.google.android.gms.common.internal.Preconditions;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.rt0, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class RunnableC2380rt0 implements Runnable {
    public final /* synthetic */ int l = 0;
    public final /* synthetic */ String m;
    public final /* synthetic */ String n;

    /* renamed from: o, reason: collision with root package name */
    public final /* synthetic */ C1531iw0 f707o;
    public final /* synthetic */ boolean p;
    public final /* synthetic */ Vt0 q;
    public final /* synthetic */ Object r;

    public RunnableC2380rt0(Vt0 vt0, String str, String str2, C1531iw0 c1531iw0, boolean z, InterfaceC2183pp0 interfaceC2183pp0) {
        this.m = str;
        this.n = str2;
        this.f707o = c1531iw0;
        this.p = z;
        this.r = interfaceC2183pp0;
        this.q = vt0;
    }

    @Override // java.lang.Runnable
    public final void run() throws Throwable {
        C2574tv0 c2574tv0;
        InterfaceC2185pq0 interfaceC2185pq0;
        Kr0 kr0;
        AtomicReference atomicReference;
        Vt0 vt0;
        InterfaceC2185pq0 interfaceC2185pq02;
        switch (this.l) {
            case 0:
                String str = this.n;
                String str2 = this.m;
                InterfaceC2183pp0 interfaceC2183pp0 = (InterfaceC2183pp0) this.r;
                Vt0 vt02 = this.q;
                Bundle bundle = new Bundle();
                try {
                    try {
                        interfaceC2185pq0 = vt02.d;
                        kr0 = (Kr0) vt02.a;
                    } catch (Throwable th) {
                        th = th;
                    }
                } catch (RemoteException e) {
                    e = e;
                }
                if (interfaceC2185pq0 == null) {
                    Nq0 nq0 = kr0.f;
                    Kr0.l(nq0);
                    nq0.f.d("Failed to get user properties; not connected to service", str2, str);
                    c2574tv0 = kr0.i;
                    Kr0.j(c2574tv0);
                    c2574tv0.e0(interfaceC2183pp0, bundle);
                    return;
                }
                C1531iw0 c1531iw0 = this.f707o;
                Preconditions.checkNotNull(c1531iw0);
                List<C1910mv0> listX = interfaceC2185pq0.x(str2, str, this.p, c1531iw0);
                Bundle bundle2 = new Bundle();
                if (listX != null) {
                    for (C1910mv0 c1910mv0 : listX) {
                        String str3 = c1910mv0.p;
                        String str4 = c1910mv0.m;
                        if (str3 != null) {
                            bundle2.putString(str4, str3);
                        } else {
                            Long l = c1910mv0.f644o;
                            if (l != null) {
                                bundle2.putLong(str4, l.longValue());
                            } else {
                                Double d = c1910mv0.r;
                                if (d != null) {
                                    bundle2.putDouble(str4, d.doubleValue());
                                }
                            }
                        }
                    }
                }
                try {
                    vt02.F();
                    C2574tv0 c2574tv02 = kr0.i;
                    Kr0.j(c2574tv02);
                    c2574tv02.e0(interfaceC2183pp0, bundle2);
                    return;
                } catch (RemoteException e2) {
                    e = e2;
                    bundle = bundle2;
                    Nq0 nq02 = ((Kr0) vt02.a).f;
                    Kr0.l(nq02);
                    nq02.f.d("Failed to get user properties; remote exception", str2, e);
                    c2574tv0 = ((Kr0) vt02.a).i;
                    Kr0.j(c2574tv0);
                    c2574tv0.e0(interfaceC2183pp0, bundle);
                    return;
                } catch (Throwable th2) {
                    th = th2;
                    bundle = bundle2;
                    C2574tv0 c2574tv03 = ((Kr0) vt02.a).i;
                    Kr0.j(c2574tv03);
                    c2574tv03.e0(interfaceC2183pp0, bundle);
                    throw th;
                }
            default:
                AtomicReference atomicReference2 = (AtomicReference) this.r;
                synchronized (atomicReference2) {
                    try {
                        try {
                            vt0 = this.q;
                            interfaceC2185pq02 = vt0.d;
                        } catch (RemoteException e3) {
                            Nq0 nq03 = ((Kr0) this.q.a).f;
                            Kr0.l(nq03);
                            nq03.f.e("(legacy) Failed to get user properties; remote exception", null, this.m, e3);
                            ((AtomicReference) this.r).set(Collections.EMPTY_LIST);
                            atomicReference = (AtomicReference) this.r;
                        }
                        if (interfaceC2185pq02 == null) {
                            Nq0 nq04 = ((Kr0) vt0.a).f;
                            Kr0.l(nq04);
                            nq04.f.e("(legacy) Failed to get user properties; not connected to service", null, this.m, this.n);
                            atomicReference2.set(Collections.EMPTY_LIST);
                            atomicReference2.notify();
                            return;
                        }
                        if (TextUtils.isEmpty(null)) {
                            C1531iw0 c1531iw02 = this.f707o;
                            Preconditions.checkNotNull(c1531iw02);
                            atomicReference2.set(interfaceC2185pq02.x(this.m, this.n, this.p, c1531iw02));
                        } else {
                            atomicReference2.set(interfaceC2185pq02.d(null, this.m, this.n, this.p));
                        }
                        vt0.F();
                        atomicReference = (AtomicReference) this.r;
                        atomicReference.notify();
                        return;
                    } catch (Throwable th3) {
                        ((AtomicReference) this.r).notify();
                        throw th3;
                    }
                }
        }
    }

    public RunnableC2380rt0(Vt0 vt0, AtomicReference atomicReference, String str, String str2, C1531iw0 c1531iw0, boolean z) {
        this.r = atomicReference;
        this.m = str;
        this.n = str2;
        this.f707o = c1531iw0;
        this.p = z;
        this.q = vt0;
    }
}
