📄 misc.cpp
字号:
HRESULT RILDrv_GetEquipmentState(DWORD dwParam)
{
FUNCTION_TRACE(RILDrv_GetEquipmentState);
HRESULT hr = S_OK;
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle) {
hr = E_FAIL;
goto Error;
}
if (!QueueCmd(pHandle, "AT+CFUN?\r", CMDOPT_IGNORERADIOOFF, APIID_GETEQUIPMENTSTATE, ParseGetEquipmentState, NULL, hr)) {
hr = E_FAIL;
goto Error;
}
Error:
return hr;
}
//
//
//
HRESULT RILDrv_SetEquipmentState(DWORD dwParam, DWORD dwEquipmentState)
{
FUNCTION_TRACE(RILDrv_SetEquipmentState);
DEBUGCHK(NUM_EQSTATES > dwEquipmentState);
DWORD dwCmdOpt = CMDOPT_NONE;
char szCmd[MAX_PATH];
HRESULT hr = S_OK;
CNotificationData * pnd = NULL;
RILEQUIPMENTSTATE res;
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle) {
hr = E_FAIL;
goto Error;
}
// Don't allow equipment states that would overrun the array.
if ( dwEquipmentState >= NUM_EQSTATES )
{
hr = E_INVALIDARG;
goto Error;
}
if (RIL_EQSTATE_UNKNOWN == dwEquipmentState) {
hr = E_INVALIDARG;
goto Error;
}
FillEquipmentStateStruct(&res, dwEquipmentState);
if (res.dwRadioSupport == RIL_RADIOSUPPORT_OFF)
{
// We'll be turning the radio off
res.dwReadyState = 0;
g_dwGPRSRegStatus = RIL_REGSTAT_UNKNOWN;
g_dwRegStatus = RIL_REGSTAT_UNKNOWN;
#ifdef RIL_WATSON_REPORT
// Reset registration status in info cache.
g_RilInfoCache.dwRegStatus = RIL_REGSTAT_UNKNOWN;
g_RilInfoCache.dwGPRSRegStatus = RIL_REGSTAT_UNKNOWN;
#endif // RIL_WATSON_REPORT
}
//dual-card:if it is not a primary card do not send the notifycation
extern BOOL IsPrimaryCard();
if (IsPrimaryCard())
{
pnd = new CNotificationData;
if (pnd && !pnd->InitFromRealBlob(RIL_NOTIFY_RADIOEQUIPMENTSTATECHANGED, (void*)&res, res.cbSize))
{
delete pnd;
pnd = NULL;
}
}
// If this command will turn on the radio, then
// note this in the command option. If this option
// is not set for the SETEQUIPMENTSTATE command,
// then it is assumed that it turns off the radio.
if (RIL_RADIOSUPPORT_ON == res.dwRadioSupport)
{
dwCmdOpt |= CMDOPT_SETRADIOON;
#if defined(WAVECOM_DRIVER) || defined(OEM1_DRIVER) || defined(OEM2_DRIVER)
// HW-SPECIFIC: WaveCom hardware always resets after AT+CFUN=<n>
dwCmdOpt |= CMDOPT_REINIT;
#endif // WAVECOM_DRIVER
#ifdef OEM2_DRIVER
if (FALSE == g_bRadioOff)
{
// The radio is already on, no need to turn it on again, particularly since we won't get the CPINN
// notification again, and this will cause the command thread to time out waiting for it.
dwCmdOpt |= CMDOPT_NOOP;
}
#endif
}
// This command is OK to send, even if the radio is "off".
dwCmdOpt |= CMDOPT_IGNORERADIOOFF;
// Set a registry key to save the new state of the radio in a location that persists across rebooting
(void)SetRegistryDWORD(RIL_LAST_EQUIPMENT_STATE_ROOT, RIL_LAST_EQUIPMENT_STATE_KEY, RIL_LAST_EQUIPMENT_STATE_VALUE, dwEquipmentState);
//#ifdef RIL_RADIO_RESILIENCE
//save the new state of the radio that persists across rebooting
g_dwEquipmentState = dwEquipmentState;
//#endif
#if defined(RIL_ENABLE_SIMTK) && defined(OEM1_DRIVER)
if (dwCmdOpt & CMDOPT_SETRADIOON)
{
// We must send the terminal profile string along when we turn on the radio
// modify config
(void)_snprintfz(szCmd, MAX_PATH, "AT%%SATC=1,0961FF7F00000010;+CFUN=%u\r", g_rgdwEquipmentStates[dwEquipmentState]);
}
else
#endif
{
#if defined(OEM1_DRIVER) || defined(OEM2_DRIVER)
if(RIL_EQSTATE_MINIMUM == dwEquipmentState)
{
// When turning the radio off, first force a GPRS detach in case the radio doesn't do so automatically
DEBUGCHK(0 == g_rgdwEquipmentStates[dwEquipmentState]);
#ifdef OEM1_DRIVER
#ifdef DISPLAY_SPN
(void)SetRegistrySZ(HKEY_LOCAL_MACHINE, TEXT("System\\CardInfo\\Card2"), TEXT("SPNNAME"), TEXT(""));
#endif
(void)_snprintfz(szCmd, MAX_PATH, "AT+CFUN=0\r");
#ifdef RIL_FIX_CMCC_NETWORK_ISSUE
//Add by Fuxiangbing 2006-07-28
if(!g_bCIMIFlag)
{
QueueCmdIgnoreRsp(APIID_NONE, "AT+CIMI\r", CMDOPT_SUPPRESSLOGGING | CMDOPT_IGNORERADIOOFF, g_TimeoutCmdInit, ParseGetUserIdentity, NULL, 0, 0, 0);
}
#endif
#else
(void)_snprintfz(szCmd, MAX_PATH, "AT+CGATT=0;+CFUN=0\r");
#endif // OEM1_DRIVER
}
else
#endif // defined(OEM1_DRIVER) || defined(OEM2_DRIVER)
{
// Generic +CFUN command
(void)_snprintfz(szCmd, MAX_PATH, "AT+CFUN=%u\r", g_rgdwEquipmentStates[dwEquipmentState]);
}
}
//add by likai for net state 200703012
if(0 == g_rgdwEquipmentStates[dwEquipmentState])
{
dwCmdOpt |= CMDOPT_FLYMOD;
}
else if(1 == g_rgdwEquipmentStates[dwEquipmentState])
{
dwCmdOpt |= CMDOPT_ONLINE;
}
//add end likai
if (!QueueCmd(pHandle, szCmd, dwCmdOpt, APIID_SETEQUIPMENTSTATE, NULL, pnd, hr)) {
hr = E_FAIL;
goto Error;
}
Error:
if(FAILED(hr))
{
delete pnd;
}
return hr;
}
//
//
//
HRESULT ParseGetPhonebookOptions(LPCSTR szRsp, void*& pBlob, UINT& cbBlob)
{
FUNCTION_TRACE(ParseGetPhonebookOptions);
UINT i;
UINT nValue;
char szLocation[MAX_PATH];
RILPHONEBOOKINFO* prpbi = NULL;
HRESULT hr = S_OK;
pBlob = NULL;
cbBlob = 0;
prpbi = (RILPHONEBOOKINFO*)AllocBlob(sizeof(RILPHONEBOOKINFO));
if (!prpbi) {
hr = E_OUTOFMEMORY;
goto Error;
}
memset(prpbi, 0x00, sizeof(RILPHONEBOOKINFO));
prpbi->cbSize = sizeof(RILPHONEBOOKINFO);
// Parse "<prefix>+CPBS: <storage>"
if (!ParseRspPrefix(szRsp, szRsp) ||
!MatchStringBeginning(szRsp, "+CPBS: ", szRsp) ||
!ParseString(szRsp, szLocation, MAX_PATH, szRsp)) {
hr = E_FAIL;
goto Error;
}
for (i = 0; i < NUM_PBLOCS; i++) {
if (!strcmp(szLocation, g_rgszPBLocations[i])) {
prpbi->dwStoreLocation = i;
break;
}
}
if (NUM_PBLOCS == i) {
// We couldn't match the response with anything
prpbi->dwStoreLocation = RIL_PBLOC_UNKNOWN;
}
prpbi->dwParams |= RIL_PARAM_PBI_STORELOCATION;
// Parse ","
if (MatchStringBeginning(szRsp, ",", szRsp)) {
// Parse "<used>"
if (!ParseUInt(szRsp, TRUE, nValue, szRsp)) {
hr = E_FAIL;
goto Error;
}
if((Get_RilExtTagForPB() == DUAL_CARD_EXP_PB_EXAPP))
{
RETAILMSG(1,(TEXT("[TI]RILDrv_GetPhonebBOOKoption ExApp required\r\n")));
Set_RilExtTagForPB(DUAL_CARD_EXP_PB_DEFAULT);
}
else
{
nValue = 0;
RETAILMSG(1,(TEXT("[TI]RILDrv_GetPhonebBOOKoption MS or Default required\r\n")));
if((Get_RilExtTagForPB() == DUAL_CARD_EXP_PB_MS) || (TRUE == g_bChangedPrimaryCard) )
{
extern BOOL ChangePBSMSRegState(DWORD dwAddingState, BOOL bClean);
Set_RilExtTagForPB(DUAL_CARD_EXP_PB_DEFAULT);
(void)ChangePBSMSRegState(RIL_SMSPB_START, FALSE);
g_bChangedPrimaryCard = FALSE;
RETAILMSG(1,(TEXT("[TI]RILDrv_GetPhonebBOOKoption MS required\r\n")));
}
}
prpbi->dwUsed = nValue;
prpbi->dwParams |= RIL_PARAM_PBI_USED;
// Parse ",<total>"
if (!MatchStringBeginning(szRsp, ",", szRsp) ||
!ParseUInt(szRsp, TRUE, nValue, szRsp)) {
hr = E_FAIL;
goto Error;
}
#if defined(OEM1_DRIVER)
// This hardware seems to have a problem reading the 255th entry
// in the SIM phone book (it crashes). Therefore, do not report the
// existance of this entry to the caller.
if (255 == nValue) {
--nValue;
}
#endif
prpbi->dwTotal = nValue;
prpbi->dwParams |= RIL_PARAM_PBI_TOTAL;
}
// Parse "<postfix>"
if (!ParseRspPostfix(szRsp, szRsp)) {
hr = E_FAIL;
goto Error;
}
pBlob = (void*)prpbi;
cbBlob = sizeof(RILPHONEBOOKINFO);
RETAILMSG(1,(TEXT("[TI][PhoneBook] prpbi->dwUsed =%d \r\n"), prpbi->dwUsed));
Error:
if (FAILED(hr)) {
FreeBlob(prpbi);
}
return hr;
}
//
//
//
HRESULT RILDrv_GetPhonebookOptions(DWORD dwParam)
{
FUNCTION_TRACE(RILDrv_GetPhonebookOptions);
HRESULT hr = S_OK;
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle) {
hr = E_FAIL;
goto Error;
}
if (!Get_RilExtTagForPB())
{
RETAILMSG(1,(TEXT("[TI]send RILDrv_GetPhonebBOOKoption MS required\r\n")));
}
else
{
RETAILMSG(1,(TEXT("[TI] send RILDrv_GetPhonebBOOKoption AppEx required\r\n")));
}
if (!QueueCmd(pHandle, "AT+CPBS?\r", CMDOPT_NONE, APIID_GETPHONEBOOKOPTIONS, ParseGetPhonebookOptions, NULL, hr)) {
hr = E_FAIL;
goto Error;
}
Error:
return hr;
}
//
//
//
HRESULT RILDrv_SetPhonebookOptions(DWORD dwParam, const RILPHONEBOOKINFO* lpPhonebookInfo)
{
FUNCTION_TRACE(RILDrv_SetPhonebookOptions);
CNotificationData* pnd = NULL;
char szCmd[MAX_PATH];
HRESULT hr = S_OK;
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle || !lpPhonebookInfo) {
hr = E_FAIL;
goto Error;
}
// Store location must be specified
if (!(lpPhonebookInfo->dwParams & RIL_PARAM_PBI_STORELOCATION)) {
hr = E_INVALIDARG;
goto Error;
}
// Store location index must be in the valid range
DEBUGCHK(NUM_PBLOCS > lpPhonebookInfo->dwStoreLocation);
if (RIL_PBLOC_UNKNOWN == lpPhonebookInfo->dwStoreLocation) {
hr = E_INVALIDARG;
goto Error;
}
pnd = new CNotificationData;
if (pnd && !pnd->InitFromDWORDBlob(RIL_NOTIFY_PHONEBOOKSTORAGECHANGED, lpPhonebookInfo->dwStoreLocation)) {
delete pnd;
pnd = NULL;
}
(void)_snprintfz(szCmd, MAX_PATH, "AT+CPBS=\"%s\"\r", g_rgszPBLocations[lpPhonebookInfo->dwStoreLocation]);
if (!QueueCmd(pHandle, szCmd, CMDOPT_NONE, APIID_SETPHONEBOOKOPTIONS, NULL, pnd, hr)) {
hr = E_FAIL;
goto Error;
}
pnd = NULL;
#ifdef RIL_RADIO_RESILIENCE
g_fPBLocationSet = TRUE;
(void)strncpyz(g_szPBLocCmd, szCmd, ARRAYSIZE(g_szPBLocCmd));
#endif // RIL_RADIO_RESILIENCE
Error:
return hr;
}
#if defined(OEM1_DRIVER) || defined(OEM2_DRIVER)
static void ConvertDTMFControlDigitSeparatorCharacter(LPWSTR szAddress)
{
ASSERT(NULL != szAddress);
WCHAR ch;
while (L'\0' != (ch = *szAddress))
{
if (L'W' == ch || L'w' == ch)
*szAddress = L'p';
++szAddress;
}
}
#endif
//
//
//
static HRESULT ParseArrayOfPhonebookEntries(LPCSTR szCmd, LPCSTR szRsp, void*& pBlob, UINT& cbBlob)
{
FUNCTION_TRACE(ParseArrayOfPhonebookEntries);
UINT nValue;
UINT nUsed = 0;
UINT nAllocated = 0;
char szAddress[MAXLENGTH_ADDRESS];
WCHAR wszText[MAXLENGTH_PHONEBOOKTEXT];
RILPHONEBOOKENTRY* rgrbpe = NULL;
HRESULT hr = S_OK;
pBlob = NULL;
cbBlob = 0;
// Parse "<prefix>"
if (!ParseRspPrefix(szRsp, szRsp)) {
hr = E_FAIL;
goto Error;
}
// Parse "<command>"
while (MatchStringBeginning(szRsp, szCmd, szRsp)) {
if (nUsed == nAllocated) {
if (!AllocateOrReallocateStorage((BYTE**)&rgrbpe, sizeof(RILPHONEBOOKENTRY), nUsed, &nAllocated, MISC_ALLOC_NUMBER)) {
hr = E_OUTOFMEMORY;
goto Error;
}
}
memset(&rgrbpe[nUsed], 0x00, sizeof(RILPHONEBOOKENTRY));
rgrbpe[nUsed].cbSize = sizeof(RILPHONEBOOKENTRY);
// Parse "<index>"
if (!ParseUInt(szRsp, TRUE, nValue, szRsp)) {
goto Continue;
}
rgrbpe[nUsed].dwIndex = nValue;
rgrbpe[nUsed].dwParams |= RIL_PARAM_PBE_INDEX;
// clear buffer before reusing
memset(szAddress, 0x00, sizeof(szAddress));
// Parse ",<number>,<type>"
if (!MatchStringBeginning(szRsp, ",", szRsp) ||
!ParseString(szRsp, szAddress, MAXLENGTH_ADDRESS, szRsp) ||
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -