package globals

var (
	OTAProgress  uint8     = 0
	CurOTAStatus OTAStatus = OTAStatus(255)

	ShowUpdateVersionInfo bool = false
	IsAfterOtaFirstBoot   bool = false

	IsBackUpSystem bool = false

	LastOtaSource OtaSource = OtaSource_Unknow
)

type OTAStatus uint8

const (
	OTAStatus_normal OTAStatus = iota
	OTAStatus_downloading
	OTAStatus_downloaded
	OTAStatus_downloaded_fail
	OTAStatus_begin
	OTAStatus_success
	OTAStatus_fail
)

type OtaSource uint8

const (
	OtaSource_Unknow OtaSource = iota
	OtaSource_APP
	OtaSource_Force
	OtaSource_NightSilent

	OtaSource_Force_Vui
	OtaSource_NightSilent_Vui
)

func (this *OtaSource) IsSilent() bool {
	switch *this {
	case OtaSource_Force, OtaSource_NightSilent:
		return true
	case OtaSource_APP, OtaSource_Force_Vui, OtaSource_NightSilent_Vui:
		return false
	}

	return true
}

func (this *OtaSource) StartUpToastAfterVui() bool {
	if *this == OtaSource_APP {
		return true
	} else {
		return false
	}
}

type VuiVersionType int

const (
	VuiVersionType_Url VuiVersionType = 1
	VuiVersionType_Tts VuiVersionType = 2
	VuiVersionType_Nil VuiVersionType = 3
)

type VersionInfo struct {
	Id             int    `json:"id"`
	Version        string `json:"version"`
	Size           uint32 `json:"size"`
	VersionMessage string `json:"versionMessage"`
	DownloadUrl    string `json:"downloadUrl"`
	Md5            string `json:"md5"`
	CreateTime     int64  `json:"createTime"`
	Enable         int    `json:"enable"`
	IsForce        int    `json:"isForce"`
	OsType         int    `json:"osType"`

	VuiAfterContent string         `json:"vuiAfterContent"`
	VuiAfterType    VuiVersionType `json:"vuiAfterType"`

	VuiBeforeContent string         `json:"vuiBeforeContent"`
	VuiBeforeType    VuiVersionType `json:"vuiBeforeType"`
}
