package defpackage;

import java.util.ArrayList;
import java.util.TimeZone;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.logging.Logger;

/* renamed from: ᵢʡ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C3246 {

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public static final C3246 f12221;

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public static final Logger f12222 = Logger.getLogger(C3246.class.getName());

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public long f12223;

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public int f12224;

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public int f12225;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final ˊʘ f12228;

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

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final Logger f12229 = f12222;

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public int f12226 = 10000;

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public final ArrayList f12231 = new ArrayList();

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public final ArrayList f12227 = new ArrayList();

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public final RunnableC2802 f12230 = new RunnableC2802(25, this);

    /* JADX WARN: Type inference failed for: r3v1, types: [ˑᵕ] */
    static {
        final String strM4107 = AbstractC1327.m4107(new StringBuilder(), AbstractC4061.f15225, " TaskRunner");
        final boolean z = true;
        f12221 = new C3246(new ˊʘ((ThreadFactoryC2067) new ThreadFactory() { // from class: ˑᵕ
            @Override // java.util.concurrent.ThreadFactory
            public final Thread newThread(Runnable runnable) {
                Thread thread = new Thread(runnable, strM4107);
                thread.setDaemon(z);
                return thread;
            }
        }));
    }

    public C3246(ˊʘ r2) {
        this.f12228 = r2;
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public static final void m7602(C3246 c3246, AbstractC1131 abstractC1131, long j, boolean z) {
        TimeZone timeZone = AbstractC4061.f15224;
        C0897 c0897 = abstractC1131.f4857;
        if (c0897.f4072 != abstractC1131) {
            ᵹˉᵞ.ᵳٴᵶ("Check failed.");
            return;
        }
        boolean z2 = c0897.f4068;
        c0897.f4068 = false;
        c0897.f4072 = null;
        c3246.f12231.remove(c0897);
        if (j != -1 && !z2 && !c0897.f4069) {
            c0897.m3016(abstractC1131, j, true);
        }
        if (c0897.f4067.isEmpty()) {
            return;
        }
        c3246.f12227.add(c0897);
        if (z) {
            return;
        }
        c3246.m7603();
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final void m7603() {
        TimeZone timeZone = AbstractC4061.f15224;
        int i = this.f12225;
        if (i > this.f12224) {
            return;
        }
        this.f12225 = i + 1;
        ((ThreadPoolExecutor) this.f12228.ᵢˇᵭ).execute(this.f12230);
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final void m7604(C0897 c0897) {
        TimeZone timeZone = AbstractC4061.f15224;
        if (c0897.f4072 == null) {
            boolean zIsEmpty = c0897.f4067.isEmpty();
            ArrayList arrayList = this.f12227;
            if (zIsEmpty) {
                arrayList.remove(c0897);
            } else {
                byte[] bArr = AbstractC1348.f5567;
                if (!arrayList.contains(c0897)) {
                    arrayList.add(c0897);
                }
            }
        }
        if (this.f12232) {
            notify();
        } else {
            m7603();
        }
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final AbstractC1131 m7605() {
        long j;
        AbstractC1131 abstractC1131;
        boolean z;
        TimeZone timeZone = AbstractC4061.f15224;
        while (true) {
            ArrayList arrayList = this.f12227;
            if (arrayList.isEmpty()) {
                return null;
            }
            long jNanoTime = System.nanoTime();
            int size = arrayList.size();
            long jMin = Long.MAX_VALUE;
            int i = 0;
            AbstractC1131 abstractC11312 = null;
            while (true) {
                if (i >= size) {
                    j = jNanoTime;
                    abstractC1131 = null;
                    z = false;
                    break;
                }
                Object obj = arrayList.get(i);
                i++;
                AbstractC1131 abstractC11313 = (AbstractC1131) ((C0897) obj).f4067.get(0);
                j = jNanoTime;
                abstractC1131 = null;
                long jMax = Math.max(0L, abstractC11313.f4860 - j);
                if (jMax > 0) {
                    jMin = Math.min(jMax, jMin);
                } else {
                    if (abstractC11312 != null) {
                        z = true;
                        break;
                    }
                    abstractC11312 = abstractC11313;
                }
                jNanoTime = j;
            }
            ArrayList arrayList2 = this.f12231;
            if (abstractC11312 != null) {
                TimeZone timeZone2 = AbstractC4061.f15224;
                abstractC11312.f4860 = -1L;
                C0897 c0897 = abstractC11312.f4857;
                c0897.f4067.remove(abstractC11312);
                arrayList.remove(c0897);
                c0897.f4072 = abstractC11312;
                arrayList2.add(c0897);
                if (z || (!this.f12232 && !arrayList.isEmpty())) {
                    m7603();
                }
                return abstractC11312;
            }
            if (this.f12232) {
                if (jMin >= this.f12223 - j) {
                    return abstractC1131;
                }
                notify();
                return abstractC1131;
            }
            this.f12232 = true;
            this.f12223 = j + jMin;
            try {
                try {
                    TimeZone timeZone3 = AbstractC4061.f15224;
                    if (jMin > 0) {
                        long j2 = jMin / 1000000;
                        Long.signum(j2);
                        long j3 = jMin - (1000000 * j2);
                        if (j2 > 0 || jMin > 0) {
                            wait(j2, (int) j3);
                        }
                    }
                } catch (InterruptedException unused) {
                    TimeZone timeZone4 = AbstractC4061.f15224;
                    for (int size2 = arrayList2.size() - 1; -1 < size2; size2--) {
                        ((C0897) arrayList2.get(size2)).m3019();
                    }
                    for (int size3 = arrayList.size() - 1; -1 < size3; size3--) {
                        C0897 c08972 = (C0897) arrayList.get(size3);
                        c08972.m3019();
                        if (c08972.f4067.isEmpty()) {
                            arrayList.remove(size3);
                        }
                    }
                }
            } finally {
                this.f12232 = false;
            }
        }
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final C0897 m7606() {
        int i;
        synchronized (this) {
            i = this.f12226;
            this.f12226 = i + 1;
        }
        return new C0897(this, AbstractC2990.m7313(i, "Q"));
    }
}
