同步操作将从 OpenHarmony/drivers_peripheral 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
The Ril driver developed based on the Hardware Driver Foundation (HDF) driver framework shields hardware differences and provides APIs for upper-layer services, such as making calls, sending SMS messages, and activating SIM cards.
The Ril driver module contains definitions and implementation code of Ril hardware driver interfaces (HDIs) and provides the telephony driver capability APIs for the upper layer. The HDIs implement service processing related to the following services:
Figure 1 Architecture of the Ril driver module
The source code directory structure is as follows:
/drivers/peripheral/ril
├── figures # Readme resource files
├── interfaces # Driver capability APIs provided for upper-layer services
│ └── include # APIs exposed externally
The Ril driver provides capability APIs that can be directly called by the framework layer. The main functions are as follows: call, SIM card, SMS/MMS, cellular data, and event reporting. The following table lists the APIs provided by the Ril driver module.
Table 1 Ril HDI APIs
API | Description |
---|---|
int32_t SetCallback(const sptr<IRilCallback> &rilCallback) | Sets the IRil callback. |
int32_t Dial(int32_t slotId, int32_t serialId, const DialInfo &dialInfo) | Makes a call. slotId indicates the card slot ID, serialId indicates the serial ID of the request, and dialInfo indicates the dialing information. |
int32_t Answer(int32_t slotId, int32_t serialId) | Answers a call. slotId indicates the card slot ID, and serialId indicates the serial ID of the request. |
int32_t SendGsmSms(int32_t slotId, int32_t serialId, const GsmSmsMessageInfo &gsmSmsMessageInfo) | Sends a GSM SMS message. slotId indicates the card slot ID, serialId indicates the serial ID of the request, and gsmSmsMessageInfo indicates the GSM SMS message information. |
int32_t SetActiveSim(int32_t slotId, int32_t serialId, int32_t index, int32_t enable) | Activates or deactivates a SIM card. slotId indicates the card slot ID, serialId indicates the serial ID of the request, index indicates the index value of the SIM card information, and enable indicates the activation status. |
int32_t GetOperatorInfo(int32_t slotId, int32_t serialId) | Queries the carrier name. slotId indicates the card slot ID, and serialId indicates the serial ID of the request. |
int32_t ActivatePdpContext(int32_t slotId, int32_t serialId, const DataCallInfo &dataCallInfo) | Activates the PDP context. slotId indicates the card slot ID, and dataCallInfo indicates the data service information. |
int32_t SetRadioState(int32_t slotId, int32_t serialId, int32_t fun, int32_t rst) | Sets the radio state. slotId indicates the card slot ID, serialId indicates the serial ID of the request, fun indicates the function mode, and rst indicates whether to perform a reset. |
For details about the APIs, access drivers_interface_ril.
This section uses the call service implementation as an example.
Sample code:
#include "V1_1/iril.h"
/* Ril callback class */
class RilCallback : public HDI::Ril::V1_1::IRilCallback {
int32_t DialResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo) override;
int32_t HangupResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo) override;
int32_t RejectResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo) override;
int32_t AnswerResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo) override;
...
}
/* Callback */
int32_t RilCallback::DialResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo)
{
printf("DialResponse");
return 0;
}
void RilSample(void)
{
/* Create a Ril interface instance. */
sptr<OHOS::HDI::Ril::V1_1::IRil> g_rilInterface = OHOS::HDI::Ril::V1_1::IRil::Get();
if (g_rilInterface == nullptr) {
return;
}
/* Set a callback. */
sptr<HDI::Ril::V1_1::IRilCallback> g_cbObj = new RilCallback();
g_rilInterface->SetCallback(RilCallback());
/** Make a call. **/
int32_t slotId = 0;
int32_t serialId = 1;
HDI::Ril::V1_1::DialInfo dialInfo = {};
dialInfo.address = "10086";
dialInfo.clir = 0;
int32_t ret = g_rilInterface->Dial(slotId, serialId, dialInfo);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。