package p138.p176.p177.p242.p265.p266;

import java.lang.Thread;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import p000.p001.p002.p003.p004.C0567;

/* JADX INFO: renamed from: ދ.ހ.֏.ހ.ބ.֏.ǃ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C4771 extends AbstractC4954 {

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public static final AtomicLong f14380 = new AtomicLong(Long.MIN_VALUE);

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public C5007 f14381;

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

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public final PriorityBlockingQueue<C4894<?>> f14383;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final BlockingQueue<C4894<?>> f14384;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final Thread.UncaughtExceptionHandler f14385;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public final Thread.UncaughtExceptionHandler f14386;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public final Object f14387;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public final Semaphore f14388;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public volatile boolean f14389;

    public C4771(C4974 c4974) {
        super(c4974);
        this.f14387 = new Object();
        this.f14388 = new Semaphore(2);
        this.f14383 = new PriorityBlockingQueue<>();
        this.f14384 = new LinkedBlockingQueue();
        this.f14385 = new C4759(this, "Thread death: Uncaught exception on worker thread");
        this.f14386 = new C4759(this, "Thread death: Uncaught exception on network thread");
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final <T> T m8002(AtomicReference<T> atomicReference, long j, String str, Runnable runnable) {
        synchronized (atomicReference) {
            C4771 c4771Mo8163 = mo8163();
            c4771Mo8163.m8482();
            C0567.m1910(runnable);
            c4771Mo8163.m8005(new C4894<>(c4771Mo8163, runnable, "Task exception on worker thread"));
            try {
                atomicReference.wait(j);
            } catch (InterruptedException unused) {
                C4792 c4792 = mo8165().f14447;
                String strValueOf = String.valueOf(str);
                c4792.m8034(strValueOf.length() != 0 ? "Interrupted waiting for ".concat(strValueOf) : new String("Interrupted waiting for "));
                return null;
            }
        }
        T t = atomicReference.get();
        if (t == null) {
            C4792 c47922 = mo8165().f14447;
            String strValueOf2 = String.valueOf(str);
            c47922.m8034(strValueOf2.length() != 0 ? "Timed out waiting for ".concat(strValueOf2) : new String("Timed out waiting for "));
        }
        return t;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final <V> Future<V> m8003(Callable<V> callable) {
        m8482();
        C0567.m1910(callable);
        C4894<?> c4894 = new C4894<>(this, callable, false, "Task exception on worker thread");
        if (Thread.currentThread() == this.f14381) {
            if (!this.f14383.isEmpty()) {
                mo8165().f14447.m8034("Callable skipped the worker queue.");
            }
            c4894.run();
        } else {
            m8005(c4894);
        }
        return c4894;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m8004(Runnable runnable) {
        m8482();
        C0567.m1910(runnable);
        m8005(new C4894<>(this, runnable, "Task exception on worker thread"));
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m8005(C4894<?> c4894) {
        synchronized (this.f14387) {
            this.f14383.add(c4894);
            if (this.f14381 == null) {
                C5007 c5007 = new C5007(this, "Measurement Worker", this.f14383);
                this.f14381 = c5007;
                c5007.setUncaughtExceptionHandler(this.f14385);
                this.f14381.start();
            } else {
                this.f14381.m8529();
            }
        }
    }

    @Override // p138.p176.p177.p242.p265.p266.C4852
    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final void mo8006() {
        if (Thread.currentThread() != this.f14382) {
            throw new IllegalStateException("Call expected from network thread");
        }
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final void m8007(Runnable runnable) {
        m8482();
        C0567.m1910(runnable);
        C4894<?> c4894 = new C4894<>(this, runnable, "Task exception on network thread");
        synchronized (this.f14387) {
            this.f14384.add(c4894);
            if (this.f14382 == null) {
                C5007 c5007 = new C5007(this, "Measurement Network", this.f14384);
                this.f14382 = c5007;
                c5007.setUncaughtExceptionHandler(this.f14386);
                this.f14382.start();
            } else {
                this.f14382.m8529();
            }
        }
    }

    @Override // p138.p176.p177.p242.p265.p266.C4852
    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final void mo8008() {
        if (Thread.currentThread() != this.f14381) {
            throw new IllegalStateException("Call expected from worker thread");
        }
    }

    @Override // p138.p176.p177.p242.p265.p266.AbstractC4954
    /* JADX INFO: renamed from: ގ, reason: contains not printable characters */
    public final boolean mo8009() {
        return false;
    }

    /* JADX INFO: renamed from: ސ, reason: contains not printable characters */
    public final boolean m8010() {
        return Thread.currentThread() == this.f14381;
    }
}
