翰林优商.apk(点击下载) / aa.java


package com.sigmob.sdk.base.common;

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 android.util.Log;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;

public class aa {
    static final int a = 1;
    private static final String b = "LocalBroadcastManager";
    private static final boolean c = false;
    private static final Object d = new Object();
    private static aa e;
    private final Context f;
    private final HashMap<BroadcastReceiver, ArrayList<b>> g = new HashMap<>();
    private final HashMap<String, ArrayList<b>> h = new HashMap<>();
    private final ArrayList<a> i = new ArrayList<>();
    private final Handler j;

    /* access modifiers changed from: private */
    public static final class a {
        final Intent a;
        final ArrayList<b> b;

        a(Intent intent, ArrayList<b> arrayList) {
            this.a = intent;
            this.b = arrayList;
        }
    }

    /* access modifiers changed from: private */
    public static final class b {
        final IntentFilter a;
        final BroadcastReceiver b;
        boolean c;
        boolean d;

        b(IntentFilter intentFilter, BroadcastReceiver broadcastReceiver) {
            this.a = intentFilter;
            this.b = broadcastReceiver;
        }

        public String toString() {
            StringBuilder sb = new StringBuilder(128);
            sb.append("Receiver{");
            sb.append(this.b);
            sb.append(" filter=");
            sb.append(this.a);
            if (this.d) {
                sb.append(" DEAD");
            }
            sb.append("}");
            return sb.toString();
        }
    }

    private aa(Context context) {
        this.f = context;
        this.j = new Handler(context.getMainLooper()) {
            /* class com.sigmob.sdk.base.common.aa.AnonymousClass1 */

            public void handleMessage(Message message) {
                if (message.what != 1) {
                    super.handleMessage(message);
                } else {
                    aa.this.a();
                }
            }
        };
    }

    public static aa a(Context context) {
        aa aaVar;
        synchronized (d) {
            if (e == null) {
                e = new aa(context.getApplicationContext());
            }
            aaVar = e;
        }
        return aaVar;
    }

    /* access modifiers changed from: package-private */
    /* JADX WARNING: Code restructure failed: missing block: B:10:0x001c, code lost:
        if (r3 >= r1) goto L_0x0000;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:11:0x001e, code lost:
        r4 = r2[r3];
        r5 = r4.b.size();
        r6 = 0;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:12:0x0027, code lost:
        if (r6 >= r5) goto L_0x0041;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:13:0x0029, code lost:
        r7 = r4.b.get(r6);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:14:0x0033, code lost:
        if (r7.d != false) goto L_0x003e;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:15:0x0035, code lost:
        r7.b.onReceive(r10.f, r4.a);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:16:0x003e, code lost:
        r6 = r6 + 1;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:17:0x0041, code lost:
        r3 = r3 + 1;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:9:0x001a, code lost:
        r3 = 0;
     */
    public void a() {
        while (true) {
            synchronized (this.g) {
                int size = this.i.size();
                if (size > 0) {
                    a[] aVarArr = new a[size];
                    this.i.toArray(aVarArr);
                    this.i.clear();
                } else {
                    return;
                }
            }
        }
    }

    public void a(BroadcastReceiver broadcastReceiver) {
        synchronized (this.g) {
            ArrayList<b> remove = this.g.remove(broadcastReceiver);
            if (remove != null) {
                for (int size = remove.size() - 1; size >= 0; size--) {
                    b bVar = remove.get(size);
                    bVar.d = true;
                    for (int i2 = 0; i2 < bVar.a.countActions(); i2++) {
                        String action = bVar.a.getAction(i2);
                        ArrayList<b> arrayList = this.h.get(action);
                        if (arrayList != null) {
                            for (int size2 = arrayList.size() - 1; size2 >= 0; size2--) {
                                b bVar2 = arrayList.get(size2);
                                if (bVar2.b == broadcastReceiver) {
                                    bVar2.d = true;
                                    arrayList.remove(size2);
                                }
                            }
                            if (arrayList.size() <= 0) {
                                this.h.remove(action);
                            }
                        }
                    }
                }
            }
        }
    }

