Introduction
Most of time we got annoying calls from annoying Pepole in mid night or work time
so what we can do to ignore this case ? we can buy Application from Store to do this ,but wait why you have to buy if you can devlope custom by you
Background
In This Application I will Highlight RIL (Radio interface Layer).
The Radio Interface Layer (RIL) provides an interface that handles the communication between the CellCore system software and the radio hardware. The RIL provides an abstraction layer that enables you to create a single driver that can be implemented on different radios. The RIL abstracts the details of the hardware dependent components of a device to enable OEMs to integrate a variety of modems into their equipment, offering an opportunity for product differentiation. This single driver then allows all of the radios to work under a single set of CellCore components.
RIL Overview
The RIL provides the interface between the system software and the radio stack residing within the modem. The system software includes all elements of the Operating System, Windows Mobile, eg: TAPI / ExTAPI, SIM Manager, SMS Manager, Dialler, etc. and customer / 3rd party applications. The RIL services system requests for radio functions, eg: voice, data, SMS, etc. and provides asynchronous notifications of changes to the system, eg: signal strength, coverage, incoming voice calls, incoming SMS messages. Telephony services within Windows Mobile are defined by the Operating System, each function or service ideally being independent of both the modem and the modem / applications processor interface. The RIL is architectured such that Windows Mobile provides a standard interface, API set and call back mechanisms which can be used across different platforms, with the specific details being hidden from the remainder of the system
Platform Implementation
The RIL source code is usually based on the sample RIL provided by Microsoft in the adaptation kit under <platform root folder>\public\cellcore\ril\driver, which provides all the mechanisms required to support a standard AT command based modem. For a non AT command based modem it may be more efficient to redesign the RIL. The sample RIL provides support for Siemens, TI, and TTPCom based modems, hence modifications will be required to adapt the RIL to the selected modem if not based on one of the above. Although most modems conform to the GSM or CDMA specifications most manufacturers implement these specifications in similar but not identical ways, hence, although the AT commands may be the same, the actual behaviour of the commands may differ. For example AT+COPS=0 on some modems block until the modem has registered (or failed to register) on the network, whereas other modems respond immediately and register in the background. The Logo Test Kit assumes a particular modem behaviour, hence, some modems will require RIL modifications to match the expected behaviour. The most common areas that require modification for each modem and/or platform are:
Power Management
The power management of the radio is a combination of modem specific and platform specific methods, eg: the modem may support power saving modes via AT commands and/or the platform may provide hardware power control to the modem. These two methods each have their own issues which need to be addressed in the RIL driver.
Audio Management
The RIL is responsible for adjusting the volume of the voice signals from the modem and selecting which audio device is currently in use. This is normally undertaken using AT commands to adjust the modem settings, however, some platforms may have external audio hardware to make these changes and in these cases the RIL will need to either access the hardware directly or, preferably, to access another device driver.
SMS handling
The sample RIL supports GSM SMS phase 2 mode 2, however, if this is not supported by the modem then the handling of SMS messages requires modification.
SIM toolkit
The SIM toolkit support in the sample RIL is designed around the Condat and TTPCom AT command set. Many modem manufacturers implement their own proprietary AT command extensions for SIM toolkit commands, hence, some work may be required to convert the radio command to what the OS is expecting. This can be quite complex if the modem implements vastly different SIM toolkit functionality as considerable changes to the parsing of the commands will need to be added within the RIL.
Own Number
Many modems do not implement the +CNUM AT command which can cause problems when the OS
attempts to fetch the modem’s own phone number as the phone control panel applet will display ‘unavailable’. To avoid this, the RIL can be modified to obtain the own number from the SIM phonebook by selecting the own number phonebook, however, this is SIM/Network operator dependent, hence, some SIM cards may not include any entries in this phonebook
RIL Modem Interface
The RIL allows hardware abstraction by accepting service requests from the upper layers, mainly TAPI and ExTAPI and converts those requests into commands supported by the modem, exchanging information over a modem / host processor interface. The original modem system design dating back over 3 decades provided a single communications channel over which both AT commands and data was routed, requiring a time consuming switching mechanism between command mode and data mode, essentially allowing only single processes to be active at any time. Advances in networks, ie: 2.5G and 3G, now provide multiple simultaneous services, eg: data connection to browse the web, send / receive email, send / receive SMS messages, originate answer voice calls, poll signal strength, etc. Network advances have outstripped modem interface advances to such a degree that it is necessary to expend effort on maximizing throughput, eg: support for a multiplexer device driver and multiplexer support in the RIL itself. Network advances have necessitated modem architecture evolution such that it is usually necessary to expend effort on the modem interface Some modems provide other interfaces eg: high speed UART’s, USB, shared memory. The same principles apply to high speed UART’s and USB ports, access to the modem is still via a standard device driver, serial or USB, with no specific RIL or MUX related functions. A shared memory
implementation requires considerable changes to the RIL and is outside the scope of this document
Using the Code
before we Start in code i suggest to take view in Radio interface Layer RIL.
This Library its very useful here you can check famous function like :
- RIL_Dial:
This function is responsible for dialing voice and data calls.
- RIL_GetCellTowerInfo: This function retrieves information about the cell tower currently used by the phone.
- RIL_GetCurrentOperator:This function retrieves the operator the device is currently registered with.
- RIL_GetMinimumQualityOfServiceList:This function gets the minimum quality of service profile for all contexts.
- RIL_AddCallForwarding :This function adds a call forwarding rule.
- RIL_AddPreferredOperator :This function adds a specified operator to the list of preferred operators.
- RIL_Answer:This function is implemented by a RIL driver. It is responsible for answering the currently offering call.
- RIL_CancelSupServiceDataSession :This function cancels the current supplementary service session.
- RIL_ChangeCallBarringPassword :This function changes the password for the specified type of call barring.
- RIL_ChangeLockingPassword :This function changes the locking password for the specified facility.
- RIL_ClearCCBSRegistration :This function clears the registration for a completion of the call to busy subscriber (CCBS) index.
- RIL_Deinitialize :This function deinitializes RIL. This function is synchronous.
- RIL_DeleteGPRSContext :This function deletes a particular GPRS context.
- RIL_Dial :This function is responsible for dialing voice and data calls.
- RIL_DisableNotifications :This function disables classes of notifications for a client. This function is synchronous.
- RIL_EnableNotifications :This function enables additional classes of notifications for a client. This function is synchronous.
- RIL_EnterGPRSDataMode :This function enters into a GPRS data state.
- RIL_FetchSimToolkitCmd :This function fetches a SIM Toolkit command from the SIM.
- RIL_GetAllOperatorsList :This function retrieves the built-in list of all known operators.
- RIL_GetATR :This function gets the Answer To Reset (ATR) string from the SIM.
- RIL_GetAudioDevices :This function retrieves the current transmit and receive audio devices.
- RIL_GetAudioGain :This function retrieves audio gain information.
- RIL_GetAudioMuting :This function is implemented by a RIL driver. It is responsible for querying the mute status of the radio.
For More Function
HRESULT hRes;
DWORD dwNotificationClasses = 0xffff0000;
hRes = RIL_Initialize(1, RILResultCallBack, RILNotifyCallBack, dwNotificationClasses, 0x55AA55AA, &g_hRil);
{
if (g_hRil == NULL)
RIL_Deinitialize(g_hRil);
return 0;
}
RIL_Initialize : This function initializes RIL for use by a client , and dwNotificationClasses 0xffff0000 to Specifies the classes of notifications in our case we will implement CALL_RING .
case RIL_NCLASS_CALLCTRL:
{
switch (dwCode) {
case RIL_NOTIFY_CALLPROGRESSINFO:
{
callInfo = (RILCALLINFO*) pData;
raAddress = callInfo->raAddress;
}break;
case RIL_NOTIFY_RING:
{
KillCProg(); }break;
}
break;
CallBack Function it's fire when you got Call
RIL_NOTIFY_CALLPROGRESSINFO : it' recived some of caller information like phone number.
RIL_NOTIFY_RING : run when we got notify ring.
hProcesses = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (INVALID_HANDLE_VALUE == hProcesses) {
dwError = ::GetLastError();
}
pe.dwSize = sizeof(pe);
for (bVal = ::Process32First(hProcesses, &pe); bVal; bVal =
::Process32Next(hProcesses, &pe))
{
if (!_tcscmp(TEXT("cprog.exe"), pe.szExeFile))
{
hProc = ::OpenProcess(0, FALSE, pe.th32ProcessID);
::TerminateProcess(hProc, 0);
::CloseHandle(hProc);
break;
}
}
::CloseToolhelp32Snapshot(hProcesses);
Now we are going inside Process view to kill cprog.exe
cprog.exe :Phone Application which used to make call or Recived call
hProcesses = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
// Take a snapshot of all modules in the specified process.
::Process32First(hProcesses, &pe);
when we catch cprog.exe if (!_tcscmp(TEXT("cprog.exe"), pe.szExeFile)) ,we can kill it ,& end of Annoying Story.