package net.gotev.uploadservice;

import android.os.Parcel;
import android.os.Parcelable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/* loaded from: classes.dex */
public class UploadInfo implements Parcelable {
    public static final Parcelable.Creator<UploadInfo> CREATOR = new Parcelable.Creator<UploadInfo>() { // from class: net.gotev.uploadservice.UploadInfo.1
        @Override // android.os.Parcelable.Creator
        public UploadInfo createFromParcel(Parcel parcel) {
            return new UploadInfo(parcel);
        }

        @Override // android.os.Parcelable.Creator
        public UploadInfo[] newArray(int i) {
            return new UploadInfo[i];
        }
    };
    private long currentTime;
    private int numberOfRetries;
    private long startTime;
    private ArrayList<String> successfullyUploadedFiles;
    private long totalBytes;
    private int totalFiles;
    private String uploadId;
    private long uploadedBytes;

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

    /* JADX INFO: Access modifiers changed from: protected */
    public UploadInfo(String str) {
        this.successfullyUploadedFiles = new ArrayList<>();
        this.uploadId = str;
        this.startTime = 0L;
        this.currentTime = 0L;
        this.uploadedBytes = 0L;
        this.totalBytes = 0L;
        this.numberOfRetries = 0;
        this.totalFiles = 0;
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public UploadInfo(String str, long j, long j2, long j3, int i, List<String> list, int i2) {
        this.successfullyUploadedFiles = new ArrayList<>();
        this.uploadId = str;
        this.startTime = j;
        this.currentTime = new Date().getTime();
        this.uploadedBytes = j2;
        this.totalBytes = j3;
        this.numberOfRetries = i;
        this.totalFiles = i2;
        if (list == null || list.isEmpty()) {
            return;
        }
        this.successfullyUploadedFiles.addAll(list);
    }

    @Override // android.os.Parcelable
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeString(this.uploadId);
        parcel.writeLong(this.startTime);
        parcel.writeLong(this.currentTime);
        parcel.writeLong(this.uploadedBytes);
        parcel.writeLong(this.totalBytes);
        parcel.writeInt(this.numberOfRetries);
        parcel.writeInt(this.totalFiles);
        parcel.writeStringList(this.successfullyUploadedFiles);
    }

    private UploadInfo(Parcel parcel) {
        this.successfullyUploadedFiles = new ArrayList<>();
        this.uploadId = parcel.readString();
        this.startTime = parcel.readLong();
        this.currentTime = parcel.readLong();
        this.uploadedBytes = parcel.readLong();
        this.totalBytes = parcel.readLong();
        this.numberOfRetries = parcel.readInt();
        this.totalFiles = parcel.readInt();
        parcel.readStringList(this.successfullyUploadedFiles);
    }

    public String getUploadId() {
        return this.uploadId;
    }

    public long getStartTime() {
        return this.startTime;
    }

    public long getElapsedTime() {
        return this.currentTime - this.startTime;
    }

    public String getElapsedTimeString() {
        int elapsedTime = (int) (getElapsedTime() / 1000);
        if (elapsedTime == 0) {
            return "0s";
        }
        int i = elapsedTime / 60;
        int i2 = elapsedTime - (i * 60);
        if (i == 0) {
            return i2 + "s";
        }
        return i + "m " + i2 + "s";
    }

    public double getUploadRate() {
        long elapsedTime = getElapsedTime();
        if (elapsedTime < 1000) {
            return 0.0d;
        }
        double d = this.uploadedBytes;
        Double.isNaN(d);
        double d2 = elapsedTime / 1000;
        Double.isNaN(d2);
        return ((d / 1024.0d) * 8.0d) / d2;
    }

    public String getUploadRateString() {
        double uploadRate = getUploadRate();
        if (uploadRate < 1.0d) {
            return ((int) (uploadRate * 1000.0d)) + " bit/s";
        } else if (uploadRate >= 1024.0d) {
            return ((int) (uploadRate / 1024.0d)) + " Mbit/s";
        } else {
            return ((int) uploadRate) + " Kbit/s";
        }
    }

    public ArrayList<String> getSuccessfullyUploadedFiles() {
        return this.successfullyUploadedFiles;
    }

    public long getUploadedBytes() {
        return this.uploadedBytes;
    }

    public long getTotalBytes() {
        return this.totalBytes;
    }

    public int getProgressPercent() {
        long j = this.totalBytes;
        if (j == 0) {
            return 0;
        }
        return (int) ((this.uploadedBytes * 100) / j);
    }

    public int getNumberOfRetries() {
        return this.numberOfRetries;
    }

    public int getTotalFiles() {
        return this.totalFiles;
    }
}
