package p463.p481;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.concurrent.LinkedBlockingQueue;
import org.slf4j.impl.StaticLoggerBinder;
import p138.p139.p143.p144.C2803;
import p463.p481.p482.C7166;
import p463.p481.p483.C7168;
import p463.p481.p483.C7169;
import p463.p481.p483.C7170;
import p463.p481.p483.C7171;
import p463.p481.p483.C7172;

/* JADX INFO: renamed from: ޒ.ހ.ހ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C7162 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static volatile int f20755;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static final C7171 f20756 = new C7171();

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public static final C7169 f20757 = new C7169();

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public static boolean f20758;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public static final String[] f20759;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public static String f20760;

    static {
        String property = null;
        try {
            property = System.getProperty("slf4j.detectLoggerNameMismatch");
        } catch (SecurityException unused) {
        }
        f20758 = property == null ? false : property.equalsIgnoreCase("true");
        f20759 = new String[]{"1.6", "1.7"};
        f20760 = "org/slf4j/impl/StaticLoggerBinder.class";
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static InterfaceC7161 m10575(Class<?> cls) {
        int i;
        InterfaceC7161 interfaceC7161Mo10553 = m10582().mo10553(cls.getName());
        if (f20758) {
            C7172.C7174 c7174 = C7172.f20784;
            Class<?> cls2 = null;
            if (c7174 == null) {
                if (C7172.f20785) {
                    c7174 = null;
                } else {
                    try {
                        c7174 = new C7172.C7174(null);
                    } catch (SecurityException unused) {
                        c7174 = null;
                    }
                    C7172.f20784 = c7174;
                    C7172.f20785 = true;
                }
            }
            if (c7174 != null) {
                Class<?>[] classContext = c7174.getClassContext();
                String name = C7172.class.getName();
                int i2 = 0;
                while (i2 < classContext.length && !name.equals(classContext[i2].getName())) {
                    i2++;
                }
                if (i2 >= classContext.length || (i = i2 + 2) >= classContext.length) {
                    throw new IllegalStateException("Failed to find org.slf4j.helpers.Util or its caller in the stack; this should not happen");
                }
                cls2 = classContext[i];
            }
            if (cls2 != null && (!cls2.isAssignableFrom(cls))) {
                C7172.m10589(String.format("Detected logger name mismatch. Given name: \"%s\"; computed name: \"%s\".", interfaceC7161Mo10553.mo10559(), cls2.getName()));
                C7172.m10589("See http://www.slf4j.org/codes.html#loggerNameMismatch for an explanation");
            }
        }
        return interfaceC7161Mo10553;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static InterfaceC7161 m10576(String str) {
        return m10582().mo10553(str);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final void m10577() {
        Set<URL> setM10579;
        try {
            if (m10583()) {
                setM10579 = null;
            } else {
                setM10579 = m10579();
                m10580(setM10579);
            }
            StaticLoggerBinder.getSingleton();
            f20755 = 3;
            m10578(setM10579);
            m10581();
            m10584();
            C7171 c7171 = f20756;
            c7171.f20782.clear();
            c7171.f20783.clear();
        } catch (Exception e) {
            f20755 = 2;
            C7172.m10590("Failed to instantiate SLF4J LoggerFactory", e);
            throw new IllegalStateException("Unexpected initialization failure", e);
        } catch (NoClassDefFoundError e2) {
            String message = e2.getMessage();
            boolean z = false;
            if (message != null && (message.contains("org/slf4j/impl/StaticLoggerBinder") || message.contains("org.slf4j.impl.StaticLoggerBinder"))) {
                z = true;
            }
            if (!z) {
                f20755 = 2;
                C7172.m10590("Failed to instantiate SLF4J LoggerFactory", e2);
                throw e2;
            }
            f20755 = 4;
            C7172.m10589("Failed to load class \"org.slf4j.impl.StaticLoggerBinder\".");
            C7172.m10589("Defaulting to no-operation (NOP) logger implementation");
            C7172.m10589("See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.");
        } catch (NoSuchMethodError e3) {
            String message2 = e3.getMessage();
            if (message2 != null && message2.contains("org.slf4j.impl.StaticLoggerBinder.getSingleton()")) {
                f20755 = 2;
                C7172.m10589("slf4j-api 1.6.x (or later) is incompatible with this binding.");
                C7172.m10589("Your binding is version 1.5.5 or earlier.");
                C7172.m10589("Upgrade your binding to version 1.6.x.");
            }
            throw e3;
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static void m10578(Set<URL> set) {
        if (set != null) {
            if (set.size() > 1) {
                StringBuilder sbM4889 = C2803.m4889("Actual binding is of type [");
                sbM4889.append(StaticLoggerBinder.getSingleton().getLoggerFactoryClassStr());
                sbM4889.append("]");
                C7172.m10589(sbM4889.toString());
            }
        }
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static Set<URL> m10579() {
        LinkedHashSet linkedHashSet = new LinkedHashSet();
        try {
            ClassLoader classLoader = C7162.class.getClassLoader();
            Enumeration<URL> systemResources = classLoader == null ? ClassLoader.getSystemResources(f20760) : classLoader.getResources(f20760);
            while (systemResources.hasMoreElements()) {
                linkedHashSet.add(systemResources.nextElement());
            }
        } catch (IOException e) {
            C7172.m10590("Error getting resources from path", e);
        }
        return linkedHashSet;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static void m10580(Set<URL> set) {
        if (set.size() > 1) {
            C7172.m10589("Class path contains multiple SLF4J bindings.");
            Iterator<URL> it = set.iterator();
            while (it.hasNext()) {
                C7172.m10589("Found binding in [" + it.next() + "]");
            }
            C7172.m10589("See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.");
        }
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public static void m10581() {
        synchronized (f20756) {
            f20756.f20781 = true;
            C7171 c7171 = f20756;
            if (c7171 == null) {
                throw null;
            }
            for (C7170 c7170 : new ArrayList(c7171.f20782.values())) {
                c7170.f20775 = m10576(c7170.f20774);
            }
        }
    }

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public static InterfaceC7160 m10582() {
        if (f20755 == 0) {
            synchronized (C7162.class) {
                if (f20755 == 0) {
                    f20755 = 1;
                    m10577();
                    if (f20755 == 3) {
                        m10585();
                    }
                }
            }
        }
        int i = f20755;
        if (i == 1) {
            return f20756;
        }
        if (i == 2) {
            throw new IllegalStateException("org.slf4j.LoggerFactory in failed state. Original exception was thrown EARLIER. See also http://www.slf4j.org/codes.html#unsuccessfulInit");
        }
        if (i == 3) {
            return StaticLoggerBinder.getSingleton().getLoggerFactory();
        }
        if (i == 4) {
            return f20757;
        }
        throw new IllegalStateException("Unreachable code");
    }

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public static boolean m10583() {
        String property;
        try {
            property = System.getProperty("java.vendor.url");
        } catch (SecurityException unused) {
            property = null;
        }
        if (property == null) {
            return false;
        }
        return property.toLowerCase().contains("android");
    }

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public static void m10584() {
        LinkedBlockingQueue<C7166> linkedBlockingQueue = f20756.f20783;
        int size = linkedBlockingQueue.size();
        ArrayList<C7166> arrayList = new ArrayList(128);
        int i = 0;
        while (linkedBlockingQueue.drainTo(arrayList, 128) != 0) {
            for (C7166 c7166 : arrayList) {
                if (c7166 != null) {
                    C7170 c7170 = c7166.f20771;
                    String str = c7170.f20774;
                    if (c7170.f20775 == null) {
                        throw new IllegalStateException("Delegate logger cannot be null at this state.");
                    }
                    if (!(c7170.f20775 instanceof C7168)) {
                        if (!c7170.m10588()) {
                            C7172.m10589(str);
                        } else if (c7170.m10588()) {
                            try {
                                c7170.f20777.invoke(c7170.f20775, c7166);
                            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException unused) {
                            }
                        }
                    }
                }
                int i2 = i + 1;
                if (i == 0) {
                    if (c7166.f20771.m10588()) {
                        C7172.m10589("A number (" + size + ") of logging calls during the initialization phase have been intercepted and are");
                        C7172.m10589("now being replayed. These are subject to the filtering rules of the underlying logging system.");
                        C7172.m10589("See also http://www.slf4j.org/codes.html#replay");
                    } else if (!(c7166.f20771.f20775 instanceof C7168)) {
                        C7172.m10589("The following set of substitute loggers may have been accessed");
                        C7172.m10589("during the initialization phase. Logging calls during this");
                        C7172.m10589("phase were not honored. However, subsequent logging calls to these");
                        C7172.m10589("loggers will work as normally expected.");
                        C7172.m10589("See also http://www.slf4j.org/codes.html#substituteLogger");
                    }
                }
                i = i2;
            }
            arrayList.clear();
        }
    }

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public static final void m10585() {
        try {
            String str = StaticLoggerBinder.REQUESTED_API_VERSION;
            boolean z = false;
            for (String str2 : f20759) {
                if (str.startsWith(str2)) {
                    z = true;
                }
            }
            if (z) {
                return;
            }
            C7172.m10589("The requested version " + str + " by your slf4j binding is not compatible with " + Arrays.asList(f20759).toString());
            C7172.m10589("See http://www.slf4j.org/codes.html#version_mismatch for further details.");
        } catch (NoSuchFieldError unused) {
        } catch (Throwable th) {
            C7172.m10590("Unexpected problem occured during version sanity check", th);
        }
    }
}
