package defpackage;

import android.accounts.Account;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.DeadObjectException;
import android.os.IBinder;
import android.os.IInterface;
import android.os.Looper;
import android.os.RemoteException;
import com.google.android.gms.common.api.Scope;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;

/* renamed from: ˉᵕᵢ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public abstract class AbstractC1187 {

    /* renamed from: ᵛˈᵤ, reason: contains not printable characters */
    public static final C0377[] f5039 = new C0377[0];

    /* renamed from: ˁˑᵰ, reason: contains not printable characters */
    public final InterfaceC1300 f5042;

    /* renamed from: ˎˑː, reason: contains not printable characters */
    public InterfaceC2004 f5045;

    /* renamed from: ˑᵥˁ, reason: contains not printable characters */
    public C0286 f5047;

    /* renamed from: ᵙᵢᵨᵳ, reason: contains not printable characters */
    public final String f5049;

    /* renamed from: ᵡᵘˎʽ, reason: contains not printable characters */
    public volatile String f5051;

    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public final HandlerC4301 f5052;

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public C4413 f5053;

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public final C1029 f5054;

    /* renamed from: ᵮᵠـˌ, reason: contains not printable characters */
    public IInterface f5057;

    /* renamed from: ᵶʔᵢˊ, reason: contains not printable characters */
    public final InterfaceC1929 f5058;

    /* renamed from: ᵺʙ, reason: contains not printable characters */
    public ServiceConnectionC3772 f5059;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public final C2782 f5060;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public final Context f5061;

    /* renamed from: ﾞⁱ, reason: contains not printable characters */
    public final int f5062;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public volatile String f5056 = null;

    /* renamed from: ˀᵗᵝᵭ, reason: contains not printable characters */
    public final Object f5040 = new Object();

    /* renamed from: ᵡˎ, reason: contains not printable characters */
    public final Object f5050 = new Object();

    /* renamed from: ᵧـˌᵎ, reason: contains not printable characters */
    public final ArrayList f5055 = new ArrayList();

    /* renamed from: ᐧﾞ, reason: contains not printable characters */
    public int f5048 = 1;

    /* renamed from: ˑᵝﹳᵜ, reason: contains not printable characters */
    public C0548 f5046 = null;

    /* renamed from: ˊᵸˊ, reason: contains not printable characters */
    public boolean f5044 = false;

    /* renamed from: ˀᵗᵩ, reason: contains not printable characters */
    public volatile C2244 f5041 = null;

    /* renamed from: ˆᵼᵷˊ, reason: contains not printable characters */
    public final AtomicInteger f5043 = new AtomicInteger(0);

    public AbstractC1187(Context context, Looper looper, C2782 c2782, C1029 c1029, int i, InterfaceC1929 interfaceC1929, InterfaceC1300 interfaceC1300, String str) {
        ᵩʛʽ.ᵶᵷᵕ(context, "Context must not be null");
        this.f5061 = context;
        ᵩʛʽ.ᵶᵷᵕ(looper, "Looper must not be null");
        ᵩʛʽ.ᵶᵷᵕ(c2782, "Supervisor must not be null");
        this.f5060 = c2782;
        ᵩʛʽ.ᵶᵷᵕ(c1029, "API availability must not be null");
        this.f5054 = c1029;
        this.f5052 = new HandlerC4301(this, looper);
        this.f5062 = i;
        this.f5058 = interfaceC1929;
        this.f5042 = interfaceC1300;
        this.f5049 = str;
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final void m3706() {
        if (!m3709() || this.f5053 == null) {
            C1260.m3816("Failed to connect when checking package");
        }
    }

    /* renamed from: ˌʾˀ, reason: contains not printable characters */
    public Account mo3707() {
        return null;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public final void m3708(InterfaceC1393 interfaceC1393, Set set) {
        Bundle bundleMo1328 = mo1328();
        String str = this.f5051;
        int i = this.f5062;
        int i2 = C1029.f4495;
        Scope[] scopeArr = C5334.f19974;
        Bundle bundle = new Bundle();
        C0377[] c0377Arr = C5334.f19973;
        C5334 c5334 = new C5334(6, i, i2, null, null, scopeArr, bundle, null, c0377Arr, c0377Arr, true, 0, false, str);
        c5334.f19987 = this.f5061.getPackageName();
        c5334.f19975 = bundleMo1328;
        if (set != null) {
            c5334.f19980 = (Scope[]) set.toArray(new Scope[0]);
        }
        if (mo3720()) {
            Account accountMo3707 = mo3707();
            if (accountMo3707 == null) {
                accountMo3707 = new Account("<<default account>>", "com.google");
            }
            c5334.f19979 = accountMo3707;
            if (interfaceC1393 != 0) {
                c5334.f19982 = ((AbstractC4043) interfaceC1393).f15206;
            }
        }
        c5334.f19977 = f5039;
        c5334.f19976 = mo1324();
        try {
            try {
                synchronized (this.f5050) {
                    try {
                        C0286 c0286 = this.f5047;
                        if (c0286 != null) {
                            c0286.m1622(new BinderC5101(this, this.f5043.get()), c5334);
                        }
                    } finally {
                    }
                }
            } catch (RemoteException | RuntimeException unused) {
                int i3 = this.f5043.get();
                C3721 c3721 = new C3721(this, 8, null, null);
                HandlerC4301 handlerC4301 = this.f5052;
                handlerC4301.sendMessage(handlerC4301.obtainMessage(1, i3, -1, c3721));
            }
        } catch (DeadObjectException unused2) {
            int i4 = this.f5043.get();
            HandlerC4301 handlerC43012 = this.f5052;
            handlerC43012.sendMessage(handlerC43012.obtainMessage(6, i4, 3));
        } catch (SecurityException e) {
            throw e;
        }
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final boolean m3709() {
        boolean z;
        synchronized (this.f5040) {
            z = this.f5048 == 4;
        }
        return z;
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final void m3710(InterfaceC2004 interfaceC2004) {
        this.f5045 = interfaceC2004;
        m3714(2, null);
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final void m3711(C4457 c4457) {
        ((C5024) c4457.f16625).f18767.f10656.post(new RunnableC2802(28, c4457));
    }

    /* renamed from: ˑᵱ */
    public abstract String mo1323();

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public final C0377[] m3712() {
        C2244 c2244 = this.f5041;
        if (c2244 == null) {
            return null;
        }
        return c2244.f8795;
    }

    /* renamed from: ᵞʡ, reason: contains not printable characters */
    public Set mo3713() {
        return Collections.EMPTY_SET;
    }

    /* renamed from: ᵡʠ */
    public C0377[] mo1324() {
        return f5039;
    }

    /* renamed from: ᵢˇᵭ */
    public boolean mo1325() {
        return mo1329() >= 211700000;
    }

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public final void m3714(int i, IInterface iInterface) {
        C4413 c4413;
        ᵩʛʽ.ᵻᵢﹳᵰ((i == 4) == (iInterface != null));
        synchronized (this.f5040) {
            try {
                this.f5048 = i;
                this.f5057 = iInterface;
                Bundle bundle = null;
                if (i == 1) {
                    ServiceConnectionC3772 serviceConnectionC3772 = this.f5059;
                    if (serviceConnectionC3772 != null) {
                        C2782 c2782 = this.f5060;
                        String str = this.f5053.f16508;
                        ᵩʛʽ.ᵝᵵᵺ(str);
                        this.f5053.getClass();
                        if (this.f5049 == null) {
                            this.f5061.getClass();
                        }
                        c2782.m6870(str, serviceConnectionC3772, this.f5053.f16510);
                        this.f5059 = null;
                    }
                } else if (i == 2 || i == 3) {
                    ServiceConnectionC3772 serviceConnectionC37722 = this.f5059;
                    if (serviceConnectionC37722 != null && (c4413 = this.f5053) != null) {
                        new StringBuilder(String.valueOf(c4413.f16508).length() + 70 + "com.google.android.gms".length());
                        C2782 c27822 = this.f5060;
                        String str2 = this.f5053.f16508;
                        ᵩʛʽ.ᵝᵵᵺ(str2);
                        this.f5053.getClass();
                        if (this.f5049 == null) {
                            this.f5061.getClass();
                        }
                        c27822.m6870(str2, serviceConnectionC37722, this.f5053.f16510);
                        this.f5043.incrementAndGet();
                    }
                    ServiceConnectionC3772 serviceConnectionC37723 = new ServiceConnectionC3772(this, this.f5043.get());
                    this.f5059 = serviceConnectionC37723;
                    String strMo1326 = mo1326();
                    boolean zMo1325 = mo1325();
                    this.f5053 = new C4413(2, strMo1326, zMo1325);
                    if (zMo1325 && mo1329() < 17895000) {
                        throw new IllegalStateException("Internal Error, the minimum apk version of this BaseGmsClient is too low to support dynamic lookup. Start service action: ".concat(String.valueOf(this.f5053.f16508)));
                    }
                    C2782 c27823 = this.f5060;
                    String str3 = this.f5053.f16508;
                    ᵩʛʽ.ᵝᵵᵺ(str3);
                    this.f5053.getClass();
                    String name = this.f5049;
                    if (name == null) {
                        name = this.f5061.getClass().getName();
                    }
                    C0548 c0548M6869 = c27823.m6869(new C2224(str3, this.f5053.f16510), serviceConnectionC37723, name, null);
                    if (!(c0548M6869.f2846 == 0)) {
                        new StringBuilder(String.valueOf(this.f5053.f16508).length() + 34 + "com.google.android.gms".length());
                        int i2 = c0548M6869.f2846;
                        if (i2 == -1) {
                            i2 = 16;
                        }
                        if (c0548M6869.f2850 != null) {
                            bundle = new Bundle();
                            bundle.putParcelable("pendingIntent", c0548M6869.f2850);
                        }
                        int i3 = this.f5043.get();
                        C2460 c2460 = new C2460(this, i2, bundle);
                        HandlerC4301 handlerC4301 = this.f5052;
                        handlerC4301.sendMessage(handlerC4301.obtainMessage(7, i3, -1, c2460));
                    }
                } else if (i == 4) {
                    ᵩʛʽ.ᵝᵵᵺ(iInterface);
                    System.currentTimeMillis();
                }
            } finally {
            }
        }
    }

    /* renamed from: ᵧᵾˀˈ */
    public abstract String mo1326();

    /* renamed from: ᵨᵳʝ, reason: contains not printable characters */
    public final IInterface m3715() {
        IInterface iInterface;
        synchronized (this.f5040) {
            try {
                if (this.f5048 == 5) {
                    throw new DeadObjectException();
                }
                if (!m3709()) {
                    throw new IllegalStateException("Not connected. Call connect() and wait for onConnected() to be called.");
                }
                iInterface = this.f5057;
                ᵩʛʽ.ᵶᵷᵕ(iInterface, "Client is connected but service is null");
            } catch (Throwable th) {
                throw th;
            }
        }
        return iInterface;
    }

    /* renamed from: ᵪʩ */
    public abstract IInterface mo1327(IBinder iBinder);

    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public final void m3716() throws PackageManager.NameNotFoundException {
        int iM3394 = this.f5054.m3394(this.f5061, mo1329());
        if (iM3394 == 0) {
            m3710(new ˊᵘʛ(this));
            return;
        }
        m3714(1, null);
        this.f5045 = new ˊᵘʛ(this);
        int i = this.f5043.get();
        HandlerC4301 handlerC4301 = this.f5052;
        handlerC4301.sendMessage(handlerC4301.obtainMessage(3, i, iM3394, null));
    }

    /* renamed from: ᵳٴᵶ, reason: contains not printable characters */
    public final void m3717() {
        this.f5043.incrementAndGet();
        ArrayList arrayList = this.f5055;
        synchronized (arrayList) {
            try {
                int size = arrayList.size();
                for (int i = 0; i < size; i++) {
                    ((AbstractC0729) arrayList.get(i)).m2789();
                }
                arrayList.clear();
            } catch (Throwable th) {
                throw th;
            }
        }
        synchronized (this.f5050) {
            this.f5047 = null;
        }
        m3714(1, null);
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final void m3718(String str) {
        this.f5056 = str;
        m3717();
    }

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public final String m3719() {
        return this.f5056;
    }

    /* renamed from: ᵸʓᵠ */
    public Bundle mo1328() {
        return new Bundle();
    }

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public boolean mo3720() {
        return false;
    }

    /* renamed from: ᵹᵝᵶ */
    public abstract int mo1329();

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final boolean m3721() {
        boolean z;
        synchronized (this.f5040) {
            int i = this.f5048;
            z = true;
            if (i != 2 && i != 3) {
                z = false;
            }
        }
        return z;
    }

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public final /* synthetic */ void m3722() {
        int i;
        int i2;
        synchronized (this.f5040) {
            i = this.f5048;
        }
        if (i == 3) {
            this.f5044 = true;
            i2 = 5;
        } else {
            i2 = 4;
        }
        HandlerC4301 handlerC4301 = this.f5052;
        handlerC4301.sendMessage(handlerC4301.obtainMessage(i2, this.f5043.get(), 16));
    }

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public final /* synthetic */ boolean m3723(int i, int i2, IInterface iInterface) {
        synchronized (this.f5040) {
            try {
                if (this.f5048 != i) {
                    return false;
                }
                m3714(i2, iInterface);
                return true;
            } catch (Throwable th) {
                throw th;
            }
        }
    }
}
