package p447.p448.p451;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.RejectedExecutionException;
import java.util.logging.Level;
import p138.p139.p143.p144.C2803;
import p138.p176.p177.p242.p246.p251.C4303;
import p402.p411.p413.C6635;
import p447.p448.C6943;

/* JADX INFO: renamed from: ސ.ޣ.ރ.ހ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C6952 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public boolean f20210;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public AbstractC6950 f20211;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final List<AbstractC6950> f20212;

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

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public final C6953 f20214;

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

    public C6952(C6953 c6953, String str) {
        if (c6953 == null) {
            C6635.m9824("taskRunner");
            throw null;
        }
        if (str == null) {
            C6635.m9824("name");
            throw null;
        }
        this.f20214 = c6953;
        this.f20215 = str;
        this.f20212 = new ArrayList();
    }

    public String toString() {
        return this.f20215;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m10184() {
        if (!C6943.f20196 || !Thread.holdsLock(this)) {
            synchronized (this.f20214) {
                if (m10187()) {
                    this.f20214.m10192(this);
                }
            }
            return;
        }
        StringBuilder sbM4889 = C2803.m4889("Thread ");
        Thread threadCurrentThread = Thread.currentThread();
        C6635.m9823((Object) threadCurrentThread, "Thread.currentThread()");
        sbM4889.append(threadCurrentThread.getName());
        sbM4889.append(" MUST NOT hold lock on ");
        sbM4889.append(this);
        throw new AssertionError(sbM4889.toString());
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m10185(AbstractC6950 abstractC6950, long j) {
        if (abstractC6950 == null) {
            C6635.m9824("task");
            throw null;
        }
        synchronized (this.f20214) {
            if (!this.f20210) {
                if (m10186(abstractC6950, j, false)) {
                    this.f20214.m10192(this);
                }
            } else {
                if (abstractC6950.f20208) {
                    if (C6953.f20218 == null) {
                        throw null;
                    }
                    if (C6953.f20217.isLoggable(Level.FINE)) {
                        C4303.m7115(abstractC6950, this, "schedule canceled (queue is shutdown)");
                    }
                    return;
                }
                if (C6953.f20218 == null) {
                    throw null;
                }
                if (C6953.f20217.isLoggable(Level.FINE)) {
                    C4303.m7115(abstractC6950, this, "schedule failed (queue is shutdown)");
                }
                throw new RejectedExecutionException();
            }
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final boolean m10186(AbstractC6950 abstractC6950, long j, boolean z) {
        String string;
        if (abstractC6950 == null) {
            C6635.m9824("task");
            throw null;
        }
        C6952 c6952 = abstractC6950.f20205;
        if (c6952 != this) {
            if (!(c6952 == null)) {
                throw new IllegalStateException("task is in multiple queues".toString());
            }
            abstractC6950.f20205 = this;
        }
        long jMo10195 = this.f20214.f20225.mo10195();
        long j2 = jMo10195 + j;
        int iIndexOf = this.f20212.indexOf(abstractC6950);
        if (iIndexOf != -1) {
            if (abstractC6950.f20206 <= j2) {
                if (C6953.f20218 == null) {
                    throw null;
                }
                if (C6953.f20217.isLoggable(Level.FINE)) {
                    C4303.m7115(abstractC6950, this, "already scheduled");
                }
                return false;
            }
            this.f20212.remove(iIndexOf);
        }
        abstractC6950.f20206 = j2;
        if (C6953.f20218 == null) {
            throw null;
        }
        if (C6953.f20217.isLoggable(Level.FINE)) {
            if (z) {
                StringBuilder sbM4889 = C2803.m4889("run again after ");
                sbM4889.append(C4303.m7153(j2 - jMo10195));
                string = sbM4889.toString();
            } else {
                StringBuilder sbM48892 = C2803.m4889("scheduled after ");
                sbM48892.append(C4303.m7153(j2 - jMo10195));
                string = sbM48892.toString();
            }
            C4303.m7115(abstractC6950, this, string);
        }
        Iterator<AbstractC6950> it = this.f20212.iterator();
        int size = 0;
        while (true) {
            if (!it.hasNext()) {
                size = -1;
                break;
            }
            if (it.next().f20206 - jMo10195 > j) {
                break;
            }
            size++;
        }
        if (size == -1) {
            size = this.f20212.size();
        }
        this.f20212.add(size, abstractC6950);
        return size == 0;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final boolean m10187() {
        AbstractC6950 abstractC6950 = this.f20211;
        if (abstractC6950 != null) {
            if (abstractC6950 == null) {
                C6635.m9822();
                throw null;
            }
            if (abstractC6950.f20208) {
                this.f20213 = true;
            }
        }
        boolean z = false;
        for (int size = this.f20212.size() - 1; size >= 0; size--) {
            if (this.f20212.get(size).f20208) {
                AbstractC6950 abstractC69502 = this.f20212.get(size);
                if (C6953.f20218 == null) {
                    throw null;
                }
                if (C6953.f20217.isLoggable(Level.FINE)) {
                    C4303.m7115(abstractC69502, this, "canceled");
                }
                this.f20212.remove(size);
                z = true;
            }
        }
        return z;
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final void m10188() {
        if (!C6943.f20196 || !Thread.holdsLock(this)) {
            synchronized (this.f20214) {
                this.f20210 = true;
                if (m10187()) {
                    this.f20214.m10192(this);
                }
            }
            return;
        }
        StringBuilder sbM4889 = C2803.m4889("Thread ");
        Thread threadCurrentThread = Thread.currentThread();
        C6635.m9823((Object) threadCurrentThread, "Thread.currentThread()");
        sbM4889.append(threadCurrentThread.getName());
        sbM4889.append(" MUST NOT hold lock on ");
        sbM4889.append(this);
        throw new AssertionError(sbM4889.toString());
    }
}
