package defpackage;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;

/* JADX INFO: renamed from: ˀᵢˊ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public abstract class AbstractC0592 {

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public static final HashMap f2894 = new HashMap();

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public static final HashMap f2893 = new HashMap();

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:58:0x00eb  */
    /* JADX WARN: Removed duplicated region for block: B:80:0x010f A[SYNTHETIC] */
    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static int m2222(Class cls) {
        Constructor declaredConstructor;
        boolean zBooleanValue;
        int length;
        HashMap map = f2894;
        Integer num = (Integer) map.get(cls);
        if (num != null) {
            return num.intValue();
        }
        int i = 1;
        if (cls.getCanonicalName() != null) {
            int i2 = 0;
            ArrayList arrayList = null;
            try {
                Package r5 = cls.getPackage();
                String canonicalName = cls.getCanonicalName();
                String name = r5 != null ? r5.getName() : "";
                if (name.length() != 0) {
                    canonicalName = canonicalName.substring(name.length() + 1);
                }
                String strConcat = AbstractC5498.m11138(canonicalName, ".", "_", false).concat("_LifecycleAdapter");
                if (name.length() != 0) {
                    strConcat = name + "." + strConcat;
                }
                declaredConstructor = Class.forName(strConcat).getDeclaredConstructor(cls);
                if (!declaredConstructor.isAccessible()) {
                    declaredConstructor.setAccessible(true);
                }
            } catch (ClassNotFoundException unused) {
                declaredConstructor = null;
            } catch (NoSuchMethodException e) {
                C4935.m10238(e);
                return 0;
            }
            HashMap map2 = f2893;
            if (declaredConstructor != null) {
                map2.put(cls, Collections.singletonList(declaredConstructor));
            } else {
                C0950 c0950 = C0950.f4131;
                HashMap map3 = c0950.f4132;
                Boolean bool = (Boolean) map3.get(cls);
                if (bool != null) {
                    zBooleanValue = bool.booleanValue();
                } else {
                    try {
                        Method[] declaredMethods = cls.getDeclaredMethods();
                        int length2 = declaredMethods.length;
                        int i3 = 0;
                        while (true) {
                            if (i3 >= length2) {
                                map3.put(cls, Boolean.FALSE);
                                zBooleanValue = false;
                                break;
                            }
                            if (((InterfaceC3323) declaredMethods[i3].getAnnotation(InterfaceC3323.class)) != null) {
                                c0950.m3206(cls, declaredMethods);
                                zBooleanValue = true;
                                break;
                            }
                            i3++;
                        }
                    } catch (NoClassDefFoundError e2) {
                        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.", e2);
                    }
                }
                if (!zBooleanValue) {
                    Class superclass = cls.getSuperclass();
                    if (superclass == null || !InterfaceC5232.class.isAssignableFrom(superclass)) {
                        Class<?>[] interfaces = cls.getInterfaces();
                        length = interfaces.length;
                        while (true) {
                            if (i2 < length) {
                                Class<?> cls2 = interfaces[i2];
                                if (cls2 != null && InterfaceC5232.class.isAssignableFrom(cls2)) {
                                    if (m2222(cls2) == 1) {
                                        break;
                                    }
                                    if (arrayList == null) {
                                        arrayList = new ArrayList();
                                    }
                                    arrayList.addAll((Collection) map2.get(cls2));
                                }
                                i2++;
                            } else if (arrayList != null) {
                                map2.put(cls, arrayList);
                            }
                        }
                    } else if (m2222(superclass) != 1) {
                        arrayList = new ArrayList((Collection) map2.get(superclass));
                        Class<?>[] interfaces2 = cls.getInterfaces();
                        length = interfaces2.length;
                        while (true) {
                            if (i2 < length) {
                            }
                            i2++;
                        }
                    }
                }
            }
            i = 2;
        }
        map.put(cls, Integer.valueOf(i));
        return i;
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public static void m2223(Constructor constructor, InterfaceC5232 interfaceC5232) {
        try {
            if (constructor.newInstance(interfaceC5232) == null) {
            } else {
                throw new ClassCastException();
            }
        } catch (IllegalAccessException e) {
            C4935.m10238(e);
        } catch (InstantiationException e2) {
            C4935.m10238(e2);
        } catch (InvocationTargetException e3) {
            C4935.m10238(e3);
        }
    }
}
