|
|
@@ -837,31 +837,56 @@ namespace Task
|
|
|
//pack_status 0-准备中 1-已就绪
|
|
|
int status = rootRet["data"]["pack_status"].asInt();
|
|
|
if(status == 1){
|
|
|
- if(!ParamCheck(rootRet)){
|
|
|
- LogWarn(Severity_Middle, Error_Exception, ERR_TASK_QUERY_CONTINUE_NEW_TASK_ERR,CSimpleStringA::Format("QueryNewContinueTask paramCheck is fail, check out server exception ,url=%s",qTempReq.m_url.c_str()).GetData());
|
|
|
- return 0;//查询失败 升级任务参数效验失败,告警码不同
|
|
|
- }else{
|
|
|
- m_fsm->m_currentTask.upgradeTaskId = rootRet["data"]["task_id"].asString().c_str();
|
|
|
- m_fsm->m_currentTask.pack_name = rootRet["data"]["pack_name"].asString().c_str();
|
|
|
- m_fsm->m_currentTask.file_path = rootRet["data"]["file_path"].asString().c_str();
|
|
|
- m_fsm->m_currentTask.download_url = rootRet["data"]["download_url"].asString().c_str();
|
|
|
- m_fsm->m_currentTask.pack_hash = rootRet["data"]["pack_hash"].asString().c_str();
|
|
|
- m_fsm->m_currentTask.pack_length = (long)rootRet["data"]["pack_length"].asInt();
|
|
|
- m_fsm->m_currentTask.pack_version = rootRet["data"]["pack_version"].asString().c_str();
|
|
|
- m_fsm->m_currentTask.reboot_type = rootRet["data"]["reboot_type"].asInt();
|
|
|
- m_fsm->m_currentTask.stop_media_play = rootRet["data"]["stop_media_play"].asBool();
|
|
|
-
|
|
|
- //解析step json
|
|
|
- if(!ParseInstallStep(rootRet)){
|
|
|
- m_fsm->ClearInstallStep();
|
|
|
- LogWarn(Severity_Middle, Error_Exception, ERR_TASK_QUERY_CONTINUE_NEW_TASK_ERR,CSimpleStringA::Format("QueryNewContinueTask ParseInstallStep is fail, check out server exception ,url=%s",qTempReq.m_url.c_str()).GetData());
|
|
|
- return 0;//查询失败 解析安装步骤失败,告警码不同
|
|
|
+ m_fsm->m_currentTask.task_type = rootRet["data"]["task_type"].asString().c_str();
|
|
|
+ if (m_fsm->m_currentTask.task_type.Compare("U") == 0) {
|
|
|
+ //升级任务
|
|
|
+ if (!ParamCheck(rootRet)) {
|
|
|
+ LogWarn(Severity_Middle, Error_Exception, ERR_TASK_QUERY_CONTINUE_NEW_TASK_ERR, CSimpleStringA::Format("QueryNewContinueTask paramCheck is fail, check out server exception ,url=%s", qTempReq.m_url.c_str()).GetData());
|
|
|
+ return 0;//查询失败 升级任务参数效验失败,告警码不同
|
|
|
}
|
|
|
-
|
|
|
- m_fsm->m_currentTask.createTaskVersion = m_fsm->m_currentVersion.ToString();//新策略,查询到包后,用当前版本值赋值
|
|
|
- DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("QueryNewContinueTaskImpl")("new task id =%s",m_fsm->m_currentTask.upgradeTaskId.GetData());
|
|
|
- return 1;//查询成功
|
|
|
- }
|
|
|
+ else {
|
|
|
+ m_fsm->m_currentTask.upgradeTaskId = rootRet["data"]["task_id"].asString().c_str();
|
|
|
+ m_fsm->m_currentTask.pack_name = rootRet["data"]["pack_name"].asString().c_str();
|
|
|
+ m_fsm->m_currentTask.file_path = rootRet["data"]["file_path"].asString().c_str();
|
|
|
+ m_fsm->m_currentTask.download_url = rootRet["data"]["download_url"].asString().c_str();
|
|
|
+ m_fsm->m_currentTask.pack_hash = rootRet["data"]["pack_hash"].asString().c_str();
|
|
|
+ m_fsm->m_currentTask.pack_length = (long)rootRet["data"]["pack_length"].asInt();
|
|
|
+ m_fsm->m_currentTask.pack_version = rootRet["data"]["pack_version"].asString().c_str();
|
|
|
+ m_fsm->m_currentTask.reboot_type = rootRet["data"]["reboot_type"].asInt();
|
|
|
+ m_fsm->m_currentTask.stop_media_play = rootRet["data"]["stop_media_play"].asBool();
|
|
|
+
|
|
|
+ //解析step json
|
|
|
+ if (!ParseInstallStep(rootRet)) {
|
|
|
+ m_fsm->ClearInstallStep();
|
|
|
+ LogWarn(Severity_Middle, Error_Exception, ERR_TASK_QUERY_CONTINUE_NEW_TASK_ERR, CSimpleStringA::Format("QueryNewContinueTask ParseInstallStep is fail, check out server exception ,url=%s", qTempReq.m_url.c_str()).GetData());
|
|
|
+ return 0;//查询失败 解析安装步骤失败,告警码不同
|
|
|
+ }
|
|
|
+
|
|
|
+ m_fsm->m_currentTask.createTaskVersion = m_fsm->m_currentVersion.ToString();//新策略,查询到包后,用当前版本值赋值
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("QueryNewContinueTaskImpl")("new task id =%s", m_fsm->m_currentTask.upgradeTaskId.GetData());
|
|
|
+ return 1;//查询成功
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(m_fsm->m_currentTask.task_type.Compare("R") == 0){
|
|
|
+ //回退任务
|
|
|
+ if (!rollbackParamCheck(rootRet)) {
|
|
|
+ LogWarn(Severity_Middle, Error_Exception, ERR_TASK_QUERY_CONTINUE_NEW_TASK_ERR, CSimpleStringA::Format("QueryNewContinueTask paramCheck is fail, check out server exception ,url=%s", qTempReq.m_url.c_str()).GetData());
|
|
|
+ return 0;//查询失败 升级任务参数效验失败,告警码不同
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ m_fsm->m_currentTask.upgradeTaskId = rootRet["data"]["task_id"].asString().c_str();
|
|
|
+ m_fsm->m_currentTask.pack_version = rootRet["data"]["pack_version"].asString().c_str();
|
|
|
+ m_fsm->m_currentTask.reboot_type = rootRet["data"]["reboot_type"].asInt();
|
|
|
+ m_fsm->m_currentTask.stop_media_play = rootRet["data"]["stop_media_play"].asBool();
|
|
|
+ m_fsm->m_currentTask.createTaskVersion = m_fsm->m_currentVersion.ToString();
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("QueryNewContinueTaskImpl")("new task id =%s", m_fsm->m_currentTask.upgradeTaskId.GetData());
|
|
|
+ return 1;//查询成功
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ LogWarn(Severity_Middle, Error_Exception, ERR_TASK_QUERY_CONTINUE_NEW_TASK_ERR, CSimpleStringA::Format("QueryNewContinueTask ParseInstallStep is fail, task_type is null ,url=%s", qTempReq.m_url.c_str()).GetData());
|
|
|
+ return 0;//查询失败 解析安装步骤失败,告警码不同
|
|
|
+ }
|
|
|
}else{
|
|
|
//任务未准备好
|
|
|
DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("QueryNewContinueTaskImpl")("QueryNewContinueTask query pack is not create ,please next query,status=%d",status);
|
|
|
@@ -938,6 +963,28 @@ namespace Task
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ bool rollbackParamCheck(Json::Value rootRet) {
|
|
|
+ CSimpleStringA upgradeTaskIdStr = rootRet["data"]["task_id"].asString().c_str();
|
|
|
+ if(upgradeTaskIdStr.IsNullOrEmpty()){
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("ParamCheck")("QueryNewContinueTask paramCheck [task_id] is null");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ int rebootTypeInt = rootRet["data"]["reboot_type"].asInt();
|
|
|
+ if(rebootTypeInt!=1 && rebootTypeInt!=2){
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("ParamCheck")("QueryNewContinueTask paramCheck [reboot_type] is invalid ,reboot_type=%d",rebootTypeInt);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ CSimpleStringA packVersionStr = rootRet["data"]["pack_version"].asString().c_str();
|
|
|
+ if (packVersionStr.IsNullOrEmpty()) {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("ParamCheck")("QueryNewContinueTask paramCheck [pack_version] is null");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
bool ParseInstallStep(Json::Value rootRet){
|
|
|
//清理以前的遗留的安装步骤
|
|
|
m_fsm->ClearInstallStep();
|
|
|
@@ -1512,7 +1559,23 @@ namespace Task
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-
|
|
|
+ //回退版本检查
|
|
|
+ struct RollBackCheckTask : public ITaskSp {
|
|
|
+ CUpgradeTaskFSM* m_fsm;
|
|
|
+ explicit RollBackCheckTask(CUpgradeTaskFSM* f) : m_fsm(f) {}
|
|
|
+ void Process() {
|
|
|
+ LOG_FUNCTION();
|
|
|
+ //回退版本检查
|
|
|
+ string failReason = "";
|
|
|
+ CSimpleStringA strErrMsg = "";
|
|
|
+ if (m_fsm->RollBackVersionCheck(failReason, strErrMsg) == Error_Succeed) {
|
|
|
+ m_fsm->PostEventFIFO(new CUpgradeTaskFSM::RollBackCheckTaskEvent(true, "", ""));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ m_fsm->PostEventFIFO(new CUpgradeTaskFSM::RollBackCheckTaskEvent(false, strErrMsg, failReason));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
//完成
|
|
|
@@ -3503,6 +3566,9 @@ bool CUpgradeTaskFSM::ClearCurrTaskInfo()
|
|
|
if(SetRunConfigStrValue("upgradeTask","NewVersion","")!=Error_Succeed){
|
|
|
return false;
|
|
|
}
|
|
|
+ if (SetRunConfigStrValue("upgradeTask", "TaskType", "") != Error_Succeed) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
//试着删除可能临时下载的升级包文件
|
|
|
CSimpleStringA strPath;
|
|
|
@@ -3525,6 +3591,7 @@ bool CUpgradeTaskFSM::ClearCurrTaskInfo()
|
|
|
m_currentTask.pack_name = "";
|
|
|
m_currentTask.cPendingState = "";
|
|
|
m_currentTask.NewVersion="";
|
|
|
+ m_currentTask.task_type = "";
|
|
|
|
|
|
m_currentTask.pack_version = "";
|
|
|
m_currentTask.stop_media_play =false;
|
|
|
@@ -3601,6 +3668,13 @@ ErrorCodeEnum CUpgradeTaskFSM::LoadPersistTaskInfo()
|
|
|
}
|
|
|
taskInfo.NewVersion = strValue;
|
|
|
|
|
|
+ rc = GetRunConfigStrValue("upgradeTask", "TaskType", strValue);
|
|
|
+ if (rc != Error_Succeed) {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("LoadPersistTaskInfo")("recover upgrade state from run config, read [upgradeTask][TaskType] fail ,err=%d", (int)rc);
|
|
|
+ return rc;
|
|
|
+ }
|
|
|
+ taskInfo.task_type = strValue;
|
|
|
+
|
|
|
//初始化其他变量
|
|
|
//CSimpleStringA pack_version; //升级包指定的版本号
|
|
|
//CSimpleStringA to_copy; //拷贝文件列表
|
|
|
@@ -3625,7 +3699,7 @@ ErrorCodeEnum CUpgradeTaskFSM::LoadPersistTaskInfo()
|
|
|
DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("LoadPersistTaskInfo")("recover upgrade state from run config, PackName=%s",taskInfo.pack_name.GetData());
|
|
|
DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("LoadPersistTaskInfo")("recover upgrade state from run config, PendingState=%s",taskInfo.cPendingState.GetData());
|
|
|
DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("LoadPersistTaskInfo")("recover upgrade state from run config, NewVersion=%s",taskInfo.NewVersion.GetData());
|
|
|
-
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("LoadPersistTaskInfo")("recover upgrade state from run config, TaskType=%s", taskInfo.task_type.GetData());
|
|
|
|
|
|
|
|
|
m_currentTask = taskInfo;
|
|
|
@@ -4145,6 +4219,67 @@ ErrorCodeEnum CUpgradeTaskFSM::NewSM3Folder(CSimpleStringA scanFilter,CSimpleStr
|
|
|
return Error_Succeed;
|
|
|
}
|
|
|
|
|
|
+ErrorCodeEnum CUpgradeTaskFSM::RollBackVersionCheck(string& failReason, CSimpleStringA& strErrMsg)
|
|
|
+{
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("RollBackVersionCheck")("begin RollBackVersionCheck");
|
|
|
+ //获取新版本号
|
|
|
+
|
|
|
+ CSimpleStringA rootVerPath;
|
|
|
+ ErrorCodeEnum rc = m_pEntity->GetFunction()->GetPath("RootVer", rootVerPath);//获取version根路径
|
|
|
+ if (rc != Error_Succeed) {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("RollBackVersionCheck")("RollBackVersionCheck fail , get RootVer path is fail");
|
|
|
+ //LogWarn(Severity_Middle, Error_Exception, ERR_TASK_UPDATE_ACTIVE_FAIL, "UpgradeToNewVersion: get RootVer path is fail");
|
|
|
+ failReason = "C";
|
|
|
+ return Error_Bug;
|
|
|
+ }
|
|
|
+
|
|
|
+ CSimpleStringA strRollbackVersion = m_currentTask.pack_version;
|
|
|
+ CVersion curVer = m_currentVersion;//当前版本号
|
|
|
+ // 指定版本
|
|
|
+ DWORD dwMajor(0), dwMinor(0), dwRevision(0), dwBuild(0);
|
|
|
+ int n = sscanf(strRollbackVersion.GetData(), "%d.%d.%d.%d", &dwMajor, &dwMinor, &dwRevision, &dwBuild);
|
|
|
+ if (n != 4)
|
|
|
+ {
|
|
|
+ strErrMsg = CSimpleStringA::Format("指定回退版本号无效(%s)", strRollbackVersion.GetData());
|
|
|
+ //LogError(Severity_Low, Error_Unexpect, 0, CSimpleStringA::Format("specified software version is invalid: [%s]", strUpgradeVersion.GetData()).GetData());
|
|
|
+ failReason = "C";
|
|
|
+ return Error_Bug;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ m_currentTask.NewVersion = strRollbackVersion;//赋值回退版本号给内存变量
|
|
|
+ }
|
|
|
+
|
|
|
+ if (curVer.ToString() == strRollbackVersion) {
|
|
|
+ //版本号相同,
|
|
|
+ strErrMsg = CSimpleStringA::Format("指定回退版本号与当前版本相同,无效(配置:%s, 当前:%s)", strRollbackVersion.GetData(), curVer.ToString().GetData());
|
|
|
+ failReason = "X";
|
|
|
+ return Error_Unexpect;
|
|
|
+ }
|
|
|
+ else if (dwMajor > curVer.GetMajor()
|
|
|
+ || (dwMajor == curVer.GetMajor() && dwMinor > curVer.GetMinor())
|
|
|
+ || (dwMajor == curVer.GetMajor() && dwMinor == curVer.GetMinor() && dwRevision > curVer.GetRevision())
|
|
|
+ || (dwMajor == curVer.GetMajor() && dwMinor == curVer.GetMinor() && dwRevision == curVer.GetRevision() && dwBuild > curVer.GetBuild())) {
|
|
|
+ //升级版本大于当前版本
|
|
|
+ strErrMsg = CSimpleStringA::Format("指定回退版本号大于当前版本号(配置:%s,当前:%s)", strRollbackVersion.GetData(), curVer.ToString().GetData());
|
|
|
+ failReason = "X";
|
|
|
+ return Error_Unexpect;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //回退版本是否存在
|
|
|
+ CSimpleStringA strRollbackVerPath = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s", rootVerPath.GetData(), m_currentTask.NewVersion.GetData());
|
|
|
+ if (!ExistsDirA(strRollbackVerPath.GetData())) {
|
|
|
+ //LogWarn(Severity_Middle, Error_Exception, ERR_TASK_UPDATE_ACTIVE_FAIL, CSimpleStringA::Format("UpgradeToNewVersion fail, strNewVerPath =%s is not exist,fail", strNewVerPath.GetData()).GetData());
|
|
|
+ strErrMsg = CSimpleStringA::Format("指定回退版本文件夹不存在(配置:%s)", strRollbackVersion.GetData());
|
|
|
+ failReason = "X";
|
|
|
+ return Error_Unexpect;//这种情况有问题,需要清除此任务
|
|
|
+ }
|
|
|
+
|
|
|
+ return Error_Succeed;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
ErrorCodeEnum CUpgradeTaskFSM::SM3FileToStr(CSimpleStringA strFilePath, CSimpleStringA &strSM3,bool isSub)
|
|
|
{
|
|
|
if(strFilePath.IsNullOrEmpty()){
|
|
|
@@ -5122,34 +5257,62 @@ unsigned int CUpgradeTaskFSM::s3_on_event(FSMEvent* event)
|
|
|
if(SetRunConfigStrValue("upgradeTask","NewVersion","")!=Error_Succeed){
|
|
|
break;
|
|
|
}
|
|
|
- if(SetRunConfigStrValue("upgradeTask","PendingState","U")!=Error_Succeed){
|
|
|
+ if (SetRunConfigStrValue("upgradeTask", "CreateTaskVersion", m_currentTask.createTaskVersion.GetData()) != Error_Succeed) {
|
|
|
break;
|
|
|
}
|
|
|
- if(SetRunConfigStrValue("upgradeTask","CreateTaskVersion",m_currentTask.createTaskVersion.GetData())!=Error_Succeed){
|
|
|
+ if (SetRunConfigStrValue("upgradeTask", "UpgradeTaskId", m_currentTask.upgradeTaskId.GetData()) != Error_Succeed) {
|
|
|
break;
|
|
|
}
|
|
|
- if(SetRunConfigStrValue("upgradeTask","PackName",m_currentTask.pack_name.GetData())!=Error_Succeed){
|
|
|
+ if (SetRunConfigStrValue("upgradeTask", "taskType", m_currentTask.task_type.GetData()) != Error_Succeed) {
|
|
|
break;
|
|
|
}
|
|
|
- if(SetRunConfigStrValue("upgradeTask","UpgradeTaskId",m_currentTask.upgradeTaskId.GetData())!=Error_Succeed){
|
|
|
- break;
|
|
|
+ if (m_currentTask.task_type.Compare("U") == 0) {
|
|
|
+ if (SetRunConfigStrValue("upgradeTask", "PendingState", "U") != Error_Succeed) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (SetRunConfigStrValue("upgradeTask", "PackName", m_currentTask.pack_name.GetData()) != Error_Succeed) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }else if(m_currentTask.task_type.Compare("R") == 0){
|
|
|
+ if (SetRunConfigStrValue("upgradeTask", "PendingState", "I") != Error_Succeed) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (SetRunConfigStrValue("upgradeTask", "PackName", "") != Error_Succeed) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
isWriteOk=true;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- if(isWriteOk){
|
|
|
- //告警下载
|
|
|
- struct CTaskProcess up;
|
|
|
- up.strPackName = m_currentTask.pack_name;//安装包名
|
|
|
- up.installVersion = m_currentTask.pack_version;//安装的版本
|
|
|
- up.CurrentVersion = m_currentVersion;//当前的版本
|
|
|
- up.cInstallState = "D";
|
|
|
- up.strInstallComment = "正在下载";
|
|
|
- SendUpgradeTaskProgress(up);
|
|
|
+ if(isWriteOk){
|
|
|
+ if (m_currentTask.task_type.Compare("U") == 0) {
|
|
|
+ //升级下载
|
|
|
+ struct CTaskProcess up;
|
|
|
+ up.strPackName = m_currentTask.pack_name;//安装包名
|
|
|
+ up.installVersion = m_currentTask.pack_version;//安装的版本
|
|
|
+ up.CurrentVersion = m_currentVersion;//当前的版本
|
|
|
+ up.cInstallState = "D";
|
|
|
+ up.strInstallComment = "正在下载";
|
|
|
+ SendUpgradeTaskProgress(up);
|
|
|
|
|
|
- m_currentTask.cPendingState = "U";//改变内存变量为U
|
|
|
- PostEventFIFO(new FSMEvent(CUpgradeTaskFSM::Event_StartDownload));//进入S4
|
|
|
+ m_currentTask.cPendingState = "U";//改变内存变量为U
|
|
|
+ PostEventFIFO(new FSMEvent(CUpgradeTaskFSM::Event_StartDownload));//进入S4
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //回退
|
|
|
+ struct CTaskProcess up;
|
|
|
+ up.strPackName = m_currentTask.pack_name;//安装包名
|
|
|
+ up.installVersion = m_currentTask.pack_version;//安装的版本
|
|
|
+ up.CurrentVersion = m_currentVersion;//当前的版本
|
|
|
+ up.cInstallState = "B";
|
|
|
+ up.strInstallComment = "正在回退";
|
|
|
+ SendUpgradeTaskProgress(up);
|
|
|
+
|
|
|
+ m_currentTask.cPendingState = "I";//改变内存变量为I
|
|
|
+ PostEventFIFO(new FSMEvent(CUpgradeTaskFSM::Event_StartInstall));//进入S5
|
|
|
+ }
|
|
|
}else{
|
|
|
DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("Event_EndPoll write runinfo is fail,retry int 5's");
|
|
|
Sleep(5 * 1000);//等待五秒,继续创建
|
|
|
@@ -5354,6 +5517,7 @@ void CUpgradeTaskFSM::s5_on_exit()
|
|
|
CancelTimer(2);//解压计时器
|
|
|
CancelTimer(3);//安装计时器
|
|
|
CancelTimer(4);//等待跳转切换计时器
|
|
|
+ CancelTimer(5);//回退检查计时器
|
|
|
}
|
|
|
|
|
|
unsigned int CUpgradeTaskFSM::s5_on_event(FSMEvent* event)
|
|
|
@@ -5415,16 +5579,35 @@ unsigned int CUpgradeTaskFSM::s5_on_event(FSMEvent* event)
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("s5 create InstallPackTask succ, enter into S6");
|
|
|
PostEventFIFO(new FSMEvent(CUpgradeTaskFSM::Event_StartSwitch));//进入S6
|
|
|
}
|
|
|
+ else if (event->param1 == 5) {
|
|
|
+ Task::RollBackCheckTask* iTask = new Task::RollBackCheckTask(this);
|
|
|
+ ErrorCodeEnum rc = m_pEntity->GetFunction()->PostThreadPoolTask(iTask);
|
|
|
+ if (rc != Error_Succeed) {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("s5 create RollBackCheckTask fail,err=%d", (int)rc);
|
|
|
+ ScheduleTimer(5, 30 * 1000);//等待30秒再次检查
|
|
|
+ }
|
|
|
+ }
|
|
|
}else if(event->iEvt == Event_EndStopMediaPlayTask){
|
|
|
|
|
|
StopMediaPlayTaskEvent* pEvent = (StopMediaPlayTaskEvent*)event;
|
|
|
if(pEvent->isSucc){
|
|
|
- //开始解压
|
|
|
- Task::UnzipPackTask* iTask = new Task::UnzipPackTask(this);
|
|
|
- ErrorCodeEnum rc = m_pEntity->GetFunction()->PostThreadPoolTask(iTask);
|
|
|
- if(rc!=Error_Succeed){
|
|
|
- DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("s5 create UnzipPackTask fail,err=%d",(int)rc);
|
|
|
- ScheduleTimer(2, 30*1000);//等待30秒再解压包
|
|
|
+ if (m_currentTask.task_type.Compare("U") == 0) {
|
|
|
+ //开始解压
|
|
|
+ Task::UnzipPackTask* iTask = new Task::UnzipPackTask(this);
|
|
|
+ ErrorCodeEnum rc = m_pEntity->GetFunction()->PostThreadPoolTask(iTask);
|
|
|
+ if (rc != Error_Succeed) {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("s5 create UnzipPackTask fail,err=%d", (int)rc);
|
|
|
+ ScheduleTimer(2, 30 * 1000);//等待30秒再解压包
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (m_currentTask.task_type.Compare("R") == 0) {
|
|
|
+ //回退检查
|
|
|
+ Task::RollBackCheckTask* iTask = new Task::RollBackCheckTask(this);
|
|
|
+ ErrorCodeEnum rc = m_pEntity->GetFunction()->PostThreadPoolTask(iTask);
|
|
|
+ if (rc != Error_Succeed) {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("s5 create RollBackCheckTask fail,err=%d", (int)rc);
|
|
|
+ ScheduleTimer(5, 30 * 1000);//等待30秒再检查
|
|
|
+ }
|
|
|
}
|
|
|
}else{
|
|
|
ScheduleTimer(1, 30*1000);//等待30秒再停止播放广告和音频
|
|
|
@@ -5619,6 +5802,85 @@ unsigned int CUpgradeTaskFSM::s5_on_event(FSMEvent* event)
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ else if (event->iEvt == Event_EndRollBackCheckTask) {
|
|
|
+ if (m_currentTask.stop_media_play) {
|
|
|
+ //恢复广告和音频播放
|
|
|
+ ErrorCodeEnum rc = m_pEntity->GetFunction()->SetSysVar("UpdateState", "0", true);
|
|
|
+ if (Error_Succeed != rc) {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("EndInstallPackTask set UpdateState to 0 fail, err=%d", (int)rc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ RollBackCheckTaskEvent* pEvent = (RollBackCheckTaskEvent*)event;
|
|
|
+ if (pEvent->isSucc) {
|
|
|
+ bool isWriteOk = false;
|
|
|
+ while (true) {
|
|
|
+ if (SetRunConfigStrValue("upgradeTask", "NewVersion", m_currentTask.NewVersion.GetData()) != Error_Succeed) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ isWriteOk = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (isWriteOk) {
|
|
|
+ m_currentTask.cPendingState = "S";//改变内存变量S
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(UpgradeMgr_VERSION_INSTALL_ID)("终端回退版本检查成功");
|
|
|
+ PostEventFIFO(new FSMEvent(CUpgradeTaskFSM::Event_StartSwitch));//进入S6
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Event_EndRollBackCheckTask write runinfo is fail,retry int 5's");
|
|
|
+ Sleep(5 * 1000);//等待五秒
|
|
|
+ PostEventFIFO(new RollBackCheckTaskEvent(true, "", ""));//继续写运行时文件
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //失败
|
|
|
+ if (pEvent->failReason.compare("C")==0) {
|
|
|
+ //回退失败,设置状态为C
|
|
|
+ if (SetRunConfigStrValue("upgradeTask", "PendingState", "C") == Error_Succeed) {
|
|
|
+ //回滚失败取消
|
|
|
+ struct CTaskProcess up;
|
|
|
+ up.strPackName = "";//安装包名
|
|
|
+ up.installVersion = m_currentTask.pack_version;//回退的版本
|
|
|
+ up.CurrentVersion = m_currentVersion;//当前的版本
|
|
|
+ up.cInstallState = "C";
|
|
|
+ up.strInstallComment = pEvent->errMsg;//错误信息
|
|
|
+ SendUpgradeTaskProgress(up);
|
|
|
+
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("RollBackCheck is fail ,prepare to s2");
|
|
|
+ m_currentTask.cPendingState = "C";//改变内存变量C
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(UpgradeMgr_VERSION_INSTALL_ID).setResultCode("RTA5637")("终端回退版本检查失败");
|
|
|
+ PostEventFIFO(new FSMEvent(CUpgradeTaskFSM::Event_StartDealTask));//进入S2
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Event_EndRollBackCheckTask write runinfo is fail,retry int 5's");
|
|
|
+ Sleep(5 * 1000);//等待五秒
|
|
|
+ PostEventFIFO(new RollBackCheckTaskEvent(false, pEvent->errMsg, "C"));//继续写运行时文件
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (pEvent->failReason.compare("X")==0) {
|
|
|
+ //安装失败,设置状态为X 未知
|
|
|
+ if (SetRunConfigStrValue("upgradeTask", "PendingState", "X") == Error_Succeed) {
|
|
|
+ //告警下载取消
|
|
|
+ struct CTaskProcess up;
|
|
|
+ up.strPackName = "";//安装包名
|
|
|
+ up.installVersion = m_currentTask.pack_version;//回退的版本
|
|
|
+ up.CurrentVersion = m_currentVersion;//当前的版本
|
|
|
+ up.cInstallState = "X";
|
|
|
+ up.strInstallComment = pEvent->errMsg;//错误信息
|
|
|
+ SendUpgradeTaskProgress(up);
|
|
|
+
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("RollBackCheck is fail ,prepare to s2");
|
|
|
+ m_currentTask.cPendingState = "X";//改变内存变量X
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(UpgradeMgr_VERSION_INSTALL_ID).setResultCode("RTA5637")("终端回退版本检查失败");
|
|
|
+ PostEventFIFO(new FSMEvent(CUpgradeTaskFSM::Event_StartDealTask));//进入S2
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Event_EndRollBackCheckTask write runinfo is fail,retry int 5's");
|
|
|
+ Sleep(5 * 1000);//等待五秒
|
|
|
+ PostEventFIFO(new RollBackCheckTaskEvent(false, pEvent->errMsg, "X"));//继续写运行时文件
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return 0;
|
|
|
}
|
|
|
|