package g.i.a.c.q;

import android.os.Parcel;
import android.os.Parcelable;
import java.util.Locale;

/* JADX INFO: loaded from: classes.dex */
public class g implements Parcelable {
    public static final Parcelable.Creator<g> CREATOR = new a();
    public long A;
    public k B;
    public boolean C;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public int f5710f;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public int f5711m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public int f5712n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public int f5713o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public int f5714p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public int f5715q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public int f5716r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public int f5717s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public int f5718t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public int f5719u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public int f5720v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public int f5721w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public long f5722x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public long f5723y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public long f5724z;

    public static class a implements Parcelable.Creator<g> {
        @Override // android.os.Parcelable.Creator
        public g createFromParcel(Parcel parcel) {
            return new g(parcel);
        }

        @Override // android.os.Parcelable.Creator
        public g[] newArray(int i2) {
            return new g[i2];
        }
    }

    public g() {
        this.f5712n = 0;
        this.f5713o = 0;
        this.f5714p = 0;
        this.f5715q = 0;
        this.f5716r = 0;
        this.f5713o = 0;
        this.f5714p = 0;
        this.f5715q = 0;
        this.f5716r = 0;
        this.f5711m = 0;
        this.C = false;
    }

    public g(Parcel parcel) {
        this.f5712n = 0;
        this.f5713o = 0;
        this.f5714p = 0;
        this.f5715q = 0;
        this.f5716r = 0;
        this.f5710f = parcel.readInt();
        this.f5711m = parcel.readInt();
        this.f5712n = parcel.readInt();
        this.f5713o = parcel.readInt();
        this.f5714p = parcel.readInt();
        this.f5715q = parcel.readInt();
        this.f5716r = parcel.readInt();
        this.f5718t = parcel.readInt();
        this.f5719u = parcel.readInt();
        this.f5720v = parcel.readInt();
        this.f5721w = parcel.readInt();
        this.f5722x = parcel.readLong();
        this.f5723y = parcel.readLong();
        this.f5724z = parcel.readLong();
        this.A = parcel.readLong();
        this.B = (k) parcel.readParcelable(k.class.getClassLoader());
        this.C = parcel.readByte() != 0;
    }

    public void a(int i2) {
        r(this.f5711m + i2);
        this.f5720v += i2;
    }

    public void c(int i2) {
        this.f5710f += i2;
    }

    public int d() {
        return this.f5710f - this.f5711m;
    }

    @Override // android.os.Parcelable
    public int describeContents() {
        return 0;
    }

    public int f() {
        int i2 = this.f5713o;
        if (i2 == 0) {
            return 0;
        }
        double d2 = 100.0f / i2;
        int i3 = this.f5710f;
        double d3 = ((double) this.f5714p) + (i3 == 0 ? 0.0d : (((double) this.f5711m) * 1.0d) / ((double) i3));
        if (d3 < i2) {
            return (int) (d3 * d2);
        }
        return 100;
    }

    public void n(int i2, int i3, int i4, int i5, boolean z2) {
        this.f5717s = i2;
        this.f5718t = i3;
        this.f5719u = i4;
        this.f5710f = i5;
        this.C = z2;
        r(0);
    }

    public boolean o() {
        return this.f5711m >= this.f5710f;
    }

    public boolean p() {
        return this.f5716r >= this.f5713o;
    }

    public void q() {
        this.f5722x = System.currentTimeMillis();
        this.f5711m = this.f5710f;
        int i2 = this.f5714p;
        this.f5715q = i2;
        this.f5716r = i2 + 1;
        g.h.a.i.U3(toString());
    }

    public void r(int i2) {
        this.f5711m = i2;
        this.f5712n = (int) ((i2 * 100.0f) / this.f5710f);
        long jCurrentTimeMillis = System.currentTimeMillis();
        this.f5723y = jCurrentTimeMillis;
        if (this.C) {
            long jMax = Math.max(0L, jCurrentTimeMillis - this.f5722x);
            float f2 = jMax > 0 ? (this.f5711m * 1000.0f) / jMax : 0.0f;
            long jCurrentTimeMillis2 = System.currentTimeMillis();
            long j2 = this.f5711m;
            long j3 = j2 - this.A;
            long j4 = jCurrentTimeMillis2 - this.f5724z;
            float f3 = j4 > 0 ? (j3 * 1000.0f) / j4 : 0.0f;
            this.f5724z = jCurrentTimeMillis2;
            this.A = j2;
            k kVar = this.B;
            if (kVar != null) {
                kVar.f5732n = jMax;
                kVar.f5733o = f2;
                kVar.f5734p = f3;
            }
        }
    }

    public void s() {
        long jCurrentTimeMillis = System.currentTimeMillis();
        this.f5722x = jCurrentTimeMillis;
        this.f5723y = jCurrentTimeMillis;
        this.f5724z = jCurrentTimeMillis;
        this.A = 0L;
        this.B = this.C ? new k(this.f5710f, this.f5711m) : null;
        g.h.a.i.U3(toString());
    }

    public String toString() {
        StringBuilder sb = new StringBuilder();
        Locale locale = Locale.US;
        sb.append(String.format(locale, "image: %d/%d", Integer.valueOf(this.f5714p + 1), Integer.valueOf(this.f5713o)));
        sb.append(String.format(locale, "\t{binId=0x%04X, imageId=0x%04X, version=0x%04X}", Integer.valueOf(this.f5717s), Integer.valueOf(this.f5718t), Integer.valueOf(this.f5719u)));
        sb.append(String.format(locale, "\tprogress: %d%%(%d/%d)--%d%%", Integer.valueOf(this.f5712n), Integer.valueOf(this.f5711m), Integer.valueOf(this.f5710f), Integer.valueOf(f())));
        return sb.toString();
    }

    @Override // android.os.Parcelable
    public void writeToParcel(Parcel parcel, int i2) {
        parcel.writeInt(this.f5710f);
        parcel.writeInt(this.f5711m);
        parcel.writeInt(this.f5712n);
        parcel.writeInt(this.f5713o);
        parcel.writeInt(this.f5714p);
        parcel.writeInt(this.f5715q);
        parcel.writeInt(this.f5716r);
        parcel.writeInt(this.f5718t);
        parcel.writeInt(this.f5719u);
        parcel.writeInt(this.f5720v);
        parcel.writeInt(this.f5721w);
        parcel.writeLong(this.f5722x);
        parcel.writeLong(this.f5723y);
        parcel.writeLong(this.f5724z);
        parcel.writeLong(this.A);
        parcel.writeParcelable(this.B, i2);
        parcel.writeByte(this.C ? (byte) 1 : (byte) 0);
    }
}
