** component.
-### Objects to Import
+#### Objects to Import
```
@@ -86,7 +86,7 @@ controller: TextInputController = new TextInputController()
```
-### caretPosition
+#### caretPosition
caretPosition(value: number): void
@@ -113,10 +113,9 @@ struct TextInputExample1 {
build() {
Column() {
- TextArea({ placeholder: 'input your word' })
+ TextInput({ placeholder: 'input your word' })
.placeholderColor("rgb(0,0,225)")
.placeholderFont({ size: 30, weight: 100, family: 'cursive', style: FontStyle.Italic })
- .textAlign(TextAlign.Center)
.caretColor(Color.Blue)
.height(50)
.fontSize(30)
diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-web.md b/en/application-dev/reference/arkui-ts/ts-basic-components-web.md
index 068f19a35f1275818b5a8beec11ad9f60236af73..b0348580d7af8e571c2e11f941c05c8468575984 100644
--- a/en/application-dev/reference/arkui-ts/ts-basic-components-web.md
+++ b/en/application-dev/reference/arkui-ts/ts-basic-components-web.md
@@ -48,7 +48,7 @@ Not supported
| textZoomAtio | number | 100 | Text zoom ratio of the page. The default value is **100**, which indicates 100%. |
| userAgent | string | - | User agent. |
-> **NOTE**
+> **NOTE**
>
> Only the following universal attributes are supported: [width](ts-universal-attributes-size.md#Attributes), [height](ts-universal-attributes-size.md#Attributes), [padding](ts-universal-attributes-size.md#Attributes), [margin](ts-universal-attributes-size.md#Attributes), and [border](ts-universal-attributes-border.md#Attributes).
@@ -74,97 +74,85 @@ The universal events are not supported.
| onShowFileSelector(callback: (event?: { result: [FileSelectorResult](#fileselectorresult), fileSelector: [FileSelectorParam](#fileselectorparam) }) => void) | Triggered to process an HTML form whose input type is **file**, in response to the tapping of the **Select File** button.
**result**: file selection result to be sent to the web component.
**fileSelector**: information about the file selector.
|
| onUrlLoadIntercept(callback: (event?: { data:string \| [WebResourceRequest](#webresourcerequest) }) => boolean) | Triggered before the **\** component loads the URL to determine whether to block the access. The callback returns **true** if the access is blocked, and **false** otherwise.
**data**: URL information.
|
-### ConsoleMessage
-
-- APIs
+## ConsoleMessage
- | Name | Description |
- | ------------------------------- | ---------------------- |
- | getLineNumber(): number | Obtains the number of rows in the **ConsoleMessage**. |
- | getMessage(): string | Obtains the log information of the **ConsoleMessage**.|
- | getMessageLevel(): MessageLevel | Obtains the log information level of the **ConsoleMessage**.|
- | getSourceId(): string | Obtains the path and name of the web page source file. |
+| Name | Description |
+| ------------------------------- | ---------------------- |
+| getLineNumber(): number | Obtains the number of rows in the **ConsoleMessage**. |
+| getMessage(): string | Obtains the log information of the **ConsoleMessage**.|
+| getMessageLevel(): [MessageLevel](#messagelevel-enums) | Obtains the log information level of the **ConsoleMessage**.|
+| getSourceId(): string | Obtains the path and name of the web page source file. |
-- MessageLevel enums
+## MessageLevel Enums
- | Name | Description |
- | ----- | :---- |
- | Debug | Debug level.|
- | Error | Error level.|
- | Info | Information level.|
- | Log | Log level.|
- | Warn | Warning level. |
+| Name | Description |
+| ----- | :---- |
+| Debug | Debug level.|
+| Error | Error level.|
+| Info | Information level.|
+| Log | Log level.|
+| Warn | Warning level. |
-### JsResult
+## JsResult
Provides the result returned to the **\** component to indicate the user operation performed in the dialog box.
-- APIs
-
- | Name | Description |
- | --------------------- | ----------------------- |
- | handleCancel(): void | The user's cancel operation in the dialog box.
|
- | handleConfirm(): void | The user's confirm operation in the dialog box.
|
+| Name | Description |
+| --------------------- | ----------------------- |
+| handleCancel(): void | The user's cancel operation in the dialog box.
|
+| handleConfirm(): void | The user's confirm operation in the dialog box.
|
-### WebResourceError
+## WebResourceError
-- APIs
-
- | Name | Description |
- | ---------------------- | ------------ |
- | getErrorCode(): number | Obtains the error code for resource loading. |
- | getErrorInfo(): string | Obtains error information about resource loading.|
-
-### WebResourceRequest
+| Name | Description |
+| ---------------------- | ------------ |
+| getErrorCode(): number | Obtains the error code for resource loading. |
+| getErrorInfo(): string | Obtains error information about resource loading.|
-- APIs
+## WebResourceRequest
- | Name | Description |
- | ---------------------------------------- | -------------------- |
- | getRequestHeader(): Array\<[Header](#header)\> | Obtains the information about the resource request header. |
- | getRequestUrl(): string | Obtains the URL of the resource request. |
- | isMainFrame(): boolean | Checks whether the resource request is in the main frame. |
- | isRedirect(): boolean | Checks whether the resource request is redirected by the server. |
- | isRequestGesture(): boolean | Checks whether the resource request is associated with a gesture (for example, a tap).|
+| Name | Description |
+| ---------------------------------------- | -------------------- |
+| getRequestHeader(): Array\<[Header](#header)\> | Obtains the information about the resource request header. |
+| getRequestUrl(): string | Obtains the URL of the resource request. |
+| isMainFrame(): boolean | Checks whether the resource request is in the main frame. |
+| isRedirect(): boolean | Checks whether the resource request is redirected by the server. |
+| isRequestGesture(): boolean | Checks whether the resource request is associated with a gesture (for example, a tap).|
-### Header
+## Header
Describes the request/response header returned by the **\** component.
-- Parameters
-
- | Name | Type | Description |
- | ----------- | ------ | ------------- |
- | headerKey | string | Key of the request/response header. |
- | headerValue | string | Value of the request/response header.|
-
+| Name | Type | Description |
+| ----------- | ------ | ------------- |
+| headerKey | string | Key of the request/response header. |
+| headerValue | string | Value of the request/response header.|
-### WebResourceResponse
-- APIs
+## WebResourceResponse
- | Name | Description |
- | ---------------------------------------- | ------------------ |
- | getReasonMessage(): string | Obtains the status code description of the resource response. |
- | getResponseCode(): number | Obtains the status code of the resource response. |
- | getResponseData(): string | Obtains the data in the resource response. |
- | getResponseEncoding(): string | Obtains the encoding of the resource response. |
- | getResponseHeader(): Array\<[Header](#header)\> | Obtains the resource response header. |
- | getResponseMimeType(): string | Obtains the media (MIME) type of the resource response.|
+| Name | Description |
+| ---------------------------------------- | ------------------ |
+| getReasonMessage(): string | Obtains the status code description of the resource response. |
+| getResponseCode(): number | Obtains the status code of the resource response. |
+| getResponseData(): string | Obtains the data in the resource response. |
+| getResponseEncoding(): string | Obtains the encoding of the resource response. |
+| getResponseHeader(): Array\<[Header](#header)\> | Obtains the resource response header. |
+| getResponseMimeType(): string | Obtains the media (MIME) type of the resource response.|
-### RenderExitReason
+## RenderExitReason
Explains why the rendering process exits.
| Name | Description |
| -------------------------- | ----------------- |
-| ProcessAbnormalTermination | The rendering process exits abnormally. |
-| ProcessWasKilled | The rendering process receives a SIGKILL message or is manually terminated.|
-| ProcessCrashed | The rendering process crashes due to a segmentation error or other errors. |
-| ProcessOom | The program memory is running low. |
-| ProcessExitUnknown | Other reason. |
+| PROCESS_ABNORMAL_TERMINATION | The rendering process exits abnormally. |
+| PROCESS_WAS_KILLED | The rendering process receives a SIGKILL message or is manually terminated.|
+| PROCESS_CRASHED | The rendering process crashes due to a segmentation error or other errors. |
+| PROCESS_OOM | The program memory is running low. |
+| PROCESS_EXIT_UNKNOWN | Other reason. |
-### MixedMode
+## MixedMode
| Name | Description |
| ---------- | ---------------------------------- |
@@ -172,7 +160,7 @@ Explains why the rendering process exits.
| Compatible | HTTP and HTTPS hybrid content can be loaded in compatibility mode. This means that some insecure content may be loaded. |
| None | HTTP and HTTPS hybrid content cannot be loaded. |
-### CacheMode
+## CacheMode
| Name | Description |
| ------- | ------------------------------------ |
| Default | The cache that has not expired is used to load the resources. If the resources do not exist in the cache, they will be obtained from the Internet.|
@@ -180,32 +168,28 @@ Explains why the rendering process exits.
| Online | The cache is not used to load the resources. All resources are obtained from the Internet. |
| Only | The cache alone is used to load the resources. |
-### FileSelectorResult
+## FileSelectorResult
Notifies the **\** component of the file selection result.
-- APIs
-
- | Name | Description |
- | ---------------------------------------------- | ------------------------------------------------------------ |
- | handleFileList(fileList: Array\): void | Instructs the **\** component to select a file.
**fileList**: list of files to operate. |
-
-### FileSelectorParam
-- APIs
+| Name | Description |
+| ---------------------------------------------- | ------------------------------------------------------------ |
+| handleFileList(fileList: Array\): void | Instructs the **\** component to select a file.
**fileList**: list of files to operate. |
- | Name | Description |
- | -------------------------------- | ------------ |
- | getTitle(): string | Obtains the title of the file selector. |
- | getMode(): FileSelectorMode | Obtains the mode of the file selector. |
- | getAcceptType(): Array\ | Obtains the file filtering type. |
- | isCapture(): boolean | Checks whether multimedia capabilities are invoked.|
+## FileSelectorParam
+| Name | Description |
+| -------------------------------- | ------------ |
+| title(): string | Title of the file selector. |
+| mode(): FileSelectorMode | Mode of the file selector. |
+| acceptType(): Array\ | File filtering type. |
+| isCapture(): boolean | Whether multimedia capabilities are invoked.|
-### FileSelectorMode
+## FileSelectorMode
| Name | Description |
| -------------------- | ---------- |
-| FileOpenMode | Open and upload a file. |
-| FileOpenMultipleMode | Open and upload multiple files. |
-| FileOpenFolderMode | Open and upload a folder.|
-| FileSaveMode | Save a file. |
+| FILE_OPEN_MODE | Open and upload a file. |
+| FILE_OPEN_MULTIPLE_MODE | Open and upload multiple files. |
+| FILE_OPEN_FOLDER_MODE | Open and upload a folder.|
+| FILE_SAVE_MODE | Save a file. |
## WebController
diff --git a/en/application-dev/reference/arkui-ts/ts-container-navigator.md b/en/application-dev/reference/arkui-ts/ts-container-navigator.md
index df3e651383f44aa20499e0a17a6dd9c0366e9409..4ccc7889444ed6de73832fa7e91616f718eab2b0 100644
--- a/en/application-dev/reference/arkui-ts/ts-container-navigator.md
+++ b/en/application-dev/reference/arkui-ts/ts-container-navigator.md
@@ -1,11 +1,12 @@
# Navigator
->  **NOTE**
+> **NOTE**
+>
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
-The **<Navigator>** component provides redirection.
+The **\** component provides redirection to the target page.
## Required Permissions
@@ -25,42 +26,43 @@ Navigator(value?: {target: string, type?: NavigationType})
Creates a navigator.
- Parameters
- | Name | Type | Mandatory | Default Value | Description |
+ | Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- |
- | target | string | Yes | - | Path of the target page to be redirected to. |
- | type | NavigationType | No | NavigationType.Push | Navigation type. |
+ | target | string | Yes | - | Path of the target page to be redirected to. |
+ | type | NavigationType | No | NavigationType.Push | Navigation type. |
- NavigationType enums
- | Name | Description |
+ | Name | Description |
| -------- | -------- |
- | Push | Navigates to a specified page in the application. |
- | Replace | Replaces the current page with another one in the application and destroys the current page. |
- | Back | Returns to the previous page or a specified page. |
+ | Push | Navigates to a specified page in the application. |
+ | Replace | Replaces the current page with another one in the application and destroys the current page. |
+ | Back | Returns to the previous page or a specified page. |
## Attributes
- | Name | Parameters | Default Value | Description |
+| Name | Parameters | Default Value | Description |
| -------- | -------- | -------- | -------- |
-| active | boolean | - | Whether the **<Navigator>** component is activated. If the component is activated, the corresponding navigation takes effect. |
-| params | Object | undefined | Data that needs to be passed to the target page during redirection. You can use **router.getParams()** to obtain the data on the target page. |
+| active | boolean | - | Whether the **\** component is activated. If the component is activated, the corresponding navigation takes effect. |
+| params | Object | undefined | Data that needs to be passed to the target page during redirection. You can use **router.getParams()** to obtain the data on the target page. |
## Example
-
-```
-// Navigator Page
+
+```ts
+// Navigator.ets
@Entry
@Component
struct NavigatorExample {
@State active: boolean = false
- @State Text: string = 'news'
+ @State Text: object = {name: 'news'}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
Navigator({ target: 'pages/container/navigator/Detail', type: NavigationType.Push }) {
- Text('Go to ' + this.Text + ' page').width('100%').textAlign(TextAlign.Center)
+ Text('Go to ' + this.Text['name'] + ' page')
+ .width('100%').textAlign(TextAlign.Center)
}.params({ text: this.Text })
Navigator() {
@@ -74,15 +76,15 @@ struct NavigatorExample {
}
```
-
-```
-// Detail Page
+
+```ts
+// Detail.ets
import router from '@system.router'
@Entry
@Component
struct DetailExample {
- @State text: string = router.getParams().text
+ @State text: any = router.getParams().text
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
@@ -90,7 +92,8 @@ struct DetailExample {
Text('Go to back page').width('100%').height(20)
}
- Text('This is ' + this.text + ' page').width('100%').textAlign(TextAlign.Center)
+ Text('This is ' + this.text['name'] + ' page')
+ .width('100%').textAlign(TextAlign.Center)
}
.width('100%').height(200).padding({ left: 35, right: 35, top: 35 })
}
@@ -98,9 +101,8 @@ struct DetailExample {
```
-
-```
-// Back Page
+```ts
+// Back.ets
@Entry
@Component
struct BackExample {
diff --git a/en/application-dev/reference/arkui-ts/ts-gesture-settings.md b/en/application-dev/reference/arkui-ts/ts-gesture-settings.md
index 8f5554c25a3529499aa415d93154cee7c0930f20..8c2d676ceccbb0bc989343db94aadc0d0fff1e78 100644
--- a/en/application-dev/reference/arkui-ts/ts-gesture-settings.md
+++ b/en/application-dev/reference/arkui-ts/ts-gesture-settings.md
@@ -16,51 +16,53 @@ None
Use the following attributes to bind gesture recognition to a component. When a gesture is recognized, the event callback is invoked to notify the component.
-| Name | Type | Default Value | Description |
+| Name | Type | Default Value | Description |
| -------- | -------- | -------- | -------- |
-| gesture | gesture: GestureType,
mask?: GestureMask | gesture: -,
mask: GestureMask.Normal | Gesture to recognize.
**gesture** specifies the type of the gesture to bind, and **mask** specifies the event response setting. |
-| priorityGesture | gesture: GestureType,
mask?: GestureMask | gesture: -,
mask: GestureMask.Normal | Gesture to preferentially recognize.
**gesture** specifies the type of the gesture to bind, and **mask** specifies the event response setting.
>  **NOTE**
> - By default, the child component takes precedence over the parent component in gesture recognition. When **priorityGesture** is configured for the parent component, the parent component takes precedence over the child component in gesture recognition. |
-| parallelGesture | gesture: GestureType,
mask?: GestureMask | gesture: -,
mask: GestureMask.Normal | Gesture that can be triggered together with the child component gesture.
**gesture** specifies the type of the gesture to bind, and **mask** specifies the event response setting.
>  **NOTE**
> - The gesture event is not a bubbling event. When **parallelGesture** is set for the parent component, gesture events that are the same for the parent component and child components can be triggered, thereby implementing a bubbling effect. |
+| gesture | gesture: GestureType,
mask?: GestureMask | gesture: -,
mask: GestureMask.Normal | Gesture to recognize.
- **gesture**: type of the gesture to bind.
- **mask**: event response setting. |
+| priorityGesture | gesture: GestureType,
mask?: GestureMask | gesture: -,
mask: GestureMask.Normal | Gesture to preferentially recognize.
- **gesture**: type of the gesture to bind.
- **mask**: event response setting.
By default, the child component takes precedence over the parent component in gesture recognition. When **priorityGesture** is configured for the parent component, the parent component takes precedence over the child component in gesture recognition. |
+| parallelGesture | gesture: GestureType,
mask?: GestureMask | gesture: -,
mask: GestureMask.Normal | Gesture that can be triggered together with the child component gesture.
- **gesture**: type of the gesture to bind.
- **mask**: event response setting.
The gesture event is not a bubbling event. When **parallelGesture** is set for the parent component, gesture events bound to both the parent and child components can be triggered, thereby implementing a bubbling effect. |
- GestureMask enums
- | Name | Description |
+ | Name | Description |
| -------- | -------- |
- | Normal | The gestures of child components are not masked and are recognized based on the default gesture recognition sequence. |
- | IgnoreInternal | The gestures of child components are masked. Only the gestures of the current component are recognized.
>  **NOTE**
> However, the built-in gestures of the child components are not masked. For example, when the child component is a **<List>** component, the built-in sliding gestures can still be triggered. |
+ | Normal | The gestures of child components are not masked and are recognized based on the default gesture recognition sequence. |
+ | IgnoreInternal | The gestures of child components are masked. Only the gestures of the current component are recognized.
However, the built-in gestures of the child components are not masked. For example, when the child component is a **<List>** component, the built-in sliding gestures can still be triggered. |
-- Gesture types
- | Name | Description |
+- GestureType enums
+ | Name | Description |
| -------- | -------- |
- | TapGesture | Tap gesture, which can be a single-tap or multi-tap gesture. |
- | LongPressGesture | Long press gesture. |
- | PanGesture | Pan gesture. |
- | PinchGesture | Pinch gesture. |
- | RotationGesture | Rotation gesture. |
- | GestureGroup | A group of gestures. Continuous recognition, parallel recognition, and exclusive recognition are supported. |
+ | TapGesture | Tap gesture, which can be a single-tap or multi-tap gesture. |
+ | LongPressGesture | Long press gesture. |
+ | PanGesture | Pan gesture. |
+ | PinchGesture | Pinch gesture. |
+ | RotationGesture | Rotation gesture. |
+ | SwipeGesture | Swipe gesture, which can be idenfied when the swipe speed is 100 vp/s or higher. |
+ | GestureGroup | A group of gestures. Continuous recognition, parallel recognition, and exclusive recognition are supported. |
## Gesture Response Event
-The component uses the **gesture** method to bind the gesture object and uses the events provided in this object to respond to the gesture operation. For example, the **onAction** event of the **TapGesture** object can be used to respond to a click event. For details about the event definition, see the section of each gesture object.
+A component uses the **gesture** method to bind the gesture object and uses the events provided in this object to respond to the gesture operation. For example, the **onAction** event of the **TapGesture** object can be used to respond to a click event. For details about the event definition, see the section of each gesture object.
- TapGesture events
- | Name | Description |
+ | Name | Description |
| -------- | -------- |
- | onAction((event?: GestureEvent) => void) | Callback invoked when a tap gesture is recognized. |
+ | onAction((event?: GestureEvent) => void) | Callback invoked when a tap gesture is recognized. |
- GestureEvent attributes
- | Name | Type | Description |
+ | Name | Type | Description |
| -------- | -------- | -------- |
- | timestamp | number | Timestamp of the event. |
- | target8+ | EventTarget | Object that triggers the gesture event. |
+ | timestamp | number | Timestamp of the event. |
+ | target8+ | [EventTarget](ts-universal-events-click.md) | Object that triggers the gesture event. |
## Example
```ts
+// xxx.ets
@Entry
@Component
struct GestureSettingsExample {
diff --git a/en/application-dev/reference/arkui-ts/ts-motion-path-animation.md b/en/application-dev/reference/arkui-ts/ts-motion-path-animation.md
index 0293a61a861421aeb80118dbb63c6d34c9ce3058..073938a1009eb7441efd4039de84ba8a24cf188c 100644
--- a/en/application-dev/reference/arkui-ts/ts-motion-path-animation.md
+++ b/en/application-dev/reference/arkui-ts/ts-motion-path-animation.md
@@ -1,23 +1,24 @@
# Motion Path Animation
->  **NOTE**
+> **NOTE**
+>
> This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
-The attributes described in this topic are used to set the motion path of the component in a translation animation.
+The attributes below can be used to set the motion path of the component in a translation animation.
## Attributes
- | Name | Type | Default Value | Description |
+| Name | Type | Default Value | Description |
| -------- | -------- | -------- | -------- |
-| motionPath | {
path: string,
from?: number,
to?: number,
rotatable?: boolean
}
>  **NOTE**
> In a path, **start** and **end** can be used to replace the start point and end point. Example:
>
> 'Mstart.x start.y L50 50 Lend.x end.y Z' | {
"",
0.0,
1.0,
false
} | Motion path of the component. The input parameters are described as follows:
- **path**: motion path of the translation animation. The **svg** path string is used.
- **from**: start point of the motion path. The default value is **0.0**.
- **to**: end point of the motion path. The default value is **1.0**.
- **rotatable**: whether to rotate along the path. |
+| motionPath | {
path: string,
from?: number,
to?: number,
rotatable?: boolean
}
**NOTE**
In a path, **start** and **end** can be used to replace the start point and end point. Example:
'Mstart.x start.y L50 50 Lend.x end.y Z' | {
"",
0.0,
1.0,
false
} | Motion path of the component. The input parameters are described as follows:
- **path**: motion path of the translation animation. The **svg** path string is used.
- **from**: start point of the motion path. The default value is **0.0**.
- **to**: end point of the motion path. The default value is **1.0**.
- **rotatable**: whether to rotate along the path. |
## Example
-
+
```
@Entry
@Component
diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md
index 4e27ab2eb1aaf983c0128787925377339d67ad3e..43907b4096dc2a0eb3c524b33a489bfd8eed1689 100644
--- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md
+++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md
@@ -1,8 +1,11 @@
# Component ID
+**id** identifies a component uniquely within an application. This module provides APIs for obtaining the attributes of or sending events to the component with the specified ID.
->  **NOTE**
-> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
+> **NOTE**
+>
+> - The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
+> - The APIs provided by this module are system APIs.
## Required Permissions
@@ -12,9 +15,9 @@ None
## Attributes
- | Name | Type | Default Value | Description |
-| -------- | -------- | -------- | -------- |
-| id | string | '' | Unique ID of the component. The uniqueness is ensured by the user. |
+| Name | Type | Default Value | Description |
+| ---- | ------ | ---- | ------------------ |
+| id | string | '' | Unique ID you assigned to the component.|
## APIs
@@ -27,15 +30,26 @@ getInspectorByKey(id: string): string
Obtains all attributes of the component with the specified ID, excluding the information about child components.
- Parameters
- | Name | Type | Mandatory | Default Value | Description |
- | -------- | -------- | -------- | -------- | -------- |
- | id | string | Yes | - | ID of the component whose attributes are to be obtained. |
+ | Name | Type | Mandatory | Default Value | Description |
+ | ---- | ------ | ---- | ---- | ----------- |
+ | id | string | Yes | - | ID of the component whose attributes are to be obtained.|
- Return value
- | Type | Description |
- | -------- | -------- |
- | string | JSON string of the component attribute list. |
+ | Type | Description |
+ | ------ | --------------- |
+ | string | JSON string of the component attribute list.|
+### getInspectorTree
+
+getInspectorTree(): string
+
+Obtains the component tree and component attributes.
+
+- Return value
+
+ | Type | Description |
+ | ------ | ------------------- |
+ | string | JSON string of the component tree and component attribute list.|
### sendEventByKey
@@ -44,61 +58,207 @@ sendEventByKey(id: string, action: number, params: string): boolean
Sends an event to the component with the specified ID.
- Parameters
- | Name | Type | Mandatory | Default Value | Description |
- | -------- | -------- | -------- | -------- | -------- |
- | id | string | Yes | - | ID of the component for which the event is to be sent. |
- | action | number | Yes | - | Type of the event to be sent. The options are as follows:
- Click event: 10.
- LongClick: 11. |
- | params | string | Yes | - | Event parameters. If there is no parameter, pass an empty string **""**. |
+ | Name | Type | Mandatory | Default Value | Description |
+ | ------ | ------ | ---- | ---- | ---------------------------------------- |
+ | id | string | Yes | - | ID of the component to which the event is to be sent. |
+ | action | number | Yes | - | Type of the event to be sent. The options are as follows:
- **10**: click event.
- **11**: long click event.|
+ | params | string | Yes | - | Event parameters. If there is no parameter, pass an empty string **""**. |
+
+- Return value
+ | Type | Description |
+ | ------- | ------------------------------ |
+ | boolean | Returns **true** if the component with the specified ID is found; returns **false** otherwise.|
+
+### sendTouchEvent
+
+sendTouchEvent(event: TouchObject): boolean
+
+Sends a touch event.
+
+- Parameters
+
+ | Name | Type | Mandatory | Default Value | Description |
+ | ----- | ----------- | ---- | ---- | ---------------------------------------- |
+ | event | TouchObject | Yes | - | Location where a touch event is triggered. For details, see [TouchEvent](ts-universal-events-touch.md#touchevent).|
+
+- Return value
+
+ | Type | Description |
+ | ------- | -------------------------- |
+ | boolean | Returns **true** if the event is sent successfully; returns **false** otherwise.|
+
+### sendKeyEvent
+
+sendKeyEvent(event: KeyEvent): boolean
+
+Sends a key event.
+
+- Parameters
+
+ | Name | Type | Mandatory | Default Value | Description |
+ | ----- | -------- | ---- | ---- | ---------------------------------------- |
+ | event | KeyEvent | Yes | - | Key event. For details, see [KeyEvent](ts-universal-events-key.md#keyevent).|
+
+- Return value
+
+ | Type | Description |
+ | ------- | --------------------------- |
+ | boolean | Returns **true** if the event is sent successfully; returns **false** otherwise.|
+
+### sendMouseEvent
+
+sendMouseEvent(event: MouseEvent): boolean
+
+Sends a mouse event.
+
+- Parameters
+
+ | Name | Type | Mandatory | Default Value | Description |
+ | ----- | ---------- | ---- | ---- | ---------------------------------------- |
+ | event | MouseEvent | Yes | - | Mouse event. For details, see [MouseEvent](ts-universal-mouse-key.md#mouseevent).|
- Return value
- | Type | Description |
- | -------- | -------- |
- | boolean | Returns **false** if the component with the specified ID cannot be found; returns **true** otherwise. |
+ | Type | Description |
+ | ------- | --------------------------- |
+ | boolean | Returns **true** if the event is sent successfully; returns **false** otherwise.|
## Example
-
-```
+```ts
+// xxx.ets
+class Utils {
+ static rect_left;
+ static rect_top;
+ static rect_right;
+ static rect_bottom;
+ static rect_value;
+
+ static getComponentRect(key) {
+ let strJson = getInspectorByKey(key);
+ let obj = JSON.parse(strJson);
+ console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj));
+ let rectInfo = JSON.parse('[' + obj.$rect + ']')
+ console.info("[getInspectorByKey] rectInfo is: " + rectInfo);
+ this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0]
+ this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1]
+ this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0]
+ this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1]
+ return this.rect_value = {
+ "left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom
+ }
+ }
+}
+
@Entry
@Component
struct IdExample {
+ @State text: string = ''
+
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
+
Button() {
- Text('click')
- .fontSize(25)
- .fontWeight(FontWeight.Bold)
- }
- .type(ButtonType.Capsule)
- .margin({
- top: 20
- }).onClick(() => {
+ Text('onKeyTab').fontSize(25).fontWeight(FontWeight.Bold)
+ }.margin({ top: 20 }).backgroundColor('#0D9FFB')
+ .onKeyEvent(() => {
+ this.text = "onKeyTab"
+ })
+
+ Button() {
+ Text('click to start').fontSize(25).fontWeight(FontWeight.Bold)
+ }.margin({ top: 20 })
+ .onClick(() => {
console.info(getInspectorByKey("click"))
console.info(getInspectorTree())
+ this.text = "Button 'click to start' is clicked"
setTimeout(() => {
sendEventByKey("longclick", 11, "")
}, 2000)
}).id('click')
Button() {
- Text('longclick')
- .fontSize(25)
- .fontWeight(FontWeight.Bold)
- }
- .type(ButtonType.Capsule)
- .margin({
- top: 20
- })
- .backgroundColor('#0D9FFB')
+ Text('longclick').fontSize(25).fontWeight(FontWeight.Bold)
+ }.margin({ top: 20 }).backgroundColor('#0D9FFB')
.gesture(
- LongPressGesture().onActionEnd(() => {
- console.info('long clicked')
- }))
- .id('longclick')
+ LongPressGesture().onActionEnd(() => {
+ console.info('long clicked')
+ this.text = "Button 'longclick' is longclicked"
+ setTimeout(() => {
+ let rect = Utils.getComponentRect('onTouch')
+ let touchPoint: TouchObject = {
+ id: 1,
+ x: rect.left + (rect.right - rect.left) / 2,
+ y: rect.top + (rect.bottom - rect.top) / 2,
+ type: TouchType.Down,
+ screenX: rect.left + (rect.right - rect.left) / 2,
+ screenY: rect.left + (rect.right - rect.left) / 2,
+ }
+ sendTouchEvent(touchPoint)
+ touchPoint.type = TouchType.Up
+ sendTouchEvent(touchPoint)
+ }, 2000)
+ })).id('longclick')
+
+ Button() {
+ Text('onTouch').fontSize(25).fontWeight(FontWeight.Bold)
+ }.type(ButtonType.Capsule).margin({ top: 20 })
+ .onClick(() => {
+ console.info('onTouch is clicked')
+ this.text = "Button 'onTouch' is clicked"
+ setTimeout(() => {
+ let rect = Utils.getComponentRect('onMouse')
+ let mouseEvent: MouseEvent = {
+ button: MouseButton.Left,
+ action: MouseAction.Press,
+ x: rect.left + (rect.right - rect.left) / 2,
+ y: rect.top + (rect.bottom - rect.top) / 2,
+ screenX: rect.left + (rect.right - rect.left) / 2,
+ screenY: rect.top + (rect.bottom - rect.top) / 2,
+ timestamp: 1,
+ target: {
+ area: {
+ width: 1,
+ height: 1,
+ position: {
+ x: 1,
+ y: 1
+ },
+ globalPosition: {
+ x: 1,
+ y: 1
+ }
+ }
+ },
+ source: SourceType.Mouse
+ }
+ sendMouseEvent(mouseEvent)
+ }, 2000)
+ }).id('onTouch')
+
+ Button() {
+ Text('onMouse').fontSize(25).fontWeight(FontWeight.Bold)
+ }.margin({ top: 20 }).backgroundColor('#0D9FFB')
+ .onMouse(() => {
+ console.info('onMouse')
+ this.text = "Button 'onMouse' in onMouse"
+ setTimeout(() => {
+ let keyEvent: KeyEvent = {
+ type: KeyType.Down,
+ keyCode: 2049,
+ keyText: 'tab',
+ keySource: 4,
+ deviceId: 0,
+ metaKey: 0,
+ timestamp: 0
+ }
+ sendKeyEvent(keyEvent)
+ }, 2000)
+ }).id('onMouse')
+
+ Text(this.text).fontSize(25).padding(15)
}
- .width('100%')
- .height('100%')
+ .width('100%').height('100%')
}
}
```
diff --git a/en/device-dev/guide/device-wlan-led-control.md b/en/device-dev/guide/device-wlan-led-control.md
index d35ab0376543e37ae7957a92323b601e7ecd330f..f6ecb319c17b8fd53aa9bdb4595232239f0773a3 100644
--- a/en/device-dev/guide/device-wlan-led-control.md
+++ b/en/device-dev/guide/device-wlan-led-control.md
@@ -6,9 +6,9 @@ Based on the Hi3861 platform, the OpenHarmony WLAN module provides abundant peri
## Development
-1. Complete the operations described in [Getting Started with Hi3861](../quick-start/quickstart-lite-introduction-hi3861.md#section19352114194115).
+1. Complete the operations described in [Getting Started with Hi3861](../quick-start/quickstart-lite-overview.md).
- LED control examples are stored in the file **applications/sample/wifi-iot/app/iothardware/led\_example.c**.
+ LED control examples are stored in the file **applications/sample/wifi-iot/app/iothardware/led\_example.c**.
2. Understand the cable connections by referring to the schematic diagram. You can learn that LED of hispark pegasus is connected to pin 9 of the chip.
@@ -73,17 +73,16 @@ Based on the Hi3861 platform, the OpenHarmony WLAN module provides abundant peri
break;
}
}
- return NULL;
}
```
-5. Call **SYS\_RUN\(\)** of OpenHarmony to start the service. \(**SYS\_RUN** is defined in the **ohos\_init.h** file.\)
+5. Call **SYS\_RUN\(\)** of OpenHarmony to start the service. \(**SYS\_RUN** is defined in the **ohos\_init.h** file.\)
```
SYS_RUN(LedExampleEntry);
```
-6. Change the **applications/sample/wifi-iot/app/BUILD.gn** file to enable **led\_example.c** to participate in compilation.
+6. Change the **applications/sample/wifi-iot/app/BUILD.gn** file to enable **led\_example.c** to participate in compilation.
```
import("//build/lite/config/component/lite_component.gni")
@@ -97,10 +96,10 @@ Based on the Hi3861 platform, the OpenHarmony WLAN module provides abundant peri
## Verification
-For details about the compilation and burning processes, see [Building](../quick-start/quickstart-lite-steps-hi3861-building.md) and [Burning](../quick-start/quickstart-lite-steps-hi3861-burn.md) in the _Getting Started with Hi3861_.
+For details about the compilation and burning processes, see [Building](../quick-start/quickstart-lite-steps-hi3861-building.md) and [Burning](../quick-start/quickstart-lite-steps-hi3861-burn.md).
-After the preceding two steps are complete, press the **RST** button to reset the module. If the LED blinks periodically as expected, the verification is passed.
+After the preceding two steps are complete, press the **RST** button to reset the module. If the LED blinks periodically as expected, the verification is passed.
-**Figure 1** LED blinking
+**Figure 1** LED blinking

diff --git a/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md b/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md
index 926bc3aaad951784a61b55dac94c213da2aa6681..3bcc3d6c94a3f1f8f444b64d5144ae19fc64fba4 100644
--- a/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md
+++ b/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md
@@ -44,26 +44,26 @@ import stats from '@ohos.bundleState';
import stats from '@ohos.bundleState'
// 异步方法promise方式
- stats.queryBundleActiveStates(0, 20000000000000).then( res => {
+ stats.queryBundleActiveStates(0, 20000000000000).then(res => {
console.log('BUNDLE_ACTIVE queryBundleActiveStates promise success.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE queryBundleActiveStates promise number : ' + (i + 1));
console.log('BUNDLE_ACTIVE queryBundleActiveStates promise result ' + JSON.stringify(res[i]));
}
- }).catch( err => {
+ }).catch(err => {
console.log('BUNDLE_ACTIVE queryBundleActiveStates promise failed, because: ' + err.code);
});
// 异步方法callback方式
stats.queryBundleActiveStates(0, 20000000000000, (err, res) => {
- if(err.code == 0) {
+ if (err) {
+ console.log('BUNDLE_ACTIVE queryBundleActiveStates callback failed, because: ' + err.code);
+ } else {
console.log('BUNDLE_ACTIVE queryBundleActiveStates callback success.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE queryBundleActiveStates callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE queryBundleActiveStates callback result ' + JSON.stringify(res[i]));
}
- } else {
- console.log('BUNDLE_ACTIVE queryBundleActiveStates callback failed, because: ' + err.code);
}
});
```
@@ -74,30 +74,30 @@ import stats from '@ohos.bundleState';
import stats from '@ohos.bundleState'
// 异步方法promise方式
- stats.queryBundleStateInfos(0, 20000000000000).then( res => {
+ stats.queryBundleStateInfos(0, 20000000000000).then(res => {
console.log('BUNDLE_ACTIVE queryBundleStateInfos promise success.');
let i = 1;
- for(let key in res){
+ for (let key in res) {
console.log('BUNDLE_ACTIVE queryBundleStateInfos promise number : ' + i);
console.log('BUNDLE_ACTIVE queryBundleStateInfos promise result ' + JSON.stringify(res[key]));
i++;
}
- }).catch( err => {
+ }).catch(err => {
console.log('BUNDLE_ACTIVE queryBundleStateInfos promise failed, because: ' + err.code);
});
// 异步方法callback方式
stats.queryBundleStateInfos(0, 20000000000000, (err, res) => {
- if(err.code == 0) {
+ if (err) {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfos callback failed, because: ' + err.code);
+ } else {
console.log('BUNDLE_ACTIVE queryBundleStateInfos callback success.');
let i = 1;
- for(let key in res){
+ for (let key in res) {
console.log('BUNDLE_ACTIVE queryBundleStateInfos callback number : ' + i);
console.log('BUNDLE_ACTIVE queryBundleStateInfos callback result ' + JSON.stringify(res[key]));
i++;
}
- } else {
- console.log('BUNDLE_ACTIVE queryBundleStateInfos callback failed, because: ' + err.code);
}
});
```
@@ -108,26 +108,26 @@ import stats from '@ohos.bundleState';
import stats from '@ohos.bundleState'
// 异步方法promise方式
- stats.queryCurrentBundleActiveStates(0, 20000000000000).then( res => {
+ stats.queryCurrentBundleActiveStates(0, 20000000000000).then(res => {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise success.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise number : ' + (i + 1));
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise result ' + JSON.stringify(res[i]));
}
- }).catch( err => {
+ }).catch(err => {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise failed, because: ' + err.code);
});
// 异步方法callback方式
stats.queryCurrentBundleActiveStates(0, 20000000000000, (err, res) => {
- if(err.code == 0) {
+ if (err) {
+ console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback failed, because: ' + err.code);
+ } else {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback success.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback result ' + JSON.stringify(res[i]));
}
- } else {
- console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback failed, because: ' + err.code);
}
});
```
@@ -138,26 +138,26 @@ import stats from '@ohos.bundleState';
import stats from '@ohos.bundleState'
// 异步方法promise方式
- stats.queryBundleStateInfoByInterval(0, 0, 20000000000000).then( res => {
+ stats.queryBundleStateInfoByInterval(0, 0, 20000000000000).then(res => {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise success.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise number : ' + (i + 1));
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise result ' + JSON.stringify(res[i]));
}
- }).catch( err => {
+ }).catch(err => {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise failed, because: ' + err.code);
});
// 异步方法callback方式
stats.queryBundleStateInfoByInterval(0, 0, 20000000000000, (err, res) => {
- if(err.code == 0) {
+ if (err) {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback failed, because: ' + err.code);
+ } else {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback success.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback result ' + JSON.stringify(res[i]));
}
- } else {
- console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback failed, because: ' + err.code);
}
});
```
@@ -168,18 +168,18 @@ import stats from '@ohos.bundleState';
import stats from '@ohos.bundleState'
// 异步方法promise方式
- stats.queryAppUsagePriorityGroup().then( res => {
+ stats.queryAppUsagePriorityGroup().then(res => {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res));
- }).catch( err => {
+ }).catch(err => {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code);
});
// 异步方法callback方式
stats.queryAppUsagePriorityGroup((err, res) => {
- if(err.code === 0) {
- console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res));
- } else {
+ if (err) {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code);
+ } else {
+ console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res));
}
});
```
@@ -190,18 +190,18 @@ import stats from '@ohos.bundleState';
import stats from '@ohos.bundleState'
// 异步方法promise方式
- stats.isIdleState("com.ohos.camera").then( res => {
+ stats.isIdleState("com.ohos.camera").then(res => {
console.log('BUNDLE_ACTIVE isIdleState promise succeeded, result: ' + JSON.stringify(res));
- }).catch( err => {
+ }).catch(err => {
console.log('BUNDLE_ACTIVE isIdleState promise failed, because: ' + err.code);
});
// 异步方法callback方式
stats.isIdleState("com.ohos.camera", (err, res) => {
- if(err.code === 0) {
- console.log('BUNDLE_ACTIVE isIdleState callback succeeded, result: ' + JSON.stringify(res));
- } else {
+ if (err) {
console.log('BUNDLE_ACTIVE isIdleState callback failed, because: ' + err.code);
+ } else {
+ console.log('BUNDLE_ACTIVE isIdleState callback succeeded, result: ' + JSON.stringify(res));
}
});
```
\ No newline at end of file
diff --git a/zh-cn/application-dev/device/device-location-geocoding.md b/zh-cn/application-dev/device/device-location-geocoding.md
index 47de33675805b6e659f6b92b0254b5c41cf88d7c..d15b8df3418540ef13cedde828173a1948d9e8fc 100644
--- a/zh-cn/application-dev/device/device-location-geocoding.md
+++ b/zh-cn/application-dev/device/device-location-geocoding.md
@@ -3,9 +3,13 @@
## 场景介绍
-使用坐标描述一个位置,非常准确,但是并不直观,面向用户表达并不友好。
+使用坐标描述一个位置,非常准确,但是并不直观,面向用户表达并不友好。系统向开发者提供了以下两种转化能力。
-系统向开发者提供了地理编码转化能力(将地理描述转化为具体坐标),以及逆地理编码转化能力(将坐标转化为地理描述)。其中地理编码包含多个属性来描述位置,包括国家、行政区划、街道、门牌号、地址描述等等,这样的信息更便于用户理解。
+- 地理编码转化:将地理描述转化为具体坐标。
+
+- 逆地理编码转化能力:将坐标转化为地理描述。
+
+其中地理编码包含多个属性来描述位置,包括国家、行政区划、街道、门牌号、地址描述等等,这样的信息更便于用户理解。
## 接口说明
diff --git a/zh-cn/application-dev/device/sensor-overview.md b/zh-cn/application-dev/device/sensor-overview.md
index 69b6c06539343276191a53ccd9227a7f2b7e7faa..048757f2ef0cd0afc8d37f7a69c60c2199fc8c51 100644
--- a/zh-cn/application-dev/device/sensor-overview.md
+++ b/zh-cn/application-dev/device/sensor-overview.md
@@ -1,7 +1,7 @@
# 传感器开发概述
-OpenHarmony系统传感器是应用访问底层硬件传感器的一种设备抽象概念。开发者根据传感器提供的Sensor API,可以查询设备上的传感器,订阅传感器数据,并根据传感器数据定制相应的算法开发各类应用,比如指南针、运动健康、游戏等。
+OpenHarmony系统传感器是应用访问底层硬件传感器的一种设备抽象概念。开发者根据传感器提供的[Sensor接口](../reference/apis/js-apis-sensor.md),可以查询设备上的传感器,订阅传感器数据,并根据传感器数据定制相应的算法开发各类应用,比如指南针、运动健康、游戏等。
传感器是指用于侦测环境中所发生事件或变化,并将此消息发送至其他电子设备(如中央处理器)的设备,通常由敏感组件和转换组件组成。传感器是实现物联网智能化的重要基石,为实现全场景智慧化战略,支撑“1+8+N”产品需求,需要构筑统一的传感器管理框架,达到为各产品/业务提供低时延、低功耗的感知数据的目的。下面为传感器列表:
diff --git a/zh-cn/application-dev/device/vibrator-guidelines.md b/zh-cn/application-dev/device/vibrator-guidelines.md
index 3e7087421c8cf635a29f8d4c7c274edaf70cfc9b..41254b7c494b2fa912283a1e3f776bf5862f133b 100644
--- a/zh-cn/application-dev/device/vibrator-guidelines.md
+++ b/zh-cn/application-dev/device/vibrator-guidelines.md
@@ -5,6 +5,8 @@
当设备需要设置不同的振动效果时,可以调用Vibrator模块,例如:设备的按键可以设置不同强度和不同时长的振动,闹钟和来电可以设置不同强度和时长的单次或周期振动。
+详细的接口介绍请参考[Vibrator接口](../reference/apis/js-apis-vibrator.md)。
+
## 接口说明
diff --git a/zh-cn/application-dev/internationalization/i18n-guidelines.md b/zh-cn/application-dev/internationalization/i18n-guidelines.md
index 4b5d14f24a12c9da2cafcbc01049f214fcfabb3e..a8acb6712629a290279d144e68297ae0668bb2c9 100644
--- a/zh-cn/application-dev/internationalization/i18n-guidelines.md
+++ b/zh-cn/application-dev/internationalization/i18n-guidelines.md
@@ -12,18 +12,19 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
| 模块 | 接口名称 | 描述 |
| -------- | -------- | -------- |
-| ohos.i18n | getSystemLanguage(): string | 获取系统语言。 |
-| ohos.i18n | getSystemRegion(): string | 获取系统区域。 |
-| ohos.i18n | getSystemLocale(): string | 获取系统Locale。 |
-| ohos.i18n | isRTL(locale: string): boolean7+ | locale对应的语言是否为从右到左语言。 |
-| ohos.i18n | is24HourClock(): boolean7+ | 获取当前系统时间是否采用24小时制 |
-| ohos.i18n | getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string | 获取语言的本地化表示。 |
-| ohos.i18n | getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string | 获取国家的本地化表示。 |
+| ohos.i18n | getSystemLanguage():string | 获取系统语言。 |
+| ohos.i18n | getSystemRegion():string | 获取系统区域。 |
+| ohos.i18n | getSystemLocale():string | 获取系统Locale。 |
+| ohos.i18n | isRTL(locale:string):boolean7+ | locale对应的语言是否为从右到左语言。 |
+| ohos.i18n | is24HourClock():boolean7+ | 获取当前系统时间是否采用24小时制。 |
+| ohos.i18n | getDisplayLanguage(language:string,locale:string,sentenceCase?:boolean):string | 获取语言的本地化表示。 |
+| ohos.i18n | getDisplayCountry(country:string,locale:string,sentenceCase?:boolean):string | 获取国家的本地化表示。 |
### 开发步骤
-1. 获取系统语言
+1. 获取系统语言。
+
调用getSystemLanguage方法获取当前系统设置的语言(i18n为导入的模块)。
@@ -31,21 +32,24 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
var language = i18n.getSystemLanguage();
```
-2. 获取系统区域
+2. 获取系统区域。
+
调用getSystemRegion方法获取当前系统设置的区域
```
var region = i18n.getSystemRegion();
```
-3. 获取系统Locale
+3. 获取系统Locale。
+
调用getSystemLocale方法获取当前系统设置的Locale
```
var locale = i18n.getSystemLocale();
```
-4. 判断Locale的语言是否为RTL语言
+4. 判断Locale的语言是否为RTL语言。
+
调用isRTL方法获取Locale的语言是否为从右到左语言。
@@ -53,14 +57,16 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
var rtl = i18n.isRTL("zh-CN");
```
-5. 判断当前系统时间是否采用24小时制
+5. 判断当前系统时间是否采用24小时制。
+
调用is24HourClock方法来判断当前系统的时间是否采用24小时制。
```
var hourClock = i18n.is24HourClock();
```
-6. 获取语言的本地化表示
+6. 获取语言的本地化表示。
+
调用getDisplayLanguage方法获取某一语言的本地化表示。其中,language表示待本地化显示的语言,locale表示本地化的Locale,sentenceCase结果是否需要首字母大写。
```
@@ -70,7 +76,8 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
var localizedLanguage = i18n.getDisplayLanguage(language, locale, sentenceCase);
```
-7. 获取国家的本地化表示
+7. 获取国家的本地化表示。
+
调用getDisplayCountry方法获取某一国家的本地化表示。其中,country表示待本地化显示的国家,locale表示本地化的Locale,sentenceCase结果是否需要首字母大写。
```
@@ -90,23 +97,24 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
| 模块 | 接口名称 | 描述 |
| -------- | -------- | -------- |
-| ohos.i18n | getCalendar(locale: string, type?: string): Calendar8+ | 获取指定locale和type的日历对象。 |
-| ohos.i18n | setTime(date: Date): void8+ | 设置日历对象内部的时间日期。 |
-| ohos.i18n | setTime(time: number): void8+ | 设置日历对象内部的时间日期。 |
-| ohos.i18n | set(year: number, month: number, date: number, hour?: number, minute?: number, second?: number): void8+ | 设置日历对象的年、月、日、时、分、秒。 |
-| ohos.i18n | setTimeZone(timezone: string): void8+ | 设置日历对象的时区。 |
-| ohos.i18n | getTimeZone(): string8+ | 获取日历对象的时区。 |
-| ohos.i18n | getFirstDayOfWeek(): number8+ | 获取日历对象的一周起始日。 |
-| ohos.i18n | setFirstDayOfWeek(value: number): void8+ | 设置日历对象的一周起始日。 |
-| ohos.i18n | getMinimalDaysInFirstWeek(): number8+ | 获取一年中第一周的最小天数。 |
-| ohos.i18n | setMinimalDaysInFirstWeek(value: number): void8+ | 设置一年中第一周的最小天数。 |
-| ohos.i18n | getDisplayName(locale: string): string8+ | 获取日历对象的本地化表示。 |
-| ohos.i18n | isWeekend(date?: Date): boolean8+ | 判断给定的日期是否在日历中是周末。 |
+| ohos.i18n | getCalendar(locale:string,type?:string):Calendar8+ | 获取指定locale和type的日历对象。 |
+| ohos.i18n | setTime(date:Date): void8+ | 设置日历对象内部的时间日期。 |
+| ohos.i18n | setTime(time:number): void8+ | 设置日历对象内部的时间日期。 |
+| ohos.i18n | set(year:number,month:number,date:number,hour?:number,minute?:number,second?:number): void8+ | 设置日历对象的年、月、日、时、分、秒。 |
+| ohos.i18n | setTimeZone(timezone:string): void8+ | 设置日历对象的时区。 |
+| ohos.i18n | getTimeZone():string8+ | 获取日历对象的时区。 |
+| ohos.i18n | getFirstDayOfWeek():number8+ | 获取日历对象的一周起始日。 |
+| ohos.i18n | setFirstDayOfWeek(value:number): void8+ | 设置日历对象的一周起始日。 |
+| ohos.i18n | getMinimalDaysInFirstWeek():number8+ | 获取一年中第一周的最小天数。 |
+| ohos.i18n | setMinimalDaysInFirstWeek(value:number): void8+ | 设置一年中第一周的最小天数。 |
+| ohos.i18n | getDisplayName(locale:string):string8+ | 获取日历对象的本地化表示。 |
+| ohos.i18n | isWeekend(date?:Date):boolean8+ | 判断给定的日期是否在日历中是周末。 |
### 开发步骤
-1. 实例化日历对象
+1. 实例化日历对象。
+
调用getCalendar方法获取指定locale和type的时区对象(i18n为导入的模块)。其中,type表示合法的日历类型,目前合法的日历类型包括:"buddhist", "chinese", "coptic", "ethiopic", "hebrew", "gregory", "indian", "islamic_civil", "islamic_tbla", "islamic_umalqura", "japanese", "persian"。当type没有给出时,采用区域默认的日历类型。
@@ -114,7 +122,8 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
var calendar = i18n.getCalendar("zh-CN", "gregory);
```
-2. 设置日历对象的时间
+2. 设置日历对象的时间。
+
调用setTime方法设置日历对象的时间。setTime方法接收两种类型的参数。一种是传入一个Date对象,另一种是传入一个数值表示从1970.1.1 00:00:00 GMT逝去的毫秒数。
```
@@ -124,14 +133,16 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
calendar.setTime(date2);
```
-3. 设置日历对象的年、月、日、时、分、秒
+3. 设置日历对象的年、月、日、时、分、秒。
+
调用set方法设置日历对象的年、月、日、时、分、秒。
```
calendar.set(2021, 12, 21, 6, 0, 0)
```
-4. 设置、获取日历对象的时区
+4. 设置、获取日历对象的时区。
+
调用setTimeZone方法和getTimeZone方法来设置、获取日历对象的时区。其中,setTimeZone方法需要传入一个字符串表示需要设置的时区。
@@ -140,7 +151,8 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
var timezone = calendar.getTimeZone();
```
-5. 设置、获取日历对象的一周起始日
+5. 设置、获取日历对象的一周起始日。
+
调用setFirstDayOfWeek方法和getFirstDayOfWeek方法设置、获取日历对象的一周起始日。其中,setFirstDayOfWeek需要传入一个数值表示一周的起始日,1代表周日,7代表周六。
@@ -165,7 +177,8 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
var localizedName = calendar.getDisplayName("zh-CN");
```
-8. 判断某一个日期是否为周末
+8. 判断某一个日期是否为周末。
+
调用isWeekend方法来判断输入的Date是否为周末。
@@ -184,14 +197,15 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
| 模块 | 接口名称 | 描述 |
| -------- | -------- | -------- |
-| ohos.i18n | constructor(country: string, options?: PhoneNumberFormatOptions)8+ | 实例化PhoneNumberFormat对象。 |
-| ohos.i18n | isValidNumber(number: string): boolean8+ | 判断number是否是一个格式正确的电话号码。 |
-| ohos.i18n | format(number: string): string8+ | 对number按照指定国家及风格进行格式化。 |
+| ohos.i18n | constructor(country:string,options?:PhoneNumberFormatOptions)8+ | 实例化PhoneNumberFormat对象。 |
+| ohos.i18n | isValidNumber(number:string):boolean8+ | 判断number是否是一个格式正确的电话号码。 |
+| ohos.i18n | format(number:string):string8+ | 对number按照指定国家及风格进行格式化。 |
### 开发步骤
-1. 实例化电话号码格式化对象
+1. 实例化电话号码格式化对象。
+
调用PhoneNumberFormat的构造函数来实例化电话号码格式化对象,需要传入电话号码的国家代码及格式化选项。其中,格式化选项是可选的,包括style选项,该选项的取值包括:"E164", "INTERNATIONAL", "NATIONAL", "RFC3966"。
@@ -199,14 +213,16 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
var phoneNumberFormat = new i18n.PhoneNubmerFormat("CN", {type: "E164"});
```
-2. 判断电话号码格式是否正确
+2. 判断电话号码格式是否正确。
+
调用isValidNumber方法来判断输入的电话号码的格式是否正确。
```
var validNumber = phoneNumberFormat.isValidNumber("15812341234");
```
-3. 电话号码格式化
+3. 电话号码格式化。
+
调用电话号码格式化对象的format方法来对输入的电话号码进行格式化。
```
@@ -223,12 +239,13 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
| 模块 | 接口名称 | 描述 |
| -------- | -------- | -------- |
-| ohos.i18n | unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string8+ | 将fromUnit的单位转换为toUnit的单位,并根据区域与风格进行格式化。 |
+| ohos.i18n | unitConvert(fromUnit:UnitInfo,toUnit:UnitInfo,value:number,locale:string,style?:string):string8+ | 将fromUnit的单位转换为toUnit的单位,并根据区域与风格进行格式化。 |
### 开发步骤
-1. 度量衡单位转换
+1. 度量衡单位转换。
+
调用[unitConvert](../reference/apis/js-apis-intl.md)方法实现度量衡单位转换,并进行格式化显示的功能。
@@ -251,15 +268,16 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
| 模块 | 接口名称 | 描述 |
| -------- | -------- | -------- |
-| ohos.i18n | getInstance(locale?: string): IndexUtil8+ | 实例化字母表索引对象。 |
-| ohos.i18n | getIndexList(): Array<string>8+ | 获取当前Locale的索引列表。 |
-| ohos.i18n | addLocale(locale: string): void8+ | 将新的Locale对应的索引加入当前索引列表。 |
-| ohos.i18n | getIndex(text: string): string8+ | 获取text对应的索引。 |
+| ohos.i18n | getInstance(locale?:string):IndexUtil8+ | 实例化字母表索引对象。 |
+| ohos.i18n | getIndexList():Array<string>8+ | 获取当前Locale的索引列表。 |
+| ohos.i18n | addLocale(locale:string): void8+ | 将新的Locale对应的索引加入当前索引列表。 |
+| ohos.i18n | getIndex(text:string):string8+ | 获取text对应的索引。 |
### 开发步骤
-1. 实例化字母表索引对象
+1. 实例化字母表索引对象。
+
调用getInstance方法来实例化特定locale对应的字母表索引对象。当locale参数为空时,实例化系统默认Locale的字母表索引对象。
@@ -267,21 +285,24 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
var indexUtil = getInstance("zh-CN");
```
-2. 获取索引列表
+2. 获取索引列表。
+
调用getIndexList方法来获取当前Locale对应的字母表索引列表。
```
var indexList = indexUtil.getIndexList();
```
-3. 增加新的索引
+3. 增加新的索引。
+
调用addLocale方法,将新的Locale对应的字母表索引添加到当前字母表索引列表中。
```
indexUtil.addLocale("ar")
```
-4. 获取字符串对应的索引
+4. 获取字符串对应的索引。
+
调用getIndex方法来获取某一字符串对应的字母表索引。
```
@@ -299,21 +320,22 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
| 模块 | 接口名称 | 描述 |
| -------- | -------- | -------- |
-| ohos.i18n | getLineInstance(locale: string): BreakIterator8+ | 实例化断行对象。 |
-| ohos.i18n | setLineBreakText(text: string): void8+ | 设置要处理的文本。 |
-| ohos.i18n | getLineBreakText(): string8+ | 获取要处理的文本。 |
-| ohos.i18n | current(): number8+ | 获取当前断行对象在处理文本的位置。 |
-| ohos.i18n | first(): number8+ | 将断行对象设置到第一个可断句的分割点。 |
-| ohos.i18n | last(): number8+ | 将断行对象设置到最后一个可断句的分割点。 |
-| ohos.i18n | next(index?: number): number8+ | 将断行对象移动index个分割点的位置。 |
-| ohos.i18n | previous(): number8+ | 将断行对象移动到前一个分割点的位置。 |
-| ohos.i18n | following(offset: number): number8+ | 将断行对象移动到offset指定位置的后面一个分割点的位置。 |
-| ohos.i18n | isBoundary(offset: number): boolean8+ | 判断某个位置是否是分割点。 |
+| ohos.i18n | getLineInstance(locale:string):BreakIterator8+ | 实例化断行对象。 |
+| ohos.i18n | setLineBreakText(text:string): void8+ | 设置要处理的文本。 |
+| ohos.i18n | getLineBreakText():string8+ | 获取要处理的文本。 |
+| ohos.i18n | current():number8+ | 获取当前断行对象在处理文本的位置。 |
+| ohos.i18n | first():number8+ | 将断行对象设置到第一个可断句的分割点。 |
+| ohos.i18n | last():number8+ | 将断行对象设置到最后一个可断句的分割点。 |
+| ohos.i18n | next(index?:number):number8+ | 将断行对象移动index个分割点的位置。 |
+| ohos.i18n | previous():number8+ | 将断行对象移动到前一个分割点的位置。 |
+| ohos.i18n | following(offset:number):number8+ | 将断行对象移动到offset指定位置的后面一个分割点的位置。 |
+| ohos.i18n | isBoundary(offset:number):boolean8+ | 判断某个位置是否是分割点。 |
### 开发步骤
-1. 实例化断行对象
+1. 实例化断行对象。
+
调用getLineInstance方法来实例化断行对象。
@@ -322,7 +344,8 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
var breakIterator = i18n.getLineInstance(locale);
```
-2. 设置、访问要断行处理的文本
+2. 设置、访问要断行处理的文本。
+
调用setLineBreakText方法和getLineBreakText方法来设置、访问要断行处理的文本。
@@ -332,7 +355,8 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
var breakText = breakIterator.getLineBreakText();
```
-3. 获取断行对象当前的位置
+3. 获取断行对象当前的位置。
+
调用current方法来获取断行对象在当前处理文本中的位置。
@@ -340,7 +364,8 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
var pos = breakIterator.current();
```
-4. 设置断行对象的位置
+4. 设置断行对象的位置。
+
系统提供了很多接口可以用于调整断行对象在处理文本中的位置,包括first, last, next, previous, following。
@@ -356,7 +381,8 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
var followingPos = breakIterator.following(10);
```
-5. 判断某个位置是否为分割点
+5. 判断某个位置是否为分割点。
+
调用isBoundary方法来判断一个方法是否为分割点;如果该位置是分割点,则返回true,并且将断行对象移动到该位置;如果该位置不是分割点,则返回false,并且将断行对象移动到该位置后的一个分割点。
diff --git a/zh-cn/application-dev/internationalization/intl-guidelines.md b/zh-cn/application-dev/internationalization/intl-guidelines.md
index ca8f6cdbce7debda3334bcf4fed119def263718c..11ee1e9e9714d64fc7a0910006e978f3d53e5df0 100644
--- a/zh-cn/application-dev/internationalization/intl-guidelines.md
+++ b/zh-cn/application-dev/internationalization/intl-guidelines.md
@@ -2,7 +2,6 @@
Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方法。
-
## 设置区域信息
调用[Locale](../reference/apis/js-apis-intl.md)的相关接口实现最大化区域信息或最小化区域信息。
@@ -10,44 +9,48 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
### 接口说明
-| 模块 | 接口名称 | 描述 |
-| --------- | ---------------------------------------- | -------------------------- |
-| ohos.intl | constructor()8+ | 实例化Locale对象。 |
-| ohos.intl | constructor(locale: string, options?: LocaleOptions) | 基于locale参数及其选项实例化Locale对象。 |
-| ohos.intl | toString(): string | 将Locale信息转换为字符串。 |
-| ohos.intl | maximize(): Locale | 最大化区域信息。 |
-| ohos.intl | minimize(): Locale | 最小化区域信息。 |
+| 模块 | 接口名称 | 描述 |
+| -------- | -------- | -------- |
+| ohos.intl | constructor()8+ | 实例化Locale对象。 |
+| ohos.intl | constructor(locale:string,options?:LocaleOptions) | 基于locale参数及其选项实例化Locale对象。 |
+| ohos.intl | toString():string | 将Locale信息转换为字符串。 |
+| ohos.intl | maximize():Locale | 最大化区域信息。 |
+| ohos.intl | minimize():Locale | 最小化区域信息。 |
### 开发步骤
-1. 实例化Locale对象
- 使用Locale的构造函数创建Locale对象,该方法接收一个表示Locale的字符串及可选的[属性](../reference/apis/js-apis-intl.md)列表(intl为导入的模块名)。
+1. 实例化Locale对象。
+ 使用Locale的构造函数创建Locale对象,该方法接收一个表示Locale的字符串及可选的[属性](../reference/apis/js-apis-intl.md)列表(intl为导入的模块名)。
+
```
var locale = "zh-CN";
var options = {caseFirst: false, calendar: "chinese", collation: pinyin};
var localeObj = new intl.Locale(locale, options);
```
-2. 获取Locale的字符串表示
- 调用toString方法来获取Locale对象的字符串表示,其中包括了语言、区域及其他选项信息。
+2. 获取Locale的字符串表示。
+ 调用toString方法来获取Locale对象的字符串表示,其中包括了语言、区域及其他选项信息。
+
```
var localeStr = localeObj.toString();
```
-3. 最大化区域信息
- 调用maximize方法来最大化区域信息,即当缺少脚本与地区信息时,对其进行补全。
+3. 最大化区域信息。
+ 调用maximize方法来最大化区域信息,即当缺少脚本与地区信息时,对其进行补全。
+
```
var maximizedLocale = localeObj.maximize();
```
-4. 最小化区域信息
- 调用minimize方法来最小化区域信息,即当存在脚本与地区信息时,对其进行删除。
+4. 最小化区域信息。
+ 调用minimize方法来最小化区域信息,即当存在脚本与地区信息时,对其进行删除。
+
```
var minimizedLocale = localeObj.minimize();
```
@@ -60,52 +63,56 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
### 接口说明
-| 模块 | 接口名称 | 描述 |
-| --------- | ---------------------------------------- | ---------------------------------------- |
-| ohos.intl | constructor()8+ | 创建日期时间格式化对象。 |
-| ohos.intl | constructor(locale: string \| Array<string>, options?: DateTimeOptions) | 创建日期时间格式化对象,并设置提供的Locale和格式化相关属性。 |
-| ohos.intl | format(date: Date): string | 依据DateTimeFormat对象的Locale及其他格式化属性,计算日期时间的格式化表示。 |
-| ohos.intl | formatRange(startDate: Date, endDate: Date): string | 依据DateTimeFormat对象的Locale及其他格式化属性,计算时间段的格式化表示。 |
-| ohos.intl | resolvedOptions(): DateTimeOptions | 获取DateTimeFormat对象的相关属性。 |
+| 模块 | 接口名称 | 描述 |
+| -------- | -------- | -------- |
+| ohos.intl | constructor()8+ | 创建日期时间格式化对象。 |
+| ohos.intl | constructor(locale:string\|Array<string>,options?:DateTimeOptions) | 创建日期时间格式化对象,并设置提供的Locale和格式化相关属性。 |
+| ohos.intl | format(date:Date):string | 依据DateTimeFormat对象的Locale及其他格式化属性,计算日期时间的格式化表示。 |
+| ohos.intl | formatRange(startDate:Date,endDate:Date):string | 依据DateTimeFormat对象的Locale及其他格式化属性,计算时间段的格式化表示。 |
+| ohos.intl | resolvedOptions():DateTimeOptions | 获取DateTimeFormat对象的相关属性。 |
### 开发步骤
-1. 实例化日期时间格式化对象
- 一种方法是使用DateTimeFormat提供的默认构造函数,通过访问系统语言和地区设置,获取系统默认Locale,并将其作为DateTimeFormat对象内部的Locale(intl为导入的模块名)。
+1. 实例化日期时间格式化对象。
+ 一种方法是使用DateTimeFormat提供的默认构造函数,通过访问系统语言和地区设置,获取系统默认Locale,并将其作为DateTimeFormat对象内部的Locale(intl为导入的模块名)。
+
```
var dateTimeFormat = new intl.DateTimeFormat();
```
另一种方法是使用开发者提供的Locale和格式化参数来创建日期时间格式化对象。其中,格式化参数是可选的,完整的格式化参数列表见[DateTimeOptions](../reference/apis/js-apis-intl.md)。
-
+
```
var options = {dateStyle: "full", timeStyle: "full"};
var dateTimeFormat = new intl.DateTimeFormat("zh-CN", options);
```
-2. 格式化日期时间
- 使用DateTimeFormat的format方法对一个Date对象进行格式化,该方法会返回一个字符串作为格式化的结果。
+2. 格式化日期时间。
+ 使用DateTimeFormat的format方法对一个Date对象进行格式化,该方法会返回一个字符串作为格式化的结果。
+
```
Date date = new Date();
var formatResult = dateTimeFormat.format(date);
```
-3. 格式化时间段
- 使用DateTimeFormat的formatRange方法对一个时间段进行格式化。该方法需要传入两个Date对象,分别表示时间段的起止时间,返回一个字符串作为格式化的结果。
+3. 格式化时间段。
+ 使用DateTimeFormat的formatRange方法对一个时间段进行格式化。该方法需要传入两个Date对象,分别表示时间段的起止时间,返回一个字符串作为格式化的结果。
+
```
Date startDate = new Date();
Date endDate = new Date();
var formatResult = dateTimeFormat.formatRange(startDate, endDate);
```
-4. 访问日期时间格式化对象的相关属性
- DateTimeFormat的resolvedOptions方法会返回一个对象,该对象包含了DateTimeFormat对象的所有相关属性及其值。
+4. 访问日期时间格式化对象的相关属性。
+ DateTimeFormat的resolvedOptions方法会返回一个对象,该对象包含了DateTimeFormat对象的所有相关属性及其值。
+
```
var options = dateTimeFormat.resolvedOptions();
```
@@ -118,42 +125,45 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
### 接口说明
-| 模块 | 接口名称 | 描述 |
-| --------- | ---------------------------------------- | ---------------------------------------- |
-| ohos.intl | constructor()8+ | 创建数字格式化对象。 |
-| ohos.intl | constructor(locale: string \| Array<string>, options?: NumberOptions) | 创建数字格式化对象,并设置提供的locale和格式化相关属性。 |
-| ohos.intl | format(number: number): string | 依据NumberFormat对象的Locale及其他格式化属性,计算数字的格式化表示。 |
-| ohos.intl | resolvedOptions(): NumberOptions | 获取NumberFormat对象的相关属性。 |
+| 模块 | 接口名称 | 描述 |
+| -------- | -------- | -------- |
+| ohos.intl | constructor()8+ | 创建数字格式化对象。 |
+| ohos.intl | constructor(locale:string\|Array<string>,options?:NumberOptions) | 创建数字格式化对象,并设置提供的locale和格式化相关属性。 |
+| ohos.intl | format(number:number):string | 依据NumberFormat对象的Locale及其他格式化属性,计算数字的格式化表示。 |
+| ohos.intl | resolvedOptions():NumberOptions | 获取NumberFormat对象的相关属性。 |
### 开发步骤
-1. 实例化数字格式化对象
- 一种方法是使用NumberFormat提供的默认构造函数,通过访问系统的语言和地区以获取系统默认Locale并进行设置(intl为导入的模块名)。
+1. 实例化数字格式化对象。
+ 一种方法是使用NumberFormat提供的默认构造函数,通过访问系统的语言和地区以获取系统默认Locale并进行设置(intl为导入的模块名)。
+
```
var numberFormat = new intl.NumberFormat();
```
另一种方法是使用开发者提供的Locale和格式化参数来创建数字格式化对象。其中,格式化参数是可选的,完整的格式化参数列表参见[NumberOptions](../reference/apis/js-apis-intl.md)。
-
+
```
var options = {compactDisplay: "short", notation: "compact"};
var numberFormat = new intl.NumberFormat("zh-CN", options);
```
-2. 数字格式化
- 使用NumberFormat的format方法对传入的数字进行格式化。该方法返回一个字符串作为格式化的结果。
+2. 数字格式化。
+ 使用NumberFormat的format方法对传入的数字进行格式化。该方法返回一个字符串作为格式化的结果。
+
```
var number = 1234.5678
var formatResult = numberFormat.format(number);
```
-3. 访问数字格式化对象的相关属性
- NumberFormat的resolvedOptions方法会返回一个对象,该对象包含了NumberFormat对象的所有相关属性及其值。
+3. 访问数字格式化对象的相关属性。
+ NumberFormat的resolvedOptions方法会返回一个对象,该对象包含了NumberFormat对象的所有相关属性及其值。
+
```
var options = numberFormat.resolvedOptions();
```
@@ -166,42 +176,45 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
### 接口说明
-| 模块 | 接口名称 | 描述 |
-| --------- | ---------------------------------------- | ------------------------------- |
-| ohos.intl | constructor()8+ | 创建排序对象。 |
-| ohos.intl | constructor(locale: string \| Array<string>, options?: CollatorOptions)8+ | 创建排序对象,并设置提供的locale和其他相关属性。 |
-| ohos.intl | compare(first: string, second: string): number8+ | 依据排序对象的Locale及其属性,计算两个字符串的比较结果。 |
-| ohos.intl | resolvedOptions(): CollatorOptions8+ | 获取排序对象的相关属性。 |
+| 模块 | 接口名称 | 描述 |
+| -------- | -------- | -------- |
+| ohos.intl | constructor()8+ | 创建排序对象。 |
+| ohos.intl | constructor(locale:string\|Array<string>,options?:CollatorOptions)8+ | 创建排序对象,并设置提供的locale和其他相关属性。 |
+| ohos.intl | compare(first:string,second:string):number8+ | 依据排序对象的Locale及其属性,计算两个字符串的比较结果。 |
+| ohos.intl | resolvedOptions():CollatorOptions8+ | 获取排序对象的相关属性。 |
### 开发步骤
-1. 实例化排序对象
- 一种方法是使用Collator提供的默认构造函数,通过访问系统的语言和地区以获取系统默认Locale并进行设置(intl为导入的模块名)。
+1. 实例化排序对象。
+ 一种方法是使用Collator提供的默认构造函数,通过访问系统的语言和地区以获取系统默认Locale并进行设置(intl为导入的模块名)。
+
```
var collator = new intl.Collator();
```
另一种方法是使用开发者提供的Locale和其他相关参数来创建Collator对象,完整的参数列表参见[CollatorOptions](../reference/apis/js-apis-intl.md)。
-
+
```
var collator= new intl.Collator("zh-CN", {localeMatcher: "best fit", usage: "sort"};
```
-2. 比较字符串
- 使用Collator的compare方法对传入的两个字符串进行比较。该方法返回一个数值作为比较的结果,返回-1表示第一个字符串小于第二个字符串,返回1表示第一个字符大于第二个字符串,返回0表示两个字符串相同。
+2. 比较字符串。
+ 使用Collator的compare方法对传入的两个字符串进行比较。该方法返回一个数值作为比较的结果,返回-1表示第一个字符串小于第二个字符串,返回1表示第一个字符大于第二个字符串,返回0表示两个字符串相同。
+
```
var str1 = "first string";
var str2 = "second string";
var compareResult = collator.compare(str1, str2);
```
-3. 访问排序对象的相关属性
- Collator的resolvedOptions方法会返回一个对象,该对象包含了Collator对象的所有相关属性及其值。
+3. 访问排序对象的相关属性。
+ Collator的resolvedOptions方法会返回一个对象,该对象包含了Collator对象的所有相关属性及其值。
+
```
var options = collator.resolvedOptions();
```
@@ -214,32 +227,34 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
### 接口说明
-| 模块 | 接口名称 | 描述 |
-| --------- | ---------------------------------------- | ---------------------------------- |
-| ohos.intl | constructor()8+ | 创建单复数对象。 |
-| ohos.intl | constructor(locale: string \| Array<string>, options?: PluralRulesOptions)8+ | 创建单复数对象,并设置提供的locale和其他相关属性。 |
-| ohos.intl | select(n: number): string8+ | 依据单复数对象的Locale及其他格式化属性,计算数字的单复数类别。 |
+| 模块 | 接口名称 | 描述 |
+| -------- | -------- | -------- |
+| ohos.intl | constructor()8+ | 创建单复数对象。 |
+| ohos.intl | constructor(locale:string\|Array<string>,options?:PluralRulesOptions)8+ | 创建单复数对象,并设置提供的locale和其他相关属性。 |
+| ohos.intl | select(n:number):string8+ | 依据单复数对象的Locale及其他格式化属性,计算数字的单复数类别。 |
### 开发步骤
-1. 实例化单复数对象
- 一种方法是使用PluralRules提供的默认构造函数,通过访问系统的语言和地区以获取系统默认Locale并进行设置(intl为导入的模块名)。
+1. 实例化单复数对象。
+ 一种方法是使用PluralRules提供的默认构造函数,通过访问系统的语言和地区以获取系统默认Locale并进行设置(intl为导入的模块名)。
+
```
var pluralRules = new intl.PluralRules();
```
- 另一种方法是使用开发者提供的Locale和其他相关参数来创建单复数对象,完整的参数列表参见[PluralRulesOptions](../reference/apis/js-apis-intl.md)。
-
+ 另一种方法是使用开发者提供的Locale和其他相关参数来创建单复数对象。完整的参数列表参见[PluralRulesOptions](../reference/apis/js-apis-intl.md)。
+
```
var plurals = new intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"};
```
-2. 计算数字单复数类别
- 使用PluralRules的select方法计算传入数字的单复数类别。该方法返回一个字符串作为传入数字的类别,包括:"zero", "one", "two", "few", "many", "other"六个类别。
+2. 计算数字单复数类别。
+ 使用PluralRules的select方法计算传入数字的单复数类别。该方法返回一个字符串作为传入数字的类别,包括:"zero", "one", "two", "few", "many", "other"六个类别。
+
```
var number = 1234.5678
var categoryResult = plurals.select(number);
@@ -253,52 +268,56 @@ Intl开发指导提供了ECMA 402中定义的国际化能力接口的使用方
### 接口说明
-| 模块 | 接口名称 | 描述 |
-| --------- | ---------------------------------------- | ---------------------------------------- |
-| ohos.intl | constructor()8+ | 创建相对时间格式化对象。 |
-| ohos.intl | constructor(locale: string \| Array<string>, options?: RelativeTimeFormatInputOptions)8+ | 创建相对时间格式化对象,并设置提供的locale和格式化相关属性。 |
-| ohos.intl | format(value: number, unit: string): string8+ | 依据相对时间格式化对象的Locale及其他格式化属性,计算相对时间的格式化表示。 |
-| ohos.intl | formatToParts(value: number, unit: string): Array<object>8+ | 依据相对时间格式化对象的Locale及其他格式化属性,返回相对时间格式化表示的各个部分。 |
-| ohos.intl | resolvedOptions(): RelativeTimeFormatResolvedOptions8+ | 获取相对时间格式化对象的相关属性。 |
+| 模块 | 接口名称 | 描述 |
+| -------- | -------- | -------- |
+| ohos.intl | constructor()8+ | 创建相对时间格式化对象。 |
+| ohos.intl | constructor(locale:string\|Array<string>,options?:RelativeTimeFormatInputOptions)8+ | 创建相对时间格式化对象,并设置提供的locale和格式化相关属性。 |
+| ohos.intl | format(value:number,unit:string):string8+ | 依据相对时间格式化对象的Locale及其他格式化属性,计算相对时间的格式化表示。 |
+| ohos.intl | formatToParts(value:number,unit:string):Array<object>8+ | 依据相对时间格式化对象的Locale及其他格式化属性,返回相对时间格式化表示的各个部分。 |
+| ohos.intl | resolvedOptions():RelativeTimeFormatResolvedOptions8+ | 获取相对时间格式化对象的相关属性。 |
### 开发步骤
-1. 实例化相对时间格式化对象
- 一种方法是使用RelativeTimeFormat提供的默认构造函数,通过访问系统的语言和地区以获取系统默认Locale并进行设置(intl为导入的模块名)。
+1. 实例化相对时间格式化对象。
+ 一种方法是使用RelativeTimeFormat提供的默认构造函数,通过访问系统的语言和地区以获取系统默认Locale并进行设置(intl为导入的模块名)。
+
```
var relativeTimeFormat = new intl.RelativeTimeFormat();
```
另一种方法是使用开发者提供的Locale和格式化参数来创建相对时间格式化对象。其中,格式化参数是可选的,完整的参数列表参见[ RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md)。
-
+
```
var relativeTimeFormat = new intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"};
```
-2. 相对时间格式化
- 使用RelativeTimeFormat的format方法对相对时间进行格式化。方法接收一个表示相对时间长度的数值和表示单位的字符串,其中单位包括:"year", "quarter", "month", "week", "day", "hour", "minute", "second"。方法返回一个字符串作为格式化的结果。
+2. 相对时间格式化。
+ 使用RelativeTimeFormat的format方法对相对时间进行格式化。方法接收一个表示相对时间长度的数值和表示单位的字符串,其中单位包括:"year", "quarter", "month", "week", "day", "hour", "minute", "second"。方法返回一个字符串作为格式化的结果。
+
```
var number = 2;
var unit = "year"
var formatResult = relativeTimeFormat.format(number, unit);
```
-3. 获取相对时间格式化结果的各个部分
- 获取相对时间格式化结果的各个部分,从而自定义格式化结果。
+3. 获取相对时间格式化结果的各个部分。
+ 获取相对时间格式化结果的各个部分,从而自定义格式化结果。
+
```
var number = 2;
var unit = "year"
var formatResult = relativeTimeFormat.formatToParts(number, unit);
```
-4. 访问相对时间格式化对象的相关属性
- RelativeTimeFormat的resolvedOptions方法会返回一个对象,该对象包含了RelativeTimeFormat对象的所有相关属性及其值,完整的属性列表参见[ RelativeTimeFormatResolvedOptions](../reference/apis/js-apis-intl.md)。
+4. 访问相对时间格式化对象的相关属性。
+ RelativeTimeFormat的resolvedOptions方法会返回一个对象,该对象包含了RelativeTimeFormat对象的所有相关属性及其值,完整的属性列表参见[ RelativeTimeFormatResolvedOptions](../reference/apis/js-apis-intl.md)。
+
```
var options = numberFormat.resolvedOptions();
```
diff --git a/zh-cn/application-dev/quick-start/basic-resource-file-categories.md b/zh-cn/application-dev/quick-start/basic-resource-file-categories.md
index e5eec75d8dd2e1ac6b79bf35d5c3408d7754b76a..e15c49af5f6d2636c212ec794b8063d5439eed98 100644
--- a/zh-cn/application-dev/quick-start/basic-resource-file-categories.md
+++ b/zh-cn/application-dev/quick-start/basic-resource-file-categories.md
@@ -20,7 +20,7 @@ resources
| | |---string.json
| |---media
| | |---icon.png
-|---rawfile // 默认存在的目录
+|---rawfile
```
**表1** resources目录分类
diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-context.md b/zh-cn/application-dev/reference/apis/js-apis-application-context.md
index ff20db878e13ebd59a8ad428e6f3887bab238c36..7e8c5f94afd785b1b05f652a146f02ece63584a6 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-application-context.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-application-context.md
@@ -18,18 +18,18 @@
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
- | 名称 | 参数类型 | 可读 | 可写 | 说明 |
+| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
-| resourceManager | ResourceManager | 是 | 否 | ResourceManager对象。 |
-| applicationInfo | ApplicationInfo | 是 | 否 | 当前应用信息。 |
-| cacheDir | string | 是 | 否 | 应用在内部存储上的缓存路径。 |
-| tempDir | string | 是 | 否 | 应用的临时文件路径。 |
-| filesDir | string | 是 | 否 | 应用在内部存储上的文件路径。 |
-| databaseDir | string | 是 | 否 | 获取本地数据存储路径。 |
-| storageDir | string | 是 | 否 | 获取轻量级数据存储路径。 |
-| bundleCodeDir | string | 是 | 否 | 应用安装路径。 |
-| distributedFilesDir | string | 是 | 否 | 应用的分布式文件路径。 |
-| eventHub | [EventHub](js-apis-eventhub.md) | 是 | 否 | 事件中心信息。|
+| resourceManager | ResourceManager | 是 | 否 | ResourceManager对象。 |
+| applicationInfo | ApplicationInfo | 是 | 否 | 当前应用信息。 |
+| cacheDir | string | 是 | 否 | 应用在内部存储上的缓存路径。 |
+| tempDir | string | 是 | 否 | 应用的临时文件路径。 |
+| filesDir | string | 是 | 否 | 应用在内部存储上的文件路径。 |
+| databaseDir | string | 是 | 否 | 获取本地数据存储路径。 |
+| storageDir | string | 是 | 否 | 获取轻量级数据存储路径。 |
+| bundleCodeDir | string | 是 | 否 | 应用安装路径。 |
+| distributedFilesDir | string | 是 | 否 | 应用的分布式文件路径。 |
+| eventHub | [EventHub](js-apis-eventhub.md) | 是 | 否 | 事件中心信息。|
## Context.createBundleContext
@@ -42,15 +42,15 @@ createBundleContext(bundleName: string): Context;
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | -------- | -------- | -------- | -------- |
- | bundleName | string | 是 | 应用bundle名。 |
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | -------- | -------- | -------- |
+| bundleName | string | 是 | 应用bundle名。 |
**返回值:**
- | 类型 | 说明 |
- | -------- | -------- |
- | Context | 对应创建应用的上下文context。 |
+| 类型 | 说明 |
+| -------- | -------- |
+| Context | 对应创建应用的上下文context。 |
**示例:**
@@ -70,13 +70,51 @@ getApplicationContext(): Context;
**返回值:**
- | 类型 | 说明 |
- | -------- | -------- |
- | Context | 当前Context 信息。 |
+| 类型 | 说明 |
+| -------- | -------- |
+| Context | 当前Context 信息。 |
**示例:**
+
```js
// 必选项。
let context = this.context.getApplicationContext();
```
+
+
+
+> **说明:**
+> 当SDK :API 9版本为Canary版本时;
+
+## Context.switchArea
+
+switchArea(mode: AreaMode): void
+
+开启文件范围
+
+**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
+
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| ------ | --------------------- | ---- | -------------- |
+| mode | [AreaMode](#AreaMode) | 是 | 应用bundle名。 |
+
+**示例**:
+
+```js
+var areaMode = 0
+this.context.switchArea(areaMode);
+```
+
+## AreaMode
+
+文件范围模式
+
+**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
+
+| 名称 | 参数类型 | 值 |
+| ---- | -------- | ---- |
+| EL1 | number | 0 |
+| EL2 | number | 1 |
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-applicationContext.md b/zh-cn/application-dev/reference/apis/js-apis-applicationContext.md
deleted file mode 100644
index fe2add752fb50c6aac9d073c91c72af1824ec2fa..0000000000000000000000000000000000000000
--- a/zh-cn/application-dev/reference/apis/js-apis-applicationContext.md
+++ /dev/null
@@ -1,116 +0,0 @@
-# Context
-
->  **说明**
->
-> 本模块首批接口从API version 9开始支持。API 9当前为Canary版本,仅供使用,不保证接口可稳定调用。
-
-
-提供开发者运行代码的上下文环境,包括应用信息、ResourceManager等信息。
-
-
-## 使用说明
-
-
-通过AbilityContext等继承实现。
-
-
-## 属性
-
-**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
-
-| 名称 | 参数类型 | 可读 | 可写 | 说明 |
-| -------- | -------- | -------- | -------- | -------- |
-| resourceManager | ResourceManager | 是 | 否 | ResourceManager对象。 |
-| applicationInfo | ApplicationInfo | 是 | 否 | 当前应用信息。 |
-| cacheDir | string | 是 | 否 | 应用在内部存储上的缓存路径。 |
-| tempDir | string | 是 | 否 | 应用的临时文件路径。 |
-| filesDir | string | 是 | 否 | 应用在内部存储上的文件路径。 |
-| databaseDir | string | 是 | 否 | 获取本地数据存储路径。 |
-| storageDir | string | 是 | 否 | 获取轻量级数据存储路径。 |
-| bundleCodeDir | string | 是 | 否 | 应用安装路径。 |
-| distributedFilesDir | string | 是 | 否 | 应用的分布式文件路径。 |
-| eventHub | [EventHub](js-apis-eventhub.md) | 是 | 否 | 事件中心信息。|
-
-
-## Context.createBundleContext
-
-createBundleContext(bundleName: string): Context;
-
-创建指定应用上下文。
-
-**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
-
-**参数:**
-
- | 参数名 | 类型 | 必填 | 说明 |
- | -------- | -------- | -------- | -------- |
- | bundleName | string | 是 | 应用bundle名。 |
-
-**返回值:**
-
- | 类型 | 说明 |
- | -------- | -------- |
- | Context | 对应创建应用的上下文context。 |
-
-**示例:**
-
-```js
-let test = "com.example.test";
-let context = this.context.createBundleContext(test);
-```
-
-
-## Context.getApplicationContext
-
-getApplicationContext(): Context;
-
-获取当前context。
-
-**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
-
-**返回值:**
-
- | 类型 | 说明 |
- | -------- | -------- |
- | Context | 当前Context 信息。 |
-
-**示例:**
-
-```js
-// 必选项。
-let context = this.context.getApplicationContext();
-```
-
-
-## Context.switchArea
-
-switchArea(mode: AreaMode): void
-
-开启文件范围
-
-**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
-
-**参数:**
-
-| 参数名 | 类型 | 必填 | 说明 |
-| -------- | -------- | -------- | -------- |
-| mode | [AreaMode](#AreaMode) | 是 | 应用bundle名。 |
-
-**示例**:
-
-```js
-var areaMode = 0
-this.context.switchArea(areaMode);
-```
-
-
-## AreaMode
-
-文件范围模式
-
-**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
-
-| 名称 | 参数类型 | 值 |
-| -------- | -------- | -------- |
-| EL1 | number | 0 |
-| EL2 | number | 1 |
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-config-policy.md b/zh-cn/application-dev/reference/apis/js-apis-config-policy.md
index a9c4752e3304c3c554582a7e666d63dd31e2c157..eb785ee6425d990141262173c47884e3df4d79c1 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-config-policy.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-config-policy.md
@@ -1,13 +1,13 @@
# 配置策略
+配置策略提供按预先定义的定制配置层级获取对应定制配置目录和文件路径的能力。
+
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
> 本模块接口均为系统接口,三方应用不支持调用。
-配置策略提供按预先定义的定制配置层级获取对应定制配置目录和文件路径的能力。
-
## 导入模块
```js
@@ -16,10 +16,10 @@ import configPolicy from '@ohos.configPolicy';
## getOneCfgFile
-getOneCfgFile(relPath: string, callback: AsyncCallback<string>): void
+getOneCfgFile(relPath: string, callback: AsyncCallback<string>)
使用callback形式返回指定文件名的最高优先级配置文件路径。
-例如,config.xml在设备中存在以下路径(优先级从低到高):/system/etc/config.xml、/sys-pod/etc/config.xml,最终返回/sys-pod/etc/config.xml。
+例如,config.xml在设备中存在以下路径(优先级从低到高):/system/etc/config.xml、/sys_pod/etc/config.xml,最终返回/sys_pod/etc/config.xml。
**系统能力**:SystemCapability.Customization.ConfigPolicy
@@ -31,7 +31,7 @@ getOneCfgFile(relPath: string, callback: AsyncCallback<string>): void
**示例:**
```js
- configPolicy.getOneCfgFile('config.xml', (error, value) => {
+ configPolicy.getOneCfgFile('etc/config.xml', (error, value) => {
if (error == undefined) {
console.log("value is " + value);
} else {
@@ -61,7 +61,7 @@ getOneCfgFile(relPath: string): Promise<string>
**示例:**
```js
- configPolicy.getOneCfgFile('config.xml').then(value => {
+ configPolicy.getOneCfgFile('etc/config.xml').then(value => {
console.log("value is " + value);
}).catch(error => {
console.log("getOneCfgFile promise " + error);
@@ -71,10 +71,10 @@ getOneCfgFile(relPath: string): Promise<string>
## getCfgFiles
-getCfgFiles(relPath: string, callback: AsyncCallback<Array<string>>): void
+getCfgFiles(relPath: string, callback: AsyncCallback<Array<string>>)
按优先级从低到高,使用callback形式返回指定文件名所有的文件列表。例如,config.xml在设备中存在以下路径(优先级从低到高):/system/etc/config.xml、
-/sys-pod/etc/config.xml,最终返回/system/etc/config.xml, /sys-pod/etc/config.xml。
+/sys_pod/etc/config.xml,最终返回/system/etc/config.xml, /sys_pod/etc/config.xml。
**系统能力**:SystemCapability.Customization.ConfigPolicy
@@ -86,7 +86,7 @@ getCfgFiles(relPath: string, callback: AsyncCallback<Array<string>>)
**示例:**
```js
- configPolicy.getCfgFiles('config.xml', (error, value) => {
+ configPolicy.getCfgFiles('etc/config.xml', (error, value) => {
if (error == undefined) {
console.log("value is " + value);
} else {
@@ -116,7 +116,7 @@ getCfgFiles(relPath: string): Promise<Array<string>>
**示例:**
```js
- configPolicy.getCfgFiles('config.xml').then(value => {
+ configPolicy.getCfgFiles('etc/config.xml').then(value => {
console.log("value is " + value);
}).catch(error => {
console.log("getCfgFiles promise " + error);
@@ -126,7 +126,7 @@ getCfgFiles(relPath: string): Promise<Array<string>>
## getCfgDirList
-getCfgDirList(callback: AsyncCallback<Array<string>>): void
+getCfgDirList(callback: AsyncCallback<Array<string>>)
使用callback形式返回配置层级目录列表。
diff --git a/zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md b/zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md
index 850bf85772169a580ee097a2ae0bca8ac2ec5ba1..113d782651b6a772ab9a10582e18d4a7ea174ecb 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md
@@ -46,10 +46,10 @@ isIdleState(bundleName: string, callback: AsyncCallback<boolean>): void
```
bundleState.isIdleState("com.ohos.camera", (err, res) => {
- if(err.code === 0) {
- console.log('BUNDLE_ACTIVE isIdleState callback succeeded, result: ' + JSON.stringify(res));
- } else {
+ if (err) {
console.log('BUNDLE_ACTIVE isIdleState callback failed, because: ' + err.code);
+ } else {
+ console.log('BUNDLE_ACTIVE isIdleState callback succeeded, result: ' + JSON.stringify(res));
}
});
```
@@ -77,9 +77,9 @@ isIdleState(bundleName: string): Promise<boolean>
**示例**:
```
- bundleState.isIdleState("com.ohos.camera").then( res => {
+ bundleState.isIdleState("com.ohos.camera").then(res => {
console.log('BUNDLE_ACTIVE isIdleState promise succeeded, result: ' + JSON.stringify(res));
- }).catch( err => {
+ }).catch(err => {
console.log('BUNDLE_ACTIVE isIdleState promise failed, because: ' + err.code);
});
```
@@ -102,10 +102,10 @@ queryAppUsagePriorityGroup(callback: AsyncCallback<number>): void
```
bundleState.queryAppUsagePriorityGroup((err, res) => {
- if(err.code === 0) {
- console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res));
- } else {
+ if (err) {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code);
+ } else {
+ console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res));
}
});
```
@@ -127,9 +127,9 @@ queryAppUsagePriorityGroup(): Promise<number>
**示例**:
```
- bundleState.queryAppUsagePriorityGroup().then( res => {
+ bundleState.queryAppUsagePriorityGroup().then(res => {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res));
- }).catch( err => {
+ }).catch(err => {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code);
});
```
@@ -158,16 +158,16 @@ queryBundleStateInfos(begin: number, end: number, callback: AsyncCallback<Bun
```
bundleState.queryBundleStateInfos(0, 20000000000000, (err, res) => {
- if(err.code == 0) {
+ if (err) {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfos callback failed, because: ' + err.code);
+ } else {
console.log('BUNDLE_ACTIVE queryBundleStateInfos callback success.');
let i = 1;
- for(let key in res){
+ for (let key in res) {
console.log('BUNDLE_ACTIVE queryBundleStateInfos callback number : ' + i);
console.log('BUNDLE_ACTIVE queryBundleStateInfos callback result ' + JSON.stringify(res[key]));
i++;
}
- } else {
- console.log('BUNDLE_ACTIVE queryBundleStateInfos callback failed, because: ' + err.code);
}
});
```
@@ -200,15 +200,15 @@ queryBundleStateInfos(begin: number, end: number): Promise<BundleActiveInfoRe
**示例**:
```
- bundleState.queryBundleStateInfos(0, 20000000000000).then( res => {
+ bundleState.queryBundleStateInfos(0, 20000000000000).then(res => {
console.log('BUNDLE_ACTIVE queryBundleStateInfos promise success.');
let i = 1;
- for(let key in res){
+ for (let key in res) {
console.log('BUNDLE_ACTIVE queryBundleStateInfos promise number : ' + i);
console.log('BUNDLE_ACTIVE queryBundleStateInfos promise result ' + JSON.stringify(res[key]));
i++;
}
- }).catch( err => {
+ }).catch(err => {
console.log('BUNDLE_ACTIVE queryBundleStateInfos promise failed, because: ' + err.code);
});
```
@@ -238,14 +238,14 @@ queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: num
```
bundleState.queryBundleStateInfoByInterval(0, 0, 20000000000000, (err, res) => {
- if(err.code == 0) {
+ if (err) {
+ console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback failed, because: ' + err.code);
+ } else {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback success.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback result ' + JSON.stringify(res[i]));
}
- } else {
- console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback failed, because: ' + err.code);
}
});
```
@@ -279,13 +279,13 @@ queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: num
**示例**:
```
- bundleState.queryBundleStateInfoByInterval(0, 0, 20000000000000).then( res => {
+ bundleState.queryBundleStateInfoByInterval(0, 0, 20000000000000).then(res => {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise success.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise number : ' + (i + 1));
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise result ' + JSON.stringify(res[i]));
}
- }).catch( err => {
+ }).catch(err => {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise failed, because: ' + err.code);
});
```
@@ -314,14 +314,14 @@ queryBundleActiveStates(begin: number, end: number, callback: AsyncCallback<A
```
bundleState.queryBundleActiveStates(0, 20000000000000, (err, res) => {
- if(err.code == 0) {
+ if (err) {
+ console.log('BUNDLE_ACTIVE queryBundleActiveStates callback failed, because: ' + err.code);
+ } else {
console.log('BUNDLE_ACTIVE queryBundleActiveStates callback success.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE queryBundleActiveStates callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE queryBundleActiveStates callback result ' + JSON.stringify(res[i]));
}
- } else {
- console.log('BUNDLE_ACTIVE queryBundleActiveStates callback failed, because: ' + err.code);
}
});
```
@@ -354,13 +354,13 @@ queryBundleActiveStates(begin: number, end: number): Promise<Array<BundleA
**示例**:
```
- bundleState.queryBundleActiveStates(0, 20000000000000).then( res => {
+ bundleState.queryBundleActiveStates(0, 20000000000000).then(res => {
console.log('BUNDLE_ACTIVE queryBundleActiveStates promise success.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE queryBundleActiveStates promise number : ' + (i + 1));
console.log('BUNDLE_ACTIVE queryBundleActiveStates promise result ' + JSON.stringify(res[i]));
}
- }).catch( err => {
+ }).catch(err => {
console.log('BUNDLE_ACTIVE queryBundleActiveStates promise failed, because: ' + err.code);
});
```
@@ -385,14 +385,14 @@ queryCurrentBundleActiveStates(begin: number, end: number, callback: AsyncCallba
```
bundleState.queryCurrentBundleActiveStates(0, 20000000000000, (err, res) => {
- if(err.code == 0) {
+ if (err) {
+ console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback failed, because: ' + err.code);
+ } else {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback success.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback result ' + JSON.stringify(res[i]));
}
- } else {
- console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback failed, because: ' + err.code);
}
});
```
@@ -421,13 +421,13 @@ queryCurrentBundleActiveStates(begin: number, end: number): Promise<Array<
**示例**:
```
- bundleState.queryCurrentBundleActiveStates(0, 20000000000000).then( res => {
+ bundleState.queryCurrentBundleActiveStates(0, 20000000000000).then(res => {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise success.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise number : ' + (i + 1));
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise result ' + JSON.stringify(res[i]));
}
- }).catch( err => {
+ }).catch(err => {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise failed, because: ' + err.code);
});
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-document.md b/zh-cn/application-dev/reference/apis/js-apis-document.md
index 55565aaaffc0a8428039bfcdc37946b226da7c49..24209f0f91c39ffb4b5b33297f94703789302944 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-document.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-document.md
@@ -12,28 +12,28 @@ import document from '@ohos.document';
## document.choose
-choose(types:string[]): Promise<string>
+choose(types? : string[]): Promise<string>
通过文件管理器选择文件,异步返回文件URI,使用promise形式返回结果。
**系统能力**:SystemCapability.FileManagement.UserFileService
-- 参数:
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ---------------------------- |
| types | string[] | 否 | 限定文件选择的类型 |
-- 返回值:
+**返回值:**
| 类型 | 说明 |
| --------------------- | -------------- |
| Promise<string> | 异步返回文件URI(注:当前返回错误码) |
-- 示例:
+**示例:**
```js
- let tpyes = [];
+ let types = [];
document.choose(types);
```
## document.choose
@@ -44,13 +44,13 @@ choose(callback:AsyncCallback<string>): void
**系统能力**:SystemCapability.FileManagement.UserFileService
-- 参数:
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ---------------------------- |
| callback | AsyncCallback<string> | 是 | 异步获取对应文件URI(注:当前返回错误码) |
-- 示例:
+**示例:**
```js
let uri = "";
@@ -66,14 +66,14 @@ choose(types:string[], callback:AsyncCallback<string>): void
**系统能力**:SystemCapability.FileManagement.UserFileService
-- 参数:
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ---------------------------- |
| types | string[] | 否 | 限定选择文件的类型 |
| callback | AsyncCallback<string> | 是 | 异步获取对应文件URI(注:当前返回错误码) |
-- 示例:
+**示例:**
```js
let types = [];
@@ -91,20 +91,20 @@ show(uri:string, type:string):Promise<void>
**系统能力**:SystemCapability.FileManagement.UserFileService
-- 参数:
+**参数:**
| 参数 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ---------------------------- |
| uri | string | 是 | 待打开的文件URI |
| type | string | 是 | 待打开文件的类型 |
-- 返回值:
+**返回值:**
| 类型 | 说明 |
| --------------------- | ------------ |
| Promise<void> | Promise回调返回void表示成功打开文件(注:当前返回错误码) |
-- 示例:
+**示例:**
```js
let type = "";
@@ -120,7 +120,7 @@ show(uri:string, type:string, callback:AsyncCallback<void>): void
**系统能力**:SystemCapability.FileManagement.UserFileService
-- 参数:
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ---------------------------- |
@@ -128,7 +128,7 @@ show(uri:string, type:string, callback:AsyncCallback<void>): void
| type | string | 是 | 待打开文件的类型 |
| callback | AsyncCallback<void> | 是 | 异步打开uri对应文件(注:当前返回错误码) |
-- 示例:
+**示例:**
```js
let type = "";
diff --git a/zh-cn/application-dev/reference/apis/js-apis-environment.md b/zh-cn/application-dev/reference/apis/js-apis-environment.md
index 518975f8f7ec926a05b0680098d47738fd28d658..768e6c876aa8382bdbee09ce92dc88fe8ce831ec 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-environment.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-environment.md
@@ -1,12 +1,12 @@
# 目录环境能力
+该模块提供环境目录能力,获取内存存储根目录、公共文件根目录的JS接口。
+
>  **说明:**
>
> - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - 本模块接口为系统接口,三方应用不支持调用。
-该模块提供环境目录能力,获取内存存储根目录、公共文件根目录的JS接口。
-
## 导入模块
```js
diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileio.md b/zh-cn/application-dev/reference/apis/js-apis-fileio.md
index 819d2a52a696b95108ca4ff9c1286b79d213efbd..6ef63e184d23e2f5a09baab4d0090978402fa7b7 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-fileio.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-fileio.md
@@ -1,10 +1,10 @@
# 文件管理
+该模块提供文件存储管理能力,包括文件基本管理、文件目录管理、文件信息统计、文件流式读写等常用功能。
+
>  **说明:**
> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
-该模块提供文件存储管理能力,包括文件基本管理、文件目录管理、文件信息统计、文件流式读写等常用功能。
-
## 导入模块
```js
@@ -22,7 +22,7 @@ import fileio from '@ohos.fileio';
context.getFilesDir().then((data) => {
path = data;
})
-```
+ ```
## fileio.stat
@@ -546,7 +546,7 @@ open(path: string, flags?: number, mode?: number): Promise<number>
```js
fileio.open(path, 0o1, 0o0200).then(function(number){
console.info("open file succeed");
- }).catch(function(error){
+ }).catch(function(err){
console.info("open file failed with error:"+ err);
});
```
@@ -639,11 +639,11 @@ read(fd: number, buffer: ArrayBuffer, options?: {
```js
let fd = fileio.openSync(path, 0o2);
let buf = new ArrayBuffer(4096);
- fileio.read(fd, buf).then(function(readout){
+ fileio.read(fd, buf).then(function(readOut){
console.info("read file data succeed");
console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer)));
- }).catch(function(error){
- console.info("read file data failed with error:"+ error);
+ }).catch(function(err){
+ console.info("read file data failed with error:"+ err);
});
```
@@ -879,7 +879,7 @@ write(fd: number, buffer: ArrayBuffer | string, options?: {
**示例:**
```js
- let fd = fileio.openSync(fpath, 0o100 | 0o2, 0o666);
+ let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, "hello, world").then(function(number){
console.info("write data to file succeed and size is:"+ number);
}).catch(function(err){
@@ -998,7 +998,7 @@ hash(path: string, algorithm: string, callback: AsyncCallback<string>): vo
**示例:**
```js
- fileio.hash(fpath, "sha256", function(err, hashStr) {
+ fileio.hash(path, "sha256", function(err, hashStr) {
if (hashStr) {
console.info("calculate file hash succeed:"+ hashStr);
}
@@ -1074,7 +1074,7 @@ chmodSync(path: string, mode: number): void
**示例:**
```js
- fileio.chmodSync(fpath, mode);
+ fileio.chmodSync(path, mode);
```
@@ -1409,7 +1409,7 @@ lstat(path: string): Promise<Stat>
**示例:**
```js
fileio.lstat(path).then(function(stat){
- console.info("get link status succeed:"+ number);
+ console.info("get link status succeed:"+ JSON.stringify(stat));
}).catch(function(err){
console.info("get link status failed with error:"+ err);
});
@@ -1663,7 +1663,7 @@ fsyncSync(fd: number): void
**示例:**
```js
- fileio.fyncsSync(fd);
+ fileio.fsyncSync(fd);
```
@@ -1857,7 +1857,7 @@ chown(path: string, uid: number, gid: number, callback: AsyncCallback<void>
**示例:**
```js
- let stat = fileio.statSync(fpath)
+ let stat = fileio.statSync(path)
fileio.chown(path, stat.uid, stat.gid, function (err){
// do something
});
@@ -1881,7 +1881,7 @@ chownSync(path: string, uid: number, gid: number): void
**示例:**
```js
- let stat = fileio.statSync(fpath)
+ let stat = fileio.statSync(path)
fileio.chownSync(path, stat.uid, stat.gid);
```
@@ -2078,7 +2078,7 @@ createStream(path: string, mode: string, callback: AsyncCallback<Stream>):
**示例:**
```js
- fileio.createStream(path, mode, function(err, stream){
+ fileio.createStream(path, "r+", function(err, stream){
// do something
});
```
@@ -2130,7 +2130,8 @@ fdopenStream(fd: number, mode: string): Promise<Stream>
**示例:**
```js
- fileio.fdopenStream(fd, mode).then(function(stream){
+ let fd = fileio.openSync(path);
+ fileio.fdopenStream(fd, "r+").then(function(stream){
console.info("openStream succeed");
}).catch(function(err){
console.info("openStream failed with error:"+ err);
@@ -2155,7 +2156,8 @@ fdopenStream(fd: number, mode: string, callback: AsyncCallback<Stream>): v
**示例:**
```js
- fileio.fdopenStream(fd, mode, function (err, stream) {
+ let fd = fileio.openSync(path);
+ fileio.fdopenStream(fd, "r+", function (err, stream) {
// do something
});
```
@@ -2182,6 +2184,7 @@ fdopenStreamSync(fd: number, mode: string): Stream
**示例:**
```js
+ let fd = fileio.openSync(path);
let ss = fileio.fdopenStreamSync(fd, "r+");
```
@@ -2235,7 +2238,7 @@ fchown(fd: number, uid: number, gid: number, callback: AsyncCallback<void>
**示例:**
```js
- let stat = fileio.statSync(fpath);
+ let stat = fileio.statSync(path);
fileio.fchown(fd, stat.uid, stat.gid, function (err){
// do something
});
@@ -2259,7 +2262,7 @@ fchownSync(fd: number, uid: number, gid: number): void
**示例:**
```js
- let stat = fileio.statSync(fpath);
+ let stat = fileio.statSync(path);
fileio.fchownSync(fd, stat.uid, stat.gid);
```
@@ -2364,9 +2367,11 @@ createWatcher(filename: string, events: number, callback: AsyncCallback<numbe
**示例:**
```js
- fileio.createWatcher(filename, events, function(watcher){
- // do something
+ let filename = path +"/test.txt";
+ fileio.createWatcher(filename, 1, function(number){
+ console.info("Monitoring times: "+number);
});
+
```
@@ -2498,7 +2503,7 @@ isFile(): boolean
**示例:**
```js
- let isFile = fileio.statSync(fpath).isFile();
+ let isFile = fileio.statSync(path).isFile();
```
@@ -2555,7 +2560,13 @@ stop(): Promise<void>
**示例:**
```js
- fileio.stop();
+ let filename = path +"/test.txt";
+ let watcher = await fileio.createWatcher(filename, 1, function(number){
+ console.info("Monitoring times: "+number);
+ });
+ watcher.stop().then(function(){
+ console.info("close watcher succeed");
+ });
```
@@ -2574,13 +2585,17 @@ stop(callback: AsyncCallback<void>): void
**示例:**
```js
- fileio.stop(function(err){
- // do something
+ let filename = path +"/test.txt";
+ let watcher = await fileio.createWatcher(filename, 1, function(number){
+ console.info("Monitoring times: "+number);
});
+ watcher.stop(function(){
+ console.info("close watcher succeed");
+ })
```
-## Stream7+
+## Stream
文件流,在调用Stream的方法前,需要先通过createStream()方法(同步或异步)来构建一个Stream实例。
@@ -2600,7 +2615,7 @@ close(): Promise<void>
**示例:**
```js
- let ss= fileio.createStreamSync(path);
+ let ss= fileio.createStreamSync(path, "r+");
ss.close().then(function(){
console.info("close fileStream succeed");
}).catch(function(err){
@@ -2624,7 +2639,7 @@ close(callback: AsyncCallback<void>): void
**示例:**
```js
- let ss= fileio.createStreamSync(path);
+ let ss= fileio.createStreamSync(path, "r+");
ss.close(function (err) {
// do something
});
@@ -2641,7 +2656,7 @@ closeSync(): void
**示例:**
```js
- let ss= fileio.createStreamSync(path);
+ let ss= fileio.createStreamSync(path, "r+");
ss.closeSync();
```
@@ -2661,7 +2676,7 @@ flush(): Promise<void>
**示例:**
```js
- let ss= fileio.createStreamSync(path);
+ let ss= fileio.createStreamSync(path, "r+");
ss.flush().then(function (){
console.info("flush succeed");
}).catch(function(err){
@@ -2685,7 +2700,7 @@ flush(callback: AsyncCallback<void>): void
**示例:**
```js
- let ss= fileio.createStreamSync(path);
+ let ss= fileio.createStreamSync(path, "r+");
ss.flush(function (err) {
// do something
});
@@ -2702,7 +2717,7 @@ flushSync(): void
**示例:**
```js
- let ss= fileio.createStreamSync(path);
+ let ss= fileio.createStreamSync(path, "r+");
ss.flushSync();
```
@@ -2733,7 +2748,7 @@ write(buffer: ArrayBuffer | string, options?: {
**示例:**
```js
- let ss= fileio.createStreamSync(fpath, "r+");
+ let ss= fileio.createStreamSync(path, "r+");
ss.write("hello, world",{offset: 1,length: 5,position: 5,encoding :'utf-8'}).then(function (number){
console.info("write succeed and size is:"+ number);
}).catch(function(err){
@@ -2764,7 +2779,7 @@ write(buffer: ArrayBuffer | string, options: {
**示例:**
```js
- let ss= fileio.createStreamSync(fpath, "r+");
+ let ss= fileio.createStreamSync(path, "r+");
ss.write("hello, world", {offset: 1, length: 5, position: 5, encoding :'utf-8'}, function (err, bytesWritten) {
if (bytesWritten) {
// do something
@@ -2800,7 +2815,7 @@ writeSync(buffer: ArrayBuffer | string, options?: {
**示例:**
```js
- let ss= fileio.createStreamSync(fpath,"r+");
+ let ss= fileio.createStreamSync(path,"r+");
let num = ss.writeSync("hello, world", {offset: 1, length: 5, position: 5, encoding :'utf-8'});
```
@@ -2830,7 +2845,7 @@ read(buffer: ArrayBuffer, options?: {
**示例:**
```js
- let ss = fileio.createStreamSync(fpath, "r+");
+ let ss = fileio.createStreamSync(path, "r+");
ss.read(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5}).then(function (readout){
console.info("read data succeed");
console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer)));
@@ -2861,7 +2876,7 @@ read(buffer: ArrayBuffer, options: {
**示例:**
```js
- let ss = fileio.createStreamSync(fpath, "r+");
+ let ss = fileio.createStreamSync(path, "r+");
ss.read(new ArrayBuffer(4096),{offset: 1, length: 5, position: 5},function (err, readOut) {
if (readOut) {
console.info("read data succeed");
@@ -2898,7 +2913,7 @@ readSync(buffer: ArrayBuffer, options?: {
**示例:**
```js
- let ss = fileio.createStreamSync(fpath, "r+");
+ let ss = fileio.createStreamSync(path, "r+");
let num = ss.readSync(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5});
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-filemanager.md b/zh-cn/application-dev/reference/apis/js-apis-filemanager.md
index 2d3d39a2071b75e0145d35ab50a9fe0f294d3362..802d3d71d66bb58f8cf9e49f85d4d2f336453140 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-filemanager.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-filemanager.md
@@ -1,11 +1,12 @@
# 公共文件访问与管理
+
+该模块提供公共文件访问和管理的服务接口,向下对接底层文件管理服务,如媒体库、外卡管理;向上对应用程序提供公共文件查询、创建的能力。
+
> **说明:**
>
>- 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>- 本模块接口为系统接口,三方应用不支持调用,当前只支持filepicker调用。
-该模块提供公共文件访问和管理的服务接口,向下对接底层文件管理服务,如媒体库、外卡管理;向上对应用程序提供公共文件查询、创建的能力。
-
## 导入模块
```js
@@ -20,18 +21,18 @@ getRoot(options? : {dev? : DevInfo}) : Promise<FileInfo[]>
**系统能力**:SystemCapability.FileManagement.UserFileService
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | -- |
| options | Object | 否 | 支持如下选项:
- dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local' |
-- 返回值
+**返回值:**
| 类型 | 说明 |
| --- | -- |
| Promise<[FileInfo](#fileinfo)[]> | 第一层目录相册信息 |
-- 示例
+**示例:**
```js
filemanager.getRoot().then((fileInfo) => {
@@ -53,22 +54,22 @@ getRoot(options? : {dev? : DevInfo}, callback : AsyncCallback<FileInfo[]>)
**系统能力**:SystemCapability.FileManagement.UserFileService
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ----------------------------- |
| options | Object | 否 | 支持如下选项:
- dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local' |
| callback | AsyncCallback<[FileInfo](#fileinfo)[]> | 是 | 异步获取文件的信息之后的回调 |
-- 示例
+**示例:**
```js
- let option = {
- "dev":{
- name:"",
- }
+ let options = {
+ "dev":{
+ "name":"local"
+ }
};
- filemanager.getRoot(option,(err, fileInfo)=>{
+ filemanager.getRoot(options, (err, fileInfo)=>{
if(Array.isArray(fileInfo)) {
for (var i = 0; i < fileInfo.length; i++) {
console.log("file:"+JSON.stringify(fileInfo));
@@ -86,27 +87,28 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num
**系统能力**:SystemCapability.FileManagement.UserFileService
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | -- |
| path | string | 是 | 待查询目录uri |
| type | string | 是 | 待查询文件类型, 支持以下类型 "file", "image", "audio", "video" |
| options | Object | 否 | 支持如下选项:
- dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local'。
- offset,number类型,待查询文件偏移个数。
- count,number类型,待查询文件个数。 |
-
-- 返回值
+
+**返回值:**
| 类型 | 说明 |
| --- | -- |
| Promise<FileInfo[]> | 文件信息 |
-- 异常
+**异常:**
+
| 错误名称 | 错误类型 | 错误码 |说明 |
| --- | -- | --- | -- |
| 对应的目录、相册不存在 | No such file or directory | 2 | uri对应的目录、相册不存在 |
| 获取FMS服务失败 | No such process | 3 | 获取FMS服务失败 |
| path对应uri不是相册、目录 | Not a directory | 20 | path对应uri不是相册、目录 |
-- 示例
+**示例:**
```js
// 获取目录下所有文件
@@ -120,10 +122,7 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num
}
}
}).catch((err) => {
-
-
-
- console.log(err)
+ console.log("failed to get file"+err);
});
```
@@ -135,23 +134,24 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num
**系统能力**:SystemCapability.FileManagement.UserFileService
-- 参数
+**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | -------- | ------------------------- | ---- | ------------------------------------------------------------ |
- | path | string | 是 | 待查询目录uri |
- | type | string | 是 | 待查询文件类型, 支持以下类型 "file", "image", "audio", "video" |
- | options | Object | 否 | 支持如下选项:
- dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local'。
- offset,number类型,待查询文件偏移个数。
- count,number类型,待查询文件个数。 |
- | callback | AsyncCallback<[FileInfo](#fileinfo)[]> | 是 | 异步获取文件的信息之后的回调 |
-- 异常
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
+| path | string | 是 | 待查询目录uri |
+| type | string | 是 | 待查询文件类型, 支持以下类型 "file", "image", "audio", "video" |
+| options | Object | 否 | 支持如下选项:
- dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local'。
- offset,number类型,待查询文件偏移个数。
- count,number类型,待查询文件个数。 |
+| callback | AsyncCallback<[FileInfo](#fileinfo)[]> | 是 | 异步获取文件的信息之后的回调 |
- | 错误名称 | 错误类型 | 错误码 | 说明 |
- | ------------------------- | ------------------------- | ------ | ------------------------- |
- | 对应的目录、相册不存在 | No such file or directory | 2 | uri对应的目录、相册不存在 |
- | 获取FMS服务失败 | No such process | 3 | 获取FMS服务失败 |
- | path对应uri不是相册、目录 | Not a directory | 20 | path对应uri不是相册、目录 |
+**异常:**
+
+| 错误名称 | 错误类型 | 错误码 | 说明 |
+| ------------------------- | ------------------------- | ------ | ------------------------- |
+| 对应的目录、相册不存在 | No such file or directory | 2 | uri对应的目录、相册不存在 |
+| 获取FMS服务失败 | No such process | 3 | 获取FMS服务失败 |
+| path对应uri不是相册、目录 | Not a directory | 20 | path对应uri不是相册、目录 |
-- 示例
+**示例:**
```js
// 通过listFile、getRoot获取的文件path
@@ -177,7 +177,7 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num
}
}
}).catch((err) => {
- console.log(err)
+ console.log("failed to get file"+err);
});
```
@@ -189,20 +189,21 @@ createFile(path : string, filename : string, options? : {dev? : DevInfo}) : P
**系统能力**:SystemCapability.FileManagement.UserFileService
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | -- |
| filename | string | 是 | 待创建的文件名 |
| path | string | 是 | 待保存目的相册uri |
| options | Object | 否 | 支持如下选项:
- dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local' |
-- 返回值
+**返回值:**
- | 类型 | 说明 |
- | --- | -- |
- | string | 文件uri |
+| 类型 | 说明 |
+| --- | -- |
+| Promise<string> | 文件uri |
+
+**异常:**
-- 异常
| 错误名称 | 错误类型 | 错误码 |说明 |
| --- | -- | --- | -- |
| 创建文件不允许 | Operation not permitted | 1 | 已有重名文件 |
@@ -210,7 +211,7 @@ createFile(path : string, filename : string, options? : {dev? : DevInfo}) : P
| 获取FMS服务失败 | No such process | 3 | 获取FMS服务失败 |
| path对应uri不是相册、目录 | Not a directory | 20 | path对应uri不是相册、目录 |
-- 示例
+**示例:**
```js
// 创建文件,返回文件uri
@@ -232,7 +233,7 @@ createFile(path : string, filename: string, options? : {dev? : DevInfo}, callbac
**系统能力**:SystemCapability.FileManagement.UserFileService
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ----------------------------- |
@@ -241,7 +242,7 @@ createFile(path : string, filename: string, options? : {dev? : DevInfo}, callbac
| options | Object | 否 | 支持如下选项:
- dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local' |
| callback | AsyncCallback<[FileInfo](#fileinfo)[]> | 是 | 异步获取文件的信息之后的回调 |
-- 异常
+**异常:**
| 错误名称 | 错误类型 | 错误码 | 说明 |
| ------------------------- | ------------------------- | ------ | ------------------------- |
@@ -250,7 +251,7 @@ createFile(path : string, filename: string, options? : {dev? : DevInfo}, callbac
| 获取FMS服务失败 | No such process | 3 | 获取FMS服务失败 |
| path对应uri不是相册、目录 | Not a directory | 20 | path对应uri不是相册、目录 |
-- 示例
+**示例:**
```js
// 创建文件,返回文件uri
@@ -258,11 +259,15 @@ createFile(path : string, filename: string, options? : {dev? : DevInfo}, callbac
let media_path = ""
// 待保存文件的后缀
let name = "xxx.jpg"
- let dev = "";
- filemanager.createFile(media_path, name, { DevInfo: dev }, function(err, uri) {
- // 返回uri给应用
+ let options = {
+ "dev":{
+ "name":"local"
+ }
+ };
+ filemanager.createFile(media_path, name, options, function(err, uri) {
+ // 返回uri给应用
console.log("file uri:"+uri);
- });
+ });
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-image.md b/zh-cn/application-dev/reference/apis/js-apis-image.md
index 0ad40735f64e37776005765481fcd817d15575f9..37385a4c6fba5dc3b840e82a4de9ab2a36bfc62a 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-image.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-image.md
@@ -2,12 +2,10 @@
> **说明:**
> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
->
-> API Version 9当前为Canary版本,仅供试用,不保证接口可稳定调用。
## 导入模块
-```
+```js
import image from '@ohos.multimedia.image';
```
@@ -22,8 +20,8 @@ createPixelMap(colors: ArrayBuffer, options: InitializationOptions): Promise\ {
- })
+const color = new ArrayBuffer(96);
+let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
+image.createPixelMap(color, opts)
+ .then((pixelmap) => {
+ })
```
## image.createPixelMap8+
@@ -51,15 +51,17 @@ createPixelMap(colors: ArrayBuffer, options: InitializationOptions, callback: As
| 名称 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------ | ---- | -------------------------- |
-| colors | ArrayBuffer | 是 | 颜色数组。 |
-| options | [InitializetionOptions](#initializationoptions8) | 是 | 属性。 |
+| colors | ArrayBuffer | 是 | BGRA_8888格式的颜色数组。 |
+| options | [InitializationOptions](#initializationoptions8) | 是 | 属性。 |
| callback | AsyncCallback\<[PixelMap](#pixelmap7)> | 是 | 通过回调返回PixelMap对象。 |
**示例:**
```js
-image.createPixelMap(Color, opts, (pixelmap) => {
- })
+const color = new ArrayBuffer(96);
+let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
+image.createPixelMap(color, opts, (pixelmap) => {
+ })
```
## PixelMap7+
@@ -68,9 +70,11 @@ image.createPixelMap(Color, opts, (pixelmap) => {
### 属性
-| 名称 | 类型 | 可读 | 可写 | 说明 |
-| ----------------------- | ------- | ---- | ---- | ------------------------------------------------------------ |
-| isEditable7+ | boolean | 是 | 否 | 设定是否图像像素可被编辑。
**系统能力:** SystemCapability.Multimedia.Image |
+**系统能力:** SystemCapability.Multimedia.Image
+
+| 名称 | 类型 | 可读 | 可写 | 说明 |
+| ----------------------- | ------- | ---- | ---- | -------------------------- |
+| isEditable7+ | boolean | 是 | 否 | 设定是否图像像素可被编辑。 |
### readPixelsToBuffer7+
@@ -95,11 +99,11 @@ readPixelsToBuffer(dst: ArrayBuffer): Promise\
**示例:**
```js
-pixelmap.readPixelsToBuffer(readBuffer).then(() => {
- //符合条件则进入
- }).catch(error => {
- //不符合条件则进入
- })
+pixelmap.readPixelsToBuffer(ReadBuffer).then(() => {
+ console.log('readPixelsToBuffer succeeded.'); //符合条件则进入
+}).catch(error => {
+ console.log('readPixelsToBuffer failed.'); //不符合条件则进入
+})
```
### readPixelsToBuffer7+
@@ -120,8 +124,13 @@ readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback\): void
**示例:**
```js
-pixelmap.readPixelsToBuffer(readBuffer, () => {
- })
+pixelmap.readPixelsToBuffer(ReadBuffer, (err, res) => {
+ if(err) {
+ console.log('readPixelsToBuffer failed.'); //不符合条件则进入
+ } else {
+ console.log('readPixelsToBuffer succeeded.'); //符合条件则进入
+ }
+})
```
### readPixels7+
@@ -147,11 +156,11 @@ readPixels(area: PositionArea): Promise\
**示例:**
```js
-pixelmap.readPixels(area).then((data) => {
- //符合条件则进入
- }).catch(error => {
- //不符合条件则进入
- })
+pixelmap.readPixels(Area).then((data) => {
+ console.log('readPixels succeeded.'); //符合条件则进入
+}).catch(error => {
+ console.log('readPixels failed.'); //不符合条件则进入
+})
```
### readPixels7+
@@ -174,19 +183,17 @@ readPixels(area: PositionArea, callback: AsyncCallback\): void
```js
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
- if(pixelmap == undefined){
- console.info('createPixelMap failed');
- expect(false).assertTrue();
- done();
- }else{
- const area = { pixels: new ArrayBuffer(8),
- offset: 0,
- stride: 8,
- region: { size: { height: 1, width: 2 }, x: 0, y: 0 }}
- pixelmap.readPixels(area, () => {
- console.info('readPixels success');
- })
- }
+ if(pixelmap == undefined){
+ console.info('createPixelMap failed.');
+ } else {
+ const area = { pixels: new ArrayBuffer(8),
+ offset: 0,
+ stride: 8,
+ region: { size: { height: 1, width: 2 }, x: 0, y: 0 }};
+ pixelmap.readPixels(area, () => {
+ console.info('readPixels success');
+ })
+ }
})
```
@@ -218,16 +225,14 @@ let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
.then( pixelmap => {
if (pixelmap == undefined) {
- console.info('createPixelMap failed');
- expect(false).assertTrue()
- done();
+ console.info('createPixelMap failed.');
}
const area = { pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
- var bufferArr = new Uint8Array(area.pixels);
+ let bufferArr = new Uint8Array(area.pixels);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
@@ -240,11 +245,8 @@ image.createPixelMap(color, opts)
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
})
- })
- .catch(error => {
+ }).catch(error => {
console.log('error: ' + error);
- expect().assertFail();
- done();
})
```
@@ -261,19 +263,23 @@ writePixels(area: PositionArea, callback: AsyncCallback\): void
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------------ | ---- | ------------------------------ |
| area | [PositionArea](#positionarea7) | 是 | 区域,根据区域写入。 |
-| callback: | AsyncCallback\ | 是 | 获取回调,失败时返回错误信息。 |
+| callback: | AsyncCallback\ | 是 | 获取回调,失败时error会返回错误信息。 |
**示例:**
```js
-pixelmap.writePixels(area, () => {
- const readArea = {
- pixels: new ArrayBuffer(20),
- offset: 0,
- stride: 8,
- region: { size: { height: 1, width: 2 }, x: 0, y: 0 },
- }
- })
+pixelmap.writePixels(Area, (error) => {
+ if (error!=undefined) {
+ console.info('writePixels failed.');
+ } else {
+ const readArea = {
+ pixels: new ArrayBuffer(20),
+ offset: 0,
+ stride: 8,
+ region: { size: { height: 1, width: 2 }, x: 0, y: 0 },
+ }
+ }
+})
```
### writeBufferToPixels7+
@@ -299,11 +305,11 @@ writeBufferToPixels(src: ArrayBuffer): Promise\
**示例:**
```js
-pixelMap.writeBufferToPixels(colorBuffer).then(() => {
+PixelMap.writeBufferToPixels(color).then(() => {
console.log("Succeeded in writing data from a buffer to a PixelMap.");
}).catch((err) => {
console.error("Failed to write data from a buffer to a PixelMap.");
-});
+})
```
### writeBufferToPixels7+
@@ -324,12 +330,13 @@ writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback\): void
**示例:**
```js
-pixelMap.writeBufferToPixels(colorBuffer, function(err) {
+PixelMap.writeBufferToPixels(color, function(err) {
if (err) {
console.error("Failed to write data from a buffer to a PixelMap.");
return;
- }
- console.log("Succeeded in writing data from a buffer to a PixelMap.");
+ } else {
+ console.log("Succeeded in writing data from a buffer to a PixelMap.");
+ }
});
```
@@ -350,7 +357,7 @@ getImageInfo(): Promise\
**示例:**
```js
-pixelMap.getImageInfo().then(function(info) {
+PixelMap.getImageInfo().then(function(info) {
console.log("Succeeded in obtaining the image pixel map information.");
}).catch((err) => {
console.error("Failed to obtain the image pixel map information.");
@@ -374,7 +381,11 @@ getImageInfo(callback: AsyncCallback\): void
**示例:**
```js
-pixelmap.getImageInfo((imageInfo) => {})
+pixelmap.getImageInfo((imageInfo) => {
+ console.log("getImageInfo succeeded.");
+}).catch((err) => {
+ console.error("getImageInfo failed.");
+})
```
### getBytesNumberPerRow7+
@@ -394,7 +405,9 @@ getBytesNumberPerRow(): number
**示例:**
```js
-rowCount = pixelmap.getBytesNumberPerRow()
+image.createPixelMap(clolr, opts, (err,pixelmap) => {
+ let rowCount = pixelmap.getBytesNumberPerRow();
+})
```
### getPixelBytesNumber7+
@@ -414,7 +427,7 @@ getPixelBytesNumber(): number
**示例:**
```js
-pixelBytesNumber = pixelmap.getPixelBytesNumber()
+let pixelBytesNumber = pixelmap.getPixelBytesNumber();
```
### release7+
@@ -434,8 +447,13 @@ release():Promise\
**示例:**
```js
- pixelmap.release().then(() => { })
- .catch(error => {})
+image.createPixelMap(color, opts, (pixelmap) => {
+ pixelmap.release().then(() => {
+ console.log('release succeeded.');
+ }).catch(error => {
+ console.log('release failed.');
+ })
+})
```
### release7+
@@ -455,7 +473,13 @@ release(callback: AsyncCallback\): void
**示例:**
```js
-pixelmap.release(()=>{ })
+image.createPixelMap(color, opts, (pixelmap) => {
+ pixelmap.release().then(() => {
+ console.log('release succeeded.');
+ }).catch(error => {
+ console.log('release failed.');
+ })
+})
```
## image.createImageSource
@@ -508,7 +532,7 @@ createImageSource(fd: number): ImageSource
**示例:**
```js
-const imageSourceApi = image.createImageSource(0)
+const imageSourceApi = image.createImageSource(0);
```
## ImageSource
@@ -517,9 +541,11 @@ const imageSourceApi = image.createImageSource(0)
### 属性
+**系统能力:** SystemCapability.Multimedia.Image
+
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ---------------- | -------------- | ---- | ---- | ------------------------------------------------------------ |
-| supportedFormats | Array\ | 是 | 否 | 支持的图片格式,包括:png,jpeg,wbmp,bmp,gif,webp,heif等。
**系统能力:** SystemCapability.Multimedia.Image |
+| supportedFormats | Array\ | 是 | 否 | 支持的图片格式,包括:png,jpeg,wbmp,bmp,gif,webp,heif等。 |
### getImageInfo
@@ -539,7 +565,13 @@ getImageInfo(index: number, callback: AsyncCallback\): void
**示例:**
```js
-imageSourceApi.getImageInfo(0,(error, imageInfo) => {})
+imageSourceApi.getImageInfo(0,(error, imageInfo) => {
+ if(error) {
+ console.log('getImageInfo failed.');
+ } else {
+ console.log('getImageInfo succeeded.');
+ }
+})
```
### getImageInfo
@@ -559,7 +591,11 @@ getImageInfo(callback: AsyncCallback\): void
**示例:**
```js
-imageSourceApi.getImageInfo(imageInfo => {})
+imageSourceApi.getImageInfo(imageInfo => {
+ console.log('getImageInfo succeeded.');
+}).catch(error => {
+ console.log('getImageInfo failed.');
+})
```
### getImageInfo
@@ -586,8 +622,11 @@ getImageInfo(index?: number): Promise\
```js
imageSourceApi.getImageInfo(0)
- .then(imageInfo => {})
- .catch(error => {})
+ .then(imageInfo => {
+ console.log('getImageInfo succeeded.');
+ }).catch(error => {
+ console.log('getImageInfo failed.');
+ })
```
### getImageProperty7+
@@ -615,8 +654,11 @@ getImageProperty(key:string, options?: GetImagePropertyOptions): Promise\ {})
- .catch(error => {})
+ .then(data => {
+ console.log('getImageProperty succeeded.');
+ }).catch(error => {
+ console.log('getImageProperty failed.');
+ })
```
### getImageProperty7+
@@ -637,7 +679,13 @@ getImageProperty(key:string, callback: AsyncCallback\): void
**示例:**
```js
-imageSourceApi.getImageProperty("BitsPerSample",(error,data) => {})
+imageSourceApi.getImageProperty("BitsPerSample",(error,data) => {
+ if(error) {
+ console.log('getImageProperty failed.');
+ } else {
+ console.log('getImageProperty succeeded.');
+ }
+})
```
### getImageProperty7+
@@ -659,7 +707,13 @@ getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCa
**示例:**
```js
-imageSourceApi.getImageProperty("BitsPerSample",property,(error,data) => {})
+imageSourceApi.getImageProperty("BitsPerSample",Property,(error,data) => {
+ if(error) {
+ console.log('getImageProperty failed.');
+ } else {
+ console.log('getImageProperty succeeded.');
+ }
+})
```
### createPixelMap7+
@@ -685,8 +739,11 @@ createPixelMap(options?: DecodingOptions): Promise\
**示例:**
```js
-imageSourceApi.createPixelMap().then(pixelmap => {})
- .catch(error => {})
+imageSourceApi.createPixelMap().then(pixelmap => {
+ console.log('createPixelMap succeeded.');
+}).catch(error => {
+ console.log('createPixelMap failed.');
+})
```
### createPixelMap7+
@@ -706,7 +763,11 @@ createPixelMap(callback: AsyncCallback\): void
**示例:**
```js
-imageSourceApi.createPixelMap(pixelmap => {})
+imageSourceApi.createPixelMap(pixelmap => {
+ console.log('createPixelMap succeeded.');
+}).catch(error => {
+ console.log('createPixelMap failed.');
+})
```
### createPixelMap7+
@@ -727,7 +788,11 @@ createPixelMap(options: DecodingOptions, callback: AsyncCallback\): vo
**示例:**
```js
-imageSourceApi.createPixelMap(decodingOptions, pixelmap => {})
+imageSourceApi.createPixelMap(decodingOptions, pixelmap => {
+ console.log('createPixelMap succeeded.');
+}).catch(error => {
+ console.log('createPixelMap failed.');
+})
```
### release
@@ -747,7 +812,11 @@ release(callback: AsyncCallback\): void
**示例:**
```js
-imageSourceApi.release(() => {})
+imageSourceApi.release(() => {
+ console.log('release succeeded.');
+}).catch(error => {
+ console.log('release failed.');
+})
```
### release
@@ -767,7 +836,11 @@ release(): Promise\
**示例:**
```js
-imageSourceApi.release().then(()=>{ }).catch(error => {})
+imageSourceApi.release().then(()=>{
+ console.log('release succeeded.');
+}).catch(error => {
+ console.log('release failed.');
+})
```
## image.createImagePacker
@@ -796,9 +869,11 @@ const imagePackerApi = image.createImagePacker();
### 属性
-| 名称 | 类型 | 可读 | 可写 | 说明 |
-| ---------------- | -------------- | ---- | ---- | ------------------------------------------------------------ |
-| supportedFormats | Array\ | 是 | 否 | 图片打包支持的格式,jpeg。
**系统能力:** SystemCapability.Multimedia.Image |
+**系统能力:** SystemCapability.Multimedia.Image
+
+| 名称 | 类型 | 可读 | 可写 | 说明 |
+| ---------------- | -------------- | ---- | ---- | -------------------------- |
+| supportedFormats | Array\ | 是 | 否 | 图片打包支持的格式,jpeg。 |
### packing
@@ -814,13 +889,13 @@ packing(source: ImageSource, option: PackingOption, callback: AsyncCallback\ | 是 | 获取图片打包回调,返回打包后数据。 |
+| callback | AsyncCallback\ | 是 | 获取图片打包回调,返回打包后数据。 |
**示例:**
```js
-let packOpts = { format:["image/jpeg"], quality:98 }
-imagePackerApi.packing(imageSourceApi, packOpts, data => {})
+let packOpts = { format:"image/jpeg", quality:98 };
+imagePackerApi.packing(ImageSourceApi, packOpts, data => {})
```
### packing
@@ -848,9 +923,12 @@ packing(source: ImageSource, option: PackingOption): Promise\
```js
let packOpts = { format:["image/jpeg"], quality:98 }
-imagePackerApi.packing(imageSourceApi, packOpts)
- .then( data => { })
- .catch(error => {})
+imagePackerApi.packing(ImageSourceApi, packOpts)
+ .then( data => {
+ console.log('packing succeeded.');
+ }).catch(error => {
+ console.log('packing failed.');
+ })
```
### packing8+
@@ -873,7 +951,11 @@ packing(source: PixelMap, option: PackingOption, callback: AsyncCallback\ {})
+imagePackerApi.packing(PixelMapApi, packOpts, data => {
+ console.log('packing succeeded.');
+}).catch(error => {
+ console.log('packing failed.');
+})
```
### packing8+
@@ -886,10 +968,10 @@ packing(source: PixelMap, option: PackingOption): Promise\
**参数:**
-| 参数名 | 类型 | 必填 | 说明 |
-| ------ | ------------------------------- | ---- | -------------- |
+| 参数名 | 类型 | 必填 | 说明 |
+| ------ | ------------------------------- | ---- | ------------------ |
| source | [PixelMap](#pixelmap) | 是 | 打包的PixelMap源。 |
-| option | [PackingOption](#packingoption) | 是 | 设置打包参数。 |
+| option | [PackingOption](#packingoption) | 是 | 设置打包参数。 |
**返回值:**
@@ -901,9 +983,12 @@ packing(source: PixelMap, option: PackingOption): Promise\
```js
let packOpts = { format:["image/jpeg"], quality:98 }
-imagePackerApi.packing(pixelMapApi, packOpts)
- .then( data => { })
- .catch(error => {})
+imagePackerApi.packing(PixelMapApi, packOpts)
+ .then( data => {
+ console.log('packing succeeded.');
+ }).catch(error => {
+ console.log('packing failed.');
+ })
```
### release
@@ -923,7 +1008,11 @@ release(callback: AsyncCallback\): void
**示例:**
```js
-imagePackerApi.release(()=>{})
+imagePackerApi.release(()=>{
+ console.log('release succeeded.');
+}).catch(error => {
+ console.log('release failed.');
+})
```
### release
@@ -943,8 +1032,390 @@ release(): Promise\
**示例:**
```js
- imagePackerApi.release().then(()=>{
- }).catch((error)=>{})
+imagePackerApi.release().then(()=>{
+ console.log('release succeeded.');
+}).catch((error)=>{
+ console.log('release failed.');
+})
+```
+
+## image.createImageReceiver9+
+
+createImageReceiver(width: number, height: number, format: number, capacity: number): ImageReceiver
+
+通过宽、高、图片格式、容量创建ImageReceiver实例。
+
+**系统能力:** SystemCapability.Multimedia.Image.ImageReceiver
+
+**参数:**
+
+| 名称 | 类型 | 必填 | 说明 |
+| -------- | ------ | ---- | ---------------------- |
+| width | number | 是 | 图像的默认宽度。 |
+| height | number | 是 | 图像的默认高度。 |
+| format | number | 是 | 图像格式。 |
+| capacity | number | 是 | 同时访问的最大图像数。 |
+
+**返回值:**
+
+| 类型 | 说明 |
+| -------------------------------- | --------------------------------------- |
+| [ImageReceiver](#imagereceiver9) | 如果操作成功,则返回ImageReceiver实例。 |
+
+**示例:**
+
+```js
+var receiver = image.createImageReceiver(8192, 8, 4, 8);
+```
+
+## ImageReceiver9+
+
+图像接收类,用于获取组件surface id,接收最新的图片和读取下一张图片,以及释放ImageReceiver实例。
+
+在调用以下方法前需要先创建ImageReceiver实例。
+
+### 属性
+
+**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image.ImageReceiver
+
+| 名称 | 类型 | 可读 | 可写 | 说明 |
+| --------------------- | ---------------------------- | ---- | ---- | ------------------ |
+| size9+ | [Size](#size) | 是 | 否 | 图片大小。 |
+| capacity9+ | number | 是 | 否 | 同时访问的图像数。 |
+| format9+ | [ImageFormat](#imageformat9) | 是 | 否 | 图像格式。 |
+
+### getReceivingSurfaceId9+
+
+getReceivingSurfaceId(callback: AsyncCallback\): void
+
+用于获取一个surface id供Camera或其他组件使用。使用callback返回结果。
+
+**系统能力:** SystemCapability.Multimedia.Image.ImageReceiver
+
+**参数:**
+
+| 名称 | 类型 | 必填 | 说明 |
+| -------- | ---------------------- | ---- | -------------------------- |
+| callback | AsyncCallback\ | 是 | 回调函数,返回surface id。 |
+
+**示例:**
+
+```js
+ receiver.getReceivingSurfaceId((err, id) => {
+ if(err) {
+ console.log('getReceivingSurfaceId failed.');
+ } else {
+ console.log('getReceivingSurfaceId succeeded.');
+ }
+});
+```
+
+### getReceivingSurfaceId9+
+
+getReceivingSurfaceId(): Promise\
+
+用于获取一个surface id供Camera或其他组件使用。使用promise返回结果。
+
+**系统能力:** SystemCapability.Multimedia.Image.ImageReceiver
+
+**返回值:**
+
+| 类型 | 说明 |
+| ---------------- | -------------------- |
+| Promise\ | 异步返回surface id。 |
+
+**示例:**
+
+```js
+receiver.getReceivingSurfaceId().then( id => {
+ console.log('getReceivingSurfaceId succeeded.');
+}).catch(error => {
+ console.log('getReceivingSurfaceId failed.');
+})
+```
+
+### readLatestImage9+
+
+readLatestImage(callback: AsyncCallback\): void
+
+从ImageReceiver读取最新的图片,并使用callback返回结果。
+
+**系统能力:** SystemCapability.Multimedia.Image.ImageReceiver
+
+**参数:**
+
+| 名称 | 类型 | 必填 | 说明 |
+| -------- | ------------------------------- | ---- | ------------------------ |
+| callback | AsyncCallback<[Image](#image9)> | 是 | 回调函数,返回最新图像。 |
+
+**示例:**
+
+```js
+receiver.readLatestImage((err, img) => {
+ if(err) {
+ console.log('readLatestImage failed.');
+ } else {
+ console.log('readLatestImage succeeded.');
+ }
+});
+```
+
+### readLatestImage9+
+
+readLatestImage(): Promise\
+
+从ImageReceiver读取最新的图片,并使用promise返回结果。
+
+**系统能力:** SystemCapability.Multimedia.Image.ImageReceiver
+
+**返回值:**
+
+| 类型 | 说明 |
+| ------------------------- | ------------------ |
+| Promise<[Image](#image8)> | 异步返回最新图片。 |
+
+**示例:**
+
+```js
+receiver.readLatestImage().then(img => {
+ console.log('readLatestImage succeeded.');
+}).catch(error => {
+ console.log('readLatestImage failed.');
+})
+```
+
+### readNextImage9+
+
+readNextImage(callback: AsyncCallback\): void
+
+从ImageReceiver读取下一张图片,并使用callback返回结果。
+
+**系统能力:** SystemCapability.Multimedia.Image.ImageReceiver
+
+**参数:**
+
+| 名称 | 类型 | 必填 | 说明 |
+| -------- | ------------------------------- | ---- | -------------------------- |
+| callback | AsyncCallback<[Image](#image9)> | 是 | 回调函数,返回下一张图片。 |
+
+**示例:**
+
+```js
+receiver.readNextImage((err, img) => {
+ if(err) {
+ console.log('readNextImage failed.');
+ } else {
+ console.log('readNextImage succeeded.');
+ }
+});
+```
+
+### readNextImage9+
+
+readNextImage(): Promise\
+
+从ImageReceiver读取下一张图片,并使用promise返回结果。
+
+**系统能力:** SystemCapability.Multimedia.Image.ImageReceiver
+
+**返回值:**
+
+| 类型 | 说明 |
+| ------------------------- | -------------------- |
+| Promise<[Image](#image9)> | 异步返回下一张图片。 |
+
+**示例:**
+
+```js
+receiver.readNextImage().then(img => {
+ console.log('readNextImage succeeded.');
+}).catch(error => {
+ console.log('readNextImage failed.');
+})
+```
+
+### on('imageArrival')9+
+
+on(type: 'imageArrival', callback: AsyncCallback\): void
+
+接收图片时注册回调。
+
+**系统能力:** SystemCapability.Multimedia.Image.ImageReceiver
+
+**参数:**
+
+| 名称 | 类型 | 必填 | 说明 |
+| -------- | -------------------- | ---- | ------------------------------------------------------ |
+| type | string | 是 | 注册事件的类型,固定为'imageArrival',接收图片时触发。 |
+| callback | AsyncCallback\ | 是 | 注册的事件回调。 |
+
+**示例:**
+
+```js
+receiver.on('imageArrival', () => {})
+```
+
+### release9+
+
+release(callback: AsyncCallback\): void
+
+释放ImageReceiver实例并使用回调返回结果。
+
+**系统能力:** SystemCapability.Multimedia.Image.ImageReceiver
+
+**参数:**
+
+| 名称 | 类型 | 必填 | 说明 |
+| -------- | -------------------- | ---- | ------------------------ |
+| callback | AsyncCallback\ | 是 | 回调函数,返回操作结果。 |
+
+**示例:**
+
+```js
+receiver.release(() => {})
+```
+
+### release9+
+
+release(): Promise\
+
+释放ImageReceiver实例并使用promise返回结果。
+
+**系统能力:** SystemCapability.Multimedia.Image.ImageReceiver
+
+**返回值:**
+
+| 类型 | 说明 |
+| -------------- | ------------------ |
+| Promise\ | 异步返回操作结果。 |
+
+**示例:**
+
+```js
+receiver.release().then(() => {
+ console.log('release succeeded.');
+}).catch(error => {
+ console.log('release failed.');
+})
+```
+
+## Image9+
+
+提供基本的图像操作,包括获取图像信息、读写图像数据。调用[readNextImage](#readnextimage9)和[readLatestImage](#readlatestimage9)接口时会返回image。
+
+### 属性
+
+**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image.Core
+
+| 名称 | 类型 | 可读 | 可写 | 说明 |
+| --------------------- | ------------------ | ---- | ---- | -------------------------------------------------- |
+| clipRect9+ | [Region](#region7) | 是 | 是 | 要裁剪的图像区域。 |
+| size9+ | [Size](#size) | 是 | 否 | 图像大小。 |
+| format9+ | number | 是 | 否 | 图像格式,参考[PixelMapFormat](#pixelmapformat7)。 |
+
+### getComponent9+
+
+getComponent(componentType: ComponentType, callback: AsyncCallback\): void
+
+根据图像的组件类型从图像中获取组件缓存并使用callback返回结果。
+
+**系统能力:** SystemCapability.Multimedia.Image.Core
+
+**参数:**
+
+| 名称 | 类型 | 必填 | 说明 |
+| ------------- | --------------------------------------- | ---- | -------------------- |
+| componentType | [ComponentType](#componenttype9) | 是 | 图像的组件类型。 |
+| callback | AsyncCallback<[Component](#component9)> | 是 | 用于返回组件缓冲区。 |
+
+**示例:**
+
+```js
+img.getComponent(4, (err, component) => {
+ if(err) {
+ console.log('getComponent failed.');
+ } else {
+ console.log('getComponent succeeded.');
+ }
+})
+```
+
+### getComponent9+
+
+getComponent(componentType: ComponentType): Promise\
+
+根据图像的组件类型从图像中获取组件缓存并使用Promise方式返回结果。
+
+**系统能力:** SystemCapability.Multimedia.Image.Core
+
+**参数:**
+
+| 名称 | 类型 | 必填 | 说明 |
+| ------------- | -------------------------------- | ---- | ---------------- |
+| componentType | [ComponentType](#componenttype9) | 是 | 图像的组件类型。 |
+
+**返回值:**
+
+| 类型 | 说明 |
+| --------------------------------- | --------------------------------- |
+| Promise<[Component](#component9)> | 用于返回组件缓冲区的promise实例。 |
+
+**示例:**
+
+```js
+img.getComponent(4).then(component => { })
+```
+
+### release9+
+
+release(callback: AsyncCallback\): void
+
+释放当前图像并使用callback返回结果。
+
+在接收另一个图像前必须先释放对应资源。
+
+**系统能力:** SystemCapability.Multimedia.Image.Core
+
+**参数:**
+
+| 名称 | 类型 | 必填 | 说明 |
+| -------- | -------------------- | ---- | -------------- |
+| callback | AsyncCallback\ | 是 | 返回操作结果。 |
+
+**示例:**
+
+```js
+img.release(() =>{
+ console.log('release succeeded.');
+}).catch(error => {
+ console.log('release failed.');
+})
+```
+
+### release9+
+
+release(): Promise\
+
+释放当前图像并使用Promise方式返回结果。
+
+在接收另一个图像前必须先释放对应资源。
+
+**系统能力:** SystemCapability.Multimedia.Image.Core
+
+**返回值:**
+
+| 类型 | 说明 |
+| -------------- | --------------------- |
+| Promise\ | promise返回操作结果。 |
+
+**示例:**
+
+```js
+img.release().then(() =>{
+ console.log('release succeeded.');
+}).catch(error => {
+ console.log('release failed.');
+})
```
## PositionArea7+
@@ -957,7 +1428,7 @@ release(): Promise\
| ------ | ------------------ | ---- | ---- | ------------------------------------------------------------ |
| pixels | ArrayBuffer | 是 | 否 | 像素。 |
| offset | number | 是 | 否 | 偏移量。 |
-| stride | number | 是 | 否 | 像素间距,stride >= region.size.width*4。 |
+| stride | number | 是 | 否 | 像素间距,stride >= region.size.width*4。 |
| region | [Region](#region7) | 是 | 否 | 区域,按照区域读写。写入的区域宽度加X坐标不能大于原图的宽度,写入的区域高度加Y坐标不能大于原图的高度 |
## ImageInfo
@@ -983,7 +1454,7 @@ release(): Promise\
## PixelMapFormat7+
-枚举,像素格式。
+枚举,图片像素格式。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image
@@ -995,7 +1466,7 @@ release(): Promise\
## AlphaType9+
-枚举,透明度。
+枚举,图像的透明度类型。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image
@@ -1008,7 +1479,7 @@ release(): Promise\
## ScaleMode9+
-枚举,缩略值。
+枚举,图像的缩放模式。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image
@@ -1019,19 +1490,21 @@ release(): Promise\
## InitializationOptions8+
+PixelMap的初始化选项。
+
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image
-| 名称 | 类型 | 可读 | 可写 | 说明 |
-| ----------- | ---------------------------------- | ---- | ---- | -------------- |
-| alphaType9+ | [AlphaType](#alphatype9) | 是 | 是 | 透明度。 |
-| editable | boolean | 是 | 是 | 是否可编辑。 |
-| pixelFormat | [PixelMapFormat](#pixelmapformat7) | 是 | 是 | 像素格式。 |
-| scaleMode9+ | [ScaleMode](#scalemode9) | 是 | 是 | 缩略值。 |
-| size | [Size](#size) | 是 | 是 | 创建图片大小。 |
+| 名称 | 类型 | 可读 | 可写 | 说明 |
+| ---------------------- | ---------------------------------- | ---- | ---- | -------------- |
+| alphaType9+ | [AlphaType](#alphatype9) | 是 | 是 | 透明度。 |
+| editable | boolean | 是 | 是 | 是否可编辑。 |
+| pixelFormat | [PixelMapFormat](#pixelmapformat7) | 是 | 是 | 像素格式。 |
+| scaleMode9+ | [ScaleMode](#scalemode9) | 是 | 是 | 缩略值。 |
+| size | [Size](#size) | 是 | 是 | 创建图片大小。 |
## DecodingOptions7+
-解码设置选项。
+图像解码设置选项。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image
@@ -1066,7 +1539,7 @@ release(): Promise\
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ------- | ------ | ---- | ---- | -------------- |
| format | string | 是 | 是 | 目标格式。 |
-| quality | number | 是 | 是 | 目标图片质量。 |
+| quality | number | 是 | 是 | JPEG编码中设定输出图片质量的参数,取值范围为1-100。 |
## GetImagePropertyOptions7+
@@ -1096,3 +1569,40 @@ release(): Promise\
| GPS_LATITUDE_REF | "GPSLatitudeRef" | 纬度引用,例如N或S。 |
| GPS_LONGITUDE_REF | "GPSLongitudeRef" | 经度引用,例如W或E。 |
+## ImageFormat9+
+
+枚举,图片格式。
+
+**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image.Core
+
+| 名称 | 默认值 | 描述 |
+| ------------ | ------ | -------------------- |
+| YCBCR_422_SP | 1000 | YCBCR422半平面格式。 |
+| JPEG | 2000 | JPEG编码格式。 |
+
+## ComponentType9+
+
+枚举,图像的组件类型。
+
+**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image.ImageReceiver
+
+| 名称 | 默认值 | 描述 |
+| ----- | ------ | ----------- |
+| YUV_Y | 1 | 亮度信息。 |
+| YUV_U | 2 | 色度信息。 |
+| YUV_V | 3 | 色度信息。 |
+| JPEG | 4 | Jpeg 类型。 |
+
+## Component9+
+
+描述图像颜色分量。
+
+**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Image.Core
+
+| 名称 | 类型 | 可读 | 可写 | 说明 |
+| ------------- | -------------------------------- | ---- | ---- | ------------ |
+| componentType | [ComponentType](#componenttype9) | 是 | 否 | 组件类型。 |
+| rowStride | number | 是 | 否 | 行距。 |
+| pixelStride | number | 是 | 否 | 像素间距。 |
+| byteBuffer | ArrayBuffer | 是 | 否 | 组件缓冲区。 |
+
diff --git a/zh-cn/application-dev/reference/apis/js-apis-securityLabel.md b/zh-cn/application-dev/reference/apis/js-apis-securityLabel.md
index 255ec5792603390e1eb64cd9e8569c0af89f8d51..34a85c6f3ca0098102c08121a098058e1fb15010 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-securityLabel.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-securityLabel.md
@@ -1,10 +1,10 @@
# 数据标签
+该模块提供文件数据安全等级的相关功能:向应用程序提供查询、设置文件数据安全等级的JS接口。
+
>  **说明:**
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
-该模块提供文件数据安全等级的相关功能:向应用程序提供查询、设置文件数据安全等级的JS接口。
-
## 导入模块
```js
diff --git a/zh-cn/application-dev/reference/apis/js-apis-statfs.md b/zh-cn/application-dev/reference/apis/js-apis-statfs.md
index d213902e4c4f46d228f1765e417ea2371306fb36..23e357dc9f3f970cf579ffbc1229023867eb2c6a 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-statfs.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-statfs.md
@@ -1,10 +1,10 @@
# statfs
+该模块提供文件系统相关存储信息的功能,向应用程序提供获取文件系统总字节数、空闲字节数的JS接口。
+
>  **说明:**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
-该模块提供文件系统相关存储信息的功能,向应用程序提供获取文件系统总字节数、空闲字节数的JS接口。
-
## 导入模块
```js
diff --git a/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md b/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md
index 511e73ec6f4c11b7bd1d2fa679dc6749fcd3a387..be091dacdebc8dd1b1d944c01af095c0b57f5625 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md
@@ -1,19 +1,19 @@
# 应用空间统计
+该模块提供空间查询相关的常用功能:包括对内外卡的空间查询,对应用分类数据统计的查询,对应用数据的查询等。
+
>  **说明:**
>
> - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - API 9当前为Canary版本,仅供试用,不保证接口可稳定调用。
-该模块提供空间查询相关的常用功能:包括对内外卡的空间查询,对应用分类数据统计的查询,对应用数据的查询等。
-
## 导入模块
```js
import storageStatistics from "@ohos.storageStatistics";
```
-## storagestatistics.getTotalSizeOfVolume
+## storageStatistics.getTotalSizeOfVolume
getTotalSizeOfVolume(volumeUuid: string): Promise<number>
@@ -23,32 +23,34 @@ getTotalSizeOfVolume(volumeUuid: string): Promise<number>
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
该接口为系统接口,三方应用不支持调用
-- 参数
+
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| volumeUuid | string | 是 | 卷id |
-- 返回值
+**返回值:**
| 类型 | 说明 |
| --------------------- | ---------------- |
| Promise<number> | 返回指定卷总空间 |
-- 示例
+**示例:**
```js
let uuid = "";
- storagestatistics.getTotalSizeOfVolume(uuid).then(function(number){
+ storageStatistics.getTotalSizeOfVolume(uuid).then(function(number){
console.info("getTotalSizeOfVolume successfully:"+ number);
}).catch(function(err){
console.info("getTotalSizeOfVolume failed with error:"+ err);
});
```
-## storagestatistics.getTotalSizeOfVolume
+## storageStatistics.getTotalSizeOfVolume
getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):void
@@ -58,28 +60,28 @@ getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):v
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
该接口为系统接口,三方应用不支持调用
-- 参数
+
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------------------ | ---- | -------------------------- |
| volumeUuid | string | 是 | 卷id |
| callback | callback:AsyncCallback<number> | 是 | 获取指定卷总空间之后的回调 |
-- 示例
+**示例:**
```js
let uuid = "";
- storagestatistics.getTotalSizeOfVolume(uuid, function(error, number){
+ storageStatistics.getTotalSizeOfVolume(uuid, function(error, number){
// do something
console.info("getTotalSizeOfVolume successfully:"+ number);
});
```
-
-
-## storagestatistics.getFreeSizeOfVolume
+## storageStatistics.getFreeSizeOfVolume
getFreeSizeOfVolume(volumeUuid: string): Promise<number>
@@ -89,25 +91,27 @@ getFreeSizeOfVolume(volumeUuid: string): Promise<number>
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
该接口为系统接口,三方应用不支持调用
-- 参数
+
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| volumeUuid | string | 是 | 卷id |
-- 返回值
+**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------ |
| Promise<number> | 返回指定卷可用空间 |
-- 示例
+**示例:**
```js
let uuid = "";
- storagestatistics.getFreeSizeOfVolume(uuid).then(function(number){
+ storageStatistics.getFreeSizeOfVolume(uuid).then(function(number){
console.info("getFreeSizeOfVolume successfully:"+ number);
}).catch(function(err){
console.info("getFreeSizeOfVolume failed with error:"+ err);
@@ -115,7 +119,7 @@ getFreeSizeOfVolume(volumeUuid: string): Promise<number>
```
-## storagestatistics.getFreeSizeOfVolume
+## storageStatistics.getFreeSizeOfVolume
getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):void
@@ -125,26 +129,28 @@ getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):vo
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
该接口为系统接口,三方应用不支持调用
-- 参数
+
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------------------ | ---- | ---------------------------- |
| volumeUuid | string | 是 | 卷id |
| callback | callback:AsyncCallback<number> | 是 | 获取指定卷可用空间之后的回调 |
-- 示例
+**示例:**
```js
let uuid = "";
- storagestatistics.getFreeSizeOfVolume(uuid, function(error, number){
+ storageStatistics.getFreeSizeOfVolume(uuid, function(error, number){
// do something
console.info("getFreeSizeOfVolume successfully:"+ number);
});
```
-## storagestatistics.getBundleStats9+
+## storageStatistics.getBundleStats9+
getBundleStats(packageName: string): Promise<BundleStats>
@@ -154,32 +160,34 @@ getBundleStats(packageName: string): Promise<BundleStats>
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
该接口为系统接口,三方应用不支持调用
-- 参数
+
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | -------- |
| packageName | string | 是 | 应用包名 |
-
-- 返回值
+
+**返回值:**
| 类型 | 说明 |
| ------------------------------------------ | -------------------------- |
| Promise<[Bundlestats](#bundlestats)> | 返回指定卷上的应用存储数据 |
-- 示例
+**示例:**
```js
let packageName = "";
- storagestatistics.getBundleStats(packageName).then(function(BundleStats){
+ storageStatistics.getBundleStats(packageName).then(function(BundleStats){
console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats));
}).catch(function(err){
console.info("getBundleStats failed with error:"+ err);
});
```
-## storagestatistics.getBundleStats9+
+## storageStatistics.getBundleStats9+
getBundleStats(packageName: string, callback: AsyncCallback<BundleStats>): void
@@ -189,28 +197,28 @@ getBundleStats(packageName: string, callback: AsyncCallback<BundleStats>)
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
该接口为系统接口,三方应用不支持调用
-- 参数
+
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| packageName | string | 是 | 应用包名 |
| callback | callback:AsyncCallback<[Bundlestats](#bundlestats)> | 是 | 获取指定卷上的应用存储数据之后的回调 |
-
-- 示例
+
+**示例:**
```js
let packageName = "";
- storagestatistics.getBundleStats(packageName, function(error, BundleStats){
+ storageStatistics.getBundleStats(packageName, function(error, BundleStats){
// do something
console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats));
});
```
-
-
-## storagestatistics.getCurrentBundleStats9+
+## storageStatistics.getCurrentBundleStats9+
getCurrentBundleStats(): Promise<BundleStats>
@@ -218,50 +226,51 @@ getCurrentBundleStats(): Promise<BundleStats>
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
-- 返回值
+**返回值:**
| 类型 | 说明 |
| ------------------------------------------ | -------------------------- |
| Promise<[Bundlestats](#bundlestats)> | 返回指定卷上的应用存储状态 |
-- 示例
+**示例:**
```js
- let bundleStats = storageStatistics.getCurrentBundleStats();
- console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats));
+ let bundleStats = storageStatistics.getCurrentBundleStats();
+ console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats));
```
-## storagestatistics.getCurrentBundleStats9+
+## storageStatistics.getCurrentBundleStats9+
getCurrentBundleStats(callback: AsyncCallback<BundleStats>): void
第三方应用异步获取占用空间,以callback方式返回。
-
+
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| callback | callback:AsyncCallback<[BundleStats](#bundlestats)> | 是 | 获取指定卷上的应用存储状态之后的回调 |
-- 示例
+**示例:**
```js
- storagestatistics.getCurrentBundleStats(function(error, bundleStats){
+ storageStatistics.getCurrentBundleStats(function(error, bundleStats){
// do something
console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats));
});
```
-
-
-
+
## BundleStats9+
-**系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.StorageService.SpatialStatistics。
+**系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.StorageService.SpatialStatistics
+
+
该接口为系统接口,三方应用不支持调用
-- 属性
+
+### 属性
| 名称 | 类型 | 说明 |
| --------- | ------ | -------------- |
@@ -270,9 +279,7 @@ getCurrentBundleStats(callback: AsyncCallback<BundleStats>): void
| dataSize | number | 应用总数据大小 |
-
-
-## storagestatistics.getTotalSize9+
+## storageStatistics.getTotalSize9+
getTotalSize(): Promise<number>
@@ -282,22 +289,24 @@ getTotalSize(): Promise<number>
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
该接口为系统接口,三方应用不支持调用
-- 返回值
+
+**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------ |
| Promise<number> | 返回内卡的总空间大小 |
-- 示例
+**示例:**
```js
- let number = storageStatistics.getTotalSize();
- console.info("getTotalSize successfully:"+ JSON.stringify(number));
+ let number = storageStatistics.getTotalSize();
+ console.info("getTotalSize successfully:"+ JSON.stringify(number));
```
-
-## storagestatistics.getTotalSize9+
+
+## storageStatistics.getTotalSize9+
getTotalSize(callback: AsyncCallback<number>): void
@@ -307,25 +316,27 @@ getTotalSize(callback: AsyncCallback<number>): void
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
该接口为系统接口,三方应用不支持调用
-- 参数
+
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------ | ---- | ------------------------ |
| callback | callback:AsyncCallback<number> | 是 | 获取内卡的总空间大小之后的回调 |
-- 示例
+**示例:**
```js
- storagestatistics.getTotalSize(function(error, number){
+ storageStatistics.getTotalSize(function(error, number){
// do something
console.info("getTotalSize successfully:"+ JSON.stringify(number));
});
```
-## storagestatistics.getFreeSize9+
+## storageStatistics.getFreeSize9+
getFreeSize(): Promise<number>
@@ -335,23 +346,25 @@ getFreeSize(): Promise<number>
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
该接口为系统接口,三方应用不支持调用
-- 返回值
+
+**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------ |
| Promise<number> | 返回内卡的可用空间大小 |
-- 示例
+**示例:**
```js
- let number = storageStatistics.getFreeSize();
- console.info("getFreeSize successfully:"+ JSON.stringify(number));
+ let number = storageStatistics.getFreeSize();
+ console.info("getFreeSize successfully:"+ JSON.stringify(number));
```
-## storagestatistics.getFreeSize9+
+## storageStatistics.getFreeSize9+
getFreeSize(callback: AsyncCallback<number>): void
@@ -361,26 +374,26 @@ getFreeSize(callback: AsyncCallback<number>): void
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
该接口为系统接口,三方应用不支持调用
-- 参数
+
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------ | ---- | ------------------------- |
| callback | callback:AsyncCallback<number> | 是 | 获取内卡的可用空间大小之后的回调 |
-- 示例
+**示例:**
```js
- storagestatistics.getFreeSize(function(error, number){
+ storageStatistics.getFreeSize(function(error, number){
// do something
console.info("getFreeSize successfully:"+ JSON.stringify(number));
});
```
-
-
-## storagestatistics.getSystemSize9+
+## storageStatistics.getSystemSize9+
getSystemSize(): Promise<number>
@@ -390,25 +403,27 @@ getSystemSize(): Promise<number>
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
该接口为系统接口,三方应用不支持调用
-- 返回值
+
+**返回值:**
| 类型 | 说明 |
| --------------------- | ---------------- |
| Promise<number> | 返回系统空间大小 |
-- 示例
+**示例:**
```js
- storagestatistics.getSystemSize().then(function(number){
+ storageStatistics.getSystemSize().then(function(number){
console.info("getSystemSize successfully:"+ number);
}).catch(function(err){
console.info("getSystemSize failed with error:"+ err);
});
```
-## storagestatistics.getSystemSize9+
+## storageStatistics.getSystemSize9+
getSystemSize(callback:AsyncCallback<number>):void
@@ -418,28 +433,28 @@ getSystemSize(callback:AsyncCallback<number>):void
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
该接口为系统接口,三方应用不支持调用
-- 参数
+
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------------------ | ---- | -------------------------- |
| callback | callback:AsyncCallback<number> | 是 | 获取系统空间大小之后的回调 |
-- 示例
+**示例:**
```js
- storagestatistics.getSystemSize(function(error, number){
+ storageStatistics.getSystemSize(function(error, number){
// do something
console.info("getSystemSize successfully:"+ number);
});
```
-
-
-
-## storagestatistics.getUserStorageStats9+
-getUserStorageStats(userId: number): Promise<StorageStats>
+## storageStatistics.getUserStorageStats9+
+
+getUserStorageStats(userId? : number): Promise<StorageStats>
异步获取用户各类别数据大小,以promise方式返回。
@@ -447,32 +462,34 @@ getUserStorageStats(userId: number): Promise<StorageStats>
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
该接口为系统接口,三方应用不支持调用
-- 参数
+
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| userId | string | 否 | 用户id
确认当前用户:
- 有值:表示指定用户。
- 无值:表示当前用户。|
-- 返回值
+**返回值:**
| 类型 | 说明 |
| --------------------- | ---------------- |
| Promise<[StorageStats](#StorageStats)> | 返回各类别数据大小 |
-- 示例
+**示例:**
```js
let userId = "";
- storagestatistics.getUserStorageStats(userId).then(function(StorageStats){
+ storageStatistics.getUserStorageStats(userId).then(function(StorageStats){
console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats));
}).catch(function(err){
console.info("getUserStorageStats failed with error:"+ err);
});
```
-## storagestatistics.getUserStorageStats9+
+## storageStatistics.getUserStorageStats9+
getUserStorageStats(userId: number, callback:AsyncCallback<StorageStats>):void
@@ -482,32 +499,37 @@ getUserStorageStats(userId: number, callback:AsyncCallback<StorageStats>):
**系统能力**:SystemCapability.FileManagement.StorageService.SpatialStatistics
+
该接口为系统接口,三方应用不支持调用
-- 参数
+
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------------------ | ---- | -------------------------- |
| userId | string | 否 | 用户id
确认当前用户:
- 有值:表示指定用户。
- 无值:表示当前用户。 |
| callback | callback:AsyncCallback<[StorageStats](#StorageStats)> | 是 | 返回各类别数据大小之后的回调 |
-- 示例
+**示例:**
```js
let userId = "";
- storagestatistics.getUserStorageStats(userId, function(error, StorageStats){
+ storageStatistics.getUserStorageStats(userId, function(error, StorageStats){
// do something
console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats));
});
```
-
## StorageStats9+
-**系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.StorageService.SpatialStatistics。
+**系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.StorageService.SpatialStatistics
+
+
该接口为系统接口,三方应用不支持调用
-- 属性
+
+
+### 属性
| 名称 | 类型 | 说明 |
| --------- | ------ | -------------- |
diff --git a/zh-cn/application-dev/reference/apis/js-apis-usb.md b/zh-cn/application-dev/reference/apis/js-apis-usb.md
index e677aa64ab3f97cc13880a25078f145b9b36764a..6f3b930ad6295efe57cb60f7543cec2a2c528990 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-usb.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-usb.md
@@ -1,6 +1,9 @@
# USB管理
+本模块主要提供管理USB设备的相关功能,包括查询USB设备列表、批量数据传输、控制命令传输、权限控制等。
+
> **说明:**
+>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
diff --git a/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md b/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md
index 7934963a80aba6e947c84c6084ef8581a954285a..7cc98e4b15693698873fed6ca834c4eb9248f51c 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md
@@ -1,13 +1,13 @@
# 卷管理
+该模块提供卷、磁盘查询和管理的相关功能:包括查询卷信息,对卷的挂载卸载、对磁盘分区以及卷的格式化等功能。
+
>  **说明:**
>
> - 本模块首批接口从API version 9开始支持。
> - API 9当前为Canary版本,仅供试用,不保证接口可稳定调用。
> - 本模块接口为系统接口,三方应用不支持调用。
-该模块提供卷、磁盘查询和管理的相关功能:包括查询卷信息,对卷的挂载卸载、对磁盘分区以及卷的格式化等功能。
-
## 导入模块
```js
@@ -24,13 +24,13 @@ getAllVolumes(): Promise<Array<Volume>>
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
-- 返回值
+**返回值:**
| 类型 | 说明 |
| ---------------------------------- | -------------------------- |
| Promise<[Volume](#volume)[]> | 返回当前所有可获得的卷信息 |
-- 示例
+**示例:**
```js
volumemanager.getAllVolumes().then(function(volumes){
@@ -48,13 +48,13 @@ getAllVolumes(callback: AsyncCallback<Array<Volume>>): void
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------- | ---- | ------------------------------------ |
| callback | callback:AsyncCallback<[Volume](#volume)[]> | 是 | 获取当前所有可获得的卷信息之后的回调 |
-
-- 示例
+
+**示例:**
```js
let uuid = "";
@@ -74,19 +74,19 @@ mount(volumeId: string): Promise<boolean>
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---- |
| volumeId | string | 是 | 卷id |
-- 返回值
+**返回值:**
| 类型 | 说明 |
| ---------------------- | ---------- |
| Promise<boolean> | 挂载指定卷 |
-- 示例
+**示例:**
```js
let volumeId = "";
@@ -105,14 +105,14 @@ mount(volumeId: string, callback:AsyncCallback<boolean>):void
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------- | ---- | -------------------- |
| volumeId | string | 是 | 卷id |
| callback | callback:AsyncCallback<boolean> | 是 | 挂载指定卷之后的回调 |
-- 示例
+**示例:**
```js
let volumeId = "";
@@ -131,19 +131,19 @@ unmount(volumeId: string): Promise<boolean>
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---- |
| volumeId | string | 是 | 卷id |
-- 返回值
+**返回值:**
| 类型 | 说明 |
| ---------------------- | ---------- |
| Promise<boolean> | 卸载指定卷 |
-- 示例
+**示例:**
```js
let volumeId = "";
@@ -162,14 +162,14 @@ unmount(volumeId: string, callback:AsyncCallback<boolean>):void
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------- | ---- | -------------------- |
| volumeId | string | 是 | 卷id |
| callback | callback:AsyncCallback<boolean> | 是 | 卸载指定卷之后的回调 |
-- 示例
+**示例:**
```js
let volumeId = "";
@@ -180,7 +180,7 @@ unmount(volumeId: string, callback:AsyncCallback<boolean>):void
## volumemanager.getVolumeByUuid
-getVolumeByUuid(uuid: string): Promise;
+getVolumeByUuid(uuid: string): Promise<Volume>
异步通过uuid获得卷信息,以promise方式返回。
@@ -188,19 +188,19 @@ getVolumeByUuid(uuid: string): Promise;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---- |
| uuid | string | 是 | 卷uuid |
-- 返回值
+**返回值:**
| 类型 | 说明 |
| ---------------------------------- | -------------------------- |
| Promise<[Volume](#volume)> | 返回当前所有可获得的卷信息 |
-- 示例
+**示例:**
```js
let uuid = "";
@@ -209,7 +209,7 @@ getVolumeByUuid(uuid: string): Promise;
## volumemanager.getVolumeByUuid
-getVolumeByUuid(uuid: string, callback: AsyncCallback): void;
+getVolumeByUuid(uuid: string, callback: AsyncCallback<Volume>): void
异步通过uuid获得卷信息,以callback方式返回。
@@ -217,14 +217,14 @@ getVolumeByUuid(uuid: string, callback: AsyncCallback): void;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------ | ---- | -------------------- |
| uuid | string | 是 | 卷uuid |
| callback | callback:AsyncCallback<[Volume](#volume)> | 是 | 获取卷信息之后的回调 |
-- 示例
+**示例:**
```js
let uuid = "";
@@ -235,7 +235,7 @@ getVolumeByUuid(uuid: string, callback: AsyncCallback): void;
## volumemanager.getVolumeById
-getVolumeById(id: string): Promise;
+getVolumeById(id: string): Promise<Volume>
异步通过卷id获得卷信息,以promise方式返回。
@@ -243,19 +243,19 @@ getVolumeById(id: string): Promise;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---- |
| id | string | 是 | 卷id |
-- 返回值
+**返回值:**
| 类型 | 说明 |
| ---------------------------------- | -------------------------- |
| Promise<[Volume](#volume)> | 返回当前所有可获得的卷信息 |
-- 示例
+**示例:**
```js
let id = "";
@@ -264,7 +264,7 @@ getVolumeById(id: string): Promise;
## volumemanager.getVolumeById
-getVolumeById(id: string, callback: AsyncCallback): void;
+getVolumeById(id: string, callback: AsyncCallback<Volume>): void
异步通过卷id获得卷信息,以callback方式返回。
@@ -272,14 +272,14 @@ getVolumeById(id: string, callback: AsyncCallback): void;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------ | ---- | -------------------- |
| id | string | 是 | 卷id |
| callback | callback:AsyncCallback<[Volume](#volume)> | 是 | 获取卷信息之后的回调 |
-- 示例
+**示例:**
```js
let id = "";
@@ -290,7 +290,7 @@ getVolumeById(id: string, callback: AsyncCallback): void;
## volumemanager.setVolumeDescription
-setVolumeDescription(uuid: string, description: string): Promise;
+setVolumeDescription(uuid: string, description: string): Promise<void>
异步通过uuid设置卷描述,以promise方式返回。
@@ -298,20 +298,20 @@ setVolumeDescription(uuid: string, description: string): Promise;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | ---- |
| uuid | string | 是 | 卷uuid |
| description | string | 是 | 卷描述 |
-- 返回值
+**返回值:**
| 类型 | 说明 |
| ---------------------- | -------------------------- |
| Promise<void> | 设置卷信息 |
-- 示例
+**示例:**
```js
let uuid = "";
@@ -321,7 +321,7 @@ setVolumeDescription(uuid: string, description: string): Promise;
## volumemanager.setVolumeDescription
-function setVolumeDescription(uuid: string, description: string, callback: AsyncCallback): void;
+setVolumeDescription(uuid: string, description: string, callback: AsyncCallback<void>): void
异步通过uuid设置卷描述,以callback方式返回。
@@ -329,7 +329,7 @@ function setVolumeDescription(uuid: string, description: string, callback: Async
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | --------------------------------------- | ---- | ---------------- |
@@ -337,7 +337,7 @@ function setVolumeDescription(uuid: string, description: string, callback: Async
| description | string | 是 | 卷描述 |
| callback | callback:AsyncCallback<void> | 是 | 设置卷描述之后的回调 |
-- 示例
+**示例:**
```js
let uuid = "";
@@ -349,7 +349,7 @@ function setVolumeDescription(uuid: string, description: string, callback: Async
## volumemanager.format
-format(volId: string): Promise;
+format(volId: string): Promise<void>
异步对指定卷进行格式化,以promise方式返回。
@@ -357,19 +357,19 @@ format(volId: string): Promise;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | ---- |
| volId | string | 是 | 卷id |
-- 返回值
+**返回值:**
| 类型 | 说明 |
| --------------------- | ----------------------- |
| Promise<void> | 对指定卷进行格式化 |
-- 示例
+**示例:**
```js
let volId = "";
@@ -378,7 +378,7 @@ format(volId: string): Promise;
## volumemanager.format
-format(volId: string, callback: AsyncCallback): void;
+format(volId: string, callback: AsyncCallback<void>): void
异步对指定卷进行格式化,以callback方式返回。
@@ -386,14 +386,14 @@ format(volId: string, callback: AsyncCallback): void;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------- | ---- | ---------------- |
| volId | string | 是 | 卷id |
| callback | callback:AsyncCallback<void> | 是 | 对指定卷进行格式化 |
-- 示例
+**示例:**
```js
let volId = "";
@@ -404,7 +404,7 @@ format(volId: string, callback: AsyncCallback): void;
## volumemanager.partition
-partition(volId: string, fstype: string): Promise;
+partition(volId: string, fstype: string): Promise<void>
异步对磁盘进行分区,以promise方式返回。
@@ -412,20 +412,20 @@ partition(volId: string, fstype: string): Promise;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | ---- |
| volId | string | 是 | 卷所属的磁盘id |
| fstype | string | 是 | 分区类型 |
-- 返回值
+**返回值:**
| 类型 | 说明 |
| --------------------- | ----------------------- |
| Promise<void> | 对磁盘进行分区 |
-- 示例
+**示例:**
```js
let volId = "";
@@ -435,7 +435,7 @@ partition(volId: string, fstype: string): Promise;
## volumemanager.partition
-partition(volId: string, fstype : string, callback: AsyncCallback): void;
+partition(volId: string, fstype : string, callback: AsyncCallback<void>): void
异步对磁盘进行分区,以callback方式返回。
@@ -443,9 +443,7 @@ partition(volId: string, fstype : string, callback: AsyncCallback): void;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
-
-
-- 参数
+**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------- | ---- | ---------------- |
@@ -453,7 +451,7 @@ partition(volId: string, fstype : string, callback: AsyncCallback): void;
| fstype | string | 是 | 分区类型 |
| callback | callback:AsyncCallback<void> | 是 | 对磁盘进行分区 |
-- 示例
+**示例:**
```js
let volId = "";
diff --git a/zh-cn/application-dev/reference/apis/js-apis-webgl.md b/zh-cn/application-dev/reference/apis/js-apis-webgl.md
index 7c78bce3a03b144ab19fddc775674f390b7378f6..f2c0b6cf7b21655ccf681ddd8fe45136c4cb1a54 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-webgl.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-webgl.md
@@ -1,11 +1,14 @@
-# webgl
+# WebGL
+
+WebGL提供图形绘制的能力,包括对当前绘制图形的位置、颜色等进行处理。
+
+WebGL标准图形API,对应OpenGL ES 2.0特性集。更多信息请参考[WebGL™标准](https://www.khronos.org/registry/webgl/specs/latest/1.0/)。
> **说明:**
+>
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
-WebGL标准图形API,对应OpenGL ES 2.0特性集。更多信息请参考[WebGL™标准](https://www.khronos.org/registry/webgl/specs/latest/1.0/)。
-
## 调用方式
diff --git a/zh-cn/application-dev/reference/apis/js-apis-webgl2.md b/zh-cn/application-dev/reference/apis/js-apis-webgl2.md
index 413090964f3841d1efa8c14df0684f5a5293f207..c57f9b87dd7b0c66f7ee6bf7ac027bf71a29a4cc 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-webgl2.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-webgl2.md
@@ -1,10 +1,15 @@
-# webgl2
+# WebGL2
+
+WebGL2支持图形的绘制,包括对当前绘制图形的位置、颜色等进行处理,其中相对WebGL来说对渲染管道和着色语言进行了增强。
+
+WebGL标准图形API,对应OpenGL ES 3.0特性集。更多信息请参考[WebGL™标准](https://www.khronos.org/registry/webgl/specs/latest/2.0/)。
> **说明:**
+>
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
-WebGL标准图形API,对应OpenGL ES 3.0特性集。更多信息请参考[WebGL™标准](https://www.khronos.org/registry/webgl/specs/latest/2.0/)。
+
## 调用方式
diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md
index fba2bfc81b1820717c146d471258bd9d1d69cac1..b3de8b9e12bdbb80ed46297a081aa368798cc470 100644
--- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md
+++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md
@@ -33,10 +33,10 @@ Image(src: string | PixelMap | Resource)
| -------- | -------- | -------- | -------- |
| alt | string | - | 加载时显示的占位图。支持本地图片和网络路径。 |
| objectFit | ImageFit | Cover | 设置图片的缩放类型。 |
-| objectRepeat | [ImageRepeat](ts-appendix-enums.md#imagerepeat枚举说明) | NoRepeat | 设置图片的重复样式。
>  **说明:**
> - SVG类型图源不支持该属性。 |
-| interpolation | ImageInterpolation | None | 设置图片的插值效果,仅针对图片放大插值。
>  **说明:**
> - SVG类型图源不支持该属性。
>
> - PixelMap资源不支持该属性。 |
-| renderMode | ImageRenderMode | Original | 设置图片渲染的模式。
>  **说明:**
> - SVG类型图源不支持该属性。 |
-| sourceSize | {
width: number,
height: number
} | - | 设置图片解码尺寸,将原始图片解码成指定尺寸的图片,number类型单位为px。
>  **说明:**
> PixelMap资源不支持该属性。 |
+| objectRepeat | [ImageRepeat](ts-appendix-enums.md#imagerepeat枚举说明) | NoRepeat | 设置图片的重复样式。
>  **说明:**
> - svg类型图源不支持该属性。 |
+| interpolation | ImageInterpolation | None | 设置图片的插值效果,仅针对图片放大插值。
>  **说明:**
> - svg类型图源不支持该属性。
> - PixelMap资源不支持该属性。 |
+| renderMode | ImageRenderMode | Original | 设置图片渲染的模式。
>  **说明:**
> - svg类型图源不支持该属性。 |
+| sourceSize | {
width: number,
height: number
} | - | 设置图片解码尺寸,将原始图片解码成指定尺寸的图片,number类型单位为px。
>  **说明:**
> - PixelMap资源不支持该属性。 |
| syncLoad8+ | boolean | false | 设置是否同步加载图片,默认是异步加载。同步加载时阻塞UI线程,不会显示占位图。 |
- ImageFit枚举说明
diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-refresh.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-refresh.md
index c9d8d7ee66c96cd73f4dffd5259eef10840c89e1..2288474152b157e53fec446aeaaf15ff741c7de2 100644
--- a/zh-cn/application-dev/reference/arkui-ts/ts-container-refresh.md
+++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-refresh.md
@@ -15,7 +15,7 @@
## 接口
-Refresh\(value: \{refreshing: boolean, offset?: Length, friction?: number\}\)
+Refresh\(value: \{refreshing: boolean, offset?: Length, friction?: number | string\}\)
- 参数
@@ -23,7 +23,7 @@ Refresh\(value: \{refreshing: boolean, offset?: Length, friction?: number\}\)
| -------- | -------- | -------- | -------- | -------- |
| refreshing | boolean | 是 | - | 当前组件是否正在刷新。 |
| offset | Length | 否 | 16 | 刷新组件静止时距离父组件顶部的距离。|
- | friction | number | 否 | 62 | 下拉摩擦系数,取值范围为0到100。
- 0表示下拉刷新容器不跟随手势下拉而下拉。
- 100表示下拉刷新容器紧紧跟随手势下拉而下拉。
- 数值越大,下拉刷新容器跟随手势下拉的反应越灵敏。 |
+ | friction | number \| string | 否 | 62 | 下拉摩擦系数,取值范围为0到100。
- 0表示下拉刷新容器不跟随手势下拉而下拉。
- 100表示下拉刷新容器紧紧跟随手势下拉而下拉。
- 数值越大,下拉刷新容器跟随手势下拉的反应越灵敏。 |
diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md b/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md
index 54950652de7e734e81f1d22f406ee059d63b35e0..bd97f739ccbae22648af5b99e7f7d363fed9a7c6 100644
--- a/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md
+++ b/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md
@@ -165,7 +165,6 @@ struct VideoCreateComponent {
@State autoPlays: boolean = false;
@State controlsss: boolean = true;
controller: VideoController = new VideoController();
- @State startStaus: boolean = true;
build() {
Column() {
Video({
diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md b/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md
index 3f7e939867de5b2f38f9b3d21b0405d780262915..57ebdcd0567bb63066f95db82d19910bae33c75c 100644
--- a/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md
+++ b/zh-cn/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md
@@ -29,8 +29,6 @@
@Entry
@Component
struct SharedTransitionExample {
- @State scale: number = 1
- @State opacity: number = 1
@State active: boolean = false
build() {
diff --git a/zh-cn/device-dev/driver/driver-platform-watchdog-des.md b/zh-cn/device-dev/driver/driver-platform-watchdog-des.md
index d23190f4463a1c4e63e68fd070f8795996ac14b0..c2067ec61e0b9408faa7a13b390f510bb3902fa5 100644
--- a/zh-cn/device-dev/driver/driver-platform-watchdog-des.md
+++ b/zh-cn/device-dev/driver/driver-platform-watchdog-des.md
@@ -1,126 +1,57 @@
-# Watchdog
-
-
-
-## 概述
-
-看门狗(Watchdog),又叫看门狗计时器(Watchdog Timer),是一种硬件的计时设备,当系统的主程序发生某些错误时,导致未及时清除看门狗计时器的计时值,这时看门狗计时器就会对系统发出复位信号,使系统从悬停状态恢复到正常运作状态。
-
-## 接口说明
-
-**表 1** 看门狗 API接口功能介绍
-
-
-功能分类
- |
-接口名
- |
-描述
- |
-
-
-打开/关闭看门狗
- |
-WatchdogOpen
- |
-打开看门狗设备
- |
-
-WatchdogClose
- |
-关闭看门狗设备
- |
-
-启动/停止看门狗
- |
-WatchdogStart
- |
-启动看门狗
- |
-
-WatchdogStop
- |
-停止看门狗
- |
-
-设置/获取超时时间
- |
-WatchdogSetTimeout
- |
-设置看门狗超时时间
- |
-
-WatchdogGetTimeout
- |
-获取看门狗超时时间
- |
-
-获取看门狗状态
- |
-WatchdogGetStatus
- |
-获取看门狗状态
- |
-
-清除看门狗定时器
- |
-WatchdogFeed
- |
-清除看门狗定时器(喂狗)
- |
-
-
-
-
-> **说明:**
->本文涉及看门狗的所有接口,仅限内核态使用,不支持在用户态使用。
-
-## 使用指导
-
-### 使用流程
-
-使用看门狗的一般流程如[图1](#fig430533913392)所示。
-
-**图 1** 看门狗使用流程图
-
-
-### 打开看门狗设备
+# Watchdog
+
+
+## 概述
+
+看门狗(Watchdog),又叫看门狗计时器(Watchdog timer),是一种硬件的计时设备。当系统主程序发生错误导致未及时清除看门狗计时器的计时值时,看门狗计时器就会对系统发出复位信号,使系统从悬停状态恢复到正常运作状态。
+
+
+## 接口说明
+
+**表1** 看门狗API接口功能介绍
+
+| 接口 | 接口描述 |
+| -------- | -------- |
+| WatchdogOpen | 打开看门狗 |
+| WatchdogClose | 关闭看门狗 |
+| WatchdogStart | 启动看门狗 |
+| WatchdogStop | 停止看门狗 |
+| WatchdogSetTimeout | 设置看门狗超时时间 |
+| WatchdogGetTimeout | 获取看门狗超时时间 |
+| WatchdogGetStatus | 获取看门狗状态 |
+| WatchdogFeed | 清除看门狗定时器(喂狗) |
+
+>  **说明:**
+> 本文涉及的看门狗的所有接口,仅限内核态使用,不支持在用户态使用。
+
+
+## 使用指导
+
+
+### 使用流程
+
+使用看门狗的一般流程如下图所示。
+
+**图1** 看门狗使用流程图
+
+
+
+
+### 打开看门狗设备
在操作看门狗之前,需要使用WatchdogOpen打开一个看门狗设备,一个系统可能有多个看门狗,通过ID号来打开指定的看门狗设备:
-DevHandle WatchdogOpen\(int16\_t wdtId\);
-
-**表 2** WatchdogOpen参数和返回值描述
-
-
-参数
- |
-参数描述
- |
-
-
-wdtId
- |
-看门狗设备号
- |
-
-返回值
- |
-返回值描述
- |
-
-NULL
- |
-打开失败
- |
-
-DevHandle类型指针
- |
-看门狗设备句柄
- |
-
-
-
+DevHandle WatchdogOpen(int16_t wdtId);
+
+**表2** WatchdogOpen参数和返回值描述
+
+| **参数** | **参数描述** |
+| -------- | -------- |
+| wdtId | 看门狗设备号 |
+| **返回值** | **返回值描述** |
+| NULL | 打开失败 |
+| DevHandle类型指针 | 看门狗设备句柄 |
+
```
DevHandle handle = NULL;
@@ -131,46 +62,21 @@ if (handle == NULL) {
}
```
-### 获取看门狗状态
-
-int32\_t WatchdogGetStatus\(DevHandle handle, int32\_t \*status\);
-
-**表 3** WatchdogGetStatus参数和返回值描述
-
-
-参数
- |
-参数描述
- |
-
-
-handle
- |
-看门狗设备句柄
- |
-
-status
- |
-获取到的启动状态指针
- |
-
-返回值
- |
-返回值描述
- |
-
-0
- |
-获取成功
- |
-
-负数
- |
-获取失败
- |
-
-
-
+
+### 获取看门狗状态
+
+int32_t WatchdogGetStatus(DevHandle handle, int32_t *status);
+
+**表3** WatchdogGetStatus参数和返回值描述
+
+| **参数** | **参数描述** |
+| -------- | -------- |
+| handle | 看门狗设备句柄 |
+| status | 获取到的看门狗状态的指针 |
+| **返回值** | **返回值描述** |
+| 0 | 获取成功 |
+| 负数 | 获取失败 |
+
```
int32_t ret;
@@ -183,46 +89,21 @@ if (ret != 0) {
}
```
-### 设置超时时间
-
-int32\_t WatchdogSetTimeout\(DevHandle \*handle, uint32\_t seconds\);
-
-**表 4** WatchdogSetTimeout参数和返回值描述
-
-
-参数
- |
-参数描述
- |
-
-
-handle
- |
-看门狗设备句柄
- |
-
-seconds
- |
-超时时间,单位为秒
- |
-
-返回值
- |
-返回值描述
- |
-
-0
- |
-设置成功
- |
-
-负数
- |
-设置失败
- |
-
-
-
+
+### 设置超时时间
+
+int32_t WatchdogSetTimeout(DevHandle *handle, uint32_t seconds);
+
+**表4** WatchdogSetTimeout参数和返回值描述
+
+| **参数** | **参数描述** |
+| -------- | -------- |
+| handle | 看门狗设备句柄 |
+| seconds | 超时时间,单位为秒 |
+| **返回值** | **返回值描述** |
+| 0 | 设置成功 |
+| 负数 | 设置失败 |
+
```
int32_t ret;
@@ -235,46 +116,21 @@ if (ret != 0) {
}
```
-### 获取超时时间
-
-int32\_t WatchdogGetTimeout\(DevHandle \*handle, uint32\_t \*seconds\);
-
-**表 5** WatchdogGetTimeout参数和返回值描述
-
-
-参数
- |
-参数描述
- |
-
-
-handle
- |
-看门狗设备句柄
- |
-
-seconds
- |
-接收超时时间的指针,单位为秒
- |
-
-返回值
- |
-返回值描述
- |
-
-0
- |
-获取成功
- |
-
-负数
- |
-获取失败
- |
-
-
-
+
+### 获取超时时间
+
+int32_t WatchdogGetTimeout(DevHandle *handle, uint32_t *seconds);
+
+**表5** WatchdogGetTimeout参数和返回值描述
+
+| **参数** | **参数描述** |
+| -------- | -------- |
+| handle | 看门狗设备句柄 |
+| seconds | 接收超时时间的指针,单位为秒 |
+| **返回值** | **返回值描述** |
+| 0 | 获取成功 |
+| 负数 | 获取失败 |
+
```
int32_t ret;
@@ -287,41 +143,20 @@ if (ret != 0) {
}
```
-### 启动看门狗
-
-int32\_t WatchdogStart\(DevHandle handle\);
-
-**表 6** WatchdogStart参数和返回值描述
-
-
-参数
- |
-参数描述
- |
-
-
-handle
- |
-看门狗设备句柄
- |
-
-返回值
- |
-返回值描述
- |
-
-0
- |
-启动成功
- |
-
-负数
- |
-启动失败
- |
-
-
-
+
+### 启动看门狗
+
+int32_t WatchdogStart(DevHandle handle);
+
+**表6** WatchdogStart参数和返回值描述
+
+| **参数** | **参数描述** |
+| -------- | -------- |
+| handle | 看门狗设备句柄 |
+| **返回值** | **返回值描述** |
+| 0 | 启动成功 |
+| 负数 | 启动失败 |
+
```
int32_t ret;
@@ -333,41 +168,20 @@ if (ret != 0) {
}
```
-### 喂狗
-
-int32\_t WatchdogFeed\(DevHandle handle\);
-
-**表 7** WatchdogFeed参数和返回值描述
-
-
-参数
- |
-参数描述
- |
-
-
-handle
- |
-看门狗设备句柄
- |
-
-返回值
- |
-返回值描述
- |
-
-0
- |
-喂狗成功
- |
-
-负数
- |
-喂狗失败
- |
-
-
-
+
+### 喂狗
+
+int32_t WatchdogFeed(DevHandle handle);
+
+**表7** WatchdogFeed参数和返回值描述
+
+| **参数** | **参数描述** |
+| -------- | -------- |
+| handle | 看门狗设备句柄 |
+| **返回值** | **返回值描述** |
+| 0 | 喂狗成功 |
+| 负数 | 喂狗失败 |
+
```
int32_t ret;
@@ -379,41 +193,20 @@ if (ret != 0) {
}
```
-### 停止看门狗
-
-int32\_t WatchdogStop\(DevHandle handle\);
-
-**表 8** WatchdogStop参数和返回值描述
-
-
-参数
- |
-参数描述
- |
-
-
-handle
- |
-看门狗设备句柄
- |
-
-返回值
- |
-返回值描述
- |
-
-0
- |
-停止成功
- |
-
-负数
- |
-停止失败
- |
-
-
-
+
+### 停止看门狗
+
+int32_t WatchdogStop(DevHandle handle);
+
+**表8** WatchdogStop参数和返回值描述
+
+| **参数** | **参数描述** |
+| -------- | -------- |
+| handle | 看门狗设备句柄 |
+| **返回值** | **返回值描述** |
+| 0 | 停止成功 |
+| 负数 | 停止失败 |
+
```
int32_t ret;
@@ -425,45 +218,38 @@ if (ret != 0) {
}
```
-### 关闭看门狗设备
+
+### 关闭看门狗设备
当操作完毕时,使用WatchdogClose关闭打开的设备句柄:
-void WatchdogClose\(DevHandle handle\);
-
-**表 9** WatchdogClose参数和返回值描述
-
-
-参数
- |
-参数描述
- |
-
-
-handle
- |
-看门狗设备句柄
- |
-
-
-
+void WatchdogClose(DevHandle handle);
+
+**表9** WatchdogClose参数和返回值描述
+
+| **参数** | **参数描述** |
+| -------- | -------- |
+| handle | 看门狗设备句柄 |
+
```
/* 关闭看门狗 */
ret = WatchdogClose(handle);
```
-## 使用实例
+
+## 使用实例
本例程提供看门狗的完整使用流程。
在本例程中,我们打开一个看门狗设备,设置超时时间并启动计时:
-- 首先定期喂狗,即按时清除看门狗定时器,确保系统不会因定时器超时而复位。
-- 接着再停止喂狗,观察定时器到期后系统是否发生复位行为。
+- 首先定期喂狗,即按时清除看门狗定时器,确保系统不会因定时器超时而复位。
-示例如下:
+- 接着再停止喂狗,观察定时器到期后系统是否发生复位行为。
+ 示例如下:
+
```
#include "watchdog_if.h"
#include "hdf_log.h"
@@ -483,7 +269,7 @@ static int32_t TestCaseWatchdog(void)
/* 打开0号看门狗设备 */
handle = WatchdogOpen(0);
if (handle == NULL) {
- HDF_LOGE("Open watchdog fail!");
+ HDF_LOGE("Open watchdog failed!");
return -1;
}
@@ -507,14 +293,14 @@ static int32_t TestCaseWatchdog(void)
/* 启动看门狗,开始计时 */
ret = WatchdogStart(handle);
if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: satrt fail! ret:%d\n", __func__, ret);
+ HDF_LOGE("%s: start fail! ret:%d\n", __func__, ret);
WatchdogClose(handle);
return ret;
}
/* 每隔1S喂狗一次 */
for (i = 0; i < WATCHDOG_TEST_FEED_TIME; i++) {
- HDF_LOGE("%s: feeding watchdog %d times... \n", __func__, i);
+ HDF_LOGI("%s: feeding watchdog %d times... \n", __func__, i);
ret = WatchdogFeed(handle);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s: feed dog fail! ret:%d\n", __func__, ret);
@@ -524,18 +310,17 @@ static int32_t TestCaseWatchdog(void)
OsalSleep(1);
}
/* 由于喂狗间隔小于超时时间,系统不会发生复位,此日志可以正常打印 */
- HDF_LOGE("%s: no reset ... feeding test OK!!!\n", __func__);
+ HDF_LOGI("%s: no reset ... feeding test OK!!!\n", __func__);
/* 接下来持续不喂狗,使得看门狗计时器超时 */
for (i = 0; i < WATCHDOG_TEST_FEED_TIME; i++) {
- HDF_LOGE("%s: watiting dog back %d times... \n", __func__, i);
+ HDF_LOGI("%s: waiting dog buck %d times... \n", __func__, i);
OsalSleep(1);
}
/* 当不喂狗时间到达之前设定的超时时间的时候,系统会发生复位,理论上观察不到此日志的打印 */
- HDF_LOGE("%s: dog hasn't back!!! \n", __func__, i);
+ HDF_LOGI("%s: dog hasn't back!!! \n", __func__, i);
WatchdogClose(handle);
return -1;
}
-```
-
+```
\ No newline at end of file
diff --git a/zh-cn/device-dev/driver/driver-platform-watchdog-develop.md b/zh-cn/device-dev/driver/driver-platform-watchdog-develop.md
index 986db11f17ffdf04bc7b9bfaf6404f9b19482529..1b47d28a96141c55f2c782b95f20834734a08dc4 100755
--- a/zh-cn/device-dev/driver/driver-platform-watchdog-develop.md
+++ b/zh-cn/device-dev/driver/driver-platform-watchdog-develop.md
@@ -1,17 +1,20 @@
-# WatchDog
+# Watchdog
-## 概述
+## 概述
-看门狗(Watchdog),又叫看门狗计时器(Watchdog timer),是一种硬件的计时设备,在HDF框架中,Watchdog接口适配模式采用独立服务模式,在这种模式下,每一个设备对象会独立发布一个设备服务来处理外部访问,设备管理器收到API的访问请求之后,通过提取该请求的参数,达到调用实际设备对象的相应内部方法的目的。独立服务模式可以直接借助HDFDeviceManager的服务管理能力,但需要为每个设备单独配置设备节点,增加内存占用。
+看门狗(Watchdog),又叫看门狗计时器(Watchdog timer),是一种硬件的计时设备。在HDF框架中,Watchdog接口适配模式采用独立服务模式,在这种模式下,每一个设备对象会独立发布一个设备服务来处理外部访问,设备管理器收到API的访问请求之后,通过提取该请求的参数,达到调用实际设备对象的相应内部方法的目的。独立服务模式可以直接借助HDFDeviceManager的服务管理能力,但需要为每个设备单独配置设备节点,增加内存占用。
-**图 1** Watchdog独立服务模式结构图
-
+ **图1** Watchdog独立服务模式结构图
-## 接口说明
+ 
+
+
+## 接口说明
WatchdogMethod定义:
+
```
struct WatchdogMethod {
int32_t (*getStatus)(struct WatchdogCntlr *wdt, int32_t *status);
@@ -20,342 +23,238 @@ struct WatchdogMethod {
int32_t (*start)(struct WatchdogCntlr *wdt);
int32_t (*stop)(struct WatchdogCntlr *wdt);
int32_t (*feed)(struct WatchdogCntlr *wdt);
- int32_t (*getPriv)(struct WatchdogCntlr *wdt); //【可选】如果WatchdogCntlr 中的priv成员存在,则按需实例化
- void (*releasePriv)(struct WatchdogCntlr *wdt);//【可选】
+ int32_t (*getPriv)(struct WatchdogCntlr *wdt); // 【可选】如果WatchdogCntlr中的priv成员存在,则按需实例化
+ void (*releasePriv)(struct WatchdogCntlr *wdt);// 【可选】
};
```
-**表 1** WatchdogMethod成员的回调函数功能说明
-
-
-成员函数
- |
-入参
- |
-出参
- |
-返回值
- |
-功能
- |
-
-
-getStatus
- |
-wdt: 结构体指针,核心层WDG控制器;
- |
-status: int32_t指针,表示狗的状态(打开或关闭);
- |
-HDF_STATUS相关状态
- |
-获取看门狗所处的状态
- |
-
-start
- |
-wdt: 结构体指针,核心层WDG控制器;
- |
-无
- |
-HDF_STATUS相关状态
- |
-打开开门狗
- |
-
-stop
- |
-wdt: 结构体指针,核心层WDG控制器;
- |
-无
- |
-HDF_STATUS相关状态
- |
-关闭开门狗
- |
-
-setTimeout
- |
-wdt: 结构体指针,核心层WDG控制器;seconds: uint32_t,时间传入值;
- |
-无
- |
-HDF_STATUS相关状态
- |
-设置超时时间值,单位秒,需要保证看门狗实际运行的时间符合该值
- |
-
-getTimeout
- |
-wdt: 结构体指针,核心层WDG控制器;
- |
-seconds: uint32_t,传出的时间值
- |
-HDF_STATUS相关状态
- |
-回读设置的超时时间值
- |
-
-feed
- |
-wdt: 结构体指针,核心层WDG控制器;
- |
-无
- |
-HDF_STATUS相关状态
- |
-喂狗
- |
-
-
-
-
-## 开发步骤
+ **表1** WatchdogMethod成员的回调函数功能说明
+
+| 成员函数 | 入参 | 出参 | 返回值 | 功能 |
+| -------- | -------- | -------- | -------- | -------- |
+| getStatus | wdt:结构体指针,核心层WDG控制器 | status: int32_t指针,表示狗的状态(打开或关闭) | HDF_STATUS相关状态 | 获取看门狗所处的状态 |
+| start | wdt:结构体指针,核心层WDG控制器 | 无 | HDF_STATUS相关状态 | 打开开门狗 |
+| stop | wdt:结构体指针,核心层WDG控制器 | 无 | HDF_STATUS相关状态 | 关闭开门狗 |
+| setTimeout | wdt:结构体指针,核心层WDG控制器 | seconds: uint32_t,时间传入值; | 无 | HDF_STATUS相关状态 | 设置超时时间值,单位秒,需要保证看门狗实际运行的时间符合该值 |
+| getTimeout | wdt:结构体指针,核心层WDG控制器 | seconds: uint32_t,传出的时间值 | HDF_STATUS相关状态 | 回读设置的超时时间值 |
+| feed | wdt:结构体指针,核心层WDG控制器 | 无 | HDF_STATUS相关状态 | 喂狗 |
+
+
+## 开发步骤
Watchdog模块适配HDF框架的三个环节是配置属性文件,实例化驱动入口,以及实例化核心层接口函数。
-1. **实例化驱动入口:**
- - 实例化HdfDriverEntry结构体成员。
- - 调用HDF\_INIT将HdfDriverEntry实例化对象注册到HDF框架中。
-
-2. **配置属性文件:**
- - 在device\_info.hcs文件中添加deviceNode描述。
- - 【可选】添加watchdog\_config.hcs器件属性文件。
-
-3. **实例化Watchdog控制器对象:**
- - 初始化WatchdogCntlr成员。
- - 实例化WatchdogCntlr成员WatchdogMethod。
-
- > **说明:**
- >实例化WatchdogCntlr成员WatchdogMethod,其定义和成员说明见[接口说明](#section752964871810)。
-
-
-4. **驱动调试:**
-
- 【可选】针对新增驱动程序,建议验证驱动基本功能,例如挂载后的信息反馈,超时时间设置的成功与否等。
-
-
-## 开发实例
-
-下方将以watchdog\_hi35xx.c为示例,展示需要厂商提供哪些内容来完整实现设备功能。
-
-1. 驱动开发首先需要实例化驱动入口,驱动入口必须为HdfDriverEntry(在 hdf\_device\_desc.h 中定义)类型的全局变量,且moduleName要和device\_info.hcs中保持一致。HDF框架会将所有加载的驱动的HdfDriverEntry对象首地址汇总,形成一个类似数组的段地址空间,方便上层调用。
-
- 一般在加载驱动时HDF会先调用Bind函数,再调用Init函数加载该驱动。当Init调用异常时,HDF框架会调用Release释放驱动资源并退出。
-
- Watchdog驱动入口参考:
-
- ```
- struct HdfDriverEntry g_watchdogDriverEntry = {
- .moduleVersion = 1,
- .Bind = Hi35xxWatchdogBind, //见Bind参考
- .Init = Hi35xxWatchdogInit, //见Init参考
- .Release = Hi35xxWatchdogRelease, //见Release参考
- .moduleName = "HDF_PLATFORM_WATCHDOG",//【必要且与HCS文件中里面的moduleName匹配】
- };
- HDF_INIT(g_watchdogDriverEntry);//调用HDF_INIT将驱动入口注册到HDF框架中
- ```
-
-2. 完成驱动入口注册之后,下一步请在device\_info.hcs文件中添加deviceNode信息,并在 watchdog\_config.hcs 中配置器件属性。deviceNode信息与驱动入口注册相关,器件属性值与核心层WatchdogCntlr 成员的默认值或限制范围有密切关系。
-
- 本例只有一个Watchdog控制器,如有多个器件信息,则需要在device\_info文件增加deviceNode信息,以及在watchdog\_config文件中增加对应的器件属性。
-
- - device\_info.hcs 配置参考。
-
- ```
- root {
- device_info {
- match_attr = "hdf_manager";
- device_watchdog :: device { // 设备节点
- device0 :: deviceNode { // 驱动的DeviceNode节点
- policy = 1; // policy字段是驱动服务发布的策略,如果需要面向用户态,则为2
- priority = 20; // 驱动启动优先级
- permission = 0644; // 驱动创建设备节点权限
- moduleName = "HDF_PLATFORM_WATCHDOG";
- // 【必要】驱动名称,该字段的值必须和驱动入口结构的moduleName值一致
- serviceName = "HDF_PLATFORM_WATCHDOG_0";
- // 【必要且唯一】驱动对外发布服务的名称
- deviceMatchAttr = "hisilicon_hi35xx_watchdog_0";
- // 【必要】驱动私有数据匹配的关键字,必须和驱动私有数据配置表中的match_attr值相等
- }
- }
- }
- }
- ```
-
- - watchdog\_config.hcs 配置参考。
-
- ```
- root {
- platform {
- template watchdog_controller {//【必要】模板配置,继承该模板的节点如果使用模板中的默认值,则节点字段可以缺省
- id = 0;
- match_attr = "";
- regBase = 0x12050000; //【必要】地址映射需要
- regStep = 0x1000; //【必要】地址映射需要
- }
- controller_0x12050000 :: watchdog_controller {//【必要】是作为设备驱动私有数据匹配的关键字
- match_attr = "hisilicon_hi35xx_watchdog_0"; //【必要】必须和device_info.hcs中的deviceMatchAttr值一致
- }
- //存在多个 watchdog 时【必须】添加,否则不用
- ...
- }
- }
- ```
-
-3. 完成驱动入口注册之后,最后一步就是以核心层WatchdogCntlr对象的初始化为核心,包括厂商自定义结构体(传递参数和数据),实例化WatchdogCntlr成员WatchdogMethod(让用户可以通过接口来调用驱动底层函数),实现HdfDriverEntry成员函数(Bind,Init,Release)。
- - 自定义结构体参考。
-
- 从驱动的角度看,自定义结构体是参数和数据的载体,而且watchdog\_config.hcs文件中的数值会被HDF读入通过DeviceResourceIface来初始化结构体成员,其中一些重要数值也会传递给核心层WatchdogCntlr对象,例如索引、管脚数等。
-
- ```
- struct Hi35xxWatchdog {
- struct WatchdogCntlr wdt; //【必要】是链接上下层的载体,具体描述见下面
- OsalSpinlock lock;
- volatile unsigned char *regBase;//【必要】地址映射需要
- uint32_t phyBase; //【必要】地址映射需要
- uint32_t regStep; //【必要】地址映射需要
- };
- //WatchdogCntlr是核心层控制器结构体,其中的成员在Init函数中会被赋值
- struct WatchdogCntlr {
- struct IDeviceIoService service;//驱动服务
- struct HdfDeviceObject *device; //驱动设备
- OsalSpinlock lock; //此变量在HDF核心层被调用来实现自旋锁功能
- struct WatchdogMethod *ops; //接口回调函数
- int16_t wdtId; //WDG设备的识别id
- void *priv; //存储指针
- };
- ```
-
- - WatchdogCntlr成员回调函数结构体WatchdogMethod的实例化,其他成员在Init和Bind函数中初始化。
-
- ```
- static struct WatchdogMethod g_method = {
- .getStatus = Hi35xxWatchdogGetStatus,
- .start = Hi35xxWatchdogStart,
- .stop = Hi35xxWatchdogStop,
- .setTimeout = Hi35xxWatchdogSetTimeout,
- .getTimeout = Hi35xxWatchdogGetTimeout,
- .feed = Hi35xxWatchdogFeed,
- };
- ```
-
- - Init函数和Bind函数参考
-
- 入参:
-
- HdfDeviceObject :HDF框架给每一个驱动创建的设备对象,用来保存设备相关的私有数据和服务接口。
-
- 返回值:
-
- HDF\_STATUS相关状态 (下表为部分展示,如需使用其他状态,可见//drivers/framework/include/utils/hdf\_base.h中HDF\_STATUS 定义)。
-
- **表 2** Init函数和Bind函数入参和返回值
-
-
- 状态(值)
- |
- 问题描述
- |
-
-
- HDF_ERR_INVALID_OBJECT
- |
- 找不到 WDG 设备
- |
-
- HDF_ERR_MALLOC_FAIL
- |
- 内存分配失败
- |
-
- HDF_ERR_IO
- |
- I/O 错误
- |
-
- HDF_SUCCESS
- |
- 初始化成功
- |
-
- HDF_FAILURE
- |
- 初始化失败
- |
-
-
-
-
- 函数说明:
-
- 初始化自定义结构体对象,初始化WatchdogCntlr成员,调用核心层WatchdogCntlrAdd函数。
-
- ```
- //一般而言,Init函数需要根据入参(HdfDeviceObject对象)的属性值初始化Hi35xxWatchdog结构体的成员,
- //但本例中是在bind函数中实现的
- static int32_t Hi35xxWatchdogInit(struct HdfDeviceObject *device)
- {
- (void)device;
- return HDF_SUCCESS;
- }
+1. **实例化驱动入口:**
+ - 实例化HdfDriverEntry结构体成员。
+ - 调用HDF_INIT将HdfDriverEntry实例化对象注册到HDF框架中。
+
+2. **配置属性文件:**
+ - 在device_info.hcs文件中添加deviceNode描述。
+ - 【可选】添加watchdog_config.hcs器件属性文件。
+
+3. **实例化Watchdog控制器对象:**
+ - 初始化WatchdogCntlr成员。
+ - 实例化WatchdogCntlr成员WatchdogMethod。
+ >  **说明:**
+ > 实例化WatchdogCntlr成员WatchdogMethod,其定义和成员说明见[接口说明](#接口说明)。
+
+4. **驱动调试:**
+ 【可选】针对新增驱动程序,建议验证驱动基本功能,例如挂载后的信息反馈,超时时间设置的成功与否等。
+
+
+## 开发实例
+
+下方将以watchdog_hi35xx.c为示例,展示需要厂商提供哪些内容来完整实现设备功能。
+
+1. 驱动开发首先需要实例化驱动入口,驱动入口必须为HdfDriverEntry(在 hdf_device_desc.h 中定义)类型的全局变量,且moduleName要和device_info.hcs中保持一致。HDF框架会将所有加载的驱动的HdfDriverEntry对象首地址汇总,形成一个类似数组的段地址空间,方便上层调用。
+ 一般在加载驱动时HDF会先调用Bind函数,再调用Init函数加载该驱动。当Init调用异常时,HDF框架会调用Release释放驱动资源并退出。
+
+ Watchdog驱动入口参考:
+
+ ```
+ struct HdfDriverEntry g_watchdogDriverEntry = {
+ .moduleVersion = 1,
+ .Bind = Hi35xxWatchdogBind, // 见Bind参考
+ .Init = Hi35xxWatchdogInit, // 见Init参考
+ .Release = Hi35xxWatchdogRelease, // 见Release参考
+ .moduleName = "HDF_PLATFORM_WATCHDOG",// 【必要且与HCS文件中里面的moduleName匹配】
+ };
+ HDF_INIT(g_watchdogDriverEntry);// 调用HDF_INIT将驱动入口注册到HDF框架中
+ ```
+
+2. 完成驱动入口注册之后,下一步请在device_info.hcs文件中添加deviceNode信息,并在 watchdog_config.hcs 中配置器件属性。deviceNode信息与驱动入口注册相关,器件属性值与核心层WatchdogCntlr 成员的默认值或限制范围有密切关系。
+ 本例只有一个Watchdog控制器,如有多个器件信息,则需要在device_info文件增加deviceNode信息,以及在watchdog_config文件中增加对应的器件属性。
+ - device_info.hcs 配置参考:
+
+
+ ```
+ root {
+ device_info {
+ match_attr = "hdf_manager";
+ device_watchdog :: device { // 设备节点
+ device0 :: deviceNode { // 驱动的DeviceNode节点
+ policy = 1; // policy字段是驱动服务发布的策略,如果需要面向用户态,则为2
+ priority = 20; // 驱动启动优先级
+ permission = 0644; // 驱动创建设备节点权限
+ moduleName = "HDF_PLATFORM_WATCHDOG";
+ // 【必要】驱动名称,该字段的值必须和驱动入口结构的moduleName值一致
+ serviceName = "HDF_PLATFORM_WATCHDOG_0";
+ // 【必要且唯一】驱动对外发布服务的名称
+ deviceMatchAttr = "hisilicon_hi35xx_watchdog_0";
+ // 【必要】驱动私有数据匹配的关键字,必须和驱动私有数据配置表中的match_attr值相等
+ }
+ }
+ }
+ }
+ ```
+
+ - watchdog_config.hcs 配置参考:
+
+
+ ```
+ root {
+ platform {
+ template watchdog_controller {// 【必要】模板配置,继承该模板的节点如果使用模板中的默认值,则节点字段可以缺省
+ id = 0;
+ match_attr = "";
+ regBase = 0x12050000; // 【必要】地址映射需要
+ regStep = 0x1000; // 【必要】地址映射需要
+ }
+ controller_0x12050000 :: watchdog_controller {// 【必要】是作为设备驱动私有数据匹配的关键字
+ match_attr = "hisilicon_hi35xx_watchdog_0"; // 【必要】必须和device_info.hcs中的deviceMatchAttr值一致
+ }
+ // 存在多个 watchdog 时【必须】添加,否则不用
+ ...
+ }
+ }
+ ```
+
+3. 完成驱动入口注册之后,最后一步就是以核心层WatchdogCntlr对象的初始化为核心,包括厂商自定义结构体(传递参数和数据),实例化WatchdogCntlr成员WatchdogMethod(让用户可以通过接口来调用驱动底层函数),实现HdfDriverEntry成员函数(Bind,Init,Release)。
+ - 自定义结构体参考。
+
+ 从驱动的角度看,自定义结构体是参数和数据的载体,而且watchdog_config.hcs文件中的数值会被HDF读入通过DeviceResourceIface来初始化结构体成员,其中一些重要数值也会传递给核心层WatchdogCntlr对象,例如索引、管脚数等。
+
+
+ ```
+ struct Hi35xxWatchdog {
+ struct WatchdogCntlr wdt; // 【必要】是链接上下层的载体,具体描述见下面
+ OsalSpinlock lock;
+ volatile unsigned char *regBase;// 【必要】地址映射需要
+ uint32_t phyBase; // 【必要】地址映射需要
+ uint32_t regStep; // 【必要】地址映射需要
+ };
+ // WatchdogCntlr是核心层控制器结构体,其中的成员在Init函数中会被赋值
+ struct WatchdogCntlr {
+ struct IDeviceIoService service;// 驱动服务
+ struct HdfDeviceObject *device; // 驱动设备
+ OsalSpinlock lock; // 此变量在HDF核心层被调用来实现自旋锁功能
+ struct WatchdogMethod *ops; // 接口回调函数
+ int16_t wdtId; // WDG设备的识别id
+ void *priv; // 存储指针
+ };
+ ```
+ - WatchdogCntlr成员回调函数结构体WatchdogMethod的实例化,其他成员在Init和Bind函数中初始化。
+
- static int32_t Hi35xxWatchdogBind(struct HdfDeviceObject *device)
- {
- int32_t ret;
- struct Hi35xxWatchdog *hwdt = NULL;
- ...
- hwdt = (struct Hi35xxWatchdog *)OsalMemCalloc(sizeof(*hwdt));//Hi35xxWatchdog 结构体的内存申请
- ...
- hwdt->regBase = OsalIoRemap(hwdt->phyBase, hwdt->regStep); //地址映射
- ...
- hwdt->wdt.priv = (void *)device->property;//【可选】此处是将设备属性的内容赋值给priv成员,但后续没有调用 priv 成员,
- // 如果需要用到priv成员,需要额外实例化WatchdogMethod的getPriv和releasePriv成员函数
- hwdt->wdt.ops = &g_method; //【必要】将实例化后的对象赋值给ops成员,就可以实现顶层调用WatchdogMethod成员函数
- hwdt->wdt.device = device; //【必要】这是为了方便HdfDeviceObject与WatchdogcCntlr相互转化
- ret = WatchdogCntlrAdd(&hwdt->wdt); //【必要】调用此函数初始化核心层结构体,返回成功信号后驱动才完全接入平台核心层
- if (ret != HDF_SUCCESS) { //不成功的话,需要释放Init函数申请的资源
- OsalIoUnmap((void *)hwdt->regBase);
- OsalMemFree(hwdt);
- return ret;
- }
- return HDF_SUCCESS;
- }
- ```
-
- - Release函数参考
-
- 入参:
-
- HdfDeviceObject :HDF框架给每一个驱动创建的设备对象,用来保存设备相关的私有数据和服务接口。
-
- 返回值:
-
- 无。
-
- 函数说明:
-
- 该函数需要在驱动入口结构体中赋值给Release,当HDF框架调用Init函数初始化驱动失败时,可以调用Release释放驱动资源。该函数中需包含释放内存和删除控制器等操作。所有强制转换获取相应对象的操作前提是在Init函数中具备对应赋值的操作。
-
- ```
- static void Hi35xxWatchdogRelease(struct HdfDeviceObject *device)
- {
- struct WatchdogCntlr *wdt = NULL;
- struct Hi35xxWatchdog *hwdt = NULL;
- ...
- wdt = WatchdogCntlrFromDevice(device);//这里会通过service成员将HdfDeviceObject转化为WatchdogCntlr
- //return (device == NULL) ? NULL : (struct WatchdogCntlr *)device->service;
- if (wdt == NULL) {
- return;
- }
- WatchdogCntlrRemove(wdt); //核心层函数,实际执行wdt->device->service = NULL以及cntlr->lock的释放
- hwdt = (struct Hi35xxWatchdog *)wdt; //这里将WatchdogCntlr转化为HimciHost
- if (hwdt->regBase != NULL) { //解除地址映射
- OsalIoUnmap((void *)hwdt->regBase);
- hwdt->regBase = NULL;
- }
- OsalMemFree(hwdt); //释放厂商自定义对象占用的内存
- }
- ```
+ ```
+ static struct WatchdogMethod g_method = {
+ .getStatus = Hi35xxWatchdogGetStatus,
+ .start = Hi35xxWatchdogStart,
+ .stop = Hi35xxWatchdogStop,
+ .setTimeout = Hi35xxWatchdogSetTimeout,
+ .getTimeout = Hi35xxWatchdogGetTimeout,
+ .feed = Hi35xxWatchdogFeed,
+ };
+ ```
+
+ - Init函数和Bind函数参考:
+ 入参:
+ HdfDeviceObject :HDF框架给每一个驱动创建的设备对象,用来保存设备相关的私有数据和服务接口。
+ 返回值:
+
+ HDF_STATUS相关状态 (下表为部分展示,如需使用其他状态,可见// drivers/framework/include/utils/hdf_base.h中HDF_STATUS 定义)。
+
+ **表2** Init函数和Bind函数入参和返回值
+
+ | 状态(值) | 问题描述 |
+ | -------- | -------- |
+ | HDF_ERR_INVALID_OBJECT | 找不到 WDG 设备 |
+ | HDF_ERR_MALLOC_FAIL | 内存分配失败 |
+ | HDF_ERR_IO | I/O 错误 |
+ | HDF_SUCCESS | 初始化成功 |
+ | HDF_FAILURE | 初始化失败 |
+
+ 函数说明:
+
+ 初始化自定义结构体对象,初始化WatchdogCntlr成员,调用核心层WatchdogCntlrAdd函数。
+
+
+ ```
+ // 一般而言,Init函数需要根据入参(HdfDeviceObject对象)的属性值初始化Hi35xxWatchdog结构体的成员,
+ // 但本例中是在bind函数中实现的
+ static int32_t Hi35xxWatchdogInit(struct HdfDeviceObject *device)
+ {
+ (void)device;
+ return HDF_SUCCESS;
+ }
+
+ static int32_t Hi35xxWatchdogBind(struct HdfDeviceObject *device)
+ {
+ int32_t ret;
+ struct Hi35xxWatchdog *hwdt = NULL;
+ ...
+ hwdt = (struct Hi35xxWatchdog *)OsalMemCalloc(sizeof(*hwdt));// Hi35xxWatchdog 结构体的内存申请
+ ...
+ hwdt->regBase = OsalIoRemap(hwdt->phyBase, hwdt->regStep); // 地址映射
+ ...
+ hwdt->wdt.priv = (void *)device->property;// 【可选】此处是将设备属性的内容赋值给priv成员,但后续没有调用 priv 成员,
+ // 如果需要用到priv成员,需要额外实例化WatchdogMethod的getPriv和releasePriv成员函数
+ hwdt->wdt.ops = &g_method; // 【必要】将实例化后的对象赋值给ops成员,就可以实现顶层调用WatchdogMethod成员函数
+ hwdt->wdt.device = device; // 【必要】这是为了方便HdfDeviceObject与WatchdogcCntlr相互转化
+ ret = WatchdogCntlrAdd(&hwdt->wdt); // 【必要】调用此函数初始化核心层结构体,返回成功信号后驱动才完全接入平台核心层
+ if (ret != HDF_SUCCESS) { // 不成功的话,需要释放Init函数申请的资源
+ OsalIoUnmap((void *)hwdt->regBase);
+ OsalMemFree(hwdt);
+ return ret;
+ }
+ return HDF_SUCCESS;
+ }
+ ```
+ - Release函数参考:
+
+ 入参:
+
+ HdfDeviceObject:HDF框架给每一个驱动创建的设备对象,用来保存设备相关的私有数据和服务接口。
+
+ 返回值:
+
+ 无。
+
+ 函数说明:
+
+ 该函数需要在驱动入口结构体中赋值给Release,当HDF框架调用Init函数初始化驱动失败时,可以调用Release释放驱动资源。该函数中需包含释放内存和删除控制器等操作。所有强制转换获取相应对象的操作前提是在Init函数中具备对应赋值的操作。
+
+
+ ```
+ static void Hi35xxWatchdogRelease(struct HdfDeviceObject *device)
+ {
+ struct WatchdogCntlr *wdt = NULL;
+ struct Hi35xxWatchdog *hwdt = NULL;
+ ...
+ wdt = WatchdogCntlrFromDevice(device);// 这里会通过service成员将HdfDeviceObject转化为WatchdogCntlr
+ // return (device == NULL) ? NULL : (struct WatchdogCntlr *)device->service;
+ if (wdt == NULL) {
+ return;
+ }
+ WatchdogCntlrRemove(wdt); // 核心层函数,实际执行wdt->device->service = NULL以及cntlr->lock的释放
+ hwdt = (struct Hi35xxWatchdog *)wdt; // 这里将WatchdogCntlr转化为HimciHost
+ if (hwdt->regBase != NULL) { // 解除地址映射
+ OsalIoUnmap((void *)hwdt->regBase);
+ hwdt->regBase = NULL;
+ }
+ OsalMemFree(hwdt); // 释放厂商自定义对象占用的内存
+ }
+ ```
\ No newline at end of file
diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hicollie.md b/zh-cn/device-dev/subsystems/subsys-dfx-hicollie.md
index c81289a859e496debb4d69e4a2a7fe8a01ae2186..64b2f6256ca6bb29eab87287ad7b17df0ac7d155 100644
--- a/zh-cn/device-dev/subsystems/subsys-dfx-hicollie.md
+++ b/zh-cn/device-dev/subsystems/subsys-dfx-hicollie.md
@@ -1,13 +1,5 @@
# HiCollie开发指导
-- [概述](#section3432134085116)
-- [接口说明](#section139261151145116)
-- [效果](#section1589120102458)
-- [开发实例](#section13905646534)
- - [C++接口开发实例](#section9797199145316)
- - [线程卡死监控](#section1734221332)
- - [超时监控](#section2186947140)
-
## 概述
diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hilog-lite.md b/zh-cn/device-dev/subsystems/subsys-dfx-hilog-lite.md
index ad09ffb51a01da5d07f78af250c187d671e06f0a..31759ce68c493a82606724e94f7daaeeee568ccb 100755
--- a/zh-cn/device-dev/subsystems/subsys-dfx-hilog-lite.md
+++ b/zh-cn/device-dev/subsystems/subsys-dfx-hilog-lite.md
@@ -1,8 +1,5 @@
# HiLog\_Lite开发指导
-- [概述](#section775017517390)
-- [接口说明](#section114412157402)
-- [开发实例](#section1482812550419)
## 概述
diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-listening.md b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-listening.md
index 81785b1a3c6568cb93307ad1aa99081eea395f59..048ff9e661cc6e019809ec8d53df4bff57d231da 100644
--- a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-listening.md
+++ b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-listening.md
@@ -1,11 +1,5 @@
# HiSysEvent订阅指导
-- [概述](#section315316685112)
- - [功能简介](#section123181433335224)
- - [约束与限制](#section123181433375224)
-- [开发指导](#section315316685113)
- - [接口说明](#section0342191810519)
- - [开发实例](#section123181432175110)
## 概述
diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-query.md b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-query.md
index d467ec4e62033d8ee421e69fda5ec4bee634c78a..9acbac7f2e017d7712b59c5a71293f9759aadb7a 100644
--- a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-query.md
+++ b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-query.md
@@ -1,9 +1,5 @@
# HiSysEvent查询指导
-- [概述](#section279684125212)
-- [开发指导](#section315316761113)
- - [接口说明](#section03869128521)
- - [开发实例](#section14286111855212)
## 概述
diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-tool.md b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-tool.md
index 8d4d6a84a9802dcbbf9702fe85f59bcea1bb67a5..1974640a3a543a2afcc5a86f784b66012e532340 100644
--- a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-tool.md
+++ b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-tool.md
@@ -1,8 +1,5 @@
# HiSysEvent工具使用指导
-- [概述](#section1886702718521)
-- [实时订阅HiSysEvent事件相关命令](#section1210623418527)
-- [查询历史HiSysEvent事件相关命令](#section1210623418539)
## 概述
diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hitrace.md b/zh-cn/device-dev/subsystems/subsys-dfx-hitrace.md
index 1b2af97a7833183344a189cd9e3c1d1f95b7f34c..a04e0abafd60441f95828a673d4bd36bf35fe9fc 100644
--- a/zh-cn/device-dev/subsystems/subsys-dfx-hitrace.md
+++ b/zh-cn/device-dev/subsystems/subsys-dfx-hitrace.md
@@ -1,18 +1,5 @@
# HiTrace开发指导
-- [概述](#section3986195420436)
-- [应用场景](#section134561822574)
- - [业务使用示例](#section63861653124417)
-
-- [接口说明](#section1517945334617)
- - [接口形式对比](#section932504474)
- - [接口功能参数](#section2514638125)
-
-- [通信调用处理](#section11257133933)
-- [开发实例](#section14310412491)
- - [C++接口实例](#section114916381509)
- - [C接口实例](#section108292107514)
-
## 概述
diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-overview.md b/zh-cn/device-dev/subsystems/subsys-dfx-overview.md
index c43e87a0da07c188fc17454b7ec780bf6334aa80..738dc3d6f9c1abe74cd52d34969e521f95fc1dca 100755
--- a/zh-cn/device-dev/subsystems/subsys-dfx-overview.md
+++ b/zh-cn/device-dev/subsystems/subsys-dfx-overview.md
@@ -1,6 +1,5 @@
# DFX概述
-- [基本概念](#section5635178134811)
在OpenHarmony中,DFX\([Design for X](https://en.wikipedia.org/wiki/Design_for_X)\)是为了提升质量属性的软件设计,目前包含的内容主要有:DFR(Design for Reliability,可靠性)和DFT(Design for Testability,可测试性)特性。
diff --git a/zh-cn/device-dev/subsystems/subsys-graphics-animation-guide.md b/zh-cn/device-dev/subsystems/subsys-graphics-animation-guide.md
index 8332aa22bd87afd1e6d8e6dff632b189cc0c19ea..cc90021eb41319166601f0c76ffe000ae67d1027 100644
--- a/zh-cn/device-dev/subsystems/subsys-graphics-animation-guide.md
+++ b/zh-cn/device-dev/subsystems/subsys-graphics-animation-guide.md
@@ -1,9 +1,5 @@
# 动画开发指导
-- [使用场景](#section726685714018)
-- [接口说明](#section85794718418)
-- [开发步骤](#section14101161317435)
-
## 使用场景
UI动画通过task处理机制每个tick调用一下用户设置的callback函数来实现,具体实现为AnimatorManager、Animator、AnimatorCallback三个类实现。
diff --git a/zh-cn/device-dev/subsystems/subsys-graphics-common-guide.md b/zh-cn/device-dev/subsystems/subsys-graphics-common-guide.md
index d9b0d48c87587588b3bbd4b39c83e636001dcbd6..b09d8fc7535a8dbfdd4234fdabce4bf8a361da10 100644
--- a/zh-cn/device-dev/subsystems/subsys-graphics-common-guide.md
+++ b/zh-cn/device-dev/subsystems/subsys-graphics-common-guide.md
@@ -1,23 +1,6 @@
# 普通组件开发指导
-- [UIButton](#section145353310214)
-- [使用场景](#section1169616141577)
-- [接口说明](#section341211538315)
-- [开发步骤](#section22501726193214)
-- [UIImageView](#section19523161611259)
-- [使用场景](#section1274484210400)
-- [接口说明](#section74981992411)
-- [开发步骤(自适应)](#section144341333134114)
-- [开发步骤(平铺模式)](#section97178160421)
-- [UILabel](#section16588132012911)
-- [使用场景](#section6870195634218)
-- [接口说明](#section2012714510433)
-- [开发步骤(默认模式)](#section83221538114410)
-- [开发步骤(背景色和透明度)](#section933360204510)
-- [开发步骤(字符间距)](#section19447826124518)
-- [开发步骤(大小自适应)](#section101711842154617)
-- [开发步骤(省略号模式)](#section1249519410471)
-- [开发步骤(滚动模式)](#section15643122618478)
+
普通组件均继承于基类UIView,不可以添加子组件,常用的普通组件有button、image、label等。
diff --git a/zh-cn/device-dev/subsystems/subsys-graphics-container-guide.md b/zh-cn/device-dev/subsystems/subsys-graphics-container-guide.md
index 52da564931e3f8ff58c2e0379c98dbcbc993aa58..8d4ec8ca4e166821cab0c7ee855034f412dd04f5 100644
--- a/zh-cn/device-dev/subsystems/subsys-graphics-container-guide.md
+++ b/zh-cn/device-dev/subsystems/subsys-graphics-container-guide.md
@@ -1,13 +1,5 @@
# 容器类组件开发指导
-- [UIViewGroup](#section145471898812)
-- [使用场景](#section0916112362216)
-- [接口说明](#section12641756192212)
-- [开发步骤](#section5412161692311)
-- [UIScrollView](#section174961523161315)
-- [使用场景](#section8937101902413)
-- [接口说明](#section14789133142420)
-- [开发步骤](#section1769754422417)
容器类组件,指能包含其它UI组件的组件,容器类组件继承于UIViewGroup(带Add方法),基于实际组件的使用场景,将需要增加其他子组件的组件,放置到容器类继承结构下。如UIAnalogClock内,通常会Add需要的计步信息,时分秒图标等。
diff --git a/zh-cn/device-dev/subsystems/subsys-graphics-layout-guide.md b/zh-cn/device-dev/subsystems/subsys-graphics-layout-guide.md
index f03df38642b7f5892957eedc54a9648b0168e3be..69f313de4670aa88bf29016ad1c52c373c649b95 100644
--- a/zh-cn/device-dev/subsystems/subsys-graphics-layout-guide.md
+++ b/zh-cn/device-dev/subsystems/subsys-graphics-layout-guide.md
@@ -1,14 +1,5 @@
# 布局容器类组件开发指导
-- [UISwipeView](#section13631719181717)
-- [使用场景](#section11299120102617)
-- [接口说明](#section767434119261)
-- [开发步骤(水平滑动,不可循环)](#section111911175287)
-- [开发步骤(水平滑动,可循环)](#section1976914915282)
-- [GridLayout](#section46819199173)
-- [使用场景](#section831618247294)
-- [接口说明](#section597214622912)
-- [开发步骤](#section1418253410306)
布局类容器组件由视图基础类组成,通过直接设置视图位置,可以达到嵌套和重叠布局的目的;通过设置布局类型和边距达到规格化布局子组件的目的;通过调用相关接口可实现根据父组件及兄弟节点布局视图的目的。
diff --git a/zh-cn/device-dev/subsystems/subsys-graphics-overview.md b/zh-cn/device-dev/subsystems/subsys-graphics-overview.md
index 49c1f610f94a083758882211c59ab8ca7b1f2150..39ebda40bf7a95cb369cae644f35a2141556834f 100755
--- a/zh-cn/device-dev/subsystems/subsys-graphics-overview.md
+++ b/zh-cn/device-dev/subsystems/subsys-graphics-overview.md
@@ -1,10 +1,5 @@
# 图形图像概述
-- [UI组件](#section1987017145112)
-- [布局](#section662016231612)
-- [动画](#section73736284117)
-- [Input事件](#section672194012114)
-- [渲染](#section14338859916)
OpenHarmony图形系统,提供基础UI组件和容器类组件,包括button、image、label、list、animator、scroll view、swipe view、font、clock、chart、canvas、slider、layout等。同时提供截屏、导出组件树的DFX能力。模块内部实现组件渲染、动画、输入事件分发等功能。
diff --git a/zh-cn/device-dev/subsystems/subsys-multimedia-camera-overview.md b/zh-cn/device-dev/subsystems/subsys-multimedia-camera-overview.md
index 824d3461ea0f803b8e568fedc442c45c86592eee..df0124e2ba86f669cd850d7b2b213b6c44e000ac 100644
--- a/zh-cn/device-dev/subsystems/subsys-multimedia-camera-overview.md
+++ b/zh-cn/device-dev/subsystems/subsys-multimedia-camera-overview.md
@@ -1,8 +1,5 @@
# 相机开发概述
-- [基本概念](#section175012297491)
-- [运作机制](#section193961322175011)
-
## 基本概念
相机是OpenHarmony多媒体进程提供的服务之一,提供了相机的录像、预览、拍照功能,支持多用户并发取流。
diff --git a/zh-cn/device-dev/subsystems/subsys-multimedia-camera-photo-guide.md b/zh-cn/device-dev/subsystems/subsys-multimedia-camera-photo-guide.md
index e0b36aed77c40460af653c70f6f2de1c96ef7baf..e1245fdb47eb38371bfb8cd45d4d4706ccaf8fe7 100644
--- a/zh-cn/device-dev/subsystems/subsys-multimedia-camera-photo-guide.md
+++ b/zh-cn/device-dev/subsystems/subsys-multimedia-camera-photo-guide.md
@@ -1,9 +1,5 @@
# 拍照开发指导
-- [使用场景](#section1963312376119)
-- [接口说明](#section56549532016)
-- [约束与限制](#section1165911177314)
-- [开发步骤](#section138543918214)
## 使用场景
diff --git a/zh-cn/device-dev/subsystems/subsys-multimedia-camera-preview-guide.md b/zh-cn/device-dev/subsystems/subsys-multimedia-camera-preview-guide.md
index 4594ff3706efbd014555fbfc421f153f289a7c29..710046fefd589d961acf18bf3147b2b231178ea0 100755
--- a/zh-cn/device-dev/subsystems/subsys-multimedia-camera-preview-guide.md
+++ b/zh-cn/device-dev/subsystems/subsys-multimedia-camera-preview-guide.md
@@ -1,9 +1,5 @@
# 预览开发指导
-- [使用场景](#section186634310418)
-- [接口说明](#section125479541744)
-- [约束与限制](#section1165911177314)
-- [开发步骤](#section34171333656)
## 使用场景
diff --git a/zh-cn/device-dev/subsystems/subsys-multimedia-camera-record-guide.md b/zh-cn/device-dev/subsystems/subsys-multimedia-camera-record-guide.md
index ef3a6f69aebe9f6d07d71ecfc2f116ae55913af5..60dd1fc7a1798a1a61bbf7b6d6f7a461dd893d5f 100755
--- a/zh-cn/device-dev/subsystems/subsys-multimedia-camera-record-guide.md
+++ b/zh-cn/device-dev/subsystems/subsys-multimedia-camera-record-guide.md
@@ -1,9 +1,5 @@
# 录像开发指导
-- [使用场景](#section186634310418)
-- [接口说明](#section125479541744)
-- [约束与限制](#section1165911177314)
-- [开发步骤](#section1196016315516)
## 使用场景
diff --git a/zh-cn/device-dev/subsystems/subsys-multimedia-video-overview.md b/zh-cn/device-dev/subsystems/subsys-multimedia-video-overview.md
index 442d452b40bbc88fe73ed2f290efc278711f5fa3..329a632b0a74591973abca1ec91ac95624d4fd2a 100755
--- a/zh-cn/device-dev/subsystems/subsys-multimedia-video-overview.md
+++ b/zh-cn/device-dev/subsystems/subsys-multimedia-video-overview.md
@@ -1,7 +1,5 @@
# 音视频开发概述
-- [基本概念](#section967213571204)
-- [编解码规格](#section1582020483111)
OpenHarmony音视频包括音视频播放和录制。
diff --git a/zh-cn/device-dev/subsystems/subsys-multimedia-video-play-guide.md b/zh-cn/device-dev/subsystems/subsys-multimedia-video-play-guide.md
index 0024dc47b5e5efe4236cd2483eb9211858feffdc..94942fba5ab83a40679683b51557a340ec72665e 100755
--- a/zh-cn/device-dev/subsystems/subsys-multimedia-video-play-guide.md
+++ b/zh-cn/device-dev/subsystems/subsys-multimedia-video-play-guide.md
@@ -1,9 +1,5 @@
# 音视频播放开发指导
-- [使用场景](#section186634310418)
-- [接口说明](#section125479541744)
-- [约束与限制](#section1165911177314)
-- [开发步骤](#section34171333656)
## 使用场景
diff --git a/zh-cn/device-dev/subsystems/subsys-multimedia-video-record-guide.md b/zh-cn/device-dev/subsystems/subsys-multimedia-video-record-guide.md
index 19887e60b975c7284406d903acb4c451934eb823..887422c16434b77032e6568c877371bb6aaaefc4 100755
--- a/zh-cn/device-dev/subsystems/subsys-multimedia-video-record-guide.md
+++ b/zh-cn/device-dev/subsystems/subsys-multimedia-video-record-guide.md
@@ -1,10 +1,5 @@
# 音视频录制开发指导
-- [使用场景](#section186634310418)
-- [接口说明](#section125479541744)
-- [约束与限制](#section1165911177314)
-- [开发步骤](#section34171333656)
-
## 使用场景
音视频录制的主要功能是录制音视频,并根据设置的编码格式、采样率、码率等参数封装输出文件。
diff --git a/zh-cn/device-dev/subsystems/subsys-remote-start.md b/zh-cn/device-dev/subsystems/subsys-remote-start.md
index 9d456643d321650e42b869ab992d76f617c48022..36b78ffb23a41792ed563cb393d647c9d9d8e691 100755
--- a/zh-cn/device-dev/subsystems/subsys-remote-start.md
+++ b/zh-cn/device-dev/subsystems/subsys-remote-start.md
@@ -1,11 +1,5 @@
# 分布式远程启动
-- [概述](#section186634310418)
-- [基本概念](#section982651246)
-- [接口说明](#section125479541744)
-- [约束与限制](#section1165911177314)
-- [开发步骤](#section34171333656)
-
## 概述
分布式任务调度模块,通过主从设备服务代理机制,在OpenHarmony操作系统上建立起分布式服务平台,支持主设备\(搭载OpenHarmony的智慧屏设备\)启动从设备\(IP Camera、运动手表等小内存OpenHarmony设备\)FA的能力。
diff --git a/zh-cn/device-dev/subsystems/subsys-security-communicationverify.md b/zh-cn/device-dev/subsystems/subsys-security-communicationverify.md
index 7196714e220ec5db74474fd7840b6c7521730f2c..2c78a6c9cb9cf4e4c3c1e13cdad1658cc38d05aa 100644
--- a/zh-cn/device-dev/subsystems/subsys-security-communicationverify.md
+++ b/zh-cn/device-dev/subsystems/subsys-security-communicationverify.md
@@ -1,9 +1,5 @@
# IPC通信鉴权开发指导
-- [场景介绍](#section18502174174019)
-- [接口说明](#section1633115419401)
-- [开发步骤](#section022611498210)
-- [常见问题](#section15729104510271)
## 场景介绍
diff --git a/zh-cn/device-dev/subsystems/subsys-security-rightmanagement.md b/zh-cn/device-dev/subsystems/subsys-security-rightmanagement.md
index 37f3cdbbf7c82ceb3489f67358c7ac0f1b07e2bf..bd1ca3462fcabad41fdd3f5a6721914286eb3bd1 100644
--- a/zh-cn/device-dev/subsystems/subsys-security-rightmanagement.md
+++ b/zh-cn/device-dev/subsystems/subsys-security-rightmanagement.md
@@ -1,10 +1,5 @@
# 应用权限管理开发指导
-- [运作机制](#section193961322175011)
-- [场景介绍](#section18502174174019)
-- [接口说明](#section1633115419401)
-- [开发步骤](#section022611498210)
-
## 运作机制
由于OpenHarmony允许安装三方应用,所以需要对三方应用的敏感权限调用进行管控,具体实现是应用在开发阶段就需要在profile.json中指明此应用在运行过程中可能会调用哪些敏感权限,这些权限包括静态权限和动态权限,静态权限表示只需要在安装阶段注册就可以,而动态权限一般表示获取用户的敏感信息,所以需要在运行时让用户确认才可以调用,授权方式包括系统设置应用手动授权等。除了运行时对应用调用敏感权限进行管控外,还需要利用应用签名管控手段确保应用安装包已经被设备厂商进行了确认。
diff --git a/zh-cn/device-dev/subsystems/subsys-security-sigverify.md b/zh-cn/device-dev/subsystems/subsys-security-sigverify.md
index 8961131c04bf8910fcdd2e8c1bd589fd69b2718b..89a16c9a792aa5115d2342f3bb8035db5349bff1 100644
--- a/zh-cn/device-dev/subsystems/subsys-security-sigverify.md
+++ b/zh-cn/device-dev/subsystems/subsys-security-sigverify.md
@@ -1,11 +1,5 @@
# 应用验签开发指导
-- [场景介绍](#section18502174174019)
-- [验签流程](#section554632717226)
-- [接口说明](#section1633115419401)
-- [开发步骤](#section4207112818418)
- - [生成OpenHarmony签名应用](#section167151429133312)
-
## 场景介绍
diff --git a/zh-cn/device-dev/subsystems/subsys-tel-guide.md b/zh-cn/device-dev/subsystems/subsys-tel-guide.md
index 5718a31637056a193ee208b2d2ac9b7a0c4f36d0..a46d5fc17a3e59990e545be50927c40463615841 100644
--- a/zh-cn/device-dev/subsystems/subsys-tel-guide.md
+++ b/zh-cn/device-dev/subsystems/subsys-tel-guide.md
@@ -1,28 +1,5 @@
# 电话服务开发指导
-- [Modem厂商库初始化开发指导](#section211mcpsimp)
- - [场景介绍](#section213mcpsimp)
- - [接口说明](#section811343241215)
- - [开发步骤](#section51031144122)
- - [调测验证](#section5351151517132)
-
-- [Modem业务请求及响应开发指导](#section295mcpsimp)
- - [场景介绍](#section297mcpsimp)
- - [接口说明](#section9503155219134)
- - [开发步骤](#section17190412101414)
- - [调测验证](#section10207938171413)
-
-- [Modem事件上报开发指导](#section390mcpsimp)
- - [场景介绍](#section401mcpsimp)
- - [接口说明](#section191193791518)
- - [开发步骤](#section16394112401512)
- - [调测验证](#section16999174401516)
- - [开发实例](#section33444350167)
-
-- [Modem厂商库集成指导](#section590mcpsimp)
- - [编译设置](#section592mcpsimp)
- - [调测验证](#section620mcpsimp)
-
## Modem厂商库初始化开发指导
diff --git a/zh-cn/device-dev/subsystems/subsys-tel-overview.md b/zh-cn/device-dev/subsystems/subsys-tel-overview.md
index 596f0cc00906fd0b5004144acb7d7612aefb7fc7..f4aebe89140ca5a0a6dcf4a711b107021c0392e1 100644
--- a/zh-cn/device-dev/subsystems/subsys-tel-overview.md
+++ b/zh-cn/device-dev/subsystems/subsys-tel-overview.md
@@ -1,10 +1,5 @@
# 电话服务概述
-- [概述](#section184mcpsimp)
-- [基本概念](#section187mcpsimp)
-- [运作机制](#section194mcpsimp)
-- [约束与限制](#section205mcpsimp)
-
## 概述
本指南简要介绍了Modem厂商库的集成、初始化、业务请求响应和事件上报的方法,并通过通话业务的具体开发实例呈现厂商库的适配开发过程,供不同Modem芯片的开发者参考,从而帮助其高效地实现电话相关业务功能的开发。
diff --git a/zh-cn/device-dev/subsystems/subsys-usbservice-guide.md b/zh-cn/device-dev/subsystems/subsys-usbservice-guide.md
index 1692e51715a588cbafc20259d30640758daee834..72b8fced7a0f3c40b5bcb665d008220ea5d5cb43 100644
--- a/zh-cn/device-dev/subsystems/subsys-usbservice-guide.md
+++ b/zh-cn/device-dev/subsystems/subsys-usbservice-guide.md
@@ -1,6 +1,5 @@
# USB服务子系统使用指导
-- [使用步骤](#section18816105182315)
下面使用步骤以bulktransfer为例。
diff --git a/zh-cn/device-dev/subsystems/subsys-usbservice-overview.md b/zh-cn/device-dev/subsystems/subsys-usbservice-overview.md
index 9475d486a900b330dc65b4da1098146bcee85cb9..189205bd3387f431e71a21ee32bbebbfd9cb3c41 100644
--- a/zh-cn/device-dev/subsystems/subsys-usbservice-overview.md
+++ b/zh-cn/device-dev/subsystems/subsys-usbservice-overview.md
@@ -1,10 +1,5 @@
# USB服务子系统概述
-- [概述](#section175431838101617)
-- [接口说明](#section83365421647)
- - [Host部分](#section83365421658)
- - [Device部分](#section83365421669)
- - [Port部分](#section83365421670)
## 概述
diff --git a/zh-cn/release-notes/OpenHarmony-v3.1.1-release.md b/zh-cn/release-notes/OpenHarmony-v3.1.1-release.md
index 58f3ae9277f61d707953b4dbc66678446fb801fd..7a47c2fc202195039a512d4cfc6b7ed6e687a61f 100644
--- a/zh-cn/release-notes/OpenHarmony-v3.1.1-release.md
+++ b/zh-cn/release-notes/OpenHarmony-v3.1.1-release.md
@@ -32,12 +32,13 @@
**表1** 版本软件和工具配套关系
-| 软件 | 版本 | 备注 |
+| 软件 | 版本 | 备注 |
| -------- | -------- | -------- |
-| OpenHarmony | 3.1.1 Release | NA |
-| SDK | Ohos_sdk_full 3.1.6.5 (API Version 8 Release) | NA |
-| HUAWEI DevEco Studio(可选) | 3.0 Beta3 for OpenHarmony | OpenHarmony应用开发推荐使用 |
-| HUAWEI DevEco Device Tool(可选) | 3.0 Release | OpenHarmony智能设备集成开发环境推荐使用 |
+| OpenHarmony | 3.1.1 Release | NA |
+| Public SDK | Ohos_sdk_public 3.1.6.6 (API Version 8 Release) | 面向应用开发者提供,不包含需要使用系统权限的系统接口。
DevEco Studio 3.0 Beta4版本起,通过DevEco Studio获取的SDK默认为Public SDK。
该版本Public SDK于7月6日单独更新发布。 |
+| Full SDK | Ohos_sdk_full 3.1.6.5 (API Version 8 Release) | 面向OEM厂商提供,包含了需要使用系统权限的系统接口。
使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](../application-dev/quick-start/full-sdk-switch-guide.md)。 |
+| HUAWEI DevEco Studio(可选) | 3.0 Beta3 for OpenHarmony | OpenHarmony应用开发推荐使用。 |
+| HUAWEI DevEco Device Tool(可选) | 3.0 Release | OpenHarmony智能设备集成开发环境推荐使用。 |
## 源码获取
@@ -101,8 +102,10 @@ repo forall -c 'git lfs pull'
| Hi3861轻量系统解决方案(二进制) | 3.1.1 Release | [站点](https://repo.huaweicloud.com/openharmony/os/3.1.1/hispark_pegasus.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.1.1/hispark_pegasus.tar.gz.sha256) |
| Hi3516轻量系统解决方案-LiteOS(二进制) | 3.1.1 Release | [站点](https://repo.huaweicloud.com/openharmony/os/3.1.1/hispark_taurus.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.1.1/hispark_taurus.tar.gz.sha256) |
| Hi3516轻量系统解决方案-Linux(二进制) | 3.1.1 Release | [站点](https://repo.huaweicloud.com/openharmony/os/3.1.1/hispark_taurus_linux.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.1.1/hispark_taurus_linux.tar.gz.sha256) |
-| 标准系统SDK包(Mac) | 3.1.1 Release | [站点](https://repo.huaweicloud.com/openharmony/os/3.1.1/ohos-sdk-mac-full.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.1.1/ohos-sdk-mac-full.tar.gz.sha256) |
-| 标准系统SDK包(Windows\Linux) | 3.1.1 Release | [站点](https://repo.huaweicloud.com/openharmony/os/3.1.1/ohos-sdk-full.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.1.1/ohos-sdk-full.tar.gz.sha256) |
+| 标准系统Full SDK包(Mac) | 3.1.1 Release | [站点](https://repo.huaweicloud.com/openharmony/os/3.1.1/ohos-sdk-mac-full.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.1.1/ohos-sdk-mac-full.tar.gz.sha256) |
+| 标准系统Full SDK包(Windows\Linux) | 3.1.1 Release | [站点](https://repo.huaweicloud.com/openharmony/os/3.1.1/ohos-sdk-full.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.1.1/ohos-sdk-full.tar.gz.sha256) |
+| 标准系统Public SDK包(Mac) | 3.1.1 Release | [站点](https://repo.huaweicloud.com/openharmony/os/3.1.1/ohos-sdk-mac-public.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.1.1/ohos-sdk-mac-public.tar.gz.sha256) |
+| 标准系统Public SDK包(Windows\Linux) | 3.1.1 Release | [站点](https://repo.huaweicloud.com/openharmony/os/3.1.1/ohos-sdk-public.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.1.1/ohos-sdk-public.tar.gz.sha256) |
## 更新说明
@@ -114,21 +117,22 @@ repo forall -c 'git lfs pull'
**表3** 版本新增特性表
- | 子系统名称 | 标准系统 | 轻量、小型系统 |
+| 子系统名称 | 标准系统 | 轻量、小型系统 |
| -------- | -------- | -------- |
-| 系统服务管理 | 新增添加群组校验机制。
主要涉及如下需求:
I52G5Q 添加群组校验机制 | NA |
-| 电源管理 | 实现兼容亮度调节和电池信息查询API接口能力。
主要涉及如下需求:
I526UP 支持\@system.brightness亮度调节接口
I526UP 支持\@system.battery电池信息查询接口 | NA |
-| 包管理 | 实现查询指定应用是否安装接口能力。
主要涉及如下需求:
I56EWD 支持对测试框架的配置
I55RZJ 查询指定应用是否安装 | NA |
-| 位置服务 | 实现兼容基本定位API接口能力。
主要涉及如下需求:
I53WFP 支持基本定位能力,兼容system API | NA |
-| 元能力 | 实现FA模型支持查询/设置组件横竖屏状态、组件锁屏显示和组件启动亮屏。
主要涉及如下需求:
I56EH7 FA模型支持查询/设置组件横竖屏状态
I50D5Y FA模型支持组件锁屏显示
I56EH7 FA模型支持组件启动亮屏
I55WB0 卡片数据支持携带图片
I55WB0 FA卡片能力补齐-formManager重构
I55WB0 FA卡片能力补齐-支持卡片状态查询
I55WB0 FA卡片能力补齐-支持删除无效卡片
I55WB0 FA卡片能力补齐-支持卡片可见状态与更新状态单独设置
I50D8H 支持拦截uncatchedexception
I50D91 支持ANR(Application Not Response)处理 | NA |
-| 媒体 | 实现音频焦点、音频解码能力相关API接口能力。
主要涉及如下需求:
I56REO 音频部件焦点/设备接口OH补齐
I522W0 支持amr格式音频编码枚举类型 | NA |
-| 窗口 | 支持对窗口属性进行设置。
主要涉及如下需求:
I56EH7 支持窗口属性设置 | NA |
-| 网络管理 | 实现兼容WebSocket、fetch等API接口能力,支持以太网连接。
主要涉及如下需求:
I53CKH 支持兼容\@system.fetch
I53CJX 支持兼容\@system.network
I53CKT 支持WebSocket
I580PC 支持以太网连接 | NA |
-| Misc软件服务 | 实现兼容http文件下载API接口能力。
主要涉及如下需求:
I56Q4X 支持文件下载接口 | NA |
-| 事件通知 | 实现通知发送和取消的API接口能力。
主要涉及如下需求:
I50EEW 通知发送和取消功能的接口能力补齐 | NA |
-| 分布式数据管理 | 实现兼容\@system.storage API接口能力。
主要涉及如下需求:
I56RF3 支持\@system.storage接口 | NA |
-| 启动恢复 | 实现兼容\@system.device API接口能力。
主要涉及如下需求:
I56GBS 支持\@system.device相关API | NA |
-| 应用 | 联系人支持第三方应用调用系统通话能力,提供用户基础通信能力。
主要涉及如下需求:
I58ZQ4 联系人支持第三方应用调用系统通话能力 | NA |
+| SDK | SDK区分Full SDK和Public SDK进行发布。
*说明:API Version 8的Public SDK首次于7月6日单独更新发布。* | NA |
+| 系统服务管理 | 新增添加群组校验机制。
主要涉及如下需求:
I52G5Q 添加群组校验机制 | NA |
+| 电源管理 | 实现兼容亮度调节和电池信息查询API接口能力。
主要涉及如下需求:
I526UP 支持\@system.brightness亮度调节接口
I526UP 支持\@system.battery电池信息查询接口 | NA |
+| 包管理 | 实现查询指定应用是否安装接口能力。
主要涉及如下需求:
I56EWD 支持对测试框架的配置
I55RZJ 查询指定应用是否安装 | NA |
+| 位置服务 | 实现兼容基本定位API接口能力。
主要涉及如下需求:
I53WFP 支持基本定位能力,兼容system API | NA |
+| 元能力 | 实现FA模型支持查询/设置组件横竖屏状态、组件锁屏显示和组件启动亮屏。
主要涉及如下需求:
I56EH7 FA模型支持查询/设置组件横竖屏状态
I50D5Y FA模型支持组件锁屏显示
I56EH7 FA模型支持组件启动亮屏
I55WB0 卡片数据支持携带图片
I55WB0 FA卡片能力补齐-formManager重构
I55WB0 FA卡片能力补齐-支持卡片状态查询
I55WB0 FA卡片能力补齐-支持删除无效卡片
I55WB0 FA卡片能力补齐-支持卡片可见状态与更新状态单独设置
I50D8H 支持拦截uncatchedexception
I50D91 支持ANR(Application Not Response)处理 | NA |
+| 媒体 | 实现音频焦点、音频解码能力相关API接口能力。
主要涉及如下需求:
I56REO 音频部件焦点/设备接口OH补齐
I522W0 支持amr格式音频编码枚举类型 | NA |
+| 窗口 | 支持对窗口属性进行设置。
主要涉及如下需求:
I56EH7 支持窗口属性设置 | NA |
+| 网络管理 | 实现兼容WebSocket、fetch等API接口能力,支持以太网连接。
主要涉及如下需求:
I53CKH 支持兼容\@system.fetch
I53CJX 支持兼容\@system.network
I53CKT 支持WebSocket
I580PC 支持以太网连接 | NA |
+| Misc软件服务 | 实现兼容http文件下载API接口能力。
主要涉及如下需求:
I56Q4X 支持文件下载接口 | NA |
+| 事件通知 | 实现通知发送和取消的API接口能力。
主要涉及如下需求:
I50EEW 通知发送和取消功能的接口能力补齐 | NA |
+| 分布式数据管理 | 实现兼容\@system.storage API接口能力。
主要涉及如下需求:
I56RF3 支持\@system.storage接口 | NA |
+| 启动恢复 | 实现兼容\@system.device API接口能力。
主要涉及如下需求:
I56GBS 支持\@system.device相关API | NA |
+| 应用 | 联系人支持第三方应用调用系统通话能力,提供用户基础通信能力。
主要涉及如下需求:
I58ZQ4 联系人支持第三方应用调用系统通话能力 | NA |
### API变更
@@ -142,7 +146,7 @@ repo forall -c 'git lfs pull'
## 修复缺陷列表
-**表6** 修复缺陷ISSUE列表
+**表4** 修复缺陷ISSUE列表
| ISSUE单 | 问题描述 |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
@@ -153,7 +157,7 @@ repo forall -c 'git lfs pull'
## 遗留缺陷列表
-**表7** 遗留缺陷列表
+**表5** 遗留缺陷列表
| ISSUE | 问题描述 | 影响 | 计划解决日期 |
| ------------------------------------------------------------ | ---------------------------------------------------------- | ------------------------------------------------- | ------------ |