package com.google.android.play.core.assetpacks; import java.io.FilterInputStream; import java.io.InputStream; import java.util.Arrays; /* loaded from: classes2.dex */ final class q0 extends FilterInputStream { /* renamed from: a, reason: collision with root package name */ private final g2 f5021a; /* renamed from: b, reason: collision with root package name */ private byte[] f5022b; /* renamed from: c, reason: collision with root package name */ private long f5023c; /* renamed from: d, reason: collision with root package name */ private boolean f5024d; /* renamed from: e, reason: collision with root package name */ private boolean f5025e; q0(InputStream inputStream) { super(inputStream); this.f5021a = new g2(); this.f5022b = new byte[4096]; this.f5024d = false; this.f5025e = false; } private final int O(byte[] bArr, int i10, int i11) { return Math.max(0, super.read(bArr, i10, i11)); } private final boolean P(int i10) { int O = O(this.f5022b, 0, i10); if (O != i10) { int i11 = i10 - O; if (O(this.f5022b, O, i11) != i11) { this.f5021a.b(this.f5022b, 0, O); return false; } } this.f5021a.b(this.f5022b, 0, i10); return true; } final boolean G() { return this.f5025e; } final boolean I() { return this.f5024d; } final long c() { return this.f5023c; } @Override // java.io.FilterInputStream, java.io.InputStream public final int read(byte[] bArr) { return read(bArr, 0, bArr.length); } final h3 z() { byte[] bArr; if (this.f5023c > 0) { do { bArr = this.f5022b; } while (read(bArr, 0, bArr.length) != -1); } if (this.f5024d || this.f5025e) { return new m0(null, -1L, -1, false, false, null); } if (!P(30)) { this.f5024d = true; return this.f5021a.c(); } h3 c10 = this.f5021a.c(); if (c10.d()) { this.f5025e = true; return c10; } if (c10.b() == 4294967295L) { throw new d1("Files bigger than 4GiB are not supported."); } int a10 = this.f5021a.a() - 30; int length = this.f5022b.length; long j10 = a10; if (j10 > length) { do { length += length; } while (length < j10); this.f5022b = Arrays.copyOf(this.f5022b, length); } if (!P(a10)) { this.f5024d = true; return this.f5021a.c(); } h3 c11 = this.f5021a.c(); this.f5023c = c11.b(); return c11; } @Override // java.io.FilterInputStream, java.io.InputStream public final int read(byte[] bArr, int i10, int i11) { long j10 = this.f5023c; if (j10 <= 0 || this.f5024d) { return -1; } int O = O(bArr, i10, (int) Math.min(j10, i11)); this.f5023c -= O; if (O != 0) { return O; } this.f5024d = true; return 0; } }