package ῲ.ᓣ.ῲ;

import android.content.Context;
import android.os.Handler;
import android.os.SystemClock;
import androidx.core.os.OperationCanceledException;
import androidx.loader.content.ModernAsyncTask;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import ῲ.ᨨ.㿎.C1868;

/* renamed from: ῲ.ᓣ.ῲ.K  reason: contains not printable characters */
/* compiled from: AsyncTaskLoader */
public abstract class AbstractC1688<D> extends C1683<D> {

    /* renamed from: Ԕ  reason: contains not printable characters */
    public Handler f5947;

    /* renamed from: ᕣ  reason: contains not printable characters */
    public volatile AbstractC1688<D>.RunnableC1689 f5948;

    /* renamed from: ᨨ  reason: contains not printable characters */
    public final Executor f5949;

    /* renamed from: 㑃  reason: contains not printable characters */
    public long f5950;

    /* renamed from: 㳳  reason: contains not printable characters */
    public volatile AbstractC1688<D>.RunnableC1689 f5951;

    /* renamed from: 䁗  reason: contains not printable characters */
    public long f5952 = -10000;

    /* renamed from: ῲ.ᓣ.ῲ.K$K  reason: contains not printable characters */
    /* compiled from: AsyncTaskLoader */
    public final class RunnableC1689 extends ModernAsyncTask<Void, Void, D> implements Runnable {

        /* renamed from: ᕣ  reason: contains not printable characters */
        public final CountDownLatch f5953 = new CountDownLatch(1);

        /* renamed from: 㑃  reason: contains not printable characters */
        public boolean f5954;

        public RunnableC1689() {
        }

        public void run() {
            this.f5954 = false;
            AbstractC1688.this.m4308();
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object[]] */
        @Override // androidx.loader.content.ModernAsyncTask
        /* renamed from: K  reason: contains not printable characters */
        public Object m4317(Void[] voidArr) {
            try {
                return AbstractC1688.this.m4313();
            } catch (OperationCanceledException e) {
                if (m715()) {
                    return null;
                }
                throw e;
            }
        }
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public AbstractC1688(Context context) {
        super(context);
        Executor executor = ModernAsyncTask.f1354;
        this.f5949 = executor;
    }

    /* renamed from: ʬ  reason: contains not printable characters */
    public void m4306(D d) {
    }

    /* renamed from: ᑓ  reason: contains not printable characters */
    public abstract D m4307();

    /* renamed from: ᓆ  reason: contains not printable characters */
    public void m4308() {
        if (this.f5948 == null && this.f5951 != null) {
            if (this.f5951.f5954) {
                this.f5951.f5954 = false;
                this.f5947.removeCallbacks(this.f5951);
            }
            if (this.f5950 <= 0 || SystemClock.uptimeMillis() >= this.f5952 + this.f5950) {
                AbstractC1688<D>.RunnableC1689 k = this.f5951;
                Executor executor = this.f5949;
                if (k.f1362 != ModernAsyncTask.Status.PENDING) {
                    int ordinal = k.f1362.ordinal();
                    if (ordinal == 1) {
                        throw new IllegalStateException("Cannot execute task: the task is already running.");
                    } else if (ordinal != 2) {
                        throw new IllegalStateException("We should never reach this state");
                    } else {
                        throw new IllegalStateException("Cannot execute task: the task has already been executed (a task can be executed only once)");
                    }
                } else {
                    k.f1362 = ModernAsyncTask.Status.RUNNING;
                    k.f1360.f1367 = null;
                    executor.execute(k.f1358);
                }
            } else {
                this.f5951.f5954 = true;
                this.f5947.postAtTime(this.f5951, this.f5952 + this.f5950);
            }
        }
    }

    @Override // ῲ.ᓣ.ῲ.C1683
    /* renamed from: ᕣ  reason: contains not printable characters */
    public boolean m4309() {
        if (this.f5951 == null) {
            return false;
        }
        if (!this.f5936) {
            this.f5933 = true;
        }
        if (this.f5948 != null) {
            if (this.f5951.f5954) {
                this.f5951.f5954 = false;
                this.f5947.removeCallbacks(this.f5951);
            }
            this.f5951 = null;
            return false;
        } else if (this.f5951.f5954) {
            this.f5951.f5954 = false;
            this.f5947.removeCallbacks(this.f5951);
            this.f5951 = null;
            return false;
        } else {
            AbstractC1688<D>.RunnableC1689 k = this.f5951;
            k.f1359.set(true);
            boolean cancel = k.f1358.cancel(false);
            if (cancel) {
                this.f5948 = this.f5951;
                m4315();
            }
            this.f5951 = null;
            return cancel;
        }
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public void m4310(AbstractC1688<D>.RunnableC1689 k, D d) {
        if (this.f5951 != k) {
            m4312(k, d);
        } else if (m4281()) {
            m4306(d);
        } else {
            m4270();
            this.f5952 = SystemClock.uptimeMillis();
            this.f5951 = null;
            m4279(d);
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m4312(AbstractC1688<D>.RunnableC1689 k, D d) {
        m4306(d);
        if (this.f5948 == k) {
            m4288();
            this.f5952 = SystemClock.uptimeMillis();
            this.f5948 = null;
            m4291();
            m4308();
        }
    }

    /* renamed from: ゎ  reason: contains not printable characters */
    public D m4313() {
        return m4307();
    }

    /* renamed from: 㴪  reason: contains not printable characters */
    public boolean m4314() {
        return this.f5948 != null;
    }

    /* renamed from: 㶋  reason: contains not printable characters */
    public void m4315() {
    }

    @Override // ῲ.ᓣ.ῲ.C1683
    /* renamed from: 䁗  reason: contains not printable characters */
    public void m4316() {
        super.m4294();
        m4280();
        this.f5951 = new RunnableC1689();
        m4308();
    }

    @Override // ῲ.ᓣ.ῲ.C1683
    @Deprecated
    /* renamed from: K  reason: contains not printable characters */
    public void m4311(String str, FileDescriptor fileDescriptor, PrintWriter printWriter, String[] strArr) {
        super.m4285(str, fileDescriptor, printWriter, strArr);
        if (this.f5951 != null) {
            printWriter.print(str);
            printWriter.print("mTask=");
            printWriter.print(this.f5951);
            printWriter.print(" waiting=");
            printWriter.println(this.f5951.f5954);
        }
        if (this.f5948 != null) {
            printWriter.print(str);
            printWriter.print("mCancellingTask=");
            printWriter.print(this.f5948);
            printWriter.print(" waiting=");
            printWriter.println(this.f5948.f5954);
        }
        if (this.f5950 != 0) {
            printWriter.print(str);
            printWriter.print("mUpdateThrottle=");
            C1868.m4832(this.f5950, printWriter, 0);
            printWriter.print(" mLastLoadCompleteTime=");
            long j = this.f5952;
            long uptimeMillis = SystemClock.uptimeMillis();
            if (j == 0) {
                printWriter.print("--");
            } else {
                C1868.m4832(j - uptimeMillis, printWriter, 0);
            }
            printWriter.println();
        }
    }
}
