提交 7f821a59 编写于 作者: D donglin

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

Change-Id: I584427ebf6db45fe914fa0e3623bec025a1b5c88
......@@ -28,26 +28,29 @@ Obtain a **Preferences** instance for data operations. A **Preferences** instanc
| --------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| ohos.data.preferences | getPreferences(context: Context, name: string): Promise\<Preferences> | Obtains a **Preferences** instance.|
### Accessing Data
### Processing Data
Call the **put()** method to add or modify data in a **Preferences** instance.
Call **put()** to add or modify data in a **Preferences** instance.
Call the **get()** method to read data from a **Preferences** instance.
Call **get()** to read data from a **Preferences** instance.
Call **getAll()** to obtain an **Object** instance that contains all KV pairs in a **Preferences** instance.
**Table 2** APIs for accessing **Preferences** data
Call **delete()** to delete the KV pair of the specified key from the **Preferences** instance.
**Table 2** APIs for processing **Preferences** data
| Class | API | Description |
| ----------- | ---------------------------------------------------------- | ------------------------------------------------------------ |
| Preferences | put(key: string, value: ValueType): Promise\<void> | Writes data to the **Preferences** instance. The value to write can be a number, a string, a Boolean value, or an array of numbers, strings, or Boolean values.|
| Preferences | get(key: string, defValue: ValueType): Promise\<ValueType> | Obtains data from the **Preferences** instance. The value to read can be a number, a string, a Boolean value, or an array of numbers, strings, or Boolean values.|
| Preferences | getAll(): Promise<Object> | Obtains an **Object** instance that contains all KV pairs in the **Preferences** instance. |
| Preferences | getAll(): Promise\<Object> | Obtains an **Object** instance that contains all KV pairs in the **Preferences** instance. |
| Preferences | delete(key: string): Promise\<void> | Deletes the KV pair of the specified key from the **Preferences** instance. |
### Storing Data Persistently
Call the **flush()** method to write the cached data back to its text file for persistent storage.
Call **flush()** to write the cached data back to its text file for persistent storage.
**Table 4** API for data persistence
......@@ -68,7 +71,7 @@ You can subscribe to data changes. When the value of the subscribed key is chang
### Deleting Data
Use the following APIs to delete a **Preferences** instance or data file.
You can use the following APIs to delete a **Preferences** instance or data file.
**Table 6** APIs for deleting **Preferences**
......@@ -130,7 +133,7 @@ Use the following APIs to delete a **Preferences** instance or data file.
3. Write data.
Use the **preferences.put()** method to write data to the **Preferences** instance.
Use **preferences.put()** to write data to the **Preferences** instance.
```js
let putPromise = preferences.put('startup', 'auto');
......@@ -143,7 +146,7 @@ Use the following APIs to delete a **Preferences** instance or data file.
4. Read data.
Use the **preferences.get()** method to read data.
Use **preferences.get()** to read data.
```js
let getPromise = preferences.get('startup', 'default');
......@@ -156,7 +159,7 @@ Use the following APIs to delete a **Preferences** instance or data file.
5. Store data persistently.
Use the **flush()** method to flush data from the **Preferences** instance to its file.
Use **flush()** to flush data from the **Preferences** instance to its file.
```js
preferences.flush();
......@@ -177,7 +180,7 @@ Use the following APIs to delete a **Preferences** instance or data file.
console.info("Failed to put the value of 'startup'. Cause: " + err);
return;
}
console.info("Put the value of 'startup' successfully.");
console.info("Put the value of 'startup' successfully.");
preferences.flush(function (err) {
if (err) {
console.info("Failed to flush data. Cause: " + err);
......@@ -190,7 +193,7 @@ Use the following APIs to delete a **Preferences** instance or data file.
7. Delete the specified file.
Use the **deletePreferences** method to delete the **Preferences** instance and its persistent file and backup and corrupted files. After the specified files are deleted, the application cannot use that instance to perform any data operation. Otherwise, data inconsistency will be caused. The deleted data and files cannot be restored.
Use **deletePreferences()** to delete the **Preferences** instance and its persistent file and backup and corrupted files. After the specified files are deleted, the application cannot use that instance to perform any data operation. Otherwise, data inconsistency will be caused. The deleted data and files cannot be restored.
```js
let proDelete = data_preferences.deletePreferences(context, 'mystore');
......
......@@ -7,7 +7,7 @@ For details about the system parameter design principles and definitions, see
> **NOTE**
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs provided by this module are system APIs.
> - Third-party applications cannot use the APIs provided by this module, because system parameters each require specific discretionary access control (DAC) and MAC permissions.
> - Third-party applications cannot use the APIs provided by this module, because system parameters each require specific discretionary access control (DAC) and mandatory access control (MAC) permissions.
## Modules to Import
......
......@@ -16,31 +16,31 @@ Refresh\(value: \{ refreshing: boolean, offset?: number | string , friction?: n
**Parameters**
| Name | Value Type | Mandatory | Description |
| ---------- | ---------------- | --------- | ---------------------------------------- |
| refreshing | boolean | Yes | Whether the current component is being refreshed.<br>This parameter can be used with $$ for two-way binding of variables. |
| offset | string \| number | No | Distance to the top of the parent component from the **<Refresh\>** component that comes to rest after a successful pull-down gesture.<br>Default value: **16**, in vp |
| friction | number \| string | No | Coefficient of friction, which indicates the **<Refresh\>** component's sensitivity to the pull-down gesture. The value ranges from 0 to 100.<br>Default value: **62**<br>- **0** indicates that the **\<Refresh>** component is not sensitive to the pull-down gesture.<br>- **100** indicates that the **\<Refresh>** component is highly sensitive to the pull-down gesture.<br>- A larger value indicates a more sensitive response of the **\<Refresh>** component to the pull-down gesture. |
| Name| Value Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| refreshing | boolean | Yes| Whether the current component is being refreshed.<br>This parameter supports [$$](../../quick-start/arkts-restrictions-and-extensions.md#two-way-binding-of-variables) for two-way binding of variables.|
| offset | string \| number | No| Distance to the top of the parent component from the **<Refresh\>** component that comes to rest after a successful pull-down gesture.<br>Default value: **16**, in vp|
| friction | number \| string | No| Coefficient of friction, which indicates the **<Refresh\>** component's sensitivity to the pull-down gesture. The value ranges from 0 to 100.<br>Default value: **62**<br>- **0** indicates that the **\<Refresh>** component is not sensitive to the pull-down gesture.<br>- **100** indicates that the **\<Refresh>** component is highly sensitive to the pull-down gesture.<br>- A larger value indicates a more sensitive response of the **\<Refresh>** component to the pull-down gesture.|
## Events
| Name | Description |
| ---------------------------------------- | ---------------------------------------- |
| onStateChange(callback: (state: RefreshStatus) => void) | Triggered when the refresh status changes.<br>- **state**: refresh status. |
| onRefreshing(callback: () => void) | Triggered when the component enters the refresh state. |
| Name| Description|
| -------- | -------- |
| onStateChange(callback: (state: [RefreshStatus](#refreshstatus)) => void)| Triggered when the refresh status changes.<br>- **state**: refresh status.|
| onRefreshing(callback: () => void)| Triggered when the component enters the refresh state.|
## RefreshStatus enums
| Name | Description |
| -------- | ---------------------------------------- |
| Inactive | The component is not pulled down. This is the default value. |
| Drag | The component is being pulled down, but the pulled distance is shorter than the minimum length required to trigger the refresh. |
| OverDrag | The component is being pulled down, and the pulled distance exceeds the minimum length required to trigger the refresh. |
| Refresh | The pull-down ends, and the component rebounds to the minimum length required to trigger the refresh and enters the refresh state. |
| Done | The refresh is complete, and the component returns to the initial state (top). |
| Name| Description|
| -------- | -------- |
| Inactive | The component is not pulled down. This is the default value.|
| Drag | The component is being pulled down, but the pulled distance is shorter than the minimum length required to trigger the refresh.|
| OverDrag | The component is being pulled down, and the pulled distance exceeds the minimum length required to trigger the refresh.|
| Refresh | The pull-down ends, and the component rebounds to the minimum length required to trigger the refresh and enters the refresh state.|
| Done | The refresh is complete, and the component returns to the initial state (top).|
## Example
......
......@@ -16,30 +16,15 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () =&gt; void, aut
**Parameters**
| Name | Type | Mandatory | Description |
| ---------------------- | ---------------------------------------- | --------- | ---------------------------------------- |
| builder | CustomDialog | Yes | Constructor of the custom dialog box content. |
| cancel | () =&gt; void | No | Callback invoked when the dialog box is closed after the overlay exits. |
| autoCancel | boolean | No | Whether to allow users to click the overlay to exit.<br>Default value: **true** |
| alignment | [DialogAlignment](#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.<br>Default value: **DialogAlignment.Default** |
| offset | {<br>dx: Length \| [Resource](ts-types.md#resource),<br>dy: Length \| [Resource](ts-types.md#resource)<br>} | No | Offset of the dialog box relative to the alignment position. |
| customStyle | boolean | No | Whether to use a custom style for the dialog box.<br>Default value: **false** |
| gridCount<sup>8+</sup> | number | No | Number of grid columns occupied by the dialog box. |
## DialogAlignment
| Name | Description |
| ------------------------ | -------------------------- |
| Top | Vertical top alignment. |
| Center | Vertical center alignment. |
| Bottom | Vertical bottom alignment. |
| Default | Default alignment. |
| TopStart<sup>8+</sup> | Top left alignment. |
| TopEnd<sup>8+</sup> | Top right alignment. |
| CenterStart<sup>8+</sup> | Center left alignment. |
| CenterEnd<sup>8+</sup> | Center right alignment. |
| BottomStart<sup>8+</sup> | Bottom left alignment. |
| BottomEnd<sup>8+</sup> | Bottom right alignment. |
| Name | Type | Mandatory | Description |
| ---------------------- | ---------------------------------------- | ------------------------- | ---------------------- |
| builder | [CustomDialog](../../quick-start/arkts-dynamic-ui-elememt-building.md#customdialog) | Yes | Constructor of the custom dialog box content. |
| cancel | () =&gt; void | No | Callback invoked when the dialog box is closed after the overlay exits. |
| autoCancel | boolean | No | Whether to allow users to click the overlay to exit.<br>Default value: **true** |
| alignment | [DialogAlignment](ts-methods-alert-dialog-box.md#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.<br>Default value: **DialogAlignment.Default** |
| offset | [Offset](ts-types.md#offset) | No | Offset of the dialog box relative to the alignment position.|
| customStyle | boolean | No | Whether to use a custom style for the dialog box.<br>Default value: **false** |
| gridCount<sup>8+</sup> | number | No | Number of [grid columns](../../ui/ui-ts-layout-grid-container-new.md) occupied by the dialog box.<br>The default value is 4, and the maximum value is the maximum number of columns supported by the system. If this parameter is set to an invalid value, the default value is used.|
## CustomDialogController
......@@ -107,17 +92,28 @@ struct CustomDialogUser {
@State textValue: string = ''
@State inputValue: string = 'click me'
dialogController: CustomDialogController = new CustomDialogController({
builder: CustomDialogExample({ cancel: this.onCancel, confirm: this.onAccept, textValue: $textValue, inputValue: $inputValue }),
builder: CustomDialogExample({
cancel: this.onCancel,
confirm: this.onAccept,
textValue: $textValue,
inputValue: $inputValue
}),
cancel: this.existApp,
autoCancel: true
autoCancel: true,
alignment: DialogAlignment.Default,
offset: { dx: 0, dy: -20 },
gridCount: 4,
customStyle: false
})
onCancel() {
console.info('Callback when the first button is clicked')
}
onAccept() {
console.info('Callback when the second button is clicked')
}
existApp() {
console.info('Click the callback in the blank area')
}
......
......@@ -2,13 +2,13 @@
## Resource
The **Resource** type is used to reference resources for setting component attribute values.
The **Resource** type is used to reference resources for setting component attributes.
If a **Resource** object is created using `$r` or `$rawfile`, modifying attribute values of the object is prohibited.
You can use `$r` or `$rawfile` to create a **Resource** object, but its attribute values cannot be changed.
- `$r('belonging.type.name')`
**belonging**: system or application resource. The value can be **'sys'** or **'app'**.
**belonging**: group to which the resource belongs, which can be **'sys'** or **'app'**.
**type**: resource type, which can be **'color'**, **'float'**, **'string'**, or **'media'**.
......@@ -16,7 +16,7 @@ If a **Resource** object is created using `$r` or `$rawfile`, modifying attribut
- `$rawfile('filename')`
**filename**: name of the file in **resources/rawfile** of the project.
**filename**: name of the file in the **resources/rawfile** directory of the project.
## Length
......@@ -24,7 +24,7 @@ The **Length** type is used to represent a size unit.
| Type | Description |
| -------- | -------------------------------------- |
| string | String type. Explicitly specify the length unit, for example, **'10px'**, or the length in percentage, for example, **'100%'**.|
| string | String type. Specify the length unit explicitly, for example, **'10px'**, or provide the length in percentage, for example, **'100%'**.|
| number | Number type. The default unit is vp. |
| [Resource](#resource) | Size referenced from system or application resources. |
......@@ -39,25 +39,25 @@ The **ResourceStr** type is used to represent the types that can be used by inpu
## Padding
The **Padding** type is used to describe the padding areas in different directions of a component.
The **Padding** type is used to describe the paddings in different directions of a component.
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------- |
| top | [Length](#length) | No | Height of the padding area on the top of the component. |
| right | [Length](#length) | No | Width of the padding area on the right of the component.|
| bottom | [Length](#length) | No | Height of the padding area at the bottom of the component. |
| left | [Length](#length) | No | Width of the padding area on the left of the component.|
| top | [Length](#length) | No | Height of the padding on the top of the component. |
| right | [Length](#length) | No | Width of the padding on the right of the component.|
| bottom | [Length](#length) | No | Height of the padding at the bottom of the component. |
| left | [Length](#length) | No | Width of the padding on the left of the component.|
## Margin
The **Margin** type is used to describe the margin areas in different directions of a component.
The **Margin** type is used to describe the margins in different directions of a component.
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------- |
| top | [Length](#length) | No | Height of the margin area above the component. |
| right | [Length](#length) | No | Width of the margin area on the right of the component.|
| bottom | [Length](#length) | No | Height of the margin area below the component. |
| left | [Length](#length) | No | Width of the margin area on the left of the component.|
| top | [Length](#length) | No | Height of the margin above the component. |
| right | [Length](#length) | No | Width of the margin on the right of the component.|
| bottom | [Length](#length) | No | Height of the margin below the component. |
| left | [Length](#length) | No | Width of the margin on the left of the component.|
## EdgeWidths<sup>9+</sup>
......@@ -110,8 +110,8 @@ The **Offset** type is used to describe the offset coordinates of a component in
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | -------- |
| dx | [Length](#length) | Yes | Horizontal offset.|
| dy | [Length](#length) | Yes | Vertical offset.|
| dx | [Length](#length) | Yes | X coordinate of the offset.|
| dy | [Length](#length) | Yes | Y coordinate of the offset.|
## ResourceColor
......@@ -119,14 +119,14 @@ The **ResourceColor** type is used to describe the color types of resources.
| Type | Description |
| ---------------------------------------- | ------------------------------------------------- |
| [Color](ts-appendix-enums.md#color) | Color enum. |
| number | Color in the hexadecimal notation. |
| string | Color in the RGB or RGBA notion. |
| [Color](ts-appendix-enums.md#color) | Color enums. |
| number | Color in hexadecimal notation. |
| string | Color in RGB or RGBA notation. |
| [Resource](#resource) | Color referenced from system or application resources.|
## LengthConstrain
The **LengthConstrain** type is used to limit the maximum and minimum lengths of a component.
The **LengthConstrain** type is used to describe the maximum and minimum lengths of a component.
| Name | Type | Mandatory | Description |
| --------- | ------ | ---- | ------- |
......@@ -147,15 +147,14 @@ The **Font** type is used to set the text style.
## Area<sup>8+</sup>
The **Area** type is used to describe the area information of the target element.
The **Area** type is used to describe the area information of a component.
| Name | Type | Description |
| -------------- | ---------------------- | ------------------------------ |
| width | [Length](#length) | Width of the target element. The value is of the number type when being used as the return value and the unit is vp.|
| height | [Length](#length) | Height of the target element. The value is of the number type when being used as the return value and the unit is vp.|
| position | [Position](#position8) | Position of the upper left corner of the target element relative to that of the parent element. |
| globalPosition | [Position](#position8) | Position of the upper left corner of the target element relative to that of the page. |
| width | [Length](#length) | Width of the component. The value is of the number type in vp when used as the return value.|
| height | [Length](#length) | Height of the component. The value is of the number type in vp when used as the return value.|
| position | [Position](#position8) | Position of the upper left corner of the component relative to that of its parent container. |
| globalPosition | [Position](#position8) | Position of the upper left corner of the component relative to that of the page where the component resides. |
## Position<sup>8+</sup>
......@@ -163,19 +162,19 @@ The **Position** type is used to represent coordinates of a point.
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | --------------------------- |
| x | [Length](#length) | No | X coordinate. The value is of the number type when being used as the return value and the unit is vp.|
| y | [Length](#length) | No | Y coordinate. The value is of the number type when being used as the return value and the unit is vp.|
| x | [Length](#length) | No | X coordinate. The value is of the number type in vp when used as the return value.|
| y | [Length](#length) | No | Y coordinate. The value is of the number type in vp when used as the return value.|
## ConstraintSizeOptions
The **ConstraintSizeOptions** type is used to set the constraint size of a component, thereby limiting the size range during component layout.
The **ConstraintSizeOptions** type is used to set the size constraints of a component during component layout.
| Name | Type | Mandatory | Description |
| --------- | ------ | ---- | ------- |
| minWidth | [Length](#length) | No | Minimum width of the element.|
| maxWidth | [Length](#length) | No | Maximum width of the element.|
| minHeight | [Length](#length) | No | Minimum height of the element.|
| maxHeight | [Length](#length) | No | Maximum height of the element.|
| minWidth | [Length](#length) | No | Minimum width of the component.|
| maxWidth | [Length](#length) | No | Maximum width of the component.|
| minHeight | [Length](#length) | No | Minimum height of the component.|
| maxHeight | [Length](#length) | No | Maximum height of the component.|
## SizeOptions
......@@ -183,8 +182,8 @@ The **SizeOptions** type is used to set the width and height.
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ----- |
| width | [Length](#length) | No | Width of the element.|
| height | [Length](#length) | No | Height of the element.|
| width | [Length](#length) | No | Width of the component.|
| height | [Length](#length) | No | Height of the component.|
## BorderOptions
......@@ -200,11 +199,11 @@ The **BorderOptions** type is used to provide border information.
## ColorFilter<sup>9+</sup>
The **ColorFilter** type is used to create a color filter with a 4*5 matrix.
The **ColorFilter** type is used to create a color filter with a 4 x 5 matrix.
| Name | Type | Mandatory | Description |
| ----------- | -------- | ---- | ---------------------------------------- |
| constructor | number[] | Yes | Constructor for creating a color filter with a 4\*5 matrix. The input parameter is [m\*n], which is the matrix value in row m and column n. The matrix is row-first.|
| constructor | number[] | Yes | Constructor for creating a color filter with a 4 x 5 matrix. The input parameter is [m*n], which is the matrix value in row m and column n. The matrix is row-first.|
## CustomBuilder<sup>8+</sup>
......@@ -213,4 +212,4 @@ The **CustomBuilder** type is used to define custom UI descriptions in component
| Name | Type | Description |
| ------------- | ---------------------- | ---------------------------------------- |
| CustomBuilder | ()&nbsp;=&gt;&nbsp;any | Must be decorated by **@Builder**. For details, see [@Builder](../../ui/ts-component-based-builder.md).|
| CustomBuilder | ()&nbsp;=&gt;&nbsp;any | Must be decorated by **@Builder**. For details, see [@Builder](../../quick-start/arkts-dynamic-ui-elememt-building.md#builder).|
......@@ -10,7 +10,7 @@ The visibility attribute controls whether a component is visible.
| Name | Type | Description |
| ---------- | ---------------------------- | ------------------------------------------ |
| visibility | [Visibility](ts-appendix-enums.md#visibility) | Whether the component is visible. Note that even if a component is invisible, it still needs to be re-created when the page is refreshed. Therefore, you are advised to use [conditional rendering](../../quick-start/arkts-rendering-control.md#conditional-rendering) instead under scenarios where consistently high performance is required.<br>Default value: **Visibility.Visible**|
| visibility | [Visibility](ts-appendix-enums.md#visibility) | Whether the component is visible. Note that even if a component is invisible, it still needs to be re-created when the page is refreshed. Therefore, you are advised to use [conditional rendering](../../quick-start/arkts-rendering-control.md#conditional-rendering) instead under scenarios where consistently high performance is required.<br>Default value: **Visibility.Visible** |
## Example
......@@ -31,7 +31,7 @@ struct VisibilityExample {
Text('Hidden').fontSize(9).width('90%').fontColor(0xCCCCCC)
Row().visibility(Visibility.Hidden).width('90%').height(80).backgroundColor(0xAFEEEE)
// The component is visiable, which is the default display mode.
// The component is visible, which is the default display mode.
Text('Visible').fontSize(9).width('90%').fontColor(0xCCCCCC)
Row().visibility(Visibility.Visible).width('90%').height(80).backgroundColor(0xAFEEEE)
}.width('90%').border({ width: 1 })
......
# Upload and Download Error Codes
## 13400001 File Operation Error
**Error Message**
File operation error.
**Description**
This error code is reported when a file operation error occurs in invoking the **uploadFile** or **downloadFile** API.
**Possible Causes**
The file permission is insufficient.
**Solution**
Make sure you have the required permission on the target files.
## 13400002 File Path Error
**Error Message**
Bad file path.
**Description**
This error code is reported when a file path error occurs in invoking the **uploadFile** or **downloadFile** API.
**Possible Causes**
The file path is incorrect.
**Solution**
Verify the file path.
## 13400003 Service Error
**Error Message**
Task manager service error.
**Description**
This error code is reported when a task manager service error occurs in invoking the **downloadFile** API.
**Possible Causes**
The task fails to be created.
**Solution**
Verify the task settings.
# Resource Manager Error Codes
## 9001001 Invalid Resource ID
**Error Message**
The resId invalid.
**Description**
This error code is reported if the specified resource ID meets the type requirement but the resource ID does not exist.
**Possible Causes**
The specified resource ID does not exist.
**Solution**
Check whether the specified resource ID exists.
## 9001002 Matching Resource Not Found Based on the Specified Resource ID
**Error Message**
The resource not found by resId.
**Description**
This error code is reported if the specified resource ID meets the type requirement but no resource is found based on the resource ID.
**Possible Causes**
1. The specified resource ID is incorrect.
2. Resource parsing is incorrect.
**Solution**
Check whether the specified resource ID is correct.
## 9001003 Invalid Resource Name
**Error Message**
The resName invalid.
**Description**
This error code is reported if the specified resource name meets the type requirement but the resource name does not exist.
**Possible Causes**
The specified resource name does not exist.
**Solution**
Check whether the specified resource name is correct.
## 9001004 Matching Resource Not Found Based on the Specified Resource Name
**Error Message**
The resource not found by resName.
**Description**
This error code is reported if the specified resource ID meets the type requirement but no resource is found based on the resource ID.
**Possible Causes**
1. The specified resource name is incorrect.
2. Resource parsing is incorrect.
**Solution**
Check whether the specified resource name is correct.
## 9001005 Invalid Relative Path
**Error Message**
The resource not found by path.
**Description**
This error code is reported if no resource is found based on the specified relative path.
**Possible Causes**
The specified relative path is incorrect.
**Solution**
Check whether the specified relative path is correct.
## 9001006 Cyclic Reference
**Error Message**
the resource re-ref too much.
**Description**
This error code is reported if resources are referenced cyclically.
**Possible Causes**
Resources are referenced cyclically.
**Solution**
Check the reference of resource $, and remove the cyclic reference, if any.
# System Parameter Error Codes
## 14700101 Failure to Query the System Parameter
**Error Message**
System parameter can not be found.
**Description**
This error code is reported when the parameter does not exist in the workspace or no key has been set for the parameter.
**Possible Causes**
The parameter is not set or fails to be set.
**Solution**
Set the parameter correctly.
## 14700102 Invalid System Parameter Value
**Error Message**
System parameter value is invalid.
**Description**
This error code is reported when the value of the system parameter is invalid.
**Possible Causes**
The value of the system parameter is empty, is out of range, or contains special characters, for example, "const..param.xxx".
**Solution**
Set the value to a valid string.
## 14700103 Permission Denial for the Operation on the System Permission
**Error Message**
System permission operation permission denied.
**Description**
This error code is reported when the system parameter does not have the discretionary access control (DAC) or mandatory access control (MAC) permission.
**Possible Causes**
The DAC or MAC permission is not configured.
**Solution**
Add the DAC or MAC permission as needed.
## 14700104 Internal System Error, Including Out of Memory and Deadlock
**Error Message**
System internal error including out of memory, deadlock etc.
**Description**
This error code is reported when the attempt to modify the **const** attribute settings, the socket connection, or the memory copy fails.
**Possible Causes**
The socket connection is abnormal, or the node fails to be added or obtained.
**Solution**
1. Analyze the memory usage of the entire process and eliminate memory leak.
2. If you are in a multi-thread scenario, check the error stack for deadlock.
......@@ -2,17 +2,27 @@
## Overview
### Basic Concepts
- Introduction to begetctl
For details, see [Description of begetctl Commands](#table14737791480).
begetctl is a CLI-based management tool. For details about this functions, see [Description of begetctl Commands](#table14737791480).
- bootchart plug-in
The bootchart plug-in is an open source tool used to evaluate system performance during Linux startup. It automatically collects information such as the CPU usage, disk throughput, and process status, and displays the evaluation result in graphics to facilitate system startup optimization.
- bootevent plug-in
bootevent is a plug-in that records key startup events of the init process and each service. The recorded information includes the event name, startup time of the service associated with the event, and event occurrence time. By using the exported file for trace parsing, you can then optimize the system startup process.
### Constraints
bootchart is available only for the standard system, and begetctl is available for both the small system and the standard system.
bootchart and bootevent are available only for the standard system, and begetctl is available for both the small system and the standard system.
## How to Develop
## Development Guidelines
### Parameters
**Table 1** Description of begetctl commands<a name="table14737791480"></a>
| Command| Format and Example| Description|
| :---------- | :---------- |:--------|
......@@ -22,7 +32,7 @@ bootchart is available only for the standard system, and begetctl is available f
| param set name value| Sets system parameters.<br>Example:<br>begetctl param set ohos.servicectrl.display 1 or param set ohos.servicectrl.display 1| N/A|
| param wait name [value] [timeout] | Waits for system parameters.<br>Example:<br>begetctl param wait persist.sys.usb.config hdc or param wait persist.sys.usb.config hdc| The default value of **timeout** is **30**.|
| param dump [verbose] | Dumps system parameter information.<br>Example:<br>begetctl param dump or param dump| N/A|
| param shell <i>[name]</i> | Enters the parameter shell.<br>Example:<br>begetctl param shell or param shell| N/A|
| param shell [name] | Enters the parameter shell.<br>Example:<br>begetctl param shell or param shell| N/A|
| timer_stop servicename | Stops the service timer.<br>Example:<br>begetctl timer_stop appspawn | The value of **servicename** can contain a maximum of 96 characters.|
| timer_start servicename timeout | Starts the service timer.<br>Example:<br>begetctl timer_start appspawn | The value of **servicename** can contain a maximum of 96 characters. The default value of **timeout** is **10**. |
| start_service servicename | Starts a service.<br>Example:<br>begetctl start_service appspawn or start_service appspawn| N/A|
......@@ -54,21 +64,19 @@ bootchart is available only for the standard system, and begetctl is available f
| modulectl uninstall moduleName | Uninstalls a dynamic plug-in.<br>Example:<br>modulectl uninstall bootchart | N/A|
| modulectl install moduleName | Installs a dynamic plug-in.<br>Example:<br>modulectl install bootchart | N/A|
| modulectl list | Views the list of dynamic plug-ins.<br>Example:<br>begetctl modulectl list | N/A|
| setloglevel level | Sets the log level to **info**.<br>Example:<br>begetctl setloglevel 1 | The log level ranges from **0** to **4**.|
| getloglevel | Obtains the log level of the init process.<br>Example:<br>begetctl getloglevel | N/A|
| bootevent disable | Disables the bootevent plug-in.<br>Example:<br>begetctl bootevent disable| N/A|
| bootevent enable | Enables the bootevent plug-in.<br>Example:<br>begetctl bootevent enable| N/A|
| dump_service parameter_service trigger | Displays information about all triggers.<br>Example:<br>begetctl dump_service parameter_service trigger | N/A|
| dump_service all | Displays information about all services.<br>Example:<br>begetctl dump_service all | N/A|
| dump_service serviceName | Displays information about a single service.<br>Example:<br>begetctl dump_service param_watcher | N/A|
| dump api | Displays information about APIs of the init process.<br>Example:<br>begetctl dump api | N/A|
## How to Develop
### Available APIs
**Table 1** Description of plug-in management APIs<a name="table14737791479"></a>
| API| Description|
| ---------- | ---------- |
| void PluginExecCmdByName(const char *name, const char *cmdContent) | Starts a plug-in by name.|
| void PluginExecCmdByCmdIndex(int index, const char *cmdContent) | Starts a plug-in by index.|
| int PluginExecCmd(const char *name, int argc, const char **argv) | Starts a plug-in by command.|
| int AddCmdExecutor(const char *cmdName, CmdExecutor execCmd) | Adds the plug-in installation command.|
### How to Develop
Add a plug-in. The following uses bootchart as an example:
1. Install the **.so** file and define an independent file to implement the following functions:
```c
static int bootchartEarlyHook(int stage, int prio, void *cookie)
......@@ -87,11 +95,11 @@ bootchart is available only for the standard system, and begetctl is available f
MODULE_CONSTRUCTOR(void)
{
// Depending on parameter service
// Depends on parameter service
InitAddPostPersistParamLoadHook(0, bootchartEarlyHook);
}
```
2. Compile the static library **libbootchart_static** and add it to the **static_modules** group.
2. Compile the static library **libbootchart\_static** and add it to the **static\_modules** group.
```
group("static_modules") {
if (!defined(ohos_lite)) {
......@@ -138,19 +146,23 @@ bootchart is available only for the standard system, and begetctl is available f
### Development Example
#### Bootchart
Prerequisites
1. Prepare the bootchart test environment. Specifically, install Python and pycairo by running **pip install pycairo** on Linux.
2. Decompress **bootchart-master.tar**.
tar -zxvf bootchart-master.tar
Procedure
1. Start the system.
2. Run the **begetctl bootchart enable** command.
3. Restart the system.
4. Run the **begetctl bootchart stop** command.
5. Run the **begetctl bootchart disable** command.
6. Export the following files from the **/data/bootchart** directory and save them to the **bootchart** folder:
6. Export the following files from the **/data/bootchart** directory and save them to the **bootchart** folder:<br>
header<br>
proc_diskstats.log<br>
proc_ps.log<br>
......@@ -161,5 +173,38 @@ bootchart is available only for the standard system, and begetctl is available f
python3 pybootchartgui.py -f pdf bootchart.tgz
```
Expected Result
A **bootchart.pdf** file is generated in the **bootchart-master** directory.
Expected result:
A **bootchart.pdf** file is generated in the **bootchart-master** directory.
#### bootevent
1. Configure one or more boot events in the **.cfg** file.
Configure a single boot event.
```json
bootevents : "bootevent.xxxbootevent",
```
Configure multiple boot events.
```json
bootevents : ["bootevent.xxxbootevent1", "bootevent.xxxbootevent2.xxx"],
```
> **NOTE**
>
> The configured event must start with **bootevent**.
2. Send the boot events.
Call the **SetParameter** API provided by init process to send the boot events. For example, to send the XXXbootevent1 event configured in the previous step, use the following code:
```c
SetParameter("bootevent.XXXbootevent1", "true");
```
3. Enable the bootevent function by running the **begetctl bootevent enable** command.
To disable the bootevent function, run the **begetctl bootevent disable** command and restart the system.
4. Use the exported bootevent file for trace analysis.
- The exported bootevent file is stored in the **/data/service/el0/startup/init/** directory.
- It is named in the format of *timestamp***.bootevent**.
- You can import the file to the trace analysis tool for visual analysis.
......@@ -7,7 +7,7 @@ The following figure shows the context structure of the Startup subsystem.
**Figure 1** Context structure of the Startup subsystem
![context-structure-of-the-startup-subsystem](figure/context-structure-of-the-Startup-subsystem.png)
![context-structure-of-the-Startup-subsystem](figure/context-structure-of-the-Startup-subsystem.png)
When the system is powered on, the kernel loads and starts services and applications as follows:
......@@ -22,27 +22,32 @@ When the system is powered on, the kernel loads and starts services and applicat
The Startup subsystem consists of the following modules:
- init module<br>
- init module
This module corresponds to the init process, which is the first user-mode process started after the kernel is initialized. After the init process starts, it reads and parses the **init.cfg** file. Based on the parsing result, the init module executes the commands listed in Table 2 in [Job Management](../subsystems/subsys-boot-init-jobs.md) and starts the key system service processes in sequence with corresponding permissions granted.
- ueventd module<br>
- ueventd module
This module listens for **netlink** events about hot swap of kernel device drivers and dynamically manages the **dev** node of the corresponding device based on the event type.
- appspawn module<br>
- appspawn module
This module spawns application processes upon receiving commands from the foundation, configures permissions for new processes, and calls the entry function of the application framework.
- bootstrap module<br>
- bootstrap module
This module provides entry identifiers for starting services and features. When SAMGR is started, the entry function identified by bootstrap is called and system services are started.
- syspara module<br>
- syspara module
This module provides APIs for obtaining device information, such as the product name, brand name, and manufacturer name, based on the OpenHarmony Product Compatibility Specifications (PCS). It also provides APIs for setting and obtaining system attributes.
## Constraints
The source code directory of the Startup subsystem varies according to the platform.
The source code directory of the Startup subsystem varies according to the platform.
**Table 1** Directories and applicable platforms of the Startup subsystem
**Table 1** Directories and applicable platforms of the Startup subsystem
| Source Code Directory| Applicable Platform|
| -------- | -------- |
......@@ -57,7 +62,9 @@ The Startup subsystem consists of the following modules:
- When porting a new chip platform, you need to add the **/vendor/etc/init/init.{hardware}.cfg** file that contains the platform-level initialization configuration. This file is used to implement platform-level initialization, for example, installing the ko driver and configuring information on the related **/proc** nodes.
> **NOTE**: The configuration file **init.cfg** must be in JSON format.
> **NOTE**
>
> The configuration file **init.cfg** must be in JSON format.
- bootstrap module: The zInit code must be configured in the link script.
......@@ -186,7 +193,9 @@ On each development board, you need to partition the memory to store the precedi
This example assumes the **system** partition as the required partition on the Hi3516D V300 platform to illustrate the boot process. During this process, the init process reads the required fstab information, creates a block device node, and mounts it to the required partition. The following provides the key code snippets and log information as reference for debugging.
> **NOTE**: The code snippets below are exhibited in the logical sequence. They are not neighboring to each other in the source code.
> **NOTE**
>
> The code snippets below are exhibited in the logical sequence. They are not neighboring to each other in the source code.
1. Obtain required device information.
```
......@@ -276,10 +285,11 @@ On each development board, you need to partition the memory to store the precedi
```
The key variables in the code are as follows:
**bus**: a string that saves the path of the bus connected to the current device.
**parent**: a string that stores the device path obtained from **syspath** in the uevent message.
**links**: a pointer to the memory that stores the soft link path.
**bootDevice**: a string that stores the value of **default_boot_device** in **bootargs**
- **bus**: a string that saves the path of the bus connected to the current device.
- **parent**: a string that stores the device path obtained from **syspath** in the uevent message.
- **links**: a pointer to the memory that stores the soft link path.
- **bootDevice**: a string that stores the value of **default_boot_device** in **bootargs**
According to the code, the corresponding soft link is created for the device only when the type of the connected bus is **platform**. The path of the soft link is as follows:
```
/dev/block/platform/soc/10100000.himci.eMMC/by-name
......@@ -328,13 +338,141 @@ On each development board, you need to partition the memory to store the precedi
- Mounting of vendor partitions
After mounting required partitions, the init process scans each script file in the **vendor** partition. The initialization scripts related to the chip or development board are named in the format of **/vendor/etc/init.{ohos.boot.hardware}.cfg**. Wherein, **/vendor/etc/fstab.{ohos.boot.hardware}** represents the extended mount partition file; **hardware** is sourced from **bootargs**, which is passed from the bootloader to the kernel.
After mounting required partitions, the init process scans each script file in the **vendor** partition. The initialization scripts related to the chip or development board are named in the format of **/vendor/etc/init.{ohos.boot.hardware}.cfg**. Wherein, **/vendor/etc/fstab.{ohos.boot.hardware}** represents the extended mount partition file; **hardware** is sourced from **bootargs**, which is passed from the bootloader to the kernel.
### Boot Loading Without ramdisk
Certain development boards do not use the ramdisk boot mode. For these boards, the boot process is implemented by directly loading the **system.img** file through the kernel. In such case, you need to modify the product configuration file in **productdefine**. Specifically, you need to turn off the **enable_ramdisk** switch to disable ramdisk generation so that the init process does not boot from ramdisk to system.
The boot loading process in this scenario is similar to that in the preceding section. The only difference is as follows: If ramdisk is used, the init process mounts **system.img** to the **/usr** directory, and then switches to the **/usr** directory using **chroot** and executes the **/etc/init.cfg** script. If ramdisk is not used, there is no chroot process, and the boot script is **init.without_two_stages.cfg**.
Boot loading in this scenario is similar to that in the preceding section. The only difference is as follows: If ramdisk is used, the init process mounts **system.img** to the **/usr** directory and then switches to the **/usr** directory using **chroot**. If ramdisk is not used, the init process directly runs the **init.cfg** file.
For boot loading without ramdisk (that is, system as root), the block device where the root file system is located is passed to the kernel through **bootargs**, for example, **root=/dev/mmcblk0p5 and rootfstype=ext4**. During initialization of the root file system, the kernel parses the **root** field in **bootargs** to complete mounting of the root file system.
### Partition A/B Booting
Currently, OpenHarmony supports booting from partitions A and B (active and standby system partitions), both of which are configured in the same device storage. During the booting process, the system partition to load is determined based on the slot of the active partition. Partition A/B booting is supported only for the system partition and chipset partition.
- bootslots
Number of the supported boot partitions. If **bootslots** is set to **2**, the system can boot from both system partitions A and B. If **bootslots** is set to **1**, partition A/B booting is not supported and the system can boot only from the default system partition.
In the initial phase of init process startup, the system reads the **bootslots** value to determine whether partition A/B booting is supported. If yes, the system continues to determine the system partition to mount. If not, the system mounts the system partition based on the default fstab. The API for the init process to obtain the **bootslots** value is as follows:
```
int GetBootSlots(void)
{
int bootSlots = GetSlotInfoFromParameter("bootslots");
BEGET_CHECK_RETURN_VALUE(bootSlots <= 0, bootSlots);
BEGET_LOGI("No valid slot value found from parameter, try to get it from cmdline");
return GetSlotInfoFromCmdLine("bootslots");
}
```
After normal system startup, you can obtain the **bootslots** value from the system parameter **ohos.boot.bootslots** to check whether the current system supports partition A/B booting. The command for obtaining **ohos.boot.bootslots** is as follows:
```
param get ohos.boot.bootslots
```
- currentslot
Current system partition, for example, partition A or partition B. The value of **currentslot** is a number. For example, **1** indicates partition A, and **2** indicates partition B.
In the initial phase of startup, the init process determines whether the system supports partition A/B booting based on **bootslots**. If the system does not support partition A/B booting, the init process directly boots from the default system partition instead of obtaining the **currentslot** value. If the system supports partition A/B booting, the init process obtains the **currentslot** value and determines whether partition A or partition B is the current system partition. The API for the init process to obtain the **currentslot** value is as follows:
```
int GetCurrentSlot(void)
{
// get current slot from parameter
int currentSlot = GetSlotInfoFromParameter("currentslot");
BEGET_CHECK_RETURN_VALUE(currentSlot <= 0, currentSlot);
BEGET_LOGI("No valid slot value found from parameter, try to get it from cmdline");
// get current slot from cmdline
currentSlot = GetSlotInfoFromCmdLine("currentslot");
BEGET_CHECK_RETURN_VALUE(currentSlot <= 0, currentSlot);
BEGET_LOGI("No valid slot value found from cmdline, try to get it from misc");
// get current slot from misc
return GetSlotInfoFromMisc(MISC_PARTITION_ACTIVE_SLOT_OFFSET, MISC_PARTITION_ACTIVE_SLOT_SIZE);
}
```
- Partition A/B booting process
1. Obtain the **currentslot** value to determine whether partition A or partition B is the current system partition.
2. Construct new partition mounting configuration based on the original fstab file, and add the suffix **a** or **b** to the partitions that support partition A/B booting, that is, system and chipset partitions.
3. Mount the partition added with the corresponding suffix and enter the second phase of startup. This phase occurs in partition A or B and concludes the partition A/B booting process.
The API for constructing new partition mounting configuration is as follows:
```
static void AdjustPartitionNameByPartitionSlot(FstabItem *item)
{
BEGET_CHECK_ONLY_RETURN(strstr(item->deviceName, "/system") != NULL ||
strstr(item->deviceName, "/chipset") != NULL);
char buffer[MAX_BUFFER_LEN] = {0};
int slot = GetCurrentSlot();
BEGET_ERROR_CHECK(slot > 0 && slot <= MAX_SLOT, slot = 1, "slot value %d is invalid, set default value", slot);
BEGET_INFO_CHECK(slot > 1, return, "default partition doesn't need to add suffix");
BEGET_ERROR_CHECK(sprintf_s(buffer, sizeof(buffer), "%s_%c", item->deviceName, 'a' + slot - 1) > 0,
return, "Failed to format partition name suffix, use default partition name");
free(item->deviceName);
item->deviceName = strdup(buffer);
BEGET_LOGI("partition name with slot suffix: %s", item->deviceName);
}
```
- Development example
The following uses the rk3568 platform as an example to illustrate how to change from default partition booting to partition A/B booting.
1. Burn the original image, and view the device information of each partition.
![Original partition](figure/ABStartup_1.png)
Use the original image to construct images of the partitions used for partition A/B booting, and test the partition A/B booting function.
- Copy the **system** and **vendor** images, and add the suffix **\_b** to them.
- Add partitions **system_b** and **vendor_b** to the partition table in **parameter.txt**.
2. Burn the images of the partitions used for partition A/B booting.
- Import the partition configuration to the rk3568 burning tool, and select the **parameter.txt** file containing the **system_b** and **vendor_b** partitions.
- Select images (including **system_b** and **vendor_b** images) based on the new partition table configuration, and then burn the images.
3. After the configuration is complete, perform the following:
1. Run the **cat /proc/cmdline** command. If the command output contains **bootslot=2**, the system supports partition A/B booting.
![cmdline](figure/ABStartup_2.png)
2. Run the **param get ohos.boot.bootslot** command. If the command output contains **2**, the **bootslot** information is successfully written to the **parameter.txt**.
3. Run the **ls -l /dev/block/by-name** command. If the command output contains **system_b** and **vendor_b**, device nodes are successfully created in partition B.
![Device information](figure/ABStartup_3.png)
4. Run the **df -h** command to check the partitions mounted to the system.
![Partition information](figure/ABStartup_4.png)
As shown in the figure, partition **mmcblk0p6** is mounted to the root file system (represented by a slash), and partition **mmcblk0p7** is mounted to **/vendor**. Based on the command output in step 3, **mmcblk0p6** is the **system** partition, and **mmcblk0p7** is the **vendor** partition. That is, the mounted partitions are the default partitions, that is, **system** and **vendor** partitions without suffixes. In other words, partition A is the default partition.
Next, let's try booting from partition B.
1) Run the **partitionslot setactive 2** command to set the slot of the active partition to **2**, that is, the slot of partition B.
![Partition slot configuration](figure/ABStartup_5.png)
2) Run the **partitionslot getslot** command to check the configured slot.
![View Slot](figure/ABStartup_6.png)
If **current slot** is **2**, the slot of the active partition is successfully set to **2**.
3) Upon restarting, run the **df -h** command to check the partitions mounted to the system.
According to the command output, partition **mmcblk0p11** is mounted to the root file system, and partition **mmcblk0p12** is mounted to **/vendor**.
![Mounting information](figure/ABStartup_7.png)
4) Run the **ls -l /dev/block/by-name** command again.
![New device information](figure/ABStartup_8.png)
For the boot loading process without ramdisk, that is, system as root, the block device where the root file system is located is passed to the kernel through **bootargs**, for example, **root=/dev/mmcblk0p5 and rootfstype=ext4**. During initialization of the root file system, the kernel parses the **root** field in **bootargs** to complete mounting of the root file system.
**mmcblk0p11** corresponds to **system_b**, and **mmcblk0p12** corresponds to **vendor_b**. That is, the system is successfully booted from partition B.
# HiTraceMeter
## Introduction
HiTraceMeter is the OpenHarmony subsystem that provides APIs to implement call chain trace throughout a service process. With HiTraceMeter, you can quickly obtain the run log specific to the call chain of a service process and locate faults in inter-device, inter-process, or inter-thread communications. HiTraceMeter supports event logging in user mode and can collect trace data in user mode and kernel mode for performance tracing and analysis.
## Basic Concepts
The HiTraceMeter subsystem consists of three parts:
- JS/C++ HiTraceMeter APIs for application logging
- hitrace CLI tool for data collection
- smartperf tool for graphical data analysis
Wherein, HiTraceMeter APIs and the hitrace CLI tool run on the device side, and the smartperf tool runs on the PC side.
HiTraceMeter APIs are provided in C++ and JS for event logging, which aims to generate the trace data necessary for performance tracing and analysis during the development process.
The hitrace CLI tool is used to collect trace data. It captures trace data flows and saves the data as a text file.
The smartperf tool allows you to perform data analysis manually or use the analysis script for automated data analysis. If you want to get the data analysis done automatically, you need to supply the data file generated by the hitrace CLI tool as the input for the smartperf tool.
Traces data is classified by trace tag or trace category. Generally, one device subsystem corresponds to one tag. The tag is passed as the **Tag** parameter to event logging APIs. When you use the hitrace CLI tool to collect trace data, only the trace data specified by the **Tag** parameter is collected. Trace data of applications is fixedly labeled as **APP Tag**, and therefore, no **Tag** parameter needs to be passed to JS APIs. The following is a list of trace tags supported by HiTraceMeter. You can view the tags in [hitrace_meter.h](https://gitee.com/openharmony/hiviewdfx_hitrace/blob/master/interfaces/native/innerkits/include/hitrace_meter/hitrace_meter.h).
```cpp
constexpr uint64_t HITRACE_TAG_NEVER = 0; // This tag is never enabled.
constexpr uint64_t HITRACE_TAG_ALWAYS = (1ULL << 0); // This tag is always enabled.
constexpr uint64_t HITRACE_TAG_DLP_CREDENTIAL = (1ULL << 21); // This tag is dlp credential service.
constexpr uint64_t HITRACE_TAG_ACCESS_CONTROL = (1ULL << 22); // This tag is access control tag.
constexpr uint64_t HITRACE_TAG_NET = (1ULL << 23); // Net tag.
constexpr uint64_t HITRACE_TAG_NWEB = (1ULL << 24); // NWeb tag.
constexpr uint64_t HITRACE_TAG_HUKS = (1ULL << 25); // This tag is huks.
constexpr uint64_t HITRACE_TAG_USERIAM = (1ULL << 26); // This tag is useriam.
constexpr uint64_t HITRACE_TAG_DISTRIBUTED_AUDIO = (1ULL << 27); // Distributed audio tag.
constexpr uint64_t HITRACE_TAG_DLSM = (1ULL << 28); // device security level tag.
constexpr uint64_t HITRACE_TAG_FILEMANAGEMENT = (1ULL << 29); // filemanagement tag.
constexpr uint64_t HITRACE_TAG_OHOS = (1ULL << 30); // OHOS generic tag.
constexpr uint64_t HITRACE_TAG_ABILITY_MANAGER = (1ULL << 31); // Ability Manager tag.
constexpr uint64_t HITRACE_TAG_ZCAMERA = (1ULL << 32); // Camera module tag.
constexpr uint64_t HITRACE_TAG_ZMEDIA = (1ULL << 33); // Media module tag.
constexpr uint64_t HITRACE_TAG_ZIMAGE = (1ULL << 34); // Image module tag.
constexpr uint64_t HITRACE_TAG_ZAUDIO = (1ULL << 35); // Audio module tag.
constexpr uint64_t HITRACE_TAG_DISTRIBUTEDDATA = (1ULL << 36); // Distributeddata manager module tag.
constexpr uint64_t HITRACE_TAG_MDFS = (1ULL << 37); // Mobile distributed file system tag.
constexpr uint64_t HITRACE_TAG_GRAPHIC_AGP = (1ULL << 38); // Graphic module tag.
constexpr uint64_t HITRACE_TAG_ACE = (1ULL << 39); // ACE development framework tag.
constexpr uint64_t HITRACE_TAG_NOTIFICATION = (1ULL << 40); // Notification module tag.
constexpr uint64_t HITRACE_TAG_MISC = (1ULL << 41); // Notification module tag.
constexpr uint64_t HITRACE_TAG_MULTIMODALINPUT = (1ULL << 42); // Multi modal module tag.
constexpr uint64_t HITRACE_TAG_SENSORS = (1ULL << 43); // Sensors mudule tag.
constexpr uint64_t HITRACE_TAG_MSDP = (1ULL << 44); // Multimodal Sensor Data Platform module tag.
constexpr uint64_t HITRACE_TAG_DSOFTBUS = (1ULL << 45); // Distributed Softbus tag.
constexpr uint64_t HITRACE_TAG_RPC = (1ULL << 46); // RPC and IPC tag.
constexpr uint64_t HITRACE_TAG_ARK = (1ULL << 47); // ARK tag.
constexpr uint64_t HITRACE_TAG_WINDOW_MANAGER = (1ULL << 48); // window manager tag.
constexpr uint64_t HITRACE_TAG_ACCOUNT_MANAGER = (1ULL << 49); // account manager tag.
constexpr uint64_t HITRACE_TAG_DISTRIBUTED_SCREEN = (1ULL << 50); // Distributed screen tag.
constexpr uint64_t HITRACE_TAG_DISTRIBUTED_CAMERA = (1ULL << 51); // Distributed camera tag.
constexpr uint64_t HITRACE_TAG_DISTRIBUTED_HARDWARE_FWK = (1ULL << 52); // Distributed hardware fwk tag.
constexpr uint64_t HITRACE_TAG_GLOBAL_RESMGR = (1ULL << 53); // Global resource manager tag.
constexpr uint64_t HITRACE_TAG_DEVICE_MANAGER = (1ULL << 54); // Distributed hardware devicemanager tag.
constexpr uint64_t HITRACE_TAG_SAMGR = (1ULL << 55); // SA tag.
constexpr uint64_t HITRACE_TAG_POWER = (1ULL << 56); // power manager tag.
constexpr uint64_t HITRACE_TAG_DISTRIBUTED_SCHEDULE = (1ULL << 57); // Distributed schedule tag.
constexpr uint64_t HITRACE_TAG_DEVICE_PROFILE = (1ULL << 58); // device profile tag.
constexpr uint64_t HITRACE_TAG_DISTRIBUTED_INPUT = (1ULL << 59); // Distributed input tag.
constexpr uint64_t HITRACE_TAG_BLUETOOTH = (1ULL << 60); // bluetooth tag.
constexpr uint64_t HITRACE_TAG_ACCESSIBILITY_MANAGER = (1ULL << 61); // accessibility manager tag.
constexpr uint64_t HITRACE_TAG_APP = (1ULL << 62); // App tag.
constexpr uint64_t HITRACE_TAG_LAST = HITRACE_TAG_APP;
constexpr uint64_t HITRACE_TAG_NOT_READY = (1ULL << 63); // Reserved for initialization.
constexpr uint64_t HITRACE_TAG_VALID_MASK = ((HITRACE_TAG_LAST - 1) | HITRACE_TAG_LAST);
```
## Implementation Principle
HiTraceMeter provides the hitrace CLI tool for capturing trace data in user mode and kernel mode, and provides C++ (innerkits) and JS (kits) APIs for event logging in user mode. Through extending kernel's ftrace functionality, HiTraceMeter can use the trace_marker node of ftrace to write the data, which is written into the user space by event logging APIs, to the kernel buffer. The following figure shows the basic HiTraceMeter architecture.
![HiTraceMeter architecture](figure/HiTraceMeter.png)
## Constraints
- The implementation of HiTraceMeter functions and APIs depends on the ftrace functionality, a framework provided by the kernel. It enables developers to add more trace functions via plug-ins. Therefore, make sure that ftrace is enabled before you use HiTraceMeter.
For most Linux kernels, ftrace is enabled by default. For details, see the ftrace documentation you may obtain.
- HiTraceMeter is available only for the mini system and standard system.
# HiTraceMeter Development
HiTraceMeter development focuses on two parts: JS/C++ event logging APIs and the hitrace CLI tool.
## When to Use
You may encounter unexpected issues like app freezing during app development or need to view the code's call chain during code debugging. With the APIs provided by HiTraceMeter, you'll be able to trace the application delay and call chain to identify performance problems.
## Available APIs
Only C++ APIs are now open for system developers. If you're developing a JS app, skip this section. The following table describes the APIs applicable to the standard system. You can find the APIs in [hitrace_meter.h](https://gitee.com/openharmony/hiviewdfx_hitrace/blob/master/interfaces/native/innerkits/include/hitrace_meter/hitrace_meter.h).
**Table 1** Sync APIs
| API | Function |Parameter Description |
| :----------------------------------------------------------- | ------------- |------------- |
| void StartTrace(uint64_t label, const std::string& value, float limit = -1); | Starts a synchronous trace.|**label**: trace category.<br>**value**: trace data that indicates the specific status, such as the memory size and queue length.|
| void FinishTrace(uint64_t label); | Stops a synchronous trace.|**label**: trace category.|
**StartTrace** and **FinishTrace** must be used in pairs, and **FinishTrace** matches the latest **StartTrace**. The two APIs can be used in nested mode. The stack data structure is used for matching during trace data parsing. The **limit** parameter is used for flow control, and you are advised to use the default value.
**Table 2** Async APIs
| API | Function |Parameter Description |
| ------------------------------------------------------------ | ------------- |------------- |
| void StartAsyncTrace(uint64_t label, const std::string& value, int32_t taskId, float limit = -1); | Starts an asynchronous trace.| **label**: trace category.<br>**value**: trace data that indicates the specific status, such as the memory size and queue length.<br>**taskId**: ID used to indicate the association of APIs in an asynchronous trace.|
| void FinishAsyncTrace(uint64_t label, const std::string& value, int32_t taskId); | Stops an asynchronous trace.| **label**: trace category.<br>**value**: trace data that indicates the specific status, such as the memory size and queue length.<br>**taskId**: ID used to indicate the association of APIs in an asynchronous trace.|
The trace data of **StartAsyncTrace** and **FinishAsyncTrace** is matched based on **value** and **taskId**, and therefore, the two APIs can be used without a strict sequence. In C++ applications, asynchronous traces are seldom used.
**Table 3** Counter APIs
| API | Function |Parameter Description |
| ------------------------------------------------------------ | --------- |--------- |
| void CountTrace(uint64_t label, const std::string& name, int64_t); | Performs a count trace.|**label**: trace category.<br>**name**: trace name displayed in the IDE.|
## How to Develop
1. Add the build dependencies to the build configuration file **base\hiviewdfx\hitrace\cmd\BUILD.gn**.
```
external_deps = [ "hitrace_native:hitrace_meter"]
```
2. Add the header file dependencies.
```cpp
#include "hitrace_meter.h"// Header file for defining APIs
```
3. When calling an API, pass the trace value as an input parameter. After the hitrace command is executed in the shell, the trace data is automatically captured. The captured data includes the function call process and the memory and time consumed during this process. You can use the data to analyze the call process to identify performance problems.
```cpp
CountTrace(label, "count number", 2000); // Integer trace
StartTrace(label, "func1Trace", -1); // Trace start point of func1Start
FinishTrace(label); // Trace end point of func1Trace
StartAsyncTrace(label, "asyncTrace1", 1234); // Start point of asyncTrace1
FinishAsyncTrace(label, "asyncTrace2", 3456); // End point of asyncTrace2
```
4. On completion of HiTraceMeter building and deployment, start a trace. After you run the application in the shell on the device, trace data will be captured automatically.
```
hdc_std shell hitrace -t 10 ohos > .\myapp_demo.ftrace
```
You can open the captured data by clicking **Open trace file** in the smartperf tool or dragging the data to the graphics area. For details, see [smartperf](https://toscode.gitee.com/openharmony-sig/smartperf).
## Development Example
You can access a full list of trace tags supported by HiTraceMeter in **hitrace_meter.h**. The following uses the **OHOS** tag as an example to illustrate how to obtain the trace data of the **func1** and **func2** functions.
```cpp
#include "hitrace_meter.h" // Include hitrace_meter.h
using namespace std;
int main()
{
uint64_t label = BYTRACE_TAG_OHOS;
sleep(1);
CountTrace(label, "count number", 2000); // Integer trace
StartTrace(label, "func1Trace", -1); // Trace start point of func1Start
sleep(1);
StartTrace(label, "func2Trace", -1); // Trace start point of func2Start
sleep(2);
FinishTrace (label); // Trace end point of func2Trace
sleep(1);
FinishTrace(label); // Trace end point of func1Trace
return 0;
}
```
## Verification
The following is a demo debugging process, where the **StartTrace** and **FinishTrace** APIs are used in synchronization mode.
1. Write the test code file [hitrace_example.cpp](https://gitee.com/openharmony/hiviewdfx_hitrace/blob/master/cmd/example/hitrace_example.cpp) by adding the **StartTrace** and **FinishTrace** APIs to the code.
```cpp
int main()
{
thread t1(ThreadFunc1);
t1.join();
StartTrace(LABEL, "testStart");
sleep(SLEEP_ONE_SECOND);
StartTrace(LABEL, "funcAStart", SLEEP_ONE_SECOND); // Trace start point
FuncA();
FinishTrace(LABEL);
sleep(SLEEP_TWO_SECOND);
thread t2(ThreadFunc2);
t2.join();
StartTrace(LABEL, "funcBStart", SLEEP_TWO_SECOND);
FuncB();
FinishTrace(LABEL);// Trace end point
sleep(SLEEP_TWO_SECOND);
sleep(SLEEP_ONE_SECOND);
FinishTrace(LABEL);
FuncC();
return 0;
}
```
2. Modify the **base\hiviewdfx\hitrace\cmd\BUILD.gn** file, and start building.
```
ohos_executable("hitrace_example") {
sources = [ "example/hitrace_example.cpp" ]
external_deps = [ "hitrace_native:hitrace_meter" ]
subsystem_name = "hiviewdfx"
part_name = "hitrace_native"
}
group("hitrace_target") {
deps = [
":hitrace",
":hitrace_example",
]
}
```
3. Place the **hitrace_example** executable file in the **/system/bin** directory of the device, and run the following commands in sequence in the shell:
```shell
hitrace --trace_begin ohos
hitrace_exampe
hitrace --trace_dump
```
If the expected trace value is present in the trace data, the capture of trace data is successful. For example:
```
<...>-1651 (-------) [002] .... 327.194136: tracing_mark_write: S|1650|H:testAsync 111
<...>-1650 (-------) [001] .... 332.197640: tracing_mark_write: B|1650|H:testStart
<...>-1650 (-------) [001] .... 333.198018: tracing_mark_write: B|1650|H:funcAStart
<...>-1650 (-------) [001] .... 334.198507: tracing_mark_write: E|1650|
<...>-1654 (-------) [003] .... 341.201673: tracing_mark_write: F|1650|H:testAsync 111
<...>-1650 (-------) [001] .... 341.202168: tracing_mark_write: B|1650|H:funcBStart
<...>-1650 (-------) [001] .... 343.202557: tracing_mark_write: E|1650|
<...>-1650 (-------) [001] .... 346.203178: tracing_mark_write: E|1650|
<...>-1650 (-------) [001] .... 346.203457: tracing_mark_write: C|1650|H:count number 1
<...>-1650 (-------) [001] .... 347.203818: tracing_mark_write: C|1650|H:count number 2
<...>-1650 (-------) [001] .... 348.204207: tracing_mark_write: C|1650|H:count number 3
<...>-1650 (-------) [001] .... 349.204473: tracing_mark_write: C|1650|H:count number 4
<...>-1650 (-------) [001] .... 350.204851: tracing_mark_write: C|1650|H:count number 5
<...>-1655 (-------) [001] .... 365.944658: tracing_mark_write: trace_event_clock_sync: realtime_ts=1502021460925
<...>-1655 (-------) [001] .... 365.944686: tracing_mark_write: trace_event_clock_sync: parent_ts=365.944641
```
# Using the hitrace CLI Tool
The hitrace CLI tool is an executable binary program. On an OpenHarmony-powered device, you can run the following commands in the shell to capture kernel's running data.
**Table 4** Command list
| Option | Description |
| ------------------------------ | ------------------------------------------------------------ |
| -h, --help | Views the help Information. |
| -b *n*, --buffer_size *n* | Sets the buffer size for trace data in KB. The default value is **2048**. |
| -t *n*, --time *n* | Sets the trace uptime in seconds, which depends on the time required for analysis.|
| --trace_clock clock | Sets the type of the clock for adding a timestamp to a trace. The value can be **boot** (default), **global**, **mono**, **uptime**, or **perf**.|
| --trace_begin | Starts capturing trace data. |
| --trace_dump | Dumps trace data to the specified position. The default position is the console. |
| --trace_finish | Stops capturing trace data and dumps trace data to the specified position. The default position is the console. |
| -l, --list_categories | Lists the trace categories supported by the device. |
| --overwrite | Sets the action to take when the buffer is full. If this option is used, the latest trace data is discarded. If this option is not used, the earliest trace data is discarded (default). |
| -o *filename*, --output *filename*| Outputs trace data to the specified file. |
| -z | Compresses the trace data. |
Examples:
- Query supported labels.
```
hitrace -l
```
Or,
```
hitrace --list_categories
```
- Trace ability information for 10 seconds and store the trace data in a buffer of 4 MB.
```
hitrace -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace
```
- Set the clock type to **mono**.
```
hitrace --trace_clock mono -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace
```
- Compress the trace data.
```
hitrace -z -b 4096 -t 10 --overwrite ability > /data/log/mytrace.ftrace
```
# FAQs
### Incomplete or Empty Data Captured by hitrace
#### Symptom
The data captured by running the hitrace command is incomplete or no data is captured.
#### Solution
Check the value of the **-t** and **-b** parameters. If the value is too small, data loss will occur. You are advised to set **-t** to **60** and **-b** to **204800** to increase the trace capture time and buffer, respectively.
# References
For details about HiTraceMeter, see [hiviewdfx_hitrace: A Lightweight Distributed Tracing](https://gitee.com/openharmony/hiviewdfx_hitrace).
......@@ -22,7 +22,7 @@
1. 控制设备上的振动器,需要申请权限ohos.permission.VIBRATE。具体配置方式请参考[权限申请声明](../security/accesstoken-guidelines.md)
2. 根据指定振动效果和振动属性触发马达振动
2. 根据指定振动效果和振动属性触发马达振动。
```js
import vibrator from '@ohos.vibrator';
......@@ -45,7 +45,7 @@
}
```
5. 按照指定模式停止马达的振动。
3. 按照指定模式停止马达的振动。
```js
import vibrator from '@ohos.vibrator';
......@@ -61,7 +61,7 @@
} catch (err) {
console.info('errCode: ' + err.code + ' ,msg: ' + err.message);
}
```
```
......
......@@ -60,7 +60,7 @@ build() {
Ability配置中缺少startWindowIcon属性配置,需要在module.json5中abilities中配置startWindowIcon。
参考文档:[Stage模型配置文件](../quick-start/stage-structure.md)
参考文档:[Stage模型应用程序包结构](../quick-start/application-package-structure-stage.md)
示例:
......@@ -109,7 +109,7 @@ Ability配置中缺少startWindowIcon属性配置,需要在module.json5中abil
适用于:OpenHarmony SDK 3.2.5.5版本, API8 FA模型
服务卡片在添加卡片后就触发了oncreat()生命周期,在不启用app的情况下也可以显示相关的用户信息-静默登录,但服务卡片目前要在app安装之后手动添加。
服务卡片在添加卡片后就触发了oncreate()生命周期,在不启用app的情况下也可以显示相关的用户信息-静默登录,但服务卡片目前要在app安装之后手动添加。
## 如何获取context
......@@ -203,7 +203,7 @@ listener.on('change', onPortrait)
适用:OpenHarmony SDK 3.2.5.5版本
使用featureAbility.getWant()和featureAbility.getContext()在json文件中router跳转发送数据,在js文件中用featureAblity方法接收
使用featureAbility.getWant()和featureAbility.getContext()在json文件中router跳转发送数据,在js文件中用featureAbility方法接收
## router.disableAlertBeforeBackPage和router.enableAlertBeforeBackPage怎么触发
......
......@@ -4,7 +4,7 @@
适用于:OpenHarmony SDK 3.2.3.5版本,API9 Stage模型
通过\@ohos.bundle模块buniple.getBundleInfo()接口获取包信息bundleInfo,然后分别通过bundleInfo.versionCode、bundleInfo.versionName
通过\@ohos.bundle模块bundle.getBundleInfo()接口获取包信息bundleInfo,然后分别通过bundleInfo.versionCode、bundleInfo.versionName
参考文档:[Bundle模块](../reference/apis/js-apis-Bundle.md#bundlegetbundleinfo)
......@@ -28,4 +28,4 @@
使用于:OpenHarmony SDK 3.2.5.5版本,API9 Stage模型
使用bundle模块的getApplicationInfo接口获取待检验的应用的ApplicaitonInfo,根据ApplicaitonInfo中systemApp字段判断,若为true,则是系统应用,否则为非系统应用。
使用bundle模块的getApplicationInfo接口获取待检验的应用的ApplicationInfo,根据ApplicationInfo中systemApp字段判断,若为true,则是系统应用,否则为非系统应用。
......@@ -3,4 +3,7 @@
- [媒体库开发概述](medialibrary-overview.md)
- [媒体资源使用指导](medialibrary-resource-guidelines.md)
- [文件路径使用指导](medialibrary-filepath-guidelines.md)
- [相册资源使用指导](medialibrary-album-guidelines.md)
\ No newline at end of file
- [相册资源使用指导](medialibrary-album-guidelines.md)
- 文件访问框架
- [用户公共文件访问框架概述](file-access-framework-overview.md)
\ No newline at end of file
# 用户公共文件访问框架概述
在搭载OpenHarmony 3.2 (API 9)及更高版本的设备上,应用可以基于FileAccessFramework(简称为FAF)对本地公共文件、分布式设备文件、外部存储设备文件、多用户共享文件进行访问。
出于对用户数据的隐私安全考虑,目前此框架仅支持用户通过**文件管理器****文件选择器**对文件访问服务端进行操作,包括创建、打开、删除、重命名、移动等。
应用卸载,不会影响到用户数据,实际用户数据仍保留在对应设备中。
其它系统应用如需要访问本地公共文件,请参考使用[媒体库接口](medialibrary-filepath-guidelines.md)
> **注意:**
> 1:如果应用是系统非管理类应用,比如:系统图库,请优先考虑直接使用媒体库接口,媒体库接口提供了一系列直接操作文件的接口。
> 2:FAF 接口与媒体库接口原则上不能混用。
## FileAccessFramework机制介绍
FAF依托于OpenHarmony上[ExtensionAbility机制](../application-models/extensionability-overview.md),实现了一套对外提供能力的统一接口。应用可以通过这套接口预览和操作公共文件,实现自己的逻辑。
有兴趣的开发者,可以预览我们的[源码仓](https://gitee.com/openharmony/filemanagement_user_file_service),提出您宝贵的意见。
基于FAF进行文件操作的全流程,包含以下几个元素,如图所示:
**图1 公共文件操作层次图**
![](figures/公共文件操作层次图.png)
- **文件访问客户端应用** - 需要访问或操作公共文件的应用。通过拉起文件选择器,用户可以在可视化界面上进行文件操作。
- **文件选择器应用** - 可以让用户访问所有共享数据集的系统应用。通过使用 FAF 的对上接口,完成各种文件操作。
- **文件访问服务端应用** - 系统内支持将数据集进行共享的服务。目前有[UserFileManager](https://gitee.com/openharmony/multimedia_medialibrary_standard)、ExternalFileManager等。前者管理了本地磁盘、分布式设备的数据集,后者管理了SD卡、U盘等多种外置存储设备的数据集。开发者也可以基于 FAF 的服务端配置,共享自己的数据集。
FAF提供的主要功能:
- 可以让用户浏览系统内所有文件服务端应用提供的数据集,而不仅仅是单一应用的数据集。
- 客户端应用不需要获取FAF的使用权限,直接通过选择器应用操作文件。
- 支持访问多个临时挂载的设备,比如外置存储卡、分布式设备等。
## 数据模型
FAF 中数据模型主要通过URI、FileInfo、RootInfo 进行传递。详情参考[fileExtension](../reference/apis/js-apis-fileExtensionInfo.md)。文件访问服务端应用可以通过 FileAccessExtensionAbility API,将自身的数据安全的共享出去。
**图2 公共文件访问框架数据流**
![](figures/公共文件访问框架数据流.png)
注意事项:
- 在FAF中,文件访问客户端和文件访问服务端并不直接交互。只需要具备拉起文件选择器应用的权限即可。
- 文件选择器应用会为用户提供标准的文档访问界面,即使底层的文件访问服务端相互之间差异很大,一致性也不受影响。
\ No newline at end of file
......@@ -8,7 +8,7 @@ AudioRoutingManager提供了音频路由、设备管理的方法。开发者可
该模块提供了路由、设备管理模块常用接口
**图1** 音量管理常用接口
**图1** 路由、设备管理常用接口
![zh-ch_image_audio_routing_manager](figures/zh-ch_image_audio_routing_manager.png)
......
......@@ -4,7 +4,7 @@
![zh-cn_image_0000001364254729](figures/zh-cn_image_0000001364254729.png)
在开始之前,您需要了解有关OpenHarmony应用的一些基本概念:UI框架的简单说明、Ability的基本概念。
在开始之前,您需要了解有关OpenHarmony应用的一些基本概念:UI框架的简单说明、应用模型的基本概念。
## 基本概念
......@@ -16,29 +16,25 @@ OpenHarmony提供了一套UI开发框架,即方舟开发框架(ArkUI框架
方舟开发框架针对不同目的和技术背景的开发者提供了两种开发范式,分别是基于ArkTS的声明式开发范式(简称“声明式开发范式”)和兼容JS的类Web开发范式(简称“类Web开发范式”)。以下是两种开发范式的简单对比。
| **开发范式名称** | **语言生态** | **UI更新方式** | **适用场景** | **适用人群** |
| -------- | -------- | -------- | -------- | -------- |
| 声明式开发范式 | ArkTS语言 | 数据驱动更新 | 复杂度较大、团队合作度较高的程序 | 移动系统应用开发人员、系统应用开发人员 |
| 类Web开发范式 | JS语言 | 数据驱动更新 | 界面较为简单的程序应用和卡片 | Web前端开发人员 |
| **开发范式名称** | **语言生态** | **UI更新方式** | **适用场景** | **适用人群** |
| ---------------- | ------------ | -------------- | -------------------------------- | -------------------------------------- |
| 声明式开发范式 | ArkTS语言 | 数据驱动更新 | 复杂度较大、团队合作度较高的程序 | 移动系统应用开发人员、系统应用开发人员 |
| 类Web开发范式 | JS语言 | 数据驱动更新 | 界面较为简单的程序应用和卡片 | Web前端开发人员 |
更多UI框架的开发内容及指导,详见[UI开发](../ui/arkui-overview.md)
### 应用模型
### Ability
应用模型是OpenHarmony为开发者提供的应用程序所需能力的抽象提炼,它提供了应用程序必备的组件和运行机制。有了应用模型,开发者可以基于一套统一的模型进行应用开发,使应用开发更简单、高效。请见[应用模型的构成要素](../application-models/application-model-composition.md)
Ability是应用所具备能力的抽象,也是应用程序的重要组成部分。一个应用可以具备多种能力(即可以包含多个Ability)。OpenHarmony支持应用以Ability为单位进行部署。
随着系统的演进发展,OpenHarmony先后提供了两种应用模型:
Ability框架模型结构具有两种形态:
- **FA(Feature Ability)模型:** OpenHarmony API 7开始支持的模型,已经不再主推。FA模型开发可见[FA模型开发概述](../application-models/fa-model-development-overview.md)
- **Stage模型:** OpenHarmony API 9开始新增的模型,是目前主推且会长期演进的模型。在该模型中,由于提供了AbilityStage、WindowStage等类作为应用组件和Window窗口的“舞台”,因此称这种应用模型为Stage模型。Stage模型开发可见[Stage模型开发概述](../application-models/stage-model-development-overview.md)
- **FA模型**:API 8及其更早版本的应用程序只能使用FA模型进行开发。更多FA模型的内容详见[FA模型综述](../ability/fa-brief.md)
FA模型和Stage模型的整体架构和设计思想等更多区别,请见[应用模型解读](../application-models/application-model-description.md)
- **Stage模型**:从API 9开始,Ability框架引入并支持使用Stage模型进行开发。更多Stage模型的内容详见[Stage模型综述](../ability/stage-brief.md)
FA模型和Stage模型的工程目录结构存在差异,Stage模型只支持使用ArkTS语言进行开发。
关于FA模型和Stage模型的整体架构和设计思想等更多区别,详见[Ability框架概述](../ability/ability-brief.md)
快速入门提供了一个含有两个页面的Ability的开发实例。更多Ability的开发内容及指导,请见[Ability开发](../ability/ability-brief.md)
快速入门提供了一个含有两个页面的开发实例,并使用了不同的开发语言或不同的应用模型进行开发,以便开发者理解以上基本概念及应用开发流程。
## 工具准备
......@@ -47,4 +43,4 @@ FA模型和Stage模型的工程目录结构存在差异,Stage模型只支持
2. 请参考[配置OpenHarmony SDK](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-setting-up-environment-0000001263160443),完成**DevEco Studio**的安装和开发环境配置。
完成上述操作及基本概念的理解后,可参照[使用ArkTS语言进行开发(Stage模型)](start-with-ets-stage.md)[使用ArkTS语言开发(FA模型)](start-with-ets-fa.md)[使用JS语言开发(FA模型)](../quick-start/start-with-js-fa.md)中的任一章节进行下一步体验和学习。
完成上述操作及基本概念的理解后,可参照[使用ArkTS语言进行开发(Stage模型)](start-with-ets-stage.md)[使用ArkTS语言开发(FA模型)](start-with-ets-fa.md)[使用JS语言开发(FA模型)](../quick-start/start-with-js-fa.md)中的任一章节进行下一步体验和学习。
\ No newline at end of file
......@@ -40,7 +40,7 @@
- **src &gt; main &gt; ets &gt; MainAbility &gt; pages &gt; index.ets**:pages列表中的第一个页面,即应用的首页入口。
- **src &gt; main &gt; ets &gt; MainAbility &gt; app.ets**:承载Ability生命周期。
- **src &gt; main &gt; resources**:用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。关于资源文件,详见[资源文件的分类](resource-categories-and-access.md#资源分类)
- **src &gt; main &gt; config.json**:模块配置文件。主要包含HAP包的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。具体的配置文件说明,详见[应用包结构配置文件的说明(FA模型)](package-structure.md)
- **src &gt; main &gt; config.json**:模块配置文件。主要包含HAP包的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。具体的配置文件说明,详见[FA模型应用程序包结构](application-package-structure-fa.md)
- **build-profile.json5**:当前的模块信息 、编译信息配置项,包括buildOption、targets配置等。
- **hvigorfile.ts**:模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。
......
......@@ -38,7 +38,7 @@
- **src &gt; main &gt; ets &gt; entryability**:应用/服务的入口。
- **src &gt; main &gt; ets &gt; pages**:应用/服务包含的页面。
- **src &gt; main &gt; resources**:用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。关于资源文件,详见[资源文件的分类](resource-categories-and-access.md#资源分类)
- **src &gt; main &gt; module.json5**:模块配置文件。主要包含HAP包的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。具体的配置文件说明,详见[应用包结构配置文件的说明(Stage模型)](stage-structure.md)
- **src &gt; main &gt; module.json5**:模块配置文件。主要包含HAP包的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。具体的配置文件说明,详见[Stage模型应用程序包结构](application-package-structure-stage.md)
- **build-profile.json5**:当前的模块信息 、编译信息配置项,包括buildOption、targets配置等。
- **hvigorfile.ts**:模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。
......
......@@ -39,7 +39,7 @@
- **src &gt; main &gt; js &gt; MainAbility &gt; app.js**:承载Ability生命周期。
- **src &gt; main &gt; resources**:用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。关于资源文件,详见[资源限定与访问](../ui/js-framework-resource-restriction.md)
- **src &gt; main &gt; config.json**:模块配置文件。主要包含HAP包的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。具体的配置文件说明,详见[应用包结构配置文件的说明(FA模型)](package-structure.md)
- **src &gt; main &gt; config.json**:模块配置文件。主要包含HAP包的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。具体的配置文件说明,详见[FA模型应用程序包结构](application-package-structure-fa.md)
- **build-profile.json5**:当前的模块信息 、编译信息配置项,包括buildOption、targets配置等。
- **hvigorfile.ts**:模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。
......
......@@ -24,6 +24,8 @@ onAdminEnabled(): void
**系统能力**:SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**示例:**
```ts
......@@ -41,6 +43,8 @@ onAdminDisabled(): void
**系统能力**:SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**示例:**
```ts
......
......@@ -6,6 +6,12 @@ Want是对象间信息传递的载体, 可以用于应用组件间的信息传
>
> 本模块首批接口从API version 6开始支持,从API version 9废弃,替换模块为[Want (Want)](js-apis-app-ability-Want.md)。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```ts
import Want from '@ohos.application.Want'
```
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase
| 名称 | 可读 | 可写 | 类型 | 必填 | 说明 |
......
......@@ -2,6 +2,16 @@
定义ability拉起、销毁之后返回的结果码和数据。
> **说明:**
>
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```ts
import AbilityResult from '@ohos.ability.ability'
```
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase
| 名称 | 可读 | 可写 | 类型 | 必填 | 说明 |
......
......@@ -375,7 +375,7 @@ getPermissionFlags(tokenID: number, permissionName: Permissions): Promise&lt;num
| 12100001 | The parameter is invalid. The tokenID is 0 |
| 12100002 | The specified tokenID does not exist. |
| 12100003 | The specified permission does not exist. |
| 12100006 | The operation is not allowd. Either the application is a sandbox or the tokenID is from a remote device. |
| 12100006 | The operation is not allowed. Either the application is a sandbox or the tokenID is from a remote device. |
| 12100007 | Service is abnormal. |
**示例:**
......
......@@ -72,7 +72,7 @@ reset(options: AnimatorOptions): void
| 错误码ID | 错误信息 |
| --------- | ------- |
| 100001 | Internal error. |
| 100001 | If no page is found for pageId or fail to get object property list. |
**示例:**
......
......@@ -17,7 +17,7 @@ import StartOptions from '@ohos.app.ability.StartOptions';
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 可读 | 可写 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | -------- | -------- |
| [windowMode](js-apis-app-ability-abilityConstant.md#abilityconstantwindowmode) | 是 | 否 | number | 否 | 窗口模式。 |
| displayId | 是 | 否 | number | 否 | 显示ID。 |
| 名称 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| [windowMode](js-apis-window.md#windowmodesup7sup) | number | 否 | 窗口模式。 |
| displayId | number | 否 | 显示ID。 |
......@@ -6,6 +6,12 @@ Want是对象间信息传递的载体, 可以用于应用组件间的信息传
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```ts
import Want from '@ohos.app.ability.Want'
```
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase
| 名称 | 可读 | 可写 | 类型 | 必填 | 说明 |
......
......@@ -70,7 +70,7 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant';
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 值 | 说明 |
| 名称 | 值 | 说明 |
| --- | --- | --- |
| WINDOW_MODE_UNDEFINED | 0 | 未定义窗口模式。 |
| WINDOW_MODE_FULLSCREEN | 1 | 全屏模式。 |
......@@ -84,7 +84,7 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant';
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 值 | 说明 |
| 名称 | 值 | 说明 |
| --- | --- | --- |
| MEMORY_LEVEL_MODERATE | 0 | 内存占用适中。 |
| MEMORY_LEVEL_LOW | 1 | 内存占用低。 |
......
......@@ -6,6 +6,12 @@ AbilityDelegator提供添加用于监视指定ability的生命周期状态更改
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```ts
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'
```
## 使用说明
通过AbilityDelegatorRegistry中getAbilityDelegator方法获取。
......
......@@ -6,6 +6,12 @@ AbilityMonitor模块提供匹配满足指定条件的受监视能力对象的方
>
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```ts
import AbilityMonitor from '@ohos.app.ability.abilityDelegatorRegistry'
```
## 使用说明
通过abilityDelegator中的addAbilityMonitor来设置。
......
......@@ -68,7 +68,7 @@ onAcceptWant(want: Want): string;
## AbilityStage.onConfigurationUpdate
onConfigurationUpdate(config: Configuration): void;
onConfigurationUpdate(newConfig: Configuration): void;
环境变化通知接口,发生全局配置变更时回调。
......@@ -78,7 +78,7 @@ onConfigurationUpdate(config: Configuration): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | 是 | 发生全局配置变更时触发回调,当前全局配置包括系统语言、深浅色模式。 |
| newConfig | [Configuration](js-apis-configuration.md) | 是 | 发生全局配置变更时触发回调,当前全局配置包括系统语言、深浅色模式。 |
**示例:**
......
......@@ -21,10 +21,10 @@ import appRecovery from '@ohos.app.ability.appRecovery'
| 名称 | 值 | 说明 |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| ALWAYS_RESTART | 0 | 总是重启应用。 |
| CPP_CRASH_NO_RESTART | 1 | 发生CPP_CRASH时不重启应用。 |
| JS_CRASH_NO_RESTART | 2 | 发生JS_CRASH时不重启应用。 |
| APP_FREEZE_NO_RESTART | 4 | 发生APP_FREEZE时不重启应用。 |
| NO_RESTART | 65535 | 总是不重启应用。 |
| CPP_CRASH_NO_RESTART | 0x0001 | 发生CPP_CRASH时不重启应用。 |
| JS_CRASH_NO_RESTART | 0x0002 | 发生JS_CRASH时不重启应用。 |
| APP_FREEZE_NO_RESTART | 0x0004 | 发生APP_FREEZE时不重启应用。 |
| NO_RESTART | 0xFFFF | 总是不重启应用。 |
## appRecovery.SaveOccasionFlag
......@@ -34,8 +34,8 @@ import appRecovery from '@ohos.app.ability.appRecovery'
| 名称 | 值 | 说明 |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| SAVE_WHEN_ERROR | 1 | 当发生应用故障时保存。 |
| SAVE_WHEN_BACKGROUND | 2 | 当应用切入后台时保存。 |
| SAVE_WHEN_ERROR | 0x0001 | 当发生应用故障时保存。 |
| SAVE_WHEN_BACKGROUND | 0x0002 | 当应用切入后台时保存。 |
## appRecovery.SaveModeFlag
......@@ -45,8 +45,8 @@ import appRecovery from '@ohos.app.ability.appRecovery'
| 名称 | 值 | 说明 |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| SAVE_WITH_FILE | 1 | 每次状态保存都会写入到本地文件缓存。 |
| SAVE_WITH_SHARED_MEMORY | 2 | 状态先保存在内存中,应用故障退出时写入到本地文件缓存。 |
| SAVE_WITH_FILE | 0x0001 | 每次状态保存都会写入到本地文件缓存。 |
| SAVE_WITH_SHARED_MEMORY | 0x0002 | 状态先保存在内存中,应用故障退出时写入到本地文件缓存。 |
## appRecovery.enableAppRecovery
......
......@@ -200,7 +200,7 @@ getProcessRunningInformation(callback: AsyncCallback\<Array\<ProcessRunningInfor
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback\<Array\<[ProcessRunningInformation](#processrunninginformation)>> | | 获取有关运行进程的信息。 |
| callback | AsyncCallback\<Array\<[ProcessRunningInformation](#processrunninginformation)>> | | 获取有关运行进程的信息。 |
**示例:**
......@@ -404,7 +404,7 @@ getForegroundApplications(callback: AsyncCallback\<Array\<AppStateData>>): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback\<Array\<AppStateData>> | 是 | 表示应用的状态数据。 |
| callback | AsyncCallback\<Array\<AppStateData>> | 是 | 表示应用的状态数据。 |
**示例:**
......@@ -685,13 +685,234 @@ clearUpApplicationData(bundleName: string): Promise\<void>;
```
## ApplicationStateObserver.onForegroundApplicationChanged
onForegroundApplicationChanged(appStateData: AppStateData): void;
将在前台或后台应用程序更改时调用。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**系统API**:该接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| appStateData | [AppStateData](#appstatedata) | 否 | 状态更改的应用程序信息。 |
**示例:**
```js
var applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
console.log('------------ onForegroundApplicationChanged -----------', appStateData);
},
onAbilityStateChanged(abilityStateData) {
console.log('------------ onAbilityStateChanged -----------', abilityStateData);
},
onProcessCreated(processData) {
console.log('------------ onProcessCreated -----------', processData);
},
onProcessDied(processData) {
console.log('------------ onProcessDied -----------', processData);
},
onProcessStateChanged(processData) {
console.log('------------ onProcessStateChanged -----------', processData);
}
}
try {
const observerCode = app.on("applicationState", applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode);
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
## ApplicationStateObserver.onAbilityStateChanged
onAbilityStateChanged(abilityStateData: AbilityStateData): void;
将在能力状态更改时调用。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**系统API**:该接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| abilityStateData | [AbilityStateData](#abilitystatedata) | 否 | 状态更改的能力信息。 |
**示例:**
```js
var applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
console.log('------------ onForegroundApplicationChanged -----------', appStateData);
},
onAbilityStateChanged(abilityStateData) {
console.log('------------ onAbilityStateChanged -----------', abilityStateData);
},
onProcessCreated(processData) {
console.log('------------ onProcessCreated -----------', processData);
},
onProcessDied(processData) {
console.log('------------ onProcessDied -----------', processData);
},
onProcessStateChanged(processData) {
console.log('------------ onProcessStateChanged -----------', processData);
}
}
try {
const observerCode = app.on("applicationState", applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode);
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
## ApplicationStateObserver.onProcessCreated
onProcessCreated(processData: ProcessData): void;
将在创建进程时调用。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**系统API**:该接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| processData | [ProcessData](#processdata) | 否 | 进程信息。 |
**示例:**
```js
var applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
console.log('------------ onForegroundApplicationChanged -----------', appStateData);
},
onAbilityStateChanged(abilityStateData) {
console.log('------------ onAbilityStateChanged -----------', abilityStateData);
},
onProcessCreated(processData) {
console.log('------------ onProcessCreated -----------', processData);
},
onProcessDied(processData) {
console.log('------------ onProcessDied -----------', processData);
},
onProcessStateChanged(processData) {
console.log('------------ onProcessStateChanged -----------', processData);
}
}
try {
const observerCode = app.on("applicationState", applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode);
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
## ApplicationStateObserver.onProcessDied
onProcessDied(processData: ProcessData): void;
将在进程终止时调用。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**系统API**:该接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| processData | [ProcessData](#processdata) | 否 | 进程信息。 |
**示例:**
```js
var applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
console.log('------------ onForegroundApplicationChanged -----------', appStateData);
},
onAbilityStateChanged(abilityStateData) {
console.log('------------ onAbilityStateChanged -----------', abilityStateData);
},
onProcessCreated(processData) {
console.log('------------ onProcessCreated -----------', processData);
},
onProcessDied(processData) {
console.log('------------ onProcessDied -----------', processData);
},
onProcessStateChanged(processData) {
console.log('------------ onProcessStateChanged -----------', processData);
}
}
try {
const observerCode = app.on("applicationState", applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode);
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
## ApplicationStateObserver.onProcessStateChanged
onProcessStateChanged(processData: ProcessData): void;
当进程状态更改时调用。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**系统API**:该接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| processData | [ProcessData](#processdata) | 否 | 进程信息。 |
**示例:**
```js
var applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
console.log('------------ onForegroundApplicationChanged -----------', appStateData);
},
onAbilityStateChanged(abilityStateData) {
console.log('------------ onAbilityStateChanged -----------', abilityStateData);
},
onProcessCreated(processData) {
console.log('------------ onProcessCreated -----------', processData);
},
onProcessDied(processData) {
console.log('------------ onProcessDied -----------', processData);
},
onProcessStateChanged(processData) {
console.log('------------ onProcessStateChanged -----------', processData);
}
}
try {
const observerCode = app.on("applicationState", applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode);
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
## AppStateData
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
**系统API**:该接口为系统接口,三方应用不支持调用。
| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 |
| 名称 | 可读 | 可写 | 类型 | 必填 | 说明 |
| ----------- | -------- |-------- | -------------------- | ---- | ------------------------------------------------------------ |
| bundleName | 是 | 否 | string | 否 | 包名。 |
| uid | 是 | 否 | number | 否 | 用户ID。 |
......@@ -731,7 +952,7 @@ clearUpApplicationData(bundleName: string): Promise\<void>;
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Mission
| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 |
| 名称 | 可读 | 可写 | 类型 | 必填 | 说明 |
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| pid | 是 | 否 | number | 否 | 进程ID。 |
| uid | 是 | 否 | number | 否 | 用户ID。 |
......@@ -757,7 +978,7 @@ clearUpApplicationData(bundleName: string): Promise\<void>;
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 |
| 名称 | 可读 | 可写 | 类型 | 必填 | 说明 |
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| pid | 是 | 否 | number | 否 | 进程ID。 |
| uid | 是 | 否 | number | 否 | 用户ID。 |
......@@ -770,7 +991,7 @@ clearUpApplicationData(bundleName: string): Promise\<void>;
**系统API**: 此接口为系统接口,三方应用不支持调用。
| 名称 | 值 | 描述 |
| 名称 | 值 | 说明 |
| -------------------- | --- | --------------------------------- |
| STATE_CREATE | 1 | 当应用在创建中的时候处于的状态。 |
| STATE_FOREGROUND | 2 | 当应用切换到前台的时候处于的状态。 |
......@@ -784,7 +1005,7 @@ clearUpApplicationData(bundleName: string): Promise\<void>;
**系统API**: 此接口为系统接口,三方应用不支持调用。
| 名称 | 值 | 描述 |
| 名称 | 值 | 说明 |
| -------------------- | --- | --------------------------------- |
| STATE_CREATE | 1 | 当进程在创建中的时候处于的状态。 |
| STATE_FOREGROUND | 2 | 当进程切换到前台的时候处于的状态。 |
......
......@@ -6,6 +6,12 @@
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```ts
import Configuration from '@ohos.app.ability.Configuration'
```
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase
| 名称 | 类型 | 可读 | 可写 | 说明 |
......
......@@ -111,4 +111,29 @@ try {
console.log("error: " + paramError.code + ", " + paramError.message);
}
```
## ErrorObserver
onUnhandledException(errMsg: string): void;
将在js运行时引发用户未捕获的异常时调用。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| errMsg | string | 否 | 有关异常的消息和错误堆栈跟踪。 |
**示例:**
```js
var observer = {
onUnhandledException(errorMsg) {
console.log('onUnhandledException, errorMsg: ', errorMsg)
}
}
errorManager.on(observer)
```
\ No newline at end of file
......@@ -20,11 +20,11 @@ hap级别的快速修复信息。
**系统API**: 此接口为系统接口,三方应用不支持调用。
| 名称 | 可读 | 可写 | 类型 | 必填 | 说明 |
| ----------- | -------- |-------- | -------------------- | ---- | ------------------------------------------------------------ |
| moduleName | 是 | 否 | string | 是 | hap包的名称。 |
| originHapHash | 是 | 否 | string | 是 | 指示hap的哈希值。 |
| quickFixFilePath | 是 | 否 | string | 是 | 指示快速修复文件的安装路径。 |
| 名称 | 类型 | 必填 | 说明 |
| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
| moduleName | string | 是 | hap包的名称。 |
| originHapHash | string | 是 | 指示hap的哈希值。 |
| quickFixFilePath | string | 是 | 指示快速修复文件的安装路径。 |
## ApplicationQuickFixInfo
......@@ -34,14 +34,14 @@ hap级别的快速修复信息。
**系统API**: 此接口为系统接口,三方应用不支持调用。
| 名称 | 可读 | 可写 | 类型 | 必填 | 说明 |
| ----------- | -------- |-------- | -------------------- | ---- | ------------------------------------------------------------ |
| bundleName | 是 | 否 | string | 是 | 应用的包名。 |
| bundleVersionCode | 是 | 否 | number | 是 | 应用的版本号。 |
| bundleVersionName | 是 | 否 | string | 是 | 应用版本号的文字描述。 |
| quickFixVersionCode | 是 | 否 | number | 是 | 快速修复补丁包的版本号。 |
| quickFixVersionName | 是 | 否 | string | 是 | 快速修复补丁包版本号的文字描述。 |
| hapModuleQuickFixInfo | 是 | 否 | Array\<[HapModuleQuickFixInfo](#hapmodulequickfixinfo)> | 是 | hap级别的快速修复信息。 |
| 名称 | 类型 | 必填 | 说明 |
| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
| bundleName | string | 是 | 应用的包名。 |
| bundleVersionCode | number | 是 | 应用的版本号。 |
| bundleVersionName | string | 是 | 应用版本号的文字描述。 |
| quickFixVersionCode | number | 是 | 快速修复补丁包的版本号。 |
| quickFixVersionName | string | 是 | 快速修复补丁包版本号的文字描述。 |
| hapModuleQuickFixInfo | Array\<[HapModuleQuickFixInfo](#hapmodulequickfixinfo)> | 是 | hap级别的快速修复信息。 |
## quickFixManager.applyQuickFix
......
......@@ -200,7 +200,7 @@ onReconnect(want: Want): void;
## ServiceExtensionAbility.onConfigurationUpdate
onConfigurationUpdate(config: Configuration): void;
onConfigurationUpdate(newConfig: Configuration): void;
当Extension更新配置信息时调用。
......@@ -212,7 +212,7 @@ onConfigurationUpdate(config: Configuration): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | 是 | 表示需要更新的配置信息。 |
| newConfig | [Configuration](js-apis-configuration.md) | 是 | 表示需要更新的配置信息。 |
**示例:**
......
......@@ -740,7 +740,7 @@ try {
## WantAgent.trigger
trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: Callback\<CompleteData\>): void
trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback\<CompleteData\>): void
主动激发WantAgent实例(callback形式)。
......@@ -752,7 +752,7 @@ trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: Callback\<Complet
| ----------- | ----------------------------- | ---- | ------------------------------- |
| agent | WantAgent | 是 | WantAgent对象。 |
| triggerInfo | TriggerInfo | 是 | TriggerInfo对象。 |
| callback | AsyncCallback\<CompleteData\> | | 主动激发WantAgent实例的回调方法。 |
| callback | AsyncCallback\<CompleteData\> | | 主动激发WantAgent实例的回调方法。 |
**示例:**
......@@ -1116,13 +1116,13 @@ try {
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 |
| -------------- | --- | ---- | ------------------------------- | ---- | ---------------------- |
| wants | 是 | 是 | Array\<Want\> | 是 | 将被执行的动作列表。 |
| operationType | 是 | 是 | wantAgent.OperationType | 是 | 动作类型。 |
| requestCode | 是 | 是 | number | 是 | 使用者定义的一个私有值。 |
| wantAgentFlags | 是 | 是 | Array<wantAgent.WantAgentFlags> | 否 | 动作执行属性。 |
| extraInfo | 是 | 是 | {[key: string]: any} | 否 | 额外数据。 |
| 名称 | 类型 | 必填 | 说明 |
| -------------- | ------------------------------- | ---- | ---------------------- |
| wants | Array\<Want\> | 是 | 将被执行的动作列表。 |
| operationType | wantAgent.OperationType | 是 | 动作类型。 |
| requestCode | number | 是 | 使用者定义的一个私有值。 |
| wantAgentFlags | Array<wantAgent.WantAgentFlags> | 否 | 动作执行属性。 |
| extraInfo | {[key: string]: any} | 否 | 额外数据。 |
......@@ -1163,13 +1163,13 @@ try {
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 |
| -------------- | --- | ---- | ------------------------------ | ---- | ---------------------- |
| info | 是 | 是 | WantAgent | 是 | 触发的wantAgent。 |
| want | 是 | 是 | Want | 是 | 存在的被触发的want。 |
| finalCode | 是 | 是 | number | 是 | 触发wantAgent的请求代码。|
| finalData | 是 | 是 | string | 否 | 公共事件收集的最终数据。 |
| extraInfo | 是 | 是 | {[key: string]: any} | 否 | 额外数据。 |
| 名称 | 类型 | 必填 | 说明 |
| -------------- | ------------------------------ | ---- | ---------------------- |
| info | WantAgent | 是 | 触发的wantAgent。 |
| want | Want | 是 | 存在的被触发的want。 |
| finalCode | number | 是 | 触发wantAgent的请求代码。|
| finalData | string | 否 | 公共事件收集的最终数据。 |
| extraInfo | {[key: string]: any} | 否 | 额外数据。 |
......@@ -1177,9 +1177,9 @@ try {
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 |
| ---------- | --- | ---- | -------------------- | ---- | ----------- |
| code | 是 | 是 | number | 是 | result code。 |
| want | 是 | 是 | Want | 否 | Want。 |
| permission | 是 | 是 | string | 否 | 权限定义。 |
| extraInfo | 是 | 是 | {[key: string]: any} | 否 | 额外数据。 |
\ No newline at end of file
| 名称 | 类型 | 必填 | 说明 |
| ---------- | -------------------- | ---- | ----------- |
| code | number | 是 | result code。 |
| want | Want | 否 | Want。 |
| permission | string | 否 | 权限定义。 |
| extraInfo | {[key: string]: any} | 否 | 额外数据。 |
\ No newline at end of file
......@@ -43,17 +43,17 @@ want操作的常数。
| ACTION_EDIT_DATA | ohos.want.action.editData | 指示编辑数据的操作。 |
| INTENT_PARAMS_INTENT | ability.want.params.INTENT | 指示用行为选择器来展示选择的操作。 |
| INTENT_PARAMS_TITLE | ability.want.params.TITLE | 指示与行为选择器一起使用时的字符序列对话框标题。 |
| ACTION_FILE_SELECT<sup>7+</sup> | ohos.action.fileSelect | 指示选择文件的操作。 |
| PARAMS_STREAM<sup>7+</sup> | ability.params.stream | 指示发送数据时与目标关联的数据流的URI |
| ACTION_APP_ACCOUNT_OAUTH <sup>8+</sup> | ohos.account.appAccount.action.oauth | 指示提供oauth服务的操作。 |
| ACTION_APP_ACCOUNT_AUTH <sup>9+</sup> | account.appAccount.action.auth | 指示提供auth服务的操作。 |
| ACTION_MARKET_DOWNLOAD <sup>9+</sup> | ohos.want.action.marketDownload | 表示从应用程序市场下载应用程序的的操作。<br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| ACTION_MARKET_CROWDTEST <sup>9+</sup> | ohos.want.action.marketCrowdTest | 指示从应用程序市场众测应用程序的操作。<br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| DLP_PARAMS_SANDBOX<sup>9+</sup> |ohos.dlp.params.sandbox | 指示沙盒标志的参数的操作。<br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| DLP_PARAMS_BUNDLE_NAME<sup>9+</sup> |ohos.dlp.params.bundleName |指示DLP包名称的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| DLP_PARAMS_MODULE_NAME<sup>9+</sup> |ohos.dlp.params.moduleName |指示DLP模块名称的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| DLP_PARAMS_ABILITY_NAME<sup>9+</sup> |ohos.dlp.params.abilityName |指示DLP能力名称的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| DLP_PARAMS_INDEX<sup>9+</sup> |ohos.dlp.params.index |指示DLP索引参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| ACTION_FILE_SELECT | ohos.action.fileSelect | 指示选择文件的操作。 |
| PARAMS_STREAM | ability.params.stream | 指示发送数据时与目标关联的数据流的URI |
| ACTION_APP_ACCOUNT_OAUTH | ohos.account.appAccount.action.oauth | 指示提供oauth服务的操作。 |
| ACTION_APP_ACCOUNT_AUTH | account.appAccount.action.auth | 指示提供auth服务的操作。 |
| ACTION_MARKET_DOWNLOAD | ohos.want.action.marketDownload | 表示从应用程序市场下载应用程序的的操作。<br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| ACTION_MARKET_CROWDTEST | ohos.want.action.marketCrowdTest | 指示从应用程序市场众测应用程序的操作。<br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| DLP_PARAMS_SANDBOX |ohos.dlp.params.sandbox | 指示沙盒标志的参数的操作。<br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| DLP_PARAMS_BUNDLE_NAME |ohos.dlp.params.bundleName |指示DLP包名称的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| DLP_PARAMS_MODULE_NAME |ohos.dlp.params.moduleName |指示DLP模块名称的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| DLP_PARAMS_ABILITY_NAME |ohos.dlp.params.abilityName |指示DLP能力名称的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| DLP_PARAMS_INDEX |ohos.dlp.params.index |指示DLP索引参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
## wantConstant.Entity
......
......@@ -18,9 +18,9 @@ FormBindingData相关描述。
**系统能力**:SystemCapability.Ability.Form
| 名称 | 可读 | 可写 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | -------- | -------- |
| data | 是 | 否 | Object | 是 | js卡片要展示的数据。可以是包含若干键值对的Object或者 json 格式的字符串。|
| 名称 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| data | Object | 是 | js卡片要展示的数据。可以是包含若干键值对的Object或者 json 格式的字符串。|
## createFormBindingData
......@@ -35,7 +35,7 @@ createFormBindingData(obj?: Object | string): FormBindingData
| 参数名 | 类型 | 必填 | 说明 |
| ------ | -------------- | ---- | ------------------------------------------------------------ |
| obj | Objectstring | 否 | js卡片要展示的数据。可以是包含若干键值对的Object或者 json 格式的字符串。其中图片数据以"formImages"作为标识,内容为图片标识与图片文件描述符的键值对{"formImages": {"key1": fd1, "key2": fd2}} |
| obj | Object\|string | 否 | js卡片要展示的数据。可以是包含若干键值对的Object或者 json 格式的字符串。其中图片数据以"formImages"作为标识,内容为图片标识与图片文件描述符的键值对{"formImages": {"key1": fd1, "key2": fd2}} |
**返回值:**
......
......@@ -17,7 +17,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
**系统能力**:SystemCapability.Ability.Form
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ------- | ------------------------------------------------------- | ---- | ---- | --------------------------------------------------- |
| context | [FormExtensionContext](js-apis-formextensioncontext.md) | 是 | 否 | FormExtensionAbility的上下文环境,继承自ExtensionContext。 |
......@@ -197,7 +197,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
## onConfigurationUpdate
onConfigurationUpdate(newconfig: Configuration): void;
onConfigurationUpdate(newConfig: Configuration): void;
当系统配置更新时调用。
......@@ -207,7 +207,7 @@ onConfigurationUpdate(newconfig: Configuration): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| newconfig | [Configuration](js-apis-configuration.md) | 是 | 表示需要更新的配置信息。 |
| newConfig | [Configuration](js-apis-configuration.md) | 是 | 表示需要更新的配置信息。 |
**示例:**
......
......@@ -18,26 +18,26 @@ import formInfo from '@ohos.app.form.formInfo';
**系统能力**:SystemCapability.Ability.Form
| 名称 | 可读 | 可写 | 类型 | 说明 |
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ----------- | -------- | -------- | -------------------- | ------------------------------------------------------------ |
| bundleName | 是 | 否 | string | 卡片所属包的包名。 |
| moduleName | 是 | 否 | string | 卡片所属模块的模块名。 |
| abilityName | 是 | 否 | string | 卡片所属的Ability名称。 |
| name | 是 | 否 | string | 卡片名称。 |
| description | 是 | 否 | string | 卡片描述。 |
| type | 是 | 否 | [FormType](#formtype) | 卡片类型。当前支持JS卡片。 |
| jsComponentName | 是 | 否 | string | js卡片的组件名。 |
| colorMode | 是 | 否 | [ColorMode](#colormode) | 卡片颜色模式。 |
| isDefault | 是 | 否 | boolean | 卡片是否是默认卡片。 |
| updateEnabled | 是 | 否 | boolean | 卡片是否使能更新。 |
| formVisibleNotify | 是 | 否 | string | 卡片是否使能可见通知。 |
| relatedBundleName | 是 | 否 | string | 卡片所属的相关联包名。 |
| scheduledUpdateTime | 是 | 否 | string | 卡片更新时间。 |
| formConfigAbility | 是 | 否 | string | 卡片配置ability。指定长按卡片弹出的选择框内,编辑选项所对应的ability。 |
| updateDuration | 是 | 否 | string | 卡片更新周期。 |
| defaultDimension | 是 | 否 | number | 表示卡片规格 |
| supportDimensions | 是 | 否 | Array&lt;number&gt; | 卡片支持的规格。具体可选规格参考[FormDimension](#formdimension) |
| customizeData | 是 | 否 | {[key: string]: [value: string]} | 卡片用户数据。 |
| bundleName | string | 是 | 否 | 卡片所属包的包名。 |
| moduleName | string | 是 | 否 | 卡片所属模块的模块名。 |
| abilityName | string | 是 | 否 | 卡片所属的Ability名称。 |
| name | string | 是 | 否 | 卡片名称。 |
| description | string | 是 | 否 | 卡片描述。 |
| type | [FormType](#formtype) | 是 | 否 | 卡片类型。当前支持JS卡片。 |
| jsComponentName | string | 是 | 否 | js卡片的组件名。 |
| colorMode | [ColorMode](#colormode) | 是 | 否 | 卡片颜色模式。 |
| isDefault | boolean | 是 | 否 | 卡片是否是默认卡片。 |
| updateEnabled | boolean | 是 | 否 | 卡片是否使能更新。 |
| formVisibleNotify | string | 是 | 否 | 卡片是否使能可见通知。 |
| relatedBundleName | string | 是 | 否 | 卡片所属的相关联包名。 |
| scheduledUpdateTime | string | 是 | 否 | 卡片更新时间。 |
| formConfigAbility | string | 是 | 否 | 卡片配置ability。指定长按卡片弹出的选择框内,编辑选项所对应的ability。 |
| updateDuration | string | 是 | 否 | 卡片更新周期。 |
| defaultDimension | number | 是 | 否 | 表示卡片规格 |
| supportDimensions | Array&lt;number&gt; | 是 | 否 | 卡片支持的规格。具体可选规格参考[FormDimension](#formdimension) |
| customizeData | {[key: string]: [value: string]} | 是 | 否 | 卡片用户数据。 |
## FormType
......@@ -68,10 +68,10 @@ import formInfo from '@ohos.app.form.formInfo';
**系统能力**:SystemCapability.Ability.Form
| 名称 | 可读 | 可写 | 类型 | 说明 |
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ----------- | -------- | -------- | -------------------- | ------------------------------------------------------------ |
| formState | 是 | 否 | [FormState](#formstate) | 卡片状态。 |
| want | 是 | 否 | Want | Want文本内容。 |
| formState | [FormState](#formstate) | 是 | 否 | 卡片状态。 |
| want | Want | 是 | 否 | Want文本内容。 |
## FormState
......@@ -125,9 +125,9 @@ import formInfo from '@ohos.app.form.formInfo';
**系统能力**:SystemCapability.Ability.Form
| 名称 | 必选 | 说明 |
| ----------- | ---- | ------------ |
| moduleName | 否 | 仅保留moduleName与提供值相符的卡片信息。 |
| 名称 | 说明 |
| ----------- | ------------ |
| moduleName | 仅保留moduleName与提供值相符的卡片信息。 |
## VisibilityType
......@@ -137,5 +137,5 @@ import formInfo from '@ohos.app.form.formInfo';
| 名称 | 值 | 说明 |
| ----------- | ---- | ------------ |
| FORM_VISIBLE | 否 | 表示卡片为可见。 |
| FORM_INVISIBLE | 否 | 表示卡片为不可见。 |
\ No newline at end of file
| FORM_VISIBLE | 1 | 表示卡片为可见。 |
| FORM_INVISIBLE | 2 | 表示卡片为不可见。 |
\ No newline at end of file
......@@ -15,7 +15,7 @@ import ExtensionAbility from '@ohos.application.ExtensionAbility';
## AbilityStage.onConfigurationUpdated
onConfigurationUpdated(newconfig: Configuration): void;
onConfigurationUpdated(newConfig: Configuration): void;
环境变化通知接口,发生全局配置变更时回调。
......@@ -25,7 +25,7 @@ onConfigurationUpdated(newconfig: Configuration): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| newconfig | [Configuration](js-apis-configuration.md) | 是 | 发生全局配置变更时触发回调,当前全局配置包括系统语言、深浅色模式。 |
| newConfig | [Configuration](js-apis-configuration.md) | 是 | 发生全局配置变更时触发回调,当前全局配置包括系统语言、深浅色模式。 |
**示例:**
......
......@@ -17,7 +17,7 @@ import StartOptions from '@ohos.application.StartOptions';
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 可读 | 可写 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | -------- | -------- |
| [windowMode](js-apis-application-abilityConstant.md#abilityconstantwindowmode) | 是 | 否 | number | 否 | 窗口模式。 |
| displayId | 是 | 否 | number | 否 | 显示ID。 |
| 名称 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| [windowMode](js-apis-application-abilityConstant.md#abilityconstantwindowmode) | number | 否 | 窗口模式。 |
| displayId | number | 否 | 显示ID。 |
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册