package o;

import android.os.Binder;
import android.os.IBinder;
import android.os.IInterface;
import android.os.Parcel;
import android.os.RemoteException;
import androidx.room.MultiInstanceInvalidationService;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.pQ, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class BinderC2142pQ extends Binder implements IInterface {
    public final /* synthetic */ MultiInstanceInvalidationService d;

    public BinderC2142pQ(MultiInstanceInvalidationService multiInstanceInvalidationService) {
        this.d = multiInstanceInvalidationService;
        attachInterface(this, "androidx.room.IMultiInstanceInvalidationService");
    }

    @Override // android.os.Binder
    public final boolean onTransact(int i, Parcel parcel, Parcel parcel2, int i2) {
        if (i >= 1 && i <= 16777215) {
            parcel.enforceInterface("androidx.room.IMultiInstanceInvalidationService");
        }
        if (i == 1598968902) {
            parcel2.writeString("androidx.room.IMultiInstanceInvalidationService");
            return true;
        }
        C0893cG c0893cG = null;
        if (i == 1) {
            IBinder strongBinder = parcel.readStrongBinder();
            if (strongBinder != null) {
                IInterface iInterfaceQueryLocalInterface = strongBinder.queryLocalInterface("androidx.room.IMultiInstanceInvalidationCallback");
                if (iInterfaceQueryLocalInterface == null || !(iInterfaceQueryLocalInterface instanceof C0893cG)) {
                    c0893cG = new C0893cG();
                    c0893cG.d = strongBinder;
                } else {
                    c0893cG = (C0893cG) iInterfaceQueryLocalInterface;
                }
            }
            String string = parcel.readString();
            int i3 = 0;
            if (string != null) {
                MultiInstanceInvalidationService multiInstanceInvalidationService = this.d;
                synchronized (multiInstanceInvalidationService.n) {
                    try {
                        int i4 = multiInstanceInvalidationService.l + 1;
                        multiInstanceInvalidationService.l = i4;
                        if (multiInstanceInvalidationService.n.register(c0893cG, Integer.valueOf(i4))) {
                            multiInstanceInvalidationService.m.put(Integer.valueOf(i4), string);
                            i3 = i4;
                        } else {
                            multiInstanceInvalidationService.l--;
                        }
                    } finally {
                    }
                }
            }
            parcel2.writeNoException();
            parcel2.writeInt(i3);
            return true;
        }
        if (i == 2) {
            IBinder strongBinder2 = parcel.readStrongBinder();
            if (strongBinder2 != null) {
                IInterface iInterfaceQueryLocalInterface2 = strongBinder2.queryLocalInterface("androidx.room.IMultiInstanceInvalidationCallback");
                if (iInterfaceQueryLocalInterface2 == null || !(iInterfaceQueryLocalInterface2 instanceof C0893cG)) {
                    c0893cG = new C0893cG();
                    c0893cG.d = strongBinder2;
                } else {
                    c0893cG = (C0893cG) iInterfaceQueryLocalInterface2;
                }
            }
            int i5 = parcel.readInt();
            MultiInstanceInvalidationService multiInstanceInvalidationService2 = this.d;
            synchronized (multiInstanceInvalidationService2.n) {
                multiInstanceInvalidationService2.n.unregister(c0893cG);
            }
            parcel2.writeNoException();
            return true;
        }
        if (i != 3) {
            return super.onTransact(i, parcel, parcel2, i2);
        }
        int i6 = parcel.readInt();
        String[] strArrCreateStringArray = parcel.createStringArray();
        MultiInstanceInvalidationService multiInstanceInvalidationService3 = this.d;
        synchronized (multiInstanceInvalidationService3.n) {
            try {
                String str = (String) multiInstanceInvalidationService3.m.get(Integer.valueOf(i6));
                if (str != null) {
                    int iBeginBroadcast = multiInstanceInvalidationService3.n.beginBroadcast();
                    for (int i7 = 0; i7 < iBeginBroadcast; i7++) {
                        try {
                            Integer num = (Integer) multiInstanceInvalidationService3.n.getBroadcastCookie(i7);
                            int iIntValue = num.intValue();
                            String str2 = (String) multiInstanceInvalidationService3.m.get(num);
                            if (i6 != iIntValue && str.equals(str2)) {
                                try {
                                    ((C0893cG) multiInstanceInvalidationService3.n.getBroadcastItem(i7)).B(strArrCreateStringArray);
                                } catch (RemoteException unused) {
                                }
                            }
                        } finally {
                            multiInstanceInvalidationService3.n.finishBroadcast();
                        }
                    }
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        return true;
    }

    @Override // android.os.IInterface
    public final IBinder asBinder() {
        return this;
    }
}
