package d3;

import java.util.concurrent.ScheduledExecutorService;

/* JADX INFO: renamed from: d3.r1, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class RunnableC0818r1 implements Runnable {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final /* synthetic */ int f12152q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final /* synthetic */ K f12153r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final /* synthetic */ ServiceConnectionC0821s1 f12154s;

    public /* synthetic */ RunnableC0818r1(ServiceConnectionC0821s1 serviceConnectionC0821s1, K k8, int i) {
        this.f12152q = i;
        this.f12153r = k8;
        this.f12154s = serviceConnectionC0821s1;
    }

    private final void a() {
        ServiceConnectionC0821s1 serviceConnectionC0821s1 = this.f12154s;
        synchronized (serviceConnectionC0821s1) {
            try {
                serviceConnectionC0821s1.f12171q = false;
                C0824t1 c0824t1 = serviceConnectionC0821s1.f12173s;
                if (!c0824t1.O()) {
                    Z z8 = ((C0817r0) c0824t1.f5146q).f12150y;
                    C0817r0.k(z8);
                    z8.D.b("Connected to service");
                    K k8 = this.f12153r;
                    c0824t1.E();
                    c0824t1.f12179t = k8;
                    c0824t1.U();
                    c0824t1.T();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // java.lang.Runnable
    public final void run() {
        ScheduledExecutorService scheduledExecutorService;
        switch (this.f12152q) {
            case n4.u0.f15495q /* 0 */:
                a();
                return;
            default:
                ServiceConnectionC0821s1 serviceConnectionC0821s1 = this.f12154s;
                synchronized (serviceConnectionC0821s1) {
                    try {
                        serviceConnectionC0821s1.f12171q = false;
                        C0824t1 c0824t1 = serviceConnectionC0821s1.f12173s;
                        if (!c0824t1.O()) {
                            Z z8 = ((C0817r0) c0824t1.f5146q).f12150y;
                            C0817r0.k(z8);
                            z8.f11871C.b("Connected to remote service");
                            K k8 = this.f12153r;
                            c0824t1.E();
                            c0824t1.f12179t = k8;
                            c0824t1.U();
                            c0824t1.T();
                        }
                    } catch (Throwable th) {
                        throw th;
                    }
                    break;
                }
                C0824t1 c0824t12 = this.f12154s.f12173s;
                if (!((C0817r0) c0824t12.f5146q).f12148w.R(null, I.p1) || (scheduledExecutorService = c0824t12.f12182w) == null) {
                    return;
                }
                scheduledExecutorService.shutdownNow();
                c0824t12.f12182w = null;
                return;
        }
    }
}
