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

import android.content.ComponentName;
import android.content.Context;
import android.os.RemoteException;
import androidx.annotation.Nullable;
import java.util.concurrent.atomic.AtomicBoolean;

/* JADX INFO: loaded from: classes2.dex */
public final class so extends androidx.browser.customtabs.v {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final AtomicBoolean f16514a = new AtomicBoolean(false);

    @Nullable
    private Context zzc;

    @Nullable
    private cr0 zzd;

    @Nullable
    private androidx.browser.customtabs.z zze;

    @Nullable
    private androidx.browser.customtabs.l zzf;

    private final void zzf(@Nullable Context context) {
        String packageName;
        if (this.zzf != null || context == null || (packageName = androidx.browser.customtabs.l.getPackageName(context, null)) == null || packageName.equals(context.getPackageName())) {
            return;
        }
        androidx.browser.customtabs.l.bindCustomTabsService(context, packageName, this);
    }

    public final void a(Context context, cr0 cr0Var) {
        if (this.f16514a.getAndSet(true)) {
            return;
        }
        this.zzc = context;
        this.zzd = cr0Var;
        zzf(context);
    }

    public final void b(int i10) {
        if (!((Boolean) n7.y.f31093e.f31096c.b(ao.f9016p5)).booleanValue() || this.zzd == null) {
            return;
        }
        b30.f9359a.execute(new lh(i10, 1, this));
    }

    public final /* synthetic */ void c() {
        zzf(this.zzc);
    }

    public final /* synthetic */ void d(int i10) {
        cr0 cr0Var = this.zzd;
        if (cr0Var != null) {
            br0 br0VarA = cr0Var.a();
            br0VarA.zzc("action", "cct_nav");
            br0VarA.zzc("cct_navs", String.valueOf(i10));
            br0VarA.b();
        }
    }

    @Override // androidx.browser.customtabs.v
    public final void onCustomTabsServiceConnected(ComponentName componentName, androidx.browser.customtabs.l lVar) {
        this.zzf = lVar;
        try {
            lVar.f877a.warmup(0L);
        } catch (RemoteException unused) {
        }
        this.zze = lVar.newSession(new ro(this));
    }

    @Override // android.content.ServiceConnection
    public final void onServiceDisconnected(ComponentName componentName) {
        this.zzf = null;
        this.zze = null;
    }

    @Nullable
    public final androidx.browser.customtabs.z zzb() {
        if (this.zze == null) {
            b30.f9359a.execute(new mv1(this, 14));
        }
        return this.zze;
    }
}
