Przeglądaj źródła

Z991239-6340 #comment 优化密码键盘StopInput逻辑,在调用StartPinInput成功之后才调用

oilyang 4 miesięcy temu
rodzic
commit
21cf40afec
2 zmienionych plików z 34 dodań i 39 usunięć
  1. 32 37
      Module/mod_pinpad/PinPadFSM.cpp
  2. 2 2
      Module/mod_pinpad/PinPadFSM.h

+ 32 - 37
Module/mod_pinpad/PinPadFSM.cpp

@@ -41,21 +41,9 @@ ErrorCodeEnum CPinPadFSM::OnExit()
 	LOG_FUNCTION();
 	m_bEntityExit = true;
 	m_hInputConVar.Broadcast();
-	ErrorCodeEnum eErr = Error_Succeed;
 	if (m_hDevHelper != nullptr)
-	{
-		m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
-		ErrorCodeEnum errClosePinPad = m_hDevHelper->StopInput();
-		m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
-		if (errClosePinPad != Error_Succeed)
-		{
-			DWORD dwUserCode = SetErrorAndLog(errClosePinPad, MEC_DEVAPI_EPP_StopInput, "DevAdapter::StopInput", __FUNCTION__, IsInBusiness(), m_ullEndTime - m_ullBeginTime);
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("DevAdapter::StopInput").setCostTime(m_ullEndTime - m_ullBeginTime)
-				.setResultCode(GetEntityBase()->GetFunction()->UserCodeToRTACode(dwUserCode))("OnExit:close pinpad(%d).", SpStrError(errClosePinPad));
-		}
 		m_hDevHelper.TearDown();
-	}
-	return eErr;
+	return Error_Succeed;
 }
 void CPinPadFSM::s0_on_entry()
 {
@@ -687,6 +675,7 @@ ErrorCodeEnum CPinPadFSM::GetEncryptText(SpReqAnsContext<PinPadService_GetInputS
 		ctxSM->Answer(Error_DevCommFailed, dwUserCode);
 		return Error_DevCommFailed;
 	}
+	m_bStartPinInputOK = true;
 	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::StartPinInput").setCostTime(m_ullEndTime - m_ullBeginTime)();
 	DbgToBeidou(ctxSM->link, "GetEncryptText")();
 	char* buf = new char[len + 1];
@@ -942,20 +931,23 @@ int CPinPadFSM::GetInput(SpReqAnsContext<PinPadService_GetInputSM_Req, PinPadSer
 	ULLINT ullGetInputBegin = SP::Module::Comm::RVCGetTickCount();
 	ErrorCodeEnum eErrCode = GetEncryptText(m_inputSMCtx);
 
-	m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
-	ErrorCodeEnum errClosePinPad = m_hDevHelper->StopInput();
-	m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
-	if (errClosePinPad != Error_Succeed)
+	if (m_bStartPinInputOK)
 	{
-		DWORD dwUserCode = SetErrorAndLog(errClosePinPad, MEC_DEVAPI_EPP_StopInput, "DevAdapter::StopInput", __FUNCTION__, IsInBusiness(), m_ullEndTime - m_ullBeginTime, PinPadService_LogCode_GetInputSM);
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("DevAdapter::StopInput").setCostTime(m_ullEndTime - m_ullBeginTime)
-			.setResultCode(GetEntityBase()->GetFunction()->UserCodeToRTACode(dwUserCode))("OnExit:close pinpad(%d).", SpStrError(errClosePinPad));
+		m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
+		ErrorCodeEnum errClosePinPad = m_hDevHelper->StopInput();
+		m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
+		if (errClosePinPad != Error_Succeed)
+		{
+			DWORD dwUserCode = SetErrorAndLog(errClosePinPad, MEC_DEVAPI_EPP_StopInput, "DevAdapter::StopInput", __FUNCTION__, IsInBusiness(), m_ullEndTime - m_ullBeginTime, PinPadService_LogCode_GetInputSM);
+			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("DevAdapter::StopInput").setCostTime(m_ullEndTime - m_ullBeginTime)
+				.setResultCode(GetEntityBase()->GetFunction()->UserCodeToRTACode(dwUserCode))("OnExit:close pinpad(%d).", SpStrError(errClosePinPad));
+		}
+		else
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::StopInput").setCostTime(m_ullEndTime - m_ullBeginTime)
+			("StopInput cost:%llu(ms), req acc.len:%d,confirm:%d,len:%d. ans:ck.len:%d", m_ullEndTime - m_ullBeginTime, m_inputSMCtx->Req.account.GetLength(), m_inputSMCtx->Req.confirm
+				, m_inputSMCtx->Req.length, m_inputSMCtx->Ans.checkcode.IsNullOrEmpty() ? 0 : m_inputSMCtx->Ans.checkcode.GetLength());
+		m_bStartPinInputOK = false;
 	}
-	else
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::StopInput").setCostTime(m_ullEndTime - m_ullBeginTime)
-		("StopInput cost:%llu(ms), req acc.len:%d,confirm:%d,len:%d. ans:ck.len:%d", m_ullEndTime - m_ullBeginTime, m_inputSMCtx->Req.account.GetLength(), m_inputSMCtx->Req.confirm
-			, m_inputSMCtx->Req.length, m_inputSMCtx->Ans.checkcode.IsNullOrEmpty() ? 0 : m_inputSMCtx->Ans.checkcode.GetLength());
-
 	DbgToBeidou(m_inputSMCtx->link, "GetInput")();
 	m_bPinInput = false;
 	LogEvent(Severity_Middle, LOG_EVT_PINPAD_GREEN_OFF, "PinPad light off.");
@@ -1395,6 +1387,7 @@ ErrorCodeEnum CPinPadFSM::GetEncryptTextJS(SpReqAnsContext<PinPadService_GetInpu
 		ctxJS->Answer(Error_DevCommFailed, dwUserCode);
 		return Error_DevCommFailed;
 	}
+	m_bStartPinInputOK = true;
 	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::StartPinInput").setCostTime(m_ullEndTime - m_ullBeginTime)();
 	DbgToBeidou(ctxJS->link, "GetEncryptTextJS")();
 	char* buf = new char[CurrentPasswordLen + 1];
@@ -1592,20 +1585,22 @@ int CPinPadFSM::GetInputJS(SpReqAnsContext<PinPadService_GetInputJS_Req, PinPadS
 	ULLINT ullGetInputBegin = SP::Module::Comm::RVCGetTickCount();
 	ErrorCodeEnum eErrCode = GetEncryptTextJS(m_inputJSCtx);
 
-	m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
-	ErrorCodeEnum errClosePinPad = m_hDevHelper->StopInput();
-	m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
-	if (errClosePinPad != Error_Succeed)
+	if (m_bStartPinInputOK)
 	{
-		DWORD dwUserCode = SetErrorAndLog(errClosePinPad, MEC_DEVAPI_EPP_StopInput, "DevAdapter::StopInput", __FUNCTION__, IsInBusiness(), m_ullEndTime - m_ullBeginTime, PinPadService_LogCode_GetInputSM);
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("DevAdapter::StopInput").setCostTime(m_ullEndTime - m_ullBeginTime)
-			.setResultCode(GetEntityBase()->GetFunction()->UserCodeToRTACode(dwUserCode))("OnExit:close pinpad(%d).", SpStrError(errClosePinPad));
+		m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
+		ErrorCodeEnum errClosePinPad = m_hDevHelper->StopInput();
+		m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
+		if (errClosePinPad != Error_Succeed)
+		{
+			DWORD dwUserCode = SetErrorAndLog(errClosePinPad, MEC_DEVAPI_EPP_StopInput, "DevAdapter::StopInput", __FUNCTION__, IsInBusiness(), m_ullEndTime - m_ullBeginTime, PinPadService_LogCode_GetInputSM);
+			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("DevAdapter::StopInput").setCostTime(m_ullEndTime - m_ullBeginTime)
+				.setResultCode(GetEntityBase()->GetFunction()->UserCodeToRTACode(dwUserCode))("OnExit:close pinpad(%d).", SpStrError(errClosePinPad));
+		}
+		else
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::StopInput").setCostTime(m_ullEndTime - m_ullBeginTime)
+			("StopInput cost:%llu(ms), req acc.len:%d,ans.ck.len:%d", m_ullEndTime - m_ullBeginTime, m_inputJSCtx->Req.account.GetLength(), m_inputJSCtx->Ans.checkcode.IsNullOrEmpty() ? 0 : m_inputJSCtx->Ans.checkcode.GetLength());
+		m_bStartPinInputOK = false;
 	}
-	else
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::StopInput").setCostTime(m_ullEndTime - m_ullBeginTime)
-		("StopInput cost:%llu(ms), req acc.len:%d,ans.ck.len:%d", m_ullEndTime - m_ullBeginTime, m_inputJSCtx->Req.account.GetLength(), m_inputJSCtx->Ans.checkcode.IsNullOrEmpty() ? 0 : m_inputJSCtx->Ans.checkcode.GetLength()
-			);
-		
 	DbgToBeidou(m_inputJSCtx->link, "GetInputJS")();
 	m_bPinInputJS = false;
 	LogEvent(Severity_Middle, LOG_EVT_PINPAD_GREEN_OFF, "PinPad light off.");

+ 2 - 2
Module/mod_pinpad/PinPadFSM.h

@@ -169,7 +169,7 @@ public:
 		END_FSM_RULE()
 
 		CPinPadFSM() : m_bFrontCancel(false),
-		m_bWaitingMore(false), m_bExit(false), m_bPlainPin(true),
+		m_bWaitingMore(false), m_bExit(false), m_bPlainPin(true), m_bStartPinInputOK(false),
 		m_bEntityExit(false), m_bPinInput(false), m_bLoadKey(false), m_bEncrypt(false)
 		, m_dwDevCommFailCount(0), m_dwPinPadRunCount(0), m_encryptkey(1)
 		, m_bSM(false), m_bSMLoaded(false), m_szModel(""), m_szType("")
@@ -284,7 +284,7 @@ private:
 	SpReqAnsContext<PinPadService_GetInputSM_Req, PinPadService_GetInputSM_Ans>::Pointer m_inputSMCtx;
 	SpReqAnsContext<PinPadService_GetInputJS_Req, PinPadService_GetInputJS_Ans>::Pointer m_inputJSCtx;
 	char m_szAccount[MAX_ACCOUNT_LEN];
-	bool m_bFrontCancel,m_bWaitingMore,m_bExit,m_bPlainPin,m_bEntityExit
+	bool m_bFrontCancel,m_bWaitingMore,m_bExit,m_bPlainPin,m_bEntityExit, m_bStartPinInputOK
 		,m_bPinInput,m_bLoadKey,m_bEncrypt,m_bSM,m_bSMLoaded, m_bPinInputJS, m_bUseBackupSN/*if use backup sn*/, m_bSetParamOnce/*call SetParam Only once*/;
 	ULLINT m_ullBeginTime, m_ullEndTime, m_ullAdpFileLoadCost, m_ullEntityStart;
 	CSimpleStringA m_deviceNo, m_devCheckData,m_keySNSM,m_szModel,m_szType,m_szVendor;