package androidx.room;

import X.AnonymousClass1DA;
import X.C04070Fp;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.IInterface;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import com.bytedance.covode.number.Covode;
import com.bytedance.helios.sdk.utils.ServiceLifecycle;
import java.util.HashMap;

public class MultiInstanceInvalidationService extends Service {
    public int LIZ;
    public final HashMap<Integer, String> LIZIZ = new HashMap<>();
    public final RemoteCallbackList<C04070Fp> LIZJ = new RemoteCallbackList<C04070Fp>() {
        static {
            Covode.recordClassIndex(1649);
        }

        public final /* synthetic */ void onCallbackDied(IInterface iInterface, Object obj) {
            MultiInstanceInvalidationService.this.LIZIZ.remove(Integer.valueOf(((Integer) obj).intValue()));
        }
    };
    public final AnonymousClass1DA LIZLLL = new AnonymousClass1DA() {
        static {
            Covode.recordClassIndex(1650);
        }

        public final void LIZ(C04070Fp r4, int i) {
            synchronized (MultiInstanceInvalidationService.this.LIZJ) {
                MultiInstanceInvalidationService.this.LIZJ.unregister(r4);
                MultiInstanceInvalidationService.this.LIZIZ.remove(Integer.valueOf(i));
            }
        }

        public final int LIZ(C04070Fp r6, String str) {
            if (str == null) {
                return 0;
            }
            synchronized (MultiInstanceInvalidationService.this.LIZJ) {
                MultiInstanceInvalidationService multiInstanceInvalidationService = MultiInstanceInvalidationService.this;
                int i = multiInstanceInvalidationService.LIZ + 1;
                multiInstanceInvalidationService.LIZ = i;
                if (MultiInstanceInvalidationService.this.LIZJ.register(r6, Integer.valueOf(i))) {
                    MultiInstanceInvalidationService.this.LIZIZ.put(Integer.valueOf(i), str);
                    return i;
                }
                MultiInstanceInvalidationService multiInstanceInvalidationService2 = MultiInstanceInvalidationService.this;
                multiInstanceInvalidationService2.LIZ--;
                return 0;
            }
        }

        public final void LIZ(int i, String[] strArr) {
            synchronized (MultiInstanceInvalidationService.this.LIZJ) {
                String str = MultiInstanceInvalidationService.this.LIZIZ.get(Integer.valueOf(i));
                if (str != null) {
                    int beginBroadcast = MultiInstanceInvalidationService.this.LIZJ.beginBroadcast();
                    int i2 = 0;
                    while (i2 < beginBroadcast) {
                        try {
                            int intValue = ((Integer) MultiInstanceInvalidationService.this.LIZJ.getBroadcastCookie(i2)).intValue();
                            String str2 = MultiInstanceInvalidationService.this.LIZIZ.get(Integer.valueOf(intValue));
                            if (i != intValue && str.equals(str2)) {
                                try {
                                    MultiInstanceInvalidationService.this.LIZJ.getBroadcastItem(i2).LIZ(strArr);
                                } catch (RemoteException unused) {
                                }
                            }
                            i2++;
                        } catch (Throwable th) {
                            MultiInstanceInvalidationService.this.LIZJ.finishBroadcast();
                            throw th;
                        }
                    }
                    MultiInstanceInvalidationService.this.LIZJ.finishBroadcast();
                }
            }
        }
    };

    static {
        Covode.recordClassIndex(1648);
    }

    public int onStartCommand(Intent intent, int i, int i2) {
        ServiceLifecycle.onStartCommand(this, intent, i, i2);
        return super.onStartCommand(intent, i, i2);
    }

    public IBinder onBind(Intent intent) {
        return this.LIZLLL;
    }
}
