package defpackage;

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.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.concurrent.LinkedBlockingQueue;
import org.slf4j.ILoggerFactory;
import org.slf4j.impl.StaticLoggerBinder;

/* renamed from: ˊᵭᵚ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public abstract class AbstractC1385 {

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public static final String[] f5687;

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public static final String f5688;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public static volatile int f5690;

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public static final boolean f5692;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public static final C4118 f5691 = new C4118(7);

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public static final ˊᵿʗ f5689 = new ˊᵿʗ(1);

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

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public static InterfaceC0567 m4255(Class cls) {
        int i;
        InterfaceC0567 interfaceC0567M4257 = m4257(cls.getName());
        if (f5692) {
            C4957 c4957 = AbstractC0494.f2612;
            Class cls2 = null;
            if (c4957 == null) {
                if (AbstractC0494.f2613) {
                    c4957 = null;
                } else {
                    try {
                        c4957 = new C4957();
                    } catch (SecurityException unused) {
                        c4957 = null;
                    }
                    AbstractC0494.f2612 = c4957;
                    AbstractC0494.f2613 = true;
                }
            }
            if (c4957 != null) {
                Class[] classContext = c4957.getClassContext();
                String name = AbstractC0494.class.getName();
                int i2 = 0;
                while (i2 < classContext.length && !name.equals(classContext[i2].getName())) {
                    i2++;
                }
                if (i2 >= classContext.length || (i = i2 + 2) >= classContext.length) {
                    ᵹˉᵞ.ᵳٴᵶ("Failed to find org.slf4j.helpers.Util or its caller in the stack; this should not happen");
                    return null;
                }
                cls2 = classContext[i];
            }
            if (cls2 != null && !cls2.isAssignableFrom(cls)) {
                AbstractC0494.m2163("Detected logger name mismatch. Given name: \"" + interfaceC0567M4257.getName() + "\"; computed name: \"" + cls2.getName() + "\".");
                AbstractC0494.m2163("See http://www.slf4j.org/codes.html#loggerNameMismatch for an explanation");
            }
        }
        return interfaceC0567M4257;
    }

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

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public static InterfaceC0567 m4257(String str) {
        return m4265().mo1014(str);
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public static void m4258() {
        C4118 c4118 = f5691;
        synchronized (c4118) {
            try {
                c4118.f15381 = true;
                ArrayList arrayList = new ArrayList(((HashMap) c4118.f15384).values());
                int size = arrayList.size();
                int i = 0;
                while (i < size) {
                    Object obj = arrayList.get(i);
                    i++;
                    C4411 c4411 = (C4411) obj;
                    c4411.f16494 = m4257(c4411.f16496);
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public static void m4259(LinkedHashSet linkedHashSet) {
        if (linkedHashSet == null || linkedHashSet.size() <= 1) {
            return;
        }
        AbstractC0494.m2163("Actual binding is of type [" + StaticLoggerBinder.getSingleton().getLoggerFactoryClassStr() + "]");
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public static final void m4260() {
        LinkedHashSet linkedHashSetM4261;
        try {
            if (m4256()) {
                linkedHashSetM4261 = null;
            } else {
                linkedHashSetM4261 = m4261();
                m4262(linkedHashSetM4261);
            }
            StaticLoggerBinder.getSingleton();
            f5690 = 3;
            m4259(linkedHashSetM4261);
            m4258();
            m4264();
            C4118 c4118 = f5691;
            ((HashMap) c4118.f15384).clear();
            ((LinkedBlockingQueue) c4118.f15383).clear();
        } catch (Exception e) {
            f5690 = 2;
            System.err.println("Failed to instantiate SLF4J LoggerFactory");
            System.err.println("Reported exception:");
            e.printStackTrace();
            C1260.m3810("Unexpected initialization failure", e);
        } catch (NoClassDefFoundError e2) {
            String message = e2.getMessage();
            if (message == null || !(message.contains("org/slf4j/impl/StaticLoggerBinder") || message.contains("org.slf4j.impl.StaticLoggerBinder"))) {
                f5690 = 2;
                System.err.println("Failed to instantiate SLF4J LoggerFactory");
                System.err.println("Reported exception:");
                e2.printStackTrace();
                throw e2;
            }
            f5690 = 4;
            AbstractC0494.m2163("Failed to load class \"org.slf4j.impl.StaticLoggerBinder\".");
            AbstractC0494.m2163("Defaulting to no-operation (NOP) logger implementation");
            AbstractC0494.m2163("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()")) {
                f5690 = 2;
                AbstractC0494.m2163("slf4j-api 1.6.x (or later) is incompatible with this binding.");
                AbstractC0494.m2163("Your binding is version 1.5.5 or earlier.");
                AbstractC0494.m2163("Upgrade your binding to version 1.6.x.");
            }
            throw e3;
        }
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public static LinkedHashSet m4261() {
        LinkedHashSet linkedHashSet = new LinkedHashSet();
        try {
            ClassLoader classLoader = AbstractC1385.class.getClassLoader();
            String str = f5688;
            Enumeration<URL> systemResources = classLoader == null ? ClassLoader.getSystemResources(str) : classLoader.getResources(str);
            while (systemResources.hasMoreElements()) {
                linkedHashSet.add(systemResources.nextElement());
            }
            return linkedHashSet;
        } catch (IOException e) {
            System.err.println("Error getting resources from path");
            System.err.println("Reported exception:");
            e.printStackTrace();
            return linkedHashSet;
        }
    }

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public static void m4262(LinkedHashSet linkedHashSet) {
        if (linkedHashSet.size() > 1) {
            AbstractC0494.m2163("Class path contains multiple SLF4J bindings.");
            Iterator it = linkedHashSet.iterator();
            while (it.hasNext()) {
                AbstractC0494.m2163("Found binding in [" + ((URL) it.next()) + "]");
            }
            AbstractC0494.m2163("See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.");
        }
    }

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public static final void m4263() {
        try {
            String str = StaticLoggerBinder.REQUESTED_API_VERSION;
            boolean z = false;
            for (String str2 : f5687) {
                if (str.startsWith(str2)) {
                    z = true;
                }
            }
            if (z) {
                return;
            }
            AbstractC0494.m2163("The requested version " + str + " by your slf4j binding is not compatible with " + Arrays.asList(f5687).toString());
            AbstractC0494.m2163("See http://www.slf4j.org/codes.html#version_mismatch for further details.");
        } catch (NoSuchFieldError unused) {
        } catch (Throwable th) {
            System.err.println("Unexpected problem occured during version sanity check");
            System.err.println("Reported exception:");
            th.printStackTrace();
        }
    }

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public static void m4264() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
        LinkedBlockingQueue linkedBlockingQueue = (LinkedBlockingQueue) f5691.f15383;
        int size = linkedBlockingQueue.size();
        ArrayList arrayList = new ArrayList(128);
        int i = 0;
        while (linkedBlockingQueue.drainTo(arrayList, 128) != 0) {
            int size2 = arrayList.size();
            int i2 = 0;
            while (i2 < size2) {
                Object obj = arrayList.get(i2);
                i2++;
                C1745 c1745 = (C1745) obj;
                if (c1745 != null) {
                    C4411 c4411 = c1745.f6959;
                    String str = c4411.f16496;
                    if (c4411.f16494 == null) {
                        ᵹˉᵞ.ᵳٴᵶ("Delegate logger cannot be null at this state.");
                        return;
                    } else if (!(c4411.f16494 instanceof C0920)) {
                        if (!c4411.m9451()) {
                            AbstractC0494.m2163(str);
                        } else if (c4411.m9451()) {
                            try {
                                c4411.f16497.invoke(c4411.f16494, c1745);
                            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException unused) {
                            }
                        }
                    }
                }
                int i3 = i + 1;
                if (i == 0) {
                    if (c1745.f6959.m9451()) {
                        AbstractC0494.m2163("A number (" + size + ") of logging calls during the initialization phase have been intercepted and are");
                        AbstractC0494.m2163("now being replayed. These are subject to the filtering rules of the underlying logging system.");
                        AbstractC0494.m2163("See also http://www.slf4j.org/codes.html#replay");
                    } else if (!(c1745.f6959.f16494 instanceof C0920)) {
                        AbstractC0494.m2163("The following set of substitute loggers may have been accessed");
                        AbstractC0494.m2163("during the initialization phase. Logging calls during this");
                        AbstractC0494.m2163("phase were not honored. However, subsequent logging calls to these");
                        AbstractC0494.m2163("loggers will work as normally expected.");
                        AbstractC0494.m2163("See also http://www.slf4j.org/codes.html#substituteLogger");
                    }
                }
                i = i3;
            }
            arrayList.clear();
        }
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public static ILoggerFactory m4265() {
        if (f5690 == 0) {
            synchronized (AbstractC1385.class) {
                try {
                    if (f5690 == 0) {
                        f5690 = 1;
                        m4260();
                        if (f5690 == 3) {
                            m4263();
                        }
                    }
                } finally {
                }
            }
        }
        int i = f5690;
        if (i == 1) {
            return f5691;
        }
        if (i == 2) {
            ᵹˉᵞ.ᵳٴᵶ("org.slf4j.LoggerFactory in failed state. Original exception was thrown EARLIER. See also http://www.slf4j.org/codes.html#unsuccessfulInit");
            return null;
        }
        if (i == 3) {
            return StaticLoggerBinder.getSingleton().getLoggerFactory();
        }
        if (i == 4) {
            return f5689;
        }
        ᵹˉᵞ.ᵳٴᵶ("Unreachable code");
        return null;
    }
}
