代码拉取完成,页面将自动刷新
同步操作将从 OpenHarmony/drivers_peripheral 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
基于HDF(Hardware Driver Foundation)驱动框架开发的Ril驱动,能够屏蔽硬件器件差异,为上层服务提供稳定的拨打电话、发短信、激活SIM卡等稳定的接口。
Ril驱动模块主要包含HDI(Hardware Driver Interface)接口定义及其实现,对上层提供Telephony的驱动能力接口,HDI接口主要提供如下功能:
图 1 Ril驱动模型图
该仓下源代码目录结构如下所示
/drivers/peripheral/ril
├── figures # readme资源文件
├── interfaces # Ril模块对上层服务提供的驱动能力接口
│ └── include # Ril模块对外提供的接口定义
Ril驱动提供给framework层可直接调用的能力接口,主要功能有:通话、SIM卡、短彩信、蜂窝数据、事件上报等业务。Ril驱动模型对HDI开放的API接口功能如表1:
表 1 Ril HDI 接口列表
接口名 | 功能描述 |
---|---|
int32_t SetCallback(const sptr<IRilCallback> &rilCallback) | 设置IRil回调接口。 |
int32_t Dial(int32_t slotId, int32_t serialId, const DialInfo &dialInfo) | 拨打电话,slotId 表示卡槽ID,serialId 表示请求的序列化ID,dialInfo 表示拨号信息。 |
int32_t Answer(int32_t slotId, int32_t serialId) | 接听电话,slotId 表示卡槽ID,serialId 表示请求的序列化ID。 |
int32_t SendGsmSms(int32_t slotId, int32_t serialId, const GsmSmsMessageInfo &gsmSmsMessageInfo) | 发送GSM短信,slotId 表示卡槽ID,serialId 表示请求的序列化ID,gsmSmsMessageInfo 表示GSM短信信息。 |
int32_t SetActiveSim(int32_t slotId, int32_t serialId, int32_t index, int32_t enable) | 激活或去激活SIM卡,slotId 表示卡槽ID,serialId 表示请求的序列化ID,index 表示SIM卡信息的索引值,enable 表示激活状态 |
int32_t GetOperatorInfo(int32_t slotId, int32_t serialId) | 查询运营商名称信息,slotId 表示卡槽ID,serialId 表示请求的序列化ID。 |
int32_t ActivatePdpContext(int32_t slotId, int32_t serialId, const DataCallInfo &dataCallInfo) | 查询运营商名称信息,slotId 表示卡槽ID,dataCallInfo 表示数据业务信息。 |
int32_t SetRadioState(int32_t slotId, int32_t serialId, int32_t fun, int32_t rst) | 给Modem上下电,slotId 表示卡槽ID,serialId 表示请求的序列化ID,fun 表示功能模式,rst 表示是否复位。 |
完整的接口说明请参考: drivers_interface_ril。
本节以拨打电话为例进行介绍。
代码示例
#include "v1_0/iril.h"
/* Ril回调类 */
class RilCallback : public HDI::Ril::V1_0::IRilCallback {
int32_t DialResponse(const HDI::Ril::V1_0::RilRadioResponseInfo &responseInfo) override;
int32_t HangupResponse(const HDI::Ril::V1_0::RilRadioResponseInfo &responseInfo) override;
int32_t RejectResponse(const HDI::Ril::V1_0::RilRadioResponseInfo &responseInfo) override;
int32_t AnswerResponse(const HDI::Ril::V1_0::RilRadioResponseInfo &responseInfo) override;
...
}
/* 回调函数 */
int32_t RilCallback::DialResponse(const HDI::Ril::V1_0::RilRadioResponseInfo &responseInfo)
{
printf("DialResponse");
return 0;
}
void RilSample(void)
{
/* 创建Ril接口实例 */
sptr<OHOS::HDI::Ril::V1_0::IRil> g_rilInterface = OHOS::HDI::Ril::V1_0::IRil::Get();
if (g_rilInterface == nullptr) {
return;
}
/* 设置回调*/
sptr<HDI::Ril::V1_0::IRilCallback> g_cbObj = new RilCallback();
g_rilInterface->SetCallback(RilCallback());
/**拨打电话**/
int32_t slotId = 0;
int32_t serialId = 1;
HDI::Ril::V1_0::DialInfo dialInfo = {};
dialInfo.address = "10086";
dialInfo.clir = 0;
int32_t ret = g_rilInterface->Dial(slotId, serialId, dialInfo);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。