|
@@ -5,6 +5,7 @@
|
|
|
#include <regex>
|
|
|
#include "CommEntityUtil.hpp"
|
|
|
#include "SpUtility.h"
|
|
|
+#include "iniutil.h"
|
|
|
#if defined(RVC_OS_WIN)
|
|
|
#include <TlHelp32.h>
|
|
|
#include <iphlpapi.h>
|
|
@@ -18,7 +19,6 @@
|
|
|
#include <unistd.h>
|
|
|
#include <fcntl.h>
|
|
|
#include <errno.h>
|
|
|
-#include "iniutil.h"
|
|
|
#endif //RVC_OS_WIN
|
|
|
|
|
|
|
|
@@ -167,38 +167,16 @@ unsigned int CHealthManagerFSM::s4_on_event(FSMEvent* pEvt)
|
|
|
WKUpdatePeriodTask* pTask = new WKUpdatePeriodTask(this);
|
|
|
GetEntityBase()->GetFunction()->PostThreadPoolTask(pTask);
|
|
|
}
|
|
|
- //oilyang@20170316@comment
|
|
|
- //for user desktop,start iebrowser no matter what TerminalStage is.
|
|
|
- //if (csTermStage[0] != 'A')
|
|
|
- // break;
|
|
|
- eErrCode = GetEntityBase()->GetFunction()->SetSysVar("RunState","O");
|
|
|
- if (eErrCode != Error_Succeed)
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("set RunState O failed (%d).",eErrCode);
|
|
|
- }
|
|
|
|
|
|
- CSmartPointer<IEntityFunction> spEntityFunction = GetEntityBase()->GetFunction();
|
|
|
- CSmartPointer<IAsynWaitSp> spWait;
|
|
|
- CSmartPointer<IEntityFunctionPrivilege> pFuncPrivilege = spEntityFunction.ConvertCase<IEntityFunctionPrivilege>();
|
|
|
- CEntityRunInfo acInfo;
|
|
|
- eErrCode = spEntityFunction->GetEntityRunInfo("Chromium",acInfo);
|
|
|
- if (eErrCode == Error_Succeed && acInfo.eState == EntityState_NoStart)
|
|
|
- {
|
|
|
- }
|
|
|
- else if (eErrCode == Error_Succeed && acInfo.eState == EntityState_Idle)
|
|
|
- {//if IE/Chromium start before healthmanager,we suppose healthmanager is restart unexpectly,then set m_bEnterMainPageEver true
|
|
|
- //m_bIEBeforeHealth = true;
|
|
|
- }
|
|
|
LogTermInfoTask* task = new LogTermInfoTask(this);
|
|
|
GetEntityBase()->GetFunction()->PostThreadPoolTask(task);
|
|
|
- if (m_iAccessAuth != AccessAuth_Suc)
|
|
|
+ if (m_iAccessAuth != VtmLoad_AccessAuth_Suc)
|
|
|
PostProcessAfterUpgrade();
|
|
|
}
|
|
|
break;
|
|
|
case USER_EVT_MAITAIN:
|
|
|
DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("to maintain...");
|
|
|
m_stateBeforeMaintain = m_fsmState;
|
|
|
- m_bIdleToMaintain = true;
|
|
|
pEvt->SetHandled();
|
|
|
break;
|
|
|
case USER_EVT_ENTER_CUSTOMER_MANAGER:
|
|
@@ -210,25 +188,20 @@ unsigned int CHealthManagerFSM::s4_on_event(FSMEvent* pEvt)
|
|
|
if (pEvt->param1 == 1)
|
|
|
{
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("VtmLoader load SIPphone entity failed, to Set TerminalStage M.");
|
|
|
- GetEntityBase()->GetFunction()->SetSysVar("TerminalStage", "M");
|
|
|
- break;
|
|
|
+ SetVtmLoadResult(VtmLoad_MediaLoadFail);
|
|
|
+ return pEvt->param1;
|
|
|
}
|
|
|
else if (pEvt->param1 == 2)
|
|
|
{
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("VtmLoader load SYNCSTART(boot cfg = 2) entity failed, to Set TerminalStage C.");
|
|
|
- GetEntityBase()->GetFunction()->SetSysVar("TerminalStage", "C");
|
|
|
- break;
|
|
|
+ SetVtmLoadResult(VtmLoad_OtherSyncEntityLoadFail);
|
|
|
+ return pEvt->param1;
|
|
|
}
|
|
|
- if (!m_bIdleToMaintain)//???no use anymore?
|
|
|
+ if (m_iAccessAuth == VtmLoad_AccessAuth_Init)
|
|
|
{
|
|
|
- if (m_iAccessAuth == AccessAuth_Init)
|
|
|
- {
|
|
|
- WaitToCallAccessAuthTask* pTask = new WaitToCallAccessAuthTask(this);
|
|
|
- GetEntityBase()->GetFunction()->PostThreadPoolTask(pTask);
|
|
|
- }
|
|
|
+ WaitToCallAccessAuthTask* pTask = new WaitToCallAccessAuthTask(this);
|
|
|
+ GetEntityBase()->GetFunction()->PostThreadPoolTask(pTask);
|
|
|
}
|
|
|
- else
|
|
|
- m_bIdleToMaintain = false;
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
@@ -243,8 +216,6 @@ void CHealthManagerFSM::s5_on_entry()
|
|
|
LogTermInfoTask* task = new LogTermInfoTask(this);
|
|
|
GetEntityBase()->GetFunction()->PostThreadPoolTask(task);
|
|
|
m_fsmState = HM_FSM_STATE_FAULT;
|
|
|
- //oilyang@20210930 add to call for Close Page
|
|
|
- GetEntityBase()->GetFunction()->SetSysVar("TerminalStage", "C");
|
|
|
PostProcessAfterUpgrade();
|
|
|
}
|
|
|
void CHealthManagerFSM::s5_on_exit()
|
|
@@ -465,13 +436,14 @@ int CHealthManagerFSM::AccessAuthDoWork()
|
|
|
{
|
|
|
//存在循环刷数据的情况,暂时不记这个,只记失败
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402501Z10301")("to call AccessAuth's Regist");
|
|
|
+ m_ullAuthStart = SP::Module::Comm::RVCGetTickCount();
|
|
|
eErrCode = (*m_pACClient)(EntityResource::getLink().upgradeLink())->Regist();
|
|
|
m_bHasAuthEver = true;
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("accessauth regist %d", eErrCode);
|
|
|
if (eErrCode == Error_Succeed)
|
|
|
{
|
|
|
do {
|
|
|
- if (m_iAccessAuth != AccessAuth_Init)
|
|
|
+ if (m_iAccessAuth != VtmLoad_AccessAuth_Init)
|
|
|
break;
|
|
|
Sleep(1000);
|
|
|
} while (1);//wait for accessauth send result
|
|
@@ -499,26 +471,33 @@ int CHealthManagerFSM::AccessAuthDoWork()
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
-void CHealthManagerFSM::SetAccessAuth(int bResult)
|
|
|
+void CHealthManagerFSM::SetVtmLoadResult(int bResult)
|
|
|
{
|
|
|
m_iAccessAuth = bResult;
|
|
|
ErrorCodeEnum eErrCode;
|
|
|
- if (bResult == AccessAuth_Suc)
|
|
|
+ if (bResult == VtmLoad_AccessAuth_Suc)
|
|
|
{
|
|
|
eErrCode = GetEntityBase()->GetFunction()->SetSysVar("TerminalStage", "A");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("AccessAuthSuc")("%d", SP::Module::Comm::RVCGetTickCount() - m_ullAuthStart);
|
|
|
}
|
|
|
- else if (bResult == AccessAuth_servFail) //准入服务端返回失败
|
|
|
+ else if (bResult == VtmLoad_AccessAuth_servFail) //准入服务端返回失败
|
|
|
{
|
|
|
eErrCode = GetEntityBase()->GetFunction()->SetSysVar("TerminalStage", "S");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("AccessAuthFailServ")("%d", SP::Module::Comm::RVCGetTickCount() - m_ullAuthStart);
|
|
|
+ }
|
|
|
+ else if (bResult == VtmLoad_MediaLoadFail) //音视频校验不通过
|
|
|
+ {
|
|
|
+ eErrCode = GetEntityBase()->GetFunction()->SetSysVar("TerminalStage", "M");
|
|
|
}
|
|
|
- else //准入其他失败
|
|
|
+ else //其他失败
|
|
|
{
|
|
|
eErrCode = GetEntityBase()->GetFunction()->SetSysVar("TerminalStage", "C");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("AccessAuthFailOther")("%d", SP::Module::Comm::RVCGetTickCount() - m_ullAuthStart);
|
|
|
}
|
|
|
if (eErrCode != Error_Succeed)
|
|
|
- DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("set TerminalStage %d,failed:%s", bResult, SpStrError(eErrCode));
|
|
|
+ DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("set TerminalStage %d,failed:%s", bResult, SpStrError(eErrCode));
|
|
|
else
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("set TerminalStage %d", bResult);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("set TerminalStage %d", bResult);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -749,28 +728,33 @@ CSimpleStringA CHealthManagerFSM::GetOsVersion()
|
|
|
while(!is.eof()){
|
|
|
getline(is, line);
|
|
|
int start = line.find("版本");
|
|
|
- if (start > 0)
|
|
|
- return CSimpleStringA(line.substr(start + 5, line.length() - start - 7).c_str());
|
|
|
+ if (start != string::npos)
|
|
|
+ //return CSimpleStringA(line.substr(start + 5, line.length() - start - 7).c_str());
|
|
|
+ return CSimpleStringA(line.c_str());
|
|
|
else
|
|
|
continue;
|
|
|
}
|
|
|
return "";
|
|
|
#else
|
|
|
+ std::map<std::string, std::string> osInfo;
|
|
|
const char filePath[] = "/etc/os-version";
|
|
|
- CSimpleStringA strVersion;
|
|
|
char tmp[33];
|
|
|
memset(tmp, 0, 33);
|
|
|
+ inifile_read_str_s("Version", "SystemName", "unknown", tmp, 32, filePath);
|
|
|
+ osInfo["SystemName"] = tmp;
|
|
|
+ memset(tmp, 0, 33);
|
|
|
+ inifile_read_str_s("Version", "ProductType", "unknown", tmp, 32, filePath);
|
|
|
+ osInfo["ProductType"] = tmp;
|
|
|
+ memset(tmp, 0, 33);
|
|
|
inifile_read_str_s("Version", "MajorVersion", "unknown", tmp, 32, filePath);
|
|
|
- strVersion = tmp;
|
|
|
- strVersion += ".";
|
|
|
+ osInfo["MajorVersion"] = tmp;
|
|
|
memset(tmp, 0, 33);
|
|
|
inifile_read_str_s("Version", "MinorVersion", "unknown", tmp, 32, filePath);
|
|
|
- strVersion += tmp;
|
|
|
- strVersion += ".";
|
|
|
+ osInfo["MinorVersion"] = tmp;
|
|
|
memset(tmp, 0, 33);
|
|
|
inifile_read_str_s("Version", "OsBuild", "unknown", tmp, 32, filePath);
|
|
|
- strVersion += tmp;
|
|
|
- return strVersion;
|
|
|
+ osInfo["OsBuild"] = tmp;
|
|
|
+ return generateJsonStr(osInfo).second.c_str();
|
|
|
#endif
|
|
|
}
|
|
|
|
|
@@ -879,7 +863,8 @@ void CHealthManagerFSM::ToLogWarnTermAboutInfo()
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
QueryAndSaveDNS();
|
|
|
- QueryAndSaveCPUInfo();
|
|
|
+ QueryAndSendCPUInfo();
|
|
|
+ QueryAndSendDisplayInfo();
|
|
|
bool bTmpEtyNewStart = m_bEntityNewStart;
|
|
|
if (m_bEntityNewStart)
|
|
|
{
|
|
@@ -907,11 +892,9 @@ void CHealthManagerFSM::ToLogWarnTermAboutInfo()
|
|
|
}
|
|
|
CSimpleStringA csOSVerion(""), csWarnMsg("");
|
|
|
std::map<std::string, std::string> termInfo;
|
|
|
- std::map<std::string, std::string> pcInfo;
|
|
|
termInfo["version"] = m_sysInfo.InstallVersion.ToString();
|
|
|
- termInfo["CPUInfo"] = m_cpuInfo;
|
|
|
|
|
|
- if (m_iAccessAuth == AccessAuth_Suc)
|
|
|
+ if (m_iAccessAuth == VtmLoad_AccessAuth_Suc)
|
|
|
{
|
|
|
termInfo["AccessAuth"] = "T";
|
|
|
}
|
|
@@ -925,34 +908,16 @@ void CHealthManagerFSM::ToLogWarnTermAboutInfo()
|
|
|
csOSVerion = GetOsVersion();
|
|
|
if (!csOSVerion.IsNullOrEmpty())
|
|
|
termInfo["OSVersion"] = csOSVerion;
|
|
|
- pcInfo["TerminalNo"] = m_sysInfo.strTerminalID;//20220704 add by zjw
|
|
|
+ termInfo["Harddisk"] = QueryHarddiskInfo();
|
|
|
|
|
|
#if defined(RVC_OS_WIN)
|
|
|
termInfo["OSType"] = "Windows";
|
|
|
- QueryComputerInfo();
|
|
|
- pcInfo["Manufacturer"] = m_computerInfo["Manufacturer"];
|
|
|
- pcInfo["ComputerName"] = m_computerInfo["ComputerName"];
|
|
|
- pcInfo["ComputerVersion"] = m_computerInfo["ComputerVersion"];
|
|
|
- pcInfo["SerialNumber"] = m_computerInfo["SerialNumber"];
|
|
|
- std::string strOSVersionName, strOSArch;
|
|
|
- CSystemStatus tempStatus;
|
|
|
- tempStatus.GetOsInfo(strOSVersionName, strOSArch);
|
|
|
- if (!strOSArch.empty()) {
|
|
|
- pcInfo["SystemArch"] = strOSArch;
|
|
|
- }
|
|
|
termInfo["AsiaInfo"] = CheckProcessExistByName("NTRtScan.exe") ? "Y" : "N";
|
|
|
termInfo["UniAccess"] = CheckProcessExistByName("UniAccessAgent.exe") ? "Y" : "N";
|
|
|
termInfo["RuiYan"] = CheckProcessExistByName("RuiYan.exe") ? "Y" : "N";
|
|
|
termInfo["Symantec"] = CheckProcessExistByName("SavUI.exe") ? "Y" : "N";
|
|
|
#else
|
|
|
termInfo["OSType"] = "UOS";
|
|
|
- pcInfo["Manufacturer"] = m_sysInfo.strManufacturer.IsNullOrEmpty() ? "": m_sysInfo.strManufacturer.GetData();
|
|
|
- pcInfo["MachineModel"] = m_sysInfo.strMachineModel.IsNullOrEmpty() ? "" : m_sysInfo.strMachineModel.GetData();
|
|
|
- pcInfo["SN"] = m_sysInfo.strMachineSN.IsNullOrEmpty() ? "" : m_sysInfo.strMachineSN.GetData();
|
|
|
- //???oiltmp
|
|
|
- termInfo["Manufacturer"] = m_sysInfo.strManufacturer.IsNullOrEmpty() ? "" : m_sysInfo.strManufacturer.GetData();
|
|
|
- termInfo["MachineMode"] = m_sysInfo.strMachineModel.IsNullOrEmpty() ? "" : m_sysInfo.strMachineModel.GetData();
|
|
|
- termInfo["MachineSN"] = m_sysInfo.strMachineSN.IsNullOrEmpty() ? "" : m_sysInfo.strMachineSN.GetData();
|
|
|
#endif
|
|
|
|
|
|
CSmartPointer<IConfigInfo> spConfigRun;
|
|
@@ -1001,20 +966,15 @@ void CHealthManagerFSM::ToLogWarnTermAboutInfo()
|
|
|
termInfo["AppPath"] = csRunPath;
|
|
|
|
|
|
std::pair<bool, std::string> strResult;
|
|
|
- std::pair<bool, std::string> strPCInfo;
|
|
|
strResult = generateJsonStr(termInfo);
|
|
|
- strPCInfo = generateJsonStr(pcInfo);
|
|
|
|
|
|
spConfigRun->ReadConfigValue("Run", "WarnMsg", csWarnMsg);
|
|
|
- DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("ToLogWarnTermAboutInfo:[%s]", strResult.second.c_str());
|
|
|
//oilyang@20210323 discard the following rule of throwing LogWarn.Always throw LogWarn
|
|
|
//oilyang@20201201 log warn every time if content of msg has changed
|
|
|
if (bTmpEtyNewStart)
|
|
|
{
|
|
|
LogWarn(Severity_Low, Error_Unexpect, LOG_WARN_HEALTH_UPLOAD_INFO_ABOUT_TERM, strResult.second.c_str());
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("InfoAboutTerm")(strResult.second.c_str());
|
|
|
- LogWarn(Severity_Low, Error_Unexpect, HealthManager_UserErrorCode_First_Info_AboutTerm, strResult.second.c_str());
|
|
|
- LogWarn(Severity_Low, Error_Unexpect, HealthManager_UserErrorCode_First_Info_AboutPC, strPCInfo.second.c_str());
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -1297,6 +1257,8 @@ bool CHealthManagerFSM::CheckProcessExistByName(CSimpleStringA procName)
|
|
|
}
|
|
|
void CHealthManagerFSM::QueryAndSaveDNS()
|
|
|
{
|
|
|
+ for (int i = 0; i < m_dns.GetCount(); ++i)
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("before to get, the m_dns[%s]", m_dns[i].c_str());
|
|
|
m_dns.Clear();
|
|
|
CSimpleStringA runInfoPath, csDNSKeyword;
|
|
|
ErrorCodeEnum eErr = GetEntityBase()->GetFunction()->GetPath("runinfo", runInfoPath);
|
|
@@ -1304,7 +1266,7 @@ void CHealthManagerFSM::QueryAndSaveDNS()
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("GetPath runinfo error=%d.", eErr);
|
|
|
return;
|
|
|
}
|
|
|
- runInfoPath += "\\runcfg\\dns";
|
|
|
+ runInfoPath = runInfoPath + SPLIT_SLASH_STR + "runcfg" + SPLIT_SLASH_STR + "dns";
|
|
|
|
|
|
#if defined(RVC_OS_WIN)
|
|
|
CSimpleStringA csCmd;
|
|
@@ -1314,7 +1276,7 @@ void CHealthManagerFSM::QueryAndSaveDNS()
|
|
|
#else
|
|
|
std::string sucContent, failedContent;
|
|
|
CSimpleStringA strCmd;
|
|
|
- strCmd = CSimpleStringA::Format("cat /etc/resolv.conf | grep \" nameserver\" >%s", runInfoPath.GetData());
|
|
|
+ strCmd = CSimpleStringA::Format("cat /etc/resolv.conf | grep \"nameserver\" >%s", runInfoPath.GetData());
|
|
|
bool ret = SP::Module::Util::ShellExecute(strCmd.GetData(), sucContent, failedContent);
|
|
|
csDNSKeyword = "nameserver";
|
|
|
#endif //RVC_OS_WIN
|
|
@@ -1323,26 +1285,26 @@ void CHealthManagerFSM::QueryAndSaveDNS()
|
|
|
if (!is.is_open())
|
|
|
{
|
|
|
DWORD dwErr = GetLastError();
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("open runcfg\\dns file failed. [%d]", dwErr);
|
|
|
+ DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("open %s file failed. [%d]", runInfoPath.GetData(), dwErr);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
string line;
|
|
|
while (!is.eof()) {
|
|
|
getline(is, line);
|
|
|
- int start = line.find(csDNSKeyword.GetData());
|
|
|
- if (start > 0)
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("line:%s", line.c_str());
|
|
|
+ size_t start = line.find(csDNSKeyword.GetData());
|
|
|
+ if (start != string::npos)
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s", line.c_str());
|
|
|
#if defined(RVC_OS_WIN)
|
|
|
int dnsStart = line.find(": ");
|
|
|
- if (dnsStart > 0)
|
|
|
+ if (dnsStart != string::npos)
|
|
|
{
|
|
|
string xDns = SP::Utility::ToTrim(line.substr(dnsStart + 1, line.length() - dnsStart - 1));
|
|
|
m_dns.Append(&xDns, 0, 1);
|
|
|
}
|
|
|
#else
|
|
|
- string xDns = SP::Utility::ToTrim(line.substr(start + 1, line.length() - start - 1));
|
|
|
+ string xDns = SP::Utility::ToTrim(line.substr(start + csDNSKeyword.GetLength() + 1, line.length() - start - csDNSKeyword.GetLength() - 1));
|
|
|
m_dns.Append(&xDns, 0, 1);
|
|
|
#endif
|
|
|
}
|
|
@@ -1351,24 +1313,27 @@ void CHealthManagerFSM::QueryAndSaveDNS()
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
-void CHealthManagerFSM::QueryAndSaveCPUInfo()
|
|
|
+void CHealthManagerFSM::QueryAndSendCPUInfo()
|
|
|
{
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
if (!m_cpuInfo.IsNullOrEmpty())
|
|
|
{
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("have queried cpu info, no need to query again, current cpuinfo:%s", m_cpuInfo.GetData());
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("InfoAboutCPU")(m_cpuInfo.GetData());
|
|
|
return;
|
|
|
}
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
+
|
|
|
SYSTEM_INFO si;
|
|
|
GetSystemInfo(&si);
|
|
|
std::map<std::string, std::string> map_cpuInfo;
|
|
|
|
|
|
- map_cpuInfo.insert(std::make_pair("CPUType", CSimpleStringA::Format("%d", si.dwProcessorType)));
|
|
|
- map_cpuInfo.insert(std::make_pair("CPULevel", CSimpleStringA::Format("%d", si.wProcessorLevel)));
|
|
|
- map_cpuInfo.insert(std::make_pair("CPUArch", CSimpleStringA::Format("%d", si.wProcessorArchitecture)));
|
|
|
- map_cpuInfo.insert(std::make_pair("CPURevision", CSimpleStringA::Format("%d", si.wProcessorRevision)));
|
|
|
- map_cpuInfo.insert(std::make_pair("CPUNum", CSimpleStringA::Format("%d", si.dwNumberOfProcessors)));
|
|
|
+ map_cpuInfo.insert(std::make_pair("dwProcessorType", CSimpleStringA::Format("%d", si.dwProcessorType)));
|
|
|
+ map_cpuInfo.insert(std::make_pair("wProcessorLevel", CSimpleStringA::Format("%d", si.wProcessorLevel)));
|
|
|
+ map_cpuInfo.insert(std::make_pair("wProcessorArchitecture", CSimpleStringA::Format("%d", si.wProcessorArchitecture)));
|
|
|
+ map_cpuInfo.insert(std::make_pair("wProcessorRevision", CSimpleStringA::Format("%d", si.wProcessorRevision)));
|
|
|
+ map_cpuInfo.insert(std::make_pair("dwNumberOfProcessors", CSimpleStringA::Format("%d", si.dwNumberOfProcessors)));
|
|
|
m_cpuInfo = generateJsonStr(map_cpuInfo).second.c_str();
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("InfoAboutCPU")(m_cpuInfo.GetData());
|
|
|
|
|
|
#else
|
|
|
ifstream cpuinfo("/proc/cpuinfo");
|
|
@@ -1377,37 +1342,125 @@ void CHealthManagerFSM::QueryAndSaveCPUInfo()
|
|
|
return;
|
|
|
}
|
|
|
std::map<std::string, std::string> map_cpuInfo;
|
|
|
- bool bModelName(false), bArch(false), bRevision(false);
|
|
|
- string line, modelName(""), arch(""), revision("");
|
|
|
-
|
|
|
- std::regex patternModelName("model\\s+name\\s*:\\s*(.*)");
|
|
|
- std::regex patternArch("CPU\\s*architecture\\s*:(.*)");
|
|
|
- std::regex patternRevision("CPU\\s+revision\\s*:\\s*(.*)");
|
|
|
- std::regex patternProcess("processor\\s*:\\s*(.*)");
|
|
|
- std::smatch match;
|
|
|
- int processNum = 0;
|
|
|
+ string line;
|
|
|
while (std::getline(cpuinfo, line)) {
|
|
|
- if (std::regex_search(line, match, patternModelName) && !bModelName) {
|
|
|
- modelName = match[1];
|
|
|
- bModelName = true;
|
|
|
- }
|
|
|
- else if (std::regex_search(line, match, patternArch) && !bArch) {
|
|
|
- arch = match[1];
|
|
|
- bArch = true;
|
|
|
- }
|
|
|
- else if (std::regex_search(line, match, patternRevision) && !bRevision) {
|
|
|
- revision = match[1];
|
|
|
- bRevision = true;
|
|
|
+ auto elems = SP::Utility::Split(line, ':');
|
|
|
+ if (elems.size() > 1) {
|
|
|
+ map_cpuInfo[SP::Utility::ToTrim(elems[0])] = SP::Utility::ToTrim(elems[1]);
|
|
|
+ if (line.find("CPU revision") != string::npos)
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("InfoAboutCPU")(generateJsonStr(map_cpuInfo).second.c_str());
|
|
|
}
|
|
|
- else if (std::regex_search(line, match, patternProcess))
|
|
|
- processNum++;
|
|
|
- }
|
|
|
- cpuinfo.close();
|
|
|
- map_cpuInfo.insert(std::make_pair("ModelName", modelName));
|
|
|
- map_cpuInfo.insert(std::make_pair("CPUArch", arch));
|
|
|
- map_cpuInfo.insert(std::make_pair("CPURevision", revision));
|
|
|
- map_cpuInfo.insert(std::make_pair("CPUNum", CSimpleStringA::Format("%d", processNum)));
|
|
|
- m_cpuInfo = generateJsonStr(map_cpuInfo).second.c_str();
|
|
|
+ }
|
|
|
#endif //RVC_OS_WIN
|
|
|
return;
|
|
|
+}
|
|
|
+void CHealthManagerFSM::QueryAndSendDisplayInfo()
|
|
|
+{
|
|
|
+ std::map<std::string, std::string> primaryInfo;
|
|
|
+ std::map<std::string, std::string> secondaryInfo;
|
|
|
+ std::map<std::string, std::string> displayInfo;
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+ DISPLAY_DEVICE devDevice;
|
|
|
+ devDevice.cb = sizeof(DISPLAY_DEVICE);
|
|
|
+
|
|
|
+ //获取系统中的所有显示设备
|
|
|
+ EnumDisplayDevices(NULL, ENUM_CURRENT_SETTINGS, &devDevice, 0);
|
|
|
+
|
|
|
+ bool bPrimary = false;
|
|
|
+ // 遍历显示设备列表
|
|
|
+ for (int i = 0; EnumDisplayDevices(NULL, i, &devDevice, 0) != 0; i++)
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("devDevice.StateFlags:%d", devDevice.StateFlags);
|
|
|
+ bPrimary = false;
|
|
|
+ //if connected
|
|
|
+ if (devDevice.StateFlags & DISPLAY_DEVICE_ACTIVE)
|
|
|
+ {
|
|
|
+ if (devDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
|
|
|
+ bPrimary = true;
|
|
|
+ // 获取显示设备的分辨率
|
|
|
+ DEVMODE devMode;
|
|
|
+ devMode.dmSize = sizeof(DEVMODE);
|
|
|
+ EnumDisplaySettings(devDevice.DeviceName, ENUM_CURRENT_SETTINGS, &devMode);
|
|
|
+ if (bPrimary)
|
|
|
+ {
|
|
|
+ primaryInfo["dmDeviceName"] = CSimpleStringA::Format("%s", devMode.dmDeviceName);
|
|
|
+ primaryInfo["dmPelsWidth"] = CSimpleStringA::Format("%d", devMode.dmPelsWidth);
|
|
|
+ primaryInfo["dmPelsHeight"] = CSimpleStringA::Format("%d", devMode.dmPelsHeight);
|
|
|
+ primaryInfo["dmDisplayOrientation"] = CSimpleStringA::Format("%d", devMode.dmDisplayOrientation);
|
|
|
+ primaryInfo["dmDisplayFixedOutput"] = CSimpleStringA::Format("%d", devMode.dmDisplayFixedOutput);
|
|
|
+ primaryInfo["dmPosition.x"] = CSimpleStringA::Format("%d", devMode.dmPosition.x);
|
|
|
+ primaryInfo["dmPosition.y"] = CSimpleStringA::Format("%d", devMode.dmPosition.y);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ secondaryInfo["dmDeviceName"] = CSimpleStringA::Format("%s", devMode.dmDeviceName);
|
|
|
+ secondaryInfo["dmPelsWidth"] = CSimpleStringA::Format("%d", devMode.dmPelsWidth);
|
|
|
+ secondaryInfo["dmPelsHeight"] = CSimpleStringA::Format("%d", devMode.dmPelsHeight);
|
|
|
+ secondaryInfo["dmDisplayOrientation"] = CSimpleStringA::Format("%d", devMode.dmDisplayOrientation);
|
|
|
+ secondaryInfo["dmDisplayFixedOutput"] = CSimpleStringA::Format("%d", devMode.dmDisplayFixedOutput);
|
|
|
+ secondaryInfo["dmPosition.x"] = CSimpleStringA::Format("%d", devMode.dmPosition.x);
|
|
|
+ secondaryInfo["dmPosition.y"] = CSimpleStringA::Format("%d", devMode.dmPosition.y);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ displayInfo["PrimaryText"] = generateJsonStr(primaryInfo).second.c_str();
|
|
|
+ displayInfo["SecondaryText"] = generateJsonStr(secondaryInfo).second.c_str();
|
|
|
+#else
|
|
|
+ CSimpleStringA runInfoPath, csDNSKeyword;
|
|
|
+ ErrorCodeEnum eErr = GetEntityBase()->GetFunction()->GetPath("runinfo", runInfoPath);
|
|
|
+ if (eErr != Error_Succeed) {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("GetPath runinfo error=%d.", eErr);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ runInfoPath = runInfoPath + SPLIT_SLASH_STR + "runcfg" + SPLIT_SLASH_STR + "monitor";
|
|
|
+
|
|
|
+
|
|
|
+ std::string sucContent, failedContent;
|
|
|
+ CSimpleStringA strCmd;
|
|
|
+ strCmd = CSimpleStringA::Format("xrandr | grep \" connected\" >%s", runInfoPath.GetData());
|
|
|
+ bool ret = SP::Module::Util::ShellExecute(strCmd.GetData(), sucContent, failedContent);
|
|
|
+ if (!ret)
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("failedContent:%s", failedContent.c_str());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ ifstream is;
|
|
|
+ is.open(runInfoPath.GetData(), ios::binary);
|
|
|
+ if (!is.is_open())
|
|
|
+ {
|
|
|
+ DWORD dwErr = GetLastError();
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("open %s file failed. [%d]", runInfoPath.GetData(), dwErr);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ string line;
|
|
|
+ while (!is.eof()) {
|
|
|
+ getline(is, line);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("line:%s", line.c_str());
|
|
|
+
|
|
|
+ if (line.find("connected") != string::npos)
|
|
|
+ {
|
|
|
+ if (line.find("primary") != string::npos)
|
|
|
+ displayInfo["PrimaryText"] = line;
|
|
|
+ else
|
|
|
+ displayInfo["SecondaryText"] = line;
|
|
|
+ }
|
|
|
+ }
|
|
|
+#endif
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("InfoAboutDisplay")(generateJsonStr(displayInfo).second.c_str());
|
|
|
+}
|
|
|
+string CHealthManagerFSM::QueryHarddiskInfo()
|
|
|
+{
|
|
|
+ CSimpleStringA csRunCfgPath("");
|
|
|
+ GetEntityBase()->GetFunction()->GetPath("RunCfg", csRunCfgPath);
|
|
|
+ csRunCfgPath = csRunCfgPath + SPLIT_SLASH_STR + "AccessAuthorization.ini";
|
|
|
+ char tmp[256];
|
|
|
+ memset(tmp, 0, 256);
|
|
|
+ inifile_read_str_s("system", "info", "", tmp, 255, csRunCfgPath);
|
|
|
+ auto elems = SP::Utility::Split(tmp, '|');
|
|
|
+ if (elems.size() > 2) {
|
|
|
+ return SP::Utility::ToTrim(elems[2]);
|
|
|
+ }
|
|
|
+ return "";
|
|
|
}
|