package com.fyber.inneractive.sdk.protobuf; import androidx.work.WorkInfo; import com.fyber.inneractive.sdk.protobuf.q1; import java.io.IOException; import java.io.OutputStream; import java.util.logging.Level; import java.util.logging.Logger; /* loaded from: classes2.dex */ public abstract class l extends h { public static final Logger b = Logger.getLogger(l.class.getName()); public static final boolean c = p1.e; public m a; public static abstract class a extends l { public final byte[] d; public final int e; public int f; public a(int i) { super(0); if (i < 0) { throw new IllegalArgumentException("bufferSize must be >= 0"); } int max = Math.max(i, 20); this.d = new byte[max]; this.e = max; } public final void e(long j) { byte[] bArr = this.d; int i = this.f; bArr[i] = (byte) (j & 255); bArr[i + 1] = (byte) ((j >> 8) & 255); bArr[i + 2] = (byte) ((j >> 16) & 255); bArr[i + 3] = (byte) (255 & (j >> 24)); bArr[i + 4] = (byte) (((int) (j >> 32)) & 255); bArr[i + 5] = (byte) (((int) (j >> 40)) & 255); bArr[i + 6] = (byte) (((int) (j >> 48)) & 255); this.f = i + 8; bArr[i + 7] = (byte) (((int) (j >> 56)) & 255); } public final void j(int i) { byte[] bArr = this.d; int i2 = this.f; bArr[i2] = (byte) (i & 255); bArr[i2 + 1] = (byte) ((i >> 8) & 255); bArr[i2 + 2] = (byte) ((i >> 16) & 255); this.f = i2 + 4; bArr[i2 + 3] = (byte) ((i >> 24) & 255); } public final void f(long j) { if (l.c) { while ((j & (-128)) != 0) { byte[] bArr = this.d; int i = this.f; this.f = i + 1; p1.a(bArr, i, (byte) ((((int) j) & 127) | 128)); j >>>= 7; } byte[] bArr2 = this.d; int i2 = this.f; this.f = i2 + 1; p1.a(bArr2, i2, (byte) j); return; } while ((j & (-128)) != 0) { byte[] bArr3 = this.d; int i3 = this.f; this.f = i3 + 1; bArr3[i3] = (byte) ((((int) j) & 127) | 128); j >>>= 7; } byte[] bArr4 = this.d; int i4 = this.f; this.f = i4 + 1; bArr4[i4] = (byte) j; } public final void k(int i) { if (l.c) { while ((i & WorkInfo.STOP_REASON_FOREGROUND_SERVICE_TIMEOUT) != 0) { byte[] bArr = this.d; int i2 = this.f; this.f = i2 + 1; p1.a(bArr, i2, (byte) ((i & 127) | 128)); i >>>= 7; } byte[] bArr2 = this.d; int i3 = this.f; this.f = i3 + 1; p1.a(bArr2, i3, (byte) i); return; } while ((i & WorkInfo.STOP_REASON_FOREGROUND_SERVICE_TIMEOUT) != 0) { byte[] bArr3 = this.d; int i4 = this.f; this.f = i4 + 1; bArr3[i4] = (byte) ((i & 127) | 128); i >>>= 7; } byte[] bArr4 = this.d; int i5 = this.f; this.f = i5 + 1; bArr4[i5] = (byte) i; } } public static class b extends l { public final byte[] d; public final int e; public int f; public b(byte[] bArr, int i) { super(0); if (((bArr.length - i) | i) < 0) { throw new IllegalArgumentException(String.format("Array range is invalid. Buffer.length=%d, offset=%d, length=%d", Integer.valueOf(bArr.length), 0, Integer.valueOf(i))); } this.d = bArr; this.f = 0; this.e = i; } public final int a() { return this.e - this.f; } @Override // com.fyber.inneractive.sdk.protobuf.l public final void a(int i, boolean z) throws IOException { i(r1.a(i, 0)); a(z ? (byte) 1 : (byte) 0); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void b(int i, i iVar) throws IOException { i(r1.a(i, 2)); i(iVar.size()); iVar.a(this); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void c(int i, int i2) throws IOException { i(r1.a(i, 0)); h(i2); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void e(int i, int i2) throws IOException { i(r1.a(i, 0)); i(i2); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void g(int i) throws IOException { try { byte[] bArr = this.d; int i2 = this.f; bArr[i2] = (byte) (i & 255); bArr[i2 + 1] = (byte) ((i >> 8) & 255); bArr[i2 + 2] = (byte) ((i >> 16) & 255); this.f = i2 + 4; bArr[i2 + 3] = (byte) ((i >> 24) & 255); } catch (IndexOutOfBoundsException e) { throw new c(String.format("Pos: %d, limit: %d, len: %d", Integer.valueOf(this.f), Integer.valueOf(this.e), 1), e); } } @Override // com.fyber.inneractive.sdk.protobuf.l public final void h(int i) throws IOException { if (i >= 0) { i(i); } else { d(i); } } @Override // com.fyber.inneractive.sdk.protobuf.l public final void d(long j) throws IOException { if (l.c && a() >= 10) { while ((j & (-128)) != 0) { byte[] bArr = this.d; int i = this.f; this.f = i + 1; p1.a(bArr, i, (byte) ((((int) j) & 127) | 128)); j >>>= 7; } byte[] bArr2 = this.d; int i2 = this.f; this.f = i2 + 1; p1.a(bArr2, i2, (byte) j); return; } while ((j & (-128)) != 0) { try { byte[] bArr3 = this.d; int i3 = this.f; this.f = i3 + 1; bArr3[i3] = (byte) ((((int) j) & 127) | 128); j >>>= 7; } catch (IndexOutOfBoundsException e) { throw new c(String.format("Pos: %d, limit: %d, len: %d", Integer.valueOf(this.f), Integer.valueOf(this.e), 1), e); } } byte[] bArr4 = this.d; int i4 = this.f; this.f = i4 + 1; bArr4[i4] = (byte) j; } @Override // com.fyber.inneractive.sdk.protobuf.l public final void i(int i) throws IOException { if (!l.c || com.fyber.inneractive.sdk.protobuf.d.a() || a() < 5) { while ((i & WorkInfo.STOP_REASON_FOREGROUND_SERVICE_TIMEOUT) != 0) { try { byte[] bArr = this.d; int i2 = this.f; this.f = i2 + 1; bArr[i2] = (byte) ((i & 127) | 128); i >>>= 7; } catch (IndexOutOfBoundsException e) { throw new c(String.format("Pos: %d, limit: %d, len: %d", Integer.valueOf(this.f), Integer.valueOf(this.e), 1), e); } } byte[] bArr2 = this.d; int i3 = this.f; this.f = i3 + 1; bArr2[i3] = (byte) i; return; } if ((i & WorkInfo.STOP_REASON_FOREGROUND_SERVICE_TIMEOUT) == 0) { byte[] bArr3 = this.d; int i4 = this.f; this.f = i4 + 1; p1.a(bArr3, i4, (byte) i); return; } byte[] bArr4 = this.d; int i5 = this.f; this.f = i5 + 1; p1.a(bArr4, i5, (byte) (i | 128)); int i6 = i >>> 7; if ((i6 & WorkInfo.STOP_REASON_FOREGROUND_SERVICE_TIMEOUT) == 0) { byte[] bArr5 = this.d; int i7 = this.f; this.f = i7 + 1; p1.a(bArr5, i7, (byte) i6); return; } byte[] bArr6 = this.d; int i8 = this.f; this.f = i8 + 1; p1.a(bArr6, i8, (byte) (i6 | 128)); int i9 = i >>> 14; if ((i9 & WorkInfo.STOP_REASON_FOREGROUND_SERVICE_TIMEOUT) == 0) { byte[] bArr7 = this.d; int i10 = this.f; this.f = i10 + 1; p1.a(bArr7, i10, (byte) i9); return; } byte[] bArr8 = this.d; int i11 = this.f; this.f = i11 + 1; p1.a(bArr8, i11, (byte) (i9 | 128)); int i12 = i >>> 21; if ((i12 & WorkInfo.STOP_REASON_FOREGROUND_SERVICE_TIMEOUT) == 0) { byte[] bArr9 = this.d; int i13 = this.f; this.f = i13 + 1; p1.a(bArr9, i13, (byte) i12); return; } byte[] bArr10 = this.d; int i14 = this.f; this.f = i14 + 1; p1.a(bArr10, i14, (byte) (i12 | 128)); byte[] bArr11 = this.d; int i15 = this.f; this.f = i15 + 1; p1.a(bArr11, i15, (byte) (i >>> 28)); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void a(int i, long j) throws IOException { i(r1.a(i, 1)); c(j); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void c(int i, i iVar) throws IOException { i(r1.a(1, 3)); e(2, i); b(3, iVar); i(r1.a(1, 4)); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void b(int i, int i2) throws IOException { i(r1.a(i, 5)); g(i2); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void a(int i, o0 o0Var, d1 d1Var) throws IOException { i(r1.a(i, 2)); i(((com.fyber.inneractive.sdk.protobuf.a) o0Var).getSerializedSize(d1Var)); d1Var.a((Object) o0Var, this.a); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void b(int i, long j) throws IOException { i(r1.a(i, 0)); d(j); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void c(long j) throws IOException { try { byte[] bArr = this.d; int i = this.f; bArr[i] = (byte) (((int) j) & 255); bArr[i + 1] = (byte) (((int) (j >> 8)) & 255); bArr[i + 2] = (byte) (((int) (j >> 16)) & 255); bArr[i + 3] = (byte) (((int) (j >> 24)) & 255); bArr[i + 4] = (byte) (((int) (j >> 32)) & 255); bArr[i + 5] = (byte) (((int) (j >> 40)) & 255); bArr[i + 6] = (byte) (((int) (j >> 48)) & 255); this.f = i + 8; bArr[i + 7] = (byte) (((int) (j >> 56)) & 255); } catch (IndexOutOfBoundsException e) { throw new c(String.format("Pos: %d, limit: %d, len: %d", Integer.valueOf(this.f), Integer.valueOf(this.e), 1), e); } } @Override // com.fyber.inneractive.sdk.protobuf.l public final void a(int i, o0 o0Var) throws IOException { i(r1.a(1, 3)); e(2, i); i(r1.a(3, 2)); i(o0Var.getSerializedSize()); o0Var.writeTo(this); i(r1.a(1, 4)); } public final void b(String str) throws IOException { int i = this.f; try { int e = l.e(str.length() * 3); int e2 = l.e(str.length()); if (e2 == e) { int i2 = i + e2; this.f = i2; int a = q1.a.a(str, this.d, i2, a()); this.f = i; i((a - i) - e2); this.f = a; } else { i(q1.a(str)); this.f = q1.a.a(str, this.d, this.f, a()); } } catch (q1.d e3) { this.f = i; a(str, e3); } catch (IndexOutOfBoundsException e4) { throw new c(e4); } } @Override // com.fyber.inneractive.sdk.protobuf.l public final void a(String str, int i) throws IOException { i(r1.a(i, 2)); b(str); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void a(byte b) throws IOException { try { byte[] bArr = this.d; int i = this.f; this.f = i + 1; bArr[i] = b; } catch (IndexOutOfBoundsException e) { throw new c(String.format("Pos: %d, limit: %d, len: %d", Integer.valueOf(this.f), Integer.valueOf(this.e), 1), e); } } @Override // com.fyber.inneractive.sdk.protobuf.h public final void a(byte[] bArr, int i, int i2) throws IOException { try { System.arraycopy(bArr, i, this.d, this.f, i2); this.f += i2; } catch (IndexOutOfBoundsException e) { throw new c(String.format("Pos: %d, limit: %d, len: %d", Integer.valueOf(this.f), Integer.valueOf(this.e), Integer.valueOf(i2)), e); } } @Override // com.fyber.inneractive.sdk.protobuf.l public final void d(int i, int i2) throws IOException { i(r1.a(i, i2)); } } public static class c extends IOException { private static final long serialVersionUID = -6947486886997889499L; public c(IndexOutOfBoundsException indexOutOfBoundsException) { super("CodedOutputStream was writing to a flat byte array and ran out of space.", indexOutOfBoundsException); } public c(String str, IndexOutOfBoundsException indexOutOfBoundsException) { super("CodedOutputStream was writing to a flat byte array and ran out of space.: " + str, indexOutOfBoundsException); } } public static final class d extends a { public final OutputStream g; public d(OutputStream outputStream, int i) { super(i); if (outputStream == null) { throw new NullPointerException("out"); } this.g = outputStream; } @Override // com.fyber.inneractive.sdk.protobuf.l public final void a(int i, o0 o0Var, d1 d1Var) throws IOException { i(r1.a(i, 2)); i(((com.fyber.inneractive.sdk.protobuf.a) o0Var).getSerializedSize(d1Var)); d1Var.a((Object) o0Var, this.a); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void b(int i, i iVar) throws IOException { i(r1.a(i, 2)); i(iVar.size()); iVar.a(this); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void c(int i, i iVar) throws IOException { i(r1.a(1, 3)); e(2, i); b(3, iVar); i(r1.a(1, 4)); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void d(int i, int i2) throws IOException { i(r1.a(i, i2)); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void e(int i, int i2) throws IOException { l(20); k(r1.a(i, 0)); k(i2); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void g(int i) throws IOException { l(4); j(i); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void h(int i) throws IOException { if (i >= 0) { i(i); } else { d(i); } } @Override // com.fyber.inneractive.sdk.protobuf.l public final void i(int i) throws IOException { l(5); k(i); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void d(long j) throws IOException { l(10); f(j); } public final void l(int i) throws IOException { if (this.e - this.f < i) { a(); } } @Override // com.fyber.inneractive.sdk.protobuf.l public final void a(int i, o0 o0Var) throws IOException { i(r1.a(1, 3)); e(2, i); i(r1.a(3, 2)); i(o0Var.getSerializedSize()); o0Var.writeTo(this); i(r1.a(1, 4)); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void b(int i, int i2) throws IOException { l(14); k(r1.a(i, 5)); j(i2); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void c(int i, int i2) throws IOException { l(20); k(r1.a(i, 0)); if (i2 >= 0) { k(i2); } else { f(i2); } } @Override // com.fyber.inneractive.sdk.protobuf.l public final void b(int i, long j) throws IOException { l(20); k(r1.a(i, 0)); f(j); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void a(String str, int i) throws IOException { i(r1.a(i, 2)); b(str); } public final void b(String str) throws IOException { try { int length = str.length() * 3; int e = l.e(length); int i = e + length; int i2 = this.e; if (i > i2) { byte[] bArr = new byte[length]; int a = q1.a.a(str, bArr, 0, length); i(a); b(bArr, 0, a); return; } if (i > i2 - this.f) { a(); } int e2 = l.e(str.length()); int i3 = this.f; try { if (e2 == e) { int i4 = i3 + e2; this.f = i4; int a2 = q1.a.a(str, this.d, i4, this.e - i4); this.f = i3; k((a2 - i3) - e2); this.f = a2; } else { int a3 = q1.a(str); k(a3); this.f = q1.a.a(str, this.d, this.f, a3); } } catch (q1.d e3) { this.f = i3; throw e3; } catch (ArrayIndexOutOfBoundsException e4) { throw new c(e4); } } catch (q1.d e5) { a(str, e5); } } @Override // com.fyber.inneractive.sdk.protobuf.l public final void c(long j) throws IOException { l(8); e(j); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void a(int i, long j) throws IOException { l(18); k(r1.a(i, 1)); e(j); } @Override // com.fyber.inneractive.sdk.protobuf.l public final void a(int i, boolean z) throws IOException { l(11); k(r1.a(i, 0)); byte b = z ? (byte) 1 : (byte) 0; byte[] bArr = this.d; int i2 = this.f; this.f = i2 + 1; bArr[i2] = b; } @Override // com.fyber.inneractive.sdk.protobuf.l public final void a(byte b) throws IOException { if (this.f == this.e) { a(); } byte[] bArr = this.d; int i = this.f; this.f = i + 1; bArr[i] = b; } @Override // com.fyber.inneractive.sdk.protobuf.h public final void a(byte[] bArr, int i, int i2) throws IOException { b(bArr, i, i2); } public final void a() throws IOException { this.g.write(this.d, 0, this.f); this.f = 0; } public final void b(byte[] bArr, int i, int i2) throws IOException { int i3 = this.e; int i4 = this.f; int i5 = i3 - i4; if (i5 >= i2) { System.arraycopy(bArr, i, this.d, i4, i2); this.f += i2; return; } System.arraycopy(bArr, i, this.d, i4, i5); int i6 = i + i5; int i7 = i2 - i5; this.f = this.e; a(); if (i7 <= this.e) { System.arraycopy(bArr, i6, this.d, 0, i7); this.f = i7; } else { this.g.write(bArr, i6, i7); } } } public /* synthetic */ l(int i) { this(); } public static int a(int i, int i2) { return e(i2) + d(i); } public static int a(long j) { int i; if (((-128) & j) == 0) { return 1; } if (j < 0) { return 10; } if (((-34359738368L) & j) != 0) { j >>>= 28; i = 6; } else { i = 2; } if (((-2097152) & j) != 0) { i += 2; j >>>= 14; } return (j & (-16384)) != 0 ? i + 1 : i; } public static int b(int i) { return d(i) + 8; } public static long b(long j) { return (j >> 63) ^ (j << 1); } public static int c(int i) { if (i >= 0) { return e(i); } return 10; } public static int d(int i) { return e(r1.a(i, 0)); } public static int e(int i) { if ((i & WorkInfo.STOP_REASON_FOREGROUND_SERVICE_TIMEOUT) == 0) { return 1; } if ((i & (-16384)) == 0) { return 2; } if (((-2097152) & i) == 0) { return 3; } return (i & (-268435456)) == 0 ? 4 : 5; } public static int f(int i) { return (i >> 31) ^ (i << 1); } public abstract void a(byte b2) throws IOException; public abstract void a(int i, long j) throws IOException; public abstract void a(int i, o0 o0Var) throws IOException; public abstract void a(int i, o0 o0Var, d1 d1Var) throws IOException; public abstract void a(int i, boolean z) throws IOException; public abstract void a(String str, int i) throws IOException; public abstract void b(int i, int i2) throws IOException; public abstract void b(int i, long j) throws IOException; public abstract void b(int i, i iVar) throws IOException; public abstract void c(int i, int i2) throws IOException; public abstract void c(int i, i iVar) throws IOException; public abstract void c(long j) throws IOException; public abstract void d(int i, int i2) throws IOException; public abstract void d(long j) throws IOException; public abstract void e(int i, int i2) throws IOException; public abstract void g(int i) throws IOException; public abstract void h(int i) throws IOException; public abstract void i(int i) throws IOException; public l() { } public static int a(int i) { return d(i) + 4; } public static int a(int i, i iVar) { int d2 = d(i); int size = iVar.size(); return e(size) + size + d2; } public static int a(String str) { int length; try { length = q1.a(str); } catch (q1.d unused) { length = str.getBytes(y.a).length; } return e(length) + length; } public final void a(String str, q1.d dVar) throws IOException { b.log(Level.WARNING, "Converting ill-formed UTF-16. Your Protocol Buffer will not round trip correctly!", (Throwable) dVar); byte[] bytes = str.getBytes(y.a); try { i(bytes.length); a(bytes, 0, bytes.length); } catch (c e) { throw e; } catch (IndexOutOfBoundsException e2) { throw new c(e2); } } }