package androidx.versionedparcelable;

import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.SparseIntArray;

/* loaded from: classes.dex */
class b extends a {

    /* renamed from: d, reason: collision with root package name */
    private final SparseIntArray f5716d;

    /* renamed from: e, reason: collision with root package name */
    private final Parcel f5717e;

    /* renamed from: f, reason: collision with root package name */
    private final int f5718f;

    /* renamed from: g, reason: collision with root package name */
    private final int f5719g;

    /* renamed from: h, reason: collision with root package name */
    private final String f5720h;

    /* renamed from: i, reason: collision with root package name */
    private int f5721i;

    /* renamed from: j, reason: collision with root package name */
    private int f5722j;

    /* renamed from: k, reason: collision with root package name */
    private int f5723k;

    /* JADX INFO: Access modifiers changed from: package-private */
    public b(Parcel parcel) {
        this(parcel, parcel.dataPosition(), parcel.dataSize(), "", new androidx.collection.a(), new androidx.collection.a(), new androidx.collection.a());
    }

    @Override // androidx.versionedparcelable.a
    public IBinder A() {
        return this.f5717e.readStrongBinder();
    }

    @Override // androidx.versionedparcelable.a
    public void D(int i10) {
        a();
        this.f5721i = i10;
        this.f5716d.put(i10, this.f5717e.dataPosition());
        N(0);
        N(i10);
    }

    @Override // androidx.versionedparcelable.a
    public void H(boolean z10) {
        this.f5717e.writeInt(z10 ? 1 : 0);
    }

    @Override // androidx.versionedparcelable.a
    public void J(byte[] bArr) {
        if (bArr == null) {
            this.f5717e.writeInt(-1);
        } else {
            this.f5717e.writeInt(bArr.length);
            this.f5717e.writeByteArray(bArr);
        }
    }

    @Override // androidx.versionedparcelable.a
    protected void L(CharSequence charSequence) {
        TextUtils.writeToParcel(charSequence, this.f5717e, 0);
    }

    @Override // androidx.versionedparcelable.a
    public void N(int i10) {
        this.f5717e.writeInt(i10);
    }

    @Override // androidx.versionedparcelable.a
    public void P(long j10) {
        this.f5717e.writeLong(j10);
    }

    @Override // androidx.versionedparcelable.a
    public void R(Parcelable parcelable) {
        this.f5717e.writeParcelable(parcelable, 0);
    }

    @Override // androidx.versionedparcelable.a
    public void U(String str) {
        this.f5717e.writeString(str);
    }

    @Override // androidx.versionedparcelable.a
    public void W(IBinder iBinder) {
        this.f5717e.writeStrongBinder(iBinder);
    }

    @Override // androidx.versionedparcelable.a
    public void a() {
        int i10 = this.f5721i;
        if (i10 >= 0) {
            int i11 = this.f5716d.get(i10);
            int dataPosition = this.f5717e.dataPosition();
            this.f5717e.setDataPosition(i11);
            this.f5717e.writeInt(dataPosition - i11);
            this.f5717e.setDataPosition(dataPosition);
        }
    }

    @Override // androidx.versionedparcelable.a
    protected a b() {
        Parcel parcel = this.f5717e;
        int dataPosition = parcel.dataPosition();
        int i10 = this.f5722j;
        if (i10 == this.f5718f) {
            i10 = this.f5719g;
        }
        return new b(parcel, dataPosition, i10, this.f5720h + "  ", this.f5712a, this.f5713b, this.f5714c);
    }

    @Override // androidx.versionedparcelable.a
    public boolean j() {
        return this.f5717e.readInt() != 0;
    }

    @Override // androidx.versionedparcelable.a
    public byte[] l() {
        int readInt = this.f5717e.readInt();
        if (readInt < 0) {
            return null;
        }
        byte[] bArr = new byte[readInt];
        this.f5717e.readByteArray(bArr);
        return bArr;
    }

    @Override // androidx.versionedparcelable.a
    protected CharSequence n() {
        return (CharSequence) TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(this.f5717e);
    }

    @Override // androidx.versionedparcelable.a
    public boolean p(int i10) {
        while (this.f5722j < this.f5719g) {
            int i11 = this.f5723k;
            if (i11 == i10) {
                return true;
            }
            if (String.valueOf(i11).compareTo(String.valueOf(i10)) > 0) {
                return false;
            }
            this.f5717e.setDataPosition(this.f5722j);
            int readInt = this.f5717e.readInt();
            this.f5723k = this.f5717e.readInt();
            this.f5722j += readInt;
        }
        return this.f5723k == i10;
    }

    @Override // androidx.versionedparcelable.a
    public int r() {
        return this.f5717e.readInt();
    }

    @Override // androidx.versionedparcelable.a
    public long t() {
        return this.f5717e.readLong();
    }

    @Override // androidx.versionedparcelable.a
    public Parcelable v() {
        return this.f5717e.readParcelable(getClass().getClassLoader());
    }

    @Override // androidx.versionedparcelable.a
    public String y() {
        return this.f5717e.readString();
    }

    private b(Parcel parcel, int i10, int i11, String str, androidx.collection.a aVar, androidx.collection.a aVar2, androidx.collection.a aVar3) {
        super(aVar, aVar2, aVar3);
        this.f5716d = new SparseIntArray();
        this.f5721i = -1;
        this.f5723k = -1;
        this.f5717e = parcel;
        this.f5718f = i10;
        this.f5719g = i11;
        this.f5722j = i10;
        this.f5720h = str;
    }
}
