e904077611
Signed-off-by: zhf <zhanghaifeng11@huawei.com> |
||
---|---|---|
common | ||
etc/init | ||
figures | ||
interfaces | ||
network_search | ||
sa_profile | ||
services | ||
sim | ||
tel_ril | ||
test | ||
BUILD.gn | ||
LICENSE | ||
ohos.build | ||
README_zh.md | ||
README.md |
Telephony Core Service
Introduction
The telephony core service initializes the RIL Manager, SIM card module, and network search module, and provides access to the RIL Adapter service.
You can implement communication with the RIL Adapter by registering the callback service and implement communication between modules by subscribing to callbacks.
Figure 1 Architecture of the telephony core service
As shown in the preceding figure, the telephony core service consists of the SIM card service, network search service, and RIL Manager service.
- SIM card service: Provides services including SIM card initialization, file read/write, loading status notification, and single-SIM/dual-SIM control. These services implement functions such as SIM card status query, SIM card management, SIM card control, STK, contact storage, and SMS storage.
- Network search service: Provides services including network registration and network status acquisition. These services offer functions such as network registration, network mode query, radio status query, network search management, signal strength query, cell management, registration status management, and time and time zone setting.
- RIL Manager service: Provides the proactive callback service and query result callback service.
Directory Structure
/base/telphony/core_service
├── interfaces # APIs
│ ├── innerkits # Internal APIs
│ └── kits # External APIs (such as JS APIs)
├── services # Implementation of the telephony core service
│ ├── include
│ └── src
├── etc # Telephony core service driver scripts
│ └── init
├── sa_profile # SA profile
├── tel_ril # RIL Manager service code
│ ├── include
│ ├── src
│ └── test
├── network_search # Network search service code
│ ├── include
│ ├── src
│ └── test
├── sim # SIM card service code
│ ├── include
│ ├── src
│ └── test
├── common
│ ├── log # Core service log print directory
│ ├── preferences
│ ├── utils
│ └── test
Constraints
- Programming language: C++、JavaScript
- In terms of software, this module needs to work with the RIL adapter service
ril\_adapter
and status registration servicestate\_registry
. - In terms of hardware, the accommodating device must be equipped with a modem and a SIM card capable of independent cellular communication.
Available APIs
The telephony core service module needs to provide APIs for related modules, including the SIM card, network search modules.
APIs for the SIM Card Service
APIs for the Network Search Service
NOTE: The RIL Manager does not provide external APIs and can only be called by modules of the Telephony subsystem.
Usage Guidelines
Network Search
The function of obtaining the network status is used as an example. The process is as follows:
-
Query the SIM card in the slot specified by slotId. If slotId is not set, information about the primary card is queried by default.
-
Call the GetNetworkStatus method in callback or Promise mode.
-
Obtain the network status information. The GetNetworkStatus method works in asynchronous mode. The execution result is returned through the callback.
import radio from "@ohos.telephony.radio"; // Set the value of slotId. let slotId = 1; // Call the API in callback mode. radio.GetNetworkStatus(slotId, (err, value) => { if (err) { // If the API call failed, err is not empty. console.error(`failed to GetNetworkStatus because ${err.message}`); return; } // If the API call succeeded, err is empty. console.log(`success to GetNetworkStatus: ${value}`); }); // Call the API in Promise mode. let promise = radio.GetNetworkStatus(slotId); promise.then((value) => { // The API call succeeded. console.log(`success to GetNetworkStatus: ${value}`); }).catch((err) => { // The API call failed. console.error(`failed to GetNetworkStatus because ${err.message}`); });
SIM Card
The function of querying the status of a specified SIM card is used as an example. The process is as follows:
-
Set the value of slotId.
-
Call the getSimState method in callback or Promise mode to obtain the SIM card status information.
-
This method works in asynchronous mode. The execution result is returned through the callback.
import sim from "@ohos.telephony.sim"; // Set the value of slotId. let slotId = 1; // Call the API in callback mode. sim.getSimState(slotId, (err, value) => { if (err) { // If the API call failed, err is not empty. console.error(`failed to getSimState because ${err.message}`); return; } // If the API call succeeded, err is empty. console.log(`success to getSimState: ${value}`); }); // Call the API in Promise mode. let promise = sim.getSimState(slotId); promise.then((value) => { // The API call succeeded. console.log(`success to getSimState: ${value}`); }).catch((err) => { // The API call failed. console.error(`failed to getSimState because ${err.message}`); });
Repositories Involved
telephony_core_service