package O1;

import B0.C0016c;
import Z6.AbstractC0385z;
import android.os.RemoteException;
import android.util.Log;
import java.util.concurrent.locks.ReentrantLock;
import n4.u0;

/* JADX INFO: loaded from: classes.dex */
public final /* synthetic */ class z extends P6.f implements O6.a {

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public /* synthetic */ z(int i, Object obj, Class cls, String str, String str2, int i5, int i8) {
        super(i, obj, cls, str, str2, i5);
        this.f5090y = i8;
    }

    @Override // O6.a
    public final Object a() throws Exception {
        switch (this.f5090y) {
            case u0.f15495q /* 0 */:
                A a3 = (A) this.f5518r;
                e7.c cVar = a3.f4914a;
                if (cVar == null) {
                    P6.g.h("coroutineScope");
                    throw null;
                }
                AbstractC0385z.f(cVar);
                C0238n c0238n = a3.d().i;
                if (c0238n != null) {
                    if (c0238n.f5060e.compareAndSet(false, true)) {
                        C0234j c0234j = c0238n.f5057b;
                        C0225a c0225a = c0238n.i;
                        P6.g.e(c0225a, "observer");
                        ReentrantLock reentrantLock = c0234j.f5044e;
                        reentrantLock.lock();
                        try {
                            C0242s c0242s = (C0242s) c0234j.f5043d.remove(c0225a);
                            if (c0242s != null) {
                                T t6 = c0234j.f5042c;
                                t6.getClass();
                                int[] iArr = c0242s.f5075b;
                                C0016c c0016c = t6.f5006h;
                                c0016c.getClass();
                                ReentrantLock reentrantLock2 = (ReentrantLock) c0016c.f718r;
                                reentrantLock2.lock();
                                try {
                                    boolean z8 = false;
                                    for (int i : iArr) {
                                        long[] jArr = (long[]) c0016c.f719s;
                                        long j8 = jArr[i];
                                        jArr[i] = j8 - 1;
                                        if (j8 == 1) {
                                            c0016c.f717q = true;
                                            z8 = true;
                                        }
                                    }
                                    if (z8) {
                                        C0233i c0233i = new C0233i(c0234j, null);
                                        Thread.interrupted();
                                        AbstractC0385z.v(E6.j.f2226q, new Q1.w(c0233i, null));
                                    }
                                } finally {
                                    reentrantLock2.unlock();
                                }
                            }
                            try {
                                InterfaceC0231g interfaceC0231g = c0238n.f5062g;
                                if (interfaceC0231g != null) {
                                    interfaceC0231g.x(c0238n.f5064j, c0238n.f5061f);
                                }
                            } catch (RemoteException e8) {
                                Log.w("ROOM", "Cannot unregister multi-instance invalidation callback", e8);
                            }
                            c0238n.f5058c.unbindService(c0238n.f5065k);
                        } finally {
                            reentrantLock.unlock();
                        }
                    }
                    break;
                }
                w wVar = a3.f4918e;
                if (wVar != null) {
                    wVar.f5084f.close();
                    return A6.n.f457a;
                }
                P6.g.h("connectionManager");
                throw null;
            case 1:
                ((d.x) this.f5518r).e();
                return A6.n.f457a;
            default:
                ((d.x) this.f5518r).e();
                return A6.n.f457a;
        }
    }
}
