提交 b40ff56e 编写于 作者: N NEEN

!333 update docs bugs

Merge pull request !333 from 杨妮/master
上级 869de226
......@@ -25,6 +25,9 @@
- [AudioDeviceDescriptor](#en-us_topic_0000001149807881_section17427121913310)
- [AudioDeviceDescriptors](#en-us_topic_0000001149807881_section5181155710523)
>![](public_sys-resources/icon-note.gif) **NOTE:**
>Due to permission issues, these feature are temporarily unavailable for the standard system.
## Modules to Import<a name="en-us_topic_0000001149807881_s56d19203690d4782bfc74069abb6bd71"></a>
```
......
......@@ -25,6 +25,9 @@
- [AudioState](#en-us_topic_0000001103383404_section5181155710523)
>![](public_sys-resources/icon-note.gif) **NOTE:**
>Due to permission issues, these feature are temporarily unavailable for the standard system.
## Modules to Import<a name="en-us_topic_0000001103383404_s56d19203690d4782bfc74069abb6bd71"></a>
```
......
......@@ -4,6 +4,9 @@
OpenHarmony provides the audio module for your application to implement audio-related features, including audio playback and volume management.
>![](public_sys-resources/icon-note.gif) **NOTE:**
>Due to permission issues, these feature are temporarily unavailable for the standard system.
## Basic Concepts<a name="section296512102281"></a>
- **Sampling**
......
# Basics
- [DevEco Studio \(OpenHarmony\) User Guide](deveco-studio-(openharmony)-user-guide.md)
- [Overview](overview.md)
- [Configuring the OpenHarmony SDK](configuring-the-openharmony-sdk.md)
- [Configuring the OpenHarmony App Signature](configuring-the-openharmony-app-signature.md)
- [Installing and Running Your OpenHarmony App](installing-and-running-your-openharmony-app.md)
- [Getting Started](getting-started.md)
- [Preparations](preparations.md)
- [Getting Started with JavaScript](getting-started-with-javascript.md)
# Configuring the OpenHarmony App Signature<a name="EN-US_TOPIC_0000001159890371"></a>
- [Generating a Key Store and CSR](#section153146467405)
- [Generating an App Certificate](#section136609429562)
- [Generating the App Profile](#section2048641015325)
- [Configuring App Signature Information](#section10152423193310)
Before running and debugging the OpenHarmony app on a real device, you need to sign the app. This section describes how to configure the signature of an OpenHarmony app. Operation instructions are the same in _HUAWEI DevEco Studio User Guide_ except this section. For details, see [HUAWEI DevEco Studio User Guide](https://developer.harmonyos.com/en/docs/documentation/doc-guides/tools_overview-0000001053582387). See the following figure for the process of configuring app signature information.
![](figures/en-us_image_0000001113808114.png)
## Generating a Key Store and CSR<a name="section153146467405"></a>
OpenHarmony uses digital certificates \(.cer\) and **Profile** files \(.p7b\) to ensure app integrity. Before applying for these files, you need to generate a key store \(.p12\) and a certificate signing request \(.csr\). You can do so in DevEco Studio or a command-line tool. For details, see [Generating a Key Store and CSR](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ide_debug_device-0000001053822404#EN-US_TOPIC_0000001154985555__section837891802519).
## Generating an App Certificate<a name="section136609429562"></a>
Use the CSR generated in [Generating a Key Store and CSR](#section153146467405) to generate the digital certificate required for app signing. The method is as follows:
Go to the **Sdk\\toolchains\\lib** directory in the DevEco Studio installation directory, and run the following command in the CLI \(if the **keytool** command cannot be executed, add the JDK environment variables to the system environment variables\). You only need to modify the input and output to quickly generate a certificate. That is, modify **-infile** to specify the path of the CSR and **-outfile** to specify the name and path of the output certificate.
```
keytool -gencert -alias "OpenHarmony Application CA" -infile app.csr -outfile IDE.cer -keystore OpenHarmony.p12 -sigalg SHA384withECDSA -storepass 123456 -ext KeyUsage:"critical=digitalSignature" -validity 3650 -rfc
```
>![](public_sys-resources/icon-note.gif) **NOTE:**
>In the preceding command, the fields in blue cannot be modified. Otherwise, the certificate cannot be generated.
Refer to the following descriptions about the parameters in the command:
- **alias**: alias of the CA private key used for issuing certificates. The CA private key of the OpenHarmony community is stored in the **OpenHarmony.p12** key store file. This parameter cannot be modified.
- **infile**: path of the CSR file.
- **outfile**: name and path of the certificate chain file.
- **keystore**: path of the CA key store for issuing certificates. The name of the OpenHarmony key store file is **OpenHarmony.p12**. The file is stored in **Sdk\\toolchains\\lib** of the OpenHarmony SDK. This parameter cannot be modified. Note that the **OpenHarmony.p12** file is not the .p12 file generated in [Generating a Key Store and CSR](#section153146467405).
- **sigalg**: certificate signature algorithm. This parameter cannot be modified.
- **storepass**: key store password. The password is **123456** and cannot be changed.
- **ext**: certificate extension. This parameter cannot be modified.
- **validity**: certificate validity period, which is user-defined.
- **rfc**: specifies the output file format. This parameter cannot be modified.
## Generating the App Profile<a name="section2048641015325"></a>
The profile contains the package name of the OpenHarmony app, digital certificate information, certificate permissions that can be applied for by the app, and devices that support app debugging \(the device list will be empty if the app type is Release\). Each app package must contain a profile file.
Go to the **Sdk\\toolchains\\lib** directory, open the command-line tool, and run the following command.
```
java -jar provisionsigtool.jar sign --in UnsgnedReleasedProfileTemplate.json --out SgnedReleasedProfileTemplate.p7b --keystore OpenHarmony.p12 --storepass 123456 --alias "OpenHarmony Application Profile Release" --sigAlg SHA256withECDSA --cert OpenHarmonyProfileRelease.pem --validity 365 --developer-id ohosdeveloper --java -jar provisionsigtool.jar sign --in UnsgnedReleasedProfileTemplate.json --out SgnedReleasedProfileTemplate.p7b --keystore OpenHarmony.p12 --storepass 123456 --alias "OpenHarmony Application Profile Release" --sigAlg SHA256withECDSA --cert OpenHarmonyProfileRelease.pem --validity 365 --developer-id ohosdeveloper --bundle-name package name --permission restricted permission name (optional) --permission restricted permission name (optional) --distribution-certificate IDE.cer
```
>![](public_sys-resources/icon-note.gif) **NOTE:**
>In the preceding command, the fields in blue cannot be modified. Otherwise, the profile cannot be generated.
Refer to the following descriptions about the parameters in the command:
- **provisionsigtool**: tool for generating the profile which is stored in **Sdk\\toolchains\\lib** of the OpenHarmony SDK.
- **in**: path of the profile template which is stored in **Sdk\\toolchains\\lib** of the OpenHarmony SDK. This parameter cannot be modified.
- **out**: name and path of the profile.
- **keystore**: path of the key store for issuing certificates. The name of the OpenHarmony key store file is **OpenHarmony.p12**. The file is stored in **Sdk\\toolchains\\lib** of the OpenHarmony SDK. This parameter cannot be modified.
- **storepass**: key store password. The password is **123456** and cannot be changed.
- **alias**: alias of the private key used for app signing. The CA private key of the OpenHarmony community is stored in the **OpenHarmony.p12** key store file. This parameter cannot be modified.
- **sigalg**: certificate signing algorithm. This parameter cannot be modified.
- **cert**: path of the certificate of the signature profile. The file is stored in **Sdk\\toolchains\\lib** of the OpenHarmony SDK. This parameter cannot be modified.
- **validity**: certificate validity period, which is user-defined.
- **developer-id**: developer ID, which is a user-defined character string.
- **bundle-name**: app package name.
- **permission** \(optional\): If permissions are not required, this field can be left empty. You can add multiple restricted permissions in the following way: ohos.permission.READ\_CONTACTS, ohos.permission.WRITE\_CONTACTS.
- **distribution-certificate**: certificate generated in [Generating an App Certificate](#section136609429562).
## Configuring App Signature Information<a name="section10152423193310"></a>
Before debugging on a real device, use the private key file \(.p12\), certificate file \(.cer\), and profile file \(.p7b\) to sign the target module.
Go to **File** \> **Project Structure**. On the displayed page, go to **Modules** \> _Module name_ \> **Signing Configs**, and set the signing parameters under **debug**.
>![](public_sys-resources/icon-note.gif) **NOTE:**
>To release a HAP package of the release type, configure the signature information from **Modules** \> _Module name_ \> **Signing Configs** \> **release**.
- **Store File**: Select the key store file with the file name extension .p12, which is generated in [Generating a Key Store and CSR](#section153146467405).
- **Store Password**: Enter the key store password.
- **Key Alias**: Enter the alias of the key.
- **Key Password**: Enter the password of the key.
- **Sign Alg**: Specify the signature algorithm, which has a fixed value of **SHA256withECDSA**.
- **Profile File**: Select the obtained debug profile in .p7b format.
- **Certpath File**: Select the obtained debug certificate in .cer format.
![](figures/en-us_image_0000001160327971.png)
Click **OK** to save your configurations. Then you can view the signature configuration information in **build.gradle** of the module.
![](figures/en-us_image_0000001113648168.png)
By default, the type of a HAP package compiled using DevEco Studio is set to **debug**. For a release type, click the **OhosBuild Variants** tab in the lower left corner of the project and set the type to **release**. For details about how to compile and build the HAP, see [HUAWEI DevEco Studio User Guide](https://developer.harmonyos.com/en/docs/documentation/doc-guides/build_hap-0000001053342418).
![](figures/en-us_image_0000001115066116.png)
After the compilation is complete, you can obtain the HAP package of your OpenHarmony app from the **build** directory of the project.
![](figures/en-us_image_0000001163552429.png)
# Configuring the OpenHarmony SDK<a name="EN-US_TOPIC_0000001113561194"></a>
- [Prerequisites](#section164161442154812)
- [Configuring the SDK Information](#section1265592425017)
- [Importing the Project](#section12559415183418)
To set up the OpenHarmony app development environment, configure the corresponding SDK information in DevEco Studio first.
>![](public_sys-resources/icon-note.gif) **NOTE:**
>The OpenHarmony SDK is of the API Version 6 Canary1, with some toolchains removed, which is not applicable to HarmonyOS app development.
## Prerequisites<a name="section164161442154812"></a>
- DevEco Studio 2.1 Release version has been downloaded and installed. You can click [here](https://developer.harmonyos.com/en/develop/deveco-studio#download) to download it.
- The OpenHarmony SDK package has been obtained and decompressed. You can click [here](https://mirror.iscas.ac.cn/OpenHarmony/sdk/OpenHarmony-SDK-2.0-Canary.7z) to download it.
## Configuring the SDK Information<a name="section1265592425017"></a>
DevEco Studio manages SDKs and toolchains using SDK Manager. OpenHarmony contains the following SDK packages:
<a name="table64565810577"></a>
<table><thead align="left"><tr id="row12455580576"><th class="cellrowborder" valign="top" width="24.709999999999997%" id="mcps1.1.4.1.1"><p id="p34565812572"><a name="p34565812572"></a><a name="p34565812572"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="25.3%" id="mcps1.1.4.1.2"><p id="p104675817575"><a name="p104675817575"></a><a name="p104675817575"></a>Package Name</p>
</th>
<th class="cellrowborder" valign="top" width="49.99%" id="mcps1.1.4.1.3"><p id="p194610586574"><a name="p194610586574"></a><a name="p194610586574"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row134615875716"><td class="cellrowborder" rowspan="2" valign="top" width="24.709999999999997%" headers="mcps1.1.4.1.1 "><p id="p8312243811"><a name="p8312243811"></a><a name="p8312243811"></a>SDK</p>
</td>
<td class="cellrowborder" valign="top" width="25.3%" headers="mcps1.1.4.1.2 "><p id="p674413467918"><a name="p674413467918"></a><a name="p674413467918"></a>Java</p>
</td>
<td class="cellrowborder" valign="top" width="49.99%" headers="mcps1.1.4.1.3 "><p id="p107441464917"><a name="p107441464917"></a><a name="p107441464917"></a>SDK for Java.</p>
</td>
</tr>
<tr id="row44334409916"><td class="cellrowborder" valign="top" headers="mcps1.1.4.1.1 "><p id="p1946175813574"><a name="p1946175813574"></a><a name="p1946175813574"></a>JS</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.1.4.1.2 "><p id="p54625885713"><a name="p54625885713"></a><a name="p54625885713"></a>SDK for JS.</p>
</td>
</tr>
<tr id="row14474585576"><td class="cellrowborder" rowspan="2" valign="top" width="24.709999999999997%" headers="mcps1.1.4.1.1 "><p id="p124765819578"><a name="p124765819578"></a><a name="p124765819578"></a>SDK Tool</p>
</td>
<td class="cellrowborder" valign="top" width="25.3%" headers="mcps1.1.4.1.2 "><p id="p1947135818571"><a name="p1947135818571"></a><a name="p1947135818571"></a>Toolchains</p>
</td>
<td class="cellrowborder" valign="top" width="49.99%" headers="mcps1.1.4.1.3 "><p id="p7471158105711"><a name="p7471158105711"></a><a name="p7471158105711"></a>Includes compiling, packaging, signing, database management, and other tools that are required to develop OpenHarmony apps.</p>
</td>
</tr>
<tr id="row337931010"><td class="cellrowborder" valign="top" headers="mcps1.1.4.1.1 "><p id="p193791108"><a name="p193791108"></a><a name="p193791108"></a>Previewer</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.1.4.1.2 "><p id="p1238951018"><a name="p1238951018"></a><a name="p1238951018"></a>OpenHarmony app previewer, which can be used to view the UI layout during app development.</p>
</td>
</tr>
</tbody>
</table>
1. Open DevEco Studio. If this is the first time you are using it, select **Do not import settings** and click **OK**.
2. Follow the instructions in DevEco Studio to go to the SDK download page. In the **HarmonyOS SDK Location** field, select the local directory where the SDK package was decompressed, then click **Next**.
>![](public_sys-resources/icon-note.gif) **NOTE:**
>If you are not using DevEco Studio for the first time, the SDK download page may not be displayed. In this case, go to **Configure \> Settings \> Appearance & Behavior \> System Settings \> HarmonyOS SDK** and click **HarmonyOS SDK Location** to download the SDK.
![](figures/en-us_image_0000001117288684.png)
3. After the SDK is installed, click **Finish**. The DevEco Studio welcome page will then be displayed.
![](figures/en-us_image_0000001162781359.png)
4. Go to the **Sdk\\js\\2.2.0.0\\build-tools\\ace-loader** directory, run the following commands in CLI, and wait until the installation is complete.
```
npm cache clean -f
npm install
```
![](figures/en-us_image_0000001163170097.png)
## Importing the Project<a name="section12559415183418"></a>
After the OpenHarmony SDK is configured, you can start developing your app only by **importing a sample project** to begin with.
1. On the DevEco Studio welcome page, click **Import HarmonyOS Sample** to import a sample project.
![](figures/en-us_image_0000001163495457.png)
2. Go to **ability** \> **HelloWorld** and click **Next**.
![](figures/en-us_image_0000001117295732.png)
3. Configure **App Name** and **Project Location** and click **Finish**. Wait until the sample project is imported.
![](figures/en-us_image_0000001163500855.png)
4. Wait until the project sync is indicated to be failed. Open the **build.gradle** file in the project and change the version number of the HAP plugin to **2.4.4.3-RC**.
![](figures/en-us_image_0000001163550987.png)
5. Click ![](figures/en-us_image_0000001117304698.png) under **Gradle** in the upper right corner to sync the project again.
![](figures/en-us_image_0000001117145200.png)
6. When the project is successfully synced, you can develop your OpenHarmony app.
![](figures/en-us_image_0000001117145614.png)
# DevEco Studio \(OpenHarmony\) User Guide<a name="EN-US_TOPIC_0000001163049851"></a>
- **[Overview](overview.md)**
- **[Configuring the OpenHarmony SDK](configuring-the-openharmony-sdk.md)**
- **[Configuring the OpenHarmony App Signature](configuring-the-openharmony-app-signature.md)**
- **[Installing and Running Your OpenHarmony App](installing-and-running-your-openharmony-app.md)**
# Installing and Running Your OpenHarmony App<a name="EN-US_TOPIC_0000001115941596"></a>
To install your OpenHarmony app, use the hdc tool to manually run the corresponding commands.
You can manually obtain the hdc tool from the open-source repository. Use the tool to send the compiled HAP package to the device and run the corresponding hdc commands to install the app.
The hdc commands are as follows:
- File sending
**file send _localpath remotepath_**
Example:
```
hdc_std file send E:\hwadmin.hap /data/local/tmp/hwadmin.hap
```
- App installation
**install \[-r/-d/-g\] _package_**
Example:
```
hdc_std install hwadmin.hap
```
- Log capturing
**hilog**
Example:
```
hdc_std hilog
```
For details about how to use the hdc tool and the command format, see the open-source repository **docs/en/device-dev/subsystems/hdc-usage-guidelines.md**.
# Overview<a name="EN-US_TOPIC_0000001116414108"></a>
- [About the Document](#section189422248491)
- [Restrictions](#section65191625782)
- [DevEco Studio Evolution Roadmap](#section187875207166)
## About the Document<a name="section189422248491"></a>
DevEco Studio is an integrated development environment \(IDE\) of HarmonyOS apps. As HarmonyOS is developed based on OpenHarmony, DevEco Studio can also be used to develop OpenHarmony apps.
The process of developing an OpenHarmony app using DevEco Studio is the same as that of developing a HarmonyOS app. This document describes the differences between OpenHarmony and HarmonyOS app development.
- **Environment setup**: You need to manually configure the SDK for the OpenHarmony app development. For details, see [Configuring the OpenHarmony SDK](configuring-the-openharmony-sdk.md).
- **Signature configuration for debugging**: To run an OpenHarmony app on a real device, you need to sign the app first. For instructions, see [Configuring the OpenHarmony App Signature](configuring-the-openharmony-app-signature.md).
- **App running on a real device**: To run your app on a real device, you need to use the hdc tool to push the HAP package of the OpenHarmony to the real device for installation. For details, see [Installing and Running Your OpenHarmony App](installing-and-running-your-openharmony-app.md).
For details about how to use DevEco Studio, see [HUAWEI DevEco Studio User Guide](https://developer.harmonyos.com/en/docs/documentation/doc-guides/tools_overview-0000001053582387).
## Restrictions<a name="section65191625782"></a>
- OpenHarmony supports only app development in JS.
- Developing OpenHarmony apps in DevEco Studio is supported on Windows.
DevEco Studio serves as a development tool for both OpenHarmony and HarmonyOS apps. Refer to the following table for descriptions about the IDE function differences between OpenHarmony and HarmonyOS.
<a name="table852516933419"></a>
<table><thead align="left"><tr id="row1952618913415"><th class="cellrowborder" valign="top" width="29.882988298829883%" id="mcps1.1.4.1.1"><p id="p165268963418"><a name="p165268963418"></a><a name="p165268963418"></a>Feature</p>
</th>
<th class="cellrowborder" valign="top" width="36.783678367836785%" id="mcps1.1.4.1.2"><p id="p25262914349"><a name="p25262914349"></a><a name="p25262914349"></a>HarmonyOS</p>
</th>
<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.1.4.1.3"><p id="p125265912343"><a name="p125265912343"></a><a name="p125265912343"></a>OpenHarmony</p>
</th>
</tr>
</thead>
<tbody><tr id="row3627192183319"><td class="cellrowborder" valign="top" width="29.882988298829883%" headers="mcps1.1.4.1.1 "><p id="p1362817213320"><a name="p1362817213320"></a><a name="p1362817213320"></a>Creating modules</p>
</td>
<td class="cellrowborder" valign="top" width="36.783678367836785%" headers="mcps1.1.4.1.2 "><p id="p8226191353"><a name="p8226191353"></a><a name="p8226191353"></a><strong id="b17226139143511"><a name="b17226139143511"></a><a name="b17226139143511"></a></strong></p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.3 "><p id="p14226894353"><a name="p14226894353"></a><a name="p14226894353"></a><strong id="b122614963510"><a name="b122614963510"></a><a name="b122614963510"></a>X</strong></p>
</td>
</tr>
<tr id="row955132319355"><td class="cellrowborder" valign="top" width="29.882988298829883%" headers="mcps1.1.4.1.1 "><p id="p1655172423517"><a name="p1655172423517"></a><a name="p1655172423517"></a>Service widgets</p>
</td>
<td class="cellrowborder" valign="top" width="36.783678367836785%" headers="mcps1.1.4.1.2 "><p id="p1555192493516"><a name="p1555192493516"></a><a name="p1555192493516"></a><strong id="b11551102403511"><a name="b11551102403511"></a><a name="b11551102403511"></a></strong></p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.3 "><p id="p85511324183514"><a name="p85511324183514"></a><a name="p85511324183514"></a><strong id="b255116244356"><a name="b255116244356"></a><a name="b255116244356"></a>X</strong></p>
</td>
</tr>
<tr id="row1552619933411"><td class="cellrowborder" valign="top" width="29.882988298829883%" headers="mcps1.1.4.1.1 "><p id="p11430122863614"><a name="p11430122863614"></a><a name="p11430122863614"></a>Automatic signing</p>
</td>
<td class="cellrowborder" valign="top" width="36.783678367836785%" headers="mcps1.1.4.1.2 "><p id="p243122863614"><a name="p243122863614"></a><a name="p243122863614"></a><strong id="b14431122873617"><a name="b14431122873617"></a><a name="b14431122873617"></a></strong></p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.3 "><p id="p4431162819362"><a name="p4431162819362"></a><a name="p4431162819362"></a><strong id="b4431328163619"><a name="b4431328163619"></a><a name="b4431328163619"></a>X</strong></p>
</td>
</tr>
<tr id="row115263913344"><td class="cellrowborder" valign="top" width="29.882988298829883%" headers="mcps1.1.4.1.1 "><p id="p1323118352362"><a name="p1323118352362"></a><a name="p1323118352362"></a>Remote emulator</p>
</td>
<td class="cellrowborder" valign="top" width="36.783678367836785%" headers="mcps1.1.4.1.2 "><p id="p723143573614"><a name="p723143573614"></a><a name="p723143573614"></a><strong id="b8231173533613"><a name="b8231173533613"></a><a name="b8231173533613"></a></strong></p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.3 "><p id="p7231435143619"><a name="p7231435143619"></a><a name="p7231435143619"></a><strong id="b1523111352363"><a name="b1523111352363"></a><a name="b1523111352363"></a>X</strong></p>
</td>
</tr>
<tr id="row183441037105115"><td class="cellrowborder" valign="top" width="29.882988298829883%" headers="mcps1.1.4.1.1 "><p id="p5345237155119"><a name="p5345237155119"></a><a name="p5345237155119"></a>Local emulator</p>
</td>
<td class="cellrowborder" valign="top" width="36.783678367836785%" headers="mcps1.1.4.1.2 "><p id="p393214320517"><a name="p393214320517"></a><a name="p393214320517"></a><strong id="b1693264315118"><a name="b1693264315118"></a><a name="b1693264315118"></a></strong></p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.3 "><p id="p139324438515"><a name="p139324438515"></a><a name="p139324438515"></a><strong id="b169321543175116"><a name="b169321543175116"></a><a name="b169321543175116"></a>X</strong></p>
</td>
</tr>
<tr id="row15269933419"><td class="cellrowborder" valign="top" width="29.882988298829883%" headers="mcps1.1.4.1.1 "><p id="p152318351369"><a name="p152318351369"></a><a name="p152318351369"></a>Using DevEco Studio for debugging, log viewing, and optimization</p>
</td>
<td class="cellrowborder" valign="top" width="36.783678367836785%" headers="mcps1.1.4.1.2 "><p id="p623118353360"><a name="p623118353360"></a><a name="p623118353360"></a><strong id="b10231535143615"><a name="b10231535143615"></a><a name="b10231535143615"></a></strong></p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.3 "><p id="p192313353367"><a name="p192313353367"></a><a name="p192313353367"></a><strong id="b1423123514368"><a name="b1423123514368"></a><a name="b1423123514368"></a>X</strong></p>
</td>
</tr>
<tr id="row7357734143617"><td class="cellrowborder" valign="top" width="29.882988298829883%" headers="mcps1.1.4.1.1 "><p id="p76694468363"><a name="p76694468363"></a><a name="p76694468363"></a>Cloud testing</p>
</td>
<td class="cellrowborder" valign="top" width="36.783678367836785%" headers="mcps1.1.4.1.2 "><p id="p2066918465369"><a name="p2066918465369"></a><a name="p2066918465369"></a><strong id="b3669546133610"><a name="b3669546133610"></a><a name="b3669546133610"></a></strong></p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.3 "><p id="p1266910467363"><a name="p1266910467363"></a><a name="p1266910467363"></a><strong id="b11669144693616"><a name="b11669144693616"></a><a name="b11669144693616"></a>X</strong></p>
</td>
</tr>
<tr id="row124331939191517"><td class="cellrowborder" valign="top" width="29.882988298829883%" headers="mcps1.1.4.1.1 "><p id="p146691546143619"><a name="p146691546143619"></a><a name="p146691546143619"></a>Security testing</p>
</td>
<td class="cellrowborder" valign="top" width="36.783678367836785%" headers="mcps1.1.4.1.2 "><p id="p614815145371"><a name="p614815145371"></a><a name="p614815145371"></a><strong id="b101485149375"><a name="b101485149375"></a><a name="b101485149375"></a></strong></p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.3 "><p id="p1514811149374"><a name="p1514811149374"></a><a name="p1514811149374"></a><strong id="b01481614133717"><a name="b01481614133717"></a><a name="b01481614133717"></a>X</strong></p>
</td>
</tr>
</tbody>
</table>
## DevEco Studio Evolution Roadmap<a name="section187875207166"></a>
Refer to the following figure for when the HUAWEI DevEco Studio support for OpenHarmony app development is available in different phases.
![](figures/en-us_image_0000001163571565.png)
......@@ -3,13 +3,7 @@
- [Basic Capabilities](#section1393616301083)
- [Overall Structure](#section105231413161115)
The JS UI framework allows you to develop cross-device applications with high performance. It supports web-development-like paradigm and polymorphic UIs.
It is considered best practice to master the following knowledge before using this document:
- HTML5
- CSS
- JavaScript
The OpenHarmony JS UI framework provides basic, container, and canvas UI components and standard CSS animation capabilities. It supports the web-development-like programming paradigm.
## Basic Capabilities<a name="section1393616301083"></a>
......@@ -18,20 +12,12 @@ It is considered best practice to master the following knowledge before using th
The JS UI framework supports languages that are similar to those for web development, such as HTML and CSS. You can use them to describe the page layout and style, and use JavaScript \(conforming to the ECMAScript specification\) for page behavior. This paradigm allows you to avoid code for UI state switching. The view configuration information is intuitive.
- **Cross-device UI display**
The JS UI framework allows your UI to be displayed across devices. The UI pages can automatically adapt to various styles of device screens. This is obscure to developers and reduces their cost of manual multi-device adaptation.
- **High performance**
The JS UI framework has many core controls, such as lists, images, and various container components. The rendering process is optimized for the declarative coding syntax.
## Overall Structure<a name="section105231413161115"></a>
The JS UI framework consists of the application, framework, engine, and porting layers.
![](figures/en-us_image_0000001110468610.png)
![](figures/zh-cn_image_0000001077953992.png)
- **Application**
......
......@@ -4,5 +4,5 @@
## Setting Up the Development Environment and Creating a Project<a name="section1912530122716"></a>
Download and install DevEco Studio. For details, see the DevEco Studio User Guide for OpenHarmony.
Download and install DevEco Studio. For details, see the [DHUAWEI DevEco Studio User Guide](../docs/zh-cn/application-dev/quick-start/DevEco-Studio(OpenHarmony)使用指南.md).
......@@ -10,7 +10,7 @@ Before you install the app and run it on the development board, install the DevE
Change the HDC client name to **hdc.exe** and add the path above to the system environment variable **path**.
2. Open the **cmd** window, and run the following command to push the HAP file to the device directory, and install it:
2. Open the **cmd** window, and run the following commands to push the HAP file to the device directory, and install it:
```
hdc smode
......
# Signing and Packaging<a name="EN-US_TOPIC_0000001161737833"></a>
After finishing writing the app code, you need to sign and package the app before running it on a real device. For details, see [Signing and Packaging Guide](../docs/zh-cn/application-dev/quick-start/配置OpenHarmony应用签名信息.md).
After finishing writing the app code, you need to sign and package the app before running it on a real device. For details, see Signing and Packaging Guide.
......@@ -65,16 +65,6 @@
- [Development Example](development-example.md)
- [OTA Upgrade](ota-upgrade.md)
- [Telephony Service](telephony-service.md)
- [Overview](overview-6.md)
- [Development Guidelines](development-guidelines-7.md)
- [Integrating Modem Vendor Library](integrating-modem-vendor-library.md)
- [Initializing a Modem Vendor Library](initializing-a-modem-vendor-library.md)
- [Responding to Modem Service Requests](responding-to-modem-service-requests.md)
- [Reporting Modem Events](reporting-modem-events.md)
- [Development Examples](development-examples-8.md)
- [Security](security.md)
- [Overview](overview-9.md)
- [Development Guidelines on Application Signature Verification](development-guidelines-on-application-signature-verification.md)
......
# Compilation and Building Guidelines<a name="EN-US_TOPIC_0000001060378721"></a>
- [Directory Structure](#section56731811102915)
- [Component-based Building Procedure](#section4207112818418)
- [Prerequisites](#section13333171022312)
- [How to Use the hb Command Line Tool](#section477242204612)
- [Adding a Module](#section4207112818418)
- [Adding a Chipset Solution](#section2737141421917)
- [Adding a Product Solution](#section720881917199)
## Directory Structure<a name="section56731811102915"></a>
## Prerequisites<a name="section13333171022312"></a>
```
build/lite # Primary directory for compilation and building
├── components # Component description file
├── hb # hb pip installation package
├── make_rootfs # make script for the file system
├── config # Compilation configuration items
│ ├── component # Definitions of component-related templates, including static libraries, dynamic libraries, extension components, and emulator libraries
│ ├── kernel # Compilation configuration parameters of the kernel
│ └── subsystem # Subsystem template
├── ndk # NDK-related compilation scripts and configuration parameters
└── toolchain # Compilation toolchains, which contain the compiler directories, compilation options, and linking options
```
Ensure that the development environment has GN, Ninja, Python 3.7.4 or later, and hb commands. For details about installation methods, see [Basic OS Environment Setup](../quick-start/environment-setup.md).
## Component-based Building Procedure<a name="section4207112818418"></a>
## How to Use the hb Command Line Tool<a name="section477242204612"></a>
1. Add the component compilation script.
hb is a command line tool for OpenHarmony to execute build commands. Common hb commands are described as follows:
The compilation script language for the component is GN. For details about its basic usage, see the [GN Quick Start Guide](https://gn.googlesource.com/gn/+/master/docs/quick_start.md). In GN, a component is a compilation unit, which can be a static library, a dynamic library, or an executable file.
1. **hb set**
The following example adds a script to compile the **hello\_world** component \(as an executable file\).
```
hb set -h
usage: hb set [-h] [-root [ROOT_PATH]] [-p]
optional arguments:
-h, --help show this help message and exit
-root [ROOT_PATH], --root_path [ROOT_PATH]
Set OHOS root path
-p, --product Set OHOS board and kernel
```
- If you run **hb set** with no argument, the default setting process starts.
- You can run **hb set -root** _dir_ to set the root directory of the source code.
- **hb set -p** is used to set the product to build.
2. **hb env**
View the current configuration.
```
hb env
[OHOS INFO] root path: xxx
[OHOS INFO] board: hispark_taurus
[OHOS INFO] kernel: liteos
[OHOS INFO] product: ipcamera
[OHOS INFO] product path: xxx/vendor/hisilicon/ipcamera
[OHOS INFO] device path: xxx/device/hisilicon/hispark_taurus/sdk_linux_4.19
```
3. **hb build**
```
hb build -h
usage: hb build [-h] [-b BUILD_TYPE] [-c COMPILER] [-t [TEST [TEST ...]]]
[--dmverity] [-p PRODUCT] [-f] [-n]
[component [component ...]]
positional arguments:
component name of the component
optional arguments:
-h, --help show this help message and exit
-b BUILD_TYPE, --build_type BUILD_TYPE
release or debug version
-t [TEST [TEST ...]], --test [TEST [TEST ...]]
compile test suit
--dmverity Enable dmverity
-p PRODUCT, --product PRODUCT
build a specified product with
{product_name}@{company}, eg: ipcamera@hisilcon
-f, --full full code compilation
-T [TARGET [TARGET ...]], --target [TARGET [TARGET ...]]
Compile single target
```
- If you run **hb build** with no argument, the previously configured code directory, product, and options are used for the build. The **-f** option will delete all products to be built, which is equivalent to running **hb clean** and **hb build**.
- You can run **hb build** _\{module\_name\}_ to build product modules separately based on the development board and kernel set for the product, for example, **hb build kv\_store**.
- You can run **hb build -p ipcamera@hisilicon** to skip the setting step and compile the product directly.
- You can run **hb build** in **device/device\_company/board** to select the kernel and start the build based on the current development board and the selected kernel to generate an image that contains the kernel and driver only.
4. **hb clean**
Clear the build result of the product in the **out** directory, and retain the **args.gn** and **build.log** files only. To clear files in a specified directory, add the directory parameter to the command, for example, **hb clean out/xxx/xxx**.
```
hb clean
usage: hb clean [-h] [out_path]
positional arguments:
out_path clean a specified path.
optional arguments:
-h, --help show this help message and exit
```
## Adding a Module<a name="section4207112818418"></a>
To add a module, determine the subsystem to which the module belongs and the module name, and then perform the following steps:
1. Add the module build script after the source code development is complete.
The following example adds the **BUILD.gn** script \(stored in the **applications/sample/hello\_world** directory\) to build the **hello\_world** module \(as an executable file\).
```
executable("hello_world") {
......@@ -37,25 +111,33 @@ build/lite # Primary directory for compilation and building
}
```
The added script is used to compile **hello\_world** that can run on OpenHarmony.
The added script is used to build **hello\_world** that can run on OpenHarmony.
2. Add the component description.
To build the preceding module separately, select a product via the **hb set** command and run the **-T** command.
The component description is stored in the **build/lite/components** directory. New components must be added to the JSON file of the corresponding subsystem. A component description must contain the following fields:
```
hb build -f -T //applications/sample/hello_world
```
After the module functions are verified based on the development board, perform steps 2 to 5 to configure the module for the product.
- **component**: name of the component
- **description**: one-sentence description of the component
- **optional**: whether the component is optional
- **dirs**: source code directory of the component
- **targets**: component compilation entry
2. Add the module description.
For example, to add the **hello\_world** component to the application subsystem, add the **hello\_world** object to the **applications.json** file.
The module description is stored in the **build/lite/components** directory. New modules must be added to the JSON file of the corresponding subsystem. A module description must contain the following fields:
- **module**: name of the module
- **description**: brief description of the module
- **optional**: whether the module is optional
- **dirs**: source code directory of the module
- **targets**: module build entry
For example, to add the **hello\_world** module to the application subsystem, add the **hello\_world** object to the **applications.json** file.
```
{
"components": [
{
"component": hello_world",
"component": "hello_world",
"description": "Hello world.",
"optional": "true",
"dirs": [
......@@ -70,9 +152,9 @@ build/lite # Primary directory for compilation and building
}
```
3. Configure the component for the product.
3. Configure the module for the product.
The product configuration file is stored in the **vendor/company/** directory. The file must contain the product name, OpenHarmony version, device vendor, development board name, kernel type, kernel version, and the subsystem and component to configure. The following example adds the **hello\_world** component to the **my\_product.json** configuration file:
The **config.json** file is stored in the **vendor/company/product/** directory. The file must contain the product name, OpenHarmony version, device vendor, development board, kernel type, kernel version, and the subsystem and module to configure. The following example adds the **hello\_world** module to the **my\_product.json** configuration file:
```
{
......@@ -94,15 +176,255 @@ build/lite # Primary directory for compilation and building
}
```
4. Compile the component or product.
1. Run **hb set** and select **hello\_world\_test@hisilicon**.
2. To build the **hello\_world** component, run the following command:
4. Build the product.
1. Run the **hb set** command in the root code directory to select the corresponding product.
2. Run the **hb build** command.
## Adding a Chipset Solution<a name="section2737141421917"></a>
The Compilation and Building subsystem allows you to add a chipset solution. Detailed operations are as follows:
1. Create a directory for the chipset solution.
Taking the RTL8720 development board of chipset provider Realtek for example, you need to run the following command in the root code directory to create a directory for the chipset solution based on [1-Configuration Rules for Modules, Chipset Solutions, and Product Solutions](compilation-and-building-overview.md#section1625463413327).
```
mkdir -p device/realtek/rtl8720
```
2. Create a directory for kernel adaptation and build the **config.gni** file of the development board.
**hb build hello\_world**
The following example adapts the LiteOS Cortex-M kernel to the RTL8720 development board of Realtek. The **device/realtek/rtl8720/liteos\_a/config.gni** file is configured as follows:
To build the **hello\_world\_test** product, run the following command:
```
# Kernel type, e.g. "linux", "liteos_a", "liteos_m".
kernel_type = "liteos_a"
# Kernel version.
kernel_version = "3.0.0"
# Board CPU type, e.g. "cortex-a7", "riscv32".
board_cpu = "real-m300"
# Board arch, e.g. "armv7-a", "rv32imac".
board_arch = ""
# Toolchain name used for system compiling.
# E.g. gcc-arm-none-eabi, arm-linux-harmonyeabi-gcc, ohos-clang, riscv32-unknown-elf.
# Note: The default toolchain is "ohos-clang". It's not mandatory if you use the default toochain.
board_toolchain = "gcc-arm-none-eabi"
# The toolchain path instatlled, it's not mandatory if you have added toolchian path to your ~/.bashrc.
board_toolchain_path =
rebase_path("//prebuilts/gcc/linux-x86/arm/gcc-arm-none-eabi/bin",
root_build_dir)
# Compiler prefix.
board_toolchain_prefix = "gcc-arm-none-eabi-"
# Compiler type, "gcc" or "clang".
board_toolchain_type = "gcc"
# Board related common compile flags.
board_cflags = []
board_cxx_flags = []
board_ld_flags = []
```
3. Build the script.
Create the **BUILD.gn** file in the development board directory. The target name must be the same as that of the development board. Taking the RTL8720 development board of Realtek as an example, the content in the **device/realtek/rtl8720/BUILD.gn** file is configured as follows:
```
group("rtl8720") { # The target can be shared_library, static_library, or an executable file.
# Content
......
}
```
4. Build the chipset solution.
Run the **hb build** command in the development board directory to start the build.
## Adding a Product Solution<a name="section720881917199"></a>
The Compilation and Building subsystem supports flexible assembly of chipset solutions and modules to customize desired product solutions. The operation procedure is as follows:
1. Create a product directory.
Taking the Wi-Fi IoT module based on the RTL8720 development board as an example, you need to run the following command in the root code directory to create a product directory based on [1-Configuration Rules for Modules, Chipset Solutions, and Product Solutions](compilation-and-building-overview.md#section1625463413327).
```
mkdir -p vendor/my_company/wifiiot
```
2. Assemble the product.
Create the **config.json** file in the product directory. Taking the Wi-Fi IoT module as an example, the **vendor/my\_company/wifiiot/config.json** file is as follows:
```
{
"product_name": "wifiiot", # Product name
"ohos_version": "OpenHarmony 1.0", # In-use OS version
"device_company": "realtek", # Name of the chipset solution vendor
"board": "rtl8720", # Name of the development board
"kernel_type": "liteos_m", # Selected kernel type
"kernel_version": "3.0.0", # Selected kernel version
"subsystems": [
{
"subsystem": "kernel", # Selected subsystem
"components": [
{ "component": "liteos_m", "features":[] } # Selected module and its features
]
},
...
{
More subsystems and modules
}
]
}
```
Before the build, the Compilation and Building subsystem will check the validity of fields, including **device\_company**, **board**, **kernel\_type**, **kernel\_version**, **subsystem**, and **component**. The first four fields and the latter two fields must match the current chipset solution and the module description in the **build/lite/components** file, respectively.
3. Implement adaptation of OS APIs.
Create the **hals** directory in the product directory and store the source code as well as the build script for OS adaptation in this directory.
4. Configure the system service.
Create the **init\_configs** directory in the product directory and then the **init.cfg** file in the newly created directory. You can configure the system service to be started on demand.
5. Configure the init process \(only for the Linux kernel\).
You need to create the **etc** directory in the **init\_configs** directory, and then the **init.d** folder as well as the **fstab** file in the newly created directory. In addition, you need to create the **rcS** and **Sxxx** files in the **init.d** file and edit them based on product requirements.
6. Configure the file system image \(required only for the development board that supports the file system\).
Create the **fs.yml** file in the product directory and configure it as required. A typical **fs.yml** file is configured as follows:
```
-
fs_dir_name: rootfs # Image name
fs_dirs:
-
# Copy the files in the out/my_board/my_product/bin directory to the rootfs/bin directory and ignore the .bin files related to testing.
source_dir: bin
target_dir: bin
ignore_files:
- Test.bin
- TestSuite.bin
-
# Copy the files in the out/my_board/my_product/libs directory to the rootfs/lib directory, ignore all .a files, and set the permissions on the files and folders to 644 and 755, respectively.
source_dir: libs
target_dir: lib
ignore_files:
- .a
dir_mode: 755
file_mode: 644
-
source_dir: usr/lib
target_dir: usr/lib
ignore_files:
- .a
dir_mode: 755
file_mode: 644
-
source_dir: config
target_dir: etc
-
source_dir: system
target_dir: system
-
source_dir: sbin
target_dir: sbin
-
source_dir: usr/bin
target_dir: usr/bin
-
source_dir: usr/sbin
target_dir: usr/sbin
-
# Create an empty proc directory.
target_dir: proc
-
target_dir: mnt
-
target_dir: opt
-
target_dir: tmp
-
target_dir: var
-
target_dir: sys
-
source_dir: etc
target_dir: etc
-
source_dir: vendor
target_dir: vendor
-
target_dir: storage
fs_filemode:
-
file_dir: lib/ld-uClibc-0.9.33.2.so
file_mode: 555
-
file_dir: lib/ld-2.24.so
file_mode: 555
-
file_dir: etc/init.cfg
file_mode: 400
fs_symlink:
-
# Create the soft link ld-musl-arm.so.1 -> libc.so in the rootfs/lib directory.
source: libc.so
link_name: ${fs_dir}/lib/ld-musl-arm.so.1
-
source: mksh
link_name: ${fs_dir}/bin/sh
-
source: mksh
link_name: ${fs_dir}/bin/shell
fs_make_cmd:
# Create an ext4 image for the rootfs directory using the script.
- ${root_path}/build/lite/make_rootfs/rootfsimg_linux.sh ${fs_dir} ext4
-
fs_dir_name: userfs
fs_dirs:
-
source_dir: storage/etc
target_dir: etc
-
source_dir: data
target_dir: data
fs_make_cmd:
- ${root_path}/build/lite/make_rootfs/rootfsimg_linux.sh ${fs_dir} ext4
```
7. Build the script.
Create the **BUILD.gn** file in the product directory and build the script based on your requirements. Taking the Wi-Fi IoT module in step 1 as an example, the **BUILD.gn** is configured as follows:
```
group("wifiiot") { # The target name must be the same as the product name.
deps = []
# Copy the init configuration.
deps += [ "init_configs" ]
# Build the hals directory.
deps += [ "hals" ]
# Others
......
}
```
**hb build**
8. Build the product.
Run the **hb set** command in the root code directory to select the new product as prompted, and then run the **hb build** command to start the build.
......@@ -54,7 +54,7 @@ The process to build OpenHarmony is as follows:
The installation command is as follows:
```
sudo apt-get install binutils git-core git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4
sudo apt-get install binutils git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4
```
# Development Examples<a name="EN-US_TOPIC_0000001144061261"></a>
- [Outgoing Calls](#section286643718507)
- [Incoming Calls](#section3205350105014)
## Outgoing Calls<a name="section286643718507"></a>
The following figure shows the API calling for an outgoing call:
**Figure 1** API calling for an outgoing call<a name="fig182512371267"></a>
![](figures/去电.png)
When an application triggers an outgoing call action, the RIL Adapter receives a request for making a call, and the **OnRequest\(\)** calls the required function based on the request ID. In the function for making a call, the data transmitted by the telephony service is encapsulated as an AT command sent to the modem. After executing the dialing command, the modem reports the execution result to RIL Adapter through **OnRequestResponse\(\)**.
```
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <alloca.h>
#include "atchannel.h"
#include "at_tok.h"
#include "hdf_log.h"
#include "ril.h"
static void OnRequest(int request, void *data, size_t datalen, RIL_Token token)
{
HDF_LOGI("OnRequest request = %{public}d start \n", request);
switch (request) {
case HREQ_CALL_DIAL:
SendDialRequest(data, datalen, token);
break;
...
default:
break;
}
}
// Send the AT command (combination of the request ID and the above parameters) to the modem through send_at_request.
static void SendDialRequest(void *data, size_t datalen __unused, RIL_Token token)
{
char *atCmd;
const char *clir;
int ret;
DialInfo *pDial;
pDial = (DialInfo *) data;
if (!strncmp(pDial->address, "*31#", 4)) {
HDF_LOGI("clir suppression");
clir = "i";
num = (char *)&(pDial->address[4]);
} else if (!strncmp(pDial->address, "#31#", 4)) {
HDF_LOGI("clir invocation");
clir = "I";
num = (char *)&(pDial->address[4]);
} else {
HDF_LOGI("set clir state to default");
clir = "";
num = (char *)pDial->number;
}
asprintf(&atCmd, "ATD%s%s;", pDial->address, clir);
ret = send_at_request(atCmd, NULL);
free(atCmd);
// Called after the AT command is executed to send the modem execution result to RIL Adapter.
OnRequestResponse(t, RIL_RESULT_SUCCESS, NULL, 0);
}
```
## Incoming Calls<a name="section3205350105014"></a>
The following figure shows the API calling of an incoming call:
**Figure 2** API calling of an incoming call<a name="fig11621520133015"></a>
![](figures/来电.png)
The **s\_tid\_read** 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.
**OnNotificationResponse\(\)** is called to parse an incoming call event. If the parsed data reported by the modem starts with characters such as **+CRING** and **RING**, it indicates that an incoming call event exists. In this case, the event is reported to RIL Adapter through **OnRadioEventNotify\(HNOTI\_CALL\_STATUS, NULL, 0\)**.
```
#include <stdio.h>
#include "atchannel.h"
#include "at_tok.h"
#include "hdf_log.h"
#include "ril.h"
bool IsCallStatusUpdated(const char *s)
{
return (StrBeginWith(s, "+CRING:")
|| StrBeginWith(s, "RING")
|| StrBeginWith(s, "NO CARRIER")
|| StrBeginWith(s, "+CCWA"));
}
// Parse the data reported by the modem into the target modem event.
static void OnNotificationResponse(const char *s, const char *sms_pdu)
{
char *line = NULL, *p;
HDF_LOGI("OnNotificationResponse = %{public}s sState = %{public}d", s, sState);
// Convert data starting with +CRING: to an incoming call event.
if (IsCallStatusUpdated(s)) {
// Notify the RIL Adapter of an incoming call event.
OnRadioEventNotify(HNOTI_CALL_STATUS, NULL, 0);
}
...
}
```
# Development Guidelines<a name="EN-US_TOPIC_0000001144221221"></a>
- **[Integrating Modem Vendor Library](integrating-modem-vendor-library.md)**
- **[Initializing a Modem Vendor Library](initializing-a-modem-vendor-library.md)**
- **[Responding to Modem Service Requests](responding-to-modem-service-requests.md)**
- **[Reporting Modem Events](reporting-modem-events.md)**
# Initializing a Modem Vendor Library<a name="EN-US_TOPIC_0000001149333801"></a>
- [When to Use](#section219mcpsimp)
- [Available APIs](#section225mcpsimp)
- [How to Develop](#section1432655815216)
- [\(Optional\) Commissioning and Verification](#section268mcpsimp)
## When to Use<a name="section219mcpsimp"></a>
Initializing a modem vendor library refers to implementing of the **const VendorCallbacks \*RilInit\(const struct RIL\_Init\_Env \*env\)** function in the vendor library. This function is mainly used to:
- Receive pointers to callbacks for modem events. When there is a modem event that needs to be reported, the target pointer will be called to report the event to the 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 event.
- Return pointers to functions used for service requests, execution results of service requests, and modem event reporting to the RIL Adapter.
## Available APIs<a name="section225mcpsimp"></a>
The following table describes the API for initializing a modem vendor library.
**Table 1** API for initializing a modem vendor library
<a name="table228mcpsimp"></a>
<table><thead align="left"><tr id="row234mcpsimp"><th class="cellrowborder" valign="top" width="56.99999999999999%" id="mcps1.2.3.1.1"><p id="p236mcpsimp"><a name="p236mcpsimp"></a><a name="p236mcpsimp"></a>API</p>
</th>
<th class="cellrowborder" valign="top" width="43%" id="mcps1.2.3.1.2"><p id="p238mcpsimp"><a name="p238mcpsimp"></a><a name="p238mcpsimp"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row240mcpsimp"><td class="cellrowborder" valign="top" width="56.99999999999999%" headers="mcps1.2.3.1.1 "><p id="p242mcpsimp"><a name="p242mcpsimp"></a><a name="p242mcpsimp"></a>const VendorCallbacks *RilInit(const struct RIL_Init_Env *env)</p>
</td>
<td class="cellrowborder" valign="top" width="43%" headers="mcps1.2.3.1.2 "><p id="p244mcpsimp"><a name="p244mcpsimp"></a><a name="p244mcpsimp"></a>Entry for running a modem vendor library</p>
</td>
</tr>
</tbody>
</table>
## How to Develop<a name="section1432655815216"></a>
1. Set the pointers to callbacks passed by RIL Adapter through **RilInit**.
```
static struct RIL_Init_Env g_rilEnv = {
OnRequestResponse,
OnRadioEventNotify,
OnReqTimerExpiredCallback,
OnAsyncReqAck
};
s_rilenv = env;
```
2. Create the **s\_tid\_main** thread to enable message loop.
```
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
ret = pthread_create(&s_tid_main, &attr, MainRunner, NULL);
```
3. In the **s\_tid\_main** thread, use **open\(\)** to open a modem node and then create the **s\_tid\_read** thread to read and process the messages reported by the modem.
```
open(s_device_path, O_RDWR); // s_device_path indicates a modem node.
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
ret = pthread_create(&s_tid_read, &attr, ReadRunner, &attr);
```
4. Return pointers to functions used for service requests, execution results of service requests, and modem event reporting.
```
static const RIL_RadioFunctions g_callbacks = {
RIL_VERSION,
OnRequest,
CurrentState,
OnSupports,
OnCancel,
GetVersion
};
return &g_callbacks;
```
## \(Optional\) Commissioning and Verification<a name="section268mcpsimp"></a>
1. Use the **HDC** tool to connect to a commissioning device, and run the **hdc file send** command to send the generated **libvendor.z.so** library file to the **/system/lib/** directory.
2. Run the **hdc shell sync** and **hdc shell reboot** commands to restart the device.
3. Run the **hdc shell hilog** command to check whether **RilInit\(\)** is successfully executed based on the log information.
# Integrating Modem Vendor Library<a name="EN-US_TOPIC_0000001148928023"></a>
- [Compilation Information Configuration](#section142111565210)
- [\(Optional\) Commissioning and Verification](#section114621643195220)
## Compilation Information Configuration<a name="section142111565210"></a>
The modem vendor library can be compiled into a dynamic library by using **BUILD.gn**. When the RIL Adapter is started, the dynamic library is loaded to the system in dlopen mode, and then the modem vendor library is initialized \(for details, see [Initializing a Modem Vendor Library](initializing-a-modem-vendor-library.md)\). The following is a compilation example of **BUILD.gn**:
```
import("//build/ohos.gni")
RIL_ADAPTER = "//base/telephony"
ohos_shared_library("vendor") {// Name of the modem vendor library
sources = [// Source files to be compiled
"vendorlib.c",
"xxx.c",
]
include_dirs = [// Header files
"$RIL_ADAPTER/ril_adapter/include",
"$RIL_ADAPTER/ril_adapter/interfaces/innerkits",
"include",
]
deps = [// Internal dependencies
"//drivers/adapter/uhdf2/osal:libhdf_utils"
]
external_deps = [// External dependencies
"hilog:libhilog"
]
part_name = "ril_adapter"
subsystem_name = "telephony"
```
## \(Optional\) Commissioning and Verification<a name="section114621643195220"></a>
After the compilation is complete, check whether the **libvendor.z.so** file is generated in the **out/ohos-arm-release/packages/phone/system/lib** directory. If this file is generated, the library integration is successful.
# Overview<a name="EN-US_TOPIC_0000001144341209"></a>
- [Basic Concepts](#section202mcpsimp)
- [Working Principles](#section205mcpsimp)
- [Limitations and Constraints](#section207mcpsimp)
This document provides development guidelines related to OpenHarmony telephony subsystem, including integrating and initializing modem vendor libraries, responding to modem service requests, and reporting modem events.
## Basic Concepts<a name="section202mcpsimp"></a>
The RIL Adapter module of the telephony subsystem is used for the communication between the cellular communication framework and a modem. This module helps develop libraries of different modem vendors and supports modem service requests and event reporting.
## Working Principles<a name="section205mcpsimp"></a>
**Figure 1** Architecture of the RIL Adapter module<a name="fig1528194911218"></a>
![](figures/ril-adapter.png)
The architecture of the RIL Adapter module consists of the module initialization \(**hril\_hdf** & **modem\_adapter**\), API implementation \(**hril** & **ril\_event\_listen**\), and modem vendor library \(**vendorlib**\), as shown in Figure 1.
After **hril\_hdf** is executed, **vendorlib** is dynamically loaded and obtains the available requests and pointers to functions for reporting events from **hril\_hdf**. After this process is complete, **hril\_hdf** can communicate with a modem through **vendorlib**.
- hril\_hdf: Entry of the RIL Adapter. It is used to load the modem vendor library file, initialize the **hril** library, start the event scheduler **ril\_event\_listen**, and load the associated modem vendor library file.
- modem\_adapter: Adapter that allows a single firmware to adapt to different modems. Specifically, you can obtain the modem type from the kernel and then load the target modem vendor library based on the modem type.
- hril: Implementation of APIs related to telephony services. The APIs include general and extended APIs. General APIs implement telephony services and main modem cellular communication \(SIM card, network search, cellular data, cellular call, and SMS/MMS services\). Extended APIs are used for vendors to implement customized capabilities.
- ril\_event\_listen: Event scheduler that processes events reported by a modem. Specifically, when an event \(for example, an incoming call\) reported by the modem is received, the event can be encapsulated as **ril\_event** and added to the event scheduling queue. Then, a callback is invoked through the queue management mechanism to report the event to the telephony service.
- 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.\)
## Limitations and Constraints<a name="section207mcpsimp"></a>
**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.
# Reporting Modem Events<a name="EN-US_TOPIC_0000001149173923"></a>
- [When to Use](#section337mcpsimp)
- [Available APIs](#section340mcpsimp)
- [How to Develop](#section183291958165215)
- [\(Optional\) Commissioning and Verification](#section405mcpsimp)
## When to Use<a name="section337mcpsimp"></a>
In a modem node thread, the messages reported by the modem are read cyclically, parsed into specific events, and then reported to RIL Adapter.
## Available APIs<a name="section340mcpsimp"></a>
The following table describes the API for reporting modem events.
**Table 1** API for reporting modem events
<a name="table343mcpsimp"></a>
<table><thead align="left"><tr id="row349mcpsimp"><th class="cellrowborder" valign="top" width="56.99999999999999%" id="mcps1.2.3.1.1"><p id="p351mcpsimp"><a name="p351mcpsimp"></a><a name="p351mcpsimp"></a>API</p>
</th>
<th class="cellrowborder" valign="top" width="43%" id="mcps1.2.3.1.2"><p id="p353mcpsimp"><a name="p353mcpsimp"></a><a name="p353mcpsimp"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row355mcpsimp"><td class="cellrowborder" valign="top" width="56.99999999999999%" headers="mcps1.2.3.1.1 "><p id="p357mcpsimp"><a name="p357mcpsimp"></a><a name="p357mcpsimp"></a>static void OnNotificationResponse(const char *s, const char *sms_pdu)</p>
</td>
<td class="cellrowborder" valign="top" width="43%" headers="mcps1.2.3.1.2 "><p id="p359mcpsimp"><a name="p359mcpsimp"></a><a name="p359mcpsimp"></a>Reports modem events.</p>
</td>
</tr>
</tbody>
</table>
## How to Develop<a name="section183291958165215"></a>
In the **s\_tid\_read** thread of the modem node, call **OnNotificationResponse\(\)** to parse the data read into a specific event and call **OnRadioEventNotify\(\)** to report the generated event to RIL Adapter.
```
bool IsCallStatusUpdated(const char *s)
{
return (StrBeginWith(s, "+CRING:")
|| StrBeginWith(s, "RING")
|| StrBeginWith(s, "NO CARRIER")
|| StrBeginWith(s, "+CCWA"));
}
bool IsSetRadioPower(const char *s)
{
return StrBeginWith(s, "+CFUN: 0");
}
static void OnNotificationResponse(const char *s, const char *sms_pdu)
{
if (IsCallStatusUpdated(s)) {
OnRadioEventNotify(HNOTI_CALL_STATUS, NULL, 0);
} else if (IsSetRadioPower(s)) {
SetRadioState(RADIO_OFF);
}
...
}
```
## \(Optional\) Commissioning and Verification<a name="section405mcpsimp"></a>
1. Use the **HDC** tool to connect to a commissioning device, and run the **hdc file send** command to send the generated **libvendor.z.so** library file to the **/system/lib/** directory.
2. Run the **hdc shell sync** and **hdc shell reboot** commands to restart the device.
3. Run the **hdc shell hilog** command to check whether **OnNotificationResponse\(\)** is successfully executed based on the log information.
# Responding to Modem Service Requests<a name="EN-US_TOPIC_0000001149293857"></a>
- [When to Use](#section273mcpsimp)
- [Available APIs](#section276mcpsimp)
- [How to Develop](#section532835815524)
- [\(Optional\) Commissioning and Verification](#section332mcpsimp)
## When to Use<a name="section273mcpsimp"></a>
After receiving a specific telephony service request, the 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<a name="section276mcpsimp"></a>
The following table describes the APIs for responding to modem service requests.
**Table 1** APIs for responding to modem service requests
<a name="table279mcpsimp"></a>
<table><thead align="left"><tr id="row285mcpsimp"><th class="cellrowborder" valign="top" width="56.99999999999999%" id="mcps1.2.3.1.1"><p id="p287mcpsimp"><a name="p287mcpsimp"></a><a name="p287mcpsimp"></a>API</p>
</th>
<th class="cellrowborder" valign="top" width="43%" id="mcps1.2.3.1.2"><p id="p289mcpsimp"><a name="p289mcpsimp"></a><a name="p289mcpsimp"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row291mcpsimp"><td class="cellrowborder" valign="top" width="56.99999999999999%" headers="mcps1.2.3.1.1 "><p id="p293mcpsimp"><a name="p293mcpsimp"></a><a name="p293mcpsimp"></a>static void</p>
<p id="p294mcpsimp"><a name="p294mcpsimp"></a><a name="p294mcpsimp"></a>OnRequest(int request, void *data, size_t datalen, RIL_Token t)</p>
</td>
<td class="cellrowborder" valign="top" width="43%" headers="mcps1.2.3.1.2 "><p id="p296mcpsimp"><a name="p296mcpsimp"></a><a name="p296mcpsimp"></a>Distributes service requests.</p>
</td>
</tr>
<tr id="row297mcpsimp"><td class="cellrowborder" valign="top" width="56.99999999999999%" headers="mcps1.2.3.1.1 "><p id="p299mcpsimp"><a name="p299mcpsimp"></a><a name="p299mcpsimp"></a>void OnRequestResponse(RIL_Token t, RIL_Errno e, void *response, size_t responselen);</p>
</td>
<td class="cellrowborder" valign="top" width="43%" headers="mcps1.2.3.1.2 "><p id="p301mcpsimp"><a name="p301mcpsimp"></a><a name="p301mcpsimp"></a>Reports the execution result of a service request to RIL Adapter.</p>
</td>
</tr>
</tbody>
</table>
## How to Develop<a name="section532835815524"></a>
1. Distribute service requests based on request IDs through **OnRequest\(\)**.
```
switch (request) {
case HREQ_CALL_DIAL:
SendDialRequest(data, datalen, t);
break;
case HREQ_CALL_HANGUP:
SendHangupRequest(data, datalen, t);
break;
...
default:
break;
}
```
2. After a modem executes a service request, call **OnRequestResponse\(\)** to report the target event to RIL Adapter.
```
asprintf(&cmd, "ATD%s%s;", dial->address, clir);
ret = send_at_request(cmd, NULL);
free(cmd);
OnRequestResponse(t, RIL_RESULT_SUCCESS, NULL, 0);
```
## \(Optional\) Commissioning and Verification<a name="section332mcpsimp"></a>
1. Use the **HDC** tool to connect to a commissioning device, and run the **hdc file send** command to send the generated **libvendor.z.so** library file to the **/system/lib/** directory.
2. Run the **hdc shell sync** and **hdc shell reboot** commands to restart the device.
3. Run the **hdc shell hilog** command to check whether **OnRequest\(\)** is successfully executed based on the log information.
# Telephony Service<a name="EN-US_TOPIC_0000001111321920"></a>
- **[Overview](overview-6.md)**
- **[Development Guidelines](development-guidelines-7.md)**
- **[Development Examples](development-examples-8.md)**
......@@ -22,7 +22,6 @@ For device developers, OpenHarmony utilizes a component-based design to tailor i
- [Sensors](device-dev/subsystems/sensors.md)
- [Application Framework](device-dev/subsystems/application-framework.md)
- [OTA Upgrade](device-dev/subsystems/ota-upgrade.md)
- [Telephony Service](device-dev/subsystems/telephony-service.md)
- [Security](device-dev/subsystems/security.md)
- [Startup](device-dev/subsystems/startup.md)
- [Testing](device-dev/subsystems/testing.md)
......
......@@ -242,14 +242,6 @@
- [开发指导](zh-cn/device-dev/subsystems/开发指导-3.md)
- [开发实例](zh-cn/device-dev/subsystems/开发实例.md)
- [OTA升级](zh-cn/device-dev/subsystems/OTA升级.md)
- [电话服务](zh-cn/device-dev/subsystems/电话服务.md)
- [概述](zh-cn/device-dev/subsystems/概述-4.md)
- [开发指导](zh-cn/device-dev/subsystems/开发指导-5.md)
- [Modem厂商库集成指导](zh-cn/device-dev/subsystems/Modem厂商库集成指导.md)
- [Modem厂商库初始化开发指导](zh-cn/device-dev/subsystems/Modem厂商库初始化开发指导.md)
- [Modem业务请求及响应开发指导](zh-cn/device-dev/subsystems/Modem业务请求及响应开发指导.md)
- [Modem事件上报开发指导](zh-cn/device-dev/subsystems/Modem事件上报开发指导.md)
- [开发实例](zh-cn/device-dev/subsystems/开发实例-6.md)
- [安全](zh-cn/device-dev/subsystems/安全.md)
- [概述](zh-cn/device-dev/subsystems/概述-7.md)
- [应用验签开发指导](zh-cn/device-dev/subsystems/应用验签开发指导.md)
......@@ -324,10 +316,10 @@
- [外设驱动开发示例](zh-cn/device-dev/guide/外设驱动开发示例.md)
- [概述](zh-cn/device-dev/guide/概述-12.md)
- [硬件资源介绍](zh-cn/device-dev/guide/硬件资源介绍.md)
- [Input模型简介](Input模型简介.md)
- [Input模型简介](zh-cn/device-dev/guide/Input模型简介.md)
- [环境搭建](zh-cn/device-dev/guide/环境搭建.md)
- [TouchScreen器件驱动开发](TouchScreen器件驱动开发.md)
- [TouchScreen器件驱动开发](zh-cn/device-dev/guide/TouchScreen器件驱动开发.md)
- [配置设备描述信息](zh-cn/device-dev/guide/配置设备描述信息.md)
- [配置Touchscreen器件信息](zh-cn/device-dev/guide/配置Touchscreen器件信息.md)
- [适配器件私有驱动](zh-cn/device-dev/guide/适配器件私有驱动.md)
......@@ -336,7 +328,7 @@
- [调试验证](zh-cn/device-dev/guide/调试验证.md)
- [开机日志分析](zh-cn/device-dev/guide/开机日志分析.md)
- [Input模型工作流程解析](Input模型工作流程解析.md)
- [Input模型工作流程解析](zh-cn/device-dev/guide/Input模型工作流程解析.md)
- [私有配置信息解析](zh-cn/device-dev/guide/私有配置信息解析.md)
- [管理驱动层初始化及注册驱动至HDF框架](zh-cn/device-dev/guide/管理驱动层初始化及注册驱动至HDF框架.md)
- [公共驱动层初始化及注册驱动至HDF框架](zh-cn/device-dev/guide/公共驱动层初始化及注册驱动至HDF框架.md)
......@@ -382,10 +374,15 @@
- [术语](zh-cn/device-dev/glossary/术语.md)
- 应用开发
- [入门](zh-cn/application-dev/quick-start/Readme-CN.md)
- [DevEco Studio(OpenHarmony)使用指南](zh-cn/application-dev/quick-start/DevEco-Studio(OpenHarmony)使用指南.md)
- [概述](zh-cn/application-dev/quick-start/概述.md)
- [配置OpenHarmony SDK](zh-cn/application-dev/quick-start/配置OpenHarmony-SDK.md)
- [配置OpenHarmony应用签名信息](zh-cn/application-dev/quick-start/配置OpenHarmony应用签名信息.md)
- [安装运行OpenHarmony应用](zh-cn/application-dev/quick-start/安装运行OpenHarmony应用.md)
- [快速入门](zh-cn/application-dev/quick-start/快速入门.md)
- [开发准备](zh-cn/application-dev/quick-start/开发准备.md)
- [使用JS语言开发](zh-cn/application-dev/quick-start/使用JS语言开发.md)
- [UI](zh-cn/application-dev/ui/Readme-CN.md)
- [JS UI框架](zh-cn/application-dev/ui/JS-UI框架.md)
- [JS UI框架概述](zh-cn/application-dev/ui/JS-UI框架概述.md)
......@@ -407,12 +404,12 @@
- [音频](zh-cn/application-dev/media/音频.md)
- [音频开发概述](zh-cn/application-dev/media/音频开发概述.md)
- [音频播放开发指导](zh-cn/application-dev/media/音频播放开发指导.md)
- [音频播放开发指导](zh-cn/application-dev/media/音频播放开发指导.md)
- [音频管理开发指导](zh-cn/application-dev/media/音频管理开发指导.md)
- [网络与连接](zh-cn/application-dev/connectivity/Readme-CN.md)
- [IPC与RPC通信](zh-cn/application-dev/connectivity/IPC与RPC通信.md)
- [IPC与RPC通信概述](zh-cn/application-dev/connectivity/IPC与RPC通信概述.md)
- [IPC与RPC通信开发指导](zh-cn/application-dev/connectivity/IPC与RPC通信开发指导.md)
......@@ -759,14 +756,6 @@
- [Development Guidelines](en/device-dev/subsystems/development-guidelines-5.md)
- [Development Example](en/device-dev/subsystems/development-example.md)
- [OTA Upgrade](en/device-dev/subsystems/ota-upgrade.md)
- [Telephony Service](en/device-dev/subsystems/telephony-service.md)
- [Overview](en/device-dev/subsystems/overview-6.md)
- [Development Guidelines](en/device-dev/subsystems/development-guidelines-7.md)
- [Integrating Modem Vendor Library](en/device-dev/subsystems/integrating-modem-vendor-library.md)
- [Initializing a Modem Vendor Library](en/device-dev/subsystems/initializing-a-modem-vendor-library.md)
- [Responding to Modem Service Requests](en/device-dev/subsystems/responding-to-modem-service-requests.md)
- [Reporting Modem Events](en/device-dev/subsystems/reporting-modem-events.md)
- [Development Examples](en/device-dev/subsystems/development-examples-8.md)
- [Security](en/device-dev/subsystems/security.md)
- [Overview](en/device-dev/subsystems/overview-9.md)
- [Development Guidelines on Application Signature Verification](en/device-dev/subsystems/development-guidelines-on-application-signature-verification.md)
......@@ -893,11 +882,15 @@
- [Glossary](en/device-dev/glossary/glossary.md)
- Application Development
- [DevEco Studio \(OpenHarmony\) User Guide](en/application-dev/quick-start/deveco-studio-(openharmony)-user-guide.md)
- [Overview](en/application-dev/quick-start/overview.md)
- [Configuring the OpenHarmony SDK](en/application-dev/quick-start/configuring-the-openharmony-sdk.md)
- [Configuring the OpenHarmony App Signature](en/application-dev/quick-start/configuring-the-openharmony-app-signature.md)
- [Installing and Running Your OpenHarmony App](en/application-dev/quick-start/installing-and-running-your-openharmony-app.md)
- [Basics ](en/application-dev/quick-start/Readme-EN.md)
- [Getting Started](en/application-dev/quick-start/getting-started.md)
- [Preparations](en/application-dev/quick-start/preparations.md)
- [Getting Started with JavaScript](en/application-dev/quick-start/getting-started-with-javascript.md)
- [UI](en/application-dev/ui/Readme-EN.md)
- [JS UI Framework](en/application-dev/ui/js-ui-framework.md)
- [JS UI Framework Overview](en/application-dev/ui/js-ui-framework-overview.md)
......@@ -914,19 +907,16 @@
- [Event](en/application-dev/ui/event.md)
- [Defining Page Routes](en/application-dev/ui/defining-page-routes.md)
- [Custom Components](en/application-dev/ui/custom-components.md)
- [Media](en/application-dev/media/Readme-EN.md)
- [Audio](en/application-dev/media/audio.md)
- [Audio Overview](en/application-dev/media/audio-overview.md)
- [Development Guidelines on Audio Playback](en/application-dev/media/development-guidelines-on-audio-playback.md)
- [Development Guidelines on Audio Management](en/application-dev/media/development-guidelines-on-audio-management.md)
- [Connectivity](en/application-dev/connectivity/Readme-EN.md)
- [IPC & RPC](en/application-dev/connectivity/ipc-rpc.md)
- [IPC & RPC Overview](en/application-dev/connectivity/ipc-rpc-overview.md)
- [IPC & RPC Development Guidelines](en/application-dev/connectivity/ipc-rpc-development-guidelines.md)
- [Subscribing to State Changes of a Remote Object](en/application-dev/connectivity/subscribing-to-state-changes-of-a-remote-object.md)
- [JS Reference](en/application-dev/js-reference/Readme-EN.md)
- [Framework](en/application-dev/js-reference/framework.md)
......
......@@ -22,9 +22,11 @@
- [volumeChange](#zh-cn_topic_0000001103383404_section139227715717)
- [finish](#zh-cn_topic_0000001103383404_section15181321181018)
- [error](#zh-cn_topic_0000001103383404_section5593132921016)
- [AudioState](#zh-cn_topic_0000001103383404_section5181155710523)
>![](public_sys-resources/icon-note.gif) **说明:**
>由于权限问题,此部分功能在标准系统暂不可用,待更新。
## 导入模块<a name="zh-cn_topic_0000001103383404_s56d19203690d4782bfc74069abb6bd71"></a>
```
......
......@@ -25,6 +25,9 @@
- [AudioDeviceDescriptor](#zh-cn_topic_0000001149807881_section17427121913310)
- [AudioDeviceDescriptors](#zh-cn_topic_0000001149807881_section5181155710523)
>![](public_sys-resources/icon-note.gif) **说明:**
>由于权限问题,此部分功能在标准系统暂不可用,待更新。
## 导入模块<a name="zh-cn_topic_0000001149807881_s56d19203690d4782bfc74069abb6bd71"></a>
```
......
......@@ -4,7 +4,8 @@
OpenHarmony音频模块支持音频业务的开发,提供音频相关的功能,主要包括音频播放、音量管理等。
\(由于权限问题,此部分功能在标准系统暂无法生效,待更新\)
>![](public_sys-resources/icon-note.gif) **说明:**
>由于权限问题,此部分功能在标准系统暂不可用,待更新。
## 基本概念<a name="section296512102281"></a>
......
# 安装运行OpenHarmony应用<a name="ZH-CN_TOPIC_0000001115941596"></a>
在开源版本上安装OpenHarmony应用,需要使用hdc工具,通过手动执行命令行完成应用的安装。
安装OpenHarmony应用需要使用hdc工具,通过手动执行命令行完成应用的安装。
hdc工具本身需要手动从开源仓中获取。然后使用工具将编译后的hap包发送至设备侧,然后通过hdc命令完成app的安装。
相关命令如下:
- 文件发送命令
- 文件发送命令
**file send _localpath remotepath_**
命令示例:
```
hdc_std file send E:\hwadmin.hap /data/local/tmp
hdc_std file send E:\hwadmin.hap /data/local/tmp/hwadmin.hap
```
- 安装命令
......@@ -26,6 +26,16 @@ hdc工具本身需要手动从开源仓中获取。然后使用工具将编译
hdc_std install hwadmin.hap
```
- 日志抓取命令
**hilog**
命令示例:
```
hdc_std hilog
```
完整的hdc工具使用指导及命令格式请参见开源仓“docs/zh-cn/device-dev/subsystems/hdc使用指导.md“。
......@@ -8,7 +8,7 @@
DevEco Studio是HarmonyOS的配套的开发IDE,因为HarmonyOS是基于OpenHarmony开发的,因此,使用DevEco Studio(配套HarmonyOS)也可以进行OpenHarmony的应用开发。
使用DevEco Studio开发开发OpenHarmony应用的流程与开发HarmonyOS的流程完全一样,本文档仅描述OpenHarmony应用开发与HarmonyOS应用开发的差异点。
使用DevEco Studio开发OpenHarmony应用的流程与开发HarmonyOS的流程完全一样,本文档仅描述OpenHarmony应用开发与HarmonyOS应用开发的差异点。
- **搭建开发环境差异**:OpenHarmony应用开发环境需要开发者手动配置SDK,具体可参考[配置OpenHarmony SDK](配置OpenHarmony-SDK.md)章节。
- **调试签名配置**:OpenHarmony应用运行在真机设备上,需要对应用进行签名,关于OpenHarmony应用的签名指导请参考[配置OpenHarmony应用签名信息](配置OpenHarmony应用签名信息.md)
......@@ -18,7 +18,10 @@ DevEco Studio是HarmonyOS的配套的开发IDE,因为HarmonyOS是基于OpenHar
## 使用约束<a name="section65191625782"></a>
OpenHarmony只支持使用JS语言开发应用,不支持Java、C/C++语言。OpenHarmony与HarmonyOS的开发工具都是DevEco Studio,下表为OpenHarmony与HarmonyOS的IDE功能差异说明:
- OpenHarmony只支持使用JS语言开发应用,不支持Java、C/C++语言。
- OpenHarmony开发环境DevEco Studio暂只支持Windows系统。
OpenHarmony与HarmonyOS的开发工具都是DevEco Studio,下表为OpenHarmony与HarmonyOS的IDE功能差异说明:
<a name="table852516933419"></a>
<table><thead align="left"><tr id="row1952618913415"><th class="cellrowborder" valign="top" width="29.882988298829883%" id="mcps1.1.4.1.1"><p id="p165268963418"><a name="p165268963418"></a><a name="p165268963418"></a>特性名称</p>
......
......@@ -6,9 +6,12 @@
在设置OpenHarmony应用开发环境时,需要开发者在DevEco Studio中配置对应的SDK信息。
>![](public_sys-resources/icon-note.gif) **说明:**
>请注意,OpenHarmony SDK版本是API Version 6 Canary1,并精简了部分工具链,因此不适用于HarmonyOS应用开发。
## 前提条件<a name="section164161442154812"></a>
- 已下载并安装好DevEco Studio 2.1 Release,点击[链接下载](https://developer.harmonyos.com/cn/develop/deveco-studio#download)**预计6月2日21:00上线,敬请期待**
- 已下载并安装好DevEco Studio 2.1 Release,点击[链接下载](https://developer.harmonyos.com/cn/develop/deveco-studio#download)
- 已获取OpenHarmony SDK包并解压,点击[链接下载](https://mirror.iscas.ac.cn/OpenHarmony/sdk/OpenHarmony-SDK-2.0-Canary.7z)
## 配置SDK信息<a name="section1265592425017"></a>
......@@ -54,17 +57,16 @@ DevEco Studio通过SDK Manager统一管理SDK及工具链,OpenHarmony包含如
1. 运行已安装的DevEco Studio,首次使用,请选择**Do not import settings**,点击OK。
2. 接下来DevEco Studio会根据向导指示,进入到SDK下载界面,**HarmonyOS SDK Location**选择本地解压的SDK包路径,然后点击**Next**
>![](public_sys-resources/icon-note.gif) **说明:**
>如果不是首次安装DevEco Studio,可能无法查看进入该界面,可通过欢迎页的**Configure \> Settings \> Appearance & Behavior \> System Settings \> HarmonyOS SDK**界面,点击**HarmonyOS SDK Location**加载SDK。
![](figures/zh-cn_image_0000001117288684.png)
3. SDK安装完成后,点击**Finish**,界面会进入到DevEco Studio欢迎页。
![](figures/zh-cn_image_0000001162781359.png)
4. 进入**Sdk\\js\\2.2.0.0\\build-tools\\ace-loader**目录,删除node\_modules文件夹。
![](figures/zh-cn_image_0000001117289652.png)
5. 然后在该目录下运行命令行工具,分别执行如下命令,直至安装完成。
4. 进入**Sdk\\js\\2.2.0.0\\build-tools\\ace-loader**目录,然后在该目录下运行命令行工具,分别执行如下命令,直至安装完成。
```
npm cache clean -f
......@@ -76,9 +78,9 @@ DevEco Studio通过SDK Manager统一管理SDK及工具链,OpenHarmony包含如
## 导入工程<a name="section12559415183418"></a>
OpenHarmony SDK配置完成后,便可以启动应用开发。针对OpenHarmony应用开发,**通过导入Sample工程的方式来创建一个新工程**
OpenHarmony SDK配置完成后,便可以启动应用开发。针对OpenHarmony应用开发,**只能通过导入Sample工程的方式来创建一个新工程**
1. 在DevEco Studio的欢迎页,点击**Import HarmonyOS Smaple**按钮,导入Sample工程。
1. 在DevEco Studio的欢迎页,点击**Import HarmonyOS Sample**按钮,导入Sample工程。
![](figures/zh-cn_image_0000001163495457.png)
......
......@@ -17,7 +17,7 @@ OpenHarmony应用通过数字证书(.cer文件)和Profile文件(.p7b文件
使用[生成密钥和证书请求文件](#section153146467405)中生成的证书请求文件,来生成应用签名所需的数字证书文件。生成方法如下:
进入Sdk\\toolchains\\lib目录下,打开命令行工具,执行如下命令。其中,只需要修改输入和输出即可快速生成证书文件,即修改**-infile**指定证书请求文件csr文件路径,**-outfile**指定输出证书文件名及路径。
进入DevEco Studio安装目录的**Sdk\\toolchains\\lib**文件夹下,打开命令行工具,执行如下命令(如果keytool命令不能执行,请在系统环境变量中添加JDK的环境变量)。其中,只需要修改输入和输出即可快速生成证书文件,即修改**-infile**指定证书请求文件csr文件路径,**-outfile**指定输出证书文件名及路径。
```
keytool -gencert -alias "OpenHarmony Application CA" -infile app.csr -outfile IDE.cer -keystore OpenHarmony.p12 -sigalg SHA384withECDSA -storepass 123456 -ext KeyUsage:"critical=digitalSignature" -validity 3650 -rfc
......
......@@ -3,13 +3,7 @@
- [基础能力](#section1393616301083)
- [整体架构](#section105231413161115)
JS UI框架是一种跨设备的高性能UI开发框架,支持类Web范式编程和跨设备多态UI。
阅读本开发指南前,开发者需要掌握以下基础知识:
- HTML5
- CSS
- JavaScript
JS UI框架是OpenHarmony UI开发框架,提供基础类、容器类、画布类等UI组件和标准CSS动画能力,支持类Web范式编程。
## 基础能力<a name="section1393616301083"></a>
......@@ -18,20 +12,12 @@ JS UI框架是一种跨设备的高性能UI开发框架,支持类Web范式编
JS UI框架采用类HTML和CSS Web编程语言作为页面布局和页面样式的开发语言,页面业务逻辑则支持ECMAScript规范的JavaScript语言。JS UI框架提供的类Web编程范式,可以让开发者避免编写UI状态切换的代码,视图配置信息更加直观。
- **跨设备**
开发框架架构上支持UI跨设备显示能力,运行时自动映射到不同设备类型,开发者无感知,降低开发者多设备适配成本。
- **高性能**
开发框架包含了许多核心的控件,如列表、图片和各类容器组件等,针对声明式语法进行了渲染流程的优化。
## 整体架构<a name="section105231413161115"></a>
JS UI框架包括应用层(Application)、前端框架层(Framework)、引擎层(Engine)和平台适配层(Porting Layer)。
![](figures/zh-cn_image_0000001110468610.png)
![](figures/zh-cn_image_0000001077953992.png)
- **Application**
......
......@@ -13,7 +13,7 @@
## 使用流程<a name="section47784125013"></a>
使用UART的一般流程如[图1](#p58686354483)所示。
使用UART的一般流程如下图所示。
**图 1** UART使用流程图<a name="fig1852173020185"></a>
......
......@@ -276,7 +276,7 @@ HUAWEI DevEco Device Tool是OpenHarmony面向智能设备开发者提供的一
Huawei DevEco Device Tool支持 OpenHarmony设备开发的演进路标如下:
![](figures/1.png)
![](figures/3.png)
## 获取应用开发工具(HUAWEI DevEco Studio)<a name="section0904101019258"></a>
......
# Modem业务请求及响应开发指导<a name="ZH-CN_TOPIC_0000001149293857"></a>
- [场景介绍](#section273mcpsimp)
- [接口说明](#section276mcpsimp)
- [开发步骤](#section532835815524)
- [调测验证(可选)](#section332mcpsimp)
## 场景介绍<a name="section273mcpsimp"></a>
Modem业务请求及响应是指RIL Adapter收到电话服务具体业务请求后,调用Modem厂商库初始化获得的函数指针,把具体业务请求发送给厂商库,厂商库根据业务请求ID做相应的业务处理。
## 接口说明<a name="section276mcpsimp"></a>
Modem业务请求及响应接口。
**表 1** Modem业务请求及响应接口功能介绍
<a name="table279mcpsimp"></a>
<table><thead align="left"><tr id="row285mcpsimp"><th class="cellrowborder" valign="top" width="56.99999999999999%" id="mcps1.2.3.1.1"><p id="p287mcpsimp"><a name="p287mcpsimp"></a><a name="p287mcpsimp"></a>接口名</p>
</th>
<th class="cellrowborder" valign="top" width="43%" id="mcps1.2.3.1.2"><p id="p289mcpsimp"><a name="p289mcpsimp"></a><a name="p289mcpsimp"></a>描述</p>
</th>
</tr>
</thead>
<tbody><tr id="row291mcpsimp"><td class="cellrowborder" valign="top" width="56.99999999999999%" headers="mcps1.2.3.1.1 "><p id="p293mcpsimp"><a name="p293mcpsimp"></a><a name="p293mcpsimp"></a>static void</p>
<p id="p294mcpsimp"><a name="p294mcpsimp"></a><a name="p294mcpsimp"></a>OnRequest(int request, void *data, size_t datalen, RIL_Token t)</p>
</td>
<td class="cellrowborder" valign="top" width="43%" headers="mcps1.2.3.1.2 "><p id="p296mcpsimp"><a name="p296mcpsimp"></a><a name="p296mcpsimp"></a>该接口对具体业务请求进行分发处理</p>
</td>
</tr>
<tr id="row297mcpsimp"><td class="cellrowborder" valign="top" width="56.99999999999999%" headers="mcps1.2.3.1.1 "><p id="p299mcpsimp"><a name="p299mcpsimp"></a><a name="p299mcpsimp"></a>void OnRequestResponse(RIL_Token t, RIL_Errno e, void *response, size_t responselen);</p>
</td>
<td class="cellrowborder" valign="top" width="43%" headers="mcps1.2.3.1.2 "><p id="p301mcpsimp"><a name="p301mcpsimp"></a><a name="p301mcpsimp"></a>该接口对业务执行结果进行响应,即当请求业务执行完成后,Modem根据该请求执行的结果上报给RIL Adapter</p>
</td>
</tr>
</tbody>
</table>
## 开发步骤<a name="section532835815524"></a>
1. 在OnRequest\(\)接口里根据业务请求ID进行分发。
```
switch (request) {
case HREQ_CALL_DIAL:
SendDialRequest(data, datalen, t);
break;
case HREQ_CALL_HANGUP:
SendHangupRequest(data, datalen, t);
break;
……
default:
break;
}
```
2. 在Modem执行业务请求完成后,调用OnRequestResponse\(\)回调函数,把事件上报给RIL Adapter。
```
asprintf(&cmd, "ATD%s%s;", dial->address, clir);
ret = send_at_request(cmd, NULL);
free(cmd);
OnRequestResponse(t, RIL_RESULT_SUCCESS, NULL, 0);
```
## 调测验证(可选)<a name="section332mcpsimp"></a>
1. 用hdc工具连接调试设备,把编译生成的libvendor.z.so库文件通过hdc file send推到/system/lib/目录下。
2. 执行hdc shell sync, hdc shell reboot重启设备。
3. hdc shell后输入hilog命令,查看OnRequest\(\)是否正确执行完成,根据日志信息判断是否成功。
# Modem事件上报开发指导<a name="ZH-CN_TOPIC_0000001149173923"></a>
- [场景介绍](#section337mcpsimp)
- [接口说明](#section340mcpsimp)
- [开发步骤](#section183291958165215)
- [调测验证(可选)](#section405mcpsimp)
## 场景介绍<a name="section337mcpsimp"></a>
Modem事件上报是指在Modem设备节点读取线程循环读取到Modem主动上报的消息后,将读取到的消息解析为对应的Modem上报事件,然后上报给RIL Adapter。
## 接口说明<a name="section340mcpsimp"></a>
Modem事件上报接口。
**表 1** Modem事件上报接口功能介绍
<a name="table343mcpsimp"></a>
<table><thead align="left"><tr id="row349mcpsimp"><th class="cellrowborder" valign="top" width="56.99999999999999%" id="mcps1.2.3.1.1"><p id="p351mcpsimp"><a name="p351mcpsimp"></a><a name="p351mcpsimp"></a>接口名</p>
</th>
<th class="cellrowborder" valign="top" width="43%" id="mcps1.2.3.1.2"><p id="p353mcpsimp"><a name="p353mcpsimp"></a><a name="p353mcpsimp"></a>描述</p>
</th>
</tr>
</thead>
<tbody><tr id="row355mcpsimp"><td class="cellrowborder" valign="top" width="56.99999999999999%" headers="mcps1.2.3.1.1 "><p id="p357mcpsimp"><a name="p357mcpsimp"></a><a name="p357mcpsimp"></a>static void OnNotificationResponse(const char *s, const char *sms_pdu)</p>
</td>
<td class="cellrowborder" valign="top" width="43%" headers="mcps1.2.3.1.2 "><p id="p359mcpsimp"><a name="p359mcpsimp"></a><a name="p359mcpsimp"></a>该接口对Modem上报的事件进行分发处理</p>
</td>
</tr>
</tbody>
</table>
## 开发步骤<a name="section183291958165215"></a>
在Modem设备节点读取线程s\_tid\_read里调用OnNotificationResponse\(\)解析具体的Modem上报事件,并调用OnRadioEventNotify\(\)把解析得到的事件上报给RIL Adapter。
```
bool IsCallStatusUpdated(const char *s)
{
return (StrBeginWith(s, "+CRING:")
|| StrBeginWith(s, "RING")
|| StrBeginWith(s, "NO CARRIER")
|| StrBeginWith(s, "+CCWA"));
}
bool IsSetRadioPower(const char *s)
{
return StrBeginWith(s, "+CFUN: 0");
}
static void OnNotificationResponse(const char *s, const char *sms_pdu)
{
if (IsCallStatusUpdated(s)) {
OnRadioEventNotify(HNOTI_CALL_STATUS, NULL, 0);
} else if (IsSetRadioPower(s)) {
SetRadioState(RADIO_OFF);
}
……
}
```
## 调测验证(可选)<a name="section405mcpsimp"></a>
1. 用hdc工具连接调试设备,把编译生成的libvendor.z.so库文件通过hdc file send推到/system/lib/目录下。
2. 执行hdc shell sync, hdc shell reboot重启设备。
3. hdc shell后输入hilog命令,查看OnNotificationResponse\(\)是否正确执行完成,根据日志信息判断是否成功。
# Modem厂商库初始化开发指导<a name="ZH-CN_TOPIC_0000001149333801"></a>
- [场景介绍](#section219mcpsimp)
- [接口说明](#section225mcpsimp)
- [开发步骤](#section1432655815216)
- [调测验证(可选)](#section268mcpsimp)
## 场景介绍<a name="section219mcpsimp"></a>
Modem厂商库初始化是指在厂商库里实现const VendorCallbacks \*RilInit\(const struct RIL\_Init\_Env \*env\)函数,在该函数里处理三个重要的功能:
- 接收RIL Adapter事件回调的函数指针,当Modem有事件上报时,调用对应的函数指针,把事件上报给RIL Adapter。
- 创建读取Modem设备节点的线程,在该线程里会循环地读取Modem上报的事件,并把接收的Modem信息解析为具体事件上报。
- 返回业务请求接口、业务请求执行结果的接口和Modem事件上报接口的函数指针给RIL Adapter。
## 接口说明<a name="section225mcpsimp"></a>
Modem厂商库初始化接口。
**表 1** Modem厂商库初始化接口功能介绍
<a name="table228mcpsimp"></a>
<table><thead align="left"><tr id="row234mcpsimp"><th class="cellrowborder" valign="top" width="56.99999999999999%" id="mcps1.2.3.1.1"><p id="p236mcpsimp"><a name="p236mcpsimp"></a><a name="p236mcpsimp"></a>接口名</p>
</th>
<th class="cellrowborder" valign="top" width="43%" id="mcps1.2.3.1.2"><p id="p238mcpsimp"><a name="p238mcpsimp"></a><a name="p238mcpsimp"></a>描述</p>
</th>
</tr>
</thead>
<tbody><tr id="row240mcpsimp"><td class="cellrowborder" valign="top" width="56.99999999999999%" headers="mcps1.2.3.1.1 "><p id="p242mcpsimp"><a name="p242mcpsimp"></a><a name="p242mcpsimp"></a>const VendorCallbacks *RilInit(const struct RIL_Init_Env *env)</p>
</td>
<td class="cellrowborder" valign="top" width="43%" headers="mcps1.2.3.1.2 "><p id="p244mcpsimp"><a name="p244mcpsimp"></a><a name="p244mcpsimp"></a>该接口为Modem厂商库运行的入口</p>
</td>
</tr>
</tbody>
</table>
## 开发步骤<a name="section1432655815216"></a>
1. RilInit接口中设置RIL Adapter传入的事件回调函数指针。
```
static struct RIL_Init_Env g_rilEnv = {
OnRequestResponse,
OnRadioEventNotify,
OnReqTimerExpiredCallback,
OnAsyncReqAck
};
s_rilenv = env;
```
2. 创建主线程s\_tid\_main,开启消息循环。
```
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
ret = pthread_create(&s_tid_main, &attr, MainRunner, NULL);
```
3. 在s\_tid\_main线程用open\(\)打开Modem设备节点,并创建s\_tid\_read线程循环读取处理Modem上报的消息。
```
open(s_device_path, O_RDWR); // s_device_path为Modem设备节点
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
ret = pthread_create(&s_tid_read, &attr, ReadRunner, &attr);
```
4. 返回业务请求接口、业务请求执行结果的接口和Modem事件上报接口的函数指针。
```
static const RIL_RadioFunctions g_callbacks = {
RIL_VERSION,
OnRequest,
CurrentState,
OnSupports,
OnCancel,
GetVersion
};
return &g_callbacks;
```
## 调测验证(可选)<a name="section268mcpsimp"></a>
1. 用hdc工具连接调试设备,把编译生成的libvendor.z.so库文件通过hdc file send推到/system/lib/目录下。
2. 执行hdc shell sync, hdc shell reboot重启设备。
3. hdc shell后输入hilog命令,查看RilInit\(\)是否正确执行完成,根据日志信息判断是否成功。
# Modem厂商库集成指导<a name="ZH-CN_TOPIC_0000001148928023"></a>
- [编译设置](#section142111565210)
- [调测验证(可选)](#section114621643195220)
## 编译设置<a name="section142111565210"></a>
Modem厂商库可通过BUILD.gn编译为一个动态库,在RIL Adapter启动时用dlopen方式加载到系统中,然后执行厂商库的初始化操作(参见[Modem厂商库初始化开发指导](Modem厂商库初始化开发指导.md)),BUILD.gn编写示例如下:
```
import("//build/ohos.gni")
RIL_ADAPTER = "//base/telephony"
ohos_shared_library("vendor") { // Modem厂商库名称
sources = [ // 编译源文件
"vendorlib.c",
"xxx.c",
]
include_dirs = [ // 包含的头文件目录
"$RIL_ADAPTER/ril_adapter/include",
"$RIL_ADAPTER/ril_adapter/interfaces/innerkits",
"include",
]
deps = [ // 内部依赖
"//drivers/adapter/uhdf2/osal:libhdf_utils"
]
external_deps = [ // 外部依赖
"hilog:libhilog"
]
part_name = "ril_adapter"
subsystem_name = "telephony"
```
## 调测验证(可选)<a name="section114621643195220"></a>
编译完成后,查看out/ohos-arm-release/packages/phone/system/lib 目录下是否生成libvendor.z.so,若生成了libvendor.z.so库文件说明系统集成成功。
......@@ -65,15 +65,6 @@
- [开发实例](开发实例.md)
- [OTA升级](OTA升级.md)
- [电话服务](电话服务.md)
- [概述](概述-4.md)
- [开发指导](开发指导-5.md)
- [Modem厂商库集成指导](Modem厂商库集成指导.md)
- [Modem厂商库初始化开发指导](Modem厂商库初始化开发指导.md)
- [Modem业务请求及响应开发指导](Modem业务请求及响应开发指导.md)
- [Modem事件上报开发指导](Modem事件上报开发指导.md)
- [开发实例](开发实例-6.md)
- [安全](安全.md)
- [概述](概述-7.md)
......
......@@ -440,7 +440,7 @@ hdc\_std tmode port 8710
使用方法(举例):
hdc\_std file send E:\\a.txt /data/local/tmp
hdc\_std file send E:\\a.txt /data/local/tmp/a.txt
- **file recv \[-a\] _remote local_**
......@@ -486,7 +486,7 @@ hdc\_std file send E:\\a.txt /data/local/tmp
使用方法(举例):
hdc\_std file recv /tmp/fileb ./
hdc\_std file recv /data/local/tmp/a.txt ./a.txt
## 应用相关的命令<a name="section2072647133819"></a>
......
# 概述<a name="ZH-CN_TOPIC_0000001144341209"></a>
- [基本概念](#section202mcpsimp)
- [运作机制](#section205mcpsimp)
- [约束与限制](#section207mcpsimp)
适用于OpenHarmony 电话服务子系统 Modem 厂商库集成、初始化、业务请求响应和事件上报的开发指南。
## 基本概念<a name="section202mcpsimp"></a>
电话服务子系统 RIL Adapter模块负责蜂窝通信框架和Modem之间的通信,可支撑不同设备Modem厂商库的开发,提供Modem业务请求和事件上报相关的功能。
## 运作机制<a name="section205mcpsimp"></a>
**图 1** RIL Adapter模块架构图<a name="fig1528194911218"></a>
![](figures/RIL-Adapter.png)
RIL Adapter模块架构如图1所示,主要由ril初始化(hril\_hdf&modem\_adapter)、ril接口实现(hril&ril\_event\_listen)和Modem厂商库(vendorlib)三部分组成。
hril\_hdf执行后,将动态加载vendorlib,vendorlib从hril\_hdf获得可以处理的请求和上报函数指针,该过程结束后,hril\_hdf才可通过vendorlib与Modem通信。
- hril\_hdf:RIL Adapter的入口。主要负责加载Modem厂商库文件、初始化hril库、启动ril\_event\_listen事件调度机制以及加载关联Modem的厂商库文件。
- modem\_adapter:实现单一固件适配不同Modem的适配器。其实现机制为:在加载Modem厂商库之前,从kernel获取Modem的设备型号,根据此型号加载对应的Modem厂商库。
- hril:与电话基础服务交互的接口实现。分为通用接口实现和vendor扩展接口实现两种:其中,通用接口实现了电话服务和主流Modem蜂窝通信的常用功能(SIM卡、搜网、蜂窝数据、蜂窝通话、短彩信等);vendor扩展接口实是为了方便Modem厂商做通用接口以外的定制化能力扩展。
- ril\_event\_listen:处理Modem上报事件的事件调度器。其实现机制为:当接收到Modem上报事件(例如来电),可以把事件封装为ril\_event并添加到事件调度队列中,通过队列管理机制调用回调函数上报到电话基础服务。
- vendorlib:Modem厂商库文件。不同的Modem厂商根据RIL Adapter提供的标准化接口或ID,进行Modem厂商库的开发(vendorlib由Modem厂商提供)。
## 约束与限制<a name="section207mcpsimp"></a>
**规格限制:**
- 需要设备厂商至少支持一个Modem,如果不支持任何Modem,无需实现厂商库接口。
# 电话服务<a name="ZH-CN_TOPIC_0000001111321920"></a>
- **[概述](概述-4.md)**
- **[开发指导](开发指导-5.md)**
- **[开发实例](开发实例-6.md)**
......@@ -52,7 +52,7 @@ OpenHarmony侧的编译构建流程主要包括编译命令行解析,调用gn
安装命令:
```
sudo apt-get install binutils git-core git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4
sudo apt-get install binutils git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4
```
......@@ -345,13 +345,24 @@ vendor
其中fs\_symlink、fs\_make\_cmd字段支持以下变量:
- $\{root\_path\}:代码根目录,对应gn的$\{ohos\_root\_path\}
- $\{out\_path\}:产品out目录,对应gn的$\{root\_out\_dir\}
- $\{fs\_dir\}:文件系统目录,由$\{root\_path\}、$\{fs\_dir\_name\}拼接而成
- $\{root\_path\}
>![](public_sys-resources/icon-note.gif) **说明:**
>fs.yml是可选的,对于没有文件系统的设备可不配置。
代码根目录,对应gn的$\{ohos\_root\_path\}
- $\{out\_path\}
产品out目录,对应gn的$\{root\_out\_dir\}
- $\{fs\_dir\}
文件系统目录,由以下变量拼接而成
- $\{root\_path\}
- $\{fs\_dir\_name\}
>![](public_sys-resources/icon-note.gif) **说明:**
>fs.yml是可选的,对于没有文件系统的设备可不配置。
6. vendor/company/product/BUILD.gn
......
......@@ -35,8 +35,6 @@
- [OTA升级](device-dev/subsystems/OTA升级.md)
- [电话服务](device-dev/subsystems/电话服务.md)
- [安全](device-dev/subsystems/安全.md)
- [启动恢复](device-dev/subsystems/启动恢复.md)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册