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

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

/**
 * HDMI data containing connection and CEC information
 */
public class HdmiData implements Parcelable {
    public static final Creator<HdmiData> CREATOR = new Creator<>() {
        @Override
        public HdmiData createFromParcel(Parcel in) {
            return new HdmiData(in);
        }

        @Override
        public HdmiData[] newArray(int size) {
            return new HdmiData[size];
        }
    };
    public boolean connected;           // HDMI cable connected (based on EDID)
    public String edid;                 // Raw EDID hex string (all zeros if not connected)
    public String monitorInfo;          // Parsed monitor info (e.g., "DELL SP2418H-1920x1080")
    public boolean cecEnabled;          // CEC is enabled
    public boolean activeSource;        // Device is active source
    public DisplayInfo display;         // Parsed display info (null if not connected)
    public PowerStatus power;           // Power status (from CEC query)
    public AudioStatus audio;           // Audio status (from CEC query)

    public HdmiData() {
    }

    protected HdmiData(Parcel in) {
        connected = in.readByte() != 0;
        edid = in.readString();
        monitorInfo = in.readString();
        cecEnabled = in.readByte() != 0;
        activeSource = in.readByte() != 0;
        display = in.readParcelable(DisplayInfo.class.getClassLoader());
        power = in.readParcelable(PowerStatus.class.getClassLoader());
        audio = in.readParcelable(AudioStatus.class.getClassLoader());
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeByte((byte) (connected ? 1 : 0));
        dest.writeString(edid);
        dest.writeString(monitorInfo);
        dest.writeByte((byte) (cecEnabled ? 1 : 0));
        dest.writeByte((byte) (activeSource ? 1 : 0));
        dest.writeParcelable(display, flags);
        dest.writeParcelable(power, flags);
        dest.writeParcelable(audio, flags);
    }

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