package IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.XnFJ5_9;

import IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.Xgtqvk_8;
import android.net.Uri;
import android.os.StatFs;
import android.os.SystemClock;
import android.util.SparseArray;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.LockSupport;
/* compiled from: MultiPointOutputStream.java */
/* loaded from: classes.dex */
public class Mqv2r_3 {
    public static final ExecutorService KQgRr5e_0 = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60, TimeUnit.SECONDS, new SynchronousQueue(), IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.PGPF6hQ_2.KQgRr5e_0("OkDownload file io", false));

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final int f165KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final IMuAHx_6.KQgRr5e_0.KQgRr5e_0.PGPF6hQ_2 f166KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.PGPF6hQ_2 f167KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final Xgtqvk_8 f168KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final PGPF6hQ_2 f169KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final SparseArray<IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.XnFJ5_9.KQgRr5e_0> f170KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public IOException f171KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final Runnable f172KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public String f173KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public volatile Thread f174KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public ArrayList<Integer> f175KQgRr5e_0;
    @SuppressFBWarnings({"IS2_INCONSISTENT_SYNC"})

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public List<Integer> f176KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public volatile Future f177KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final AtomicLong f178KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public boolean f179KQgRr5e_0;

    /* renamed from: Mqv2r_3  reason: collision with root package name */
    public volatile boolean f3063Mqv2r_3;
    public final int PGPF6hQ_2;

    /* renamed from: PGPF6hQ_2  reason: collision with other field name */
    public final SparseArray<Thread> f180PGPF6hQ_2;

    /* renamed from: PGPF6hQ_2  reason: collision with other field name */
    public final boolean f181PGPF6hQ_2;
    public final int QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public PGPF6hQ_2 f182QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public final SparseArray<AtomicLong> f183QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public final AtomicLong f184QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public final boolean f185QxJ9d_1;

    /* compiled from: MultiPointOutputStream.java */
    /* loaded from: classes.dex */
    public class KQgRr5e_0 implements Runnable {
        public KQgRr5e_0() {
        }

        @Override // java.lang.Runnable
        public void run() {
            Mqv2r_3.this.FSaI4_7();
        }
    }

    /* compiled from: MultiPointOutputStream.java */
    /* loaded from: classes.dex */
    public static class PGPF6hQ_2 {

        /* renamed from: KQgRr5e_0  reason: collision with other field name */
        public boolean f186KQgRr5e_0;
        public List<Integer> KQgRr5e_0 = new ArrayList();
        public List<Integer> QxJ9d_1 = new ArrayList();

        public boolean KQgRr5e_0() {
            return this.f186KQgRr5e_0 || this.QxJ9d_1.size() > 0;
        }
    }

    /* compiled from: MultiPointOutputStream.java */
    /* loaded from: classes.dex */
    public class QxJ9d_1 implements Runnable {
        public QxJ9d_1() {
        }

        @Override // java.lang.Runnable
        public void run() {
            Mqv2r_3.this.m108KQgRr5e_0();
        }
    }

    public Mqv2r_3(IMuAHx_6.KQgRr5e_0.KQgRr5e_0.PGPF6hQ_2 pGPF6hQ_2, IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.PGPF6hQ_2 pGPF6hQ_22, Xgtqvk_8 xgtqvk_8, Runnable runnable) {
        this.f170KQgRr5e_0 = new SparseArray<>();
        this.f183QxJ9d_1 = new SparseArray<>();
        this.f178KQgRr5e_0 = new AtomicLong();
        this.f184QxJ9d_1 = new AtomicLong();
        this.f179KQgRr5e_0 = false;
        this.f180PGPF6hQ_2 = new SparseArray<>();
        this.f169KQgRr5e_0 = new PGPF6hQ_2();
        this.f182QxJ9d_1 = new PGPF6hQ_2();
        this.f3063Mqv2r_3 = true;
        this.f166KQgRr5e_0 = pGPF6hQ_2;
        this.f165KQgRr5e_0 = pGPF6hQ_2.QxJ9d_1();
        this.QxJ9d_1 = pGPF6hQ_2.IMuAHx_6();
        this.PGPF6hQ_2 = pGPF6hQ_2.IFxWkV_5();
        this.f167KQgRr5e_0 = pGPF6hQ_22;
        this.f168KQgRr5e_0 = xgtqvk_8;
        this.f185QxJ9d_1 = IMuAHx_6.KQgRr5e_0.KQgRr5e_0.X6FRs_4.KQgRr5e_0().m29KQgRr5e_0().KQgRr5e_0();
        this.f181PGPF6hQ_2 = IMuAHx_6.KQgRr5e_0.KQgRr5e_0.X6FRs_4.KQgRr5e_0().m30KQgRr5e_0().m113KQgRr5e_0(pGPF6hQ_2);
        this.f175KQgRr5e_0 = new ArrayList<>();
        if (runnable == null) {
            this.f172KQgRr5e_0 = new KQgRr5e_0();
        } else {
            this.f172KQgRr5e_0 = runnable;
        }
        File m20PGPF6hQ_2 = pGPF6hQ_2.m20PGPF6hQ_2();
        if (m20PGPF6hQ_2 != null) {
            this.f173KQgRr5e_0 = m20PGPF6hQ_2.getAbsolutePath();
        }
    }

    public void FSaI4_7() {
        try {
            IMuAHx_6();
        } catch (IOException e) {
            this.f171KQgRr5e_0 = e;
            IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.PGPF6hQ_2.QxJ9d_1("MultiPointOutputStream", "Sync to breakpoint-store for task[" + this.f166KQgRr5e_0.KQgRr5e_0() + "] failed with cause: " + e);
        }
    }

    public void IFxWkV_5() {
        LockSupport.park();
    }

    public void IMuAHx_6() throws IOException {
        int i;
        IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.PGPF6hQ_2.KQgRr5e_0("MultiPointOutputStream", "OutputStream start flush looper task[" + this.f166KQgRr5e_0.KQgRr5e_0() + "] with syncBufferIntervalMills[" + this.PGPF6hQ_2 + "] syncBufferSize[" + this.QxJ9d_1 + "]");
        this.f174KQgRr5e_0 = Thread.currentThread();
        long j = (long) this.PGPF6hQ_2;
        PGPF6hQ_2();
        while (true) {
            KQgRr5e_0(j);
            KQgRr5e_0(this.f182QxJ9d_1);
            if (this.f182QxJ9d_1.KQgRr5e_0()) {
                IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.PGPF6hQ_2.KQgRr5e_0("MultiPointOutputStream", "runSync state change isNoMoreStream[" + this.f182QxJ9d_1.f186KQgRr5e_0 + "] newNoMoreStreamBlockList[" + this.f182QxJ9d_1.QxJ9d_1 + "]");
                if (this.f178KQgRr5e_0.get() > 0) {
                    PGPF6hQ_2();
                }
                for (Integer num : this.f182QxJ9d_1.QxJ9d_1) {
                    Thread thread = this.f180PGPF6hQ_2.get(num.intValue());
                    this.f180PGPF6hQ_2.remove(num.intValue());
                    if (thread != null) {
                        KQgRr5e_0(thread);
                    }
                }
                if (this.f182QxJ9d_1.f186KQgRr5e_0) {
                    break;
                }
            } else {
                if (m110KQgRr5e_0()) {
                    i = this.PGPF6hQ_2;
                } else {
                    j = KQgRr5e_0();
                    if (j <= 0) {
                        PGPF6hQ_2();
                        i = this.PGPF6hQ_2;
                    }
                }
                j = i;
            }
        }
        int size = this.f180PGPF6hQ_2.size();
        for (int i2 = 0; i2 < size; i2++) {
            Thread valueAt = this.f180PGPF6hQ_2.valueAt(i2);
            if (valueAt != null) {
                KQgRr5e_0(valueAt);
            }
        }
        this.f180PGPF6hQ_2.clear();
        IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.PGPF6hQ_2.KQgRr5e_0("MultiPointOutputStream", "OutputStream stop flush looper task[" + this.f166KQgRr5e_0.KQgRr5e_0() + "]");
    }

    public synchronized void KQgRr5e_0(int i, byte[] bArr, int i2) throws IOException {
        if (this.f179KQgRr5e_0) {
            return;
        }
        KQgRr5e_0(i).KQgRr5e_0(bArr, 0, i2);
        long j = i2;
        this.f178KQgRr5e_0.addAndGet(j);
        this.f183QxJ9d_1.get(i).addAndGet(j);
        Mqv2r_3();
    }

    public void Mqv2r_3(int i) throws IOException {
        IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.KQgRr5e_0 KQgRr5e_02 = this.f167KQgRr5e_0.KQgRr5e_0(i);
        if (IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.PGPF6hQ_2.KQgRr5e_0(KQgRr5e_02.QxJ9d_1(), KQgRr5e_02.KQgRr5e_0())) {
            return;
        }
        throw new IOException("The current offset on block-info isn't update correct, " + KQgRr5e_02.QxJ9d_1() + " != " + KQgRr5e_02.KQgRr5e_0() + " on " + i);
    }

    public void PGPF6hQ_2(int i) throws IOException {
        this.f175KQgRr5e_0.add(Integer.valueOf(i));
        try {
            if (this.f171KQgRr5e_0 == null) {
                if (this.f177KQgRr5e_0 != null && !this.f177KQgRr5e_0.isDone()) {
                    AtomicLong atomicLong = this.f183QxJ9d_1.get(i);
                    if (atomicLong != null && atomicLong.get() > 0) {
                        KQgRr5e_0(this.f169KQgRr5e_0);
                        KQgRr5e_0(this.f169KQgRr5e_0.f186KQgRr5e_0, i);
                    }
                } else if (this.f177KQgRr5e_0 == null) {
                    IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.PGPF6hQ_2.KQgRr5e_0("MultiPointOutputStream", "OutputStream done but no need to ensure sync, because the sync job not run yet. task[" + this.f166KQgRr5e_0.KQgRr5e_0() + "] block[" + i + "]");
                } else {
                    IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.PGPF6hQ_2.KQgRr5e_0("MultiPointOutputStream", "OutputStream done but no need to ensure sync, because the syncFuture.isDone[" + this.f177KQgRr5e_0.isDone() + "] task[" + this.f166KQgRr5e_0.KQgRr5e_0() + "] block[" + i + "]");
                }
                return;
            }
            throw this.f171KQgRr5e_0;
        } finally {
            QxJ9d_1(i);
        }
    }

    /* renamed from: QxJ9d_1  reason: collision with other method in class */
    public void m111QxJ9d_1() {
        KQgRr5e_0.execute(new QxJ9d_1());
    }

    public final void X6FRs_4() {
        if (this.f173KQgRr5e_0 != null || this.f166KQgRr5e_0.m20PGPF6hQ_2() == null) {
            return;
        }
        this.f173KQgRr5e_0 = this.f166KQgRr5e_0.m20PGPF6hQ_2().getAbsolutePath();
    }

    /* renamed from: QxJ9d_1  reason: collision with other method in class */
    public boolean m112QxJ9d_1() {
        return this.f174KQgRr5e_0 != null;
    }

    public synchronized void QxJ9d_1(int i) throws IOException {
        IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.XnFJ5_9.KQgRr5e_0 kQgRr5e_0 = this.f170KQgRr5e_0.get(i);
        if (kQgRr5e_0 != null) {
            kQgRr5e_0.close();
            this.f170KQgRr5e_0.remove(i);
            IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.PGPF6hQ_2.KQgRr5e_0("MultiPointOutputStream", "OutputStream close task[" + this.f166KQgRr5e_0.KQgRr5e_0() + "] block[" + i + "]");
        }
    }

    public void Mqv2r_3() throws IOException {
        IOException iOException = this.f171KQgRr5e_0;
        if (iOException == null) {
            if (this.f177KQgRr5e_0 == null) {
                synchronized (this.f172KQgRr5e_0) {
                    if (this.f177KQgRr5e_0 == null) {
                        this.f177KQgRr5e_0 = m107KQgRr5e_0();
                    }
                }
                return;
            }
            return;
        }
        throw iOException;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public synchronized void m108KQgRr5e_0() {
        if (this.f176KQgRr5e_0 == null) {
            return;
        }
        if (this.f179KQgRr5e_0) {
            return;
        }
        this.f179KQgRr5e_0 = true;
        this.f175KQgRr5e_0.addAll(this.f176KQgRr5e_0);
        if (this.f178KQgRr5e_0.get() <= 0) {
            for (Integer num : this.f176KQgRr5e_0) {
                try {
                    QxJ9d_1(num.intValue());
                } catch (IOException e) {
                    IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.PGPF6hQ_2.KQgRr5e_0("MultiPointOutputStream", "OutputStream close failed task[" + this.f166KQgRr5e_0.KQgRr5e_0() + "] block[" + num + "]" + e);
                }
            }
            this.f168KQgRr5e_0.KQgRr5e_0(this.f166KQgRr5e_0.KQgRr5e_0(), IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.X6FRs_4.KQgRr5e_0.CANCELED, (Exception) null);
            return;
        }
        if (this.f177KQgRr5e_0 != null && !this.f177KQgRr5e_0.isDone()) {
            X6FRs_4();
            IMuAHx_6.KQgRr5e_0.KQgRr5e_0.X6FRs_4.KQgRr5e_0().m30KQgRr5e_0().KQgRr5e_0().QxJ9d_1(this.f173KQgRr5e_0);
            try {
                KQgRr5e_0(true, -1);
                IMuAHx_6.KQgRr5e_0.KQgRr5e_0.X6FRs_4.KQgRr5e_0().m30KQgRr5e_0().KQgRr5e_0().KQgRr5e_0(this.f173KQgRr5e_0);
            } catch (Throwable th) {
                IMuAHx_6.KQgRr5e_0.KQgRr5e_0.X6FRs_4.KQgRr5e_0().m30KQgRr5e_0().KQgRr5e_0().KQgRr5e_0(this.f173KQgRr5e_0);
                throw th;
            }
        }
        for (Integer num2 : this.f176KQgRr5e_0) {
            try {
                QxJ9d_1(num2.intValue());
            } catch (IOException e2) {
                IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.PGPF6hQ_2.KQgRr5e_0("MultiPointOutputStream", "OutputStream close failed task[" + this.f166KQgRr5e_0.KQgRr5e_0() + "] block[" + num2 + "]" + e2);
            }
        }
        this.f168KQgRr5e_0.KQgRr5e_0(this.f166KQgRr5e_0.KQgRr5e_0(), IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.X6FRs_4.KQgRr5e_0.CANCELED, (Exception) null);
        return;
    }

    public long QxJ9d_1() {
        return SystemClock.uptimeMillis();
    }

    /* JADX WARN: Removed duplicated region for block: B:17:0x005c  */
    /* JADX WARN: Removed duplicated region for block: B:35:? A[RETURN, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void PGPF6hQ_2() throws IOException {
        int size;
        boolean z;
        synchronized (this.f183QxJ9d_1) {
            size = this.f183QxJ9d_1.size();
        }
        SparseArray sparseArray = new SparseArray(size);
        int i = 0;
        while (true) {
            long j = 0;
            if (i >= size) {
                break;
            }
            try {
                int keyAt = this.f170KQgRr5e_0.keyAt(i);
                long j2 = this.f183QxJ9d_1.get(keyAt).get();
                if (j2 > 0) {
                    sparseArray.put(keyAt, Long.valueOf(j2));
                    this.f170KQgRr5e_0.get(keyAt).KQgRr5e_0();
                }
                i++;
            } catch (IOException e) {
                IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.PGPF6hQ_2.QxJ9d_1("MultiPointOutputStream", "OutputStream flush and sync data to filesystem failed " + e);
                z = false;
            }
            if (z) {
                return;
            }
            int size2 = sparseArray.size();
            for (int i2 = 0; i2 < size2; i2++) {
                int keyAt2 = sparseArray.keyAt(i2);
                long longValue = ((Long) sparseArray.valueAt(i2)).longValue();
                this.f168KQgRr5e_0.KQgRr5e_0(this.f167KQgRr5e_0, keyAt2, longValue);
                j += longValue;
                this.f183QxJ9d_1.get(keyAt2).addAndGet(-longValue);
                IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.PGPF6hQ_2.KQgRr5e_0("MultiPointOutputStream", "OutputStream sync success (" + this.f166KQgRr5e_0.KQgRr5e_0() + ") block(" + keyAt2 + ")  syncLength(" + longValue + ") currentOffset(" + this.f167KQgRr5e_0.KQgRr5e_0(keyAt2).QxJ9d_1() + ")");
            }
            this.f178KQgRr5e_0.addAndGet(-j);
            this.f184QxJ9d_1.set(SystemClock.uptimeMillis());
            return;
        }
        z = true;
        if (z) {
        }
    }

    public Mqv2r_3(IMuAHx_6.KQgRr5e_0.KQgRr5e_0.PGPF6hQ_2 pGPF6hQ_2, IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Mqv2r_3.PGPF6hQ_2 pGPF6hQ_22, Xgtqvk_8 xgtqvk_8) {
        this(pGPF6hQ_2, pGPF6hQ_22, xgtqvk_8, null);
    }

    public void KQgRr5e_0(boolean z, int i) {
        if (this.f177KQgRr5e_0 == null || this.f177KQgRr5e_0.isDone()) {
            return;
        }
        if (!z) {
            this.f180PGPF6hQ_2.put(i, Thread.currentThread());
        }
        if (this.f174KQgRr5e_0 != null) {
            KQgRr5e_0(this.f174KQgRr5e_0);
        } else {
            while (!m112QxJ9d_1()) {
                KQgRr5e_0(25L);
            }
            KQgRr5e_0(this.f174KQgRr5e_0);
        }
        if (z) {
            KQgRr5e_0(this.f174KQgRr5e_0);
            try {
                this.f177KQgRr5e_0.get();
                return;
            } catch (InterruptedException | ExecutionException unused) {
                return;
            }
        }
        IFxWkV_5();
    }

    public void KQgRr5e_0(long j) {
        LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(j));
    }

    public void KQgRr5e_0(Thread thread) {
        LockSupport.unpark(thread);
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public Future m107KQgRr5e_0() {
        return KQgRr5e_0.submit(this.f172KQgRr5e_0);
    }

    public void KQgRr5e_0(PGPF6hQ_2 pGPF6hQ_2) {
        pGPF6hQ_2.QxJ9d_1.clear();
        int size = new HashSet((List) this.f175KQgRr5e_0.clone()).size();
        if (size != this.f176KQgRr5e_0.size()) {
            IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.PGPF6hQ_2.KQgRr5e_0("MultiPointOutputStream", "task[" + this.f166KQgRr5e_0.KQgRr5e_0() + "] current need fetching block count " + this.f176KQgRr5e_0.size() + " is not equal to no more stream block count " + size);
            pGPF6hQ_2.f186KQgRr5e_0 = false;
        } else {
            IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.PGPF6hQ_2.KQgRr5e_0("MultiPointOutputStream", "task[" + this.f166KQgRr5e_0.KQgRr5e_0() + "] current need fetching block count " + this.f176KQgRr5e_0.size() + " is equal to no more stream block count " + size);
            pGPF6hQ_2.f186KQgRr5e_0 = true;
        }
        SparseArray<IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.XnFJ5_9.KQgRr5e_0> clone = this.f170KQgRr5e_0.clone();
        int size2 = clone.size();
        for (int i = 0; i < size2; i++) {
            int keyAt = clone.keyAt(i);
            if (this.f175KQgRr5e_0.contains(Integer.valueOf(keyAt)) && !pGPF6hQ_2.KQgRr5e_0.contains(Integer.valueOf(keyAt))) {
                pGPF6hQ_2.KQgRr5e_0.add(Integer.valueOf(keyAt));
                pGPF6hQ_2.QxJ9d_1.add(Integer.valueOf(keyAt));
            }
        }
    }

    public void KQgRr5e_0(List<Integer> list) {
        this.f176KQgRr5e_0 = list;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public void m109KQgRr5e_0(int i) {
        this.f175KQgRr5e_0.add(Integer.valueOf(i));
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public boolean m110KQgRr5e_0() {
        return this.f178KQgRr5e_0.get() < ((long) this.QxJ9d_1);
    }

    public long KQgRr5e_0() {
        return this.PGPF6hQ_2 - (QxJ9d_1() - this.f184QxJ9d_1.get());
    }

    public synchronized IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.XnFJ5_9.KQgRr5e_0 KQgRr5e_0(int i) throws IOException {
        IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.XnFJ5_9.KQgRr5e_0 kQgRr5e_0;
        Uri KQgRr5e_02;
        kQgRr5e_0 = this.f170KQgRr5e_0.get(i);
        if (kQgRr5e_0 == null) {
            boolean QxJ9d_12 = IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.PGPF6hQ_2.QxJ9d_1(this.f166KQgRr5e_0.KQgRr5e_0());
            if (QxJ9d_12) {
                File m20PGPF6hQ_2 = this.f166KQgRr5e_0.m20PGPF6hQ_2();
                if (m20PGPF6hQ_2 != null) {
                    File KQgRr5e_03 = this.f166KQgRr5e_0.KQgRr5e_0();
                    if (!KQgRr5e_03.exists() && !KQgRr5e_03.mkdirs()) {
                        throw new IOException("Create parent folder failed!");
                    }
                    if (m20PGPF6hQ_2.createNewFile()) {
                        IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.PGPF6hQ_2.KQgRr5e_0("MultiPointOutputStream", "Create new file: " + m20PGPF6hQ_2.getName());
                    }
                    KQgRr5e_02 = Uri.fromFile(m20PGPF6hQ_2);
                } else {
                    throw new FileNotFoundException("Filename is not ready!");
                }
            } else {
                KQgRr5e_02 = this.f166KQgRr5e_0.KQgRr5e_0();
            }
            IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.XnFJ5_9.KQgRr5e_0 KQgRr5e_04 = IMuAHx_6.KQgRr5e_0.KQgRr5e_0.X6FRs_4.KQgRr5e_0().m29KQgRr5e_0().KQgRr5e_0(IMuAHx_6.KQgRr5e_0.KQgRr5e_0.X6FRs_4.KQgRr5e_0().m31KQgRr5e_0(), KQgRr5e_02, this.f165KQgRr5e_0);
            if (this.f185QxJ9d_1) {
                long PGPF6hQ_22 = this.f167KQgRr5e_0.KQgRr5e_0(i).PGPF6hQ_2();
                if (PGPF6hQ_22 > 0) {
                    KQgRr5e_04.QxJ9d_1(PGPF6hQ_22);
                    IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.PGPF6hQ_2.KQgRr5e_0("MultiPointOutputStream", "Create output stream write from (" + this.f166KQgRr5e_0.KQgRr5e_0() + ") block(" + i + ") " + PGPF6hQ_22);
                }
            }
            if (this.f3063Mqv2r_3) {
                this.f168KQgRr5e_0.m102KQgRr5e_0(this.f166KQgRr5e_0.KQgRr5e_0());
            }
            if (!this.f167KQgRr5e_0.m93KQgRr5e_0() && this.f3063Mqv2r_3 && this.f181PGPF6hQ_2) {
                long m87KQgRr5e_0 = this.f167KQgRr5e_0.m87KQgRr5e_0();
                if (QxJ9d_12) {
                    File m20PGPF6hQ_22 = this.f166KQgRr5e_0.m20PGPF6hQ_2();
                    long length = m87KQgRr5e_0 - m20PGPF6hQ_22.length();
                    if (length > 0) {
                        KQgRr5e_0(new StatFs(m20PGPF6hQ_22.getAbsolutePath()), length);
                        KQgRr5e_04.KQgRr5e_0(m87KQgRr5e_0);
                    }
                } else {
                    KQgRr5e_04.KQgRr5e_0(m87KQgRr5e_0);
                }
            }
            synchronized (this.f183QxJ9d_1) {
                this.f170KQgRr5e_0.put(i, KQgRr5e_04);
                this.f183QxJ9d_1.put(i, new AtomicLong());
            }
            this.f3063Mqv2r_3 = false;
            kQgRr5e_0 = KQgRr5e_04;
        }
        return kQgRr5e_0;
    }

    public void KQgRr5e_0(StatFs statFs, long j) throws IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Xgtqvk_8.X6FRs_4 {
        long KQgRr5e_02 = IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.PGPF6hQ_2.KQgRr5e_0(statFs);
        if (KQgRr5e_02 < j) {
            throw new IMuAHx_6.KQgRr5e_0.KQgRr5e_0.XnFJ5_9.Xgtqvk_8.X6FRs_4(j, KQgRr5e_02);
        }
    }
}
