📄 supsvc.cpp
字号:
break;
}
}
if (NUM_FWDREASONS == i) {
hr = E_INVALIDARG;
goto Error;
}
if( (RIL_FWDREASON_UNCONDITIONAL == dwReason) && (RIL_SVCSTAT_DISABLED == dwStatus))
{
dwCMDOPT |= CMDOPT_UNCONDITIONALCCFC;
}
szWalk = BeginLineSpecificCommand(szCmd, MAX_PATH, 0);
// unspecified infoclass is treated as default
if ((RIL_INFOCLASS_NONE == dwInfoClasses) || ((RIL_INFOCLASS_VOICE | RIL_INFOCLASS_DATA | RIL_INFOCLASS_FAX) == dwInfoClasses)) {
(void)_snprintfz(szWalk, MAX_PATH - (szWalk - szCmd), "+CCFC=%u,%u", nValue, (RIL_SVCSTAT_DISABLED == dwStatus ? 0 : 1));
szWalk = strchr(szWalk, '\0'); // NO_TYPO: 27
DEBUGCHK(NULL != szWalk);
} else {
for (i = 0 ; i < NUM_INFOCLASSES; i++) {
if (dwInfoClasses & g_rgdwInfoClasses[i]) {
dwClass |= (0x01 << i);
}
}
(void)_snprintfz(szWalk, MAX_PATH - (szWalk - szCmd), "+CCFC=%u,%u,,,%u", nValue,
(RIL_SVCSTAT_DISABLED == dwStatus ? 0 : 1), dwClass);
szWalk = strchr(szWalk, '\0'); // NO_TYPO: 27
DEBUGCHK(NULL != szWalk);
}
(void)strncpyz(szWalk, "\r", MAX_PATH - (szWalk - szCmd)); // NO_TYPO: 30
if (!QueueCmd(pHandle, szCmd, dwCMDOPT, APIID_SETCALLFORWARDINGSTATUS, NULL, NULL, hr)) {
hr = E_FAIL;
goto Error;
}
Error:
return hr;
}
//
//
//
static HRESULT ParseGetCallWaitingSettings(LPCSTR szRsp, void*& pBlob, UINT& cbBlob)
{
FUNCTION_TRACE(ParseGetCallWaitingSettings);
UINT i;
UINT nStatus;
UINT nValue;
DWORD* pdwInfoClasses = NULL;
HRESULT hr = S_OK;
pBlob = NULL;
cbBlob = 0;
pdwInfoClasses = (DWORD*)AllocBlob(sizeof(DWORD));
if (!pdwInfoClasses) {
hr = E_OUTOFMEMORY;
goto Error;
}
memset(pdwInfoClasses, 0x00, sizeof(DWORD));
// Parse "<prefix>"
if (!ParseRspPrefix(szRsp, szRsp)) {
hr = E_FAIL;
goto Error;
}
// Parse "+CCWA: "
while (MatchStringBeginning(szRsp, "+CCWA: ", szRsp)) {
// Parse "<status>,<class>"
if (!ParseUInt(szRsp, TRUE, nStatus, szRsp) ||
!MatchStringBeginning(szRsp, ",", szRsp) ||
!ParseUInt(szRsp, TRUE, nValue, szRsp)) {
goto Continue;
}
if (1 == nStatus) {
// Set all required info classes bits
for (i = 0 ; i < NUM_INFOCLASSES; i++) {
if (nValue & (0x01 << i)) {
*pdwInfoClasses |= g_rgdwInfoClasses[i];
}
}
}
Continue:
// Find "<postfix>"
if (!FindRspPostfix(szRsp, szRsp)) {
hr = E_FAIL;
goto Error;
}
}
pBlob = (void*)pdwInfoClasses;
cbBlob = sizeof(DWORD);
Error:
if (FAILED(hr)) {
FreeBlob(pdwInfoClasses);
}
return hr;
}
//
//
//
HRESULT RILDrv_GetCallWaitingSettings(DWORD dwParam, DWORD dwInfoClasses)
{
char szBuf[50];
UINT i;
DWORD dwClass = 0;
FUNCTION_TRACE(RILDrv_GetCallWaitingSettings);
HRESULT hr = S_OK;
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle) {
hr = E_FAIL;
goto Error;
}
// unspecified infoclass is treated as default
if ((RIL_INFOCLASS_NONE == dwInfoClasses) || ((RIL_INFOCLASS_VOICE | RIL_INFOCLASS_DATA | RIL_INFOCLASS_FAX) == dwInfoClasses)) {
strcpy(szBuf, "AT+CCWA=1,2\r");
}
else {
for (i = 0 ; i < NUM_INFOCLASSES; i++) {
if (dwInfoClasses & g_rgdwInfoClasses[i]) {
dwClass |= (0x01 << i);
}
}
sprintf(szBuf, "AT+CCWA=1,2,%u\r", dwClass);
}
if (!QueueCmd(pHandle, szBuf, CMDOPT_NONE, APIID_GETCALLWAITINGSETTINGS, ParseGetCallWaitingSettings, NULL, hr)) {
hr = E_FAIL;
goto Error;
}
Error:
return hr;
}
//
//
//
HRESULT RILDrv_SetCallWaitingStatus(DWORD dwParam, DWORD dwInfoClasses, DWORD dwStatus)
{
FUNCTION_TRACE(RILDrv_SetCallWaitingStatus);
UINT i;
DWORD dwClass = 0;
char szCmd[MAX_PATH];
LPSTR szWalk = szCmd;
HRESULT hr = S_OK;
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle) {
hr = E_FAIL;
goto Error;
}
// Check that the status value is in the correct range
if (RIL_SVCSTAT_DISABLED != dwStatus && RIL_SVCSTAT_ENABLED != dwStatus) {
hr = E_INVALIDARG;
goto Error;
}
// unspecified infoclass is treated as default
if ((RIL_INFOCLASS_NONE == dwInfoClasses) || ((RIL_INFOCLASS_VOICE | RIL_INFOCLASS_DATA | RIL_INFOCLASS_FAX) == dwInfoClasses)) {
(void)_snprintfz(szCmd, MAX_PATH, "AT+CCWA=1,%u", (RIL_SVCSTAT_DISABLED == dwStatus ? 0 : 1));
szWalk = strchr(szCmd, '\0'); // NO_TYPO: 27
DEBUGCHK(NULL != szWalk);
} else {
(void)strncpyz(szCmd, "AT", MAX_PATH);
szWalk += 2;
for (i = 0 ; i < NUM_INFOCLASSES; i++) {
if (dwInfoClasses & g_rgdwInfoClasses[i]) {
dwClass |= (0x01 << i);
}
}
(void)_snprintfz(szWalk, MAX_PATH - (szWalk - szCmd), "+CCWA=1,%u,%u", (RIL_SVCSTAT_DISABLED == dwStatus ? 0 : 1),
dwClass);
szWalk = strchr(szWalk, '\0'); // NO_TYPO: 27
DEBUGCHK(NULL != szWalk);
}
(void) strncpyz(szWalk, "\r", MAX_PATH - (szWalk - szCmd)); // NO_TYPO: 30
if (!QueueCmd(pHandle, szCmd, CMDOPT_NONE, APIID_SETCALLWAITINGSTATUS, NULL, NULL, hr)) {
hr = E_FAIL;
goto Error;
}
Error:
return hr;
}
//dongqiang add for adapt language pack,and begin sent USSD num have present
BOOL CALLBACK EnumFindUssdCallback(HWND hwnd, LPARAM lParam )
{
HWND itemhwnd = NULL;
WCHAR wszBuf[MAX_PATH] = {0};
::GetClassName(hwnd, wszBuf, MAX_PATH - 1);
if(wcsncmp(wszBuf, L"Dialog", wcslen(L"Dialog")) != 0)
{
return TRUE;
}
RETAILMSG(1, (TEXT("[TI][USSD] EnumFindUssd hwnd=[0x%08X],wszBuf=[%s]\r\n"),hwnd,wszBuf));
itemhwnd = ::GetDlgItem(hwnd, IDC_EDIT_INPUT);
RETAILMSG(1, (TEXT("[TI][USSD] EnumFindUssd itemhwnd=[0x%08X]\r\n"),itemhwnd));
if(itemhwnd == NULL)
{
return TRUE;
}
itemhwnd = ::GetDlgItem(hwnd, IDC_EDIT_MESSAGE);
RETAILMSG(1, (TEXT("[TI][USSD] EnumFindUssd itemhwnd=[0x%08X]\r\n"),itemhwnd));
if(itemhwnd == NULL)
{
return TRUE;
}
itemhwnd = ::GetDlgItem(hwnd, IDC_EDIT_IDENIFY1);
RETAILMSG(1, (TEXT("[TI][USSD] EnumFindUssd itemhwnd=[0x%08X]\r\n"),itemhwnd));
if(itemhwnd == NULL)
{
return TRUE;
}
g_hUSSDWnd = hwnd;
return FALSE;
}
BOOL EnumFindUssd()
{
RETAILMSG(1, (TEXT("[TI][USSD] EnumFindUssd \r\n")));
g_hUSSDWnd = NULL;
return EnumWindows(EnumFindUssdCallback, NULL);
}
//dongqiang add for adapt language pack,and begin sent USSD num have present end
//
// Send a USSD string.
//
// lpbData -- points to a Unicode string
// dwSize -- size (in bytes) of Unicode string
//
HRESULT RILDrv_SendSupServiceData(DWORD dwParam, const BYTE* lpbData, DWORD dwSize)
{
FUNCTION_TRACE(RILDrv_SendSupServiceData);
DEBUGCHK(NULL != lpbData);
DEBUGCHK(0 != dwSize);
DEBUGCHK(2 == sizeof(WCHAR)); // for >>1 to substitute /sizeof(WCHAR)
char szCmd[MAX_PATH+1]; // Add one to the buffer so that we can pass in the address to AppendQuotedEncodedString without Prefix error.
HRESULT hr = S_OK;
LPSTR szWalk = szCmd;
const char pszCUSDPostfix[] = ",15\r"; // 15 = default alphabet, language unspecified
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle || !lpbData) {
hr = E_FAIL;
goto Error;
}
// Use this code for +CSCS settings that don't require us to modify the data bytes (including the one in our init string)
(void)strncpyz(szWalk, "AT+CUSD=1,", MAX_PATH);
szWalk = strchr(szCmd, '\0'); // Guaranteed to succeed thanks to _strcpyz
DEBUGCHK(0 != szWalk);
// Convert the Unicode into the current TE character set.
// This copies directly into the command string buffer.
if (!AppendQuotedEncodedString(ENCODING_TECHARSET, (LPCWSTR)lpbData, szWalk, (PUCHAR)&szCmd[MAX_PATH], FALSE))
{
hr = E_FAIL;
goto Error;
}
if ( (szWalk + sizeof(pszCUSDPostfix)) > &szCmd[MAX_PATH])
{
hr = E_FAIL;
goto Error;
}
// Append the command postfix after the string we just copied
(void)strncpyz(szWalk, ",15\r", MAX_PATH - (szWalk - szCmd)); // NO_TYPO: 30
RETAILMSG(1, (TEXT("[TI][USSD] USSD number %s now will be sent \r\n"),TString(szCmd)));
if (!QueueCmd(pHandle, szCmd, CMDOPT_SUPPRESSLOGGING, APIID_SENDSUPSERVICEDATA, NULL, NULL, hr)) {
hr = E_FAIL;
goto Error;
}
//dongqiang add code for USSD that used for notify the top leveal,and "ussd daling....." would present
RETAILMSG(1, (TEXT("[TI][USSD] Begin check if the ussd app is started \r\n")));
/*HWND hUSSDWnd = FindWindow(L"Dialog", L"USSD Message");
if (NULL == hUSSDWnd)
{
if (CreateProcess(TEXT("ussd.exe"), NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL))
{
Sleep(1000);
hUSSDWnd = FindWindow(L"Dialog", L"USSD Message");
RETAILMSG(1, (TEXT("[GSM][USSD] create process ok! \r\n")));
}
}
if (hUSSDWnd != GetForegroundWindow() )
{
SendMessage(hUSSDWnd, WM_SETTEXT, (WPARAM )dwSize, (LPARAM)L"TECHFAITH_USSD_RIL_MESSAGE_DIALING");
RETAILMSG(1, (TEXT("[GSM][USSD] SendMessage to Top leve over \r\n")));
}
*/
if (!EnumFindUssd())
{
if (CreateProcess(TEXT("ussd1.exe"), NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL))
{
Sleep(1000);
if(!EnumFindUssd())
{
RETAILMSG(1, (TEXT("[TI][USSD] hUSSDWnd == NULL ,please check create ussed.exe! \r\n")));
ASSERT(0);
}
RETAILMSG(1, (L"[TI][USSD] create process ok! hUSSDWnd=[0x%08X]\r\n",g_hUSSDWnd));
}
}
if (g_hUSSDWnd != GetForegroundWindow() )
{
SendMessage(g_hUSSDWnd, WM_SETTEXT, (WPARAM )dwSize, (LPARAM)L"TECHFAITH_USSD1_RIL_MESSAGE_DIALING");
RETAILMSG(1, (L"[TI][USSD] GetForegroundWindow() hUSSDWnd=[0x%08X]\r\n",g_hUSSDWnd));
// SetForegroundWindow((HWND)(((ULONG) g_hUSSDWnd) | 0x01) );
RETAILMSG(1, (TEXT("[TI][USSD] SendMessage to Top leve over \r\n")));
}
//dongqiang add code end
Error:
return hr;
}
//
//
//
HRESULT RILDrv_CancelSupServiceDataSession(DWORD dwParam)
{
FUNCTION_TRACE(RILDrv_CancelSupServiceDataSession);
HRESULT hr = S_OK;
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle) {
hr = E_FAIL;
goto Error;
}
if (!QueueCmd(pHandle, "AT+CUSD=2\r", CMDOPT_NONE, APIID_CANCELSUPSERVICEDATASESSION, NULL, NULL, hr)) {
hr = E_FAIL;
goto Error;
}
Error:
return hr;
}
static HRESULT ParseGetHideConnectedIdSettings(LPCSTR szRsp, void*& pBlob, UINT& cbBlob)
{
FUNCTION_TRACE(ParseGetHideConnectedIdSettings);
RILHIDECONNECTEDIDSETTINGS* phcids = NULL;
HRESULT hr = S_OK;
UINT nValue;
pBlob = NULL;
cbBlob = 0;
// Parse "<prefix>%COLR: <status>"
if (!ParseRspPrefix(szRsp, szRsp) ||
!MatchStringBeginning(szRsp, "%COLR: ", szRsp)) {
hr = E_FAIL;
goto Error;
}
if ( !ParseUInt(szRsp, TRUE, nValue, szRsp) )
{
nValue = -1;
}
phcids = (RILHIDECONNECTEDIDSETTINGS*)AllocBlob(sizeof(RILHIDECONNECTEDIDSETTINGS));
if (!phcids) {
hr = E_OUTOFMEMORY;
goto Error;
}
memset(phcids, 0x00, sizeof(RILHIDECONNECTEDIDSETTINGS));
phcids->cbSize = sizeof(RILHIDECONNECTEDIDSETTINGS);
phcids->dwStatus = RIL_SVCSTAT_DEFAULT ;
switch ( nValue )
{
case -1: // COLR Status Not Present
phcids->dwProvisioning = RIL_SVCPROV_NOTPROVISIONED;
phcids->dwStatus = RIL_SVCSTAT_DISABLED ;
break;
case 0: // COLR Status Not Provided
phcids->dwProvisioning = RIL_SVCPROV_NOTPROVISIONED;
phcids->dwStatus = RIL_SVCSTAT_DISABLED ;
break;
case 1: // COLR Status Provided
phcids->dwProvisioning = RIL_SVCPROV_PROVISIONED;
phcids->dwStatus = RIL_SVCSTAT_ENABLED ;
break;
case 2: // COLR Status Unknown
phcids->dwProvisioning = RIL_SVCPROV_NOTPROVISIONED;
phcids->dwStatus = RIL_SVCSTAT_DISABLED ;
break;
default:
phcids->dwProvisioning = RIL_SVCPROV_UNKNOWN;
phcids->dwStatus = RIL_SVCSTAT_DISABLED ;
}
phcids->dwParams |= RIL_PARAM_HCIDS_PROVISIONING;
phcids->dwParams |= RIL_PARAM_HCIDS_STATUS;
pBlob = (void*)phcids;
cbBlob = sizeof(RILHIDECONNECTEDIDSETTINGS);
Error:
if (FAILED(hr)) {
FreeBlob(phcids);
}
return hr;
}
//
// Get COLR status
//
HRESULT RILDrv_GetHideConnectedIdSettings(DWORD dwParam)
{
FUNCTION_TRACE(RILDrv_GetHideConnectedIdSettings);
HRESULT hr = S_OK;
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle) {
hr = E_FAIL;
goto Error;
}
// COLR get MMI GSM 2.30
if (!QueueCmd(pHandle, "ATD*#77#;\r", CMDOPT_NONE, APIID_SENDSUPSERVICEDATA, ParseGetHideConnectedIdSettings, NULL, hr)) {
hr = E_FAIL;
goto Error;
}
Error:
return hr;
}
//
//
//
HRESULT RILDrv_SetHideConnectedIdStatus(DWORD dwParam, DWORD dwParam2)
{
FUNCTION_TRACE(RILDrv_GetHideConnectedIdSettings);
HRESULT hr = S_OK;
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle) {
hr = E_FAIL;
goto Error;
}
if ( RIL_SVCSTAT_DISABLED == dwParam2 )
{
if (!QueueCmd(pHandle, "ATD#77#;\r", CMDOPT_NONE, APIID_SENDSUPSERVICEDATA, NULL, NULL, hr)) {
hr = E_FAIL;
}
}
else if ( RIL_SVCSTAT_ENABLED == dwParam2 )
{
if (!QueueCmd(pHandle, "ATD*77#;\r", CMDOPT_NONE, APIID_SENDSUPSERVICEDATA, NULL, NULL, hr)) {
hr = E_FAIL;
}
}
else
{
hr = E_FAIL;
}
Error:
return hr;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -