📄 rilmain.cpp
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
rilmain.cpp
Abstract:
Notes:
--*/
/*------------------------------------------------------------------------------
Revision History
Date Author Activity ID Activity Headline
2005-12-09 caohongsheng CEDB00003939 Incoming Call Fire Wall and Tone
2006-02-20 wangzhengang CEDB00006684 The roaming state is not normal
2006-03-23 liuhongjie CEDB00011160 A CMCC sim card with MNC: 02, An Roaming Icon will be displayed
But in fact, it's not Roaming status.
2006-04-27 wuguangliang CEDB200000271 Reboot GSM_subsystem when RILLOG_EVENT_SIMREMOVAL is received
2006-06-16 Fuxiangbing CEDB200002792 手机插入159a卡出现漫游图标
2006-06-27 Fuxiangbing CEDB200003545 使用159号段sim卡网络信号显示为满格但是无法呼出电话
2006-07-31 Fuxiangbing CEDB200006623 无线管理器:多次打开关闭电话功能后,电话功能无法再开启
2007-01-29 XieFei CEDB200042432 modify phone book and SMS module for exporting
2007-01-26 Fanjun CEDB200041929 Add the functionality of importing short messages under dual cards condition
2007-03-30 XieFei CEDB200049615 Merge crowsbow code to cynthia850
2007-11-12 qinxuetao WM600021500 Rename RILDRIVERPRESENT_EVENT
2007-11-21 zhongchuren WM600023517 Fix the issue with power On/Off
2007-11-30 sunrenhong WM600024521 give BT interface
2008-01-16 xiangming WM600029305 add for setting the initialization of some reg
2008-01-17 qinxuetao WM600029232 Add IOCTL_RILEXT_SETEQUIPMENTSTATE to open slave card
2008-02-04 Cuiguoqing WM600030811 Add a new registry key in order to judge master card correctly for APP.
2008-02-19 Cuiguoqing WM600031498 Modify some codes in order to meet the new requirement that user can set whether select card interface has been loaded.
2008-02-27 Cuiguoqing WM600031783 Optimize codes.
2008-02-22 yingmingbo WM600030877 add IOCTL_RILEXT_GETCONTACTNAMEINFO for querying phonebook encode info
------------------------------------------------------------------------------*/
#include "precomp.h"
#include "rilhand.h"
#include "rilproxyExt_ioctl.h"
#ifdef RIL_FIX_CMCC_NETWORK_ISSUE
/*This includes the MCC and MNC ID saved in SIM*/
static DWORD s_dwSIMNetWorkID = 0;
/*The flag that requires to modify g_dwRegStatus to non-roaming status*/
static DWORD s_dwNetNetworkID = 0;
//Add by fuxiangbing 2006-07-28
BOOL g_bCIMIFlag=FALSE;
#endif
//
//Dual-card
//
extern BOOL g_SpecReady;
//
// Globals
//
CRilEventLog g_RilLog;
CRITICAL_SECTION g_csClosing;
#ifdef RIL_RADIO_RESILIENCE
extern CRITICAL_SECTION g_csReboot;
#else
HANDLE g_hCriticalErrorEvent; // = NULL;
#endif // ! RIL_RADIO_RESILIENCE
HANDLE g_hDriverPresentEvent; // = NULL;
HANDLE g_hNewDialOrHangupEvent; // = NULL;
#ifdef OEM2_DRIVER
HANDLE g_hCPINNEvent;
#endif
DWORD g_dwReadyState;
DWORD g_dwRegStatus;
DWORD g_dwGPRSRegStatus;
HINSTANCE g_hNetworkResDll = NULL; // instance handle of the network resource DLL
BOOL g_rfExternalCalltypeDetermination = FALSE;
RILCALLTYPECALLBACK g_rlpfExternalCalltypeFunction = NULL;
HINSTANCE g_hCalltypeLib = NULL;
extern RILCALLINFO g_rgfCallStates[RIL_MAX_TRACKED_CALL_ID];
extern RINGINGCALLDATA g_rcdRingingCallData;
// CS required for safe access - see RINGINGCALLDATA definition for details
CRITICAL_SECTION g_csRingingCallData;
extern DIALEDCALLDATA g_rcdDialedCallData;
// CS required for safe access - see DIALEDCALLDATA definition for details
CRITICAL_SECTION g_csDialedCallData;
extern WAITINGCALLDATA g_rcdWaitingCallData;
// No CS required for safe access - see WAITINGCALLDATA definition for details
// Storage for the SIM toolkit Terminal Profile settings
CRilSTKTerminalProfile g_RilSTKTerminalProfile;
//Wu added 2006/04/18
// CS required for safe access - see g_bIncomingCallBlockRunning
//CRITICAL_SECTION g_csIncomingcallBlock;
CRITICAL_SECTION g_csManualSearchNetwork;
//added by wuguangliang 2006/4/10
extern HANDLE g_hGetRegistrationEvent;
#ifdef RIL_LAST_ERROR
DWORD g_dwLastError; // = 0;
#endif
#ifdef OEM1_DRIVER
HANDLE g_hWavDev;
#endif
#ifdef RIL_WATSON_REPORT
// Info Cache for Watson reporting
RilInfoCache g_RilInfoCache;
CRITICAL_SECTION g_csRilInfoCache;
BOOL g_fWatsonCalled;
// In-memory buffer to capture AT Cmd logs for Watson reports.
CRilATCmdLogBuffer g_RilATCmdLogBuffer;
// Unique platform identifier used as a Watson parameter
const TCHAR* gc_szWatsonDeviceType = TEXT("Generic");
DWORD g_WatsonThreadId = NULL;
#endif
BOOL g_cphschange = FALSE;
const char *g_pcszCPHS = NULL;
#ifdef RIL_ENABLE_EONS
EONS g_eons;
EONSCache g_eonscache;
BOOL g_eonschange = FALSE;
#endif
HANDLE g_hSTKInitTI = NULL;
//dual-card:flag for exporting PB and SMS
static DWORD g_rilExtTagForPB = DUAL_CARD_EXP_PB_DEFAULT;
static BOOL rilExtTagForSMS = FALSE;
#define STKINIT_TI TEXT("TISIMToolkit/SetSTKReady/INITSTK")
DBGPARAM dpCurSettings =
{
L"RILDrv",
{
L"Error", L"Info", L"Trace", L"Function",
L"Read", L"NDIS", L"NDIS Packets", L"Undefined",
L"Undefined", L"Undefined", L"Undefined", L"Undefined",
L"Undefined", L"Undefined", L"Undefined", L"Undefined"
},
ZONEMASK_ERROR |ZONEMASK_INFO |ZONEMASK_TRACE | ZONEMASK_READ
};
//
// Stubs for unsupported RILDrv_ functions
//
#define UNSUPPORTED(n, m) \
HRESULT n m \
{ \
FUNCTION_TRACE(n); \
DEBUGMSG(ZONE_ERROR, (TEXT(#n) TEXT("RILDrv : E : : E_NOTIMPL\r\n"))); \
return E_NOTIMPL; \
}
UNSUPPORTED(RILDrv_SetDTMFMonitoring, (DWORD, BOOL));
UNSUPPORTED(RILDrv_GetAudioDevices, (DWORD));
UNSUPPORTED(RILDrv_FetchSimToolkitCmd, (DWORD));
UNSUPPORTED(RILDrv_GetCCBSStatus, (DWORD, DWORD));
UNSUPPORTED(RILDrv_ClearCCBSRegistration, (DWORD, DWORD));
UNSUPPORTED(RILDrv_GetSystemTime, (DWORD));
UNSUPPORTED(RILDrv_GetPacketByteCount, (DWORD));
UNSUPPORTED(RILDrv_ResetPacketByteCount, (DWORD));
UNSUPPORTED(RILDrv_SendFlash, (DWORD, RILADDRESS));
UNSUPPORTED(RILDrv_GetRoamingMode, (DWORD));
UNSUPPORTED(RILDrv_SetRoamingMode, (DWORD, DWORD));
UNSUPPORTED(RILDrv_GetPreferredPrivacyMode, (DWORD));
UNSUPPORTED(RILDrv_SetPreferredPrivacyMode, (DWORD, DWORD));
UNSUPPORTED(RILDrv_GetCurrentPrivacyStatus, (DWORD));
UNSUPPORTED(RILDrv_GetCurrentLocationStatus, (DWORD));
UNSUPPORTED(RILDrv_GetCurrentRoamingStatus, (DWORD));
UNSUPPORTED(RILDrv_SendAKey, (DWORD, LPCSTR));
#ifndef SCI_OLD
BOOL g_bSciNoMenuVersion = FALSE;
extern void SetSimCacheState( BOOL bCache );
#endif
//Begin. ___added for importing short messages under dual cards condition.
static void Set_RilExtTagForSMS(BOOL status)
{
rilExtTagForSMS = status;
}
BOOL Get_RilExtTagForSMS(void)
{
return rilExtTagForSMS;
}
//End. ___added for importing short messages under dual cards condition.
//add for exporting PB in DC
// g2_rilExtTag == FALSE--->MS get phonebook options
// g2_rilExtTag == TRUE--->ExAPP get phonebook options
void Set_RilExtTagForPB(DWORD status)
{
g_rilExtTagForPB = status;
}
DWORD Get_RilExtTagForPB(void)
{
return g_rilExtTagForPB;
}
//
// DLL entry point
//
BOOL WINAPI DllMain(HANDLE hinstDll, DWORD dwReason, LPVOID lpReserved)
{
g_hNetworkResDll = (HINSTANCE)hinstDll;
if (DLL_PROCESS_ATTACH == dwReason)
{
g_RilLog.Register();
DEBUGREGISTER((HMODULE) hinstDll);
DEBUGMSG(ZONE_TRACE, (TEXT("RILDrv : t : DllMain : DLL_PROCESS_ATTACH\r\n")));
}
else if (DLL_PROCESS_DETACH == dwReason)
{
g_RilLog.Unregister();
DEBUGMSG(ZONE_TRACE, (TEXT("RILDrv : t : DllMain : DLL_PROCESS_DETACH\r\n")));
}
return TRUE;
}
#ifdef RIL_ALLOW_DRIVER_REMOVAL_TESTING
CRilHandle * g_pDeviceAllowDriverRemovalTesting = NULL;
#define DRIVERCOOKIE_FROM_RILHANDLE(pDevice) (DWORD)(g_pDeviceAllowDriverRemovalTesting = pDevice)
#define RILHANDLE_FROM_DRIVERCOOKIE(dwData) (g_pDeviceAllowDriverRemovalTesting)
#else
#define DRIVERCOOKIE_FROM_RILHANDLE(pDevice) (DWORD)pDevice;
#define RILHANDLE_FROM_DRIVERCOOKIE(dwData) (CRilHandle*)dwData;
#endif
#ifdef RIL_FIX_CMCC_NETWORK_ISSUE
/*Save MCC and MNC ID saved in SIM Card*/
void SetMCCMNCIdInSim(DWORD dwId)
{
g_bCIMIFlag=TRUE;
s_dwSIMNetWorkID = dwId;
}
DWORD GetMCCMNCIdInSim(void)
{
return s_dwSIMNetWorkID;
}
/*Get MCC and MNC ID saved on Network*/
DWORD GetMCCMNCIdOnNetwork(void)
{
return s_dwNetNetworkID;
}
/*Save MCC and MNC ID saved on Network*/
void SetMCCMNCIdOnNetwork(DWORD dwId)
{
s_dwNetNetworkID = dwId;
}
/*Get Network issue flag with CMCC*/
DWORD GetFixRegStatusFlag(void)
{
if(s_dwSIMNetWorkID == 46002)
{
if(46000== s_dwNetNetworkID)
{
return 1;
}
else
{
return 0;
}
}
return 0;
}
#endif
//
// RIL driver initialization
//
DWORD RLO_Init(DWORD dwInfo)
{
FUNCTION_TRACE(RLO_Init);
DEBUGMSG(ZONE_TRACE, (TEXT("RILDrv : t : RLO_Init : params: dwInfo = %d\r\n"), dwInfo));
RETAILMSG(1, (TEXT("[TI]>>>>>>enter RLO_Init..........................")));
CRilHandle* pDevice = NULL;
DWORD dwRet = 0;
#ifdef OEM1_DRIVER
HANDLE hThread = NULL;
#endif
// Initialize globals
InitializeCriticalSection(&g_csClosing);
#ifdef RIL_RADIO_RESILIENCE
InitializeCriticalSection(&g_csReboot);
memset(&g_LastResetTime, 0, sizeof(g_LastResetTime));
#else
g_hCriticalErrorEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (!g_hCriticalErrorEvent)
{
goto Error;
}
#endif // ! RIL_RADIO_RESILIENCE
#ifdef RIL_WATSON_REPORT
InitializeCriticalSection(&g_csRilInfoCache);
#endif // RIL_WATSON_REPORT
#if defined(OEM1_GPRS_DEACT)
InitializeCriticalSection(&g_csGPRSDeactLock);
#endif // OEM1_GPRS_DEACT
InitializeCriticalSection(&g_csDeactCringLock);
g_hDriverPresentEvent = CreateEvent(NULL, TRUE, FALSE, TI_RILDRIVERPRESENT_EVENT);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -