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

import java.io.IOException;

/* JADX INFO: loaded from: classes2.dex */
public abstract class i implements z0 {
    protected int zza;

    @Override // com.google.android.gms.internal.pal.z0
    public final zzaby b() {
        try {
            d0 d0Var = (d0) this;
            int iH = d0Var.h();
            zzaby zzabyVar = zzaby.f21409a;
            byte[] bArr = new byte[iH];
            s sVar = new s(bArr, iH);
            j1 j1VarA = g1.f20921c.a(d0Var.getClass());
            t tVar = sVar.f21190j;
            if (tVar == null) {
                tVar = new t(sVar);
            }
            j1VarA.a(d0Var, tVar);
            if (iH - sVar.f21193m == 0) {
                return new zzabv(bArr);
            }
            throw new IllegalStateException("Did not write as much data as expected.");
        } catch (IOException e10) {
            throw new RuntimeException(com.google.android.gms.measurement.internal.u1.k("Serializing ", getClass().getName(), " to a ByteString threw an IOException (should never happen)."), e10);
        }
    }

    @Override // com.google.android.gms.internal.pal.z0
    public final byte[] c() {
        try {
            d0 d0Var = (d0) this;
            int iH = d0Var.h();
            byte[] bArr = new byte[iH];
            s sVar = new s(bArr, iH);
            j1 j1VarA = g1.f20921c.a(d0Var.getClass());
            t tVar = sVar.f21190j;
            if (tVar == null) {
                tVar = new t(sVar);
            }
            j1VarA.a(d0Var, tVar);
            if (iH - sVar.f21193m == 0) {
                return bArr;
            }
            throw new IllegalStateException("Did not write as much data as expected.");
        } catch (IOException e10) {
            throw new RuntimeException(com.google.android.gms.measurement.internal.u1.k("Serializing ", getClass().getName(), " to a byte array threw an IOException (should never happen)."), e10);
        }
    }
}
