package defpackage;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

/* renamed from: ᵷˑˌ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C4885 {

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public static final C4885 f18191 = new C4885();

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final HashMap f18192 = new HashMap();

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final HashMap f18193 = new HashMap();

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public static void m10331(HashMap map, C3397 c3397, EnumC3315 enumC3315, Class cls) {
        EnumC3315 enumC33152 = (EnumC3315) map.get(c3397);
        if (enumC33152 == null || enumC3315 == enumC33152) {
            if (enumC33152 == null) {
                map.put(c3397, enumC3315);
            }
        } else {
            String name = c3397.f12670.getName();
            String name2 = cls.getName();
            ᵹˉᵞ.ˌᵜᵹᵩ(AbstractC3915.m8592(AbstractC1327.m4104("Method ", name, " in ", name2, " already declared with different @OnLifecycleEvent value: previous value "), String.valueOf(enumC33152), ", new value ", String.valueOf(enumC3315)));
        }
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final C2446 m10332(Class cls, Method[] methodArr) {
        int i;
        Class superclass = cls.getSuperclass();
        HashMap map = new HashMap();
        HashMap map2 = this.f18192;
        if (superclass != null) {
            C2446 c2446M10332 = (C2446) map2.get(superclass);
            if (c2446M10332 == null) {
                c2446M10332 = m10332(superclass, null);
            }
            map.putAll(c2446M10332.f9562);
        }
        for (Class<?> cls2 : cls.getInterfaces()) {
            C2446 c2446M103322 = (C2446) map2.get(cls2);
            if (c2446M103322 == null) {
                c2446M103322 = m10332(cls2, null);
            }
            for (Map.Entry entry : c2446M103322.f9562.entrySet()) {
                m10331(map, (C3397) entry.getKey(), (EnumC3315) entry.getValue(), cls);
            }
        }
        if (methodArr == null) {
            try {
                methodArr = cls.getDeclaredMethods();
            } catch (NoClassDefFoundError e) {
                throw new IllegalArgumentException("The observer class has some methods that use newer APIs which are not available in the current OS version. Lifecycles cannot access even other methods so you should make sure that your observer classes only access framework classes that are available in your min API level OR use lifecycle:compiler annotation processor.", e);
            }
        }
        boolean z = false;
        for (Method method : methodArr) {
            InterfaceC0061 interfaceC0061 = (InterfaceC0061) method.getAnnotation(InterfaceC0061.class);
            if (interfaceC0061 != null) {
                Class<?>[] parameterTypes = method.getParameterTypes();
                if (parameterTypes.length <= 0) {
                    i = 0;
                } else {
                    if (!InterfaceC3985.class.isAssignableFrom(parameterTypes[0])) {
                        ᵹˉᵞ.ˌᵜᵹᵩ("invalid parameter type. Must be one and instanceof LifecycleOwner");
                        return null;
                    }
                    i = 1;
                }
                EnumC3315 enumC3315Value = interfaceC0061.value();
                if (parameterTypes.length > 1) {
                    if (!EnumC3315.class.isAssignableFrom(parameterTypes[1])) {
                        ᵹˉᵞ.ˌᵜᵹᵩ("invalid parameter type. second arg must be an event");
                        return null;
                    }
                    if (enumC3315Value != EnumC3315.ON_ANY) {
                        ᵹˉᵞ.ˌᵜᵹᵩ("Second arg is supported only for ON_ANY value");
                        return null;
                    }
                    i = 2;
                }
                if (parameterTypes.length > 2) {
                    ᵹˉᵞ.ˌᵜᵹᵩ("cannot have more than 2 params");
                    return null;
                }
                m10331(map, new C3397(i, method), enumC3315Value, cls);
                z = true;
            }
        }
        C2446 c2446 = new C2446(map);
        map2.put(cls, c2446);
        this.f18193.put(cls, Boolean.valueOf(z));
        return c2446;
    }
}
