package com.amazon.ads.ema.api.model;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Resource data containing memory, storage, temperature, and CPU information
 */
public class ResourceData implements Parcelable {
    public static final Creator<ResourceData> CREATOR = new Creator<>() {
        @Override
        public ResourceData createFromParcel(Parcel in) {
            return new ResourceData(in);
        }

        @Override
        public ResourceData[] newArray(int size) {
            return new ResourceData[size];
        }
    };
    public MemoryInfo memory;
    public StorageInfo storage;
    public TemperatureInfo temperature;
    public CpuInfo cpu;
    public long elapsedMs;              // Device uptime in milliseconds

    public ResourceData() {
    }

    protected ResourceData(Parcel in) {
        memory = in.readParcelable(MemoryInfo.class.getClassLoader());
        storage = in.readParcelable(StorageInfo.class.getClassLoader());
        temperature = in.readParcelable(TemperatureInfo.class.getClassLoader());
        cpu = in.readParcelable(CpuInfo.class.getClassLoader());
        elapsedMs = in.readLong();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeParcelable(memory, flags);
        dest.writeParcelable(storage, flags);
        dest.writeParcelable(temperature, flags);
        dest.writeParcelable(cpu, flags);
        dest.writeLong(elapsedMs);
    }

    @Override
    public int describeContents() {
        return 0;
    }
}
