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

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

/**
 * Display power status from CEC query
 */
public class PowerStatus implements Parcelable {
    public static final Creator<PowerStatus> CREATOR = new Creator<>() {
        @Override
        public PowerStatus createFromParcel(Parcel in) {
            return new PowerStatus(in);
        }

        @Override
        public PowerStatus[] newArray(int size) {
            return new PowerStatus[size];
        }
    };
    public boolean displayOn;           // Display power state (from CEC query)
    public String state;                // "ON", "STANDBY", "TRANSITIONING_ON", "TRANSITIONING_OFF", "UNKNOWN"
    public boolean canControl;          // Can control via CEC
    public long lastUpdatedMs;          // Last query timestamp (epoch millis)

    public PowerStatus() {
    }

    protected PowerStatus(Parcel in) {
        displayOn = in.readByte() != 0;
        state = in.readString();
        canControl = in.readByte() != 0;
        lastUpdatedMs = in.readLong();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeByte((byte) (displayOn ? 1 : 0));
        dest.writeString(state);
        dest.writeByte((byte) (canControl ? 1 : 0));
        dest.writeLong(lastUpdatedMs);
    }

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