|
@@ -1,5 +1,6 @@
|
|
|
#include "stdafx.h"
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
+#include <algorithm>
|
|
|
#include "SelfCheckerFSM.h"
|
|
|
#include "EventCode.h"
|
|
|
#pragma comment(lib,"user32.lib")
|
|
@@ -107,7 +108,6 @@ void CSelfCheckerFSM::s0_on_entry()
|
|
|
|| tmpNames[i] == "Download" || tmpNames[i] == "UpgradeRun" || tmpNames[i] == "UpgradeManager")
|
|
|
{
|
|
|
m_allEntity.push_back(tmpNames[i]);
|
|
|
- m_activeEntity.push_back(tmpNames[i]);
|
|
|
}
|
|
|
}
|
|
|
FSMEvent* pEvt = new FSMEvent(USER_EVT_INIT);
|
|
@@ -278,6 +278,8 @@ ErrorCodeEnum CSelfCheckerFSM::Initial()
|
|
|
spConfigRun->ReadConfigValueInt("WarnRecord", "disk", m_diskLastWarnHour);
|
|
|
}
|
|
|
|
|
|
+ m_activeEntity.push_back("Chromium");
|
|
|
+
|
|
|
return Error_Succeed;
|
|
|
}
|
|
|
ErrorCodeEnum CSelfCheckerFSM::ExceptionErrorProcess(const char* pszEntityName, ErrorCodeEnum eCode)
|
|
@@ -472,7 +474,7 @@ ErrorCodeEnum CSelfCheckerFSM::CheckEntity(const char* pszEntityName, EntityTest
|
|
|
//the hardward entity and some other entity no need to test
|
|
|
if (_strnicmp("PinPad", pszEntityName, strlen("PinPad")) == 0 || _strnicmp("CardIssuer", pszEntityName, strlen("CardIssuer")) == 0
|
|
|
|| _strnicmp("CardSwiper", pszEntityName, strlen("CardSwiper")) == 0 || _strnicmp("ContactlessCard", pszEntityName, strlen("ContactlessCard")) == 0
|
|
|
- || _strnicmp("IDCertificate", pszEntityName, strlen("IDCertificate")) == 0 || _strnicmp("ups", pszEntityName, strlen("ups")) == 0
|
|
|
+ || _strnicmp("IDCertificate", pszEntityName, strlen("IDCertificate")) == 0
|
|
|
|| _strnicmp("gpio", pszEntityName, strlen("gpio")) == 0 || _strnicmp("HSPScanner", pszEntityName, strlen("HSPScanner")) == 0
|
|
|
|| _strnicmp("FingerPrint", pszEntityName, strlen("FingerPrint")) == 0
|
|
|
)
|
|
@@ -480,7 +482,9 @@ ErrorCodeEnum CSelfCheckerFSM::CheckEntity(const char* pszEntityName, EntityTest
|
|
|
}
|
|
|
}
|
|
|
//oilyang@20170926 no need to check by self.Let the HealthManager entity to do it.
|
|
|
- if (pszEntityName != NULL && strnicmp(pszEntityName, GetEntityBase()->GetEntityName(), strlen(GetEntityBase()->GetEntityName())) == 0)
|
|
|
+ //oilyang@20231106 no need to check VtmLoader
|
|
|
+ if (pszEntityName != NULL && (strnicmp(pszEntityName, GetEntityBase()->GetEntityName(), strlen(GetEntityBase()->GetEntityName())) == 0
|
|
|
+ || strnicmp(pszEntityName, "VtmLoader", strlen("VtmLoader")) == 0))
|
|
|
return Error_Succeed;
|
|
|
CSmartPointer<IEntityFunction> pFunc = GetEntityBase()->GetFunction();
|
|
|
CSmartPointer<IEntityFunctionPrivilege> pFuncPrivilege = pFunc.ConvertCase<IEntityFunctionPrivilege>();
|
|
@@ -536,60 +540,9 @@ void CSelfCheckerFSM::OnNormalWorkTimerout(void* pData)
|
|
|
|
|
|
void CSelfCheckerFSM::DoOnCreated(const char* pszEntityName, ErrorCodeEnum eOnStartErrorCode, const char* pszCallerEntity)
|
|
|
{
|
|
|
- if (eOnStartErrorCode == Error_Succeed)
|
|
|
- {
|
|
|
- vector<CSimpleStringA>::iterator it, itAct;
|
|
|
- bool bFound = false, bActFound = false;
|
|
|
-
|
|
|
- for (it = m_allEntity.begin(); it != m_allEntity.end(); ++it)
|
|
|
- {
|
|
|
- if (!strncmp(pszEntityName, *it, it->GetLength()))
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("already exist %s", pszEntityName);
|
|
|
- bFound = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!bFound)
|
|
|
- m_allEntity.push_back(pszEntityName);
|
|
|
-
|
|
|
- for (itAct = m_activeEntity.begin(); itAct != m_activeEntity.end(); ++itAct)
|
|
|
- {
|
|
|
- if (!strncmp(pszEntityName, *itAct, itAct->GetLength()))
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("active entity already exist %s", pszEntityName);
|
|
|
- bActFound = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!bActFound)
|
|
|
- {
|
|
|
- m_activeEntity.push_back(pszEntityName);
|
|
|
- }
|
|
|
- m_entCfgInfo[pszEntityName].entityRestartCount = 0;
|
|
|
- }
|
|
|
}
|
|
|
void CSelfCheckerFSM::DoOnClosed(const char* pszEntityName, EntityCloseCauseEnum eCloseCause, ErrorCodeEnum eOnCloseErrorCode, const char* pszCallerEntity)
|
|
|
{
|
|
|
- //not close by selfchecker
|
|
|
- if (strncmp(pszCallerEntity, GetEntityBase()->GetEntityName(), strlen(pszCallerEntity)))
|
|
|
- {
|
|
|
- if (eCloseCause == CloseCause_Self || eCloseCause == CloseCause_Other)
|
|
|
- {
|
|
|
- vector<CSimpleStringA>::iterator it;
|
|
|
- for (it = m_activeEntity.begin(); it != m_activeEntity.end(); ++it)
|
|
|
- {
|
|
|
- if (!strncmp(pszEntityName, *it, it->GetLength()))
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("onclosed %s", pszEntityName);
|
|
|
- //oilyang@20210425 as almost all entity's start configure have been set to 0(can be ignored)
|
|
|
- //no need to erase the m_activeEntity any more
|
|
|
- //m_activeEntity.erase(it);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
void CSelfCheckerFSM::DoOnException(const char* pszEntityName, const char* pszFunctionName, EntityStateEnum eState, EntityStateEnum eLastState, ErrorCodeEnum eErrorCode)
|
|
|
{
|
|
@@ -796,22 +749,6 @@ ErrorCodeEnum CSelfCheckerFSM::GetEntityErrorList(int& warmLevel, CSimpleStringA
|
|
|
}
|
|
|
int CSelfCheckerFSM::Proc(string entity, ProcType eType, DWORD dwCode, const char* pszMessage)
|
|
|
{
|
|
|
- ConnectToHealthManager();
|
|
|
- if (!m_entRunInfo[entity.c_str()].bGetLoadOpt)
|
|
|
- {
|
|
|
- if (m_pHealthClient != NULL)
|
|
|
- {
|
|
|
- HealthManagerService_GetEntityCfgInfo_Req req;
|
|
|
- HealthManagerService_GetEntityCfgInfo_Ans ans;
|
|
|
- req.name = entity.c_str();
|
|
|
- ErrorCodeEnum errCode = (*m_pHealthClient)(EntityResource::getLink().upgradeLink())->GetEntityCfgInfo(req, ans, 10000);
|
|
|
- if (errCode == Error_Succeed)
|
|
|
- {
|
|
|
- m_entRunInfo[entity.c_str()].bGetLoadOpt = true;
|
|
|
- SetEntityCfgInfo(entity.c_str(), ans.loadOpt);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
map<string, EntityCfg, EntityNameCompare>::iterator it;
|
|
|
if ((it = m_mapEntity.find(entity.c_str())) == m_mapEntity.end())
|
|
|
{
|
|
@@ -1178,51 +1115,9 @@ void CSelfCheckerFSM::UpgradeActionProcess(const char* pszEntityName, const char
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
-ErrorCodeEnum CSelfCheckerFSM::ConnectToHealthManager()
|
|
|
-{
|
|
|
- if (m_pHealthClient == NULL || m_pHealthClient->QuerySessionClosed())
|
|
|
- {
|
|
|
- m_pHealthClient = new HealthManagerService_ClientBase(GetEntityBase());
|
|
|
- ErrorCodeEnum ErrorConn = m_pHealthClient->Connect();
|
|
|
- if (ErrorConn != Error_Succeed) {
|
|
|
- m_pHealthClient->SafeDelete();
|
|
|
- m_pHealthClient = NULL;
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Connect to Healthmanager failed.%d", ErrorConn);
|
|
|
- return Error_Unexpect;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("HealthManager connected.");
|
|
|
- }
|
|
|
- }
|
|
|
- return Error_Succeed;
|
|
|
-}
|
|
|
void CSelfCheckerFSM::SetEverEnterMainPageFlag(bool bValue)
|
|
|
{
|
|
|
m_bEverInMainPage = bValue;
|
|
|
- if (!m_bHaveGetEntityList)
|
|
|
- {
|
|
|
- ConnectToHealthManager();
|
|
|
- if (m_pHealthClient != NULL)
|
|
|
- {
|
|
|
- HealthManagerService_GetEntityCfgInfo_Req req;
|
|
|
- HealthManagerService_GetEntityCfgInfo_Ans ans;
|
|
|
- req.name = "AllConfiguredEntity";
|
|
|
- ErrorCodeEnum errCode = (*m_pHealthClient)(EntityResource::getLink().upgradeLink())->GetEntityCfgInfo(req, ans, 5000);
|
|
|
- if (errCode == Error_Succeed)
|
|
|
- {
|
|
|
- m_bHaveGetEntityList = true;
|
|
|
- CAutoArray<CSimpleStringA> allCfgEntity = ans.reserved2.Split(',');
|
|
|
- m_activeEntity.clear();
|
|
|
- for (int i = 0; i < allCfgEntity.GetCount(); i++)
|
|
|
- {
|
|
|
- if (allCfgEntity[i].Trim().GetLength() > 1)//except for empty entity name
|
|
|
- m_activeEntity.push_back(allCfgEntity[i]);
|
|
|
- }
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("to get all entity list:%s", ans.reserved2);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
void CSelfCheckerFSM::AddFWBEntityToList()
|
|
|
{
|
|
@@ -1261,4 +1156,38 @@ void CSelfCheckerFSM::AddFWBEntityToList()
|
|
|
m_activeEntity.push_back("IDCertificate");
|
|
|
if (!bActFingerPrintFound)
|
|
|
m_activeEntity.push_back("FingerPrint");
|
|
|
+}
|
|
|
+void CSelfCheckerFSM::GetEntityList(CSimpleStringA csList)
|
|
|
+{
|
|
|
+
|
|
|
+
|
|
|
+ CAutoArray<CSimpleStringA> arrStageList;
|
|
|
+ arrStageList.Init(64);
|
|
|
+ arrStageList = csList.Split('|');
|
|
|
+ for (int i = 0; i < arrStageList.GetCount(); ++i)
|
|
|
+ {
|
|
|
+ CAutoArray<CSimpleStringA> arrEntity;
|
|
|
+ arrEntity.Init(2);
|
|
|
+ arrEntity = arrStageList[i].Split('=');
|
|
|
+ if (arrEntity.GetCount() < 2)
|
|
|
+ break;
|
|
|
+ //去重,防止前面已经加载了
|
|
|
+ if (find(m_activeEntity.begin(), m_activeEntity.end(), arrEntity[0].GetData()) != m_activeEntity.end())
|
|
|
+ continue;
|
|
|
+ m_activeEntity.push_back(arrEntity[0]);
|
|
|
+ m_entRunInfo[arrEntity[0]].bGetLoadOpt = true;
|
|
|
+ if (arrEntity[1].Compare("1") == 0)
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s config with loadopt 1", arrEntity[0].GetData());
|
|
|
+ m_entRunInfo[arrEntity[0]].loadOpt = 1;
|
|
|
+ }
|
|
|
+ else if (arrEntity[1].Compare("2") == 0)
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s config with loadopt 2", arrEntity[0].GetData());
|
|
|
+ m_entRunInfo[arrEntity[0]].loadOpt = 2;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ m_entRunInfo[arrEntity[0]].loadOpt = 0;
|
|
|
+ }
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("m_activeEntity has %d entity", m_activeEntity.size());
|
|
|
}
|