Ver código fonte

Merge branch 'ST2_cly_0314_VtmErrMsg' into compile_upgrade_base230

chenliangyu 1 ano atrás
pai
commit
911390da1b

+ 1 - 1
CMakeLists.txt

@@ -288,7 +288,7 @@ conan_cmake_run(REQUIRES RvcFramework/1.2.0.104@LR04.02_FrameworkLib/dev
 	Audio/2024.0118.01@LR04.02_MediaRes/testing
 BASIC_SETUP CMAKE_TARGETS)
 else()
-conan_cmake_run(REQUIRES RvcFramework/1.2.0.103@LR04.02_FrameworkLib/dev
+conan_cmake_run(REQUIRES RvcFramework/1.2.0.104@LR04.02_FrameworkLib/dev
 	Audio/2024.0118.01@LR04.02_MediaRes/testing
 BASIC_SETUP CMAKE_TARGETS)
 endif(MSVC)

+ 2 - 0
Module/include/EventCode.h

@@ -81,6 +81,7 @@ static const char* Device_Type_Table[] = {
 #define Event_VtmLoader_EntityLoad_Finished 	0x10f00002	//实体加载完成
 #define Event_VtmLoader_EntityLoad_Failed 		0x10f00003	//实体加载失败
 #define Event_VtmLoader_GetConfig_Fail 		0x10f00004	//配置拉取失败
+#define Event_VtmLoader_GetVTMERRMSG_Suc 			0x10f00005	//错误码后置配置拉取完成
 
 #ifndef _WIN32
 /*----MaintainWatcher--modify--by--LZM--at--2020/4/8----*/
@@ -750,6 +751,7 @@ ERROR_ACCESSAUTH_CONNECT_ACS_x}
 #define LOG_WARN_CHROMIUM_NOT_SUPPORT_TOKILL_SPECIFIED_BROWSER 0x4020001E
 #define LOG_WARN_CHROMIUM_INSTALL_URLS_CHECK	0x40200021
 #define LOG_WARN_CHROMIUM_INSTALL_NOTSURPORT	0x40200022
+#define LOG_WARN_CHROMIUM_VTMUSERMSG_ERR		0x40200023
 
 #define EVENT_RESTART_SHELL      0x50300001  // 重启Shell
 #define EVENT_RESTART_MACHINE     0x50300002  // 重启终端

+ 7 - 16
Module/mod_chromium/CModTools.cpp

@@ -229,14 +229,6 @@ namespace Chromium {
 			}
 		}
 		break;
-		case ERR_PAGE_REASON::ErrNotify:
-		{
-			errPageParams.Append(CSimpleStringA("reason=")).Append(std::get<0>(exParam).c_str()).Append(CSimpleStringA(generate_url_prefix()));
-
-			errPageParams.Append(CSimpleStringA(generate_url_prefix())).Append(CSimpleStringA("&showlimit=")).Append(std::to_string((unsigned long long)1).c_str());
-
-		}
-		break;
 		default:
 			return std::make_pair(false, std::string("unknown err_page_reason:").append(errType._to_string()));
 		}
