package k.c.a;

import com.cvte.vman.instance.InvokeCmd;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/* JADX INFO: compiled from: SubscriberMethodFinder.java */
/* JADX INFO: loaded from: classes.dex */
public class m {
    public static final Map<Class<?>, List<l>> a = new ConcurrentHashMap();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final a[] f4967b = new a[4];

    /* JADX INFO: compiled from: SubscriberMethodFinder.java */
    public static class a {
        public final List<l> a = new ArrayList();

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public final Map<Class, Object> f4968b = new HashMap();

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public final Map<String, Class> f4969c = new HashMap();

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public final StringBuilder f4970d = new StringBuilder(128);

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        public Class<?> f4971e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public boolean f4972f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        public k.c.a.o.a f4973g;

        public boolean a(Method method, Class<?> cls) {
            Object objPut = this.f4968b.put(cls, method);
            if (objPut == null) {
                return true;
            }
            if (objPut instanceof Method) {
                if (!b((Method) objPut, cls)) {
                    throw new IllegalStateException();
                }
                this.f4968b.put(cls, this);
            }
            return b(method, cls);
        }

        public final boolean b(Method method, Class<?> cls) {
            this.f4970d.setLength(0);
            this.f4970d.append(method.getName());
            StringBuilder sb = this.f4970d;
            sb.append('>');
            sb.append(cls.getName());
            String string = this.f4970d.toString();
            Class<?> declaringClass = method.getDeclaringClass();
            Class clsPut = this.f4969c.put(string, declaringClass);
            if (clsPut == null || clsPut.isAssignableFrom(declaringClass)) {
                return true;
            }
            this.f4969c.put(string, clsPut);
            return false;
        }

        public void c() {
            if (this.f4972f) {
                this.f4971e = null;
                return;
            }
            Class<? super Object> superclass = this.f4971e.getSuperclass();
            this.f4971e = superclass;
            String name = superclass.getName();
            if (name.startsWith("java.") || name.startsWith("javax.") || name.startsWith("android.")) {
                this.f4971e = null;
            }
        }
    }

    public m(List<?> list, boolean z, boolean z2) {
    }

    public final void a(a aVar) {
        Method[] methods;
        j jVar;
        try {
            methods = aVar.f4971e.getDeclaredMethods();
        } catch (Throwable unused) {
            methods = aVar.f4971e.getMethods();
            aVar.f4972f = true;
        }
        for (Method method : methods) {
            int modifiers = method.getModifiers();
            if ((modifiers & 1) != 0 && (modifiers & InvokeCmd.CMD_AUDIO_SET_MIC_POWER_DOWN) == 0) {
                Class<?>[] parameterTypes = method.getParameterTypes();
                if (parameterTypes.length == 1 && (jVar = (j) method.getAnnotation(j.class)) != null) {
                    Class<?> cls = parameterTypes[0];
                    if (aVar.a(method, cls)) {
                        aVar.a.add(new l(method, cls, jVar.threadMode(), jVar.priority(), jVar.sticky()));
                    }
                }
            }
        }
    }

    public final List<l> b(a aVar) {
        ArrayList arrayList = new ArrayList(aVar.a);
        aVar.a.clear();
        aVar.f4968b.clear();
        aVar.f4969c.clear();
        int i2 = 0;
        aVar.f4970d.setLength(0);
        aVar.f4971e = null;
        aVar.f4972f = false;
        aVar.f4973g = null;
        synchronized (f4967b) {
            while (true) {
                if (i2 >= 4) {
                    break;
                }
                a[] aVarArr = f4967b;
                if (aVarArr[i2] == null) {
                    aVarArr[i2] = aVar;
                    break;
                }
                i2++;
            }
        }
        return arrayList;
    }

    public final a c() {
        synchronized (f4967b) {
            for (int i2 = 0; i2 < 4; i2++) {
                a[] aVarArr = f4967b;
                a aVar = aVarArr[i2];
                if (aVar != null) {
                    aVarArr[i2] = null;
                    return aVar;
                }
            }
            return new a();
        }
    }
}
