提交 69639820 编写于 作者: Y yyuanche

Merge branch 'master' into Dimension

......@@ -135,7 +135,7 @@ zh-cn/application-dev/IDL/ @RayShih @littlejerry1 @gwang2008 @ccllee @chengxingz
zh-cn/application-dev/device-usage-statistics/ @chenmingJay @ningningW @tangtiantian2021 @nan-xiansen @iceice1001
zh-cn/application-dev/ui/ @HelloCrease @huaweimaxuchu @tomatodevboy @niulihua
zh-cn/application-dev/notification/ @RayShih @jayleehw @li-weifeng2 @currydavids
zh-cn/application-dev/windowmanager/ @ge-yafang @zhangqiang183 @zhouyaoying @zxg-gitee
zh-cn/application-dev/windowmanager/ @ge-yafang @zhangqiang183 @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/webgl/ @zengyawen @zhangqiang183 @wind_zj @zxg-gitee
zh-cn/application-dev/media/audio-overview.md @zengyawen @liuyuehua1 @saga2020 @currydavids
zh-cn/application-dev/media/audio-playback.md @zengyawen @liuyuehua1 @saga2020 @currydavids
......@@ -186,7 +186,7 @@ zh-cn/application-dev/dfx/errormanager-guidelines.md @littlejerry1 @ccllee @chen
zh-cn/application-dev/dfx/errormanager-guidelines.md @littlejerry1 @ccllee @chengxingzhen @RayShih
zh-cn/application-dev/key-features/multi-device-app-dev/ @lingminghw @crazyracing0726
zh-cn/application-dev/database/ @ge-yafang @feng-aiwen @gong-a-shi @logic42
zh-cn/application-dev/napi/native-window-guidelines.md @ge-yafang @zhangqiang183 @zhouyaoying @zxg-gitee
zh-cn/application-dev/napi/native-window-guidelines.md @ge-yafang @zhangqiang183 @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/napi/mindspore-lite-guidelines.md @ge-yafang @grbuzhidao @jianghui58 @auraxu
zh-cn/application-dev/napi/mindspore-lite-offline-model-guidelines.md @ge-yafang @grbuzhidao @jianghui58 @auraxu
zh-cn/application-dev/napi/rawfile_guidelines.md @ningningW
......@@ -275,9 +275,9 @@ zh-cn/application-dev/reference/apis/js-apis-application-shellCmdResult.md @litt
zh-cn/application-dev/reference/apis/js-apis-application-StartOptions.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-application-Want.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/application-models/windowextensionability.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-inner-application-windowExtensionContext.md @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/application-models/windowextensionability.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/reference/apis/js-apis-inner-application-windowExtensionContext.md @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/reference/apis/js-apis-appmanager.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-arraylist.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-audio.md @liuyuehua1 @zengyawen @magekkkk @currydavids
......@@ -334,7 +334,7 @@ zh-cn/application-dev/reference/apis/js-apis-deque.md @gongjunsong @ge-yafang @f
zh-cn/application-dev/reference/apis/js-apis-device-info.md @mupceet @zengyawen @handyohos @nan-xiansen
zh-cn/application-dev/reference/apis/js-apis-device-manager.md @intermilano @RayShih @william-ligang @liuhonggang123
zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md @shuaytao @RayShih @wangzhen107 @inter515
zh-cn/application-dev/reference/apis/js-apis-display.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-display.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/reference/apis/js-apis-distributed-account.md @nianCode @zengyawen @JiDong-CS @murphy1984
zh-cn/application-dev/reference/apis/js-apis-distributed-data.md @feng-aiwen @ge-yafang @gong-a-shi @logic42
zh-cn/application-dev/reference/apis/js-apis-distributedMissionManager.md @chenmingJay @ningningW @nan-xiansen @iceice1001
......@@ -419,8 +419,8 @@ zh-cn/application-dev/reference/apis/js-apis-router.md @huaweimaxuchu @HelloCrea
zh-cn/application-dev/reference/apis/js-apis-rpc.md @xuepianpian @RayShih @zhaopeng_gitee @vagrant_world
zh-cn/application-dev/reference/apis/js-apis-runninglock.md @aqxyjay @zengyawen @aqxyjay @alien0208
zh-cn/application-dev/reference/apis/js-apis-screen.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-screenshot.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-screen.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/reference/apis/js-apis-screenshot.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/reference/apis/js-apis-securityLabel.md @panqinxu @zengyawen @bubble_mao @jinhaihw
zh-cn/application-dev/reference/apis/js-apis-sensor.md @hellohyh001 @ningningW @butterls @star-wind-snow-and-rain
zh-cn/application-dev/reference/apis/js-apis-service-extension-ability.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
......@@ -482,7 +482,7 @@ zh-cn/application-dev/reference/apis/js-apis-webgl2.md @zhangqiang183 @ge-yafan
zh-cn/application-dev/reference/apis/js-apis-webSocket.md @zhang-hai-feng @zengyawen @jyh926 @gaoxi785
zh-cn/application-dev/reference/apis/js-apis-wifi.md @cheng_guohong @RayShih @cheng_guohong @quanli125
zh-cn/application-dev/reference/apis/js-apis-wifiext.md @cheng_guohong @RayShih @cheng_guohong @quanli125
zh-cn/application-dev/reference/apis/js-apis-window.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-window.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/reference/apis/js-apis-windowAnimationManager.md @zhangqiang183 @ge-yafang @wind_zj @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-worker.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-taskpool.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
......
# Device Usage Statistics Development (API Version 9)
# Device Usage Statistics Development
## When to Use
......
# Native APIs
- [Introduction to Native APIs](introduction.md)
- [Using N-APIs in Application Projects](napi-guidelines.md)
- [Using Native APIs in Application Projects](napi-guidelines.md)
- [Drawing Development](drawing-guidelines.md)
- [Raw File Development](rawfile-guidelines.md)
- [Native Window Development](native-window-guidelines.md)
......
# Using N-APIs in Application Projects
# Using Native APIs in Application Projects
In OpenHarmony, you can use the N-APIs in C APIs to implement interaction between ArkTS/TS/JS and C/C++. The N-API names are the same as those in the third-party **Node.js**. Currently, OpenHarmony supports some N-APIs. For details about the APIs supported, see [arkui_napi](https://gitee.com/openharmony/arkui_napi/blob/master/libnapi.ndk.json).
......
......@@ -210,6 +210,9 @@
- [@ohos.multimedia.camera (Camera Management)](js-apis-camera.md)
- [@ohos.multimedia.image (Image Processing)](js-apis-image.md)
- [@ohos.multimedia.media (Media)](js-apis-media.md)
- [@ohos.multimedia.systemSoundManager (System Sound Management)](js-apis-systemSoundManager.md)
- multimedia
- [ringtonePlayer (Ringtone Player)](js-apis-inner-multimedia-ringtonePlayer.md)
- Resource Manager
- [@ohos.i18n (Internationalization)](js-apis-i18n.md)
......@@ -319,6 +322,7 @@
- [@ohos.InputMethodExtensionAbility (InputMethodExtensionAbility)](js-apis-inputmethod-extension-ability.md)
- [@ohos.InputMethodExtensionContext (InputMethodExtensionContext)](js-apis-inputmethod-extension-context.md)
- [@ohos.InputMethodSubtype (Input Method Subtype)](js-apis-inputmethod-subtype.md)
- [@ohos.logLibrary (Log Library)](js-apis-loglibrary.md)
- [@ohos.pasteboard (Pasteboard)](js-apis-pasteboard.md)
- [@ohos.screenLock (Screenlock)](js-apis-screen-lock.md)
- [@ohos.systemDateTime (System Time and Time Zone)](js-apis-system-date-time.md)
......
......@@ -247,7 +247,7 @@ Cancels the listener for changes in the list of enabled accessibility extension
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Listening type. The value is fixed at **'enabledAccessibilityExtensionListChange'**, indicating listening for changes in the list of enabled accessibility extension abilities.|
| callback | Callback<void> | No| Callback invoked when the list of enabled accessibility extension abilities changes.|
| callback | Callback<void> | No| Callback for the event.|
**Example**
......@@ -425,7 +425,7 @@ Cancels the listener for attribute changes. This API uses an asynchronous callba
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | Callback<T> | No| Callback invoked when the list of enabled accessibility extension abilities changes.|
| callback | Callback<T> | No| Callback for the event.|
**Example**
......
......@@ -22,9 +22,9 @@ Checks whether this application is undergoing a stability test. This API uses an
**Parameters**
| Type| Description|
| -------- | -------- |
|AsyncCallback<boolean> |Callback used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is undergoing a stability test, and **false** means the opposite.|
| Type| Description|
| -------- | -------- |
|AsyncCallback<boolean> |Callback used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is undergoing a stability test, and **false** means the opposite.|
**Error codes**
......@@ -59,9 +59,9 @@ Checks whether this application is undergoing a stability test. This API uses a
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<boolean> | Promise used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is undergoing a stability test, and **false** means the opposite.|
| Type| Description|
| -------- | -------- |
| Promise<boolean> | Promise used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is undergoing a stability test, and **false** means the opposite.|
**Error codes**
......@@ -94,9 +94,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<boolean> | Promise used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is running on a RAM constrained device, and **false** means the opposite.|
| Type| Description|
| -------- | -------- |
| Promise<boolean> | Promise used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is running on a RAM constrained device, and **false** means the opposite.|
**Error codes**
......@@ -128,9 +128,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Parameters**
| Type| Description|
| -------- | -------- |
| AsyncCallback<boolean> |Callback used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is running on a RAM constrained device, and **false** means the opposite.|
| Type| Description|
| -------- | -------- |
| AsyncCallback<boolean> |Callback used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is running on a RAM constrained device, and **false** means the opposite.|
**Error codes**
......@@ -164,9 +164,9 @@ Obtains the memory size of this application. This API uses a promise to return t
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<number> | Promise used to return the API call result and the memory size. You can perform error handling or custom processing in this callback.|
| Type| Description|
| -------- | -------- |
| Promise<number> | Promise used to return the API call result and the memory size. You can perform error handling or custom processing in this callback.|
**Error codes**
......@@ -198,9 +198,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb
**Parameters**
| Type| Description|
| -------- | -------- |
|AsyncCallback<number> |Callback used to return the API call result and the memory size. You can perform error handling or custom processing in this callback.|
| Type| Description|
| -------- | -------- |
|AsyncCallback<number> |Callback used to return the API call result and the memory size. You can perform error handling or custom processing in this callback.|
**Error codes**
......@@ -298,6 +298,82 @@ appManager.getRunningProcessInformation((err, data) => {
});
```
## appManager.isSharedBundleRunning
isSharedBundleRunning(bundleName: string, versionCode: number): Promise\<boolean>;
Checks whether the shared library is in use. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| bundleName | string | Yes | Bundle name of the shared library.|
| versionCode | number | Yes | Version number of the shared library. |
**Return value**
| Type| Description|
| -------- | -------- |
| Promise\<boolean> | Promise used to return the result. The value **true** means that the shared library is in use, and **false** means the opposite.|
**Example**
```ts
import appManager from '@ohos.app.ability.appManager';
appManager.isSharedBundleRunning(bundleName, versionCode).then((data) => {
console.log('The shared bundle running is: ${JSON.stringify(data)}');
}).catch((error) => {
console.error('error: ${JSON.stringify(error)}');
});
```
## appManager.isSharedBundleRunning
isSharedBundleRunning(bundleName: string, versionCode: number, callback: AsyncCallback\<boolean>): void;
Checks whether the shared library is in use. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| bundleName | string | Yes | Bundle name of the shared library.|
| versionCode | number | Yes | Version number of the shared library. |
**Return value**
| Type| Description|
| -------- | -------- |
|AsyncCallback\<boolean>> | Callback used to return the result. The value **true** means that the shared library is in use, and **false** means the opposite.|
**Example**
```ts
import appManager from '@ohos.app.ability.appManager';
appManager.isSharedBundleRunning(bundleName, versionCode, (err, data) => {
if (err) {
console.error('err: ${JSON.stringify(err)}');
} else {
console.log('The shared bundle running is: ${JSON.stringify(data)}');
}
});
```
## appManager.on
on(type: 'applicationState', observer: ApplicationStateObserver): number;
......@@ -641,7 +717,7 @@ Obtains applications that are running in the foreground. This API uses a promise
| Type| Description|
| -------- | -------- |
| Promise\<Array\<[AppStateData](js-apis-inner-application-appStateData.md)>> | Promise used to return an array holding the application state data. |
| Promise\<Array\<[AppStateData](js-apis-inner-application-appStateData.md)>> | Promise used to return an array holding the application state data.|
**Error codes**
......@@ -731,11 +807,11 @@ Kills a process by bundle name and account ID. This API uses an asynchronous cal
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Bundle name.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the API call result. You can perform error handling or custom processing in this callback.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Bundle name.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the API call result. You can perform error handling or custom processing in this callback.|
**Error codes**
......
......@@ -116,8 +116,8 @@ struct SnapshotExample {
Image(this.pixmap)
.width(300).height(300)
// ...Component
// ...Components
// ...Components
// ...Component
// ...Component
Button("click to generate UI snapshot")
.onClick(() => {
componentSnapshot.get("root")
......
......@@ -2,8 +2,7 @@
> **NOTE**
>
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs provided by this module are system APIs.
> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
......@@ -118,8 +117,9 @@ Enumerates the camera error codes, which are returned when an API call is incorr
| SESSION_NOT_RUNNING | 7400104 | The session is not running. |
| SESSION_CONFIG_LOCKED | 7400105 | The session configuration is locked. |
| DEVICE_SETTING_LOCKED | 7400106 | The device setting is locked. |
| CONFILICT_CAMERA | 7400107 | The device is already started. |
| CONFLICT_CAMERA | 7400107 | The device is already started. |
| DEVICE_DISABLED | 7400108 | The camera is disabled for security reasons. |
| DEVICE_PREEMPTED | 7400109 | The camera is preempted. |
| SERVICE_FATAL_ERROR | 7400201 | An error occurs in the camera service. |
## CameraManager
......@@ -203,7 +203,7 @@ isCameraMuteSupported(): boolean
Checks whether the camera can be muted.
This is a system API.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core
......@@ -225,7 +225,7 @@ muteCamera(mute: boolean): void
Mutes or unmutes the camera.
This is a system API.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core
......@@ -562,7 +562,7 @@ on(type: 'cameraMute', callback: AsyncCallback\<boolean\>): void
Listens for camera mute status changes. This API uses an asynchronous callback to return the result.
This is a system API.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core
......@@ -630,6 +630,20 @@ Enumerates the camera connection types.
| CAMERA_CONNECTION_USB_PLUGIN | 1 | Camera connected using USB.|
| CAMERA_CONNECTION_REMOTE | 2 | Remote camera.|
## HostDeviceType
Enumerates the remote camera types.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Value | Description |
| ---------------------------- | ---- | ------------- |
| UNKNOWN_TYPE | 0 | Unknown type. |
| PHONE | 0x0E | Camera of a smartphone.|
| TABLET | 0x11 | Camera of a tablet.|
## CameraDevice
Defines the camera device information.
......@@ -642,6 +656,8 @@ Defines the camera device information.
| cameraPosition | [CameraPosition](#cameraposition) | Yes | Camera position. |
| cameraType | [CameraType](#cameratype) | Yes | Camera type. |
| connectionType | [ConnectionType](#connectiontype) | Yes | Camera connection type.|
| hostDeviceName | string | Yes | Name of the remote device.<br>**System API**: This is a system API.|
| hostDeviceType | [hostDeviceType](#hostdevicetype) | Yes | Type of the remote device.<br>**System API**: This is a system API.|
## Size
......@@ -1754,7 +1770,7 @@ Before the setting, you are advised to use **[getExposureBiasRange](#getexposure
| Name | Type | Mandatory| Description |
| -------- | -------------------------------| ---- | ------------------- |
| exposureBias | number | Yes | EV. The supported EV range can be obtained by calling **getExposureBiasRange**. If calling the API fails, an error code defined in [CameraErrorCode](#cameraerrorcode) will be returned. If the value passed is not within the supported range, the nearest critical point is used.|
| exposureBias | number | Yes | EV. The supported EV range can be obtained by calling **getExposureBiasRange**. If the value passed is not within the supported range, the nearest critical point is used. There is a step for EV. For example, if the step is 0.5 and this parameter is set to 1.2, the EV that takes effect is 1.0. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned. |
**Error codes**
......@@ -1788,7 +1804,7 @@ Obtains the exposure value in use.
| Type | Description |
| ---------- | ----------------------------- |
| number | Exposure value obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
| number | Exposure value obtained. There is a step for EV. For example, if the step is 0.5 and this parameter is set to 1.2, the EV that takes effect is 1.0. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned. |
**Error codes**
......
......@@ -433,7 +433,7 @@ try {
getWindows(callback: AsyncCallback\<Array\<AccessibilityElement>>): void;
Obtains the list of windows on a display. This API uses an asynchronous callback to return the result.
Obtains the list of windows on this display. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
......@@ -610,7 +610,7 @@ Defines the accessibilityelement. Before calling APIs of **AccessibilityElement*
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
## attributeNames
### attributeNames
attributeNames\<T extends keyof ElementAttributeValues>(): Promise\<Array\<T>>;
......@@ -636,7 +636,7 @@ rootElement.attributeNames().then((data) => {
console.log('failed to get attribute names, because ${JSON.stringify(err)}');
});
```
## attributeNames
### attributeNames
attributeNames\<T extends keyof ElementAttributeValues>(callback: AsyncCallback\<Array\<T>>): void;
......@@ -664,7 +664,7 @@ rootElement.attributeNames((err, data) => {
console.info('get attribute names success');
});
```
## AccessibilityElement.attributeValue
### attributeValue
attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T): Promise\<ElementAttributeValues[T]>;
......@@ -709,7 +709,7 @@ try {
console.error('failed to get attribute value, because ${JSON.stringify(exception)}');
}
```
## AccessibilityElement.attributeValue
### attributeValue
attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T,
callback: AsyncCallback\<ElementAttributeValues[T]>): void;
......@@ -752,7 +752,7 @@ try {
console.error('failed to get attribute value, because ${JSON.stringify(exception)}');
}
```
## actionNames
### actionNames
actionNames(): Promise\<Array\<string>>;
......@@ -778,7 +778,7 @@ rootElement.actionNames().then((data) => {
console.error('failed to get action names because ${JSON.stringify(err)}');
});
```
## actionNames
### actionNames
actionNames(callback: AsyncCallback\<Array\<string>>): void;
......@@ -806,7 +806,7 @@ rootElement.actionNames((err, data) => {
console.info('get action names success');
});
```
## performAction
### performAction
performAction(actionName: string, parameters?: object): Promise\<void>;
......@@ -818,8 +818,8 @@ Performs an action based on the specified action name. This API uses a promise t
| Name | Type | Mandatory | Description |
| ----------- | ---------------------------------------- | ---- | -------------- |
| actionName | string | Yes | Action name. For details, see [Action](./js-apis-accessibility.md#action). |
| parameters | object | No | Parameters required for performing the target action. Not supported currently. |
| actionName | string | Yes | Action name. For details, see [Action](./js-apis-accessibility.md#action).
| parameters | object | No | Parameters required for performing the target action. Empty by default. Not supported currently. |
**Return value**
......@@ -849,7 +849,7 @@ try {
console.error('failed to perform action, because ${JSON.stringify(exception)}');
}
```
## performAction
### performAction
performAction(actionName: string, callback: AsyncCallback\<void>): void;
......@@ -861,7 +861,7 @@ Performs an action based on the specified action name. This API uses an asynchro
| Name | Type | Mandatory | Description |
| ----------- | ---------------------------------------- | ---- | -------------- |
| actionName | string | Yes | Action name. For details, see [Action](./js-apis-accessibility.md#action). |
| actionName | string | Yes | Action name. For details, see [Action](./js-apis-accessibility.md#action).
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes**
......@@ -888,7 +888,7 @@ try {
console.error('failed to perform action, because ${JSON.stringify(exception)}');
}
```
## performAction
### performAction
performAction(actionName: string, parameters: object, callback: AsyncCallback\<void>): void;
......@@ -901,7 +901,7 @@ Performs an action based on the specified action name. This API uses an asynchro
| Name | Type | Mandatory | Description |
| ---------- | ------------------------- | ---- | ---------------------------------------- |
| actionName | string | Yes | Action name. For details, see [Action](./js-apis-accessibility.md#action).|
| parameters | object | Yes | Parameters required for performing the target action. Not supported currently. |
| parameters | object | Yes | Parameters required for performing the target action. Empty by default. Not supported currently. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes**
......@@ -932,7 +932,7 @@ try {
console.error('failed to perform action, because ${JSON.stringify(exception)}');
}
```
## findElement('content')
### findElement('content')
findElement(type: 'content', condition: string): Promise\<Array\<AccessibilityElement>>;
......@@ -971,7 +971,7 @@ try {
console.error('failed to find element, because ${JSON.stringify(exception)}');
}
```
## findElement('content')
### findElement('content')
findElement(type: 'content', condition: string, callback: AsyncCallback\<Array\<AccessibilityElement>>): void;
......@@ -1007,7 +1007,7 @@ try {
console.error('failed to find element, because ${JSON.stringify(exception)}');
}
```
## findElement('focusType')
### findElement('focusType')
findElement(type: 'focusType', condition: FocusType): Promise\<AccessibilityElement>;
......@@ -1046,7 +1046,7 @@ try {
console.error('failed to find element, because ${JSON.stringify(exception)}');
}
```
## findElement('focusType')
### findElement('focusType')
findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback\<AccessibilityElement>): void;
......@@ -1082,7 +1082,7 @@ try {
console.error('failed to find element, because ${JSON.stringify(exception)}');
}
```
## findElement('focusDirection')
### findElement('focusDirection')
findElement(type: 'focusDirection', condition: FocusDirection): Promise\<AccessibilityElement>;
......@@ -1121,7 +1121,7 @@ try {
console.error('failed to find element, because ${JSON.stringify(exception)}');
}
```
## findElement('focusDirection')
### findElement('focusDirection')
findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCallback\<AccessibilityElement>): void;
......
......@@ -43,5 +43,5 @@ let applicationStateObserver = {
console.log('onProcessStateChanged onProcessStateChanged: ${JSON.stringify(processData)}');
}
};
let observerCode = appManager.registerApplicationStateObserver(applicationStateObserver);
let observerCode = appManager.on('applicationState', applicationStateObserver);
```
# ringtonePlayer (Ringtone Player)
The **ringtonePlayer** module provides APIs for playing, configuring, and obtaining system ringtones.
This module must work with [@ohos.multimedia.systemSoundManager](js-apis-systemSoundManager.md) to manage system ringtones.
> **NOTE**
>
> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.
## Modules to Import
```js
import systemSoundManager from '@ohos.multimedia.systemSoundManager';
```
## RingtoneOptions
Enumerates the ringtone parameters.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
| Name | Type |Mandatory | Description |
| --------- | -------------- | ---- | --------------------------------- |
| volume | number | Yes | Relative volume. The value ranges from 0.00 to 1.00. The value **1.00** indicates the maximum volume (100%).|
| loop | boolean | Yes | Whether to enable loop playback. The value **true** means to enable loop playback, and **false** means the opposite.|
## RingtonePlayer
Provides APIs for setting and obtaining system ringtone parameters as well as playing and stopping system ringtones. Before calling any API in **RingtonePlayer**, you must use [getSystemRingtonePlayer](js-apis-systemSoundManager.md#getsystemringtoneplayer) to create a **RingtonePlayer** instance.
### Attributes
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
| Name | Type | Readable| Writable| Description |
| ----- | -------------------------- | ---- | ---- | ------------------ |
| state | [media.AVPlayerState](js-apis-media.md#avplayerstate9) | Yes | No | Audio renderer state.|
**Example**
```js
let state = systemRingtonePlayer.state;
```
### getTitle
getTitle(callback: AsyncCallback&lt;string&gt;): void
Obtains the title of a system ringtone. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -----------------------------------------| ---- | ------------------------- |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the ringtone title obtained. |
**Example**
```js
systemRingtonePlayer.getTitle((err, value) => {
if (err) {
console.error(`Failed to get system ringtone title. ${err}`);
return;
}
console.info(`Callback invoked to indicate the value of the system ringtone title is obtained ${value}.`);
});
```
### getTitle
getTitle(): Promise&lt;string&gt;
Obtains the title of a system ringtone. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Return value**
| Type | Description |
| --------------------- | -------------------------------- |
| Promise&lt;string&gt; | Promise used to return the ringtone title obtained.|
**Example**
```js
systemRingtonePlayer.getTitle().then((value) => {
console.info(`Promise returned to indicate that the value of the system ringtone title is obtained ${value}.`);
}).catch ((err) => {
console.error(`Failed to get the system ringtone title ${err}`);
});
```
### getAudioRendererInfo
getAudioRendererInfo(callback: AsyncCallback&lt;audio.AudioRendererInfo&gt;): void
Obtains the information about the audio renderer used by the ringtone. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -----------------------------------------| ---- | ------------------------- |
| callback | AsyncCallback&lt;[audio.AudioRendererInfo](js-apis-audio.md#audiorendererinfo8)&gt; | Yes| Callback used to return the audio renderer information obtained.|
**Example**
```js
import audio from '@ohos.multimedia.audio';
let audioRendererInfo: audio.AudioRendererInfo = null;
systemRingtonePlayer.getAudioRendererInfo((err, value) => {
if (err) {
console.error(`Failed to get ringtone AudioRendererInfo. ${err}`);
return;
}
console.info(`Callback invoked to indicate the value of the ringtone AudioRendererInfo is obtained.`);
audioRendererInfo = value;
});
```
### getAudioRendererInfo
getAudioRendererInfo(): Promise&lt;audio.AudioRendererInfo&gt;
Obtains the information about the audio renderer used by the ringtone. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Return value**
| Type | Description |
| ------------------- | ------------------------------- |
| Promise&lt;[audio.AudioRendererInfo](js-apis-audio.md#audiorendererinfo8)&gt; | Promise used to return the audio renderer information obtained.|
**Example**
```js
import audio from '@ohos.multimedia.audio';
let audioRendererInfo: audio.AudioRendererInfo = null;
systemRingtonePlayer.getAudioRendererInfo().then((value) => {
console.info(`Promise returned to indicate that the value of the ringtone AudioRendererInfo is obtained ${value}.`);
audioRendererInfo = value;
}).catch ((err) => {
console.error(`Failed to get the ringtone AudioRendererInfo ${err}`);
});
```
### configure
configure(options: RingtoneOptions, callback: AsyncCallback&lt;void&gt;): void
Sets ringtone parameters. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -----------------------------------------| ---- | ------------------------- |
| options | [RingtoneOptions](#ringtoneoptions) | Yes | Ringtone parameters. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
let ringtoneOptions = {volume: 0.5, loop: true};
systemRingtonePlayer.configure(ringtoneOptions, (err) => {
if (err) {
console.error(`Failed to configure ringtone options. ${err}`);
return;
}
console.info(`Callback invoked to indicate a successful setting of ringtone options.`);
});
```
### configure
configure(options: RingtoneOptions): Promise&lt;void&gt;
Sets ringtone parameters. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -----------------------------------------| ---- | ------------------------- |
| options | [RingtoneOptions](#ringtoneoptions) | Yes | Ringtone parameters. |
**Return value**
| Type | Description |
| ------------------- | ------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let ringtoneOptions = {volume: 0.5, loop: true};
systemRingtonePlayer.configure(ringtoneOptions).then(() => {
console.info(`Promise returned to indicate a successful setting of ringtone options.`);
}).catch ((err) => {
console.error(`Failed to configure ringtone options. ${err}`);
});
```
### start
start(callback: AsyncCallback&lt;void&gt;): void
Starts playing the ringtone. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -----------------------------------------| ---- | ------------------------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
systemRingtonePlayer.start((err) => {
if (err) {
console.error(`Failed to start playing ringtone. ${err}`);
return;
}
console.info(`Callback invoked to indicate a successful starting of ringtone.`);
});
```
### start
start(): Promise&lt;void&gt;
Starts playing the ringtone. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Return value**
| Type | Description |
| ------------------- | -------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
systemRingtonePlayer.start().then(() => {
console.info(`Promise returned to indicate a successful starting of ringtone.`);
}).catch ((err) => {
console.error(`Failed to start playing ringtone. ${err}`);
});
```
### stop
stop(callback: AsyncCallback&lt;void&gt;): void
Stops playing the ringtone. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -----------------------------------------| ---- | ------------------------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
systemRingtonePlayer.stop((err) => {
if (err) {
console.error(`Failed to stop playing ringtone. ${err}`);
return;
}
console.info(`Callback invoked to indicate a successful stopping of ringtone.`);
});
```
### stop
stop(): Promise&lt;void&gt;
Stops playing the ringtone. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Return value**
| Type | Description |
| ------------------- | -------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
systemRingtonePlayer.stop().then(() => {
console.info(`Promise returned to indicate a successful stopping of ringtone.`);
}).catch ((err) => {
console.error(`Failed to stop playing ringtone. ${err}`);
});
```
### release
release(callback: AsyncCallback&lt;void&gt;): void
Releases the ringtone player. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -----------------------------------------| ---- | ------------------------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
systemRingtonePlayer.release((err) => {
if (err) {
console.error(`Failed to release ringtone player. ${err}`);
return;
}
console.info(`Callback invoked to indicate a successful releasing of ringtone player.`);
});
```
### release
release(): Promise&lt;void&gt;
Releases the ringtone player. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Return value**
| Type | Description |
| ------------------- | ------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result. |
**Example**
```js
systemRingtonePlayer.release().then(() => {
console.info(`Promise returned to indicate a successful releasing of ringtone player.`);
}).catch ((err) => {
console.error(`Failed to release ringtone player. ${err}`);
});
```
### on('audioInterrupt')
on(type: 'audioInterrupt', callback: Callback&lt;audio.InterruptEvent&gt;): void
Subscribes to audio interruption events. This API uses a callback to obtain interrupt events.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------------------------------------------- |
| type | string | Yes | Event type. The value **'audioInterrupt'** means the audio interruption event, which is triggered when audio rendering is interrupted.|
| callback | Callback&lt;[audio.InterruptEvent](js-apis-audio.md#interruptevent9)&gt; | Yes | Callback used to return the audio interruption event. |
**Error codes**
For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
| ID| Error Message|
| ------- | --------------------------------------------|
| 401 | if input parameter type or number mismatch |
| 6800101 | if input parameter value error |
**Example**
```js
import audio from '@ohos.multimedia.audio';
let isPlaying; // An identifier specifying whether rendering is in progress.
let isDucked; // An identifier specifying whether the audio volume is reduced.
systemRingtonePlayer.on('audioInterrupt', async(interruptEvent) => {
if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) {
// The system forcibly interrupts audio rendering. The application must update the status and displayed content accordingly.
switch (interruptEvent.hintType) {
case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
// The audio stream has been paused and temporarily loses the focus. It will receive the interruptEvent corresponding to resume when it is able to regain the focus.
console.info('Force paused. Update playing status and stop writing');
isPlaying = false; // A simplified processing indicating several operations for switching the application to the paused state.
break;
case audio.InterruptHint.INTERRUPT_HINT_STOP:
// The audio stream has been stopped and permanently loses the focus. The user must manually trigger the operation to resume rendering.
console.info('Force stopped. Update playing status and stop writing');
isPlaying = false; // A simplified processing indicating several operations for switching the application to the paused state.
break;
case audio.InterruptHint.INTERRUPT_HINT_DUCK:
// The audio stream is rendered at a reduced volume.
console.info('Force ducked. Update volume status');
isDucked = true; // A simplified processing indicating several operations for updating the volume status.
break;
case audio.InterruptHint.INTERRUPT_HINT_UNDUCK:
// The audio stream is rendered at the normal volume.
console.info('Force ducked. Update volume status');
isDucked = false; // A simplified processing indicating several operations for updating the volume status.
break;
default:
break;
}
} else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) {
// The application can choose to take action or ignore.
switch (interruptEvent.hintType) {
case audio.InterruptHint.INTERRUPT_HINT_RESUME:
// It is recommended that the application continue rendering. (The audio stream has been forcibly paused and temporarily lost the focus. It can resume rendering now.)
console.info('Resume force paused renderer or ignore');
// To continue rendering, the application must perform the required operations.
break;
default:
break;
}
}
});
```
......@@ -57,7 +57,9 @@ Provides the constant values of function keys, edit boxes, and the cursor.
getInputMethodAbility(): InputMethodAbility
Obtains an [InputMethodAbility](#inputmethodability) instance for the input method.
This API can be called only by an input method.
The input method can use the obtained instance to subscribe to a soft keyboard display/hide request event, create/destroy an input method panel, and the like.
**System capability**: SystemCapability.MiscServices.InputMethodFramework
......@@ -494,7 +496,7 @@ This API can be called only by an input method. Only one SOFT_KEYBOARD panel and
| Name | Type | Mandatory| Description |
| ------- | ----------- | ---- | ------------------------ |
| ctx | [BaseContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-inner-application-baseContext.md) | Yes | Context of the current input method.|
| ctx | [BaseContext](js-apis-inner-application-baseContext.md) | Yes | Context of the current input method.|
| info | [PanelInfo](#panelinfo10) | Yes | Information about the input method panel.|
| callback | AsyncCallback\<[Panel](#panel10)> | Yes | Callback used to return the result. If the operation is successful, the created input method panel is returned. |
......@@ -538,7 +540,7 @@ This API can be called only by an input method. Only one SOFT_KEYBOARD panel and
| Name | Type | Mandatory| Description |
| ------- | ----------- | ---- | ------------------------ |
| ctx | [BaseContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-inner-application-baseContext.md) | Yes | Context of the current input method.|
| ctx | [BaseContext](js-apis-inner-application-baseContext.md) | Yes | Context of the current input method.|
| info | [PanelInfo](#panelinfo10) | Yes | Information about the input method panel.|
**Return value**
......@@ -953,7 +955,7 @@ Loads content from a page linked to LocalStorage to this panel. This API uses an
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------- |
| path | string | Yes | Path of the page from which the content will be loaded.|
| storage | [LocalStorage](../../quick-start/arkts-localstorage.md) | Yes | Storage unit that provides storage for mutable and immutable state variables in the application.|
| storage | [LocalStorage](../arkui-ts/ts-state-management.md#localstorage9) | Yes | Storage unit that provides storage for mutable and immutable state variables in the application.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
......@@ -987,7 +989,7 @@ Loads content from a page linked to LocalStorage to this panel. This API uses a
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------- |
| path | string | Yes | Path of the page from which the content will be loaded.|
| storage | [LocalStorage](../../quick-start/arkts-localstorage.md) | Yes | Storage unit that provides storage for mutable and immutable state variables in the application.|
| storage | [LocalStorage](../arkui-ts/ts-state-management.md#localstorage9) | Yes | Storage unit that provides storage for mutable and immutable state variables in the application.|
**Return value**
......@@ -1067,7 +1069,7 @@ The panel width cannot exceed the screen width, and the panel height cannot be h
| Type | Description |
| ------- | ------------------------------ |
| Promise<void> | Promise that returns no value. |
| Promise\<void> | Promise that returns no value. |
**Example**
......@@ -1139,7 +1141,7 @@ This API does not work on panels in the FLG_FIXED state.
| Type | Description |
| ------- | ------------------------------ |
| Promise<void> | Promise that returns no value. |
| Promise\<void> | Promise that returns no value. |
**Example**
......@@ -1558,7 +1560,7 @@ Sends the function key. This API uses a promise to return the result.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| action | number | Yes| Action of the function key.<br>**0**: invalid key.<br>**1**: confirm key (Enter key).|
| action | number | Yes| Action of the function key.<br>- **0**: invalid key.<br>- **1**: confirm key (Enter key).|
**Return value**
......@@ -2521,8 +2523,8 @@ Describes the attribute of a key.
| Name | Type| Readable| Writable| Description |
| --------- | -------- | ---- | ---- | ------------ |
| keyCode | number | Yes | No | Key value.|
| keyAction | number | Yes | No | Key status.|
| keyCode | number | Yes | No | Key value. For detail, see [KeyCode](js-apis-keycode.md#keycode).|
| keyAction | number | Yes | No | Key event type.<br>- **2**: keydown event.<br>- **3**: keyup event.|
## PanelFlag<sup>10+</sup>
......
......@@ -77,7 +77,6 @@ let media = mediaLibrary.getMediaLibrary();
### getFileAssets<sup>7+</sup>
getFileAssets(options: MediaFetchOptions, callback: AsyncCallback&lt;FetchFileResult&gt;): void
Obtains file assets (also called files). This API uses an asynchronous callback to return the result.
......@@ -105,7 +104,7 @@ async function example() {
selectionArgs: [imageType.toString()],
};
// Obtain the files in asynchronous callback mode.
media.getFileAssets(imagesFetchOp, (error, fetchFileResult) => {
media.getFileAssets(imagesFetchOp, async (error, fetchFileResult) => {
// Check whether the result set of the obtained files is undefined. If yes, the API call fails.
if (fetchFileResult == undefined) {
console.error('get fetchFileResult failed with error: ' + error);
......@@ -124,8 +123,8 @@ async function example() {
return;
}
console.info('Get fetchFileResult successfully, count: ' + count);
// Obtain the first file in the result set in asynchronous callback mode.
fetchFileResult.getFirstObject((error, fileAsset) => {
// Obtain the first file in the result set in asynchronous callback mode. If there are a large number of files, use getAllObject instead.
fetchFileResult.getFirstObject(async (error, fileAsset) => {
// Check whether the first file is undefined. If yes, the API call fails.
if (fileAsset == undefined) {
console.error('get first object failed with error: ' + error);
......@@ -178,7 +177,7 @@ async function example() {
selectionArgs: [imageType.toString()],
};
// Obtain the files in promise mode.
media.getFileAssets(imagesFetchOp).then((fetchFileResult) => {
media.getFileAssets(imagesFetchOp).then(async (fetchFileResult) => {
// Obtain the total number of files in the result set.
const count = fetchFileResult.getCount();
// Check whether the number is less than 0. If yes, the API call fails.
......@@ -192,8 +191,8 @@ async function example() {
return;
}
console.info('Get fetchFileResult successfully, count: ' + count);
// Obtain the first file in the result set in promise mode.
fetchFileResult.getFirstObject().then((fileAsset) => {
// Obtain the first file in the result set in promise mode. If there are a large number of files, use getAllObject instead.
fetchFileResult.getFirstObject().then(async (fileAsset) => {
console.info('fileAsset.displayName ' + '0 : ' + fileAsset.displayName);
// Call getNextObject to obtain the next file until the last one.
for (let i = 1; i < count; i++) {
......@@ -514,9 +513,10 @@ Obtains the albums. This API uses an asynchronous callback to return the result.
```js
async function example() {
// To obtain the file assets in an album, you must preset the album and resources. The sample code below presets 'New Album 1'.
let AlbumNoArgsfetchOp = {
selections: '',
selectionArgs: [],
selections: mediaLibrary.FileKey.ALBUM_NAME + '= ?',
selectionArgs:['New Album 1'],
};
media.getAlbums(AlbumNoArgsfetchOp, (error, albumList) => {
if (albumList != undefined) {
......@@ -554,9 +554,10 @@ Obtains the albums. This API uses a promise to return the result.
```js
async function example() {
// To obtain the file assets in an album, you must preset the album and resources. The sample code below presets 'New Album 1'.
let AlbumNoArgsfetchOp = {
selections: '',
selectionArgs: [],
selections: mediaLibrary.FileKey.ALBUM_NAME + '= ?',
selectionArgs:['New Album 1'],
};
media.getAlbums(AlbumNoArgsfetchOp).then((albumList) => {
console.info('getAlbums successfully: ' + JSON.stringify(albumList));
......@@ -2021,7 +2022,7 @@ async function example() {
### getNextObject<sup>7+</sup>
getNextObject(callback: AsyncCallback&lt;FileAsset&gt;): void
getNextObject(callback: AsyncCallback&lt;FileAsset&gt;): void
Obtains the next file asset in the result set. This API uses an asynchronous callback to return the result.
> **NOTE**
......@@ -2049,7 +2050,8 @@ async function example() {
};
let fetchFileResult = await media.getFileAssets(getImageOp);
let fileAsset = await fetchFileResult.getFirstObject();
if (!fileAsset.isAfterLast) {
console.log('fetchFileResult getFirstObject successfully, displayName: ' + fileAsset.displayName);
if (!fetchFileResult.isAfterLast()) {
fetchFileResult.getNextObject((error, fileAsset) => {
if (error) {
console.error('fetchFileResult getNextObject failed with error: ' + error);
......@@ -2065,7 +2067,7 @@ async function example() {
### getNextObject<sup>7+</sup>
getNextObject(): Promise&lt;FileAsset&gt;
getNextObject(): Promise&lt;FileAsset&gt;
Obtains the next file asset in the result set. This API uses a promise to return the result.
> **NOTE**
......@@ -2093,7 +2095,8 @@ async function example() {
};
let fetchFileResult = await media.getFileAssets(getImageOp);
let fileAsset = await fetchFileResult.getFirstObject();
if (!fileAsset.isAfterLast) {
console.log('fetchFileResult getFirstObject successfully, displayName: ' + fileAsset.displayName);
if (!fetchFileResult.isAfterLast()) {
fetchFileResult.getNextObject().then((fileAsset) => {
console.info('fetchFileResult getNextObject successfully, displayName: ' + fileAsset.displayName);
fetchFileResult.close();
......@@ -2369,9 +2372,10 @@ Commits the modification in the album attributes to the database. This API uses
```js
async function example() {
// To obtain the file assets in an album, you must preset the album and resources. The sample code below presets 'New Album 1'.
let AlbumNoArgsfetchOp = {
selections: '',
selectionArgs: [],
selections: mediaLibrary.FileKey.ALBUM_NAME + '= ?',
selectionArgs:['New Album 1'],
};
const albumList = await media.getAlbums(AlbumNoArgsfetchOp);
const album = albumList[0];
......@@ -2406,9 +2410,10 @@ Commits the modification in the album attributes to the database. This API uses
```js
async function example() {
// To obtain the file assets in an album, you must preset the album and resources. The sample code below presets 'New Album 1'.
let AlbumNoArgsfetchOp = {
selections: '',
selectionArgs: [],
selections: mediaLibrary.FileKey.ALBUM_NAME + '= ?',
selectionArgs:['New Album 1'],
};
const albumList = await media.getAlbums(AlbumNoArgsfetchOp);
const album = albumList[0];
......@@ -2423,6 +2428,47 @@ async function example() {
### getFileAssets<sup>7+</sup>
getFileAssets(callback: AsyncCallback&lt;FetchFileResult&gt;): void
Obtains the file assets in this album. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.READ_MEDIA
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------- | ---- | ----------------------------------- |
| callback | AsyncCallback<[FetchFileResult](#fetchfileresult7)> | Yes | Callback used to return the file assets.|
**Example**
```js
async function example() {
// To obtain the file assets in an album, you must preset the album and resources. The sample code below presets 'New Album 1'.
let AlbumNoArgsfetchOp = {
selections: mediaLibrary.FileKey.ALBUM_NAME + '= ?',
selectionArgs:['New Album 1'],
};
// Obtain the albums that meet the retrieval options and return the album list.
const albumList = await media.getAlbums(AlbumNoArgsfetchOp);
const album = albumList[0];
// Obtain an album from the album list and obtain all media assets that meet the retrieval options in the album.
album.getFileAssets((error, fetchFileResult) => {
if (error) {
console.error('album getFileAssets failed with error: ' + error);
return;
}
let count = fetchFileResult.getCount();
console.info('album getFileAssets successfully, count: ' + count);
fetchFileResult.close();
});
}
```
### getFileAssets<sup>7+</sup>
getFileAssets(options: MediaFetchOptions, callback: AsyncCallback&lt;FetchFileResult&gt;): void
Obtains the file assets in this album. This API uses an asynchronous callback to return the result.
......@@ -2442,9 +2488,10 @@ Obtains the file assets in this album. This API uses an asynchronous callback to
```js
async function example() {
// To obtain the file assets in an album, you must preset the album and resources. The sample code below presets 'New Album 1'.
let AlbumNoArgsfetchOp = {
selections: '',
selectionArgs: [],
selections: mediaLibrary.FileKey.ALBUM_NAME + '= ?',
selectionArgs:['New Album 1'],
};
let fileNoArgsfetchOp = {
selections: '',
......@@ -2492,9 +2539,10 @@ Obtains the file assets in this album. This API uses a promise to return the res
```js
async function example() {
// To obtain the file assets in an album, you must preset the album and resources. The sample code below presets 'New Album 1'.
let AlbumNoArgsfetchOp = {
selections: '',
selectionArgs: [],
selections: mediaLibrary.FileKey.ALBUM_NAME + '= ?',
selectionArgs:['New Album 1'],
};
let fileNoArgsfetchOp = {
selections: '',
......
......@@ -20,9 +20,7 @@ import reminderAgent from'@ohos.reminderAgent';
## reminderAgent.publishReminder<sup>(deprecated)</sup>
```ts
publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback\<number>): void
```
Publishes a reminder through the reminder agent. This API uses an asynchronous callback to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8).
......@@ -39,7 +37,7 @@ Publishes a reminder through the reminder agent. This API uses an asynchronous c
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| reminderReq | [ReminderRequest](#reminderrequest) | Yes| Reminder to be published.|
| callback | AsyncCallback\<number\> | Yes| Callback used to return the published reminder's ID.|
| callback | AsyncCallback\<number> | Yes| Callback used to return the published reminder's ID.|
**Example**
```ts
......@@ -56,9 +54,7 @@ Publishes a reminder through the reminder agent. This API uses an asynchronous c
## reminderAgent.publishReminder<sup>(deprecated)</sup>
```ts
publishReminder(reminderReq: ReminderRequest): Promise\<number>
```
Publishes a reminder through the reminder agent. This API uses a promise to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8).
......@@ -78,7 +74,7 @@ Publishes a reminder through the reminder agent. This API uses a promise to retu
**Return value**
| Type| Description|
| -------- | -------- |
| Promise\<number\> | Promise used to return the published reminder's ID.|
| Promise\<number> | Promise used to return the published reminder's ID.|
**Example**
```ts
......@@ -95,9 +91,7 @@ Publishes a reminder through the reminder agent. This API uses a promise to retu
## reminderAgent.cancelReminder<sup>(deprecated)</sup>
```ts
cancelReminder(reminderId: number, callback: AsyncCallback\<void>): void
```
Cancels the reminder with the specified ID. This API uses an asynchronous callback to return the cancellation result.
......@@ -112,7 +106,7 @@ Cancels the reminder with the specified ID. This API uses an asynchronous callba
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| reminderId | number | Yes| ID of the reminder to cancel. The value is obtained by calling [publishReminder](#reminderagentpublishreminder).|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Example**
......@@ -125,9 +119,7 @@ reminderAgent.cancelReminder(1, (err, data) => {
## reminderAgent.cancelReminder<sup>(deprecated)</sup>
```ts
cancelReminder(reminderId: number): Promise\<void>
```
Cancels the reminder with the specified ID. This API uses a promise to return the cancellation result.
......@@ -147,7 +139,7 @@ Cancels the reminder with the specified ID. This API uses a promise to return th
| Type| Description|
| -------- | -------- |
| Promise\<void\> | Promise used to return the result.|
| Promise\<void> | Promise used to return the result.|
**Example**
......@@ -159,9 +151,7 @@ reminderAgent.cancelReminder(1).then(() => {
## reminderAgent.getValidReminders<sup>(deprecated)</sup>
```ts
getValidReminders(callback: AsyncCallback\<Array\<ReminderRequest>>): void
```
Obtains all valid (not yet expired) reminders set by the current application. This API uses an asynchronous callback to return the reminders.
......@@ -175,7 +165,7 @@ Obtains all valid (not yet expired) reminders set by the current application. Th
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback\<Array\<[ReminderRequest](#reminderrequest)\>\> | Yes| Callback used to return an array of all valid reminders set by the current application.|
| callback | AsyncCallback\<Array\<[ReminderRequest](#reminderrequest)>> | Yes| Callback used to return an array of all valid reminders set by the current application.|
**Example**
......@@ -209,9 +199,7 @@ reminderAgent.getValidReminders((err, reminders) => {
## reminderAgent.getValidReminders<sup>(deprecated)</sup>
```ts
getValidReminders(): Promise\<Array\<ReminderRequest>>
```
Obtains all valid (not yet expired) reminders set by the current application. This API uses a promise to return the reminders.
......@@ -225,7 +213,7 @@ Obtains all valid (not yet expired) reminders set by the current application. Th
| Type| Description|
| -------- | -------- |
| Promise\<Array\<[ReminderRequest](#reminderrequest)\>\> | Promise used to return an array of all valid reminders set by the current application.|
| Promise\<Array\<[ReminderRequest](#reminderrequest)>> | Promise used to return an array of all valid reminders set by the current application.|
**Example**
......@@ -259,9 +247,7 @@ reminderAgent.getValidReminders().then((reminders) => {
## reminderAgent.cancelAllReminders<sup>(deprecated)</sup>
```ts
cancelAllReminders(callback: AsyncCallback\<void>): void
```
Cancels all reminders set by the current application. This API uses an asynchronous callback to return the cancellation result.
......@@ -275,7 +261,7 @@ Cancels all reminders set by the current application. This API uses an asynchron
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Example**
......@@ -288,9 +274,7 @@ reminderAgent.cancelAllReminders((err, data) =>{
## reminderAgent.cancelAllReminders<sup>(deprecated)</sup>
```ts
cancelAllReminders(): Promise\<void>
```
Cancels all reminders set by the current application. This API uses a promise to return the cancellation result.
......@@ -304,7 +288,7 @@ Cancels all reminders set by the current application. This API uses a promise to
| Type| Description|
| -------- | -------- |
| Promise\<void\> | Promise used to return the result.|
| Promise\<void> | Promise used to return the result.|
**Example**
......@@ -316,9 +300,7 @@ reminderAgent.cancelAllReminders().then(() => {
## reminderAgent.addNotificationSlot<sup>(deprecated)</sup>
```ts
addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback\<void>): void
```
Adds a notification slot. This API uses an asynchronous callback to return the result.
......@@ -333,7 +315,7 @@ Adds a notification slot. This API uses an asynchronous callback to return the r
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| slot | [NotificationSlot](js-apis-notification.md#notificationslot) | Yes| Notification slot, whose type can be set.|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Example**
......@@ -351,9 +333,7 @@ reminderAgent.addNotificationSlot(mySlot, (err, data) => {
## reminderAgent.addNotificationSlot<sup>(deprecated)</sup>
```ts
addNotificationSlot(slot: NotificationSlot): Promise\<void>
```
Adds a notification slot. This API uses a promise to return the result.
......@@ -373,7 +353,7 @@ Adds a notification slot. This API uses a promise to return the result.
| Type| Description|
| -------- | -------- |
| Promise\<void\> | Promise used to return the result.|
| Promise\<void> | Promise used to return the result.|
**Example**
......@@ -391,9 +371,7 @@ reminderAgent.addNotificationSlot(mySlot).then(() => {
## reminderAgent.removeNotificationSlot<sup>(deprecated)</sup>
```ts
removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback<void>): void
```
Removes a notification slot of a specified type. This API uses an asynchronous callback to return the result.
......@@ -408,7 +386,7 @@ Removes a notification slot of a specified type. This API uses an asynchronous c
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| slotType | [notification.SlotType](js-apis-notification.md#slottype) | Yes| Type of the reminder notification slot to remove.|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Example**
......@@ -423,9 +401,7 @@ reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION,
## reminderAgent.removeNotificationSlot<sup>(deprecated)</sup>
```ts
removeNotificationSlot(slotType: notification.SlotType): Promise<void>
```
Removes a notification slot of a specified type. This API uses a promise to return the result.
......@@ -445,7 +421,7 @@ Removes a notification slot of a specified type. This API uses a promise to retu
| Type| Description|
| -------- | -------- |
| Promise\<void\> | Promise used to return the result.|
| Promise\<void> | Promise used to return the result.|
**Example**
......@@ -568,7 +544,6 @@ Defines the reminder to publish.
## ReminderRequestCalendar<sup>(deprecated)</sup>
ReminderRequestCalendar extends ReminderRequest
Defines a reminder for a calendar event.
......@@ -581,13 +556,12 @@ Defines a reminder for a calendar event.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| dateTime | [LocalDateTime](#localdatetime) | Yes| Reminder time.|
| repeatMonths | Array\<number\> | No| Month in which the reminder repeats.|
| repeatDays | Array\<number\> | No| Date on which the reminder repeats.|
| repeatMonths | Array\<number> | No| Month in which the reminder repeats.|
| repeatDays | Array\<number> | No| Date on which the reminder repeats.|
## ReminderRequestAlarm<sup>(deprecated)</sup>
ReminderRequestAlarm extends ReminderRequest
Defines a reminder for an alarm.
......@@ -601,13 +575,11 @@ Defines a reminder for an alarm.
| -------- | -------- | -------- | -------- |
| hour | number | Yes| Hour portion of the reminder time.|
| minute | number | Yes| Minute portion of the reminder time.|
| daysOfWeek | Array\<number\> | No| Days of a week when the reminder repeats. The value ranges from 1 to 7, corresponding to the data from Monday to Sunday.|
| daysOfWeek | Array\<number> | No| Days of a week when the reminder repeats. The value ranges from 1 to 7, corresponding to the data from Monday to Sunday.|
## ReminderRequestTimer<sup>(deprecated)</sup>
ReminderRequestTimer extends ReminderRequest
Defines a reminder for a scheduled timer.
> **NOTE**
......
......@@ -170,7 +170,7 @@ Cancels the reminder with the specified ID. This API uses a promise to return th
| Type| Description|
| -------- | -------- |
| PPromise\<void> | Promise used to return the result.|
| Promise\<void> | Promise used to return the result.|
**Error codes**
......@@ -611,7 +611,7 @@ Defines the reminder to publish.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| reminderType | [ReminderType](#remindertype) | Yes| Type of the reminder.|
| actionButton<sup>10+</sup> | [ActionButton](#actionbutton) | No| Button displayed for the reminder in the notification panel. For common applications, a maximum of two buttons are supported. For system applications, a maximum of two buttons are supported in API version 9, and a maximum of three buttons are supported in API version 10 and later versions. |
| actionButton<sup>10+</sup> | [ActionButton](#actionbutton) | No| Button displayed for the reminder in the notification panel. For common applications, a maximum of two buttons are supported. For system applications, a maximum of two buttons are supported in API version 9, and a maximum of three buttons are supported in API version 10 and later versions.|
| wantAgent | [WantAgent](#wantagent) | No| Information about the ability that is redirected to when the reminder is clicked.|
| maxScreenWantAgent | [MaxScreenWantAgent](#maxscreenwantagent) | No| Information about the ability that is automatically started when the reminder arrives. If the device is in use, a notification will be displayed.|
| ringDuration | number | No| Ringing duration, in seconds. The default value is **1**.|
......
# @ohos.multimedia.systemSoundManager (System Sound Management)
The **systemSoundManager** module provides basic capabilities for managing system sounds, including setting and obtaining system ringtones and obtaining a player to play the system ringtone.
> **NOTE**
>
> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.
## Modules to Import
```js
import systemSoundManager from '@ohos.multimedia.systemSoundManager';
```
## RingtoneType
Enumerates the ringtone types.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
| Name | Value | Description |
| ------------------------------- | ------ | -------------------------------------------- |
| RINGTONE_TYPE_DEFAULT | 0 | Default ringtone type. |
| RINGTONE_TYPE_MULTISIM | 1 | Multi-SIM ringtone type. |
## systemSoundManager.getSystemSoundManager
getSystemSoundManager(): SystemSoundManager
Obtains a system sound manager.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Return value**
| Type | Description |
| ----------------------------- | ------------ |
| [SystemSoundManager](#systemsoundmanager) | System sound manager obtained.|
**Example**
```js
let systemSoundManagerInstance = systemSoundManager.getSystemSoundManager();
```
## SystemSoundManager
Provides APIs to manage system sounds. Before calling any API in **SystemSoundManager**, you must use [getSystemSoundManager](#systemsoundmanagergetsystemsoundmanager) to create a **SystemSoundManager** instance.
### setSystemRingtoneUri
setSystemRingtoneUri(context: Context, uri: string, type: RingtoneType, callback: AsyncCallback&lt;void&gt;): void
Sets a URI for the system ringtone. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | ------------------------ |
| context | Context | Yes | Application context. |
| uri | string | Yes | URI of the system ringtone. For details, see [media.AVPlayer](js-apis-media.md#avplayer9).|
| type | [RingtoneType](#ringtonetype) | Yes | Type of the system ringtone. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
let context = this.context;
let uri = 'file://data/test.wav'; // Set the URI of the target ringtone file.
let type = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
systemSoundManagerInstance.setSystemRingtoneUri(context, uri, type, (err) => {
if (err) {
console.error(`Failed to set system ringtone uri. ${err}`);
return;
}
console.info(`Callback invoked to indicate a successful setting of the system ringtone uri.`);
});
```
### setSystemRingtoneUri
setSystemRingtoneUri(context: Context, uri: string, type: RingtoneType): Promise&lt;void&gt;
Sets a URI for the system ringtone. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | ------------------------ |
| context | Context | Yes | Application context. |
| uri | string | Yes | URI of the system ringtone. For details, see [media.AVPlayer](js-apis-media.md#avplayer9).|
| type | [RingtoneType](#ringtonetype) | Yes | Type of the system ringtone. |
**Return value**
| Type | Description |
| ------------------- | ------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result. |
**Example**
```js
let context = this.context;
let uri = 'file://data/test.wav'; // Set the URI of the target ringtone file.
let type = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
systemSoundManagerInstance.setSystemRingtoneUri(context, uri, type).then(() => {
console.info(`Promise returned to indicate a successful setting of the system ringtone uri.`);
}).catch ((err) => {
console.error(`Failed to set the system ringtone uri ${err}`);
});
```
### getSystemRingtoneUri
getSystemRingtoneUri(context: Context, type: RingtoneType, callback: AsyncCallback&lt;string&gt;): void
Obtains the URI of a system ringtone. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | ------------------------ |
| context | Context | Yes | Application context. |
| type | [RingtoneType](#ringtonetype) | Yes | Type of the system ringtone. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the ringtone URI obtained.|
**Example**
```js
let context = this.context;
let type = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
systemSoundManagerInstance.getSystemRingtoneUri(context, type, (err, value) => {
if (err) {
console.error(`Failed to get system ringtone uri. ${err}`);
return;
}
console.info(`Callback invoked to indicate the value of the system ringtone uri is obtained ${value}.`);
});
```
### getSystemRingtoneUri
getSystemRingtoneUri(context: Context, type: RingtoneType): Promise&lt;string&gt;
Obtains the URI of a system ringtone. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | ------------------------ |
| context | Context | Yes | Application context. |
| type | [RingtoneType](#ringtonetype) | Yes | Type of the system ringtone. |
**Return value**
| Type | Description |
| ------------------- | ---------------------------------- |
| Promise&lt;string&gt; | Promise used to return the ringtone URI obtained.|
**Example**
```js
let context = this.context;
let type = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
systemSoundManagerInstance.getSystemRingtoneUri(context, type).then((value) => {
console.info(`Promise returned to indicate that the value of the system ringtone uri is obtained ${value}.`);
}).catch ((err) => {
console.error(`Failed to get the system ringtone uri ${err}`);
});
```
### getSystemRingtonePlayer
getSystemRingtonePlayer(context: Context, type: RingtoneType, callback: AsyncCallback&lt;RingtonePlayer&gt;): void
Obtains a player to play the system ringtone. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -----------------------------------------| ---- | --------------------------- |
| context | Context | Yes | Application context. |
| type | [RingtoneType](#ringtonetype) | Yes | Type of the system ringtone.|
| callback | AsyncCallback&lt;[RingtonePlayer](js-apis-inner-multimedia-ringtonePlayer.md#ringtoneplayer)&gt; | Yes| Callback used to return the ringtone player obtained.|
**Example**
```js
let context = this.context;
let type = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
let systemRingtonePlayer = null;
systemSoundManagerInstance.getSystemRingtonePlayer(context, type, (err, value) => {
if (err) {
console.error(`Failed to get system ringtone player. ${err}`);
return;
}
console.info(`Callback invoked to indicate the value of the system ringtone player is obtained.`);
systemRingtonePlayer = value;
});
```
### getSystemRingtonePlayer
getSystemRingtonePlayer(context: Context, type: RingtoneType): Promise&lt;RingtonePlayer&gt;
Obtains a player to play the system ringtone. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -----------------------------------------| ---- | --------------------------- |
| context | Context | Yes | Application context. |
| type | [RingtoneType](#ringtonetype) | Yes | Type of the system ringtone.|
**Return value**
| Type | Description |
| ------------------- | ------------------------------- |
| Promise&lt;[RingtonePlayer](js-apis-inner-multimedia-ringtonePlayer.md#ringtoneplayer)&gt; | Promise used to return the ringtone player obtained.|
**Example**
```js
let context = this.context;
let type = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
let systemRingtonePlayer = null;
systemSoundManagerInstance.getSystemRingtonePlayer(context, type).then((value) => {
console.info(`Promise returned to indicate that the value of the system ringtone player is obtained.`);
systemRingtonePlayer = value;
}).catch ((err) => {
console.error(`Failed to get the system ringtone player ${err}`);
});
```
# @ohos.taskpool (Using the Task Pool)
# @ohos.taskpool (Starting the Task Pool)
The task pool provides a multi-thread running environment for applications. It helps reduce resource consumption and improve system performance. It also frees you from caring about the lifecycle of thread instances. You can use the **TaskPool** APIs to create background tasks and perform operations on them, for example, executing or canceling a task. Theoretically, you can create an unlimited number of tasks, but this is not recommended for memory considerations. In addition, you are not advised performing blocking operations in a task, especially indefinite blocking. Long-time blocking operations occupy worker threads and may block other task scheduling, adversely affecting your application performance.
You can determine the execution sequence of tasks with the same priority. They are executed in the same sequence as you call the task execution APIs. The default task priority is **MEDIUM**. (The task priority mechanism is not supported yet.)
You can determine the execution sequence of tasks with the same priority. They are executed in the same sequence as you call the task execution APIs. The default task priority is **MEDIUM**.
If the number of tasks to be executed is greater than the number of worker threads in the task pool, the task pool scales out based on load balancing to minimize the waiting duration. Similarly, when the number of tasks to be executed falls below the number of worker threads, the task pool scales in to reduce the number of worker threads. (The load balancing mechanism is not supported yet.)
If the number of tasks to be executed is greater than the number of worker threads in the task pool, the task pool scales out based on load balancing to minimize the waiting duration. Similarly, when the number of tasks to be executed falls below the number of worker threads, the task pool scales in to reduce the number of worker threads.
The **TaskPool** APIs return error codes in numeric format. For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
......@@ -32,13 +32,13 @@ Enumerates the priorities available for created tasks.
**Example**
```ts
function func(args) {
"use concurrent";
console.log("func: " + args);
@Concurrent
function printArgs(args) {
console.log("printArgs: " + args);
return args;
}
async function taskpoolTest() {
let task = new taskpool.Task(func, 100);
async function taskpoolPriority() {
let task = new taskpool.Task(printArgs, 100);
let highCount = 0;
let mediumCount = 0;
......@@ -65,7 +65,7 @@ async function taskpoolTest() {
})
}
}
taskpoolTest();
taskpoolPriority();
```
## Task
......@@ -99,12 +99,12 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
```ts
@Concurrent
function func(args) {
console.log("func: " + args);
function printArgs(args) {
console.log("printArgs: " + args);
return args;
}
let task = new taskpool.Task(func, "this is my first Task");
let task = new taskpool.Task(printArgs, "this is my first Task");
```
### Attributes
......@@ -151,17 +151,17 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
```ts
@Concurrent
function func(args) {
console.log("func: " + args);
function printArgs(args) {
console.log("printArgs: " + args);
return args;
}
async function taskpoolTest() {
let value = await taskpool.execute(func, 100);
async function taskpoolExecute() {
let value = await taskpool.execute(printArgs, 100);
console.log("taskpool result: " + value);
}
taskpoolTest();
taskpoolExecute();
```
## taskpool.execute
......@@ -199,18 +199,18 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
```ts
@Concurrent
function func(args) {
console.log("func: " + args);
function printArgs(args) {
console.log("printArgs: " + args);
return args;
}
async function taskpoolTest() {
let task = new taskpool.Task(func, 100);
async function taskpoolExecute() {
let task = new taskpool.Task(printArgs, 100);
let value = await taskpool.execute(task);
console.log("taskpool result: " + value);
}
taskpoolTest();
taskpoolExecute();
```
## taskpool.cancel
......@@ -239,14 +239,14 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
**Example of successful task cancellation**
```ts
function func(args) {
"use concurrent";
console.log("func: " + args);
@Concurrent
function printArgs(args) {
console.log("printArgs: " + args);
return args;
}
async function taskpoolTest() {
let task = new taskpool.Task(func, 100);
async function taskpoolCancel() {
let task = new taskpool.Task(printArgs, 100);
taskpool.execute(task);
try {
taskpool.cancel(task);
......@@ -255,20 +255,20 @@ async function taskpoolTest() {
}
}
taskpoolTest();
taskpoolCancel();
```
**Example of a failure to cancel a task that has been executed**
```ts
function func(args) {
"use concurrent";
console.log("func: " + args);
@Concurrent
function printArgs(args) {
console.log("printArgs: " + args);
return args;
}
async function taskpoolTest() {
let task = new taskpool.Task(func, 100);
async function taskpoolCancel() {
let task = new taskpool.Task(printArgs, 100);
let value = taskpool.execute(task);
let start = new Date().getTime();
while (new Date().getTime() - start < 1000) {// Wait for 1s to ensure that the task has been executed.
......@@ -282,25 +282,25 @@ async function taskpoolTest() {
}
}
taskpoolTest();
taskpoolCancel();
```
**Example of a failure to cancel an ongoing task**
```ts
function func(args) {
"use concurrent";
console.log("func: " + args);
@Concurrent
function printArgs(args) {
console.log("printArgs: " + args);
return args;
}
async function taskpoolTest() {
let task1 = new taskpool.Task(func, 100);
let task2 = new taskpool.Task(func, 200);
let task3 = new taskpool.Task(func, 300);
let task4 = new taskpool.Task(func, 400);
let task5 = new taskpool.Task(func, 500);
let task6 = new taskpool.Task(func, 600);
async function taskpoolCancel() {
let task1 = new taskpool.Task(printArgs, 100);
let task2 = new taskpool.Task(printArgs, 200);
let task3 = new taskpool.Task(printArgs, 300);
let task4 = new taskpool.Task(printArgs, 400);
let task5 = new taskpool.Task(printArgs, 500);
let task6 = new taskpool.Task(printArgs, 600);
let res1 = taskpool.execute(task1);
let res2 = taskpool.execute(task2);
......@@ -315,7 +315,7 @@ async function taskpoolTest() {
}
}
taskpoolTest();
taskpoolCancel();
```
## Additional Information
......@@ -327,7 +327,7 @@ The following sequenceable data types are supported: All Primitive Type (excludi
- The task pool APIs can be used only in the module with **compileMode** set to **esmodule** in the stage model. To check the **compileMode** setting of a module, open the **build-profile.json5** file of the module and check for **"compileMode": "esmodule"** under **buildOption**.
- A task in the task pool can reference only variables passed in by input parameters or imported variables, rather than closure variables. The decorator **@Concurrent** is used to intercept unsupported variables.
- A task in the task pool supports only common functions or async functions, rather than class member functions or anonymous functions. The decorator **@Concurrent** is used to intercept unsupported functions.
- The decorator **@Concurrent** can be used only in the .ets file. To create a task in the task pool in the .ts file, use the statement **use concurrent**.
- The decorator **@Concurrent** can be used only in .ets files.
### Using the Task Pool in Simple Mode
......@@ -336,23 +336,23 @@ The following sequenceable data types are supported: All Primitive Type (excludi
```ts
// Common functions are supported, and variables passed in by input parameters are also supported.
@Concurrent
function func(args) {
function printArgs(args) {
console.log("func: " + args);
return args;
}
async function taskpoolTest() {
async function taskpoolExecute() {
// taskpool.execute(task)
let task = new taskpool.Task(func, "create task, then execute");
let task = new taskpool.Task(printArgs, "create task, then execute");
let val1 = await taskpool.execute(task);
console.log("taskpool.execute(task) result: " + val1);
// taskpool.execute(function)
let val2 = await taskpool.execute(func, "execute task by func");
let val2 = await taskpool.execute(printArgs, "execute task by func");
console.log("taskpool.execute(function) result: " + val2);
}
taskpoolTest();
taskpoolExecute();
```
**Example 2**
......@@ -367,24 +367,24 @@ export var c = 2000;
import { c } from "./b";
@Concurrent
function test(a) {
function printArgs(a) {
console.log(a);
console.log(c);
return a;
}
async function taskpoolTest() {
async function taskpoolExecute() {
// taskpool.execute(task)
let task = new taskpool.Task(test, "create task, then execute");
let task = new taskpool.Task(printArgs, "create task, then execute");
let val1 = await taskpool.execute(task);
console.log("taskpool.execute(task) result: " + val1);
// taskpool.execute(function)
let val2 = await taskpool.execute(test, "execute task by func");
let val2 = await taskpool.execute(printArgs, "execute task by func");
console.log("taskpool.execute(function) result: " + val2);
}
taskpoolTest();
taskpoolExecute();
```
**Example 3**
......@@ -392,57 +392,52 @@ taskpoolTest();
```ts
// The async functions are supported.
@Concurrent
async function task() {
async function delayExcute() {
let ret = await Promise.all([
new Promise(resolve => setTimeout(resolve, 1000, "resolved"))
]);
return ret;
}
async function taskpoolTest() {
taskpool.execute(task).then((result) => {
async function taskpoolExecute() {
taskpool.execute(delayExcute).then((result) => {
console.log("TaskPoolTest task result: " + result);
});
}
taskpoolTest();
taskpoolExecute();
```
**Example 4**
```ts
// Use use concurrent to create a task in the task pool in the .ts file.
// c.ts
function test1(n) {
"use concurrent"
return n;
// c.ets
@Concurrent
function strSort(inPutArr) {
let newArr = inPutArr.sort();
return newArr;
}
export async function taskpoolTest1() {
console.log("taskpoolTest1 start");
var task = new taskpool.Task(test1, 100);
export async function func1() {
console.log("taskpoolTest start");
let strArray = ['c test string', 'b test string', 'a test string'];
var task = new taskpool.Task(strSort, strArray);
var result = await taskpool.execute(task);
console.log("taskpoolTest1 result:" + result);
console.log("func1 result:" + result);
}
async function test2() {
"use concurrent"
var ret = await Promise.all([
new Promise(resolve => setTimeout(resolve, 1000, "resolved"))
]);
return ret;
}
export async function taskpoolTest2() {
export async function func2() {
console.log("taskpoolTest2 start");
taskpool.execute(test2).then((result) => {
console.log("TaskPoolTest2 result: " + result);
let strArray = ['c test string', 'b test string', 'a test string'];
taskpool.execute(strSort, strArray).then((result) => {
console.log("func2 result: " + result);
});
}
```
```ts
/ / a.ets (in the same directory as c.ts)
/ / a.ets (in the same directory as c.ets)
import { taskpoolTest1, taskpoolTest2 } from "./c";
taskpoolTest1();
taskpoolTest2();
func1();
func2();
```
# Blank
The **\<Blank>** component is able to automatically fill the empty spaces in the container along the main axis. It is valid only when the parent container is **\<Row>** or **\<Column>**.
The **\<Blank>** component is able to automatically fill the empty spaces in the container along the main axis. It works only when the parent component is **\<Row>**, **\<Column>**, or **\<Flex>**.
> **NOTE**
>
......@@ -30,7 +30,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| Name| Type| Description|
| -------- | -------- | -------- |
| color | [ResourceColor](ts-types.md#resourcecolor) | Color to fill the empty spaces.<br>Default value: **Color.Transparent**<br>Since API version 9, this API is supported in ArkTS widgets. |
| color | [ResourceColor](ts-types.md#resourcecolor) | Color to fill the empty spaces.<br>Default value: **Color.Transparent**<br>Since API version 9, this API is supported in ArkTS widgets.|
## Events
......@@ -50,7 +50,7 @@ struct BlankExample {
Row() {
Text('Bluetooth').fontSize(18)
Blank()
Toggle({ type: ToggleType.Switch })
Toggle({ type: ToggleType.Switch }).margin({ top: 14, bottom: 14, left: 6, right: 6 })
}.width('100%').backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 })
}.backgroundColor(0xEFEFEF).padding(20)
}
......@@ -80,14 +80,14 @@ struct BlankExample {
Row() {
Text('Bluetooth').fontSize(18)
Blank().color(Color.Yellow)
Toggle({ type: ToggleType.Switch })
Toggle({ type: ToggleType.Switch }).margin({ top: 14, bottom: 14, left: 6, right: 6 })
}.backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 })
Row() {
Text('Bluetooth').fontSize(18)
// Set the minimum width to 160.
Blank('160').color(Color.Yellow)
Toggle({ type: ToggleType.Switch })
Toggle({ type: ToggleType.Switch }).margin({ top: 14, bottom: 14, left: 6, right: 6 })
}.backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 })
}.backgroundColor(0xEFEFEF).padding(20).width('100%')
......
......@@ -29,7 +29,7 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory | Description |
| ---- | ---------------------------------------- | ---- | ---------------------------------------- |
| src | [PixelMap](../apis/js-apis-image.md#pixelmap7) \|ResourceStr\| [DrawableDescriptor](../apis/js-apis-arkui-drawableDescriptor.md#drawabledescriptor) | Yes | Image source. Both local and online images are supported.<br>When using an image referenced using a relative path, for example, **Image("common/test.jpg")**, the **\<Image>** component cannot be called across bundles or modules. Therefore, you are advised to use **\$r** to reference image resources that need to be used globally.<br>- The following image formats are supported: PNG, JPG, BMP, SVG, GIF.<br>\- Base64 strings are supported. The value format is data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data], where [base64 data] is a Base64 string.<br/>\- Strings with the **datashare://** path prefix are supported, which are used to access the image path provided by a Data ability.<br/>\- Strings with the **file:///data/storage** prefix are supported, which are used to read image resources in the **files** folder in the installation directory of the application. Ensure that the application has the read permission to the files in the specified path.<br/>\- [DrawableDescriptor](../apis/js-apis-arkui-drawableDescriptor.md#drawabledescriptor) objects are supported.<br/>**NOTE**<br/>- ArkTS widgets support GIF images, but the images are played only once when they are displayed.<br/>- ArkTS widgets do not support the **http://**, **datashare://**, or **file://data/storage** path prefixes.<br>- ArkTS widgets do not support the [PixelMap](../apis/js-apis-image.md#pixelmap7) type.|
| src | [PixelMap](../apis/js-apis-image.md#pixelmap7) \| ResourceStr\| [DrawableDescriptor](../apis/js-apis-arkui-drawableDescriptor.md#drawabledescriptor) | Yes | Image source. Both local and online images are supported.<br>When using an image referenced using a relative path, for example, **Image("common/test.jpg")**, the **\<Image>** component cannot be called across bundles or modules. Therefore, you are advised to use **\$r** to reference image resources that need to be used globally.<br>- The following image formats are supported: PNG, JPG, BMP, SVG, GIF.<br>\- Base64 strings are supported. The value format is data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data], where [base64 data] is a Base64 string.<br/>\- Strings with the **datashare://** prefix are supported, which are used to access the image path provided by a Data ability.<br/>\- Strings with the **file:///data/storage** prefix are supported, which are used to read image resources in the **files** folder in the installation directory of the current application. Ensure that the application has the read permission to the files in the specified path.<br/>\- [DrawableDescriptor](../apis/js-apis-arkui-drawableDescriptor.md#drawabledescriptor) objects are supported.<br/>- For details, see [Displaying Images](../../ui/arkts-graphics-display.md).<br/>**NOTE**<br/>- ArkTS widgets support GIF animations, but the animations only play once on display.<br/>- ArkTS widgets do not support the strings with the **http://**, **datashare://**, or **file:///data/storage** prefix.<br>- ArkTS widgets do not support the [PixelMap](../apis/js-apis-image.md#pixelmap7) type.|
## Attributes
......@@ -56,7 +56,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
>
> To use shortcut keys to copy the image, the image must be in focus. To enable the image to gain focus, set both the **focusable** and **focusOnTouch** attributes to **true**.
>
> For SVG images, only the following tags are included in the supported list: **svg**, **rect**, **circle**, **ellipse**, **path**, **line**, **polyline**, **polygon**, and **animate**.
> For SVG images, only the following tags are included in the supported list: **svg**, **rect**, **circle**, **ellipse**, **path**, **line**, **polyline**, and **polygon**.
### ImageInterpolation
......@@ -94,6 +94,8 @@ In addition to the [universal events](ts-universal-events-click.md), the followi
Load and display different types of images and set the scale mode of the images.
The **overlay** attribute sets the mask text of an image. For details, see [Overlay](ts-universal-attributes-overlay.md).
```ts
@Entry
@Component
......@@ -416,4 +418,86 @@ struct LoadImageExample {
}
}
```
<!--no_check-->
\ No newline at end of file
### Applying a Filter to an Image
```ts
// xxx.ets
@Entry
@Component
struct colorFilterExample {
@State colorFilterR: number = 0
@State colorFilterG: number = 0
@State colorFilterB: number = 0
@State colorFilterA: number = 0
build() {
Row() {
Column() {
Image($r('app.media.sky'))
.width(200)
.height(200)
Image($r('app.media.sky'))
.width(200)
.height(200)
.colorFilter([
this.colorFilterR, 0, this.colorFilterR, 0, 0,
0, this.colorFilterG, this.colorFilterG, 0, 0,
this.colorFilterB, 0, this.colorFilterB, 0, 0,
0, 0, this.colorFilterA, 0, 0
])
Row() {
Text('R')
Slider({
min: 0,
max: 1,
step: 0.01
})
.onChange((valueR) => {
this.colorFilterR = valueR
})
}
Row() {
Text('G')
Slider({
min: 0,
max: 1,
step: 0.01
})
.onChange((valueG) => {
this.colorFilterG = valueG
})
}
Row() {
Text('B')
Slider({
min: 0,
max: 1,
step: 0.01
})
.onChange((valueB) => {
this.colorFilterB = valueB
})
}
Row() {
Text('A')
Slider({
min: 0,
max: 1,
step: 0.01
})
.onChange((valueA) => {
this.colorFilterA = valueA
})
}
}.width('90%').alignItems(HorizontalAlign.Center)
}.height('100%').width('100%').justifyContent(FlexAlign.Center)
}
}
```
![colorFilter](figures/colorFilter.gif)
......@@ -24,7 +24,7 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | string | Yes| Content of the QR code. A maximum of 256 characters are supported. If the number of characters exceeds 256, the first 256 characters are used.|
| value | string | Yes| Content of the QR code. A maximum of 256 characters are supported. If the number of characters exceeds 256, the first 256 characters are used.<br>**NOTE**<br>The string cannot be **null**, **undefined**, or empty.|
## Attributes
......
......@@ -260,9 +260,11 @@ struct WaterflowDemo {
Text("N" + item).fontSize(12).height('16')
Image('res/waterFlowTest(' + item % 5 + ').jpg')
.objectFit(ImageFit.Fill)
.width('100%')
.layoutWeight(1)
}
}
.width(this.itemWidthArray[item])
.width('100%')
.height(this.itemHeightArray[item])
.backgroundColor(this.colors[item % 5])
}, item => item)
......
......@@ -11,16 +11,24 @@ The size attributes set the width, height, and margin of a component.
| Name | Type | Description |
| -------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| -------------- | ---------------------------------------- | ---------------------------------------- |
| width | [Length](ts-types.md#length) | Width of the component. By default, the width required to fully hold the component content is used. If the width of the component is greater than that of the parent container, the range of the parent container is drawn.<br>Since API version 9, this API is supported in ArkTS widgets.<br>Since API version 10, this API supports the calc calculation feature.|
| height | [Length](ts-types.md#length) | Height of the component. By default, the height required to fully hold the component content is used. If the height of the component is greater than that of the parent container, the range of the parent container is drawn.<br>Since API version 9, this API is supported in ArkTS widgets.<br>Since API version 10, this API supports the calc calculation feature.|
| size | {<br>width?: [Length](ts-types.md#length),<br>height?: [Length](ts-types.md#length)<br>} | Size of the component.<br>Since API version 9, this API is supported in ArkTS widgets.<br>Since API version 10, this API supports the calc calculation feature.|
| padding | [Padding](ts-types.md#padding) \| [Length](ts-types.md#length) | Padding of the component.<br>When the parameter is of the **Length** type, the four paddings take effect.<br>Default value: **0**<br>When **padding** is set to a percentage, the width of the parent container is used as the basic value.<br>Since API version 9, this API is supported in ArkTS widgets.<br>Since API version 10, this API supports the calc calculation feature.|
| margin | [Margin](ts-types.md#margin) \| [Length](ts-types.md#length) | Margin of the component.<br>When the parameter is of the **Length** type, the four margins take effect.<br>Default value: **0**<br>When **margin** is set to a percentage, the width of the parent container is used as the basic value.<br>Since API version 9, this API is supported in ArkTS widgets.<br>Since API version 10, this API supports the calc calculation feature.|
| constraintSize | {<br>minWidth?: [Length](ts-types.md#length),<br>maxWidth?: [Length](ts-types.md#length),<br>minHeight?: [Length](ts-types.md#length),<br>maxHeight?: [Length](ts-types.md#length)<br>} | Constraint size of the component, which is used to limit the size range during component layout. **constraintSize** takes precedence over **width** and **height**. If the value of **minWidth** is greater than that of **maxWidth**, only the value of **minWidth** takes effect. The same rule applies to **minHeight** and **maxHeight**.<br>Default value:<br>{<br>minWidth: 0,<br>maxWidth: Infinity,<br>minHeight: 0,<br>maxHeight: Infinity<br>}<br>Since API version 9, this API is supported in ArkTS widgets.<br>Since API version 10, this API supports the calc calculation feature.|
| layoutWeight | number \| string | Weight of the component during layout. When the container size is determined, the container space is allocated along the main axis among the component and sibling components based on the layout weight, and the component size setting is ignored.<br>Default value: **0**<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>This attribute is valid only for the **\<Row>**, **\<Column>**, and **\<Flex>** layouts.<br>The value can be a number greater than or equal to 0 or a string that can be converted to a number.|
| constraintSize | {<br>minWidth?: [Length](ts-types.md#length),<br>maxWidth?: [Length](ts-types.md#length),<br>minHeight?: [Length](ts-types.md#length),<br>maxHeight?: [Length](ts-types.md#length)<br>} | Constraint size of the component, which is used to limit the size range during component layout. **constraintSize** takes precedence over **width** and **height**. Learn [how the value of this attribute affects the width and height](#impact-of-constraintsize-on-widthheight).<br>Default value:<br>{<br>minWidth: 0,<br>maxWidth: Infinity,<br>minHeight: 0,<br>maxHeight: Infinity<br>}<br>Since API version 9, this API is supported in ArkTS widgets.<br>Since API version 10, this API supports the calc calculation feature.|
## Impact of constraintSize on width/height
| Size Arrangement | Result |
| ---------------------------------------- | ------------------ |
| minWidth/minHeight < width/height< maxWidth/maxHeight | width/height |
| minWidth/minHeight < maxWidth/maxHeight < width/height | maxWidth/maxHeight |
| maxWidth/maxHeight < minWidth/minHeight < width/height | minWidth/minHeight |
| maxWidth/maxHeight < width/height< minWidth/minHeight | minWidth/minHeight |
| width/height < maxWidth/maxHeight < minWidth/minHeight | minWidth/minHeight |
| width/height < minWidth/minHeight < maxWidth/maxHeight | minWidth/minHeight |
## Example
```ts
......
# Standard Libraries Supported by Native APIs
- [Node_API](third_party_napi/napi.md)
- [libc](third_party_libc/musl.md)
- [Node-API](third_party_napi/napi.md)
- [libuv](third_party_libuv/libuv.md)
- [Native Standard Libraries Supported by Openharmony](third_party_libc/musl.md)
- [OpenSL ES](third_party_opensles/opensles.md)
- Appendix
- [Native API Symbols Not Exported](third_party_libc/musl-peculiar-symbol.md)
- [Native API Symbols That May Fail to Be Invoked Due to Permission Control](third_party_libc/musl-permission-control-symbol.md)
......
......@@ -774,8 +774,8 @@
- [Shape](reference/arkui-ts/ts-drawing-components-shape.md)
- Canvas Components
- [Canvas](reference/arkui-ts/ts-components-canvas-canvas.md)
- [CanvasRenderingContext2D](reference/arkui-ts/ts-canvasrenderingcontext2d.md)
- [CanvasGradient](reference/arkui-ts/ts-components-canvas-canvasgradient.md)
- [CanvasRenderingContext2D](reference/arkui-ts/ts-canvasrenderingcontext2d.md)
- [ImageBitmap](reference/arkui-ts/ts-components-canvas-imagebitmap.md)
- [ImageData](reference/arkui-ts/ts-components-canvas-imagedata.md)
- [OffscreenCanvasRenderingConxt2D](reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md)
......@@ -1185,6 +1185,9 @@
- [@ohos.multimedia.camera (Camera Management)](reference/apis/js-apis-camera.md)
- [@ohos.multimedia.image (Image Processing)](reference/apis/js-apis-image.md)
- [@ohos.multimedia.media (Media)](reference/apis/js-apis-media.md)
- [@ohos.multimedia.systemSoundManager (System Sound Management)](reference/apis/js-apis-systemSoundManager.md)
- multimedia
- [ringtonePlayer (Ringtone Player)](reference/apis/js-apis-inner-multimedia-ringtonePlayer.md)
- Resource Manager
- [@ohos.i18n (Internationalization)](reference/apis/js-apis-i18n.md)
- [@ohos.intl (Internationalization)](reference/apis/js-apis-intl.md)
......@@ -1285,6 +1288,7 @@
- [@ohos.InputMethodExtensionAbility (InputMethodExtensionAbility)](reference/apis/js-apis-inputmethod-extension-ability.md)
- [@ohos.InputMethodExtensionContext (InputMethodExtensionContext)](reference/apis/js-apis-inputmethod-extension-context.md)
- [@ohos.InputMethodSubtype (Input Method Subtype)](reference/apis/js-apis-inputmethod-subtype.md)
- [@ohos.logLibrary (Log Library)](reference/apis/js-apis-loglibrary.md)
- [@ohos.pasteboard (Pasteboard)](reference/apis/js-apis-pasteboard.md)
- [@ohos.screenLock (Screenlock)](reference/apis/js-apis-screen-lock.md)
- [@ohos.systemDateTime (System Time and Time Zone)](reference/apis/js-apis-system-date-time.md)
......@@ -1315,6 +1319,7 @@
- [@ohos.multimodalInput.mouseEvent (Mouse Event)](reference/apis/js-apis-mouseevent.md)
- [@ohos.multimodalInput.pointer (Mouse Pointer)](reference/apis/js-apis-pointer.md)
- [@ohos.multimodalInput.touchEvent (Touch Event)](reference/apis/js-apis-touchevent.md)
- [@ohos.multimodalInput.shortKey (Shortcut Key)](reference/apis/js-apis-shortKey.md)
- [@ohos.power (System Power Management)](reference/apis/js-apis-power.md)
- [@ohos.runningLock (Runninglock)](reference/apis/js-apis-runninglock.md)
- [@ohos.sensor (Sensor)](reference/apis/js-apis-sensor.md)
......@@ -1494,6 +1499,7 @@
- [Application Event Logging Error Codes](reference/errorcodes/errorcode-hiappevent.md)
- [HiSysEvent Error Codes](reference/errorcodes/errorcode-hisysevent.md)
- [HiDebug Error Codes](reference/errorcodes/errorcode-hiviewdfx-hidebug.md)
- [Log Library Error Codes](reference/errorcodes/errorcode-loglibrary.md)
- [Input Method Framework Error Codes](reference/errorcodes/errorcode-inputmethod-framework.md)
- [Pasteboard Error Codes](reference/errorcodes/errorcode-pasteboard.md)
- [Screen Lock Management Error Codes](reference/errorcodes/errorcode-screenlock.md)
......@@ -1615,7 +1621,7 @@
- [OH_Huks_PubKeyInfo](reference/native-apis/_o_h___huks___pub_key_info.md)
- [OH_Huks_Result](reference/native-apis/_o_h___huks___result.md)
- Standard Libraries Supported by Native APIs
- [Node_API](reference/native-lib/third_party_napi/napi.md)
- [Node-API](reference/native-lib/third_party_napi/napi.md)
- [libuv](reference/native-lib/third_party_libuv/libuv.md)
- [Native Standard Libraries Supported by Openharmony](reference/native-lib/third_party_libc/musl.md)
- Appendix
......@@ -1649,4 +1655,3 @@
- [SDK Usage](faqs/faqs-sdk.md)
- [Usage of Third- and Fourth-Party Libraries](faqs/faqs-third-fourth-party-library.md)
<!--no_check-->
\ No newline at end of file
......@@ -12,14 +12,14 @@
| 2 | Upload path | Upload markdown files to **docs/en/application-dev/reference/apis**.<br>Upload images to **docs/en/application-dev/reference/apis/figures**. In addition, reference the image path in the markdown file as follows: **![](figures/exampleImage.jpg)**, **![](figures/exampleImage.png)**, or **![](figures/exampleImage.gif)**.|
| 3 | File name | Provide one JS API reference document for each d.ts file. Name the file in the format of **js-apis-exampleModule.md**, where **exampleModule** is a variable and must be the same as the actual module name.<br>Examples:<br>For @ohos.multimedia.audio in the Multimedia subsystem, the JS API file name is **js-apis-audio.md**.<br>For @ohos.telephony.sms in the Telephony subsystem, the JS API file name is **js-apis-sms.md**.|
| 4 | Directory update | After uploading an API reference document, update the **Readme-EN.md** file in **docs/en/application-dev/reference/apis**.<br>The directories are automatically arranged in alphabetical order.|
| 5 | Document structure | - Module description<br>- Initial version description<br>- Modules to Import/Usage description<br>- API description (attributes, constants, methods, enums, and custom types)<br> The order in which APIs are described in the document must be consistent with that in which they appear in the code. If some APIs have a logical sequence, pay attention to their sequence in the API reference document. |
| 6 | Initial version description | 1. Use the greater-than sign (**>**) followed by a space to indent the description about the initial version of the module. Unless otherwise marked, all APIs in the module have the same initial version.<br>2. When introducing an API to an existing module, use the **<sup>** tag to mark its earliest version. The format is **<sup>versionNumber+</sup>**, for example, **<sup>7+</sup>**.<br>If an attribute is added to an existing module, suffix the **<sup>** tag to the new attribute name, for example, **newAttribute<sup>7+</sup>**.<br>If a method is added to an existing module, suffix the **<sup>** tag to the method name, for example, **sim.getSimIccId<sup>7+</sup>**. The same rule applies to new interfaces, classes, and enums. |
| 5 | Document structure | - Module description<br>- Initial version description<br>- Modules to Import/Usage description<br>- API description (attributes, constants, methods, enums, and custom types)<br> The order in which APIs are described in the document must be consistent with that in which they appear in the code. If some APIs have a logical sequence, pay attention to their sequence in the API reference document.|
| 6 | Initial version description | 1. Use the greater-than sign (**>**) followed by a space to indent the description about the initial version of the module. Unless otherwise marked, all APIs in the module have the same initial version.<br>2. When introducing an API to an existing module, use the **<sup>** tag to mark its earliest version. The format is **<sup>versionNumber+</sup>**, for example, **<sup>7+</sup>**.<br>If an attribute is added to an existing module, suffix the **<sup>** tag to the new attribute name, for example, **newAttribute<sup>7+</sup>**.<br>If a method is added to an existing module, suffix the **<sup>** tag to the method name, for example, **sim.getSimIccId<sup>7+</sup>**. The same rule applies to new interfaces, classes, and enums.|
| 7 | Deprecated API description | Do not delete the deprecated content from the document. Instead, suffix **deprecated** as a superscript to the content, and use the greater-than sign (**>**) to introduce the initial version and deprecated version.<br>Example: abandonmentMethod<sup>(deprecated)</sup><br>> This API is supported since API version 4 and deprecated since API version 7. You are advised to use [newMethod]\(#newmethod) instead.|
| 8 | Permission description | Provide the same permission description as that defined in the code for each method, enum, and attribute.<br>1. If a specific permission required for using the API can be requested only by system applications, provide the description in the following format:<br>**Required permissions**: ohos.permission.examplePermission (available only to system applications)<br>2. If a specific permission required for using the API can be requested by all applications, provide the description in the following format:<br>**Required permissions**: ohos.permission.examplePermission<br>3. If multiple permissions are required for using the API, provide the permissions with **and** or **or** in the following format:<br>**Required permissions**: ohos.permission.examplePermissionA and ohos.permission.examplePermissionB<br>**Required permissions**: ohos.permission.examplePermissionA or ohos.permission.examplePermissionB |
| 9 | @syscap | 1. Provide a description for every API in the following format, wherein *A.B* indicates a specific system capability.<br>**System capability**: SystemCapability.*A.B*<br>2. There are two cases for adding system capability information to a table (of attributes, enums, constants, or variables).<br>1) If all the items in a table require the same system capability, add the following information to the front of the table:<br>**System capability**: SystemCapability.*A.B*<br>2) If the items in a table require different system capabilities, list the system capability for each item in the table. |
| 8 | Permission description | Provide the same permission description as that defined in the code for each method, enum, and attribute.<br> 1. If only one permission is required for using the API, use the following format:<br>**Required permissions**: ohos.permission.examplePermission<br>2. If multiple permissions are required for using the API, provide the permissions with **and** or **or** in the following format:<br>**Required permissions**: ohos.permission.examplePermissionA and ohos.permission.examplePermissionB<br> **Required permissions**: ohos.permission.examplePermissionA or ohos.permission.examplePermissionB |
| 9 | @syscap | 1. Provide a description for every API in the following format, wherein *A.B* indicates a specific system capability.<br> **System capability**: SystemCapability.*A.B*<br>2. There are two cases for adding system capability information to a table (of attributes, enums, constants, or variables).<br> 1) If all the items in a table require the same system capability, add the following information to the front of the table:<br> **System capability**: SystemCapability.*A.B*<br> 2) If the items in a table require different system capabilities, list the system capability for each item in the table.|
| 10 | @system api | 1. If all APIs of the module are system APIs, add the following sentence to the next line of the initial version description:<br>The APIs provided by this module are system APIs.<br>2. If an API is a system API that can be used only by original equipment manufacturers (OEMs), add the following sentence to the API description:<br>**System API**: This is a system API.|
| 11 | @FAModelOnly<br>@StageModelOnly | 1. If a module is implemented only for a specific ability model, add the following sentence to the next line of the initial version description:<br>The APIs of this module can be used only in the FA model.<br>Or<br>The APIs of this module can be used only in the stage model.<br>2. If an API is implemented only for a specific ability model, add the following sentence to the API description:<br>**Model restriction**: This API can be used only in the FA model.<br/>Or<br/>**Model restriction**: This API can be used only in the stage model.|
| 12 | Asynchronous methods (callback and promise)| Use the following sentences for callback methods.<br>Method introduction: *Describe the method.* This API uses an asynchronous callback to return the result.<br>Parameter description:<br>**callback\<boolean>**: Callback used to return the result. The value **true** indicates *something*, and **false** indicates the opposite.<br>**callback\<Object>**: Callback used to return *something*. Example: Callback used to return the **AudioCapturer** object. <br>**AsyncCallback\<void>**: Callback used to return the result. If the operation (or a specific operation description) is successful, **err** is **undefined**; otherwise, **err** is an error object.<br>**AsyncCallback\<Object x>**: Callback used to return the result. If the operation (or a specific operation description) is successful, **err** is **undefined** and **data** is the *x* object obtained; otherwise, **err** is an error object.<br>Use the following sentences for promise methods.<br>Method introduction: *Describe the method.* This API uses a promise to return the result.<br>Parameter description:<br>**Promise\<boolean>**: Promise used to return the result. The value **true** indicates *something*, and **false** indicates the opposite.<br>**Promise\<Object>**: Promise used to return *something*. Example: Promise used to return the **AudioCapturer** object. <br>**Promise\<void>**: Promise that returns no value. |
| 12 | Asynchronous methods (callback and promise)| Use the following sentences for callback methods.<br>Method introduction: *Describe the method.* This API uses an asynchronous callback to return the result.<br>Parameter description:<br>**callback\<boolean>**: Callback used to return the result. The value **true** indicates *something*, and **false** indicates the opposite.<br>**callback\<Object>**: Callback used to return *something*. Example: Callback used to return the **AudioCapturer** object. <br>**AsyncCallback\<void>**: Callback used to return the result. If the operation (or a specific operation description) is successful, **err** is **undefined**; otherwise, **err** is an error object.<br>**AsyncCallback\<Object x>**: Callback used to return the result. If the operation (or a specific operation description) is successful, **err** is **undefined** and **data** is the *x* object obtained; otherwise, **err** is an error object.<br>Use the following sentences for promise methods.<br>Method introduction: *Describe the method.* This API uses a promise to return the result.<br>Parameter description:<br>**Promise\<boolean>**: Promise used to return the result. The value **true** indicates *something*, and **false** indicates the opposite.<br>**Promise\<Object>**: Promise used to return *something*. Example: Promise used to return the **AudioCapturer** object. <br>**Promise\<void>**: Promise that returns no value.|
| 13 | Sample code programming language | Use code blocks to provide sample code and mark the programming language.<br>Use **js** as the mark if both JS and eTS can be used, and use **ts** if only eTS can be used.|
| 14 | Link | Link format: [Link text]\(Link content)<br>Cross-folder link format: [markdown file name]\(\.\./../xxx/xxx.md). One **../** indicates one upper-level folder.<br>Intra-topic link format: [Interface A<sup>7+</sup>]\(#xxxa7). The text in the intra-topic link must be the same as the title to be linked. In the link, all letters must be in lowercase, and no special character (except the hyphen) or tag is included.|
......@@ -146,7 +146,7 @@ Describe the method. For details, see the fourth and fifth points in "Writing In
**System API**: This is a system API. (Delete this part if it is not involved.)
**Required permissions**: ohos.permission.examplePermission (Delete this part if no permission is involved. If a system permission is required, specify it.)
**Required permissions**: ohos.permission.examplePermission (Delete this part if no permission is involved.)
**System capability**: SystemCapability.*A.B* (This part is mandatory.)
......@@ -161,7 +161,7 @@ Describe the method. For details, see the fourth and fifth points in "Writing In
| Type | Description |
| ------------------------------------------ | ----------------------------------------------- |
| string | Describe the return value, for example, what can be done after the return value is obtained.|
| string | Describe the return value from the following aspects:<br>1. What can be done after the return value is obtained.<br>2. If the return values can be enumerated, describe the meaning of the return values.<br>3. If the return value is a specific value or format, keeyp the value or format consistent with the actual implementation. |
| Promise\<Array<[CustomType](#classinterface)>> | Describe the return value. For details about how to write promise methods, see item 14 in "General Writing Instructions."|
**Error codes** (This part is optional. Delete it if no error code is thrown.)
......@@ -211,7 +211,7 @@ Describe the method. For details, see the fourth and fifth points in "Writing In
**System API**: This is a system API. (Delete this part if it is not involved.)
**Required permissions**: ohos.permission.examplePermission (Delete this part if no permission is involved. If a system permission is required, specify it.)
**Required permissions**: ohos.permission.examplePermission (Delete this part if no permission is involved.)
**System capability**: SystemCapability.*A.B* (This part is mandatory.)
......@@ -219,7 +219,7 @@ Describe the method. For details, see the fourth and fifth points in "Writing In
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Describe the event and when or how it will be triggered. If a method involves multiple events, describe them separately.<br>**Example 1 (single event):**<br>Type of the event. The **'play'** event is triggered when the **play()** API is called and audio playback starts.<br>Example 2 (multiple events):<br>Type of the event. The following events are supported:<br/>- **'play'**: triggered when the **play()** API is called and audio playback starts.<br>- **'dataLoad'**: triggered when the audio data is loaded, that is, when the **src** attribute is configured.<br>- **'finish'**: triggered when the audio playback is finished. |
| type | string | Yes | Describe the event and when or how it will be triggered. If a method involves multiple events, describe them separately.<br>**Example 1 (single event):**<br>Type of the event. The **'play'** event is triggered when the **play()** API is called and audio playback starts.<br>Example 2 (multiple events):<br>Type of the event. The following events are supported:<br>- **'play'**: triggered when the **play()** API is called and audio playback starts.<br>- **'dataLoad'**: triggered when the audio data is loaded, that is, when the **src** attribute is configured.<br>- **'finish'**: triggered when the audio playback is finished.|
| callback | Callback\<[CustomType](#classinterface)> | No | Describe the parameter. The instructions are the same as those provided under [Methods](#methods). |
**Return value** (This part is optional. Delete it if there is no return value.)
......@@ -262,7 +262,7 @@ Describe the class or interface. If there are usage restrictions, describe them
> *Writing Instructions*
>
> Except that level-3 headings are used, other requirements are the same as those in [Attribute](#attributes).
> Except that level-3 headings are used, other requirements are the same as those in [Attributes](#attributes).
### Methods in Classes/Interfaces
......
......@@ -94,7 +94,7 @@ struct FancyUse {
Text('FancyA')
.globalFancy ()
.fontSize(30)
// 使用全局的@Styles封装的样式
// 使用组件内的@Styles封装的样式
Text('FancyB')
.fancy()
.fontSize(30)
......
......@@ -913,3 +913,15 @@ Wi-Fi P2P群组信息已更改。
## [COMMON_EVENT_QUICK_FIX_REVOKE_RESULT<sup>10+<sup>](./common_event/commonEvent-ability.md#common_event_quick_fix_revoke_result10)
指示撤销快速修复的动作。
## [COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGIN](./common_event/commonEvent-account.md)
(预留事件,暂未支持)表示分布式帐号登录成功的动作。
## [COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT](./common_event/commonEvent-account.md)
(预留事件,暂未支持)表示分布式帐号登出成功的动作。
## [COMMON_EVENT_DISTRIBUTED_ACCOUNT_TOKEN_INVALID](./common_event/commonEvent-account.md)
(预留事件,暂未支持)表示分布式帐号token令牌无效的动作。
## [COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOFF](./common_event/commonEvent-account.md)
(预留事件,暂未支持)表示分布式帐号注销的动作。
\ No newline at end of file
......@@ -6,7 +6,7 @@
>
> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
> 该模块不支持在[UIAbility](./js-apis-app-ability-uiAbility.md)中使用。
> 该模块不支持在[UIAbility](./js-apis-app-ability-uiAbility.md)中使用,需要在创建组件实例后使用
## 导入模块
......
......@@ -5,8 +5,6 @@
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
> 本模块接口为系统接口。
## 导入模块
......
......@@ -6,7 +6,7 @@
>
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
>
> 该模块不支持在[UIAbility](./js-apis-app-ability-uiAbility.md)中使用。
> 该模块不支持在[UIAbility](./js-apis-app-ability-uiAbility.md)中使用,需要在创建组件实例后使用
## 导入模块
......
......@@ -6,7 +6,7 @@
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
> 该模块不支持在[UIAbility](./js-apis-app-ability-uiAbility.md)中使用。
> 该模块不支持在[UIAbility](./js-apis-app-ability-uiAbility.md)中使用,需要在创建组件实例后使用
## 导入模块
......
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册