package P2;

import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Build;
import android.os.IBinder;
import android.os.StrictMode;
import java.util.HashMap;
import java.util.Iterator;
import java.util.concurrent.Executor;

/* JADX INFO: loaded from: classes.dex */
public final class F implements ServiceConnection {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final HashMap f5341q = new HashMap();

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public int f5342r = 2;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public boolean f5343s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public IBinder f5344t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public final E f5345u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public ComponentName f5346v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public final /* synthetic */ H f5347w;

    public F(H h8, E e8) {
        this.f5347w = h8;
        this.f5345u = e8;
    }

    public static M2.b a(F f3, String str, Executor executor) {
        try {
            Intent intentA = f3.f5345u.a(f3.f5347w.f5353b);
            f3.f5342r = 3;
            StrictMode.VmPolicy vmPolicy = StrictMode.getVmPolicy();
            if (Build.VERSION.SDK_INT >= 31) {
                StrictMode.setVmPolicy(T2.d.a(new StrictMode.VmPolicy.Builder(vmPolicy)).build());
            }
            try {
                H h8 = f3.f5347w;
                boolean zC = h8.f5355d.c(h8.f5353b, str, intentA, f3, 4225, executor);
                f3.f5343s = zC;
                if (zC) {
                    f3.f5347w.f5354c.sendMessageDelayed(f3.f5347w.f5354c.obtainMessage(1, f3.f5345u), f3.f5347w.f5357f);
                    M2.b bVar = M2.b.f4153u;
                    StrictMode.setVmPolicy(vmPolicy);
                    return bVar;
                }
                f3.f5342r = 2;
                try {
                    H h9 = f3.f5347w;
                    h9.f5355d.b(h9.f5353b, f3);
                } catch (IllegalArgumentException unused) {
                }
                M2.b bVar2 = new M2.b(16);
                StrictMode.setVmPolicy(vmPolicy);
                return bVar2;
            } catch (Throwable th) {
                StrictMode.setVmPolicy(vmPolicy);
                throw th;
            }
        } catch (x e8) {
            return e8.f5443q;
        }
    }

    @Override // android.content.ServiceConnection
    public final void onBindingDied(ComponentName componentName) {
        onServiceDisconnected(componentName);
    }

    @Override // android.content.ServiceConnection
    public final void onServiceConnected(ComponentName componentName, IBinder iBinder) {
        synchronized (this.f5347w.f5352a) {
            try {
                this.f5347w.f5354c.removeMessages(1, this.f5345u);
                this.f5344t = iBinder;
                this.f5346v = componentName;
                Iterator it = this.f5341q.values().iterator();
                while (it.hasNext()) {
                    ((ServiceConnection) it.next()).onServiceConnected(componentName, iBinder);
                }
                this.f5342r = 1;
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // android.content.ServiceConnection
    public final void onServiceDisconnected(ComponentName componentName) {
        synchronized (this.f5347w.f5352a) {
            try {
                this.f5347w.f5354c.removeMessages(1, this.f5345u);
                this.f5344t = null;
                this.f5346v = componentName;
                Iterator it = this.f5341q.values().iterator();
                while (it.hasNext()) {
                    ((ServiceConnection) it.next()).onServiceDisconnected(componentName);
                }
                this.f5342r = 2;
            } catch (Throwable th) {
                throw th;
            }
        }
    }
}
