package com.google.android.gms.internal.ads;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;

/* JADX INFO: loaded from: classes2.dex */
public final class bi1 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final wi f9546a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final File f9547b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final File f9548c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final File f9549d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public byte[] f9550e;

    public bi1(wi wiVar, File file, File file2, File file3) {
        this.f9546a = wiVar;
        this.f9547b = file;
        this.f9548c = file3;
        this.f9549d = file2;
    }

    public final byte[] a() throws Throwable {
        FileInputStream fileInputStream;
        byte[] bArrZ;
        ArrayList arrayList;
        int iMin;
        FileInputStream fileInputStream2 = null;
        if (this.f9550e == null) {
            try {
                fileInputStream = new FileInputStream(this.f9549d);
                try {
                    zzian zzianVar = zzian.f19856a;
                    arrayList = new ArrayList();
                    iMin = 256;
                } catch (IOException unused) {
                    hb.a.d(fileInputStream);
                    bArrZ = null;
                } catch (Throwable th) {
                    th = th;
                    fileInputStream2 = fileInputStream;
                    hb.a.d(fileInputStream2);
                    throw th;
                }
            } catch (IOException unused2) {
                fileInputStream = null;
            } catch (Throwable th2) {
                th = th2;
            }
            while (true) {
                byte[] bArr = new byte[iMin];
                int i10 = 0;
                while (i10 < iMin) {
                    int i11 = fileInputStream.read(bArr, i10, iMin - i10);
                    if (i11 == -1) {
                        break;
                    }
                    i10 += i11;
                }
                zzian zzianVarW = i10 == 0 ? null : zzian.w(0, i10, bArr);
                if (zzianVarW == null) {
                    break;
                }
                arrayList.add(zzianVarW);
                iMin = Math.min(iMin + iMin, 8192);
                this.f9550e = bArrZ;
            }
            bArrZ = zzian.y(arrayList).z();
            hb.a.d(fileInputStream);
            this.f9550e = bArrZ;
        }
        byte[] bArr2 = this.f9550e;
        if (bArr2 == null) {
            return null;
        }
        return Arrays.copyOf(bArr2, bArr2.length);
    }
}
