diff --git a/en/OpenHarmony-Overview.md b/en/OpenHarmony-Overview.md index 5fb7e99c92cdf5b732f824eb89fa71b2810efe8d..99b54ccfb9742bbde4516cf46f8579ca1e1a8909 100644 --- a/en/OpenHarmony-Overview.md +++ b/en/OpenHarmony-Overview.md @@ -374,7 +374,7 @@ For details about how to obtain the source code of OpenHarmony, see [Source Cod For details about how to join in the OpenHarmony community, see [OpenHarmony Community](https://gitee.com/openharmony/community/blob/master/README.md). -For details about how to contribute, see [Contribution](https://gitee.com/openharmony/docs/blob/master/en/contribute/contribution.md). +For details about how to contribute, see [How to Contribute](contribute/how-to-contribute.md). ## License Agreement diff --git a/en/application-dev/internationalization/Readme-EN.md b/en/application-dev/internationalization/Readme-EN.md index 4a1435843d6842dfaacbd1a56419efc6ef5b7487..d7042968cf5c6824e49f77911e207e4cbb4be443 100644 --- a/en/application-dev/internationalization/Readme-EN.md +++ b/en/application-dev/internationalization/Readme-EN.md @@ -1,5 +1,6 @@ # Internationalization -- [Overview](international-overview.md) +- [Internationalization Overview](international-overview.md) - [Internationalization Development (intl)](intl-guidelines.md) - [Internationalization Development (i18n)](i18n-guidelines.md) + diff --git a/en/application-dev/internationalization/international-overview.md b/en/application-dev/internationalization/international-overview.md index f41f6b0cb00c105e9a69e9e94388713c638ad658..b858bad7f1fa63a22edf73497b1684b7c723122d 100644 --- a/en/application-dev/internationalization/international-overview.md +++ b/en/application-dev/internationalization/international-overview.md @@ -1,4 +1,4 @@ -# Overview +# Internationalization Overview If an application is targeted for users and markets in different regions with different languages and time zones, it is necessary for you to provide localized versions to ensure good experience for your users. diff --git a/en/application-dev/media/Readme-EN.md b/en/application-dev/media/Readme-EN.md index b5012b28ac7d60e147562d239791d7d878284152..84de2ab360697e2b15b253572a675648b4588b06 100755 --- a/en/application-dev/media/Readme-EN.md +++ b/en/application-dev/media/Readme-EN.md @@ -3,13 +3,9 @@ - Audio - [Audio Overview](audio-overview.md) - - - [Audio Playback Development](audio-playback.md) - - - [Audio Rendering Development](audio-renderer.md) - +- [Audio Playback Development](audio-playback.md) - [Audio Recording Development](audio-recorder.md) - +- [Audio Rendering Development](audio-renderer.md) - [Audio Capture Development](audio-capturer) - Video diff --git a/en/application-dev/security/Readme-EN.md b/en/application-dev/security/Readme-EN.md index 6d434aacb1d4e894bba5d8d9707f3add72e4e0b6..f35f70483564be9f9fdba75a305ed5c4a03dcf8d 100644 --- a/en/application-dev/security/Readme-EN.md +++ b/en/application-dev/security/Readme-EN.md @@ -1,16 +1,14 @@ # Security +- Access Control + - [Access Control Overview](accesstoken-overview.md) + - [Access Control Development](accesstoken-guidelines.md) - User Authentication - [User Authentication Overview](userauth-overview.md) - [User Authentication Development](userauth-guidelines.md) - - Key Management - [HUKS Overview](huks-overview.md) - [HUKS Development](huks-guidelines.md) - - hapsigntool - [hapsigntool Guide](hapsigntool-guidelines.md) - -- Access Control - - [Access Control Overview](accesstoken-overview.md) - - [Access Control Development](accesstoken-guidelines.md) \ No newline at end of file + diff --git a/en/contribute/Readme-EN.md b/en/contribute/Readme-EN.md index 1cd693e71d27e4fe751a1a5fa6eb5b45195b1608..24fcbe6d10db5ead1172a88577af8523330e2f1e 100755 --- a/en/contribute/Readme-EN.md +++ b/en/contribute/Readme-EN.md @@ -1,10 +1,10 @@ -# Contributing Documents +# Contribution Guide -- [Contribution](contribution.md) +- [How to Contribute](how-to-contribute.md) - [Code of Conduct](code-of-conduct.md) - [Code Contribution](code-contribution.md) - [Contribution Process](contribution-process.md) -- [Auto-Test](../readme/test_subsystem.md) +- [Auto-Test](../readme/test.md) - [Documentation Contribution](documentation-contribution.md) - [Writing Instructions](writing-instructions.md) - [Communication in Community](communication-in-community.md) diff --git a/en/contribute/contribution-guide.md b/en/contribute/contribution-guide.md new file mode 100644 index 0000000000000000000000000000000000000000..8ae87c6f330d4ae6f44a5001823d1113d1c8a8e5 --- /dev/null +++ b/en/contribute/contribution-guide.md @@ -0,0 +1,10 @@ +# Contribution Guide + +- **[How to Contribute](how-to-contribute.md)** +- **[Code of Conduct](code-of-conduct.md)** +- **[Code Contribution](code-contribution.md)** +- **[Contribution Process](contribution-process.md)** +- **[FAQs](FAQ.md)** +- **[Documentation Contribution](documentation-contribution.md)** +- **[Writing Instructions](writing-instructions.md)** +- **[Communication in Community](communication-in-community.md)** diff --git a/en/contribute/contribution.md b/en/contribute/how-to-contribute.md old mode 100755 new mode 100644 similarity index 93% rename from en/contribute/contribution.md rename to en/contribute/how-to-contribute.md index 2819f40f16c3eaa4ff1454f9d475fe372d39c874..26a3bb146ec3cb2e80c898d668262fc98f0992ca --- a/en/contribute/contribution.md +++ b/en/contribute/how-to-contribute.md @@ -1,4 +1,4 @@ -# Contribution +# How to Contribute ## Contributing Code @@ -24,7 +24,7 @@ For details about how to contribute to code, see [Code Contributing ](code-cont ## Auto-Test -For details about how to develop test cases based on test requirements, see [Test Subsystem](../readme/test_subsystem.md). +For details about how to develop test cases based on test requirements, see [Test Subsystem](../readme/test.md). ## Contributing Documents diff --git a/en/device-dev/Readme-EN.md b/en/device-dev/Readme-EN.md index 4d1aff9ef22611b662169c4d1333a2dc6e697649..eb6e2ceafd34f71881c393a6d0e2fb93423ebb69 100644 --- a/en/device-dev/Readme-EN.md +++ b/en/device-dev/Readme-EN.md @@ -31,8 +31,8 @@ - [Sensor](subsystems/subsys-sensor.md) - [USB](subsystems/subsys-usbservice.md) - [Application Framework](subsystems/subsys-application-framework.md) - - [OTA Upgrade](subsystems/subsys-ota-guide.md) - - [Telephony Service](subsystems/subsys-tel.md) + - [OTA Update](subsystems/subsys-ota-guide.md) + - [Telephony](subsystems/subsys-tel.md) - [Security](subsystems/subsys-security.md) - [Startup](subsystems/subsys-boot.md) - [DFX](subsystems/subsys-dfx.md) @@ -55,4 +55,4 @@ - References - [FAQs](faqs/Readme-EN.md) - Contribution - - [How to Contribute](../contribute/contribution.md) \ No newline at end of file + - [How to Contribute](../contribute/how-to-contribute.md) \ No newline at end of file diff --git a/en/device-dev/faqs/Readme-EN.md b/en/device-dev/faqs/Readme-EN.md index 68d411240e1eade334d885c33e4448911ea91798..361ca82eba707c5ab5b1e85060b2e212a17e9d84 100644 --- a/en/device-dev/faqs/Readme-EN.md +++ b/en/device-dev/faqs/Readme-EN.md @@ -1,10 +1,10 @@ # FAQs - [Overview of FAQs](faqs-overview.md) -- [Environment Setup](faqs-environment-building.md) +- [Environment Setup](faqs-environment-setup.md) - [Compilation and Building Subsystem](faqs-building.md) - [Burning](faqs-burning.md) - [Kernel](faqs-kernel.md) -- [Porting](faqs-transplant.md) -- [Startup](faqs-init.md) -- [System Applications](faqs-system-using.md) +- [Porting](faqs-porting.md) +- [Startup](faqs-startup.md) +- [System Applications](faqs-system-applications.md) diff --git a/en/device-dev/faqs/faqs-environment-building.md b/en/device-dev/faqs/faqs-environment-setup.md similarity index 100% rename from en/device-dev/faqs/faqs-environment-building.md rename to en/device-dev/faqs/faqs-environment-setup.md diff --git a/en/device-dev/faqs/faqs-transplant.md b/en/device-dev/faqs/faqs-porting.md similarity index 100% rename from en/device-dev/faqs/faqs-transplant.md rename to en/device-dev/faqs/faqs-porting.md diff --git a/en/device-dev/faqs/faqs-init.md b/en/device-dev/faqs/faqs-startup.md similarity index 100% rename from en/device-dev/faqs/faqs-init.md rename to en/device-dev/faqs/faqs-startup.md diff --git a/en/device-dev/faqs/faqs-system-using.md b/en/device-dev/faqs/faqs-system-applications.md similarity index 100% rename from en/device-dev/faqs/faqs-system-using.md rename to en/device-dev/faqs/faqs-system-applications.md diff --git a/en/device-dev/quick-start/Readme-EN.md b/en/device-dev/quick-start/Readme-EN.md index 0efb4c35dffce1b8d80785002855b0a70c2671d1..3257b6a2a45e9f548183906dafaf72e08da4a872 100644 --- a/en/device-dev/quick-start/Readme-EN.md +++ b/en/device-dev/quick-start/Readme-EN.md @@ -12,7 +12,7 @@ - [Burning](quickstart-ide-lite-steps-hi3861-burn.md) - [Networking](quickstart-ide-lite-steps-hi3861-netconfig.md) - [Debugging and Verification](quickstart-ide-lite-steps-hi3861-debug.md) - - [Running](quickstart-ide-lite-steps-hi3816-running.md) + - [Running](quickstart-ide-lite-steps-hi3861-running.md) - Hi3516 Development Board - [Writing a Hello World Program](quickstart-ide-lite-steps-hi3516-application-framework.md) - [Building](quickstart-ide-lite-steps-hi3516-building.md) diff --git a/en/device-dev/quick-start/quickstart-ide-lite-steps-hi3816-running.md b/en/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-running.md similarity index 100% rename from en/device-dev/quick-start/quickstart-ide-lite-steps-hi3816-running.md rename to en/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-running.md diff --git a/en/device-dev/subsystems/subsys-tel-guide.md b/en/device-dev/subsystems/subsys-tel-guide.md new file mode 100644 index 0000000000000000000000000000000000000000..443052548616424659481bb183bd0fc69426a572 --- /dev/null +++ b/en/device-dev/subsystems/subsys-tel-guide.md @@ -0,0 +1,592 @@ +# Telephony Development + +## Initializing a Modem Vendor Library + +### When to Use + +Initializing a modem vendor library means to implement **const HRilOps \*RilInitOps\(const struct HRilReport \*reportOps\)** function in the vendor library. This function is mainly used to: + +- Receive function pointers to event callbacks of RIL Adapter. When a service event needs to be reported, the target pointer will be called to report the event to RIL Adapter. +- Create a thread for reading modem nodes. In this thread, the data reported by the modem is read cyclically and parsed as a specific service event for reporting. +- Return the function pointer of the service request API to RIL Adapter. + +### Available APIs + +The following table describes the API for initializing a modem vendor library. + +**Table 1** API for initializing a modem vendor library + + + + + + + + + + +

API

+

Description

+

const HRilOps *RilInitOps(const struct HRilReport * reportOps)

+

Function: Provides an entry for running a modem vendor library.

+

Input parameter:

+

reportOps: Specifies the pointer to the event callback function, which is passed by RIL Adapter.

+

Return result: function pointer of the service request API.

+
+ +### How to Develop + +1. Set the event callback function pointers passed by RIL Adapter through **RilInitOps**. + + ``` + // Define the callback function pointers of the modem vendor library. + static struct HRilReport g_reportOps = { + OnCallReport, // Callback function for call services + OnDataReport, // Callback function for cellular data services + OnModemReport, // Callback function for modem services + OnNetworkReport, // Callback function for network search services + OnSimReport, // Callback function for SIM card services + OnSmsReport // Callback function for SMS services + }; + ``` + + +1. Create the **g\_reader** main thread to enable message looping. + + ``` + pthread_attr_t t; + pthread_attr_init(&t); + pthread_attr_setdetachstate(&t, PTHREAD_CREATE_DETACHED); + ret = pthread_create(&g_reader, &t, ReaderLoop, &t); // Create the g_reader thread. + ``` + + +1. In the **g\_eventListeners** thread, use **open\(\)** to open a modem node and then create the **g\_reader** thread to read and process messages reported by the modem. + + ``` + g_fd = open(g_devicePath, O_RDWR); // Open the device node specified by g_devicePath. + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + ret = pthread_create(&g_eventListeners, &attr, EventListeners, NULL); + ``` + + +1. Return the function pointer of the service request API. + + ``` + // Structure for the service request API of the call module + typedef struct { + // Obtain the call list. + void (*GetCallList)(ReqDataInfo *requestInfo, const void *data, size_t dataLen); + // Make a call. + void (*Dial)(ReqDataInfo *requestInfo, const void *data, size_t dataLen); + // Disconnect a call. + void (*Hangup)(ReqDataInfo *requestInfo, const void *data, size_t dataLen); + // Reject a call. + void (*Reject)(ReqDataInfo *requestInfo, const void *data, size_t dataLen); + // Answer a call. + void (*Answer)(ReqDataInfo *requestInfo, const void *data, size_t dataLen); + } HRilCallReq; + + // Callback function pointers of the call module + static const HRilCallReq g_callReqOps = { + .GetCallList = ReqGetCallList, // Obtain the call list. + .Dial = ReqDial, // Make a call. + .Hangup = ReqHangup, // Disconnect a call. + .Reject = ReqReject, // Reject a call. + .Answer = ReqAnswer, // Answer a call. + }; + + // Service request structure + typedef struct { + const HRilCallReq *callOps; // Pointer to the structure of call service requests + const HRilSimReq *simOps; // Pointer to the structure of SIM card service requests + const HRilSmsReq *smsOps; // Pointer to the structure of SMS and MMS service requests + const HRilDataReq *dataOps; // Pointer to the structure of cellular data service requests + const HRilNetworkReq *networkOps; // Pointer to the structure of network search service requests + const HRilModemReq *modemOps; // Pointer to the structure of modem service requests + } HRilOps; + + // Service request APIs + HRilOps g_hrilOps = { + .callOps = &g_callReqOps, // API for call service requests + .simOps = &g_simReqOps, // API for SIM card service requests + .smsOps = &g_smsReqOps, // API for SMS and MMS service requests + .networkOps = &g_networkReqOps, // API for cellular data service requests + .dataOps = &g_dataReqOps, // API for network search service requests + .modemOps = &g_modemReqOps, // API for modem service requests + }; + ``` + + +### Debugging and Verification + +1. Use the [hdc\_std](https://gitee.com/openharmony/docs/blob/master/en/device-dev/subsystems/subsys-toolchain-hdc-guide.md#preparations) tool to connect to a debugging device. Then, run the following command to send the generated **libril\_vendor.z.so** library file to the **/system/lib/** directory of the device. For details about how to integrate a library file, see [Integrating Modem Vendor Libraries](#section590mcpsimp). + + ``` + hdc_std file send libril_vendor.z.so /system/lib/ + ``` + +2. Reboot the debugging device. + + ``` + hdc_std shell sync + hdc_std shell reboot + ``` + +3. Run the **hdc\_std shell hilog** command to view the debug log, and check whether the **RilInitOps\(\)** function is successfully executed. The following debug log is for reference: + + ``` + 01-01 05:13:23.071 136 2319 D 00000/RilAdapterInit: [RilAdapterDispatch-(hril_hdf.c:55)] sbuf IPC obtain test success! + 01-01 05:13:23.071 136 2319 D 00000/RilAdapterInit: [LoadVendor-(hril_hdf.c:33)] RilInit rilInit start + 01-01 05:13:23.071 136 2319 D 00000/RilAdapterInit: [LoadVendor -(hril_hdf.c:45)] RilInit rilInit completed + ``` + + +## Responding to Modem Service Requests + +### When to Use + +After receiving a specific telephony service request, RIL Adapter calls the target function pointer obtained in modem vendor library initialization to send a specific service request to the vendor library. Then, the vendor library processes the request based on the request ID. + +### Available APIs + +The following table describes the APIs for responding to modem service requests, with the dial module as an example. + +**Table 2** APIs for responding to modem service requests + + + + + + + + + + + + + +

API

+

Description

+

void ReqDial(ReqDataInfo *requestInfo, const void *data, size_t dataLen);

+

Function: Processes number dial requests.

+

Input parameters:

+
  • requestInfo: request type
+
  • data: called number
+
  • dataLen: data length
+

Return value: none

+

void (*OnCallReport)(struct ReportInfo reportInfo, const void *data, size_t dataLen);

+

Function: Reports the execution result of a service request to RIL Adapter.

+

Input parameters:

+
  • reportInfo: request type
+
  • data: called number
+
  • dataLen: data length
+

Return value: none

+
+ +### How to Develop + +1. Implement processing of dial requests in the **ReqDial\(\)** API. + + ``` + // Implement the API for processing dial requests. + void ReqDial(ReqDataInfo *requestInfo, const void *data, size_t dataLen) + { + HRilDial *pDial = NULL; + char cmd[MAX_BUFF_SIZE] = {0}; + const char *clir = NULL; + int ret; + int err = HRIL_ERR_SUCCESS; + struct ReportInfo reportInfo = {}; + ResponseInfo *pResponse = NULL; + if (data == NULL) { + TELEPHONY_LOGE("data is null!!!"); + err = HRIL_ERR_INVALID_PARAMETER; + reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0); + OnCallReport(reportInfo, NULL, 0); + return; + } + pDial = (HRilDial *)data; + switch (pDial->clir) { + case CALL_CLIR_INVOCATION: + clir = "I"; + break; /* invocation */ + case CALL_CLIR_SUPPRESSION: + clir = "i"; + break; /* suppression */ + case CALL_CLIR_SUBSCRIPTION_DEFUALT: + default: + clir = ""; + break; /* subscription default */ + } + (void)sprintf_s(cmd, MAX_BUFF_SIZE, "ATD%s%s;", pDial->address, clir); + ret = SendCommandLock(cmd, NULL, 0, &pResponse); // Send the AT command. + ...... + } + ``` + +2. After the modem executes the dial command, report the execution result to RIL Adapter via **OnCallReport\(\)**. + + ``` + ret = SendCommandLock(cmd, NULL, 0, &pResponse); + if (ret != 0 || (pResponse != NULL && pResponse->success == 0)) { + TELEPHONY_LOGE("ATD send failed"); + err = HRIL_ERR_GENERIC_FAILURE; + } + reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0); + OnCallReport(reportInfo, NULL, 0); // Invoke the callback function of the call service. + ``` + + +### Debugging and Verification + +1. Use the [hdc\_std](en-us_topic_0000001080478129.md#section05992022154916) tool to connect to a debugging device. Then, run the following command to send the generated **libril\_vendor.z.so** library file to the **/system/lib/** directory of the device. + + ``` + hdc_std file send libril_vendor.z.so /system/lib/ + ``` + +2. Reboot the debugging device. + + ``` + hdc_std shell sync + hdc_std shell reboot + ``` + +3. Run the **hdc\_std shell** command. Then, run the **./system/bin/ril\_adapter\_test** command, type **1**, and enter the phone number as prompted to test the call function. + + ``` + hdc_std shell + # ./system/bin/ril_adapter_test + ----> Test Enter --------->Call--------------------- + + 1----> RilUnitTest::OnRequestCallDialTest + 2----> RilUnitTest:: OnRequestCallHangupTest + 3----> RilUnitTest:: OnRequestCallAnswerTest + 4----> RilUnitTest::OnRequestCallGetCurrentCallsStatusTest + 5----> RilUnitTest::OnRequestRefusedCallTest + + 1 + ``` + +4. Open another terminal window, and run the **hdc\_std shell hilog** command. Then, view the log to check whether **ReqDial\(\)** is successfully executed. The following debug log is for reference: + + ``` + 01-01 05:27:27.419 136 408 D 02b01/Rilvendor: [SendCommandLock-(at_support.c:210)] SendCommandLock enter, cmd: ATD17620373527 + 01-01 05:27:27.419 136 408 D 02b01/Rilvendor: [SendCommandLock-(at_support.c:231)] SendCommandLock() command ATD17620373527 + 01-01 05:27:27.419 136 408 D 02b01/Rilvendor: [WriteATCommand-(channel.c:115)] WriteATCommand enter, cmd:ATD17620373527 + 01-01 05:27:27.421 136 187 D 02b01/Rilvendor: [ReadResponse-(channel.c:94)] g_bufferCur : + 01-01 05:27:27.421 136 187 D 02b01/Rilvendor: OK + 01-01 05:27:27.422 136 187 D 02b01/Rilvendor: [ProcessResponse-(at_support.c:144)] processLine line = OK + 01-01 05:27:27.422 136 187 D 02b01/Rilvendor: [ReadResponse-(channel.c:81)] ReadResponse enter + 01-01 05:27:27.422 136 187 D 02b01/Rilvendor: [ProcessLastResponse-(channel.c:37)] last data more than one line , FindEndOfLine g_bufferCur: + 01-01 05:27:27.422 136 187 E 02b01/Rilvendor: [ProcessLastResponse-(channel.c:39)] g_bufferCur endLine is null + 01-01 05:27:27.422 136 187 E 02b01/Rilvendor:^ORIG:1,0 + 01-01 05:27:27.422 136 408 E 02b01/Rilvendor: [SendCommandLock-(at_support.c:234)] processLine line = ^ORIG:1,0 + 01-01 05:27:27.422 136 408 E 02b01/Rilvendor: [SendCommandLock-(vendor_report.c:234)] enter to [^ORIG:1,0]: (null) + 01-01 05:27:27.422 136 408 E 02b01/Rilvendor: [SendCommandLock-(at_support.c:264)] err = 0, cmd:ADT17620373527 + ``` + + +## Reporting Modem Events + +### When to Use + +A modem node thread reads the messages reported by the modem cyclically, parses the messages into specific events, and then reports the events to RIL Adapter. + +### Available APIs + +The following table describes the API for reporting modem events. + +**Table 3** API for reporting modem events + + + + + + + + + + +

API

+

Description

+

void OnNotifyOps(const char *s, const char *smsPdu)

+

Function: Distributes the events reported by the modem.

+

Input parameters:

+
  • s: AT command prefix
+
  • smsPdu: PDU of the SMS message
+

Return value: none

+
+ +### How to Develop + +1. Call **OnNotifyOps\(\)** in the g\_reader thread of the modem device node to parse reported modem events. On determining the command type, call **OnXxxReport\(\)** to report the parsed module events to the hril layer. + + ``` + // Parse the data reported by the modem as events proactively reported by the corresponding module. + void OnNotifyOps(const char *s, const char *smsPdu) + { + int ret = 0; + struct ReportInfo reportInfo = {0}; + reportInfo.error = HRIL_ERR_SUCCESS; + reportInfo.type = HRIL_NOTIFICATION; + if (GetRadioState() == HRIL_RADIO_POWER_STATE_UNAVAILABLE) { + return; + } + TELEPHONY_LOGD("enter to [%{public}s]:%{public}s", s, smsPdu); + // Determine the type of the proactively reported events based on the AT command. + if (ReportStrWith(s, "+CRING:") || ReportStrWith(s, "RING") || ReportStrWith(s, "IRING") || + ReportStrWith(s, "NO CARRIER") || ReportStrWith(s, "+CCWA") || ReportStrWith(s, "^CCALLSTATE") || + ReportStrWith(s, "^CEND") || ReportStrWith(s, "^CCWA")) { + reportInfo.notifyId = HNOTI_CALL_STATE_UPDATED; + OnCallReport(reportInfo, NULL, 0); + } else if (ReportStrWith(s, "+CMT:")) { + reportInfo.notifyId = HNOTI_SMS_NEW_SMS; + OnSmsReport(reportInfo, (void *)smsPdu, strlen(smsPdu)); + } + // Report the events of each module to the hril layer. + ... + } + ``` + + +1. Distribute the reported events from the **hril** layer to the Telephony Service layer. + + ``` + // Report the call status proactively. + int32_t HRilCall::CallStateUpdated( + int32_t slotId, int32_t notifyType, const HRilErrno e, const void *response, size_t responseLen) + { + struct HdfSBuf *dataSbuf = HdfSBufTypedObtain(SBUF_IPC); + if (serviceCallbackNotify_ == nullptr) { + TELEPHONY_LOGE("RilAdapter serviceCallbackNotify_ is null"); + HdfSBufRecycle(dataSbuf); + return HDF_FAILURE; + } + // Distribute events. + int32_t ret = serviceCallbackNotify_->dispatcher->Dispatch( + serviceCallbackNotify_, HNOTI_CALL_STATE_UPDATED, dataSbuf, nullptr); + if (ret != HDF_SUCCESS) { + HdfSBufRecycle(dataSbuf); + return HDF_FAILURE; + } + HdfSBufRecycle(dataSbuf); + return HDF_SUCCESS; + } + ``` + + +### Debugging and Verification + +1. Use the [hdc\_std](en-us_topic_0000001080478129.md#section05992022154916) tool to connect to a debugging device. Then, run the following command to send the generated **libril\_vendor.z.so** library file to the **/system/lib/** directory of the device. + + ``` + hdc_std file send libril_vendor.z.so /system/lib/ + ``` + +2. Reboot the debugging device. + + ``` + hdc_std shell sync + hdc_std shell reboot + ``` + +3. Run the **hdc\_std shell** command. Then, run the **./system/bin/ril\_adapter\_test** command, type **1**, and enter the phone number as prompted to test the call function. + + ``` + hdc_std shell + # ./system/bin/ril_adapter_test + ----> Test Enter --------->Call--------------------- + + 1----> RilUnitTest::OnRequestCallDialTest + 2----> RilUnitTest:: OnRequestCallHangupTest + 3----> RilUnitTest:: OnRequestCallAnswerTest + 4----> RilUnitTest::OnRequestCallGetCurrentCallsStatusTest + 5----> RilUnitTest::OnRequestRefusedCallTest + + 1 + ``` + +4. Open another terminal window, and run the **hdc\_std shell hilog** command. Then, view the log to check whether **OnNotifyOps\(\)** is successfully executed. The following debug log is for reference: + + ``` + 01-01 00:08:01.334 546 551 D 02b01/TelRilTest: [DialResponse-(tel_ril_call.cpp:280)] DialResponse --> radioResponseInfo->serial:2, radioResponseInfo->error:0 + 01-01 00:08:01.334 546 557 D 02b01/TelRilTest: [ProcessEvent-(tel_ril_test.cpp:1262)] TelRilTest::DemoHandler::ProcessEvent --> eventId:101 + 01-01 00:08:01.334 143 512 D 02b01/Rilvendor: [ReadResponse-(channel.c:93)] g_bufferCur : + 01-01 00:08:01.334 143 512 D 02b01/Rilvendor: ^ORIG:1,0 + 01-01 00:08:01.334 143 512 D 02b01/Rilvendor: [ReadResponse-(channel.c:108)] AT< ^ORIG:1,0 + 01-01 00:08:01.334 143 512 D 02b01/Rilvendor: [ProcessResponse-(at_support.c:137)] processLine line = ^ORIG:1,0 + 01-01 00:08:01.334 143 512 D 02b01/Rilvendor: [OnNotifyOps-(vendor_report.c:126)] enter to [^ORIG:1,0]:(null) + 01-01 00:08:01.335 143 512 W 02b01/Rilvendor: [OnNotifyOps-(vendor_report.c:167)] enter to is unrecognized command: ^ORIG:1,0 + 01-01 00:08:01.335 143 512 D 02b01/Rilvendor: [ProcessLastResponse-(channel.c:37)] last data more than one line , FindEndOfLine g_bufferCur: + 01-01 00:08:01.335 143 512 E 02b01/Rilvendor: [ProcessLastResponse-(channel.c:39)] g_bufferCur endLine is null + 01-01 00:08:01.336 143 512 D 02b01/Rilvendor: [ReadResponse-(channel.c:93)] g_bufferCur : + 01-01 00:08:01.336 143 512 D 02b01/Rilvendor: ^CCALLSTATE: 1,0,1 + 01-01 00:08:01.336 143 512 D 02b01/Rilvendor: [ReadResponse-(channel.c:108)] AT< ^CCALLSTATE: 1,0,1 + 01-01 00:08:01.336 143 512 D 02b01/Rilvendor: [ProcessResponse-(at_support.c:137)] processLine line = ^CCALLSTATE: 1,0,1 + 01-01 00:08:01.336 143 512 D 02b01/Rilvendor: [OnNotifyOps-(vendor_report.c:126)] enter to [^CCALLSTATE: 1,0,1]:(null) + 01-01 00:08:01.336 546 551 D 02b01/CoreService: [OnRemoteRequest-(tel_ril_manager.cpp:80)] RilManager OnRemoteRequest code:1001 + 01-01 00:08:01.336 546 551 D 02b01/CoreService: [NotifyObserver-(observer_handler.cpp:76)] handler->SendEvent:8 + ``` + + +### Development Examples + +- **Outgoing Call** + + The following figure shows the API calling for an outgoing call. + + **Figure 1** Time sequence of API calling for an outgoing call + + + ![](figure/en-us_image_0000001171507146.png) + + When an application initiates an outgoing call, RIL Adapter receives a call request, and the **hril** layer invokes the **ReqDial\(\)** function. In **ReqDial\(\)**, the data passed by the Telephony Service is encapsulated as an AT command and sent to the modem. After executing the dial command, the modem reports the execution result to RIL Adapter through **OnCallReport\(\)**. + + ``` + // Callback function pointer of the call module + static const HRilCallReq g_callReqOps = { + .GetCallList = ReqGetCallList, // Obtain the call list. + .Dial = ReqDial, // Make a call. + .Hangup = ReqHangup, // Disconnect a call. + .Reject = ReqReject, // Reject a call. + .Answer = ReqAnswer, // Answer a call. + }; + + // Service request APIs + HRilOps g_hrilOps = { + .callOps = &g_callReqOps, // API for call service requests + .simOps = &g_simReqOps, // API for SIM card service requests + .smsOps = &g_smsReqOps, // API for SMS and MMS service requests + .networkOps = &g_networkReqOps, // API for cellular data service requests + .dataOps = &g_dataReqOps, // API for network search service requests + .modemOps = &g_modemReqOps, // API for modem service requests + }; + + // Implement the API for processing dial requests. + void ReqDial(ReqDataInfo *requestInfo, const void *data, size_t dataLen) + { + HRilDial *pDial = NULL; + char cmd[MAX_BUFF_SIZE] = {0}; + const char *clir = NULL; + int ret; + int err = HRIL_ERR_SUCCESS; + struct ReportInfo reportInfo = {}; + ResponseInfo *pResponse = NULL; + if (data == NULL) { + TELEPHONY_LOGE("data is null!!!"); + err = HRIL_ERR_INVALID_PARAMETER; + reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0); + OnCallReport(reportInfo, NULL, 0); + return; + } + pDial = (HRilDial *)data; + switch (pDial->clir) { + case CALL_CLIR_INVOCATION: + clir = "I"; + break; /* invocation */ + case CALL_CLIR_SUPPRESSION: + clir = "i"; + break; /* suppression */ + case CALL_CLIR_SUBSCRIPTION_DEFUALT: + default: + clir = ""; + break; /* subscription default */ + } + (void)sprintf_s(cmd, MAX_BUFF_SIZE, "ATD%s%s;", pDial->address, clir); + ret = SendCommandLock(cmd, NULL, 0, &pResponse); // Send the AT command. + if (ret != 0) { + err = HRIL_ERR_CMD_SEND_FAILURE; + TELEPHONY_LOGE("ATD send failed"); + } else { + if (pResponse != NULL && pResponse->success == 0) { + TELEPHONY_LOGE("ReqDial return ERROR"); + err = HRIL_ERR_CMD_NO_CARRIER; + } + } + reportInfo = CreateReportInfo(requestInfo, err, HRIL_RESPONSE, 0); + OnCallReport(reportInfo, NULL, 0); // Invoke the callback function of the call service. + FreeResponseInfo(pResponse); + } + ``` + + +- **Incoming Call** + + The following figure shows the API calling of an incoming call. + + **Figure 2** Time sequence of API calling for an incoming call + + + ![](figure/en-us_image_0000001214727595.png) + + The **g\_reader** thread cyclically reads the messages reported by the modem. When the modem receives an incoming call event, it actively reports the information about the incoming call. + + The **g\_reader** thread calls **OnNotifyOps\(\)** to parse the reported information. If the parsed data reported by the modem starts with characters such as **+CRING** or **RING**, it indicates that an incoming call event exists. In this case, the event is reported to RIL Adapter through **OnCallReport\(reportInfo, NULL, 0\)**. + + ``` + // Parse the data reported by the modem as events proactively reported by the corresponding module. + void OnNotifyOps(const char *s, const char *smsPdu) + { + int ret = 0; + struct ReportInfo reportInfo = {0}; + reportInfo.error = HRIL_ERR_SUCCESS; + reportInfo.type = HRIL_NOTIFICATION; + if (GetRadioState() == HRIL_RADIO_POWER_STATE_UNAVAILABLE) { + return; + } + TELEPHONY_LOGD("enter to [%{public}s]:%{public}s", s, smsPdu); + // Determine the type of the proactively reported events based on the AT command. + if (ReportStrWith(s, "+CRING:") || ReportStrWith(s, "RING") || ReportStrWith(s, "IRING") || + ReportStrWith(s, "NO CARRIER") || ReportStrWith(s, "+CCWA") || ReportStrWith(s, "^CCALLSTATE") || + ReportStrWith(s, "^CEND") || ReportStrWith(s, "^CCWA")) { + reportInfo.notifyId = HNOTI_CALL_STATE_UPDATED; + OnCallReport(reportInfo, NULL, 0); // Invoke the callback function of the call service. + } else if (ReportStrWith(s, "+CMT:")) { + reportInfo.notifyId = HNOTI_SMS_NEW_SMS; + OnSmsReport(reportInfo, (void *)smsPdu, strlen(smsPdu)); + } + // add your codes + ...... + } + ``` + + +## Integrating Modem Vendor Libraries + +### Configuring Compilation Information + +Compile the modem vendor library into a dynamic library by using **BUILD.gn**. Upon startup, RIL Adapter loads the dynamic library to the system in dlopen mode and then initializes the library. For details about how to implement vendor library initialization, see [Initializing a Modem Vendor Library](#section211mcpsimp). The following is an example of **BUILD.gn**: + +``` +import("//build/ohos.gni") +RIL_ADAPTER = "//base/telephony" +ohos_shared_library("ril_vendor") { // Modem vendor library + sources = [ // Source files to compile + "at_call.c", + "at_data.c", + "xxx.c", + ] + include_dirs = [ // Header files + "$RIL_ADAPTER/ril_adapter/vendor/include", + "$RIL_ADAPTER/ril_adapter/interfaces/innerkits", + "include", + ] + deps = [ // Internal dependencies + "//drivers/adapter/uhdf2/osal:libhdf_utils", + "//base/telephony/core_service/utils:libtelephony_common", + ] + external_deps = [ "hilog:libhilog" ] // External dependencies + + part_name = "ril_adapter" // Part name + subsystem_name = "telephony" // Subsystem name +} +``` + +### Debugging and Verification + +1. Compile the code. +2. Check whether **libril\_vendor.z.so** exists in the **/out/{device_name}/telephony/ril\_adapter** directory. If yes, the integration is successful. Otherwise, correct the error and perform debugging and verification again. + diff --git a/en/device-dev/subsystems/subsys-tel-overview.md b/en/device-dev/subsystems/subsys-tel-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..7ee561e36b48430058d26bae3ed4157d0ded9a6e --- /dev/null +++ b/en/device-dev/subsystems/subsys-tel-overview.md @@ -0,0 +1,41 @@ +# Telephony Overview + +## Introduction + +This document provides development guidelines related to the telephony subsystem, including modem vendor library integration, initialization, service request responding, and modem event reporting. It is intended as a reference for developers of different modem chips, helping them efficiently develop telephony service-related functions. + +## Basic Concepts + +- Telephony Service: core service layer of the telephony subsystem. Its main functions are as follows: + - Initializes the RIL Manager module, SIM card module, and network search modules. + - Provides access to the RIL Adapter service, and implements communication with RIL Adapter by registering the callback service. + - Implements communication between modules, such as the call module and SMS module, by subscribing to callbacks. + +- RIL Adapter: RIL adaptation layer of the Telephony subsystem. This layer provides functions such as vendor library loading and service API implementation. It shields the differences of modems supplied by different vendors to provide a unified API for the telephony service layer. It communicates with the telephony service layer by registering the Hardware Driver Foundation \(HDF\) service. +- HDF: Hardware Driver Foundation, which allows for unified access from peripheral devices and provides a framework for driver development and management. +- hdc\_std: OpenHarmony Device Connector, a command line tool provided by OpenHarmony for developers to debug device connectivity. + +## Working Principles + +**Figure 1** RIL Adapter architecture + + +![](figure/en-us_image_0000001210683929.png) + +As shown in the preceding figure, RIL Adapter is logically divided into three layers: **hril\_hdf**, **hril**, and **vendorlib**. + +- **hril\_hdf**: unique entry of RIL Adapter. The main function of this layer is to load modem vendor library files. Wherein, **modem\_adapter** enables a single firmware to adapt to different modems. + + Specifically, **hril\_hdf** obtains the modem type from the kernel and then loads the target modem vendor library based on the modem type. + +- **hril**: OpenHarmony Radio Interface Layer, which provides APIs for communication between the **vendorlib** and various Telephony Service modules, including the SIM card, network search, cellular call, cellular data, and SMS/MMS modules. +- **vendorlib**: Modem vendor library file. Different modem vendor libraries are developed based on standard APIs or service request IDs provided by RIL Adapter. \(**vendorlib** is provided by modem vendors.\) + +After **hril\_hdf** is executed, **vendorlib** is dynamically loaded so that it can obtain the pointers to the response processing and event reporting functions from **hril\_hdf**. After this process is complete, **hril\_hdf** can communicate with a modem through **vendorlib**. + +## Constraints + +**Specifications** + +At least one modem must be supported by a device vendor. If no modem is supported, **vendorlib** APIs do not need to be implemented. + diff --git a/en/device-dev/subsystems/subsys-tel.md b/en/device-dev/subsystems/subsys-tel.md index b99d321dbbd08136cad53418227ef408c23c40ef..d2dfe0e890b7281d4b356f231907469586a15f55 100644 --- a/en/device-dev/subsystems/subsys-tel.md +++ b/en/device-dev/subsystems/subsys-tel.md @@ -1,6 +1,5 @@ -# Subsystems +# Telephony -- [Telephony Service](telephony-service.md) - - [Telephony Service](telephony-service.md) - - [Development Guidelines](development-guidelines.md) +- **[Telephony Overview](subsys-tel-overview.md)** +- **[Telephony Development](subsys-tel-guide.md)** diff --git a/en/device-dev/website.md b/en/device-dev/website.md index eb6097f059d0685cc8689f838e668960c1b5cd77..90ace45acfc8819dcad3e8f237948095beb9385a 100644 --- a/en/device-dev/website.md +++ b/en/device-dev/website.md @@ -358,10 +358,10 @@ - [Setting Up a Development Environment](subsystems/subsys-application-framework-envbuild.md) - [Development Guidelines](subsystems/subsys-application-framework-guide.md) - [Development Example](subsystems/subsys-application-framework-demo.md) - - [OTA Upgrade](subsystems/subsys-ota-guide.md) - - Telephony Service - - [Telephony Service](subsystems/telephony-service.md) - - [Development Guidelines](subsystems/development-guidelines.md) + - [OTA Update](subsystems/subsys-ota-guide.md) + - Telephony + - [Telephony Overview](subsystems/subsys-tel-overview.md) + - [Telephony Development](subsystems/subsys-tel-guide.md) - Security - [Overview](subsystems/subsys-security-overview.md) - [Development Guidelines on Application Signature Verification](subsystems/subsys-security-sigverify.md) diff --git a/en/readme.md b/en/readme.md index 7c8b305e741b55835c6bfdc14a794b69de572487..9168f0abf8e2142427ab6ccead628f60d02cff10 100644 --- a/en/readme.md +++ b/en/readme.md @@ -8,5 +8,6 @@ This repository stores a complete range of OpenHarmony documentation. The conten - [Release Notes](release-notes/Readme.md) - [Subsystems](./readme) - OpenHarmony Contribution - - [How to Contribute](contribute/contribution.md) + - [How to Contribute](contribute/how-to-contribute.md) - [OpenHarmony Part and API Design Reference](./design) + diff --git a/en/website.md b/en/website.md index cc078aadb03513172a7c5a72a7a71552834efe37..3ec0bdc640ac5c513e1b7e2a01acaa5981bacd38 100644 --- a/en/website.md +++ b/en/website.md @@ -21,11 +21,11 @@ - [OpenHarmony 1.1.0 LTS (2021-04-01)](release-notes/OpenHarmony-1-1-0-LTS.md) - [OpenHarmony 1.0 (2020-09-10)](release-notes/OpenHarmony-1-0.md) - Contribution - - [Contribution](contribute/contribution.md) + - [How to Contribute](contribute/how-to-contribute.md) - [Code of Conduct](contribute/code-of-conduct.md) - [Code Contribution](contribute/code-contribution.md) - [Contribution Process](contribute/contribution-process.md) - - [Auto-Test](readme/test_subsystem.md) + - [Auto-Test](readme/test.md) - [Documentation Contribution](contribute/documentation-contribution.md) - [Writing Instructions](contribute/writing-instructions.md) - [Communication in Community](contribute/communication-in-community.md) diff --git a/zh-cn/device-dev/quick-start/Readme-CN.md b/zh-cn/device-dev/quick-start/Readme-CN.md index 16d6bbe9f6314de0fac33e80a1c0868d9c302a41..93f6cd8a77099718bb886726151c78a1531f0f00 100644 --- a/zh-cn/device-dev/quick-start/Readme-CN.md +++ b/zh-cn/device-dev/quick-start/Readme-CN.md @@ -12,7 +12,7 @@ - [烧录](quickstart-ide-lite-steps-hi3861-burn.md) - [联网](quickstart-ide-lite-steps-hi3861-netconfig.md) - [调试验证](quickstart-ide-lite-steps-hi3861-debug.md) - - [运行](quickstart-ide-lite-steps-hi3816-running.md) + - [运行](quickstart-ide-lite-steps-hi3861-running.md) - Hi3516开发板 - [编写“Hello World”程序](quickstart-ide-lite-steps-hi3516-application-framework.md) - [编译](quickstart-ide-lite-steps-hi3516-building.md) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3816-running.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-running.md similarity index 100% rename from zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3816-running.md rename to zh-cn/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-running.md diff --git a/zh-cn/device-dev/website.md b/zh-cn/device-dev/website.md index 9d151d2dd31ae4b95805a7af5eb1f10335d6f16a..cbe9b0bd22241fa05af7034fcf8ec60393f9967f 100644 --- a/zh-cn/device-dev/website.md +++ b/zh-cn/device-dev/website.md @@ -16,7 +16,7 @@ - [烧录](quick-start/quickstart-ide-lite-steps-hi3861-burn.md) - [联网](quick-start/quickstart-ide-lite-steps-hi3861-netconfig.md) - [调试验证](quick-start/quickstart-ide-lite-steps-hi3861-debug.md) - - [运行](quick-start/quickstart-ide-lite-steps-hi3816-running.md) + - [运行](quick-start/quickstart-ide-lite-steps-hi3861-running.md) - Hi3516开发板 - [编写“Hello World”程序](quick-start/quickstart-ide-lite-steps-hi3516-application-framework.md) - [编译](quick-start/quickstart-ide-lite-steps-hi3516-building.md)