提交 dfcd5710 编写于 作者: J junyi233 提交者: Gitee

扫描缺陷修改

......@@ -78,9 +78,9 @@ The ability assistant is pre-installed in the device environment. You can direct
| -l/--mission-list | type (All logs are printed if this parameter is left unspecified.)| Prints mission stack information.<br>The following values are available for **type**:<br>- NORMAL <br>- DEFAULT_STANDARD<br>- DEFAULT_SINGLE<br>- LAUNCHER |
| -e/--extension | elementName | Prints extended component information. |
| -u/--userId | UserId | Prints stack information of a specified user ID. This parameter must be used together with other parameters.<br>Example commands: aa **dump -a -u 100** and **aa dump -d -u 100**|
| -d/--data | | Prints Data ability information. |
| -d/--data | - | Prints Data ability information. |
| -i/--ability | AbilityRecord ID | Prints detailed information about a specified ability. |
| -c/--client | | Prints detailed ability information. This parameter must be used together with other parameters.<br>Example commands: **aa dump -a -c** and **aa dump -i 21 -c**|
| -c/--client | - | Prints detailed ability information. This parameter must be used together with other parameters.<br>Example commands: **aa dump -a -c** and **aa dump -i 21 -c**|
**Method**
......
......@@ -132,7 +132,9 @@ You can also include **parameters** in the **want** parameter and set its value
);
```
### Starting a Remote Page Ability
>Note: This feature applies only to system applications, since the **getTrustedDeviceListSync** API of the **DeviceManager** class is open only to system applications.
>Note
>
>This feature applies only to system applications, since the **getTrustedDeviceListSync** API of the **DeviceManager** class is open only to system applications.
**Modules to Import**
......
......@@ -166,7 +166,7 @@ let connId = featureAbility.connectAbility(
);
```
When a Service ability is connected, the **onConnect()** callback is invoked and returns an **IRemoteObject** defining the proxy used for communicating with the Service ability. OpenHarmony provides a default implementation of the **IRemoteObject** interface. You can extend **rpc.RemoteObject** to implement your own class of **IRemoteObject**.
When a Service ability is connected, the **onConnect()** callback is invoked and returns an **IRemoteObject** defining the proxy used for communicating with the Service ability. OpenHarmony provides a default implementation of **IRemoteObject**. You can extend **rpc.RemoteObject** to implement your own class of **IRemoteObject**.
The following code snippet shows how the Service ability instance returns itself to the calling ability:
......
......@@ -119,7 +119,7 @@ The following table lists the APIs used for ability continuation. For details ab
```javascript
onContinue(wantParam : {[key: string]: any}) {
Logger.info("onContinue using distributedObject")
// Set the user input data into the want parameter.
// Set the user input data into want params.
wantParam["input"] = AppStorage.Get<string>('ContinueInput');
Logger.info(`onContinue input = ${wantParam["input"]}`);
return AbilityConstant.OnContinueResult.AGREE
......
......@@ -12,7 +12,8 @@ Basic concepts:
- Widget host: an application that displays the widget content and controls the position where the widget is displayed in the host application.
- Widget Manager: a resident agent that manages widgets added to the system and provides functions such as periodic widget update.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**
>
> The widget host and provider do not keep running all the time. The Widget Manager starts the widget provider to obtain widget information when a widget is added, deleted, or updated.
You only need to develop widget content as the widget provider. The system automatically handles the work done by the widget host and Widget Manager.
......@@ -254,7 +255,7 @@ Data of a temporary widget is not persistently stored. If it is deleted from the
### Updating Widget Data
When a widget application initiates a data update upon a scheduled or periodic update, the application obtains the latest data and calls **updateForm** to update the widget. The code snippet is as follows:
When a widget application initiates a data update upon a scheduled or periodic update, the application obtains the latest data and calls **updateForm** to update the widget. The sample code is as follows:
```javascript
onUpdate(formId) {
......
# Service Extension Ability Development
## When to Use
**ExtensionAbility** is the base class of the new Extension component in the stage model. It is used to process missions without UIs. The lifecycle of an Extension ability is simple and does not involve foreground or background. **ServiceExtensionAbility** is extended from **ExtensionAbility**.
**ExtensionAbility** is the base class of the new Extension component in the stage model. It is used to process missions without UIs. The lifecycle of an Extension ability is simple and does not involve foreground or background states. **ServiceExtensionAbility** is extended from **ExtensionAbility**.
You can customize a class that inherits from **ServiceExtensionAbility** and override the lifecycle callbacks in the base class to perform service logic operations during the initialization, connection, and disconnection processes.
## Available APIs
**Table 1** ServiceExtensionAbility lifecycle callbacks
**Table 1** ServiceExtensionAbility lifecycle APIs
|API|Description|
|:------|:------|
|onCreate|Called for the initialization when **startAbility** or **connectAbility** is invoked for a given ability for the first time.|
|onRequest|Called each time **startAbility** is invoked for a given ability. The initial value of **startId** is 1, and the value is incremented by one each time **startAbility** is invoked for that ability.|
|onConnect|Called when **connectAbility** is invoked for a given ability. This callback is not invoked for repeated calling of **connectAbility** for a specific ability. However, it will be invoked when **disconnectAbility** is called to disconnect an ability and then **connectAbility** is called to connect the ability again. The returned result is a **RemoteObject**.|
|onDisconnect|Called when **disconnectAbility** is called for a given ability. If the Extension ability is started by **connectAbility** and is not bound by other applications, the **onDestroy** callback will also be triggered to destroy the Extension ability.|
|onDestroy|Called when **terminateSelf** is invoked to terminate the ability.|
|onCreate(want: Want): void|Called for the initialization when **startAbility** or **connectAbility** is invoked for a given ability for the first time.|
|onRequest(want: Want, startId: number): void|Called each time **startAbility** is invoked for a given ability. The initial value of **startId** is **1**, and the value is incremented by one each time **startAbility** is invoked for that ability.|
|onConnect(want: Want): rpc.RemoteObject|Called when **connectAbility** is invoked for a given ability. This callback is not invoked for repeated calling of **connectAbility** for a specific ability. However, it will be invoked unless **connectAbility** is called after the ability has been disconnected using **disconnectAbility**. The returned result is a **RemoteObject**.|
|onDisconnect(want: Want): void|Called when **disconnectAbility** is called for a given ability. If the Extension ability is started by **connectAbility** and is not bound to other applications, the **onDestroy** callback will also be triggered to destroy the Extension ability.|
|onDestroy(): void|Called when **terminateSelf** is invoked to terminate the ability.|
## Constraints
- Currently, OpenHarmony does not support creation of a Service Extension ability for third-party applications.
OpenHarmony does not support creation of a Service Extension ability for third-party applications.
## How to Develop
1. Create a Service Extension ability.
Customize a class that inherits from **ServiceExtensionAbility** in the .ts file and override the lifecycle callbacks of the base class. The code sample is as follows:
2. Customize a class that inherits from **ServiceExtensionAbility** in the .ts file in the directory where the Service Extension ability is defined and override the lifecycle callbacks of the base class. The code sample is as follows:
```js
import rpc from '@ohos.rpc'
......@@ -61,9 +61,9 @@ Customize a class that inherits from **ServiceExtensionAbility** in the .ts file
2. Register the Service Extension ability.
Declare the Service Extension ability in the **module.json** file by setting its **type** attribute to **service**.
Declare the Service Extension ability in the **module.json** file by setting its **type** attribute to **service**.
**module.json configuration example**
**module.json configuration example**
```json
"extensionAbilities":[{
......@@ -76,9 +76,7 @@ Declare the Service Extension ability in the **module.json** file by setting its
}]
```
## Development Example
The following sample is provided to help you better understand how to develop a Service Extension ability:
- [`ServiceExtAbility`: Stage Extension Ability Creation and Usage (eTS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/ability/ServiceExtAbility)
## Samples
The following sample is provided to help you better understand how to develop Service Extension abilities:
- [`ServiceExtAbility`: Stage Extension Ability Creation and Usage (eTS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility)
# video
> **NOTE**<br>
> **NOTE**
>
> - This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version.
>
......@@ -15,7 +15,7 @@
> ]
> ```
The **\<Video>** component provides a video player.
The **\<video>** component provides a video player.
## Child Components
......@@ -76,7 +76,8 @@ In addition to the [universal methods](../arkui-js/js-components-common-methods.
| pause | - | Pauses a video.|
| setCurrentTime | {&nbsp;currenttime:&nbsp;value&nbsp;} | Sets the video playback position, in seconds.|
> **NOTE**<br>
> **NOTE**
>
> The methods in the above table can be called after the **attached** callback is invoked.
## Example
......@@ -89,7 +90,7 @@ In addition to the [universal methods](../arkui-js/js-components-common-methods.
onpaues='pauesCallback' onfinish='finishCallback' onerror='errorCallback'
onseeking='seekingCallback' onseeked='seekedCallback'
ontimeupdate='timeupdateCallback'
style="object-fit:fit; width:80%; height:400px;"
style="object-fit:fill; width:80%; height:400px;"
onclick="change_start_pause">
</video>
</div>
......
......@@ -54,7 +54,7 @@ ImageAnimator()
## Events
| Name | Description |
| -------- | -------- | -------- |
| -------- | -------- |
| onStart() =&gt; void | Triggered when the animation starts to play. |
| onPause() =&gt; void | Triggered when the animation playback is paused. |
| onRepeat() =&gt; void | Triggered when the animation playback is repeated. |
......
# Progress
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**
>
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
The **&lt;Progress&gt;** component is used to provide a progress bar that displays the progress of content loading or an operation.
The **\<Progress>** component is used to provide a progress bar that displays the progress of content loading or an operation.
## Required Permissions
......@@ -15,17 +16,17 @@ None
## Child Components
None
Not supported
## APIs
Progress(value: { value: number, total?: number, type?: ProgressType})
Progress(value: {value: number, total?: number, type?: ProgressType})
Creates a progress bar.
- Parameters
| Name | Type | Mandatory | Default Value | Description |
| Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- |
| value | number | Yes | - | Current progress. |
| total | number | No | 100 | Total progress. |
......@@ -33,7 +34,7 @@ Creates a progress bar.
- ProgressType enums
| Name | Description |
| Name | Description |
| -------- | -------- |
| Linear | Linear type. |
| Ring<sup>8+</sup> | Ring type without scale. The ring fills up as the progress increases. |
......@@ -54,7 +55,8 @@ Creates a progress bar.
## Example
```
```ts
// xxx.ets
@Entry
@Component
struct ProgressExample {
......@@ -88,8 +90,8 @@ struct ProgressExample {
Text('Capsule Progress').fontSize(9).fontColor(0xCCCCCC).width('90%')
Row({ space: 40 }) {
Progress({ value: 10, type: ProgressType.Capsule }).width(100)
Progress({ value: 20, total: 150, type: ProgressType.Capsule }).color(Color.Grey).value(50).width(100)
Progress({ value: 10, type: ProgressType.Capsule }).width(100).height(50)
Progress({ value: 20, total: 150, type: ProgressType.Capsule }).color(Color.Grey).value(50).width(100).height(50)
}
}.width('100%').margin({ top: 30 })
}
......
# TextArea
> **NOTE**<br>
> **NOTE**
>
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
......@@ -20,7 +21,7 @@ Not supported
## APIs
TextArea(value?:{placeholder?: string controller?: TextAreaController})
TextArea(value?:{placeholder?: string, controller?: TextAreaController})
- Parameters
| Name | Type | Mandatory | Default Value | Description |
......@@ -93,10 +94,11 @@ Sets the position of the caret.
@Entry
@Component
struct TextAreaExample1 {
controller: TextAreaController = new TextAreaController()
@State text: string = ''
build() {
Column() {
TextArea({ placeholder: 'input your word'})
TextArea({ placeholder: 'input your word', controller: this.controller})
.placeholderColor("rgb(0,0,225)")
.placeholderFont({ size: 30, weight: 100, family: 'cursive', style: FontStyle.Italic })
.textAlign(TextAlign.Center)
......@@ -112,6 +114,7 @@ struct TextAreaExample1 {
})
.onChange((value: string) => {
this.text = value
this.controller.caretPosition(-1)
})
Text(this.text).width('90%')
}
......
# TextInput
> **NOTE**<br/>
> **NOTE**
>
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
......@@ -39,9 +40,8 @@ In addition to universal attributes, the following attributes are supported.
| placeholderFont | {<br/>size?: Length,<br/>weight?: number\|[FontWeight](ts-universal-attributes-text-style.md),<br/>family?: string,<br/>style?: [FontStyle](ts-universal-attributes-text-style.md)<br/>} | - | Placeholder text style.<br/>- **size**: font size. If the value is of the number type, the unit fp is used.<br/>- **weight**: font weight. For the number type, the value ranges from 100 to 900, at an interval of 100. The default value is **400**. A larger value indicates a larger font weight.<br/>- **family**: font family. Use commas (,) to separate multiple fonts, for example, **'Arial, sans-serif'**. The priority of the fonts is the sequence in which they are placed.<br/>- **style**: font style. |
| enterKeyType | EnterKeyType | EnterKeyType.Done | How the Enter key is labeled. |
| caretColor | Color | - | Color of the caret (also known as the text insertion cursor). |
| maxLength<sup>8+</sup> | number | - | Maximum number of characters in the text input. |
| maxLength | number | - | Maximum number of characters in the text input. |
| inputFilter<sup>8+</sup> | {<br/>value: [ResourceStr](../../ui/ts-types.md)<sup>8+</sup>,<br/>error?: (value: string)<br/>} | - | Regular expression for input filtering. Only inputs that comply with the regular expression can be displayed. Other inputs are ignored. The specified regular expression can match single characters, but not strings. Example: ^(? =.\*\d)(? =.\*[a-z])(? =.\*[A-Z]).{8,10}$. Strong passwords containing 8 to 10 characters cannot be filtered.<br/>- **value**: regular expression to set.<br/>- **error**: error message containing the ignored content returned when regular expression matching fails. |
| copyOption<sup>9+</sup> | boolean\|[CopyOption](ts-basic-components-text.md) | true | Whether copy and paste is allowed. |
- EnterKeyType enums
| Name | Description |
......@@ -75,10 +75,10 @@ In addition to universal attributes, the following attributes are supported.
### TextInputController<sup>8+</sup>
Implements the controller of the **&lt;TextInput&gt;** component.
Implements the controller of the **\<TextInput>** 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)
......
......@@ -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**<br>
> **NOTE**<br>
>
> 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) | <p>Triggered to process an HTML form whose input type is **file**, in response to the tapping of the **Select File** button.<br>**result**: file selection result to be sent to the web component.<br>**fileSelector**: information about the file selector.</p> |
| onUrlLoadIntercept(callback: (event?: { data:string \| [WebResourceRequest](#webresourcerequest) }) => boolean) | <p>Triggered before the **\<Web>** component loads the URL to determine whether to block the access. The callback returns **true** if the access is blocked, and **false** otherwise.<br>**data**: URL information.</p> |
### 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 **\<Web>** component to indicate the user operation performed in the dialog box.
- APIs
| Name | Description |
| --------------------- | ----------------------- |
| handleCancel(): void | <p>The user's cancel operation in the dialog box.</p> |
| handleConfirm(): void | <p>The user's confirm operation in the dialog box.</p> |
| Name | Description |
| --------------------- | ----------------------- |
| handleCancel(): void | <p>The user's cancel operation in the dialog box.</p> |
| handleConfirm(): void | <p>The user's confirm operation in the dialog box.</p> |
### 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 **\<Web>** 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 **\<Web>** component of the file selection result.
- APIs
| Name | Description |
| ---------------------------------------------- | ------------------------------------------------------------ |
| handleFileList(fileList: Array\<string>): void | Instructs the **\<Web>** component to select a file.<br>**fileList**: list of files to operate. |
### FileSelectorParam
- APIs
| Name | Description |
| ---------------------------------------------- | ------------------------------------------------------------ |
| handleFileList(fileList: Array\<string>): void | Instructs the **\<Web>** component to select a file.<br>**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\<string\> | 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\<string\> | 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
......
# Navigator
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**
>
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
The **&lt;Navigator&gt;** component provides redirection.
The **\<Navigator>** 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 **&lt;Navigator&gt;** 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 **\<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. |
## 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 {
......
......@@ -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,<br/>mask?: GestureMask | gesture: -,<br/>mask: GestureMask.Normal | Gesture to recognize.<br/>**gesture** specifies the type of the gesture to bind, and **mask** specifies the event response setting. |
| priorityGesture | gesture: GestureType,<br/>mask?: GestureMask | gesture: -,<br/>mask: GestureMask.Normal | Gesture to preferentially recognize.<br/>**gesture** specifies the type of the gesture to bind, and **mask** specifies the event response setting.<br/>> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>> - 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,<br/>mask?: GestureMask | gesture: -,<br/>mask: GestureMask.Normal | Gesture that can be triggered together with the child component gesture.<br/>**gesture** specifies the type of the gesture to bind, and **mask** specifies the event response setting.<br/>> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>> - 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,<br/>mask?: GestureMask | gesture: -,<br/>mask: GestureMask.Normal | Gesture to recognize.<br/>- **gesture**: type of the gesture to bind.<br/>- **mask**: event response setting. |
| priorityGesture | gesture: GestureType,<br/>mask?: GestureMask | gesture: -,<br/>mask: GestureMask.Normal | Gesture to preferentially recognize.<br/>- **gesture**: type of the gesture to bind.<br/>- **mask**: event response setting.<br/>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,<br/>mask?: GestureMask | gesture: -,<br/>mask: GestureMask.Normal | Gesture that can be triggered together with the child component gesture.<br/>- **gesture**: type of the gesture to bind.<br/>- **mask**: event response setting.<br/>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.<br/>> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>> However, the built-in gestures of the child components are not masked. For example, when the child component is a **&lt;List&gt;** 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.<br/>However, the built-in gestures of the child components are not masked. For example, when the child component is a **&lt;List&gt;** 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) =&gt; void) | Callback invoked when a tap gesture is recognized. |
| onAction((event?: GestureEvent) =&gt; void) | Callback invoked when a tap gesture is recognized. |
- GestureEvent attributes
| Name | Type | Description |
| Name | Type | Description |
| -------- | -------- | -------- |
| timestamp | number | Timestamp of the event. |
| target<sup>8+</sup> | EventTarget | Object that triggers the gesture event. |
| timestamp | number | Timestamp of the event. |
| target<sup>8+</sup> | [EventTarget](ts-universal-events-click.md) | Object that triggers the gesture event. |
## Example
```ts
// xxx.ets
@Entry
@Component
struct GestureSettingsExample {
......
# Motion Path Animation
> ![icon-note.gif](public_sys-resources/icon-note.gif) **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 | {<br/>path: string,<br/>from?: number,<br/>to?: number,<br/>rotatable?: boolean<br/>}<br/>> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>> In a path, **start** and **end** can be used to replace the start point and end point. Example:<br/>> <br/>> 'Mstart.x start.y L50 50 Lend.x end.y Z' | {<br/>"",<br/>0.0,<br/>1.0,<br/>false<br/>} | Motion path of the component. The input parameters are described as follows:<br/>- **path**: motion path of the translation animation. The **svg** path string is used.<br/>- **from**: start point of the motion path. The default value is **0.0**.<br/>- **to**: end point of the motion path. The default value is **1.0**.<br/>- **rotatable**: whether to rotate along the path. |
| motionPath | {<br/>path: string,<br/>from?: number,<br/>to?: number,<br/>rotatable?: boolean<br/>}<br/>**NOTE**<br/>In a path, **start** and **end** can be used to replace the start point and end point. Example:<br/>'Mstart.x start.y L50 50 Lend.x end.y Z' | {<br/>"",<br/>0.0,<br/>1.0,<br/>false<br/>} | Motion path of the component. The input parameters are described as follows:<br/>- **path**: motion path of the translation animation. The **svg** path string is used.<br/>- **from**: start point of the motion path. The default value is **0.0**.<br/>- **to**: end point of the motion path. The default value is **1.0**.<br/>- **rotatable**: whether to rotate along the path. |
## Example
```
@Entry
@Component
......
# 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.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **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:<br/>- Click event: 10.<br/>- 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:<br>- **10**: click event.<br>- **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%')
}
}
```
......@@ -6,9 +6,9 @@ Based on the Hi3861 platform, the OpenHarmony WLAN module provides abundant peri
## Development<a name="section13857170163412"></a>
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<a name="section1949121910344"></a>
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<a name="fig20768175218527"></a>
**Figure 1** LED blinking<a name="fig20768175218527"></a>
![](figures/led-blinking.gif "led-blinking")
......@@ -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
......@@ -3,9 +3,13 @@
## 场景介绍
使用坐标描述一个位置,非常准确,但是并不直观,面向用户表达并不友好。
使用坐标描述一个位置,非常准确,但是并不直观,面向用户表达并不友好。系统向开发者提供了以下两种转化能力。
系统向开发者提供了地理编码转化能力(将地理描述转化为具体坐标),以及逆地理编码转化能力(将坐标转化为地理描述)。其中地理编码包含多个属性来描述位置,包括国家、行政区划、街道、门牌号、地址描述等等,这样的信息更便于用户理解。
- 地理编码转化:将地理描述转化为具体坐标。
- 逆地理编码转化能力:将坐标转化为地理描述。
其中地理编码包含多个属性来描述位置,包括国家、行政区划、街道、门牌号、地址描述等等,这样的信息更便于用户理解。
## 接口说明
......
# 传感器开发概述
OpenHarmony系统传感器是应用访问底层硬件传感器的一种设备抽象概念。开发者根据传感器提供的Sensor API,可以查询设备上的传感器,订阅传感器数据,并根据传感器数据定制相应的算法开发各类应用,比如指南针、运动健康、游戏等。
OpenHarmony系统传感器是应用访问底层硬件传感器的一种设备抽象概念。开发者根据传感器提供的[Sensor接口](../reference/apis/js-apis-sensor.md),可以查询设备上的传感器,订阅传感器数据,并根据传感器数据定制相应的算法开发各类应用,比如指南针、运动健康、游戏等。
传感器是指用于侦测环境中所发生事件或变化,并将此消息发送至其他电子设备(如中央处理器)的设备,通常由敏感组件和转换组件组成。传感器是实现物联网智能化的重要基石,为实现全场景智慧化战略,支撑“1+8+N”产品需求,需要构筑统一的传感器管理框架,达到为各产品/业务提供低时延、低功耗的感知数据的目的。下面为传感器列表:
......
......@@ -5,6 +5,8 @@
当设备需要设置不同的振动效果时,可以调用Vibrator模块,例如:设备的按键可以设置不同强度和不同时长的振动,闹钟和来电可以设置不同强度和时长的单次或周期振动。
详细的接口介绍请参考[Vibrator接口](../reference/apis/js-apis-vibrator.md)
## 接口说明
......
......@@ -12,18 +12,19 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
| 模块 | 接口名称 | 描述 |
| -------- | -------- | -------- |
| ohos.i18n | getSystemLanguage():&nbsp;string | 获取系统语言。 |
| ohos.i18n | getSystemRegion():&nbsp;string | 获取系统区域。 |
| ohos.i18n | getSystemLocale():&nbsp;string | 获取系统Locale。 |
| ohos.i18n | isRTL(locale:&nbsp;string):&nbsp;boolean<sup>7+</sup> | locale对应的语言是否为从右到左语言。 |
| ohos.i18n | is24HourClock():&nbsp;boolean<sup>7+</sup> | 获取当前系统时间是否采用24小时制 |
| ohos.i18n | getDisplayLanguage(language:&nbsp;string,&nbsp;locale:&nbsp;string,&nbsp;sentenceCase?:&nbsp;boolean):&nbsp;string | 获取语言的本地化表示。 |
| ohos.i18n | getDisplayCountry(country:&nbsp;string,&nbsp;locale:&nbsp;string,&nbsp;sentenceCase?:&nbsp;boolean):&nbsp;string | 获取国家的本地化表示。 |
| ohos.i18n | getSystemLanguage():string | 获取系统语言。 |
| ohos.i18n | getSystemRegion():string | 获取系统区域。 |
| ohos.i18n | getSystemLocale():string | 获取系统Locale。 |
| ohos.i18n | isRTL(locale:string):boolean<sup>7+</sup> | locale对应的语言是否为从右到左语言。 |
| ohos.i18n | is24HourClock():boolean<sup>7+</sup> | 获取当前系统时间是否采用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:&nbsp;string,&nbsp;type?:&nbsp;string):&nbsp;Calendar<sup>8+</sup> | 获取指定locale和type的日历对象。 |
| ohos.i18n | setTime(date:&nbsp;Date): void<sup>8+</sup> | 设置日历对象内部的时间日期。 |
| ohos.i18n | setTime(time:&nbsp;number): void<sup>8+</sup> | 设置日历对象内部的时间日期。 |
| ohos.i18n | set(year:&nbsp;number,&nbsp;month:&nbsp;number,&nbsp;date:&nbsp;number,&nbsp;hour?:&nbsp;number,&nbsp;minute?:&nbsp;number,&nbsp;second?:&nbsp;number): void<sup>8+</sup> | 设置日历对象的年、月、日、时、分、秒。 |
| ohos.i18n | setTimeZone(timezone:&nbsp;string): void<sup>8+</sup> | 设置日历对象的时区。 |
| ohos.i18n | getTimeZone():&nbsp;string<sup>8+</sup> | 获取日历对象的时区。 |
| ohos.i18n | getFirstDayOfWeek():&nbsp;number<sup>8+</sup> | 获取日历对象的一周起始日。 |
| ohos.i18n | setFirstDayOfWeek(value:&nbsp;number): void<sup>8+</sup> | 设置日历对象的一周起始日。 |
| ohos.i18n | getMinimalDaysInFirstWeek():&nbsp;number<sup>8+</sup> | 获取一年中第一周的最小天数。 |
| ohos.i18n | setMinimalDaysInFirstWeek(value:&nbsp;number): void<sup>8+</sup> | 设置一年中第一周的最小天数。 |
| ohos.i18n | getDisplayName(locale:&nbsp;string):&nbsp;string<sup>8+</sup> | 获取日历对象的本地化表示。 |
| ohos.i18n | isWeekend(date?:&nbsp;Date):&nbsp;boolean<sup>8+</sup> | 判断给定的日期是否在日历中是周末。 |
| ohos.i18n | getCalendar(locale:string,type?:string):Calendar<sup>8+</sup> | 获取指定locale和type的日历对象。 |
| ohos.i18n | setTime(date:Date): void<sup>8+</sup> | 设置日历对象内部的时间日期。 |
| ohos.i18n | setTime(time:number): void<sup>8+</sup> | 设置日历对象内部的时间日期。 |
| ohos.i18n | set(year:number,month:number,date:number,hour?:number,minute?:number,second?:number): void<sup>8+</sup> | 设置日历对象的年、月、日、时、分、秒。 |
| ohos.i18n | setTimeZone(timezone:string): void<sup>8+</sup> | 设置日历对象的时区。 |
| ohos.i18n | getTimeZone():string<sup>8+</sup> | 获取日历对象的时区。 |
| ohos.i18n | getFirstDayOfWeek():number<sup>8+</sup> | 获取日历对象的一周起始日。 |
| ohos.i18n | setFirstDayOfWeek(value:number): void<sup>8+</sup> | 设置日历对象的一周起始日。 |
| ohos.i18n | getMinimalDaysInFirstWeek():number<sup>8+</sup> | 获取一年中第一周的最小天数。 |
| ohos.i18n | setMinimalDaysInFirstWeek(value:number): void<sup>8+</sup> | 设置一年中第一周的最小天数。 |
| ohos.i18n | getDisplayName(locale:string):string<sup>8+</sup> | 获取日历对象的本地化表示。 |
| ohos.i18n | isWeekend(date?:Date):boolean<sup>8+</sup> | 判断给定的日期是否在日历中是周末。 |
### 开发步骤
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:&nbsp;string,&nbsp;options?:&nbsp;PhoneNumberFormatOptions)<sup>8+</sup> | 实例化PhoneNumberFormat对象。 |
| ohos.i18n | isValidNumber(number:&nbsp;string):&nbsp;boolean<sup>8+</sup> | 判断number是否是一个格式正确的电话号码。 |
| ohos.i18n | format(number:&nbsp;string):&nbsp;string<sup>8+</sup> | 对number按照指定国家及风格进行格式化。 |
| ohos.i18n | constructor(country:string,options?:PhoneNumberFormatOptions)<sup>8+</sup> | 实例化PhoneNumberFormat对象。 |
| ohos.i18n | isValidNumber(number:string):boolean<sup>8+</sup> | 判断number是否是一个格式正确的电话号码。 |
| ohos.i18n | format(number:string):string<sup>8+</sup> | 对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:&nbsp;UnitInfo,&nbsp;toUnit:&nbsp;UnitInfo,&nbsp;value:&nbsp;number,&nbsp;locale:&nbsp;string,&nbsp;style?:&nbsp;string):&nbsp;string<sup>8+</sup> | 将fromUnit的单位转换为toUnit的单位,并根据区域与风格进行格式化。 |
| ohos.i18n | unitConvert(fromUnit:UnitInfo,toUnit:UnitInfo,value:number,locale:string,style?:string):string<sup>8+</sup> | 将fromUnit的单位转换为toUnit的单位,并根据区域与风格进行格式化。 |
### 开发步骤
1. 度量衡单位转换
1. 度量衡单位转换。
调用[unitConvert](../reference/apis/js-apis-intl.md)方法实现度量衡单位转换,并进行格式化显示的功能。
......@@ -251,15 +268,16 @@ I18n开发指导提供了未在ECMA 402中定义的国际化能力接口的使
| 模块 | 接口名称 | 描述 |
| -------- | -------- | -------- |
| ohos.i18n | getInstance(locale?:&nbsp;string):&nbsp;IndexUtil<sup>8+</sup> | 实例化字母表索引对象。 |
| ohos.i18n | getIndexList():&nbsp;Array&lt;string&gt;<sup>8+</sup> | 获取当前Locale的索引列表。 |
| ohos.i18n | addLocale(locale:&nbsp;string): void<sup>8+</sup> | 将新的Locale对应的索引加入当前索引列表。 |
| ohos.i18n | getIndex(text:&nbsp;string):&nbsp;string<sup>8+</sup> | 获取text对应的索引。 |
| ohos.i18n | getInstance(locale?:string):IndexUtil<sup>8+</sup> | 实例化字母表索引对象。 |
| ohos.i18n | getIndexList():Array&lt;string&gt;<sup>8+</sup> | 获取当前Locale的索引列表。 |
| ohos.i18n | addLocale(locale:string): void<sup>8+</sup> | 将新的Locale对应的索引加入当前索引列表。 |
| ohos.i18n | getIndex(text:string):string<sup>8+</sup> | 获取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:&nbsp;string):&nbsp;BreakIterator<sup>8+</sup> | 实例化断行对象。 |
| ohos.i18n | setLineBreakText(text:&nbsp;string): void<sup>8+</sup> | 设置要处理的文本。 |
| ohos.i18n | getLineBreakText():&nbsp;string<sup>8+</sup> | 获取要处理的文本。 |
| ohos.i18n | current():&nbsp;number<sup>8+</sup> | 获取当前断行对象在处理文本的位置。 |
| ohos.i18n | first():&nbsp;number<sup>8+</sup> | 将断行对象设置到第一个可断句的分割点。 |
| ohos.i18n | last():&nbsp;number<sup>8+</sup> | 将断行对象设置到最后一个可断句的分割点。 |
| ohos.i18n | next(index?:&nbsp;number):&nbsp;number<sup>8+</sup> | 将断行对象移动index个分割点的位置。 |
| ohos.i18n | previous():&nbsp;number<sup>8+</sup> | 将断行对象移动到前一个分割点的位置。 |
| ohos.i18n | following(offset:&nbsp;number):&nbsp;number<sup>8+</sup> | 将断行对象移动到offset指定位置的后面一个分割点的位置。 |
| ohos.i18n | isBoundary(offset:&nbsp;number):&nbsp;boolean<sup>8+</sup> | 判断某个位置是否是分割点。 |
| ohos.i18n | getLineInstance(locale:string):BreakIterator<sup>8+</sup> | 实例化断行对象。 |
| ohos.i18n | setLineBreakText(text:string): void<sup>8+</sup> | 设置要处理的文本。 |
| ohos.i18n | getLineBreakText():string<sup>8+</sup> | 获取要处理的文本。 |
| ohos.i18n | current():number<sup>8+</sup> | 获取当前断行对象在处理文本的位置。 |
| ohos.i18n | first():number<sup>8+</sup> | 将断行对象设置到第一个可断句的分割点。 |
| ohos.i18n | last():number<sup>8+</sup> | 将断行对象设置到最后一个可断句的分割点。 |
| ohos.i18n | next(index?:number):number<sup>8+</sup> | 将断行对象移动index个分割点的位置。 |
| ohos.i18n | previous():number<sup>8+</sup> | 将断行对象移动到前一个分割点的位置。 |
| ohos.i18n | following(offset:number):number<sup>8+</sup> | 将断行对象移动到offset指定位置的后面一个分割点的位置。 |
| ohos.i18n | isBoundary(offset:number):boolean<sup>8+</sup> | 判断某个位置是否是分割点。 |
### 开发步骤
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,并且将断行对象移动到该位置后的一个分割点。
......
......@@ -20,7 +20,7 @@ resources
| | |---string.json
| |---media
| | |---icon.png
|---rawfile // 默认存在的目录
|---rawfile
```
**表1** resources目录分类
......
......@@ -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&nbsp;信息。 |
| 类型 | 说明 |
| -------- | -------- |
| Context | 当前Context&nbsp;信息。 |
**示例:**
```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
# Context
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明**
>
> 本模块首批接口从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&nbsp;信息。 |
**示例:**
```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
# 配置策略
配置策略提供按预先定义的定制配置层级获取对应定制配置目录和文件路径的能力。
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
> 本模块接口均为系统接口,三方应用不支持调用。
配置策略提供按预先定义的定制配置层级获取对应定制配置目录和文件路径的能力。
## 导入模块
```js
......@@ -16,10 +16,10 @@ import configPolicy from '@ohos.configPolicy';
## getOneCfgFile
getOneCfgFile(relPath: string, callback: AsyncCallback&lt;string&gt;): void
getOneCfgFile(relPath: string, callback: AsyncCallback&lt;string&gt;)
使用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&lt;string&gt;): 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&lt;string&gt;
**示例:**
```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&lt;string&gt;
## getCfgFiles
getCfgFiles(relPath: string, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
getCfgFiles(relPath: string, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;)
按优先级从低到高,使用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&lt;Array&lt;string&gt;&gt;)
**示例:**
```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&lt;Array&lt;string&gt;&gt;
**示例:**
```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&lt;Array&lt;string&gt;&gt;
## getCfgDirList
getCfgDirList(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
getCfgDirList(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;)
使用callback形式返回配置层级目录列表。
......
......@@ -46,10 +46,10 @@ isIdleState(bundleName: string, callback: AsyncCallback&lt;boolean&gt;): 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&lt;boolean&gt;
**示例**
```
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&lt;number&gt;): 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&lt;number&gt;
**示例**
```
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&lt;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&lt;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&lt;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&lt;Array&lt;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&lt;Array&lt;
**示例**
```
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);
});
```
......
......@@ -12,28 +12,28 @@ import document from '@ohos.document';
## document.choose
choose(types:string[]): Promise&lt;string&gt;
choose(types? : string[]): Promise&lt;string&gt;
通过文件管理器选择文件,异步返回文件URI,使用promise形式返回结果。
**系统能力**:SystemCapability.FileManagement.UserFileService
- 参数:
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ---------------------------- |
| types | string[] | 否 | 限定文件选择的类型 |
- 返回值:
**返回值:**
| 类型 | 说明 |
| --------------------- | -------------- |
| Promise&lt;string&gt; | 异步返回文件URI(注:当前返回错误码) |
- 示例:
**示例:**
```js
let tpyes = [];
let types = [];
document.choose(types);
```
## document.choose
......@@ -44,13 +44,13 @@ choose(callback:AsyncCallback&lt;string&gt;): void
**系统能力**:SystemCapability.FileManagement.UserFileService
- 参数:
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ---------------------------- |
| callback | AsyncCallback&lt;string&gt; | 是 | 异步获取对应文件URI(注:当前返回错误码) |
- 示例:
**示例:**
```js
let uri = "";
......@@ -66,14 +66,14 @@ choose(types:string[], callback:AsyncCallback&lt;string&gt;): void
**系统能力**:SystemCapability.FileManagement.UserFileService
- 参数:
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ---------------------------- |
| types | string[] | 否 | 限定选择文件的类型 |
| callback | AsyncCallback&lt;string&gt; | 是 | 异步获取对应文件URI(注:当前返回错误码) |
- 示例:
**示例:**
```js
let types = [];
......@@ -91,20 +91,20 @@ show(uri:string, type:string):Promise&lt;void&gt;
**系统能力**:SystemCapability.FileManagement.UserFileService
- 参数:
**参数:**
| 参数 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ---------------------------- |
| uri | string | 是 | 待打开的文件URI |
| type | string | 是 | 待打开文件的类型 |
- 返回值:
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------ |
| Promise&lt;void&gt; | Promise回调返回void表示成功打开文件(注:当前返回错误码) |
- 示例:
**示例:**
```js
let type = "";
......@@ -120,7 +120,7 @@ show(uri:string, type:string, callback:AsyncCallback&lt;void&gt;): void
**系统能力**:SystemCapability.FileManagement.UserFileService
- 参数:
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ---------------------------- |
......@@ -128,7 +128,7 @@ show(uri:string, type:string, callback:AsyncCallback&lt;void&gt;): void
| type | string | 是 | 待打开文件的类型 |
| callback | AsyncCallback&lt;void&gt; | 是 | 异步打开uri对应文件(注:当前返回错误码) |
- 示例:
**示例:**
```js
let type = "";
......
# 目录环境能力
该模块提供环境目录能力,获取内存存储根目录、公共文件根目录的JS接口。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
>
> - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - 本模块接口为系统接口,三方应用不支持调用。
该模块提供环境目录能力,获取内存存储根目录、公共文件根目录的JS接口。
## 导入模块
```js
......
# 文件管理
该模块提供文件存储管理能力,包括文件基本管理、文件目录管理、文件信息统计、文件流式读写等常用功能。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从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&lt;number&gt;
```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&lt;string&gt;): 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&lt;Stat&gt;
**示例:**
```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&lt;void&gt
**示例:**
```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&lt;Stream&gt;):
**示例:**
```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&lt;Stream&gt;
**示例:**
```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&lt;Stream&gt;): 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&lt;void&gt;
**示例:**
```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&lt;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&lt;void&gt;
**示例:**
```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&lt;void&gt;): 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");
})
```
## Stream<sup>7+</sup>
## Stream
文件流,在调用Stream的方法前,需要先通过createStream()方法(同步或异步)来构建一个Stream实例。
......@@ -2600,7 +2615,7 @@ close(): Promise&lt;void&gt;
**示例:**
```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&lt;void&gt;): 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&lt;void&gt;
**示例:**
```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&lt;void&gt;): 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});
```
......
# 公共文件访问与管理
该模块提供公共文件访问和管理的服务接口,向下对接底层文件管理服务,如媒体库、外卡管理;向上对应用程序提供公共文件查询、创建的能力。
>![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
>
>- 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>- 本模块接口为系统接口,三方应用不支持调用,当前只支持filepicker调用。
该模块提供公共文件访问和管理的服务接口,向下对接底层文件管理服务,如媒体库、外卡管理;向上对应用程序提供公共文件查询、创建的能力。
## 导入模块
```js
......@@ -20,18 +21,18 @@ getRoot(options? : {dev? : DevInfo}) : Promise&lt;FileInfo[]&gt;
**系统能力**:SystemCapability.FileManagement.UserFileService
- 参数
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | -- |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local' |
- 返回值
**返回值:**
| 类型 | 说明 |
| --- | -- |
| Promise&lt;[FileInfo](#fileinfo)[]&gt; | 第一层目录相册信息 |
- 示例
**示例:**
```js
filemanager.getRoot().then((fileInfo) => {
......@@ -53,22 +54,22 @@ getRoot(options? : {dev? : DevInfo}, callback : AsyncCallback&lt;FileInfo[]&gt;)
**系统能力**:SystemCapability.FileManagement.UserFileService
- 参数
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ----------------------------- |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local' |
| callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | 是 | 异步获取文件的信息之后的回调 |
- 示例
**示例:**
```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 | 否 | 支持如下选项:<br/>-&nbsp;dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local'。<br/>-&nbsp;offset,number类型,待查询文件偏移个数。<br/>-&nbsp;count,number类型,待查询文件个数。 |
- 返回值
**返回值:**
| 类型 | 说明 |
| --- | -- |
| Promise&lt;FileInfo[]&gt; | 文件信息 |
- 异常
**异常:**
| 错误名称 | 错误类型 | 错误码 |说明 |
| --- | -- | --- | -- |
| 对应的目录、相册不存在 | 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 | 否 | 支持如下选项:<br/>-&nbsp;dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local'。<br/>-&nbsp;offset,number类型,待查询文件偏移个数。<br/>-&nbsp;count,number类型,待查询文件个数。 |
| callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | 是 | 异步获取文件的信息之后的回调 |
- 异常
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| path | string | 是 | 待查询目录uri |
| type | string | 是 | 待查询文件类型, 支持以下类型 "file", "image", "audio", "video" |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local'。<br/>-&nbsp;offset,number类型,待查询文件偏移个数。<br/>-&nbsp;count,number类型,待查询文件个数。 |
| callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | 是 | 异步获取文件的信息之后的回调 |
| 错误名称 | 错误类型 | 错误码 | 说明 |
| ------------------------- | ------------------------- | ------ | ------------------------- |
| 对应的目录、相册不存在 | 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 | 否 | 支持如下选项:<br/>-&nbsp;dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local' |
- 返回值
**返回值:**
| 类型 | 说明 |
| --- | -- |
| string | 文件uri |
| 类型 | 说明 |
| --- | -- |
| Promise&lt;string&gt; | 文件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 | 否 | 支持如下选项:<br/>-&nbsp;dev,[DevInfo](#devinfo)类型,不填默认dev = {name: "local"}, 当前仅支持设备'local' |
| callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | 是 | 异步获取文件的信息之后的回调 |
- 异常
**异常:**
| 错误名称 | 错误类型 | 错误码 | 说明 |
| ------------------------- | ------------------------- | ------ | ------------------------- |
......@@ -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);
});
});
```
......
# 数据标签
该模块提供文件数据安全等级的相关功能:向应用程序提供查询、设置文件数据安全等级的JS接口。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
该模块提供文件数据安全等级的相关功能:向应用程序提供查询、设置文件数据安全等级的JS接口。
## 导入模块
```js
......
# statfs
该模块提供文件系统相关存储信息的功能,向应用程序提供获取文件系统总字节数、空闲字节数的JS接口。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
该模块提供文件系统相关存储信息的功能,向应用程序提供获取文件系统总字节数、空闲字节数的JS接口。
## 导入模块
```js
......
# USB管理
本模块主要提供管理USB设备的相关功能,包括查询USB设备列表、批量数据传输、控制命令传输、权限控制等。
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
......
# 卷管理
该模块提供卷、磁盘查询和管理的相关功能:包括查询卷信息,对卷的挂载卸载、对磁盘分区以及卷的格式化等功能。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
>
> - 本模块首批接口从API version 9开始支持。
> - API 9当前为Canary版本,仅供试用,不保证接口可稳定调用。
> - 本模块接口为系统接口,三方应用不支持调用。
该模块提供卷、磁盘查询和管理的相关功能:包括查询卷信息,对卷的挂载卸载、对磁盘分区以及卷的格式化等功能。
## 导入模块
```js
......@@ -24,13 +24,13 @@ getAllVolumes(): Promise&lt;Array&lt;Volume&gt;&gt;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
- 返回值
**返回值:**
| 类型 | 说明 |
| ---------------------------------- | -------------------------- |
| Promise&lt;[Volume](#volume)[]&gt; | 返回当前所有可获得的卷信息 |
- 示例
**示例:**
```js
volumemanager.getAllVolumes().then(function(volumes){
......@@ -48,13 +48,13 @@ getAllVolumes(callback: AsyncCallback&lt;Array&lt;Volume&gt;&gt;): void
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
- 参数
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------- | ---- | ------------------------------------ |
| callback | callback:AsyncCallback&lt;[Volume](#volume)[]&gt; | 是 | 获取当前所有可获得的卷信息之后的回调 |
- 示例
**示例:**
```js
let uuid = "";
......@@ -74,19 +74,19 @@ mount(volumeId: string): Promise&lt;boolean&gt;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
- 参数
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---- |
| volumeId | string | 是 | 卷id |
- 返回值
**返回值:**
| 类型 | 说明 |
| ---------------------- | ---------- |
| Promise&lt;boolean&gt; | 挂载指定卷 |
- 示例
**示例:**
```js
let volumeId = "";
......@@ -105,14 +105,14 @@ mount(volumeId: string, callback:AsyncCallback&lt;boolean&gt;):void
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
- 参数
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------- | ---- | -------------------- |
| volumeId | string | 是 | 卷id |
| callback | callback:AsyncCallback&lt;boolean&gt; | 是 | 挂载指定卷之后的回调 |
- 示例
**示例:**
```js
let volumeId = "";
......@@ -131,19 +131,19 @@ unmount(volumeId: string): Promise&lt;boolean&gt;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
- 参数
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---- |
| volumeId | string | 是 | 卷id |
- 返回值
**返回值:**
| 类型 | 说明 |
| ---------------------- | ---------- |
| Promise&lt;boolean&gt; | 卸载指定卷 |
- 示例
**示例:**
```js
let volumeId = "";
......@@ -162,14 +162,14 @@ unmount(volumeId: string, callback:AsyncCallback&lt;boolean&gt;):void
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
- 参数
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------- | ---- | -------------------- |
| volumeId | string | 是 | 卷id |
| callback | callback:AsyncCallback&lt;boolean&gt; | 是 | 卸载指定卷之后的回调 |
- 示例
**示例:**
```js
let volumeId = "";
......@@ -180,7 +180,7 @@ unmount(volumeId: string, callback:AsyncCallback&lt;boolean&gt;):void
## volumemanager.getVolumeByUuid
getVolumeByUuid(uuid: string): Promise<Volume>;
getVolumeByUuid(uuid: string): Promise&lt;Volume&gt;
异步通过uuid获得卷信息,以promise方式返回。
......@@ -188,19 +188,19 @@ getVolumeByUuid(uuid: string): Promise<Volume>;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
- 参数
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---- |
| uuid | string | 是 | 卷uuid |
- 返回值
**返回值:**
| 类型 | 说明 |
| ---------------------------------- | -------------------------- |
| Promise&lt;[Volume](#volume)&gt; | 返回当前所有可获得的卷信息 |
- 示例
**示例:**
```js
let uuid = "";
......@@ -209,7 +209,7 @@ getVolumeByUuid(uuid: string): Promise<Volume>;
## volumemanager.getVolumeByUuid
getVolumeByUuid(uuid: string, callback: AsyncCallback<Volume>): void;
getVolumeByUuid(uuid: string, callback: AsyncCallback&lt;Volume&gt;): void
异步通过uuid获得卷信息,以callback方式返回。
......@@ -217,14 +217,14 @@ getVolumeByUuid(uuid: string, callback: AsyncCallback<Volume>): void;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
- 参数
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------ | ---- | -------------------- |
| uuid | string | 是 | 卷uuid |
| callback | callback:AsyncCallback&lt;[Volume](#volume)&gt; | 是 | 获取卷信息之后的回调 |
- 示例
**示例:**
```js
let uuid = "";
......@@ -235,7 +235,7 @@ getVolumeByUuid(uuid: string, callback: AsyncCallback<Volume>): void;
## volumemanager.getVolumeById
getVolumeById(id: string): Promise<Volume>;
getVolumeById(id: string): Promise&lt;Volume&gt;
异步通过卷id获得卷信息,以promise方式返回。
......@@ -243,19 +243,19 @@ getVolumeById(id: string): Promise<Volume>;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
- 参数
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---- |
| id | string | 是 | 卷id |
- 返回值
**返回值:**
| 类型 | 说明 |
| ---------------------------------- | -------------------------- |
| Promise&lt;[Volume](#volume)&gt; | 返回当前所有可获得的卷信息 |
- 示例
**示例:**
```js
let id = "";
......@@ -264,7 +264,7 @@ getVolumeById(id: string): Promise<Volume>;
## volumemanager.getVolumeById
getVolumeById(id: string, callback: AsyncCallback<Volume>): void;
getVolumeById(id: string, callback: AsyncCallback&lt;Volume&gt;): void
异步通过卷id获得卷信息,以callback方式返回。
......@@ -272,14 +272,14 @@ getVolumeById(id: string, callback: AsyncCallback<Volume>): void;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
- 参数
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------ | ---- | -------------------- |
| id | string | 是 | 卷id |
| callback | callback:AsyncCallback&lt;[Volume](#volume)&gt; | 是 | 获取卷信息之后的回调 |
- 示例
**示例:**
```js
let id = "";
......@@ -290,7 +290,7 @@ getVolumeById(id: string, callback: AsyncCallback<Volume>): void;
## volumemanager.setVolumeDescription
setVolumeDescription(uuid: string, description: string): Promise<void>;
setVolumeDescription(uuid: string, description: string): Promise&lt;void&gt;
异步通过uuid设置卷描述,以promise方式返回。
......@@ -298,20 +298,20 @@ setVolumeDescription(uuid: string, description: string): Promise<void>;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
- 参数
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | ---- |
| uuid | string | 是 | 卷uuid |
| description | string | 是 | 卷描述 |
- 返回值
**返回值:**
| 类型 | 说明 |
| ---------------------- | -------------------------- |
| Promise&lt;void&gt; | 设置卷信息 |
- 示例
**示例:**
```js
let uuid = "";
......@@ -321,7 +321,7 @@ setVolumeDescription(uuid: string, description: string): Promise<void>;
## volumemanager.setVolumeDescription
function setVolumeDescription(uuid: string, description: string, callback: AsyncCallback<void>): void;
setVolumeDescription(uuid: string, description: string, callback: AsyncCallback&lt;void&gt;): 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&lt;void&gt; | 是 | 设置卷描述之后的回调 |
- 示例
**示例:**
```js
let uuid = "";
......@@ -349,7 +349,7 @@ function setVolumeDescription(uuid: string, description: string, callback: Async
## volumemanager.format
format(volId: string): Promise<void>;
format(volId: string): Promise&lt;void&gt;
异步对指定卷进行格式化,以promise方式返回。
......@@ -357,19 +357,19 @@ format(volId: string): Promise<void>;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
- 参数
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | ---- |
| volId | string | 是 | 卷id |
- 返回值
**返回值:**
| 类型 | 说明 |
| --------------------- | ----------------------- |
| Promise&lt;void&gt; | 对指定卷进行格式化 |
- 示例
**示例:**
```js
let volId = "";
......@@ -378,7 +378,7 @@ format(volId: string): Promise<void>;
## volumemanager.format
format(volId: string, callback: AsyncCallback<void>): void;
format(volId: string, callback: AsyncCallback&lt;void&gt;): void
异步对指定卷进行格式化,以callback方式返回。
......@@ -386,14 +386,14 @@ format(volId: string, callback: AsyncCallback<void>): void;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
- 参数
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------- | ---- | ---------------- |
| volId | string | 是 | 卷id |
| callback | callback:AsyncCallback&lt;void&gt; | 是 | 对指定卷进行格式化 |
- 示例
**示例:**
```js
let volId = "";
......@@ -404,7 +404,7 @@ format(volId: string, callback: AsyncCallback<void>): void;
## volumemanager.partition
partition(volId: string, fstype: string): Promise<void>;
partition(volId: string, fstype: string): Promise&lt;void&gt;
异步对磁盘进行分区,以promise方式返回。
......@@ -412,20 +412,20 @@ partition(volId: string, fstype: string): Promise<void>;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
- 参数
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | ---- |
| volId | string | 是 | 卷所属的磁盘id |
| fstype | string | 是 | 分区类型 |
- 返回值
**返回值:**
| 类型 | 说明 |
| --------------------- | ----------------------- |
| Promise&lt;void&gt; | 对磁盘进行分区 |
- 示例
**示例:**
```js
let volId = "";
......@@ -435,7 +435,7 @@ partition(volId: string, fstype: string): Promise<void>;
## volumemanager.partition
partition(volId: string, fstype : string, callback: AsyncCallback<void>): void;
partition(volId: string, fstype : string, callback: AsyncCallback&lt;void&gt;): void
异步对磁盘进行分区,以callback方式返回。
......@@ -443,9 +443,7 @@ partition(volId: string, fstype : string, callback: AsyncCallback<void>): void;
**系统能力**:SystemCapability.FileManagement.StorageService.Volume
- 参数
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------- | ---- | ---------------- |
......@@ -453,7 +451,7 @@ partition(volId: string, fstype : string, callback: AsyncCallback<void>): void;
| fstype | string | 是 | 分区类型 |
| callback | callback:AsyncCallback&lt;void&gt; | 是 | 对磁盘进行分区 |
- 示例
**示例:**
```js
let volId = "";
......
# 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/)
## 调用方式
......
# 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/)
## 调用方式
......
......@@ -33,10 +33,10 @@ Image(src: string | PixelMap | Resource)
| -------- | -------- | -------- | -------- |
| alt | string | - | 加载时显示的占位图。支持本地图片和网络路径。 |
| objectFit | ImageFit | Cover | 设置图片的缩放类型。 |
| objectRepeat | [ImageRepeat](ts-appendix-enums.md#imagerepeat枚举说明) | NoRepeat | 设置图片的重复样式。<br/>>&nbsp;![icon-note.gif](public_sys-resources/icon-note.gif)&nbsp;**说明:**<br/>>&nbsp;-&nbsp;SVG类型图源不支持该属性。 |
| interpolation | ImageInterpolation | None | 设置图片的插值效果,仅针对图片放大插值。<br/>>&nbsp;![icon-note.gif](public_sys-resources/icon-note.gif)&nbsp;**说明:**<br/>>&nbsp;-&nbsp;SVG类型图源不支持该属性。<br/>>&nbsp;<br/>>&nbsp;-&nbsp;PixelMap资源不支持该属性。 |
| renderMode | ImageRenderMode | Original | 设置图片渲染的模式。<br/>>&nbsp;![icon-note.gif](public_sys-resources/icon-note.gif)&nbsp;**说明:**<br/>>&nbsp;-&nbsp;SVG类型图源不支持该属性。 |
| sourceSize | {<br/>width:&nbsp;number,<br/>height:&nbsp;number<br/>} | - | 设置图片解码尺寸,将原始图片解码成指定尺寸的图片,number类型单位为px。<br/>>&nbsp;![icon-note.gif](public_sys-resources/icon-note.gif)&nbsp;**说明:**<br/>>&nbsp;PixelMap资源不支持该属性。 |
| objectRepeat | [ImageRepeat](ts-appendix-enums.md#imagerepeat枚举说明) | NoRepeat | 设置图片的重复样式。<br/>>&nbsp;![icon-note.gif](public_sys-resources/icon-note.gif)&nbsp;**说明:**<br/>>&nbsp;-&nbsp;svg类型图源不支持该属性。 |
| interpolation | ImageInterpolation | None | 设置图片的插值效果,仅针对图片放大插值。<br/>>&nbsp;![icon-note.gif](public_sys-resources/icon-note.gif)&nbsp;**说明:**<br/>>&nbsp;-&nbsp;svg类型图源不支持该属性。<br/>>&nbsp;-&nbsp;PixelMap资源不支持该属性。 |
| renderMode | ImageRenderMode | Original | 设置图片渲染的模式。<br/>>&nbsp;![icon-note.gif](public_sys-resources/icon-note.gif)&nbsp;**说明:**<br/>>&nbsp;-&nbsp;svg类型图源不支持该属性。 |
| sourceSize | {<br/>width:&nbsp;number,<br/>height:&nbsp;number<br/>} | - | 设置图片解码尺寸,将原始图片解码成指定尺寸的图片,number类型单位为px。<br/>>&nbsp;![icon-note.gif](public_sys-resources/icon-note.gif)&nbsp;**说明:**<br/>>&nbsp;-&nbsp;PixelMap资源不支持该属性。 |
| syncLoad<sup>8+</sup> | boolean | false | 设置是否同步加载图片,默认是异步加载。同步加载时阻塞UI线程,不会显示占位图。 |
- ImageFit枚举说明
......
......@@ -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。<br/>-&nbsp;0表示下拉刷新容器不跟随手势下拉而下拉。<br/>-&nbsp;100表示下拉刷新容器紧紧跟随手势下拉而下拉。<br/>-&nbsp;数值越大,下拉刷新容器跟随手势下拉的反应越灵敏。 |
| friction | number&nbsp;\|&nbsp;string | 否 | 62 | 下拉摩擦系数,取值范围为0到100。<br/>-&nbsp;0表示下拉刷新容器不跟随手势下拉而下拉。<br/>-&nbsp;100表示下拉刷新容器紧紧跟随手势下拉而下拉。<br/>-&nbsp;数值越大,下拉刷新容器跟随手势下拉的反应越灵敏。 |
......
......@@ -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({
......
......@@ -29,8 +29,6 @@
@Entry
@Component
struct SharedTransitionExample {
@State scale: number = 1
@State opacity: number = 1
@State active: boolean = false
build() {
......
# HiCollie开发指导<a name="ZH-CN_TOPIC_0000001231255509"></a>
- [概述](#section3432134085116)
- [接口说明](#section139261151145116)
- [效果](#section1589120102458)
- [开发实例](#section13905646534)
- [C++接口开发实例](#section9797199145316)
- [线程卡死监控](#section1734221332)
- [超时监控](#section2186947140)
## 概述<a name="section3432134085116"></a>
......
# HiLog\_Lite开发指导<a name="ZH-CN_TOPIC_0000001185815838"></a>
- [概述](#section775017517390)
- [接口说明](#section114412157402)
- [开发实例](#section1482812550419)
## 概述<a name="section775017517390"></a>
......
# HiSysEvent订阅指导<a name="ZH-CN_TOPIC_0000001185655868"></a>
- [概述](#section315316685112)
- [功能简介](#section123181433335224)
- [约束与限制](#section123181433375224)
- [开发指导](#section315316685113)
- [接口说明](#section0342191810519)
- [开发实例](#section123181432175110)
## 概述<a name="section315316685112"></a>
......
# HiSysEvent查询指导<a name="ZH-CN_TOPIC_0000001231455461"></a>
- [概述](#section279684125212)
- [开发指导](#section315316761113)
- [接口说明](#section03869128521)
- [开发实例](#section14286111855212)
## 概述<a name="section279684125212"></a>
......
# HiSysEvent工具使用指导<a name="ZH-CN_TOPIC_0000001231614021"></a>
- [概述](#section1886702718521)
- [实时订阅HiSysEvent事件相关命令](#section1210623418527)
- [查询历史HiSysEvent事件相关命令](#section1210623418539)
## 概述<a name="section1886702718521"></a>
......
# HiTrace开发指导<a name="ZH-CN_TOPIC_0000001186134310"></a>
- [概述](#section3986195420436)
- [应用场景](#section134561822574)
- [业务使用示例](#section63861653124417)
- [接口说明](#section1517945334617)
- [接口形式对比](#section932504474)
- [接口功能参数](#section2514638125)
- [通信调用处理](#section11257133933)
- [开发实例](#section14310412491)
- [C++接口实例](#section114916381509)
- [C接口实例](#section108292107514)
## 概述<a name="section3986195420436"></a>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册