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

import android.os.Bundle;
import android.os.RemoteException;
import androidx.annotation.Nullable;

/* JADX INFO: loaded from: classes2.dex */
public final class gu0 extends cu0 {

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public String f11881g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f11882h;

    @Override // com.google.android.gms.internal.ads.cu0, com.google.android.gms.common.internal.b
    public final void onConnected(@Nullable Bundle bundle) {
        synchronized (this.f10081b) {
            try {
                if (!this.f10083d) {
                    this.f10083d = true;
                    try {
                        int i10 = this.f11882h;
                        if (i10 == 2) {
                            this.f10085f.d().E0(this.f10084e, ((Boolean) n7.y.f31093e.f31096c.b(ao.f8909ie)).booleanValue() ? new bu0(this.f10080a, this.f10084e) : new au0(this));
                        } else if (i10 == 3) {
                            this.f10085f.d().D2(this.f11881g, ((Boolean) n7.y.f31093e.f31096c.b(ao.f8909ie)).booleanValue() ? new bu0(this.f10080a, this.f10084e) : new au0(this));
                        } else {
                            this.f10080a.a(new zzeff(1));
                        }
                    } catch (RemoteException | IllegalArgumentException unused) {
                        this.f10080a.a(new zzeff(1));
                    } catch (Throwable th) {
                        m7.n.C.f30469h.d("RemoteUrlAndCacheKeyClientTask.onConnected", th);
                        this.f10080a.a(new zzeff(1));
                    }
                }
            } catch (Throwable th2) {
                throw th2;
            }
        }
    }

    @Override // com.google.android.gms.internal.ads.cu0, com.google.android.gms.common.internal.c
    public final void onConnectionFailed(e8.b bVar) {
        q7.j.a("Cannot connect to remote service, fallback to local instance.");
        this.f10080a.a(new zzeff(1));
    }
}
