package o; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.net.Uri; import android.os.Handler; import android.os.Message; import com.airbnb.deeplinkdispatch.UrlTreeKt; import java.util.ArrayList; import java.util.HashMap; import java.util.Set; @Deprecated /* renamed from: o.BcN, reason: case insensitive filesystem */ /* loaded from: classes.dex */ public final class C0198BcN { private static final Object a = new Object(); private static C0198BcN d; final Context e; private final Handler h; final HashMap> b = new HashMap<>(); private final HashMap> f = new HashMap<>(); final ArrayList c = new ArrayList<>(); /* renamed from: o.BcN$HBt */ /* loaded from: classes.dex */ static final class HBt { boolean a; final BroadcastReceiver b; boolean c; final IntentFilter e; HBt(IntentFilter intentFilter, BroadcastReceiver broadcastReceiver) { this.e = intentFilter; this.b = broadcastReceiver; } public final String toString() { StringBuilder sb = new StringBuilder(128); sb.append("Receiver{"); sb.append(this.b); sb.append(" filter="); sb.append(this.e); if (this.c) { sb.append(" DEAD"); } sb.append(UrlTreeKt.componentParamSuffix); return sb.toString(); } } /* renamed from: o.BcN$RVV */ /* loaded from: classes.dex */ static final class RVV { final Intent a; final ArrayList c; RVV(Intent intent, ArrayList arrayList) { this.a = intent; this.c = arrayList; } } public static C0198BcN d(Context context) { C0198BcN c0198BcN; synchronized (a) { if (d == null) { d = new C0198BcN(context.getApplicationContext()); } c0198BcN = d; } return c0198BcN; } private C0198BcN(Context context) { this.e = context; this.h = new Handler(this, context.getMainLooper()) { // from class: o.BcN.4 final C0198BcN e; { this.e = this; } @Override // android.os.Handler public final void handleMessage(Message message) { int size; RVV[] rvvArr; if (message.what != 1) { super.handleMessage(message); return; } C0198BcN c0198BcN = this.e; while (true) { synchronized (c0198BcN.b) { size = c0198BcN.c.size(); if (size <= 0) { return; } rvvArr = new RVV[size]; c0198BcN.c.toArray(rvvArr); c0198BcN.c.clear(); } for (int i = 0; i < size; i++) { RVV rvv = rvvArr[i]; int size2 = rvv.c.size(); for (int i2 = 0; i2 < size2; i2++) { HBt hBt = rvv.c.get(i2); if (!hBt.c) { hBt.b.onReceive(c0198BcN.e, rvv.a); } } } } } }; } public final void zD_(BroadcastReceiver broadcastReceiver, IntentFilter intentFilter) { synchronized (this.b) { HBt hBt = new HBt(intentFilter, broadcastReceiver); ArrayList arrayList = this.b.get(broadcastReceiver); if (arrayList == null) { arrayList = new ArrayList<>(1); this.b.put(broadcastReceiver, arrayList); } arrayList.add(hBt); for (int i = 0; i < intentFilter.countActions(); i++) { String action = intentFilter.getAction(i); ArrayList arrayList2 = this.f.get(action); if (arrayList2 == null) { arrayList2 = new ArrayList<>(1); this.f.put(action, arrayList2); } arrayList2.add(hBt); } } } public final void zF_(BroadcastReceiver broadcastReceiver) { synchronized (this.b) { ArrayList remove = this.b.remove(broadcastReceiver); if (remove == null) { return; } for (int size = remove.size() - 1; size >= 0; size--) { HBt hBt = remove.get(size); hBt.c = true; for (int i = 0; i < hBt.e.countActions(); i++) { String action = hBt.e.getAction(i); ArrayList arrayList = this.f.get(action); if (arrayList != null) { for (int size2 = arrayList.size() - 1; size2 >= 0; size2--) { HBt hBt2 = arrayList.get(size2); if (hBt2.b == broadcastReceiver) { hBt2.c = true; arrayList.remove(size2); } } if (arrayList.size() <= 0) { this.f.remove(action); } } } } } } public final boolean zE_(Intent intent) { int i; String str; ArrayList arrayList; ArrayList arrayList2; String str2; boolean z; synchronized (this.b) { String action = intent.getAction(); String resolveTypeIfNeeded = intent.resolveTypeIfNeeded(this.e.getContentResolver()); Uri data = intent.getData(); String scheme = intent.getScheme(); Set categories = intent.getCategories(); boolean z2 = true; boolean z3 = (intent.getFlags() & 8) != 0; ArrayList arrayList3 = this.f.get(intent.getAction()); if (arrayList3 != null) { ArrayList arrayList4 = null; int i2 = 0; while (i2 < arrayList3.size()) { HBt hBt = arrayList3.get(i2); if (z3) { IntentFilter intentFilter = hBt.e; } if (hBt.a) { i = i2; arrayList2 = arrayList3; str = action; str2 = resolveTypeIfNeeded; arrayList = arrayList4; z = z2; } else { IntentFilter intentFilter2 = hBt.e; String str3 = action; String str4 = resolveTypeIfNeeded; i = i2; str = action; arrayList = arrayList4; arrayList2 = arrayList3; str2 = resolveTypeIfNeeded; z = z2; if (intentFilter2.match(str3, str4, scheme, data, categories, "LocalBroadcastManager") >= 0) { arrayList4 = arrayList == null ? new ArrayList() : arrayList; arrayList4.add(hBt); hBt.a = z; i2 = i + 1; z2 = z; action = str; arrayList3 = arrayList2; resolveTypeIfNeeded = str2; } } arrayList4 = arrayList; i2 = i + 1; z2 = z; action = str; arrayList3 = arrayList2; resolveTypeIfNeeded = str2; } ArrayList arrayList5 = arrayList4; boolean z4 = z2; if (arrayList5 != null) { for (int i3 = 0; i3 < arrayList5.size(); i3++) { ((HBt) arrayList5.get(i3)).a = false; } this.c.add(new RVV(intent, arrayList5)); if (!this.h.hasMessages(z4 ? 1 : 0)) { this.h.sendEmptyMessage(z4 ? 1 : 0); } return z4; } } return false; } } }