    public void a(BroadcastReceiver broadcastReceiver, IntentFilter intentFilter) {
        synchronized (this.g) {
            b bVar = new b(intentFilter, broadcastReceiver);
            ArrayList<b> arrayList = this.g.get(broadcastReceiver);
            if (arrayList == null) {
                arrayList = new ArrayList<>(1);
                this.g.put(broadcastReceiver, arrayList);
            }
            arrayList.add(bVar);
            for (int i2 = 0; i2 < intentFilter.countActions(); i2++) {
                String action = intentFilter.getAction(i2);
                ArrayList<b> arrayList2 = this.h.get(action);
                if (arrayList2 == null) {
                    arrayList2 = new ArrayList<>(1);
                    this.h.put(action, arrayList2);
                }
                arrayList2.add(bVar);
            }
        }
    }

    public boolean a(Intent intent) {
        return a(intent, 0);
    }

    public boolean a(Intent intent, int i2) {
        String str;
        ArrayList<b> arrayList;
        String str2;
        int i3;
        Uri uri;
        ArrayList arrayList2;
        synchronized (this.g) {
            String action = intent.getAction();
            String resolveTypeIfNeeded = intent.resolveTypeIfNeeded(this.f.getContentResolver());
            Uri data = intent.getData();
            String scheme = intent.getScheme();
            Set<String> categories = intent.getCategories();
            boolean z = (intent.getFlags() & 8) != 0;
            if (z) {
                Log.v(b, "Resolving type " + resolveTypeIfNeeded + " scheme " + scheme + " of intent " + intent);
            }
            ArrayList<b> arrayList3 = this.h.get(intent.getAction());
            if (arrayList3 != null) {
                if (z) {
                    Log.v(b, "Action list: " + arrayList3);
                }
                ArrayList arrayList4 = null;
                int i4 = 0;
                while (i4 < arrayList3.size()) {
                    b bVar = arrayList3.get(i4);
                    if (z) {
                        Log.v(b, "Matching against filter " + bVar.a);
                    }
                    if (bVar.c) {
                        if (z) {
                            Log.v(b, "  Filter's target already added");
                        }
                        i3 = i4;
                        arrayList = arrayList3;
                        str2 = action;
                        str = resolveTypeIfNeeded;
                        uri = data;
                        arrayList2 = arrayList4;
                    } else {
                        i3 = i4;
                        str2 = action;
                        arrayList2 = arrayList4;
                        arrayList = arrayList3;
                        str = resolveTypeIfNeeded;
                        uri = data;
                        int match = bVar.a.match(action, resolveTypeIfNeeded, scheme, data, categories, b);
                        if (match >= 0) {
                            if (z) {
                                Log.v(b, "  Filter matched!  match=0x" + Integer.toHexString(match));
                            }
                            arrayList4 = arrayList2 == null ? new ArrayList() : arrayList2;
                            arrayList4.add(bVar);
                            bVar.c = true;
                            i4 = i3 + 1;
                            data = uri;
                            action = str2;
                            arrayList3 = arrayList;
                            resolveTypeIfNeeded = str;
                        } else if (z) {
                            Log.v(b, "  Filter did not match: " + (match != -4 ? match != -3 ? match != -2 ? match != -1 ? "unknown reason" : "type" : "data" : "action" : "category"));
                        }
                    }
                    arrayList4 = arrayList2;
                    i4 = i3 + 1;
                    data = uri;
                    action = str2;
                    arrayList3 = arrayList;
                    resolveTypeIfNeeded = str;
                }
                if (arrayList4 != null) {
                    for (int i5 = 0; i5 < arrayList4.size(); i5++) {
                        ((b) arrayList4.get(i5)).c = false;
                    }
                    this.i.add(new a(intent, arrayList4));
                    if (!this.j.hasMessages(1)) {
                        if (i2 > 0) {
                            this.j.sendEmptyMessageDelayed(1, (long) i2);
                        } else {
                            this.j.sendEmptyMessage(1);
                        }
                    }
                    return true;
                }
            }
            return false;
        }
    }

    public void b(Intent intent) {
        if (a(intent)) {
            a();
        }
    }
}