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

import android.os.Bundle;
import android.os.IBinder;
import android.os.IInterface;
import android.os.RemoteException;
import androidx.annotation.BinderThread;
import androidx.annotation.Nullable;
import java.util.Objects;

/* JADX INFO: loaded from: classes2.dex */
public final class a1 extends p0 {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final /* synthetic */ g f8316e;

    @Nullable
    public final IBinder zze;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    @BinderThread
    public a1(g gVar, @Nullable int i10, @Nullable IBinder iBinder, Bundle bundle) {
        super(gVar, i10, bundle);
        Objects.requireNonNull(gVar);
        this.f8316e = gVar;
        this.zze = iBinder;
    }

    @Override // com.google.android.gms.common.internal.p0
    public final boolean d() {
        try {
            IBinder iBinder = this.zze;
            w.checkNotNull(iBinder);
            String interfaceDescriptor = iBinder.getInterfaceDescriptor();
            g gVar = this.f8316e;
            if (!gVar.getServiceDescriptor().equals(interfaceDescriptor)) {
                new StringBuilder(String.valueOf(gVar.getServiceDescriptor()).length() + 34 + String.valueOf(interfaceDescriptor).length());
                return false;
            }
            IInterface iInterfaceCreateServiceInterface = gVar.createServiceInterface(this.zze);
            if (iInterfaceCreateServiceInterface == null) {
                return false;
            }
            if (!gVar.zze(2, 4, iInterfaceCreateServiceInterface) && !gVar.zze(3, 4, iInterfaceCreateServiceInterface)) {
                return false;
            }
            gVar.zzn(null);
            b bVarZzk = gVar.zzk();
            Bundle connectionHint = gVar.getConnectionHint();
            if (bVarZzk != null) {
                gVar.zzk().onConnected(connectionHint);
            }
            return true;
        } catch (RemoteException unused) {
            return false;
        }
    }

    @Override // com.google.android.gms.common.internal.p0
    public final void e(e8.b bVar) {
        g gVar = this.f8316e;
        if (gVar.zzl() != null) {
            gVar.zzl().onConnectionFailed(bVar);
        }
        gVar.onConnectionFailed(bVar);
    }
}
