📄 network.cpp
字号:
{ 732123, "COL Movistar", "--" },
{ 738002, "GUY CLNK PLS", "--" },
{ 750001, "C&W FLK", "--" },
{ 2501260, "RF FAR EAST", "RU" },
};
#define NUM_OPERATORNAMES (sizeof(g_rgonmOperatorNames) / sizeof(g_rgonmOperatorNames[0]))
//
// Services
//
static const DWORD g_rgdwServices[] =
{
RIL_SERVICE_MODEM_ASYNC, // 1
RIL_SERVICE_MODEM_SYNC, // 2
RIL_SERVICE_PADACCESS_ASYNC, // 3
RIL_SERVICE_PACKETACCESS_SYNC, // 4
RIL_SERVICE_VOICE, // 5
};
#define NUM_SERVICES (sizeof(g_rgdwServices) / sizeof(DWORD))
//
// Operator status values
//
static const DWORD g_rgdwOperStats[] =
{
RIL_OPSTATUS_UNKNOWN, // 0
RIL_OPSTATUS_AVAILABLE, // 1
RIL_OPSTATUS_CURRENT, // 2
RIL_OPSTATUS_FORBIDDEN, // 3
};
#define NUM_OPERSTATS (sizeof(g_rgdwOperStats) / sizeof(DWORD))
//
// Operator formats
//
static const DWORD g_rgdwOperFormats[] =
{
RIL_OPFORMAT_LONG, // 0
RIL_OPFORMAT_SHORT, // 1
RIL_OPFORMAT_NUM, // 2
};
#define NUM_OPERFORMATS (sizeof(g_rgdwOperFormats) / sizeof(DWORD))
//
// Operator selection modes
//
static const DWORD g_rgdwOperSelModes[] =
{
RIL_OPSELMODE_AUTOMATIC, // 0
RIL_OPSELMODE_MANUAL, // 1
-1, // 2
-1, // 3
RIL_OPSELMODE_MANUALAUTOMATIC, // 4
};
#define NUM_OPSELMODES (sizeof(g_rgdwOperSelModes) / sizeof(DWORD))
//
// Comparison routine used for binary search below
//
static int _cdecl BSCompareOperatorNames(const void* pElem1, const void* pElem2)
{
int nRet;
UINT nNumericName1 = ((OPERATORNAMEMAP*)pElem1)->nNumericName;
UINT nNumericName2 = ((OPERATORNAMEMAP*)pElem2)->nNumericName;
if (nNumericName1 < nNumericName2) {
nRet = -1;
} else if (nNumericName1 == nNumericName2) {
nRet = 0;
} else {
nRet = 1;
}
return nRet;
}
//
//
//
static HRESULT ParseGetRegistrationStatus(LPCSTR szRsp, void*& pBlob, UINT& cbBlob);
static void GetLongOperatorNameEx(RILOPERATORNAMES* pronNames, DWORD dwLAC)
{
FUNCTION_TRACE(GetLongOperatorNameEx);
OPERATORNAMEMAP onmKey;
OPERATORNAMEMAP* ponmFound;
TCHAR tszLongName[MAXLENGTH_OPERATOR_LONG];
// Operator name precedence:
// 1) EONS.
// 2) EONS cache (ONLY if EONS isnt ready yet).
// 3) CPHS SIM field for HPLMN.
// 4) Value in registry, keyed by network number.
// 5) Value in hard-coded table above.
// 6) Value from radio response.
// 7) Numeric value.
BOOL fDone = FALSE;
#ifdef RIL_ENABLE_EONS
if (RIL_PARAM_ON_NUMNAME & pronNames->dwParams)
{
DWORD dwPLMN = atoi( pronNames->szNumName );
RILOPERATORNAMES ron;
memset( &ron, 0, sizeof(ron) );
/* use cache only if EONS isnt ready */
BOOL fReady = g_eons.Ready();
if ( fReady )
{
if ( dwLAC != 0xFFFFFFFF )
{
fDone = g_eons.Search( dwPLMN, dwLAC, &ron );
}
else
{
fDone = g_eons.Search( dwPLMN, &ron );
}
}
else
{
/* cached value */
if ( dwLAC != 0xFFFFFFFF )
{
fDone = g_eonscache.Search( dwPLMN, dwLAC, &ron );
}
else
{
fDone = g_eonscache.Search( dwPLMN, &ron );
}
}
if ( fDone )
{
if ( ron.dwParams & RIL_PARAM_ON_LONGNAME )
{
memcpy( pronNames->szLongName, ron.szLongName, sizeof(pronNames->szLongName) );
pronNames->dwParams |= RIL_PARAM_ON_LONGNAME;
}
if ( ron.dwParams & RIL_PARAM_ON_SHORTNAME )
{
memcpy( pronNames->szShortName, ron.szShortName, sizeof(pronNames->szShortName) );
pronNames->dwParams |= RIL_PARAM_ON_SHORTNAME;
}
if ( ron.dwParams & RIL_PARAM_ON_COUNTRY_CODE )
{
memcpy( pronNames->szCountryCode, ron.szCountryCode, sizeof(pronNames->szCountryCode) );
pronNames->dwParams |= RIL_PARAM_ON_COUNTRY_CODE;
}
}
}
#endif
/* CPHS override if EONS is not available and when registered HOME */
if(g_hNetworkResDll)
{
LANGID useid = GetUserDefaultUILanguage();
LANGID langID = GetUserDefaultLangID();
if((useid == 0x0804)&&(langID == 0x0804))
{
RETAILMSG(1, (TEXT("[TI][GetLongOperatorNameEx]we shouldnt give cphs operator name when chinese\r\n")));
}
else
{
/* CPHS override if EONS is not available and when registered HOME */
if ( !fDone && g_dwRegStatus == RIL_REGSTAT_HOME )
{
if ( g_pcszCPHS != NULL && g_pcszCPHS[0] != TEXT('\0') )
{
if(!g_bGetOperatorList )
{
strncpyz(pronNames->szLongName, g_pcszCPHS, ARRAY_LENGTH(pronNames->szLongName));
pronNames->dwParams |= RIL_PARAM_ON_LONGNAME;
fDone = TRUE;
}
}
}
}
}
// Make sure we have a numeric name
if (!fDone&&(RIL_PARAM_ON_NUMNAME & pronNames->dwParams)) {
// Now see if we have a mapping for this numeric name specified in the registry
if (GetRegistrySZ(HKEY_LOCAL_MACHINE, g_tszRegKeyOperNames, TString(pronNames->szNumName), tszLongName, MAXLENGTH_OPERATOR_LONG)) {
// Yes, we do -- use it
strncpyz(pronNames->szLongName, AnsiString(tszLongName), MAXLENGTH_OPERATOR_LONG);
pronNames->dwParams |= RIL_PARAM_ON_LONGNAME;
} else {
// Set up the key for binary search
memset(&onmKey, 0x00, sizeof(onmKey));
// It's a good idea to check the g_rgonmOperatorNames table periodically
//#define VERIFY_OPERATORNAMEMAP_TABLE
#if defined(VERIFY_OPERATORNAMEMAP_TABLE)
for(int i = 0 ; i < NUM_OPERATORNAMES-1 ; i++) {
DEBUGCHK(g_rgonmOperatorNames[i].nNumericName < g_rgonmOperatorNames[i+1].nNumericName); // Entries must be sorted
DEBUGCHK(g_rgonmOperatorNames[i].szLongName && (strlen(g_rgonmOperatorNames[i].szLongName) <= 16)); // Operator names should not exceed 16 characters
DEBUGCHK(g_rgonmOperatorNames[i].szCountryCode && (strlen(g_rgonmOperatorNames[i].szCountryCode) <= 4)); // country code should not exceed 4 characters
}
DEBUGCHK(i == NUM_OPERATORNAMES-1); // Made it to the second-to-last entry
DEBUGCHK(g_rgonmOperatorNames[i].szLongName && (strlen(g_rgonmOperatorNames[i].szLongName) <= 16)); // Operator names should not exceed 16 characters
DEBUGCHK(g_rgonmOperatorNames[i].szCountryCode && (strlen(g_rgonmOperatorNames[i].szCountryCode) <= 4)); // country code should not exceed 4 characters
#endif // defined(VERIFY_OPERATORNAMEMAP_TABLE)
// Perform binary search on the operator name map
//direct search first
onmKey.nNumericName = atoi(pronNames->szNumName);
ponmFound = (OPERATORNAMEMAP*)bsearch(&onmKey, g_rgonmOperatorNames, NUM_OPERATORNAMES, sizeof(OPERATORNAMEMAP), BSCompareOperatorNames);
if ((NULL == ponmFound) && (6 == strlen(pronNames->szNumName))) {
//handle 2 unusual PCS 1900 cases..
DWORD dwTemp;
//try the YYY0XX case first...(this needs to be done first because of proper ambiguity resolution)
onmKey.nNumericName = atoi(pronNames->szNumName);
dwTemp = onmKey.nNumericName % 100;
DEBUGCHK((0 <= dwTemp) && (100 > dwTemp));
onmKey.nNumericName -= dwTemp;
//if we now have a number divisible by 1000 (i.e. the form YYY000) then proceed
if (0 == (onmKey.nNumericName % 1000)) {
//map YYY000 to YYY00
onmKey.nNumericName /= 10;
//map YYY00 to YYYXX
onmKey.nNumericName += dwTemp;
ponmFound = (OPERATORNAMEMAP*)bsearch(&onmKey, g_rgonmOperatorNames, NUM_OPERATORNAMES, sizeof(OPERATORNAMEMAP), BSCompareOperatorNames);
}
if (NULL == ponmFound) {
//try the YYYXX0 case next...
onmKey.nNumericName = atoi(pronNames->szNumName);
//if we now have a number divisible by 10 (i.e. the form YYYXX0) then proceed
if (0 == (onmKey.nNumericName % 10)) {
//map YYYXX0 to YYYXX
onmKey.nNumericName /= 10;
ponmFound = (OPERATORNAMEMAP*)bsearch(&onmKey, g_rgonmOperatorNames, NUM_OPERATORNAMES, sizeof(OPERATORNAMEMAP), BSCompareOperatorNames);
}
}
}
if (ponmFound)
{
LANGID useid = GetUserDefaultUILanguage();
LANGID langID = GetUserDefaultLangID();
if(g_hNetworkResDll)
{
if((useid == 0x0804)&&(langID == 0x0804))
{
if(onmKey.nNumericName == 46000 || onmKey.nNumericName == 46002)
{
memset(pronNames->szLongName, 0x00, MAXLENGTH_OPERATOR_LONG);
strncpyz(pronNames->szLongName, "中国移动", MAXLENGTH_OPERATOR_LONG);
}
else if (onmKey.nNumericName == 46001)
{
memset(pronNames->szLongName, 0x00, MAXLENGTH_OPERATOR_LONG);
strncpyz(pronNames->szLongName, "中国联通", MAXLENGTH_OPERATOR_LONG);
}
else
{
memset(pronNames->szLongName, 0x00, MAXLENGTH_OPERATOR_LONG);
strncpyz(pronNames->szLongName, ponmFound->szLongName, MAXLENGTH_OPERATOR_LONG);
}
}
else
{
strncpyz(pronNames->szLongName, ponmFound->szLongName, MAXLENGTH_OPERATOR_LONG);
}
}
else
{
RETAILMSG(1, (TEXT("[TI][GetLongOperatorNameEx]g_hNetworkResDll=NULL\r\n")));
}
strncpyz(pronNames->szCountryCode, ponmFound->szCountryCode, MAXLENGTH_OPERATOR_COUNTRY_CODE);
pronNames->dwParams |= RIL_PARAM_ON_LONGNAME|RIL_PARAM_ON_COUNTRY_CODE;
}
}
// If we still don't have a long name, then fill in with the numeric name
if (!(RIL_PARAM_ON_LONGNAME & pronNames->dwParams))
{
strncpyz(pronNames->szLongName, pronNames->szNumName, MAXLENGTH_OPERATOR_LONG);
strncpyz(pronNames->szCountryCode, UNKNOWN_COUNTRY_CODE, MAXLENGTH_OPERATOR_COUNTRY_CODE);
pronNames->dwParams |= RIL_PARAM_ON_LONGNAME|RIL_PARAM_ON_COUNTRY_CODE;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -