提交 b7507124 编写于 作者: J jiangminsen 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/docs into master

Signed-off-by: Njiangminsen <jiangminsen@huawei.com>
......@@ -224,8 +224,9 @@ zh-cn/application-dev/background-agent-scheduled-reminder/ @RayShih
zh-cn/application-dev/background-task-management/ @ningningW @wangwenli_wolf @tangtiantian2021 @nan-xiansen
zh-cn/application-dev/work-scheduler/ @ningningW
zh-cn/application-dev/internationalization/ @ningningW @Buda-Liu @mengjingzhimo @yangqing3
zh-cn/application-dev/device/usb-overview.md @ge-yafang @jasonyujia @andeszhang @liuhonggang123
zh-cn/application-dev/device/usb-guidelines.md @ge-yafang @jasonyujia @andeszhang @liuhonggang123
zh-cn/application-dev/device/usb-overview.md @ge-yafang @Kevin-Lau @liuhonggang123
zh-cn/application-dev/device/usb-guidelines.md @ge-yafang @Kevin-Lau @liuhonggang123
zh-cn/application-dev/napi/usb-ddk-guidelines.md @ge-yafang @Kevin-Lau @liuhonggang123
zh-cn/application-dev/device/device-location-overview.md @RayShih
zh-cn/application-dev/device/device-location-info.md @RayShih
zh-cn/application-dev/device/device-location-geocoding.md @RayShih
......@@ -499,9 +500,9 @@ zh-cn/application-dev/reference/apis/js-apis-uitest.md @inter515 @ningningW @int
zh-cn/application-dev/reference/apis/js-apis-update.md @hughes802 @ningningW @zhangzhengxue @mamba-ting
zh-cn/application-dev/reference/apis/js-apis-uri.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-url.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-usbManager.md @jasonyujia @ge-yafang @andeszhang @liuhonggang123
zh-cn/application-dev/reference/apis/js-apis-usb.md @jasonyujia @ge-yafang @andeszhang @liuhonggang123
zh-cn/application-dev/reference/apis/js-apis-usb-deprecated.md @jasonyujia @ge-yafang @andeszhang @liuhonggang123
zh-cn/application-dev/reference/apis/js-apis-usbManager.md @ge-yafang @Kevin-Lau @liuhonggang123
zh-cn/application-dev/reference/apis/js-apis-usb.md @ge-yafang @Kevin-Lau @liuhonggang123
zh-cn/application-dev/reference/apis/js-apis-usb-deprecated.md @ge-yafang @Kevin-Lau @liuhonggang123
zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md @gaoyong @zengyawen @niejiteng @jumozhanjiang
zh-cn/application-dev/reference/apis/js-apis-util.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-vector.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
......
......@@ -80,7 +80,7 @@ The widget provider development based on the [stage model](stage-model-developme
- [Creating a FormExtensionAbility Instance](#creating-a-formextensionability-instance): Develop the lifecycle callback functions of FormExtensionAbility.
- [Configuring the Widget Configuration File](#configuring-the-widget-configuration-file): Configure the application configuration file **module.json5** and profile configuration file.
- [Configuring the Widget Configuration Files](#configuring-the-widget-configuration-files): Configure the application configuration file **module.json5** and profile configuration file.
- [Persistently Storing Widget Data](#persistently-storing-widget-data): Manage widget data persistence.
......
......@@ -48,7 +48,7 @@ try {
.then((uploadTask) => {
uploadTask.on('complete', (taskStates) => {
for (let i = 0; i < taskStates.length; i++) {
console.info(`upload complete taskState: ${JSON.stringify(taskStates[i])}');
console.info(`upload complete taskState: ${JSON.stringify(taskStates[i])}`);
}
});
})
......
......@@ -11,7 +11,32 @@ What the internal state is depends on the component. For example, for the [bindP
- $$ supports variables of simple types and variables decorated by **\@State**, **\@Link**, or **\@Prop**.
- Currently, $$ supports only the **show** parameter of the [bindPopup](../reference/arkui-ts/ts-universal-attributes-popup.md) attribute method, the **checked** attribute of the [\<Radio>](../reference/arkui-ts/ts-basic-components-radio.md) component, and the **refreshing** parameter of the [\<Refresh>](../reference/arkui-ts/ts-container-refresh.md) component.
- $$ supports the components listed below.
| Component | Supported Parameter/Attribute| Initial API Version|
| ------------------------------------------------------------ | --------------- | ----------- |
| [bindPopup](../reference/arkui-ts/ts-universal-attributes-popup.md) | show | 8 |
| [Checkbox](../reference/arkui-ts/ts-basic-components-checkbox.md) | select | 10 |
| [CheckboxGroup](../reference/arkui-ts/ts-basic-components-checkboxgroup.md) | selectAll | 10 |
| [DatePicker](../reference/arkui-ts/ts-basic-components-datepicker.md) | selected | 10 |
| [TimePicker](../reference/arkui-ts/ts-basic-components-timepicker.md) | selected | 10 |
| [MenuItem](../reference/arkui-ts/ts-basic-components-menuitem.md) | selected | 10 |
| [Panel](../reference/arkui-ts/ts-container-panel.md) | mode | 10 |
| [Radio](../reference/arkui-ts/ts-basic-components-radio.md) | checked | 10 |
| [Rating](../reference/arkui-ts/ts-basic-components-rating.md) | rating | 10 |
| [Refresh](../reference/arkui-ts/ts-container-refresh.md) | refreshing | 8 |
| [Search](../reference/arkui-ts/ts-basic-components-search.md) | value | 10 |
| [SideBarContainer](../reference/arkui-ts/ts-container-sidebarcontainer.md) | showSideBar | 10 |
| [Slider](../reference/arkui-ts/ts-basic-components-slider.md) | value | 10 |
| [Stepper](../reference/arkui-ts/ts-basic-components-stepper.md) | index | 10 |
| [Swiper](../reference/arkui-ts/ts-container-swiper.md) | isOn | 10 |
| [Tabs](../reference/arkui-ts/ts-container-tabs.md) | index | 10 |
| [TextArea](../reference/arkui-ts/ts-basic-components-textarea.md) | text | 10 |
| [TextInput](../reference/arkui-ts/ts-basic-components-textinput.md) | text | 10 |
| [TextPicker](../reference/arkui-ts/ts-basic-components-textpicker.md) | selected, value| 10 |
| [Toggle](../reference/arkui-ts/ts-basic-components-toggle.md) | isOn | 10 |
| [AlphabetIndexer](../reference/arkui-ts/ts-container-alphabet-indexer.md) | selected | 10 |
| [Select](../reference/arkui-ts/ts-basic-components-select.md) | selected, value| 10 |
- When the variable bound to $$ changes, the UI is re-rendered synchronously.
......
......@@ -301,6 +301,7 @@
- [@ohos.nfc.controller (Standard NFC)](js-apis-nfcController.md)
- [@ohos.nfc.tag (Standard NFC Tags)](js-apis-nfcTag.md)
- [@ohos.rpc (RPC)](js-apis-rpc.md)
- [@ohos.secureElement (SE Channel Management)](js-apis-secureElement.md)
- [@ohos.wifiManager (WLAN) (Recommended)](js-apis-wifiManager.md)
- [@ohos.wifiManagerExt (WLAN Extension) (Recommended)](js-apis-wifiManagerExt.md)
- [@ohos.wifi (WLAN) (To Be Deprecated Soon)](js-apis-wifi.md)
......
......@@ -34,6 +34,12 @@ Obtains the snapshot of a component that has been loaded. This API uses an async
| id | string | Yes | [ID](../arkui-ts/ts-universal-attributes-component-id.md) of the target component.|
| callback | AsyncCallback&lt;image.PixelMap&gt; | Yes | Callback used to return the result. |
**Error codes**
| ID| Error Message |
| -------- | ------------------- |
| 100001 | if id is not valid. |
**Example**
```js
......@@ -159,6 +165,12 @@ Renders a custom component in the application background and outputs its snapsho
| builder | [CustomBuilder](../arkui-ts/ts-types.md#custombuilder8) | Yes | Builder of the custom component.|
| callback | AsyncCallback&lt;image.PixelMap&gt; | Yes | Callback used to return the result.|
**Error codes**
| ID| Error Message |
| -------- | ----------------------------------------- |
| 100001 | if builder is not a valid build function. |
**Example**
```ts
......
......@@ -31,6 +31,18 @@ Creates a **DrawableDescriptor** object when the passed resource ID or name belo
Creates a **LayeredDrawableDescriptor** object when the passed resource ID or name belongs to a JSON file that contains foreground and background resources.
The content of the **drawble.json** file is as follows:
```json
{
"layered-image":
{
"background" : "$media:background",
"foreground" : "$media:foreground"
}
}
```
**Example**
```ts
// xxx.ets
......@@ -45,7 +57,7 @@ struct Index {
Row() {
Column() {
Image((<LayeredDrawableDescriptor> (this.resManager.getDrawableDescriptor($r('app.media.icon').id))))
Image(((<LayeredDrawableDescriptor> (this.resManager.getDrawableDescriptor($r('app.media.icon')
Image(((<LayeredDrawableDescriptor> (this.resManager.getDrawableDescriptor($r('app.media.drawable')
.id))).getForeground()).getPixelMap())
}.height('50%')
}.width('50%')
......@@ -68,7 +80,8 @@ Obtains this **pixelMap** object.
**Example**
```ts
pixmap: PixelMap = drawable1.getPixelMap();
pixmap: PixelMap = (<DrawableDescriptor> (this.resManager.getDrawableDescriptor($r('app.media.icon')
.id))).getPixelMap();
```
## LayeredDrawableDescriptor.getPixelMap
......@@ -86,7 +99,8 @@ Obtains the **pixelMap** object where the foreground, background, and mask are b
**Example**
```ts
pixmap: PixelMap = layeredDrawable1.getPixelMap();
pixmap: PixelMap = (<LayeredDrawableDescriptor> (this.resManager.getDrawableDescriptor($r('app.media.drawable')
.id))).getPixelMap();
```
## LayeredDrawableDescriptor.getForeground
......@@ -104,7 +118,8 @@ Obtains the **DrawableDescriptor** object of the foreground.
**Example**
```ts
drawable: DrawableDescriptor = layeredDrawable1.getForeground();
drawable: DrawableDescriptor = (<LayeredDrawableDescriptor> (this.resManager.getDrawableDescriptor($r('app.media.drawable')
.id))).getForeground();
```
## LayeredDrawableDescriptor.getBackground
......@@ -122,7 +137,8 @@ Obtains the **DrawableDescriptor** object of the background.
**Example**
```ts
drawable: DrawableDescriptor = layeredDrawable1.getBackground();
drawable: DrawableDescriptor = (<LayeredDrawableDescriptor> (this.resManager.getDrawableDescriptor($r('app.media.drawable')
.id))).getBackground();
```
## LayeredDrawableDescriptor.getMask
......@@ -140,5 +156,6 @@ Obtains the **DrawableDescriptor** object of the mask.
**Example**
```ts
drawable: DrawableDescriptor = layeredDrawable1.getMask();
drawable: DrawableDescriptor = (<LayeredDrawableDescriptor> (this.resManager.getDrawableDescriptor($r('app.media.drawable')
.id))).getMask();
```
......@@ -34,12 +34,14 @@ Registers a custom font with the font manager.
## FontOptions
**System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Mandatory | Description |
| ---------- | ------ | ---- | ------------ |
| familyName | string | Yes | Name of the custom font to register. |
| familySrc | string | Yes | Path of the custom font to register.|
## Example
**Example**
```ts
// xxx.ets
......@@ -68,7 +70,7 @@ struct FontExample {
}
}
```
## font.getSystemFontList
## font.getSystemFontList<sup>10+</sup>
getSystemFontList(): Array\<string>
......@@ -82,7 +84,7 @@ Obtains the list of supported fonts.
| -------------------- | ----------------- |
| Array\<string> | List of supported fonts. |
## Example
**Example**
```ts
// xxx.ets
......@@ -105,7 +107,7 @@ struct FontExample {
}
```
## font.getFontByName
## font.getFontByName<sup>10+</sup>
getFontByName(fontName: string): FontInfo;
......@@ -127,18 +129,22 @@ Obtains information about a system font based on the font name.
## FontInfo
| Name | Type | Description |
| -------------- | ------- | ------------------------- |
| path | string | File path of the system font. |
| postScriptName | string | PostScript name of the system font.|
| fullName | string | Name of the system font. |
| family | string | Family of the system font. |
| subfamily | string | Subfamily of the system font. |
| weight | number | Weight of the system font. |
| width | number | Width of the system font. |
| italic | boolean | Whether the system font is italic. |
| monoSpace | boolean | Whether the system font is monospaced. |
| symbolic | boolean | Whether the system font supports symbols. |
**System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Mandatory | Description |
| -------------- | ------- | ------------------------- | ------------------------- |
| path | string | Yes| File path of the system font. |
| postScriptName | string | Yes| PostScript name of the system font.|
| fullName | string | Yes| Name of the system font. |
| family | string | Yes| Family of the system font. |
| subfamily | string | Yes| Subfamily of the system font. |
| weight | number | Yes| Weight of the system font. |
| width | number | Yes| Width of the system font. |
| italic | boolean | Yes| Whether the system font is italic. |
| monoSpace | boolean | Yes| Whether the system font is monospaced. |
| symbolic | boolean | Yes| Whether the system font supports symbols. |
**Example**
```ts
// xxx.ets
......@@ -169,4 +175,3 @@ struct FontExample {
}
}
```
......@@ -16,7 +16,7 @@ import matrix4 from '@ohos.matrix4'
## matrix4.init
init(option: [number,number,number,number,number,number,number,number,number,number,number,number,number,number,number,number]): Matrix4Transit
init(options: [number,number,number,number,number,number,number,number,number,number,number,number,number,number,number,number]): Matrix4Transit
Matrix constructor, which is used to create a 4 x 4 matrix by using the input parameter. Column-major order is used.
......@@ -27,7 +27,7 @@ Matrix constructor, which is used to create a 4 x 4 matrix by using the input pa
| Name| Type | Mandatory| Description |
| ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| option | [number,number,number,number,number,number,number,number,number,number,number,number,number,number,number,number] | Yes | A number array whose length is 16 (4 x 4). For details, see **Description of a 4 x 4 matrix**.<br>Default value:<br>[1, 0, 0, 0,<br>0, 1, 0, 0,<br>0, 0, 1, 0,<br>0, 0, 0, 1] |
| option | [number,number,number,number,number,number,number,number,number,number,number,number,number,number,number,number] | Yes | A number array whose length is 16 (4 x 4). For details, see **Description of a 4 x 4 matrix**.<br>Default value:<br>[1,&nbsp;0,&nbsp;0,&nbsp;0,<br>0,&nbsp;1,&nbsp;0,&nbsp;0,<br>0,&nbsp;0,&nbsp;1,&nbsp;0,<br>0,&nbsp;0,&nbsp;0,&nbsp;1] |
**Return value**
......@@ -176,7 +176,7 @@ struct Test {
### combine
combine(option: Matrix4Transit): Matrix4Transit
combine(options: Matrix4Transit): Matrix4Transit
Combines the effects of two matrices to generate a new matrix object.
......@@ -273,7 +273,7 @@ struct Tests {
### translate
translate(option: TranslateOption): Matrix4Transit
translate(options: TranslateOption): Matrix4Transit
Translates this matrix object along the x, y, and z axes.
......@@ -317,7 +317,7 @@ struct Test {
### scale
scale(option: ScaleOption): Matrix4Transit
scale(options: ScaleOption): Matrix4Transit
Scales this matrix object along the x, y, and z axes.
......@@ -362,7 +362,7 @@ struct Test {
### rotate
rotate(option: RotateOption): Matrix4Transit
rotate(options: RotateOption): Matrix4Transit
Rotates this matrix object along the x, y, and z axes.
......@@ -408,7 +408,7 @@ struct Test {
### transformPoint
transformPoint(option: [number, number]): [number, number]
transformPoint(options: [number, number]): [number, number]
Applies the current transformation effect to a coordinate point.
......@@ -466,15 +466,19 @@ struct Test {
## TranslateOption
**System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ----------------------------------------------------------- |
| x | number | No | Translation distance along the x-axis, in px.<br>Default value: **0**<br>Value range: (-∞, +∞)|
| y | number | No | Translation distance along the y-axis, in px.<br>Default value: **0**<br>Value range: (-∞, +∞)|
| z | number | No | Translation distance along the z-axis, in px.<br>Default value: **0**<br>Value range: (-∞, +∞)|
| ---- | ------ | ---- | ----------------------------------------------------------- |
| x | number | No | Translation distance along the x-axis, in px.<br>Default value: **0**<br>Value range: (-∞, +∞)|
| y | number | No | Translation distance along the y-axis, in px.<br>Default value: **0**<br>Value range: (-∞, +∞)|
| z | number | No | Translation distance along the z-axis, in px.<br>Default value: **0**<br>Value range: (-∞, +∞)|
## ScaleOption
| Name | Type | Mandatory| Description |
**System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------------------------------------------------------------ |
| x | number | No | Scaling multiple along the x-axis. If the value is greater than 1, the image is scaled up along the x-axis. If the value is less than 1, the image is scaled down along the x-axis.<br>Default value: **1**<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value.|
| y | number | No | Scaling multiple along the y-axis. If the value is greater than 1, the image is scaled up along the y-axis. If the value is less than 1, the image is scaled down along the y-axis.<br>Default value: **1**<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value.|
......@@ -484,7 +488,9 @@ struct Test {
## RotateOption
| Name | Type | Mandatory| Description |
**System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------------------------------------------------------- |
| x | number | No | X coordinate of the rotation axis vector.<br>Default value: **1**<br>Value range: (-∞, +∞)|
| y | number | No | Y coordinate of the rotation axis vector.<br>Default value: **1**<br>Value range: (-∞, +∞)|
......
......@@ -262,7 +262,7 @@ pluginComponentManager.push(
name: "ets/pages/plugin2.js",
data: {
"js": "ets/pages/plugin.js",
"key_1": 1111, ,
"key_1": 1111,
},
extraData: {
"extra_str": "this is push event"
......@@ -376,10 +376,24 @@ Listens for events of the request type and returns the requested data, or listen
| eventType | string | Yes | Type of the event to listen for. The options are as follows:<br>**"push"**: The component provider pushes data to the component consumer.<br>**"request"**: The component consumer proactively requests data from the component provider.|
| callback | [OnPushEventCallback](#onpusheventcallback)&nbsp;\|&nbsp;[OnRequestEventCallback](#onrequesteventcallback) | Yes | Callback used to return the result. The type is [OnPushEventCallback](#onpusheventcallback) for the push event and [OnRequestEventCallback](#onrequesteventcallback) for the request event.|
**Example**
```js
function onPushListener(source, template, data, extraData) {
console.log("onPushListener template.source=" + template.source)
console.log("onPushListener source=" + JSON.stringify(source))
console.log("onPushListener template=" + JSON.stringify(template))
console.log("onPushListener data=" + JSON.stringify(data))
console.log("onPushListener extraData=" + JSON.stringify(extraData))
}
function onRequestListener(source, name, data) {
console.error("onRequestListener");
console.log("onRequestListener source=" + JSON.stringify(source));
console.log("onRequestListener name=" + name);
console.log("onRequestListener data=" + JSON.stringify(data));
return { template: "ets/pages/plugin.js", data: data };
}
pluginComponentManager.on("push", onPushListener)
pluginComponentManager.on("request", onRequestListener)
```
......
......@@ -604,7 +604,7 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message|
| --------- | ------- |
| 100001 | if UI execution context not found. |
| 100001 | if UI execution context not found, only throw in standard system. |
| 100004 | if the named route is not exist. |
**Example**
......@@ -645,7 +645,7 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message|
| --------- | ------- |
| 100001 | if UI execution context not found. |
| 100001 | if UI execution context not found, only throw in standard system. |
| 100004 | if the named route is not exist. |
**Example**
......@@ -693,7 +693,7 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message|
| --------- | ------- |
| 100001 | if can not get the delegate. |
| 100001 | if UI execution context not found, only throw in standard system. |
| 100004 | if the named route is not exist. |
**Example**
......@@ -735,7 +735,7 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message|
| --------- | ------- |
| 100001 | if UI execution context not found. |
| 100001 | if UI execution context not found, only throw in standard system. |
| 100004 | if the named route is not exist. |
**Example**
......@@ -1054,7 +1054,7 @@ struct Second {
Text(this.text)
.fontSize(30)
.onClick(() => {
this.secondData = (this.data.['array'][1]).toString()
this.secondData = (this.data['array'][1]).toString()
})
.margin({ top: 20 })
Text(`This is the data passed from the first page: ${this.secondData}`)
......
......@@ -60,6 +60,7 @@
- [Bluetooth Error Codes](errorcode-bluetoothManager.md)
- [Wi-Fi Error Codes](errorcode-wifi.md)
- [NFC Error Codes](errorcode-nfc.md)
- [SE Error Codes](errorcode-se.md)
- [RPC Error Codes](errorcode-rpc.md)
- Basic Features
- [Accessibility Error Codes](errorcode-accessibility.md)
......
......@@ -22,7 +22,7 @@ The operation for obtaining the rendering engine or parsing parameters fails.
NA
## 100002 Incorrect URI
## 100002 Incorrect URI During Page Redirection
**Error Message**
......@@ -58,7 +58,21 @@ Too many pages are pushed.
Delete unnecessary or invalid pages.
## 200002 Incorrect URI
## 100004 Incorrect Route Name
**Error Message**
Named route error. The named route is not exist.
**Description**
This error code is reported when the specified route name for redirection is incorrect or does not exist.
**Possible Causes**
The specified route name for redirection is incorrect or does not exist.
## 200002 Incorrect URI During Page Replacement
**Error Message**
......
# SE Error Codes
> **NOTE**
>
> This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md).
## 3300101 Abnormal SE Service Status
**Error Message**
Illegal service state exception.
**Description**
The SecureElement (SE) service is abnormal.
**Possible Causes**
1. The SE service is disconnected.
**Solution**
1. Close the SE service.
2. Set up a connection with the SE service again.
## 3300102 No Such SE
**Error Message**
No such element exception.
**Description**
The SE is unavailable.
**Possible Causes**
1. Communication with the SE service is abnormal.
2. Communication of the SE chip is abnormal.
**Solution**
1. Close the SE service and set up a connection with the SE service again.
2. Restart the device.
## 3300103 Failed to Obtain the Access Rule
**Error Message**
Illegal access rule exception.
**Description**
The access rule cannot be obtained.
**Possible Causes**
1. There is no access rule for the application on the SE.
**Solution**
1. Write correct access rules to the SE.
2. Close the SE service and set up a connection with the SE service again.
## 3300104 SE Chip I/O Exception
**Error Message**
Secure element IO exception.
**Description**
The I/O of the SE chip is abnormal.
**Possible Causes**
1. The communication with the SE chip is abnormal.
2. The SE chip is abnormal.
**Solution**
1. Close the SE service and set up a connection with the SE service again.
2. Restart the device.
# Native API Introduction
Native APIs, also called Native Develop Kit (NDK), are a set of native interfaces and tools provided by the OpenHarmony SDK for implementing key application features by using C or C++. Different from JS APIs, the Native APIs provide only part of underlying capabilities of OpenHarmony, such as the libc, graphics library, window system, multimedia, and compression library. The Native APIs will be build as a dynamic library before being packaged into an application.
## Concepts
|Term|Description|
|--|--|
|Native API|Native interfaces, build scripts, and compiler toolchains provided by the **native** package in the OpenHarmony SDK for third-party application development. Native APIs include the C runtime libc, 3D graphics library **OpenGL**, and Node-APIs for cross-language programming between JS and C.|
|NDK|Native Develop Kit (NDK) that provides the Native APIs in OpenHarmony. NDK is the equivalent of Native API. Native API is the official name.|
|SDK CAPI|C interfaces and toolchains in OpenHarmony Native APIs.<br/>Currently, OpenHarmony Native APIs contain only C interfaces. Therefore, Native API is CAPI. However, you are advised to use CAPI.|
|Node-API|Native interfaces that implement cross-language invocation between C and JS. Node-API is formerly called napi. Although OpenHarmony Node-APIs are extension of the Node-APIs provided by **Node.js**, they are not fully compatible with the Node-APIs in **Node.js**.|
|napi|Former name of Node-API. It is not used because it may be interpreted as Native API or Node-API by mistake. Currently, the interfaces in the Node-API header files still start with **napi_**.|
## Native API Composition
### Native API Directory Structure
Native APIs are stored in the **$(SDK_ROOT)/native** directory of the SDK.
|Directory|Description|
|--|--|
|build|Provides the toolchain cmake script used to build the dynamic library of an application. The **ohos.toolchain.cmake** file in this directory defines OpenHarmony cross-compilation options.|
|build-tools|Provides build tools, such as CMake.|
|docs|Provides Native API reference documents, which are extracted from the header files using Doxgen.|
|llvm|Provides the LLVM, a cross compiler that supports the OpenHarmony Application Binary Interface (ABI).|
|sysroot|Provides dependencies of links, including header files and dynamic libraries.|
### Native APIs
|Category|Description|Introduced Since Version|
|--|--|--|
|[C standard library](native-lib/third_party_libc/musl.md)|Provides more than 1500 libc interfaces based on musl.|8|
|[C++ standard library](native-lib/third_party_libc/cpp.md)|Provides the libc++_shared library for C++ runtime. This library must be packed or statically linked to the application during packing.|8|
|Log|Provides HiLog interfaces for printing logs to the system.|8|
|Node-API|Provides APIs like Node-APIs (also called napis) for accessing the JS application environment. Node-APIs are provided by ArkUI and are part of Native APIs.|8|
|XComponent|Provides Surface and touchscreen event interfaces for developing high-performance graphics applications on ArkUI.|8|
|libuv|Provides a third-party asynchronous I/O library integrated by ArkUI.|8|
|libz|Provides basic compression and decompression interfaces.|8|
|Drawing|Provides a 2D graphics library for drawing on Surface.|8|
|OpenGL|Provides OpenGL 3.0 interfaces.|8|
|Rawfile|Provides application resource access interfaces for reading various resources packed in applications.|8|
|OpenSLES|Provides interfaces for 2D and 3D audio acceleration.|8|
|Mindspore|Provides AI model interfaces.|9|
|Bundle management|Provides bundle service interfaces for querying bundle information of applications.|8|
### Native API Documents
* [Native API Reference](native-apis/_o_h___native_x_component.md): provides reference for Native APIs.
* [Standard Libraries Supported by Native APIs](../reference/native-lib/third_party_libc/musl.md): describes the open-source standard libraries supported by Native APIs.
* [Native API Development](../napi/napi-guidelines.md): describes how to use Native APIs.
* [Using NDK to Build a CMake C/C++ Project](../faqs/how-to-migrate-cmake-with-ohosndk.md): describes how to use Native APIs to develop a CMake project.
* [Using Node-APIs in Application Projects](../napi/napi-guidelines.md): describes how to use Node-APIs.
## How to Use
### Recommended Use of Native APIs
Use Native APIs when you want to:
1. Develop performance-sensitive code in computing-intensive scenarios, such as gaming and physical simulation.
2. Reuse the existing C or C++ library.
3. Customize libraries related to CPU features, such as neon acceleration.
### Use of Native APIs Not Recommended
Do not use Native APIs when you want to:
1. Develop a pure OpenHarmony application.
2. Develop an application that is compatible on as many OpenHarmony devices as possible.
## Debugging Capabilities
1. OpenHarmony provides remote code debugging by using the low-level Debugger (LLDB). For details, see [LLDB](https://gitee.com/openharmony/third_party_llvm-project/blob/master/lldb/README_en.md).
2. OpenHarmony provides the log debugging for the musl library. For details, see "Debugging Capabilities" in [libc](./native-lib/third_party_libc/musl.md).
<!--no_check-->
\ No newline at end of file
# Standard Libraries Supported by Native APIs
# Native API Standard Libraries
- [libc](third_party_libc/musl.md)
- [libc++](third_party_libc/cpp.md)
- [Node-API](third_party_napi/napi.md)
- [libuv](third_party_libuv/libuv.md)
- [OpenSL ES](third_party_opensles/opensles.md)
- [OpenGL ES](third_party_opengl/opengles.md)
- [EGL](third_party_opengl/egl.md)
- [zlib](third_party_zlib/zlib.md)
- Appendix
- [Native API Symbols Not Exported](third_party_libc/musl-peculiar-symbol.md)
- [Native API Symbols That May Fail to Be Invoked Due to Permission Control](third_party_libc/musl-permission-control-symbol.md)
......
# libc++
Currently, OpenHarmony uses the C++ standard library [(libc++)](https://libcxx.llvm.org/) of the LLVM project.
## Version
From OpenHarmony 3.0, libc++ uses Clang/LLVM 10.0.1.
From OpenHarmony 3.2, libc++ is upgraded to Clang/LLVM 12.0.1.
From OpenHarmony 4.0, libc++ is upgraded to Clang/LLVM 15.0.4.
## Supported Capabilities
The C++11 and C++14 standards are supported, and the C++17 and C++20 standards are on the way. For details about the standards supported by language features, see the corresponding Release Notes at [https://libcxx.llvm.org/](https://libcxx.llvm.org/).
## ABI Compatibility
In OpenHarmony, both the system library and application native library use the libc++. However, the two libc++ are different. The libc++ of the system library is updated with the image version, while the libc++ of the application native library is updated with the SDK version used for compilation. Both the libc++ libraries cross multiple major versions, which may cause Application Binary Interface (ABI) compatibility issues. To solve this problem, OpenHarmony differentiates the libc++ libraries as follows:
* System library: uses **libc++.so**, which is released with the system image.
* Application native library: uses **libc++_shared.so**, which is released with the application.
The two libc++ libraries use different namespaces. **libc++_shared.so** uses **__n1** as the namespace for C++ symbols, and **libc++.so** uses **__h** as the namespace for C++ symbols.
> **CAUTION**
>
> Currently, the Native API supports C only. The system library can use any programming language.
<!--no_check-->
\ No newline at end of file
# Native API Symbols That May Fail to Be Invoked Due to Permission Control
Before using the following interfaces, ensure that the application entity has the corresponding permission.
| Symbol| Possible Cause|
| --- | --- |
| mlockall | User namespace isolation or lack of the CAP_IPC_LOCK privilege.|
| swapon | User namespace isolation. |
| swapoff | User namespace isolation. |
| stime | User namespace isolation or lack of the CAP_SYS_TIME privilege.|
| settimeofday | User namespace isolation or lack of the CAP_SYS_TIME privilege.|
| adjtime | User namespace isolation or lack of the CAP_SYS_TIME privilege.|
| clock_settime | User namespace isolation or lack of the CAP_SYS_TIME privilege.|
| klogctl | User namespace isolation or lack of the CAP_SYS_ADMIN/CAP_SYSLOG privilege.|
| mlockall | usr namespace isolation or lack of CAP_IPC_LOCK privilege |
| swapon | usr namespace isolation |
| swapoff | usr namespace isolation |
| stime | usr namespace isolation or lack of CAP_SYS_TIME privilege |
| settimeofday | usr namespace isolation or lack of CAP_SYS_TIME privilege |
| adjtime | usr namespace isolation or lack of CAP_SYS_TIME privilege |
| clock_settime | usr namespace isolation or lack of CAP_SYS_TIME privilege |
| klogctl | usr namespace isolation or lack of CAP_SYS_ADMIN/CAP_SYSLOG privilege |
# Native Standard Libraries Supported by OpenHarmony
# libc
## Overview
The C standard library (libc) provides standard header files and common library implementations (such as input/output processing and string handling) in C language programming.
**Table 1** Standard libraries supported by OpenHarmony
OpenHarmony uses musl as the libc. musl is a lightweight, fast, simple, and free open-source libc. For details, see [musl libc Reference Manual](http://musl.libc.org/manual.html).
| Library | Description |
| :-------- | :----------------------------------------------------------- |
| C standard library | C11 standard library implemented by [libc, libm, and libdl](https://en.cppreference.com/w/c/header). |
| C++ standard library ([libc++](https://libcxx.llvm.org/))| An implementation of the C++ standard library. |
| Open Sound Library for Embedded Systems ([OpenSL ES](https://www.khronos.org/registry/OpenSL-ES/))| An embedded, cross-platform audio processing library.|
| [zlib](https://zlib.net/) | A general data compression library implemented in C/C++.|
| [EGL](https://www.khronos.org/egl/) | A standard software interface between rendering APIs and the underlying native window system.|
| Open Graphics Library for Embedded Systems ([OpenGL ES](https://www.khronos.org/opengles/))| A cross-platform software interface for rendering 3D graphics on embedded and mobile systems.|
For details about the differences between musl and glibc, see [Functional differences from glibc](https://wiki.musl-libc.org/functional-differences-from-glibc.html).
## C Standard Library
## libc Components
The C standard library is a C11 standard library implemented by:
C11 is implemented by [libc, libm, and libdl](https://en.cppreference.com/w/c/header).
- libc: provides thread-related functions and a majority of standard functions.
libc: provides thread-related interfaces and a majority of standard interfaces.
libm: provides mathematical library interfaces. Currently, OpenHarmony provides a link to libm, and the interfaces are defined in libc.
- libm: provides basic mathematical functions.
libdl: provides dynamic linker interfaces such as dlopen. Currently, OpenHarmony provides a link to libdl, and the interfaces are defined in libc.
- libdl: provides functions related to dynamic linking, such as **dlopen**.
**Version**
## musl Version
1.2.0
**Capabilities**
C standard library includes a set of header files in accordance with standard C and provides common functions, such as the functions related to input/output (I/O) and string control.
**musl**
From OpenHarmony 4.0, musl 1.2.3 is supported.
## Supported Capabilities
OpenHarmony provides header files and library interfaces that are compatible (not fully compatible) with C99, C11, and POSIX, and supports Armv7-A, Arm64, and x86_64 architectures.
To better adapt to the basic features of OpenHarmony devices, such as high performance, low memory, high security, lightweight, and multi-form support, OpenHarmony has optimized the musl library and removed the interfaces that are not applicable to embedded devices.
### New Capabilities
1. The dynamic loader supports isolation by namespace. The dynamic libraries that can be loaded by **dlopen()** are restricted by the system namespace. For example, the system dynamic libraries cannot be opened.
2. **dlclose()** can be used to unload a dynamic library. This capability is not supported by musl.
3. The symbol-versioning is supported.
4. **dlopen()** can directly load uncompressed files in a .zip package.
### Debugging Capabilities
The libc provides dynamic settings of the basic log functions (disabled by default) for developers to view internal exceptions of the libc. You can set the **param** to enable or disable the log functions, without recompiling the libc. However, you are advised not to use the log functions in official release versions because they affect the running performance.
#### 1. musl.log
Set **musl.log.enable** to **true** to enable the **musl.log** function. To print other logs, you need to enable this function first.
```
setparam musl.log.enable true
```
#### 2. Loader log function
The loader starts applications and invokes dlopen() and dlclose() in libc. To view exceptions in the dynamic loading process, enable the loader log function.
* Enable the loader log of all applications (exercise caution when using this function).
```
param set musl.log.ld.app true
```
* Enable the loader log of the specified application. {app_name} specifies the target application.
```
param set musl.log.ld.all false
param set musl.log.ld.app.{app_name} true
```
* Enable the loader log of all applications except the specified application.
```
param set musl.log.ld.all true
param set musl.log.ld.app.{app_name} false
```
## Interfaces Not Supported by musl
[Native API Symbols Not Exported](musl-peculiar-symbol.md)
[Native API Symbols That May Fail to Be Invoked Due to Permission Control](musl-permission-control-symbol.md)
## libc++
[libc++](https://libcxx.llvm.org/) is an implementation of the C++ standard library.
**Version**
10.0.1
**Capabilities**
The C++11 and C++14 standards are supported, and the C++17 and C++20 standards are on the way.
## OpenSL ES
[OpenGL ES](https://www.khronos.org/opengles/) is an embedded, cross-platform audio processing library.
**Capabilities**
[OpenSL ES Interfaces Supported by Native APIs](../third_party_opensles/opensles.md)
## zlib
[zlib](https://zlib.net/) is a general data compression library implemented in C/C++.
## EGL
EGL is an interface between Khronos rendering APIs (such as OpenGL ES and OpenVG) and the underlying native window system. OpenHarmony supports EGL.
**Symbols Exported from the Standard Library**
[EGL Symbols Exported from Native APIs](../third_party_opengl/egl-symbol.md)
## OpenGL ES
OpenGL is a cross-platform software interface for 3D graphics processing. [OpenGL ES](https://www.khronos.org/opengles/) is a OpenGL specification for embedded devices. OpenHarmony supports OpenGL ES 3.0.
**Capabilities**
OpenGL ES 3.0
**Symbols Exported from the Standard Library**
[OpenGL ES 3.0 Symbols Exported from Native APIs](../third_party_opengl/openglesv3-symbol.md)
# EGL
EGL is an interface between Khronos rendering APIs (such as OpenGL ES and OpenVG) and the underlying native window system. OpenHarmony supports EGL.
## **Symbols Exported from the NAPI Library**
[EGL Symbols Exported fom Native APIs](egl-symbol.md)
# OpenGL ES
OpenGL is a cross-platform software interface for 3D graphics processing. [OpenGL ES](https://www.khronos.org/opengles/) is a OpenGL specification for embedded devices. OpenHarmony supports OpenGL ES 3.0.
## Supported Capabilities
OpenGL ES 3.0
## **Symbols Exported from the NAPI Library**
[OpenGL ES 3.0 Symbols Exported from Native APIs](openglesv3-symbol.md)
# zlib
[zlib](https://zlib.net/) is a general data compression library implemented in C/C++.
\ No newline at end of file
# Smartperf-Host
## Overview
Smartperf-Host is an intuitive performance and power optimization tool that offers in-depth data mining and fine-grained data visualization. In this tool, you can gain visibility into a multitude of metrics in terms of CPU scheduling, frequency, process and thread time slices, heap memory, frame rate, and more, in swimlanes. Better yet, you can analyze the collected data intuitively on the GUI.
## Architecture
![System Architecture](figures/smartperf_frame.png)
Smartperf-Host consists of the device end and PC end, which exchange data with each other based on gRPC – a high-performance remote procedure call (RPC) framework.
The device end consists of modules such as Native Hook (application-embedded component), hiprofiler_command (command-line tool), hiprofilerd (performance profiler service), a set of performance profiler plug-ins, and some system tools and kernels. The device end provides the plug-in extension capability by exposing plug-in interfaces for external systems. By drawing on this capability, you can integrate custom plug-ins into the framework. For details about the preset plug-ins, see [Performance Profiler Component](https://gitee.com/openharmony/developtools_profiler).
The PC end is accessible from the Smartperf-Host website. It consists of modules such as Trace Streamer, SQLite, HDC device management, data import, UI drawing, and data analysis.
## Project Directory
```
/smartperf_host
├── host # Smartperf-Host related code
│ ├── doc # Smartperf-Host documentation
│ ├── ide # Smartperf-Host IDE module
│ │ └── src # Profiler module
│ │ │ ├── base-ui # Basic components
│ │ │ └── Trace # Service logic
│ ├── trace_streamer # Trace Streamer module
│ │ ├── base # Basic functionality
│ │ ├── cfg # Configuration
│ │ ├── filter # Filter
│ │ ├── include # Header files
│ │ ├── multi_platform # Platform adaptation
│ │ ├── parser # Parsing service logic
│ │ │ ├── bytrace_parser # byTrace service logic
│ │ │ └── htrace_parser # hTrace service logic
│ │ ├── table # Table structure
│ │ ├── trace_data # Trace structure
│ │ ├── trace_streamer # Trace Streamer structure
│ │ │ └── kits # JS APIs and native APIs
```
## Function Description
- Loading Trace Files on Web Pages
Load local trace files (such as htrace and ftrace) and display the data in swimlanes. For details, see [Loading Trace Files on Web Pages](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_systemtrace.md).
- Capturing Traces Online
Use Smartperf_Host to capture traces online, with the content, duration, and save path all customizable. For details, see [Capturing Traces on Web Pages](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_web_record.md).
- Capturing Traces on a Device
Capture traces on the target device, with the content, duration, and save path all customizable. For details, see [Capturing Traces from a Device](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_device_record.md).
- Using Ability Monitor
With Ability Monitor in Smartperf_Host, you can learn the CPU, memory, disk I/O, and network usage of your application. For details, see [Ability Monitor Usage](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_ability_monitor.md).
- Using Native Memory
With Native Memory in Smartperf_Host, you can track the allocation and release of your application's native memory (specific to C and C++). For details, see [Native Memory Usage](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_native_memory.md).
- Using Hiperf
With Hiperf in Smartperf_Host, you can view the CPU usage of your application and the call stack. For details, see [Hiperf Usage](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_hiperf.md).
- Using HiSystemEvent
With HiSystemEvent in Smartperf_Host, you can inspect the power consumption of each category (CPU, network, and location, and more) of your application, resource application and usage records (WorkScheduler, Runninglock, Alarm, and Location Request), power consumption exceptions, and system states associated with the power consumption (battery level and screen status). For details, see [HiSystemEvent Usage](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_hisystemevent.md).
- Collecting FileSystem Records
In Smartperf_Host, you can find out the system invoking information and read/write invoking times of all file systems. For details, see [Usage of FileSystem Recording](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_filesystem.md).
- Collecting Page Fault Records
In Smartperf_Host, you can collect page fault records, covering various aspects such as start time, duration, triggering process, triggering thread, event type, memory address, and memory size of page memory events. For details, see [Usage of Page Fault Recording](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_page_fault.md).
- Collecting BIO Records
In Smartperf_Host, you can collect I/O operation records, which provide the following information: start time, total latency, process, average latency of every 4 KB data, thread, operation (write data, page swap-in, and metadata), access traffic, path, block number, priority, and backtrace call stack. For details, see [Usage of BIO Latency Recording](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_bio.md).
- Collecting Smaps Records
In Smartperf_Host, you can collect the smaps data (type, Pss, Rss, Vss, and more) on a process-by-process basis. The data source is **/proc/$pid/smaps**. For details, see [Smaps Usage](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_smaps.md).
- Using SQL Analysis and Metrics
You can use Query (SQL) and Metrics features to quickly locate the trace data. For details, see [SQL Analysis and Metrics Usage](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_sql_metrics.md).
## Compilation Guidance
Project compilation includes Trace Streamer compilation and Smartperf-Host compilation and deployment.
### Prerequisites
- C++ version: 11 or later
- Node.js version: 16.15.1 or later
- npm version: 8.13.2 or later
- TypeScript version: 4.2.3 or later
- Go version: 1.13.8 or later
### Compiling Trace Streamer
To set up the Smartperf_Host website, you need to compile the WASM version of Trace Streamer for the web page to parse the original trace data. For details about the compilation process, see [Compiling Trace Streamer](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/trace_streamer/doc/compile_trace_streamer.md).
### Compiling and Deploying Smartperf-Host
For details about the compilation and deployment process, see [SmartPerf Compilation and Deployment Guide](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/README_zh.md)). After successful deployment, you can start to use Smartperf_Host by visiting **https://[*IP address of the device where SmartPerf is deployed*]:9000/application/**.
......@@ -54,6 +54,7 @@
| formVisibleNotify | 标识是否允许卡片使用卡片可见性通知。 | 字符串 | 可缺省,缺省值为空。 |
| metadata | 表示卡片的自定义信息,包含customizeData数组标签。 | 对象 | 可缺省,缺省值为空。 |
| dataProxyEnabled | 表示卡片是否支持[卡片代理刷新](./arkts-ui-widget-update-by-proxy.md),取值范围:<br/>-&nbsp;true:表示支持代理刷新。<br/>-&nbsp;false:表示不支持代理刷新。<br/>设置为true时,[定时刷新和下次刷新不生效,但不影响定点刷新](./arkts-ui-widget-update-by-time.md) | 布尔类型 | 可缺省,缺省值为false。 |
| isDynamic | 表示此卡片是否为动态卡片(仅针对ArkTS卡片生效)。<br/>-&nbsp;true:为动态卡片。<br/>-&nbsp;false:为静态卡片,当卡片添加成功后,将以静态图显示。 | 布尔类型 | 可缺省,缺省值为true。 |
配置示例如下:
......
......@@ -28,7 +28,7 @@
1. 数据提供方以`key + subscriberId`作为数据的标识,将数据存储到数据库。
2. 数据管理服务感知到数据库变化,将新的数据发布给当前注册的所有订阅实例。
3. 卡片管理服务从订阅实例中解析出数据,发送给卡片渲染服务。
4. 卡片渲染服务运行卡片页面代码widgets.abc,widgets.abc按新数据进行渲染,并将渲染后的数据发送至卡片使用方对应的[卡片组件](https://gitee.com/openharmony/docs/blob/fd489446c497c09d86ffa3beafd73dad90f1adb6/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-formcomponent.md)
4. 卡片渲染服务运行卡片页面代码widgets.abc,widgets.abc按新数据进行渲染,并将渲染后的数据发送至卡片使用方对应的[卡片组件](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-formcomponent.md)
数据提供方提供的共享数据有两种类型:
......@@ -177,7 +177,7 @@
}
```
- 在卡片页面代码widgets.abc中,通过LocalStorage变量获取订阅到的数据,LocalStorage绑定了一个字符串,以key:value的键值对格式来刷新卡片订阅数据,其中key必须与卡片提供方订阅的key保持一致。示例中,通过'list'获取订阅的数据,并把第一个元素的值显示在Text组件上。
- 在卡片页面代码文件(一般为工程中卡片目录下pages目录中的.ets文件)中,通过LocalStorage变量获取订阅到的数据,LocalStorage绑定了一个字符串,以key:value的键值对格式来刷新卡片订阅数据,其中key必须与卡片提供方订阅的key保持一致。示例中,通过'list'获取订阅的数据,并把第一个元素的值显示在Text组件上。
```ts
let storage = new LocalStorage();
@Entry(storage)
......
......@@ -20,7 +20,8 @@
},
"colorMode": "auto",
"isDefault": true,
"updateEnabled": true,"scheduledUpdateTime": "07:00",
"updateEnabled": true,
"scheduledUpdateTime": "07:00",
"updateDuration": 0,
"defaultDimension": "2*2",
"supportDimensions": ["2*2"]
......@@ -102,10 +103,15 @@
let isTempCard: boolean = want.parameters[formInfo.FormParam.TEMPORARY_KEY];
if (isTempCard === false) { // 如果为常态卡片,直接进行信息持久化
console.info('Not temp card, init db for:' + formId);
let storeDB = dataPreferences.getPreferences(this.context, 'mystore')
storeDB.put('A' + formId, 'false');
storeDB.put('B' + formId, 'false');
storeDB.flush();
let promise = dataPreferences.getPreferences(this.context, 'myStore');
promise.then((storeDB) => {
console.info("Succeeded to get preferences.");
storeDB.putSync('A' + formId, 'false');
storeDB.putSync('B' + formId, 'false');
storeDB.flush();
}).catch((err) => {
console.info(`Failed to get preferences. ${JSON.stringify(err)}`);
})
}
let formData = {};
return formBindingData.createFormBindingData(formData);
......@@ -113,54 +119,71 @@
onRemoveForm(formId) {
console.info('onRemoveForm, formId:' + formId);
let storeDB = dataPreferences.getPreferences(this.context, 'mystore')
storeDB.delete('A' + formId);
storeDB.delete('B' + formId);
let promise = dataPreferences.getPreferences(this.context, 'myStore');
promise.then((storeDB) => {
console.info("Succeeded to get preferences.");
storeDB.deleteSync('A' + formId);
storeDB.deleteSync('B' + formId);
}).catch((err) => {
console.info(`Failed to get preferences. ${JSON.stringify(err)}`);
})
}
// 如果在添加时为临时卡片,则建议转为常态卡片时进行信息持久化
onCastToNormalForm(formId) {
console.info('onCastToNormalForm, formId:' + formId);
let storeDB = dataPreferences.getPreferences(this.context, 'myStore')
storeDB.put('A' + formId, 'false');
storeDB.put('B' + formId, 'false');
storeDB.flush();
let promise = dataPreferences.getPreferences(this.context, 'myStore');
promise.then((storeDB) => {
console.info("Succeeded to get preferences.");
storeDB.putSync('A' + formId, 'false');
storeDB.putSync('B' + formId, 'false');
storeDB.flush();
}).catch((err) => {
console.info(`Failed to get preferences. ${JSON.stringify(err)}`);
})
}
onUpdateForm(formId) {
let storeDB = dataPreferences.getPreferences(this.context, 'myStore')
let stateA = storeDB.get('A' + formId, 'false').toString()
let stateB = storeDB.get('B' + formId, 'false').toString()
// A状态选中则更新textA
if (stateA === 'true') {
let formInfo = formBindingData.createFormBindingData({
'textA': 'AAA'
})
formProvider.updateForm(formId, formInfo)
}
// B状态选中则更新textB
if (stateB === 'true') {
let formInfo = formBindingData.createFormBindingData({
'textB': 'BBB'
})
formProvider.updateForm(formId, formInfo)
}
let promise = dataPreferences.getPreferences(this.context, 'myStore');
promise.then((storeDB) => {
console.info("Succeeded to get preferences.");
let stateA = storeDB.getSync('A' + formId, 'false').toString();
let stateB = storeDB.getSync('B' + formId, 'false').toString();
// A状态选中则更新textA
if (stateA === 'true') {
let formInfo = formBindingData.createFormBindingData({'textA': 'AAA'});
formProvider.updateForm(formId, formInfo);
}
// B状态选中则更新textB
if (stateB === 'true') {
let formInfo = formBindingData.createFormBindingData({'textB': 'BBB'});
formProvider.updateForm(formId, formInfo);
}
console.info(`Update form success stateA:${stateA} stateB:${stateB}.`);
}).catch((err) => {
console.info(`Failed to get preferences. ${JSON.stringify(err)}`);
})
}
onFormEvent(formId, message) {
// 存放卡片状态
console.info('onFormEvent formId:' + formId + 'msg:' + message);
let storeDB = dataPreferences.getPreferences(this.context, 'myStore')
let msg = JSON.parse(message)
if (msg.selectA != undefined) {
console.info('onFormEvent selectA info:' + msg.selectA);
storeDB.put('A' + formId, msg.selectA);
}
if (msg.selectB != undefined) {
console.info('onFormEvent selectB info:' + msg.selectB);
storeDB.put('B' + formId, msg.selectB);
}
storeDB.flush();
let promise = dataPreferences.getPreferences(this.context, 'myStore');
promise.then((storeDB) => {
console.info("Succeeded to get preferences.");
let msg = JSON.parse(message);
if (msg.selectA != undefined) {
console.info('onFormEvent selectA info:' + msg.selectA);
storeDB.putSync('A' + formId, msg.selectA);
}
if (msg.selectB != undefined) {
console.info('onFormEvent selectB info:' + msg.selectB);
storeDB.putSync('B' + formId, msg.selectB);
}
storeDB.flush();
}).catch((err) => {
console.info(`Failed to get preferences. ${JSON.stringify(err)}`);
})
}
};
```
......
......@@ -16,11 +16,11 @@
- **跨端迁移**
在用户使用设备的过程中,当使用情境发生变化时(例如从室内走到户外或者周围有更合适的设备等),之前使用的设备可能已经不适合继续当前的任务,此时,用户可以选择新的设备来继续当前的任务,原设备退出任务,这就是跨端迁移场景。常见的跨端迁移场景实例:在平板上播放的视频,迁移到智慧屏继续播放,从而获得更佳的观看体验;平板上的视频应用退出。在应用开发层面,跨端迁移指在A端运行的UIAbility迁移到B端上,完成迁移后, B端UIAbility继续任务,而A端UIAbility退出。
在用户使用设备的过程中,当使用情境发生变化时(例如从室内走到户外或者周围有更合适的设备等),之前使用的设备可能已经不适合继续当前的任务,此时,用户可以选择新的设备来继续当前的任务,原设备可按需决定是否退出任务,这就是跨端迁移场景。常见的跨端迁移场景实例:在平板上播放的视频,迁移到智慧屏继续播放,从而获得更佳的观看体验;平板上的视频应用退出。在应用开发层面,跨端迁移指在A端运行的UIAbility迁移到B端上,完成迁移后, B端UIAbility继续任务,而A端UIAbility可按需决定是否退出。
- **多端协同**
用户拥有的多个设备,可以作为一个整体,为用户提供比单设备更加高效、沉浸的体验,这就是多端协同场景。常见的多端协同场景实例:平板侧应用A做答题板,智慧屏侧应用B做直播,为用户提供更优的上网课体验。在应用开发层面,多端协同指多端上的不同UIAbility/ServiceExtensionAbility同时运行、或者交替运行实现完整的业务;或者多端上的相同UIAbility/ServiceExtensionAbility同时运行实现完整的业务。
用户拥有的多个设备,可以作为一个整体,为用户提供比单设备更加高效、沉浸的体验,这就是多端协同场景。常见的多端协同场景实例:场景一:两台设备A和B打开备忘录同一篇笔记进行双端协同编辑,在设备A上可以使用本地图库中的图片资源插入编辑,设备B上进行文字内容编辑。场景二:设备A上正在和客户进行聊天,客户需要的资料在设备B上,可以通过聊天软件打开设备B上的文档应用选择到想要的资料回传到设备A上,然后通过聊天软件发送给客户。在应用开发层面,多端协同指多端上的不同UIAbility/ServiceExtensionAbility同时运行、或者交替运行实现完整的业务;或者多端上的相同UIAbility/ServiceExtensionAbility同时运行实现完整的业务。
## 流转架构
......
......@@ -96,8 +96,8 @@
| 属性名称 | 备注说明 | 必填 |
| ----------------------- | ---------------------------------------- | ---- |
| uri | 数据使用的URI,是跨应用数据访问的唯一标识。 | 是 |
| requiredReadPermission | 访问数据时需要的权限,不配置默认不允许其他APP访问数据。 | 否 |
| requiredWritePermission | 修改数据时需要的权限,不配置默认不允许其他APP修改数据。 | 否 |
| requiredReadPermission | 标识从该数据代理读取数据时所需要的权限,不配置默认不允许其他APP访问数据。支持权限可参考[权限列表](../security/permission-list.md)。 | 否 |
| requiredWritePermission | 标识从该数据代理修改数据时所需要的权限,不配置默认不允许其他APP修改数据。支持权限可参考[权限列表](../security/permission-list.md) | 否 |
| metadata | 数据源的信息,包含name和resource字段。<br /> name类型固定为"dataProperties",是配置的唯一标识。 <br /> resource类型固定为"$profile:{fileName}",表示配置文件的名称为{fileName}.json。 | 是 |
**module.json5配置样例:**
......@@ -107,7 +107,7 @@
{
"uri": "datashareproxy://com.acts.ohos.data.datasharetest/test",
"requiredReadPermission": "ohos.permission.GET_BUNDLE_INFO",
"requiredWritePermission": "ohos.permission.GET_BUNDLE_INFO",
"requiredWritePermission": "ohos.permission.KEEP_BACKGROUND_RUNNING",
"metadata": {
"name": "dataProperties",
"resource": "$profile:my_config"
......@@ -244,8 +244,8 @@
| 属性名称 | 备注说明 | 必填 |
| ----------------------- | ----------------------------- | ---- |
| uri | 数据使用的URI,是跨应用数据访问的唯一标识。 | 是 |
| requiredReadPermission | 访问数据时需要的权限,不配置默认不允许其他APP访问数据。 | 否 |
| requiredWritePermission | 修改数据时需要的权限,不配置默认不允许其他APP修改数据。 | 否 |
| requiredReadPermission | 标识从该数据代理读取数据时所需要的权限,不配置默认不允许其他APP访问数据。支持权限可参考[权限列表](../security/permission-list.md)。 | 否 |
| requiredWritePermission | 标识从该数据代理修改数据时所需要的权限,不配置默认不允许其他APP访问数据。支持权限可参考[权限列表](../security/permission-list.md)。 | 否 |
**module.json5配置样例:**
......@@ -254,7 +254,7 @@
{
"uri": "datashareproxy://com.acts.ohos.data.datasharetest/weather",
"requiredReadPermission": "ohos.permission.GET_BUNDLE_INFO",
"requiredWritePermission": "ohos.permission.GET_BUNDLE_INFO"
"requiredWritePermission": "ohos.permission.KEEP_BACKGROUND_RUNNING"
}
]
```
......
......@@ -3,9 +3,13 @@
- [Native API在应用工程中的使用指导](napi-guidelines.md)
- [Drawing开发指导](drawing-guidelines.md)
- [Rawfile开发指导](rawfile-guidelines.md)
- [NativeBuffer开发指导](native-buffer-guidelines.md)
- [NativeImage开发指导](native-image-guidelines.md)
- [NativeVsync开发指导](native-vsync-guidelines.md)
- [NativeWindow开发指导](native-window-guidelines.md)
- [使用MindSpore Lite引擎进行模型推理](mindspore-lite-guidelines.md)
- [使用MindSpore Lite进行离线模型的转换及推理](mindspore-lite-offline-model-guidelines.md)
- [Neural Network Runtime对接AI推理框架开发指导](neural-network-runtime-guidelines.md)
- [Purgeable memory开发指导](purgeable-memory-guidelines.md)
- [XComponent开发指导](xcomponent-guidelines.md)
\ No newline at end of file
- [XComponent开发指导](xcomponent-guidelines.md)
- [USB DDK开发指导](usb-ddk-guidelines.md)
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册