@@ -783,17 +775,16 @@ namespace Chromium {
 		{
 			std::vector<std::string> installUrls;
 #ifdef DEVOPS_ON_ST /*DevOps流水线编译,ST环境*/
-			installUrls.push_back("https://one-account-gateway.paasuat.cmbchina.cn/auth/sso-login?client_id=78e38f5453c547ef8a0d5d10a2ed5121&response_type=code&redirect_uri=https://deviceinstallweb.paasst.cmbchina.cn/installRequire");
-			installUrls.push_back("https://one-account-gateway.paasuat.cmbchina.cn/auth/sso-login?client_id=78e38f5453c547ef8a0d5d10a2ed5121&response_type=code&redirect_uri=https://deviceinstallweb.paasst.cmbchina.cn/installRequire");
+			installUrls.push_back("https://deviceinstallweb.paasst.cmbchina.cn/installRequire");
+			installUrls.push_back("https://deviceinstallwebdmz.paasst.cmbchina.cn/installRequire");
 #elif defined(DEVOPS_ON_UAT)/*DevOps流水线编译,UAT环境*/
-			installUrls.push_back("http://deviceinstallweb.paasuat.cmbchina.cn");
-			installUrls.push_back("http://deviceinstallweb.paasuat.cmbchina.com");
+			installUrls.push_back("https://deviceinstallweb.paasuat.cmbchina.cn/installRequire");
+			installUrls.push_back("https://deviceinstallwebdmz.paasuat.cmbchina.cn/installRequire");
 #elif defined(DEVOPS_ON_PRD)/*DevOps流水线编译,PRD环境*/
-			installUrls.push_back("http://deviceinstallweb.paas.cmbchina.cn");
-			installUrls.push_back("http://deviceinstallweb.paas.cmbchina.com");
+			installUrls.push_back("https://deviceinstallweb.paas.cmbchina.cn/installRequire");
+			installUrls.push_back("https://deviceinstallweb.paas.cmbchina.com/installRequire");
 #else/*本地编译等非DevOps环境编译的版本*/
-			installUrls.push_back("https://one-account-gateway.paasuat.cmbchina.cn/auth/sso-login?client_id=78e38f5453c547ef8a0d5d10a2ed5121&response_type=code&redirect_uri=https://deviceinstallweb.paasst.cmbchina.cn/installRequire");
-			installUrls.push_back("https://one-account-gateway.paasuat.cmbchina.cn/auth/sso-login?client_id=78e38f5453c547ef8a0d5d10a2ed5121&response_type=code&redirect_uri=https://deviceinstallweb.paasst.cmbchina.cn/installRequire");
+			installUrls.push_back("https://deviceinstallweb.paas.cmbchina.cn/installRequire");
 #endif
 			auto checkRet = DetectActiveHttp(installUrls);
 			if (!checkRet.first)

+ 3 - 3
Module/mod_chromium/CWSCodec.cpp

@@ -484,7 +484,7 @@ namespace Chromium {
 			cJSON_AddNumberToObject(ret, "errorCode", errorCode);
 			ReadT(msg.getPayload(), errorMsg, &rpos);
 			{
-				auto userCodeInfo = splitStrToUserCodeAndErrMsg(errorMsg.GetData());
+				auto userCodeInfo = getErrMsgByRemark(errorMsg.GetData());
 				if (userCodeInfo.first != 0)
 					cJSON_AddNumberToObject(ret, "userCode", userCodeInfo.first);
 				cJSON_AddStringToObject(ret, "errorMsg", userCodeInfo.second.c_str());
@@ -497,7 +497,7 @@ namespace Chromium {
 			cJSON_AddNumberToObject(ret, "errorCode", errorCode);
 			ReadT(msg.getPayload(), errorMsg, &rpos);
 			{
-				auto userCodeInfo = splitStrToUserCodeAndErrMsg(errorMsg.GetData());
+				auto userCodeInfo = getErrMsgByRemark(errorMsg.GetData());
 				if (userCodeInfo.first != 0)
 					cJSON_AddNumberToObject(ret, "userCode", userCodeInfo.first);
 				cJSON_AddStringToObject(ret, "errorMsg", userCodeInfo.second.c_str());
@@ -516,7 +516,7 @@ namespace Chromium {
 			cJSON_AddNumberToObject(ret, "errorCode", errorCode);
 			ReadT(msg.getPayload(), errorMsg, &rpos);
 			{
-				auto userCodeInfo = splitStrToUserCodeAndErrMsg(errorMsg.GetData());
+				auto userCodeInfo = getErrMsgByRemark(errorMsg.GetData());
 				if (userCodeInfo.first != 0)
 					cJSON_AddNumberToObject(ret, "userCode", userCodeInfo.first);
 				cJSON_AddStringToObject(ret, "errorMsg", userCodeInfo.second.c_str());

+ 37 - 0
Module/mod_chromium/baseEx.cpp

@@ -39,6 +39,7 @@ bool g_withSpecialTest = false;
 std::string g_usercodeTranslateFile = "";
 std::map<std::string, std::vector<std::string>> g_networkParse;
 std::map<std::string, clock_t> g_networkExpiredData;
+std::map<std::string, std::string> g_UserCodeToMsgTip;
 boost::mutex g_networkMutex;
 
 const std::wstring WCHAR_NULL = L"";
@@ -330,6 +331,42 @@ void InitTranslateFile(std::string srcFile)
 	g_usercodeTranslateFile = srcFile;
 }
 
+void InitUserCodeToMsgTip(CAutoArray<CSimpleStringA>& strErrorCodeArr, CAutoArray<CSimpleStringA>& strDescriptionArr, CAutoArray<CSimpleStringA>& strRemarkArr)
+{
+	g_UserCodeToMsgTip.clear();//should not be inited muli times
+
+	for (int i = 0; i < strErrorCodeArr.GetCount(); i++)
+	{
+		std::string dstDescribe = std::string(strErrorCodeArr[i].GetData()) + "|" + std::string(strDescriptionArr[i].GetData());
+		if(g_UserCodeToMsgTip.find(strRemarkArr[i].GetData()) != g_UserCodeToMsgTip.end())
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("InitUserCodeToMsgTip repeated usercode:%s", strRemarkArr[i].GetData());
+		g_UserCodeToMsgTip.insert(std::make_pair(strRemarkArr[i].GetData(), dstDescribe));
+	}
+
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("InitUserCodeToMsgTip size:%d", g_UserCodeToMsgTip.size());
+}
+
+std::pair<unsigned long, std::string> getErrMsgByRemark(std::string srcMsg)
+{
+	const std::string headerStr = "UserError=";
+	if (srcMsg.find(headerStr) != 0)
+		return std::make_pair(0, srcMsg);
+
+	unsigned long userCode = std::stoi(srcMsg.substr(headerStr.length()));
+	std::string userCodeStr = CSimpleString::Format("0x%X", userCode).GetData();
+
+	if(g_UserCodeToMsgTip.size() == 0)
+		return std::make_pair(0, CSimpleString::Format("RTA42F0|微服务异常|(%s)", srcMsg.c_str()).GetData());
+
+	if (g_UserCodeToMsgTip.find(userCodeStr) != g_UserCodeToMsgTip.end())
+	{
+		auto curMsg = g_UserCodeToMsgTip[userCodeStr];
+		return std::make_pair(userCode, curMsg.c_str());
+	}		
+	else
+		return std::make_pair(userCode, CSimpleString::Format("RTA42F1|错误映射异常|(%s)", srcMsg.c_str()).GetData());
+}
+
 std::pair<unsigned long, std::string> splitStrToUserCodeAndErrMsg(std::string srcMsg)
 {
 	const std::string headerStr = "UserError=";

+ 2 - 0
Module/mod_chromium/baseEx.h

@@ -27,6 +27,8 @@ void DbgToFileLogger(std::string msg);
 bool deleteDir_byFileSystem(const std::string srcPath);
 void InitTranslateFile(std::string srcFile);
 std::pair<unsigned long, std::string> splitStrToUserCodeAndErrMsg(std::string srcMsg);
+void InitUserCodeToMsgTip(CAutoArray<CSimpleStringA>& strErrorCodeArr, CAutoArray<CSimpleStringA>& strDescriptionArr, CAutoArray<CSimpleStringA>& strRemarkArr);
+std::pair<unsigned long, std::string> getErrMsgByRemark(std::string srcMsg);
 
 std::string UtfToGbk(const char* utf8);
 std::string ConvertGBKToUtf8(std::string& strGBK);

+ 35 - 37
Module/mod_chromium/mod_chromium.cpp

@@ -359,12 +359,6 @@ namespace Chromium {
 					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("can not open centerSetting, maybe fault");
 				}
 
-				CSimpleString translatePath;
-				GetFunction()->GetPath("Cfg", translatePath);
-				translatePath.Append(CSimpleStringA(SPLIT_SLASH_STR) + "UserCodeToMsgTip.ini");
-
-				InitTranslateFile(translatePath.GetData());
-
 				if (m_withMagic)
 				{
 					std::string magicStr = CModTools::get_mutable_instance().getMagicStr();
@@ -589,6 +583,12 @@ namespace Chromium {
 		if (ErrorCodeEnum::Error_Succeed == GetFunction()->GetSysVar("TerminalStage", t_terminalState))
 		{
 				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("OnPreStart TerminalStage:%s", t_terminalState.GetData());
+				CAutoArray<CSimpleStringA> strErrorCodeArr;
+				CAutoArray<CSimpleStringA> strDescriptionArr;
+				CAutoArray<CSimpleStringA> strRemarkArr;
+				auto ret = GetFunction()->GetPrivilegeFunction()->GetVTMErrMsgArr(strErrorCodeArr, strDescriptionArr, strRemarkArr);
+				if (Error_Succeed == ret)
+					InitUserCodeToMsgTip(strErrorCodeArr, strDescriptionArr, strRemarkArr);
 			startWithCfg();//属于chromium重启或者其他情况,已经初始化好配置
 		}
 		else
@@ -758,43 +758,41 @@ namespace Chromium {
 		const CAutoArray<DWORD>& Param, const char* pszEntityName, const char* pszModuleName, const char* pszMessage, const linkContext& pLinkInfo)
 	{
 		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("OnLog %x from entity %s, msg : %s", dwUserCode, NULL == pszEntityName ? "" : pszEntityName, NULL == pszMessage ? "" : pszMessage);
-		if (Event_VtmLoader_GetConfig_Suc == dwUserCode || Event_VtmLoader_GetConfig_Fail == dwUserCode)
+		switch (dwUserCode)
 		{
+		case Event_VtmLoader_GetConfig_Suc:
+		case Event_VtmLoader_GetConfig_Fail:
 			refreshLogLevel();//后置后需要刷新log level,因为chromium是先启动的实体
 			startWithCfg();
-		}
+			break;
+		case Event_VtmLoader_GetVTMERRMSG_Suc:
+			/*
+				CSimpleString translatePath;
+				GetFunction()->GetPath("Cfg", translatePath);
+				translatePath.Append(CSimpleStringA(SPLIT_SLASH_STR) + "UserCodeToMsgTip.ini");
 
-#if (defined _WIN32 || defined _WIN64)
-		//No Log_Notify
-#else
-		if (Log_Notify == eLogType)
-		{
-			try {
-				cJSON* pJson = cJSON_Parse(pszMessage);
-				auto notifyReason = cJSON_GetObjectItem(pJson, "reason")->valuestring;
-				auto notifymsg = cJSON_GetObjectItem(pJson, "errmsg")->valuestring;
-				auto notiryRebootTime = cJSON_GetObjectItem(pJson, "rebootTime")->valuestring;
-				auto notifyPool = m_pWsServer->getNotifyPool();
-				if (notifyPool.size() > 0)
-				{
-					for (auto it : notifyPool)
-					{
-						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Log_Notify err, notifyPool to %d, %d", it.first, it.second);
-						m_pWsServer->do_send_notifyMsg(it.first, it.second, notifyReason, notifymsg, notiryRebootTime, dwSysError, dwUserCode);
-					}
-				}
+				InitTranslateFile(translatePath.GetData());
+			*/
+			if (!GetFunction()->HasPrivilege())
+			{
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("no privilege");
+				break;
+		}
+			{
+				CAutoArray<CSimpleStringA> strErrorCodeArr;
+				CAutoArray<CSimpleStringA> strDescriptionArr;
+				CAutoArray<CSimpleStringA> strRemarkArr;
+				auto ret = GetFunction()->GetPrivilegeFunction()->GetVTMErrMsgArr(strErrorCodeArr, strDescriptionArr, strRemarkArr);
+				if (Error_Succeed == ret)
+					InitUserCodeToMsgTip(strErrorCodeArr, strDescriptionArr, strRemarkArr);
 				else
-				{
-					auto openRet = CModTools::get_mutable_instance().StartChromiumBrowser(ERR_PAGE_REASON::ErrNotify, { m_sysInfo.strTerminalID.GetData(), generateTimeStr() }, { notifyReason, notifymsg, notiryRebootTime, dwSysError, dwUserCode });
-					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Log_Notify err, open page %s, %d", Error_Succeed == openRet.first ? "success" : "fail", openRet.second);
-				}
-			}
-			catch (std::exception& e) {
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Log_Notify err, %s", e.what());
+					LogWarn(Severity_Low, Error_Debug, LOG_WARN_CHROMIUM_VTMUSERMSG_ERR, CSimpleStringA::Format("GetVTMErrMsgArr err:%d", ret));
 			}
-			return;
-	}
-#endif
+			break;
+		default:
+			break;
+		}
+		
 	}
 
 

+ 16 - 0
Module/mod_vtmloader/VtmLoaderFSM.cpp

@@ -86,7 +86,19 @@ DWORD tokenUpdate(void* param)
 		// 等待一段时间后再次检查
 		Sleep(20000); // 20秒
 	}
+	return 0;
+}
+
+DWORD errMsgListUpdate(void* param)
+{
+	CVtmLoaderFSM* t_entity = (CVtmLoaderFSM*)param;
+
+	//update err list after setting centersetting urls
+	//try updating every 20s until success
+	while (Error_Succeed != t_entity->GetEntityBase()->GetFunction()->GetPrivilegeFunction()->TryUpdateVTMERRMSG())
+		Sleep(20000);
 
+	LogEvent(Severity_High, Event_VtmLoader_GetVTMERRMSG_Suc, "Get config succeed.");
 	return 0;
 }
 DWORD checkUrlActive(LPVOID param)
@@ -1575,6 +1587,10 @@ bool CVtmLoaderFSM::GetConfig()
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR040210F13").setResultCode("RTA1F02")("Get config, TryUpdateToken failed:0x%x", eErr);
 			LogWarn(Severity_High, Error_Unexpect, VtmLoader_GetConfig_UpdateToken_Failed, CSimpleStringA::Format("拉取配置失败:0x%x(%s)", eErr, SpStrError(eErr)).GetData());
 		}
+
+		//update err msg list
+		CloseHandle(CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&errMsgListUpdate, this, 0, NULL));
+
 		//if token update failed,we can also update cfg suc
 		if (Error_Succeed != (eErr = GetEntityBase()->GetFunction()->GetPrivilegeFunction()->TryUpdateCfg()))
 		{