📄 callctrl.cpp
字号:
/*++
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) 1995-1999 Microsoft Corporation
Module Name:
callctrl.cpp
Abstract:
Notes:
--*/
//----------------------------------------------------------------------------------------------------------------------------------------------------------
// Date Author Activity ID Activity Headline
// 2007-05-22 fengguisen CEDB200055583 add new code for cc of Cynthia850
// 2007-07-18 xiangming WM600010395 add the G/E icon function
// 2007-08-01 ningwenfeng WM600010775 卡1通话中且还有有一路卡1通话在保持中,无法发起卡2通话
// 2007-08-02 ningwenfeng WM600012171 fix a bug brought by dialpad upgrade
// 2007-08-09 wangfengli WM600012888 ril add api function for G1/G2 answer key
// 2007-08-30 wangxiaogang WM600015132 Recover some callctrl flow
// 2007-09-13 qinxuetao WM600011136 In conference call, one end can't receive voice.
// 2007-10-10 sunrenhong WM600019169 delete check audio list for new audio interface,and reject call flag can't be cleared
// 2007-10-18 Cuiguoqing WM600020042 Add a registry and write some codes for callflag icon on cynthia850_ver2.04.
// 2007-10-22 Cuiguoqing WM600020011 write some codes for modify ring tone on cynthia850_ver2.04.
// 2007-11-05 zhongchuren WM600022039 Don't allow phone off when call in progress
// 2007-11-07 qinxuetao WM600021934 fix CMUT issues
// 2007-11-09 sunrenhong WM600021853 fix bug WM600021853 WM600022398 WM600022452 WM600022456
// 2007-11-13 sunrenhong WM600022706 add the confict code for card dial and incoming problem
// 2007-11-20 sunrenhong WM600023534 fix the bug WM600023534
// 2007-11-20 qinxuetao WM600022996 Change CLCC and CHLD waiting timeout values
// 2007-11-21 zhongchuren WM600023517 Fix the issue with power On/Off
// 2007-11-26 qinxuetao WM600024004 Fix the deadlock issue while updating +CLCC times
// 2007-11-27 qinxuetao WM600024006 Change RILDrv_CC_GetCPASStatus
// 2007-11-30 sunrenhong WM600024521 resolve csd call and voice conflict and give BT interface
// 2007-12-03 sunrenhong WM600024808 Clear share memory
// 2007-12-06 Sunrenhong WM600024329 take a2dp code to ril,clcc is incoming will close atdp,and connected and release call will open a2dp
// 2007-12-07 Sunrenhong WM600025293 call shouldn't be hold when dial csd call
// 2007-12-11 Sunrenhong WM600025448 modified answer the second only call waiting code
// 2007-12-19 Sunrenhong WM600026007 disconnect csd call when dial voice call
// 2007-12-26 Cuiguoqing WM600027248 Synchronize Gallic some codes for CallSettings ring sound and script issue.
// 2007-12-27 Cuiguoqing WM600026303 Modify some codes to solve out of memory on Ring Setting in ver2.16.
// 2007-12-28 Cuiguoqing WM600027051 Modify some codes to solve the issue that user can't adjust ring level after vibrate type call in ver2.16.
// 2007-12-30 Cuiguoqing WM600026432 Modify some codes to solve ring vibrate issue in ver2.16.
// 2008-01-02 Sunrenhong WM600027714 When card1 incoming call,and accept call by card2 key,the actvie call net is wrong
// 2008-01-09 Cuiguoqing WM600028155 Modify for setting correctly default ring script to be apw3r class.
// 2008-01-24 Cuiguoqing WM600029992 Modify for ring type "a" issue.
// 2008-02-02 sunrenhong WM600030645 initialize the struct CALLCTRL_SHARE_MEMORY_OPTION
// 2008-02-25 sunrenhong WM600031812 add declare hang up the call when two card have active call
//----------------------------------------------------------------------------------------------------------------------------------------------------------
#include "precomp.h"
#include <rilbacklight.h>
#include "rilhand.h"
#include "rilproxyext_ioctl.h"
#include <wavedev.h>
#ifdef OEM1_DRIVER_WAVEXT
// Platform dependent.
#include <wavext.h>
#endif
//
// Call status values
//
static const DWORD g_rgdwCallStats[] =
{
RIL_CALLSTAT_ACTIVE, // 0
RIL_CALLSTAT_ONHOLD, // 1
RIL_CALLSTAT_DIALING, // 2
RIL_CALLSTAT_ALERTING, // 3
RIL_CALLSTAT_INCOMING, // 4
RIL_CALLSTAT_WAITING, // 5
};
#define NUM_CALLSTATS (sizeof(g_rgdwCallStats) / sizeof(DWORD))
//add by fengguisen for Simultaneous voice and data call
#define RIL_CALLSTAT_UNKNOWN (NUM_CALLSTATS+1)
//end add
#ifdef OEM1_DRIVER
extern HANDLE g_hWavDev;
#endif
#if defined(OEM1_DRIVER) || defined(OEM2_DRIVER)
extern BOOL g_bRadioOff;
#endif
//
// Call type values
//
static const DWORD g_rgdwCallTypes[] =
{
RIL_CALLTYPE_VOICE, // 0
RIL_CALLTYPE_DATA, // 1
RIL_CALLTYPE_FAX, // 2
RIL_CALLTYPE_PTT, // 3
RIL_CALLTYPE_UNKNOWN, // 4
RIL_CALLTYPE_UNKNOWN, // 5
RIL_CALLTYPE_UNKNOWN, // 6
RIL_CALLTYPE_UNKNOWN, // 7
RIL_CALLTYPE_UNKNOWN, // 8
RIL_CALLTYPE_UNKNOWN, // 9
};
#define NUM_CALLTYPES (sizeof(g_rgdwCallTypes) / sizeof(DWORD))
//
// Line status values
//
static const DWORD g_rgdwLineStats[] =
{
RIL_LINESTAT_READY, // 0
RIL_LINESTAT_UNAVAILABLE, // 1
RIL_LINESTAT_UNKNOWN, // 2
RIL_LINESTAT_RINGING, // 3
RIL_LINESTAT_CALLINPROGRESS, // 4
RIL_LINESTAT_ASLEEP, // 5
};
#define NUM_LINESTATS (sizeof(g_rgdwLineStats) / sizeof(DWORD))
// Defines an arbitrary maximum string length for the dial command.
// This maximum is not strictly enforced. It is used only as an aid
// for reporting a more specific error (RIL_E_DIALSTRINGTOOLONG) if
// the radio returns an error that is too generic.
#define MAX_DIAL_STRING_LENGTH 43
#define CALLSETTING_RING_ROOT HKEY_CURRENT_USER
#define CALLSETTING_RING_CHECK_PATH TEXT("ControlPanel\\Phone")
#define CALLSETTING_RING_CHECK_SOUND_VALUE TEXT("UserModifySound2")
#define CALLSETTING_RING_CHECK_SCRIPT_VALUE TEXT("UserModifyScript2")
BOOL g_rgfCallsInProgress[RIL_MAX_TRACKED_CALL_ID] = { FALSE }; // Initialize to FALSE
RILCALLINFO g_rgfCallStates[RIL_MAX_TRACKED_CALL_ID];
extern BOOL g_rfExternalCalltypeDetermination;
BOOL g_rgfCalltypeChecked[RIL_MAX_TRACKED_CALL_ID] = { FALSE }; // Initialize to FALSE
DWORD g_rgctCalltype[RIL_MAX_TRACKED_CALL_ID] = { 0 }; // Initialize to 0
BOOL g_rgfTCHAssigned[RIL_MAX_TRACKED_CALL_ID] ={ FALSE}; //Added for china mainland 112 call
DIALEDCALLDATA g_rcdDialedCallData;
extern CRITICAL_SECTION g_csDialedCallData;
extern RINGINGCALLDATA g_rcdRingingCallData;
extern CRITICAL_SECTION g_csRingingCallData;
extern WAITINGCALLDATA g_rcdWaitingCallData;
extern BOOL g_dwCPIStatus;
//add by fengguisen for Simultaneous voice and data call
HANDLE g_ShareMemHandle;//DMDC share memory handle
HANDLE g_ShareMemMutexHandle;//DMDC share memory Mutex Handle
LPCALLCTRL_SHARE_MEMORY g_pShareMem;//point to the share momory buffer
CALLCTRL_CID g_stDriver1CIDMap[CALLCTRL_MAX_CID] ;//call id array for local driver
HANDLE g_hCLCCOKEvent = NULL ;//clcc ok event ,only used in compose clcc mode
HANDLE g_hCHLDOKEvent =NULL;
HANDLE g_hCHLDERROEvent =NULL;
HANDLE g_hWaitCsdDisconnectEvent =NULL;
static BOOL g_bSpecIncomingCallFlag = FALSE;//flag indicate if send the SPECINCOMING notification to ExtDial
static BOOL g_bSpecShouldAnswerFlag = FALSE;//flag indicate if send SPECSHOULDANSWER notification to ExtDial
static BOOL g_bIncomingRINGFlag = FALSE;//flag indicate if had receive the CRING for local-second voice call
BOOL g_ClearSoundScript = FALSE ;
#if 0
static BOOL g_b2ndCallDisconnectFlag = FALSE;//flag indicate if received cpi:1,1 message for second voice call
#endif
static BOOL g_bSystemIDLEFlag = FALSE;//flag indicate if system startup OK,and enter IDLE state
UINT g_nGetCallListTimes = 0;//times for get call list
static BOOL g_bFakeHangUp = FALSE;//FakeHangUpFlag in Local Driver
//static BOOL g_bSpecFakeDisconnectFlag = FALSE;//flag indicate if send SPECFAKEDISCONNECT notification to ExtDial
char g_szCSDCallNumber[40] = {0};//record the csd call number:17201 or 17266
static BOOL g_bNotifyCLCC2MSFlag = TRUE;//flag indicate if need notify MS about CLCC response ,for driver 2 ,
CRITICAL_SECTION g_csUpdateCLCCTimes ; //CRITICAL SECTION for access clcc times
static BOOL g_bHangUpDialingCallFlag = FALSE;//flag indicate if system startup OK,and enter IDLE state
RILREMOTEPARTYINFO g_sCallIdTemp;
BOOL g_bBTctr_flag = FALSE;
//end add
VOID SetCalltypeFromCallInfo(RILCALLINFO *prci);
#ifdef OEM1_DRIVER_WAVEXT
static BOOL g_fInCall = FALSE;
#endif // OEM1_DRIVER_WAVEXT
// BOOL g_rgfFirstParseCLCC; // use only if g_rgfPreviousCallsInProgress and g_rgfPreviousCallStates are to be added
HRESULT RILDrv_HangUpAllCall(DWORD dwParam)
{
HRESULT hResult = S_OK;
BOOL bSendNotification = FALSE;
CNotificationData* pnd = NULL;
DWORD uCallerId = 0;
char szCmd[MAX_PATH] = {0};
CRilInstanceHandle* phHandle = ExtractHandle(dwParam);
if (!phHandle)
{
RETAILMSG(1, (TEXT("[TI]RILDrv_HangUpAllCall:invalid input param...\r\n")));
return E_FAIL;
}
for(uCallerId = 0; uCallerId < CALLCTRL_MAX_CID; uCallerId++)
{
if(g_stDriver1CIDMap[uCallerId].bUsed == TRUE)
{
if(g_stDriver1CIDMap[uCallerId].nCallType == CALL_TYPE_CSD)
{
continue;
}
memset(szCmd,0,sizeof(szCmd));
sprintf(szCmd,"AT%%CHLD=7%d\r",uCallerId + 1);
if (!QueueCmdIgnoreRsp(APIID_NONE, szCmd, CMDOPT_HANGUP, g_TimeoutAPIDefault, NULL, NULL, 0, 0, 0))
{
hResult = E_FAIL;
}
bSendNotification = TRUE;
}
}
if(bSendNotification)
{
DWORD net = (DWORD)SPECNOTIF_NETSLOT2;
Sleep(500);
phHandle->GetDevice()->BroadcastRealBlobNotification(RIL_NOTIFY_SPECHANGUP, &net, sizeof(DWORD));
}
RETAILMSG(1, (TEXT("[TI]RILDrv_HangUpAllCall:End..\r\n")));
return hResult;
}
HRESULT RILDrv_Dial(DWORD dwParam, LPCSTR szAddress, DWORD dwType, DWORD dwOptions)
{
FUNCTION_TRACE(RILDrv_Dial);
#if defined (NODIALING) && !defined (SHIP_BUILD)
bool fNoDialing;
bool fNoEmergencyDialing;
#endif // NODIALING
CNotificationData* pnd = NULL;
RILCONNECTINFO rci; memset(&rci,0,sizeof(rci)); // zero struct
char szCmd[MAX_PATH];
LPSTR szWalk = szCmd;
LPSTR szDialStringStart = NULL;
HRESULT hr = S_OK;
LPCSTR szAddrWalk = NULL;
// BOOL bTurnoffAudio = FALSE;
DWORD dwDialOpts = CMDOPT_DIAL|CMDOPT_RETRYONSIMLOCKED;
//add by fengguisen for Simultaneous voice and data call
BOOL bSendSpechangup = FALSE;
CC_OPTION stCCOption;
//end add
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle || !szAddress) {
hr = E_FAIL;
goto Error;
}
#if defined (NODIALING) && !defined (SHIP_BUILD)
// See if we want to disable dialing
if (GetRegistryBoolean(HKEY_LOCAL_MACHINE, g_tszRegKeyRIL, TEXT("NoDialing"), &fNoDialing) && fNoDialing) {
// We can't allow any dialing (for stress tests)
#ifndef SHIP_BUILD
DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : RILDrv_Dial : Dialing is prevented: %s\r\n"), TString(szAddress)));
#endif // !SHIP_BUILD
hr = E_FAIL;
goto Error;
}
// See if we want to disable emergency dialing
if (GetRegistryBoolean(HKEY_LOCAL_MACHINE, g_tszRegKeyRIL, TEXT("NoEmergencyDialing"), &fNoEmergencyDialing) &&
fNoEmergencyDialing) {
if (!strcmp(szAddress, "911") || !strcmp(szAddress, "112") || !strcmp(szAddress, "08")) {
// We can't allow dialing of emergency numbers (for stress tests)
#ifndef SHIP_BUILD
DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : RILDrv_Dial : Dialing of an emergency number is prevented: %s\r\n"), TString(szAddress)));
#endif // !SHIP_BUILD
hr = E_FAIL;
goto Error;
}
}
#endif // NODIALING
szWalk = BeginLineSpecificCommand(szCmd, MAX_PATH, 0);
switch (dwType)
{
case RIL_CALLTYPE_VOICE:
case RIL_CALLTYPE_PTT:
pnd = new CNotificationData;
if (pnd) {
rci.cbSize = sizeof(RILCONNECTINFO);
rci.dwParams = RIL_PARAM_CNI_CALLTYPE;
rci.dwCallType = dwType;
if (!pnd->InitFromRealBlob(RIL_NOTIFY_CONNECT, &rci, sizeof(RILCONNECTINFO))) {
delete pnd;
pnd = NULL;
}
}
// fall through
case RIL_CALLTYPE_DATA:
if(dwType == RIL_CALLTYPE_DATA)
{
memset(g_szCSDCallNumber,00,sizeof(g_szCSDCallNumber));
memcpy(g_szCSDCallNumber,szAddress,((strlen(szAddress) > 40) ? 40 :strlen(szAddress)));
RETAILMSG(1, (TEXT("[TI]RILDrv_Dial():CSD Call Number = %S,record CSD Number=%S\r\n"),szAddress,g_szCSDCallNumber));
}
strncpyz(szWalk,"D",MAX_PATH - (szWalk - szCmd));
break;
case RIL_CALLTYPE_FAX:
(void)strncpyz(szWalk, "+FCLASS+1;D", MAX_PATH - (szWalk - szCmd));
break;
default:
// This should have been caught in the proxy
DEBUGCHK(FALSE);
case RIL_CALLTYPE_UNKNOWN:
hr = E_INVALIDARG;
goto Error;
}
szWalk = strchr(szWalk, '\0'); // NO_TYPO: 27
DEBUGCHK(NULL != szWalk);
szDialStringStart = szWalk;
// Copy the number in
szAddrWalk = szAddress;
const char * const pcszCmdEnd = &szCmd[ ARRAY_LENGTH(szCmd)-1 ];
while( szWalk < pcszCmdEnd && *szAddrWalk != '\0' )
{
// Only allow characters in the set specified by GSM 07.07 section 6.2
if (strchr("1234567890*#+ABCD,TP!W@",*szAddrWalk))
{
*szWalk++ = *szAddrWalk;
}
szAddrWalk++;
}
// If the dial string is really long, make a note in case the
// command fails with a generic error. We can then guess that
// the real error is that the dial string was too long.
if ((szWalk - szDialStringStart) > MAX_DIAL_STRING_LENGTH)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -