package defpackage;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.os.Build;
import j$.util.concurrent.ConcurrentHashMap;
import java.util.NoSuchElementException;
import java.util.concurrent.Executor;

/* renamed from: ᵦˑᵶ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C3580 {

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public static volatile C3580 f13386;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public static final Object f13387 = new Object();

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final ConcurrentHashMap f13388 = new ConcurrentHashMap();

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public static C3580 m8186() {
        if (f13386 == null) {
            synchronized (f13387) {
                try {
                    if (f13386 == null) {
                        f13386 = new C3580();
                    }
                } finally {
                }
            }
        }
        C3580 c3580 = f13386;
        ᵩʛʽ.ᵝᵵᵺ(c3580);
        return c3580;
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final boolean m8187(Context context, String str, Intent intent, ServiceConnection serviceConnection, int i, Executor executor) {
        ComponentName component = intent.getComponent();
        if (component != null) {
            String packageName = component.getPackageName();
            "com.google.android.gms".equals(packageName);
            try {
                if ((C4004.m8846(context).f11588.getPackageManager().getApplicationInfo(packageName, 0).flags & 2097152) != 0) {
                    return false;
                }
            } catch (PackageManager.NameNotFoundException unused) {
            }
        }
        if (serviceConnection instanceof ServiceConnectionC1180) {
            if (executor == null) {
                executor = null;
            }
            return (Build.VERSION.SDK_INT < 29 || executor == null) ? context.bindService(intent, serviceConnection, i) : context.bindService(intent, i, executor, serviceConnection);
        }
        ConcurrentHashMap concurrentHashMap = this.f13388;
        ServiceConnection serviceConnection2 = (ServiceConnection) concurrentHashMap.putIfAbsent(serviceConnection, serviceConnection);
        if (serviceConnection2 != null && serviceConnection != serviceConnection2) {
            String.format("Duplicate binding with the same ServiceConnection: %s, %s, %s.", serviceConnection, str, intent.getAction());
        }
        if (executor == null) {
            executor = null;
        }
        try {
            boolean zBindService = (Build.VERSION.SDK_INT < 29 || executor == null) ? context.bindService(intent, serviceConnection, i) : context.bindService(intent, i, executor, serviceConnection);
            if (zBindService) {
                return zBindService;
            }
            return false;
        } finally {
            concurrentHashMap.remove(serviceConnection, serviceConnection);
        }
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final void m8188(Context context, ServiceConnection serviceConnection) {
        if (!(serviceConnection instanceof ServiceConnectionC1180)) {
            ConcurrentHashMap concurrentHashMap = this.f13388;
            if (concurrentHashMap.containsKey(serviceConnection)) {
                try {
                    try {
                        context.unbindService((ServiceConnection) concurrentHashMap.get(serviceConnection));
                    } catch (IllegalArgumentException | IllegalStateException | NoSuchElementException unused) {
                    }
                    return;
                } finally {
                    concurrentHashMap.remove(serviceConnection);
                }
            }
        }
        try {
            context.unbindService(serviceConnection);
        } catch (IllegalArgumentException | IllegalStateException | NoSuchElementException unused2) {
        }
    }
}
