package eh;

import android.os.SystemClock;
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

/* loaded from: classes4.dex */
public abstract class v {

    /* renamed from: a, reason: collision with root package name */
    public static String f17150a = "Volley";

    /* renamed from: b, reason: collision with root package name */
    public static boolean f17151b = Log.isLoggable("Volley", 2);

    /* renamed from: c, reason: collision with root package name */
    private static final String f17152c = v.class.getName();

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static class a {

        /* renamed from: c, reason: collision with root package name */
        public static final boolean f17153c = v.f17151b;

        /* renamed from: a, reason: collision with root package name */
        private final List f17154a = new ArrayList();

        /* renamed from: b, reason: collision with root package name */
        private boolean f17155b = false;

        /* JADX INFO: Access modifiers changed from: private */
        /* renamed from: eh.v$a$a, reason: collision with other inner class name */
        /* loaded from: classes4.dex */
        public static class C0372a {

            /* renamed from: a, reason: collision with root package name */
            public final String f17156a;

            /* renamed from: b, reason: collision with root package name */
            public final long f17157b;

            /* renamed from: c, reason: collision with root package name */
            public final long f17158c;

            public C0372a(String str, long j10, long j11) {
                this.f17156a = str;
                this.f17157b = j10;
                this.f17158c = j11;
            }
        }

        private long c() {
            if (this.f17154a.size() == 0) {
                return 0L;
            }
            return ((C0372a) this.f17154a.get(r4.size() - 1)).f17158c - ((C0372a) this.f17154a.get(0)).f17158c;
        }

        public synchronized void a(String str, long j10) {
            if (this.f17155b) {
                throw new IllegalStateException("Marker added to finished log");
            }
            this.f17154a.add(new C0372a(str, j10, SystemClock.elapsedRealtime()));
        }

        public synchronized void b(String str) {
            this.f17155b = true;
            long c10 = c();
            if (c10 <= 0) {
                return;
            }
            long j10 = ((C0372a) this.f17154a.get(0)).f17158c;
            v.b("(%-4d ms) %s", Long.valueOf(c10), str);
            for (C0372a c0372a : this.f17154a) {
                long j11 = c0372a.f17158c;
                v.b("(+%-4d) [%2d] %s", Long.valueOf(j11 - j10), Long.valueOf(c0372a.f17157b), c0372a.f17156a);
                j10 = j11;
            }
        }

        protected void finalize() {
            if (this.f17155b) {
                return;
            }
            b("Request on the loose");
            v.c("Marker log finalized without finish() - uncaught exit point for request", new Object[0]);
        }
    }

    private static String a(String str, Object... objArr) {
        String str2;
        if (objArr != null) {
            str = String.format(Locale.US, str, objArr);
        }
        StackTraceElement[] stackTrace = new Throwable().fillInStackTrace().getStackTrace();
        int i10 = 2;
        while (true) {
            if (i10 >= stackTrace.length) {
                str2 = "<unknown>";
                break;
            }
            if (!stackTrace[i10].getClassName().equals(f17152c)) {
                String className = stackTrace[i10].getClassName();
                String substring = className.substring(className.lastIndexOf(46) + 1);
                str2 = substring.substring(substring.lastIndexOf(36) + 1) + "." + stackTrace[i10].getMethodName();
                break;
            }
            i10++;
        }
        return String.format(Locale.US, "[%d] %s: %s", Long.valueOf(Thread.currentThread().getId()), str2, str);
    }

    public static void b(String str, Object... objArr) {
        Log.d(f17150a, a(str, objArr));
    }

    public static void c(String str, Object... objArr) {
        Log.e(f17150a, a(str, objArr));
    }

    public static void d(Throwable th2, String str, Object... objArr) {
        Log.e(f17150a, a(str, objArr), th2);
    }

    public static void e(String str, Object... objArr) {
        if (f17151b) {
            Log.v(f17150a, a(str, objArr));
        }
    }

    public static void f(String str, Object... objArr) {
        Log.wtf(f17150a, a(str, objArr));
    }
}
