提交 7e16e8ef 编写于 作者: H HelloCrease

Merge branch 'OpenHarmony-3.2-Release' of https://gitee.com/HelloCrease/docs...

Merge branch 'OpenHarmony-3.2-Release' of https://gitee.com/HelloCrease/docs into OpenHarmony-3.2-Release
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
- ExtensionAbility Component - ExtensionAbility Component
- [ExtensionAbility Component Overview](extensionability-overview.md) - [ExtensionAbility Component Overview](extensionability-overview.md)
- [ServiceExtensionAbility](serviceextensionability.md) - [ServiceExtensionAbility](serviceextensionability.md)
- [DataShareExtensionAbility (for System Applications Only)](datashareextensionability.md)
- [AccessibilityExtensionAbility](accessibilityextensionability.md) - [AccessibilityExtensionAbility](accessibilityextensionability.md)
- [EnterpriseAdminExtensionAbility](enterprise-extensionAbility.md) - [EnterpriseAdminExtensionAbility](enterprise-extensionAbility.md)
- [InputMethodExtensionAbility](inputmethodextentionability.md) - [InputMethodExtensionAbility](inputmethodextentionability.md)
...@@ -37,9 +36,9 @@ ...@@ -37,9 +36,9 @@
- [Applying Custom Drawing in the Widget](arkts-ui-widget-page-custom-drawing.md) - [Applying Custom Drawing in the Widget](arkts-ui-widget-page-custom-drawing.md)
- Widget Event Development - Widget Event Development
- [Widget Event Capability Overview](arkts-ui-widget-event-overview.md) - [Widget Event Capability Overview](arkts-ui-widget-event-overview.md)
- [Redirecting to a Specified Page Through the Router Event](arkts-ui-widget-event-router.md)
- [Updating Widget Content Through FormExtensionAbility](arkts-ui-widget-event-formextensionability.md) - [Updating Widget Content Through FormExtensionAbility](arkts-ui-widget-event-formextensionability.md)
- [Updating Widget Content Through UIAbility](arkts-ui-widget-event-uiability.md) - [Updating Widget Content Through UIAbility](arkts-ui-widget-event-uiability.md)
- [Redirecting to a Specified Page Through the Router Event](arkts-ui-widget-event-router.md)
- Widget Data Interaction - Widget Data Interaction
- [Widget Data Interaction Overview](arkts-ui-widget-interaction-overview.md) - [Widget Data Interaction Overview](arkts-ui-widget-interaction-overview.md)
- [Configuring a Widget to Update Periodically](arkts-ui-widget-update-by-time.md) - [Configuring a Widget to Update Periodically](arkts-ui-widget-update-by-time.md)
...@@ -61,8 +60,9 @@ ...@@ -61,8 +60,9 @@
- [Continuation Overview](inter-device-interaction-hop-overview.md) - [Continuation Overview](inter-device-interaction-hop-overview.md)
- [Cross-Device Migration (for System Applications Only)](hop-cross-device-migration.md) - [Cross-Device Migration (for System Applications Only)](hop-cross-device-migration.md)
- [Multi-device Collaboration (for System Applications Only)](hop-multi-device-collaboration.md) - [Multi-device Collaboration (for System Applications Only)](hop-multi-device-collaboration.md)
- IPC - [Subscribing to System Environment Variable Changes](subscribe-system-environment-variable-changes.md)
- [Process Model](process-model-stage.md) - Process Model
- [Process Model Overview](process-model-stage.md)
- Common Events - Common Events
- [Introduction to Common Events](common-event-overview.md) - [Introduction to Common Events](common-event-overview.md)
- Common Event Subscription - Common Event Subscription
...@@ -72,14 +72,16 @@ ...@@ -72,14 +72,16 @@
- [Unsubscribing from Common Events](common-event-unsubscription.md) - [Unsubscribing from Common Events](common-event-unsubscription.md)
- [Publishing Common Events](common-event-publish.md) - [Publishing Common Events](common-event-publish.md)
- [Background Services](background-services.md) - [Background Services](background-services.md)
- Inter-Thread Communication - Thread Model
- [Thread Model](thread-model-stage.md) - [Thread Model Overview](thread-model-stage.md)
- [Using Emitter for Inter-Thread Communication](itc-with-emitter.md) - [Using Emitter for Inter-Thread Communication](itc-with-emitter.md)
- [Using Worker for Inter-Thread Communication](itc-with-worker.md) - [Using Worker for Inter-Thread Communication](itc-with-worker.md)
- Mission Management - Mission Management
- [Mission Management Scenarios](mission-management-overview.md) - [Mission Management Scenarios](mission-management-overview.md)
- [Mission Management and Launch Type](mission-management-launch-type.md) - [Mission Management and Launch Type](mission-management-launch-type.md)
- [Page Stack and MissionList](page-mission-stack.md) - [Page Stack and MissionList](page-mission-stack.md)
- [Setting the Icon and Name of a Mission Snapshot](mission-set-icon-name-for-task-snapshot.md)
- [Application Configuration File (Stage Model)](config-file-stage.md)
- FA Model Development - FA Model Development
- [FA Model Development Overview](fa-model-development-overview.md) - [FA Model Development Overview](fa-model-development-overview.md)
- FA Mode Application Components - FA Mode Application Components
...@@ -116,12 +118,12 @@ ...@@ -116,12 +118,12 @@
- [Context](application-context-fa.md) - [Context](application-context-fa.md)
- [Want](want-fa.md) - [Want](want-fa.md)
- [Component Startup Rules](component-startup-rules-fa.md) - [Component Startup Rules](component-startup-rules-fa.md)
- IPC - Process Model
- [Process Model](process-model-fa.md) - [Process Model Overview](process-model-fa.md)
- [Common Events](common-event-fa.md) - [Common Events](common-event-fa.md)
- [Background Services](rpc.md) - [Background Services](rpc.md)
- Inter-Thread Communication - Thread Model
- [Thread Model](thread-model-fa.md) - [Thread Model Overview](thread-model-fa.md)
- [Inter-Thread Communication](itc-fa-overview.md) - [Inter-Thread Communication](itc-fa-overview.md)
- [Mission Management](mission-management-fa.md) - [Mission Management](mission-management-fa.md)
- Development of Component Interaction Between the FA Model and Stage Model - Development of Component Interaction Between the FA Model and Stage Model
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
Generally, local images or online images downloaded from the network need to be displayed on a widget. To obtain local and online images, use the FormExtensionAbility. The following exemplifies how to show local and online images on a widget. Generally, local images or online images downloaded from the network need to be displayed on a widget. To obtain local and online images, use the FormExtensionAbility. The following exemplifies how to show local and online images on a widget.
1. Internet access is required for downloading online images. Therefore, you need to apply for the **ohos.permission.INTERNET** permission. For details, see[Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md). 1. Internet access is required for downloading online images. Therefore, you need to apply for the **ohos.permission.INTERNET** permission. For details, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md).
2. Update local files in the **onAddForm** lifecycle callback of the EntryFormAbility. 2. Update local files in the **onAddForm** lifecycle callback of the EntryFormAbility.
......
# Application Configuration File (Stage Model)
The application configuration file contains information about the application configuration, application components, and permissions, as well as custom information. The information will be provided for the compiler, application market, and operating system in the build, distribution, and running phases.
The application project code developed based on the stage model contains one **app.json5** file and one or more **module.json5** files. For details about common configuration items, see [Application- or Component-Level Configuration (Stage Model)](application-component-configuration-stage.md). For details about the two files, see [Application Configuration File Overview (Stage Model)](../quick-start/application-configuration-file-overview-stage.md).
...@@ -11,13 +11,13 @@ The following describes how the mission list manager manages the UIAbility insta ...@@ -11,13 +11,13 @@ The following describes how the mission list manager manages the UIAbility insta
![mission-and-singleton](figures/mission-and-singleton.png) ![mission-and-singleton](figures/mission-and-singleton.png)
- **multiton**: Each time **startAbility()** is called, a **UIAbility** instance is created in the application process. - **multiton**: Each time [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is called, a UIAbility instance is created in the application process.
**Figure 2** Missions and multiton mode **Figure 2** Missions and multiton mode
![mission-and-multiton](figures/mission-and-standard.png) ![mission-and-multiton](figures/mission-and-multiton.png)
- **specified**: The ([onAcceptWant()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonacceptwant)) method of [AbilityStage](abilitystage.md) determines whether to create an instance. - **specified**: The ([onAcceptWant()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonacceptwant)) method of [AbilityStage](abilitystage.md) determines whether to create a UIAbility instance.
**Figure 3** Missions and specified mode **Figure 3** Missions and specified mode
...@@ -33,4 +33,3 @@ Every mission retains a snapshot of the UIAbility instance. After the UIAbility ...@@ -33,4 +33,3 @@ Every mission retains a snapshot of the UIAbility instance. After the UIAbility
> **NOTE** > **NOTE**
> >
> The **specified** mode is supported in the stage model only. > The **specified** mode is supported in the stage model only.
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
Before getting started with the development of mission management, be familiar with the following concepts related to mission management: Before getting started with the development of mission management, be familiar with the following concepts related to mission management:
- AbilityRecord: minimum unit for the system service to manage a UIAbility instance. It corresponds to a UIAbility component instance of an application. - AbilityRecord: minimum unit for the system service to manage a UIAbility instance. It corresponds to a UIAbility component instance of an application. A maximum of 512 UIAbility instances can be managed on the system service side.
- MissionRecord: minimum unit for mission management. One MissionRecord has only one AbilityRecord. In other words, a UIAbility component instance corresponds to a mission. - MissionRecord: minimum unit for mission management. One MissionRecord has only one AbilityRecord. In other words, a UIAbility component instance corresponds to a mission.
...@@ -13,7 +13,6 @@ Before getting started with the development of mission management, be familiar w ...@@ -13,7 +13,6 @@ Before getting started with the development of mission management, be familiar w
- MissionListManager: system mission management module that maintains all the MissionLists and is consistent with the list in **Recents**. - MissionListManager: system mission management module that maintains all the MissionLists and is consistent with the list in **Recents**.
**Figure 1** Mission management **Figure 1** Mission management
![mission-list-manager](figures/mission-list-manager.png) ![mission-list-manager](figures/mission-list-manager.png)
...@@ -29,102 +28,102 @@ Missions are managed by system applications (such as home screen), rather than t ...@@ -29,102 +28,102 @@ Missions are managed by system applications (such as home screen), rather than t
- Switch a mission to the foreground. - Switch a mission to the foreground.
A UIAbility instance corresponds to an independent mission. Therefore, when an application calls **startAbility()** to start a UIAbility, a mission is created. A UIAbility instance corresponds to an independent mission. Therefore, when an application calls [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) to start a UIAbility, a mission is created.
1. To call [missionManager](../reference/apis/js-apis-application-missionManager.md) to manage missions, the home screen application must request the **ohos.permission.MANAGE_MISSIONS** permission. For details about the configuration, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
To call [missionManager](../reference/apis/js-apis-application-missionManager.md) to manage missions, the home screen application must request the **ohos.permission.MANAGE_MISSIONS** permission. For details about the configuration, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
2. You can use **missionManager** to manage missions, for example, listening for mission changes, obtaining mission information or snapshots, and clearing, locking, or unlocking missions.
You can use **missionManager** to manage missions, for example, listening for mission changes, obtaining mission information or snapshots, and clearing, locking, or unlocking missions. The sample code is as follows: ```ts
import missionManager from '@ohos.app.ability.missionManager'
```ts
import missionManager from '@ohos.app.ability.missionManager' let listener = {
// Listen for mission creation.
let listener = { onMissionCreated: function (mission) {
// Listen for mission creation. console.info("--------onMissionCreated-------")
onMissionCreated: function (mission) { },
console.info("--------onMissionCreated-------") // Listen for mission destruction.
}, onMissionDestroyed: function (mission) {
// Listen for mission destruction. console.info("--------onMissionDestroyed-------")
onMissionDestroyed: function (mission) { },
console.info("--------onMissionDestroyed-------") // Listen for mission snapshot changes.
}, onMissionSnapshotChanged: function (mission) {
// Listen for mission snapshot changes. console.info("--------onMissionSnapshotChanged-------")
onMissionSnapshotChanged: function (mission) { },
console.info("--------onMissionSnapshotChanged-------") // Listen for switching the mission to the foreground.
}, onMissionMovedToFront: function (mission) {
// Listen for switching the mission to the foreground. console.info("--------onMissionMovedToFront-------")
onMissionMovedToFront: function (mission) { },
console.info("--------onMissionMovedToFront-------") // Listen for mission icon changes.
}, onMissionIconUpdated: function (mission, icon) {
// Listen for mission icon changes. console.info("--------onMissionIconUpdated-------")
onMissionIconUpdated: function (mission, icon) { },
console.info("--------onMissionIconUpdated-------") // Listen for mission name changes.
}, onMissionLabelUpdated: function (mission) {
// Listen for mission name changes. console.info("--------onMissionLabelUpdated-------")
onMissionLabelUpdated: function (mission) { },
console.info("--------onMissionLabelUpdated-------") // Listen for mission closure events.
}, onMissionClosed: function (mission) {
// Listen for mission closure events. console.info("--------onMissionClosed-------")
onMissionClosed: function (mission) { }
console.info("--------onMissionClosed-------") };
}
}; // 1. Register a mission change listener.
let listenerId = missionManager.on('mission', listener);
// 1. Register a mission change listener.
let listenerId = missionManager.on('mission', listener); // 2. Obtain the latest 20 missions in the system.
missionManager.getMissionInfos("", 20, (error, missions) => {
// 2. Obtain the latest 20 missions in the system. console.info("getMissionInfos is called, error.code = " + error.code);
missionManager.getMissionInfos("", 20, (error, missions) => { console.info("size = " + missions.length);
console.info("getMissionInfos is called, error.code = " + error.code); console.info("missions = " + JSON.stringify(missions));
console.info("size = " + missions.length); });
console.info("missions = " + JSON.stringify(missions));
}); // 3. Obtain the detailed information about a mission.
let missionId = 11; // The mission ID 11 is only an example.
// 3. Obtain the detailed information about a mission. let mission = missionManager.getMissionInfo("", missionId).catch(function (err) {
let missionId = 11; // The mission ID 11 is only an example. console.info(err);
let mission = missionManager.getMissionInfo("", missionId).catch(function (err) { });
console.info(err);
}); // 4. Obtain the mission snapshot.
missionManager.getMissionSnapShot("", missionId, (error, snapshot) => {
// 4. Obtain the mission snapshot. console.info("getMissionSnapShot is called, error.code = " + error.code);
missionManager.getMissionSnapShot("", missionId, (error, snapshot) => { console.info("bundleName = " + snapshot.ability.bundleName);
console.info("getMissionSnapShot is called, error.code = " + error.code); })
console.info("bundleName = " + snapshot.ability.bundleName);
}) // 5. Obtain the low-resolution mission snapshot.
missionManager.getLowResolutionMissionSnapShot("", missionId, (error, snapshot) => {
// 5. Obtain the low-resolution mission snapshot. console.info("getLowResolutionMissionSnapShot is called, error.code = " + error.code);
missionManager.getLowResolutionMissionSnapShot("", missionId, (error, snapshot) => { console.info("bundleName = " + snapshot.ability.bundleName);
console.info("getLowResolutionMissionSnapShot is called, error.code = " + error.code); })
console.info("bundleName = " + snapshot.ability.bundleName);
}) // 6. Lock or unlock the mission.
missionManager.lockMission(missionId).then(() => {
// 6. Lock or unlock the mission. console.info("lockMission is called ");
missionManager.lockMission(missionId).then(() => { });
console.info("lockMission is called ");
}); missionManager.unlockMission(missionId).then(() => {
console.info("unlockMission is called ");
missionManager.unlockMission(missionId).then(() => { });
console.info("unlockMission is called ");
}); // 7. Switch the mission to the foreground.
missionManager.moveMissionToFront(missionId).then(() => {
// 7. Switch the mission to the foreground. console.info("moveMissionToFront is called ");
missionManager.moveMissionToFront(missionId).then(() => { });
console.info("moveMissionToFront is called ");
}); // 8. Clear a single mission.
missionManager.clearMission(missionId).then(() => {
// 8. Clear a single mission. console.info("clearMission is called ");
missionManager.clearMission(missionId).then(() => { });
console.info("clearMission is called ");
}); // 9. Clear all missions.
missionManager.clearAllMissions().catch(function (err) {
// 9. Clear all missions. console.info(err);
missionManager.clearAllMissions().catch(function (err) { });
console.info(err);
}); // 10. Deregister the mission change listener.
missionManager.off('mission', listenerId, (error) => {
// 10. Deregister the mission change listener. console.info("unregisterMissionListener");
missionManager.off('mission', listenerId, (error) => { })
console.info("unregisterMissionListener"); ```
})
```
# Setting the Icon and Name of a Mission Snapshot
Setting a unique icon and name for each mission snapshot of an application helps you better manage the missions and functions of the application.
By default, the **icon** and **label** fields in the [abilities tag](../quick-start/module-configuration-file.md#abilities) of the [module.json5 file](../quick-start/module-configuration-file.md) are used to set the icon and label.
Figure 1 Mission snapshot of a UIAbility
![](figures/mission-list-recent.png)
You can also use [UIAbilityContext.setMissionIcon()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextsetmissionicon) and [UIAbilityContext.setMissionLabel()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextsetmissionlabel) to customize the icon and name for a mission snapshot. For example, for a UIAbility instance in multiton mode, you can configure the icon and name for each mission snapshot based on different functions.
This document describes the following operations:
- [Setting a Mission Snapshot Icon (for System Applications Only)](#setting-a-mission-snapshot-icon-for-system-applications-only)
- [Setting a Mission Snapshot Name](#setting-a-mission-snapshot-name)
## Setting a Mission Snapshot Icon (for System Applications Only)
Call [UIAbilityContext.setMissionIcon()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextsetmissionicon) to set the icon of a mission snapshot. The icon is an object of the [PixelMap](../reference/apis/js-apis-image.md#pixelmap7) type. For details about how to obtain the context, see [Obtaining the Context of UIAbility](uiability-usage.md#obtaining-the-context-of-uiability).
```ts
let imagePixelMap: PixelMap = undefined; // Obtain the PixelMap information.
this.context.setMissionIcon(imagePixelMap, (err) => {
console.error(`setMissionLabel failed, code is ${err.code}, message is ${err.message}`);
})
```
The display effect is shown below.
Figure 2 Mission snapshot icon
![](figures/mission-set-task-snapshot-icon.png)
## Setting a Mission Snapshot Name
Call [UIAbilityContext.setMissionLabel()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextsetmissionlabel) to set the name of a mission snapshot.
```ts
this.context.setMissionLabel('test').then(() => {
console.info('setMissionLabel succeeded.');
}).catch((err) => {
console.error(`setMissionLabel failed, code is ${err.code}, message is ${err.message}`);
});
```
The display effect is shown below.
Figure 3 Mission snapshot name
![](figures/mission-set-task-snapshot-label.png)
# Process Model (FA Model) # Process Model Overview (FA Model)
The OpenHarmony process model is shown below. The OpenHarmony process model is shown below.
......
# Process Model (Stage Model) # Process Model Overview (Stage Model)
The OpenHarmony process model is shown below. The OpenHarmony process model is shown below.
......
# Subscribing to System Environment Variable Changes
System environment variables are system settings (for example, the system language or screen direction) of a device that may change during the running of an application.
By subscribing to the changes of system environment variables, the application can detect the changes in a timely manner and process the changes accordingly, providing better user experience. For example, when the system language changes, the application can display the UI in the new language; when the user rotates the device to landscape or portrait mode, the application can re-arrange the UI to adapt to the new screen orientation and size.
The system environment variable changes are usually triggered by options in **Settings** or icons in **Control Panel**. For details about the system environment variables that support subscription, see [Configuration](../reference/apis/js-apis-app-ability-configuration.md).
In OpenHarmony, you can subscribe to system environment variable changes in the following ways:
- [Using ApplicationContext for Subscription](#using-applicationcontext-for-subscription)
- [Using AbilityStage for Subscription](#using-abilitystage-for-subscription)
- [Using UIAbility for Subscription](#using-uiability-for-subscription)
- [Using ExtensionAbility for Subscription](#using-extensionability-for-subscription)
## Using ApplicationContext for Subscription
[ApplicationContext](../reference/apis/js-apis-inner-application-applicationContext.md) provides an API for registering a callback function to subscribe to the system environment variable changes. It also provides an API for deregistration so you can release related resources when they are no longer needed.
1. Call **ApplicationContext.on(type: 'environment', callback: EnvironmentCallback)** to subscribe to changes in system environment variables. The code snippet below is used to subscribe to system language changes on a page.
```ts
import common from '@ohos.app.ability.common';
@Entry
@Component
struct Index {
private context = getContext(this) as common.UIAbilityContext;
private callbackId: number; // ID of the subscription for system environment variable changes.
subscribeConfigurationUpdate() {
let systemLanguage: string = this.context.config.language; // Obtain the system language in use.
// 1. Obtain an ApplicationContext object.
let applicationContext = this.context.getApplicationContext();
// 2. Subscribe to system environment variable changes through ApplicationContext.
let environmentCallback = {
onConfigurationUpdated(newConfig) {
console.info(`onConfigurationUpdated systemLanguage is ${systemLanguage}, newConfig: ${JSON.stringify(newConfig)}`);
if (this.systemLanguage !== newConfig.language) {
console.info(`systemLanguage from ${systemLanguage} changed to ${newConfig.language}`);
systemLanguage = newConfig.language; // Save the new system language as the system language in use, which will be used for comparison.
}
},
onMemoryLevel(level) {
console.info(`onMemoryLevel level: ${level}`);
}
}
this.callbackId = applicationContext.on('environment', environmentCallback);
}
// Page display.
build() {
// ...
}
}
```
2. Call **ApplicationContext.off(type: 'environment', callbackId: number)** to release the resources.
```ts
import common from '@ohos.app.ability.common';
@Entry
@Component
struct Index {
private context = getContext(this) as common.UIAbilityContext;
private callbackId: number; // ID of the subscription for system environment variable changes.
unsubscribeConfigurationUpdate() {
let applicationContext = this.context.getApplicationContext();
applicationContext.off('environment', this.callbackId);
}
// Page display.
build() {
// ...
}
}
```
## Using AbilityStage for Subscription
The AbilityStage component provides the [AbilityStage.onConfigurationUpdate()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonconfigurationupdate) callback for subscribing to system environment variable changes. This callback is invoked when a system environment variable changes. In this callback, the latest system environment configuration is obtained through the [Configuration](../reference/apis/js-apis-app-ability-configuration.md) object.
> **NOTE**
>
> - AbilityStage is not automatically generated in the default project of DevEco Studio. For details about how to create an AbilityStage file, see [AbilityStage Component Container](abilitystage.md).
> - The callback used to subscribe to system environment variable changes has the same lifecycle as the [AbilityStage](../reference/apis/js-apis-app-ability-abilityStage.md) instance and will be destroyed when the instance is destroyed.
The code snippet below uses the [AbilityStage.onConfigurationUpdate()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonconfigurationupdate) callback to subscribe to the system language changes.
```ts
import AbilityStage from '@ohos.app.ability.AbilityStage';
let systemLanguage: string; // System language in use.
export default class MyAbilityStage extends AbilityStage {
onCreate() {
systemLanguage = this.context.config.language; // Obtain the system language in use when the AbilityStage instance is loaded for the first time.
console.info(`systemLanguage is ${systemLanguage} `);
}
onConfigurationUpdate(newConfig) {
console.info(`onConfigurationUpdated systemLanguage is ${systemLanguage}, newConfig: ${JSON.stringify(newConfig)}`);
if (systemLanguage !== newConfig.language) {
console.info(`systemLanguage from ${systemLanguage} changed to ${newConfig.language}`);
systemLanguage = newConfig.language; // Save the new system language as the system language in use, which will be used for comparison.
}
}
}
```
## Using UIAbility for Subscription
The UIAbility component provides the **UIAbility.onConfigurationUpdate()** callback for subscribing to system environment variable changes. This callback is invoked when a system environment variable changes. In this callback, the latest system environment configuration is obtained through the [Configuration](../reference/apis/js-apis-app-ability-configuration.md) object, without restarting the UIAbility.
> **NOTE**
>
> The callback used to subscribe to system environment variable changes has the same lifecycle as the UIAbility instance and will be destroyed when the instance is destroyed.
The code snippet below uses the **onConfigurationUpdate()** callback to subscribe to the system language changes.
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
let systemLanguage: string; // System language in use.
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
systemLanguage = this.context.config.language; // Obtain the system language in use when the UIAbility instance is loaded for the first time.
console.info(`systemLanguage is ${systemLanguage} `);
}
onConfigurationUpdate(newConfig) {
console.info(`onConfigurationUpdated systemLanguage is ${systemLanguage}, newConfig: ${JSON.stringify(newConfig)}`);
if (systemLanguage !== newConfig.language) {
console.info(`systemLanguage from ${systemLanguage} changed to ${newConfig.language}`);
systemLanguage = newConfig.language; // Save the new system language as the system language in use, which will be used for comparison.
}
}
// ...
}
```
## Using ExtensionAbility for Subscription
The ExtensionAbility component provides the **onConfigurationUpdate()** callback for subscribing system environment variable changes. This callback is invoked when a system environment variable changes. In this callback, the latest system environment configuration is obtained through the [Configuration](../reference/apis/js-apis-app-ability-configuration.md) object.
> **NOTE**
>
> The callback used to subscribe to system environment variable changes has the same lifecycle as the ExtensionAbility instance and will be destroyed when the instance is destroyed.
The code snippet below uses FormExtensionAbility as an example to describe how to use the **onConfigurationUpdate()** callback to subscribe to system environment variable changes.
```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class EntryFormAbility extends FormExtensionAbility {
onConfigurationUpdate(newConfig) {
console.info(`newConfig is ${JSON.stringify(newConfig)}`);
}
// ...
}
```
# Thread Model (FA Model) # Thread Model Overview (FA Model)
There are three types of threads in the FA model: There are three types of threads in the FA model:
......
# Thread Model (Stage Model) # Thread Model Overview (Stage Model)
For an OpenHarmony application, each process has a main thread to provide the following functionalities: For an OpenHarmony application, each process has a main thread to provide the following functionalities:
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
## When to Use ## When to Use
According to big data statistics, in a typical cross-application data access scenario, applications are started nearly 83 times on average in a day. In a typical cross-application data access scenario, an application may be started multiple times.
To reduce the number of application startup times and improve the access speed, OpenHarmony provides the silent access feature, which allows direct access to the database without starting the data provider. To reduce the number of application startup times and improve the access speed, OpenHarmony provides the silent access feature, which allows direct access to the database without starting the data provider.
......
...@@ -6,7 +6,7 @@ The file of an application can be shared with another application based on the f ...@@ -6,7 +6,7 @@ The file of an application can be shared with another application based on the f
- You can also use **open()** of the ohos.file.fs module to share an application file with the specified permissions to another application based on the FD. After parsing the FD from **Want**, the target application can read and write the file by using **read()** and **write()** APIs of ohos.file.fs. - You can also use **open()** of the ohos.file.fs module to share an application file with the specified permissions to another application based on the FD. After parsing the FD from **Want**, the target application can read and write the file by using **read()** and **write()** APIs of ohos.file.fs.
You can use the related APIs to [share a file with another application](#sharing-a-file-with-another-application) or [use shared application files](#using-shared-application-files). You can use the related APIs to [share a file with another application](#sharing-a-file-with-another-application) or [use shared application files](#using-shared-files).
## File URI Specifications ## File URI Specifications
......
...@@ -20,6 +20,10 @@ The decorators described above can observe only the changes of the first layer. ...@@ -20,6 +20,10 @@ The decorators described above can observe only the changes of the first layer.
- Using \@Observed alone has no effect. Combined use with \@ObjectLink for two-way synchronization or with [\@Prop](arkts-prop.md) for one-way synchronization is required. - Using \@Observed alone has no effect. Combined use with \@ObjectLink for two-way synchronization or with [\@Prop](arkts-prop.md) for one-way synchronization is required.
## Restrictions
Using \@Observed to decorate a class changes the original prototype chain of the class. Using \@Observed and other class decorators to decorate the same class may cause problems.
## Decorator Description ## Decorator Description
| \@Observed Decorator| Description | | \@Observed Decorator| Description |
...@@ -212,7 +216,7 @@ Event handlers in **ViewB**: ...@@ -212,7 +216,7 @@ Event handlers in **ViewB**:
- this.b.a = new ClassA(0) and this.b = new ClassB(new ClassA(0)): Change to the \@State decorated variable **b** and its attributes. - this.b.a = new ClassA(0) and this.b = new ClassB(new ClassA(0)): Change to the \@State decorated variable **b** and its attributes.
- this.b.a.c = ... : Second change. [@State](arkts-state.md# observe the change) cannot observe the change of the second layer, but ClassA is decorated by \@Observed, and therefore the change of its attribute c can be observed by \@ObjectLink. - this.b.a.c = ... : Second change. [@State](arkts-state.md#observed-changes) cannot observe the change of the second layer, but ClassA is decorated by \@Observed, and therefore the change of its attribute c can be observed by \@ObjectLink.
Event handlers in **ViewA**: Event handlers in **ViewA**:
...@@ -296,7 +300,7 @@ struct ViewB { ...@@ -296,7 +300,7 @@ struct ViewB {
1. ForEach: The newly added Class A object is unknown to the **ForEach** [itemGenerator](arkts-rendering-control-foreach.md#api-description). The item builder of **ForEach** will be executed to create a **View A** component instance. 1. ForEach: The newly added Class A object is unknown to the **ForEach** [itemGenerator](arkts-rendering-control-foreach.md#api-description). The item builder of **ForEach** will be executed to create a **View A** component instance.
2. ViewA({ label: ViewA this.arrA[last], a: this.arrA[this.arrA.length-1] }): The last item of the array is changed. As a result, the second **View A** component instance is changed. For **ViewA({ label: ViewA this.arrA[first], a: this.arrA[0] })**, a change to the array does not trigger a change to the array item, so the first **View A** component instance is not refreshed. 2. ViewA({ label: ViewA this.arrA[last], a: this.arrA[this.arrA.length-1] }): The last item of the array is changed. As a result, the second **View A** component instance is changed. For **ViewA({ label: ViewA this.arrA[first], a: this.arrA[0] })**, a change to the array does not trigger a change to the array item, so the first **View A** component instance is not refreshed.
- this.arrA[Math.floor (this.arrA.length/2)].c: [@State] (arkts-state.md#observe-changes) cannot observe changes in the second layer. However, as **ClassA** is decorated by \@Observed, the change of its attributes will be observed by \@ObjectLink. - this.arrA[Math.floor (this.arrA.length/2)].c: [@State](arkts-state.md#observed-changes) cannot observe changes in the second layer. However, as **ClassA** is decorated by \@Observed, the change of its attributes will be observed by \@ObjectLink.
### Two-Dimensional Array ### Two-Dimensional Array
...@@ -312,7 +316,7 @@ class StringArray extends Array<String> { ...@@ -312,7 +316,7 @@ class StringArray extends Array<String> {
Declare a class that extends from** Array**: **class StringArray extends Array\<String> {}** and create an instance of **StringArray**. The use of the **new** operator is required for the \@Observed class decorator to work properly. Declare a class that extends from **Array**: **class StringArray extends Array\<String> {}** and create an instance of **StringArray**. The use of the **new** operator is required for the \@Observed class decorator to work properly.
```ts ```ts
......
...@@ -19,7 +19,7 @@ The following lifecycle callbacks are provided for the lifecycle of a page, that ...@@ -19,7 +19,7 @@ The following lifecycle callbacks are provided for the lifecycle of a page, that
- [onBackPress](../reference/arkui-ts/ts-custom-component-lifecycle.md#onbackpress): Invoked when the user clicks the Back button. - [onBackPress](../reference/arkui-ts/ts-custom-component-lifecycle.md#onbackpress): Invoked when the user clicks the Back button.
The following lifecycle callbacks are provided for the lifecycle of a custom component, which is one decorated with \@Component: The following lifecycle callbacks are provided for the lifecycle of a component, that is, the lifecycle of a custom component decorated with \@Component:
- [aboutToAppear](../reference/arkui-ts/ts-custom-component-lifecycle.md#abouttoappear): Invoked when the custom component is about to appear. Specifically, it is invoked after a new instance of the custom component is created and before its **build** function is executed. - [aboutToAppear](../reference/arkui-ts/ts-custom-component-lifecycle.md#abouttoappear): Invoked when the custom component is about to appear. Specifically, it is invoked after a new instance of the custom component is created and before its **build** function is executed.
...@@ -129,11 +129,11 @@ struct MyComponent { ...@@ -129,11 +129,11 @@ struct MyComponent {
build() { build() {
Column() { Column() {
// When this.showChild is true, the Child component is created, and Child aboutToAppear is invoked. // When this.showChild is true, the Child child component is created, and Child aboutToAppear is invoked.
if (this.showChild) { if (this.showChild) {
Child() Child()
} }
// When this.showChild is false, the Child component is deleted, and Child aboutToDisappear is invoked. // When this.showChild is false, the Child child component is deleted, and Child aboutToDisappear is invoked.
Button('delete Child').onClick(() => { Button('delete Child').onClick(() => {
this.showChild = false; this.showChild = false;
}) })
......
...@@ -75,15 +75,17 @@ interface DataChangeListener { ...@@ -75,15 +75,17 @@ interface DataChangeListener {
} }
``` ```
| Declaration | Parameter Type | Description | | Declaration | Parameter Type | Description |
| ---------------------------------------- | -------------------------------------- | ---------------------------------------- | | ------------------------------------------------------------ | -------------------------------------- | ------------------------------------------------------------ |
| onDataReloaded():&nbsp;void | - | Invoked when all data is reloaded. | | onDataReloaded():&nbsp;void | - | Invoked when all data is reloaded. |
| onDataAdded(index:&nbsp;number):void | number | Invoked when data is added to the position indicated by the specified index.<br>**index**: index of the position where data is added. | | onDataAdded(index:&nbsp;number):void<sup>(deprecated)</sup> | number | Invoked when data is added to the position indicated by the specified index.<br>This API is deprecated since API version 8. You are advised to use **onDataAdd** instead.<br>**index**: index of the position where data is added.|
| onDataMoved(from:&nbsp;number,&nbsp;to:&nbsp;number):&nbsp;void | from:&nbsp;number,<br>to:&nbsp;number | Invoked when data is moved.<br>**from**: original position of data; **to**: target position of data.<br>**NOTE**<br>The ID must remain unchanged before and after data movement. If the ID changes, APIs for deleting and adding data must be called.| | onDataMoved(from:&nbsp;number,&nbsp;to:&nbsp;number):&nbsp;void<sup>(deprecated)</sup> | from:&nbsp;number,<br>to:&nbsp;number | Invoked when data is moved.<br>This API is deprecated since API version 8. You are advised to use **onDataMove** instead.<br>**from**: original position of data; **to**: target position of data.<br>**NOTE**<br>The ID must remain unchanged before and after data movement. If the ID changes, APIs for deleting and adding data must be called.|
| onDataChanged(index:&nbsp;number):&nbsp;void | number | Invoked when data in the position indicated by the specified index is changed.<br>**index**: listener for data changes. | | onDataDeleted(index: number):void<sup>(deprecated)</sup> | number | Invoked when data is deleted from the position indicated by the specified index. LazyForEach will update the displayed content accordingly.<br>This API is deprecated since API version 8. You are advised to use **onDataDelete** instead.<br>**index**: index of the position where data is deleted.|
| onDataAdd(index:&nbsp;number):&nbsp;void | number | Invoked when data is added to the position indicated by the specified index.<br>**index**: index of the position where data is added. | | onDataChanged(index:&nbsp;number):&nbsp;void<sup>(deprecated)</sup> | number | Invoked when data in the position indicated by the specified index is changed.<br>This API is deprecated since API version 8. You are advised to use **onDataChange** instead.<br>**index**: listener for data changes.|
| onDataMove(from:&nbsp;number,&nbsp;to:&nbsp;number):&nbsp;void | from:&nbsp;number,<br>to:&nbsp;number | Invoked when data is moved.<br>**from**: original position of data; **to**: target position of data.<br>**NOTE**<br>The ID must remain unchanged before and after data movement. If the ID changes, APIs for deleting and adding data must be called.| | onDataAdd(index:&nbsp;number):&nbsp;void<sup>8+</sup> | number | Invoked when data is added to the position indicated by the specified index.<br>**index**: index of the position where data is added.|
| onDataChanged(index:&nbsp;number):&nbsp;void | number | Invoked when data in the position indicated by the specified index is changed.<br>**index**: index of the position where data is changed.| | onDataMove(from:&nbsp;number,&nbsp;to:&nbsp;number):&nbsp;void<sup>8+</sup> | from:&nbsp;number,<br>to:&nbsp;number | Invoked when data is moved.<br>**from**: original position of data; **to**: target position of data.<br>**NOTE**<br>The ID must remain unchanged before and after data movement. If the ID changes, APIs for deleting and adding data must be called.|
| onDataDelete(index: number):void<sup>8+</sup> | number | Invoked when data is deleted from the position indicated by the specified index. LazyForEach will update the displayed content accordingly.<br>**index**: index of the position where data is deleted.<br>**NOTE**<br>Before **onDataDelete** is called, ensure that the corresponding data in **dataSource** has been deleted. Otherwise, undefined behavior will occur during page rendering.|
| onDataChange(index:&nbsp;number):&nbsp;void<sup>8+</sup> | number | Invoked when data in the position indicated by the specified index is changed.<br>**index**: index of the position where data is changed.|
## Restrictions ## Restrictions
......
...@@ -106,6 +106,10 @@ Decorators for [managing the state owned by a component](arkts-state.md): ...@@ -106,6 +106,10 @@ Decorators for [managing the state owned by a component](arkts-state.md):
- \@ObjectLink: An \@ObjectLink decorated variable, when used with an \@Observed decorated class of the parent component, is for two-way data synchronization in scenarios involving multiple levels of nested objects or arrays in the class. - \@ObjectLink: An \@ObjectLink decorated variable, when used with an \@Observed decorated class of the parent component, is for two-way data synchronization in scenarios involving multiple levels of nested objects or arrays in the class.
> **NOTE**
>
> Only [\@Observed/\@ObjectLink](arkts-observed-and-objectlink.md) can observe changes of nested attributes. Other decorators can only observe changes of attributes at the first layer. For details, see the "Observed Changes and Behavior" part in each decorator section.
Decorators for [managing the state owned by an application](arkts-state.md): Decorators for [managing the state owned by an application](arkts-state.md):
......
...@@ -231,7 +231,7 @@ struct MyComponent { ...@@ -231,7 +231,7 @@ struct MyComponent {
Text(`${this.title.value}`) Text(`${this.title.value}`)
Button(`Click to change title`).onClick(() => { Button(`Click to change title`).onClick(() => {
// The update of the @State decorated variable triggers the update of the <Text> component. // The update of the @State decorated variable triggers the update of the <Text> component.
this.title.value = this.title.value === 'Hello ArkUI' ? 'Hello World' : 'HelloArkUI'; this.title.value = this.title.value === 'Hello ArkUI' ? 'Hello World' : 'Hello ArkUI';
}) })
Button(`Click to increase count=${this.count}`).onClick(() => { Button(`Click to increase count=${this.count}`).onClick(() => {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
A Harmony Archive (HAR) is a static shared package that can contain code, C++ libraries, resources, and configuration files. It enables modules and projects to share code related to ArkUI components, resources, and more. Unlike a Harmony Ability Package (HAP), a HAR cannot be independently installed on a device. Instead, it can be referenced only as the dependency of an application module. A Harmony Archive (HAR) is a static shared package that can contain code, C++ libraries, resources, and configuration files. It enables modules and projects to share code related to ArkUI components, resources, and more. Unlike a Harmony Ability Package (HAP), a HAR cannot be independently installed on a device. Instead, it can be referenced only as the dependency of an application module.
## Creating a HAR Module ## Creating a HAR Module
You can kickstart your HAR module development with the module template of the **Library** type in DevEco Studio. By default, obfuscation is disabled for the HAR module. To enable this feature, set **artifactType** in the **build-profile.json5** file of the HAR module to **obfuscation** as follows: You can [create a HAR module in DevEco Studio](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/creating_har_api9-0000001518082393-V3#section143510369612). To better protect your source code, enable obfuscation for the HAR module so that DevEco Studio compiles, obfuscates, and compresses code during HAR building. To enable obfuscation, open the **build-profile.json5** file of the HAR module and set **artifactType** to **obfuscation** as follows:
```json ```json
{ {
...@@ -12,15 +12,13 @@ You can kickstart your HAR module development with the module template of the ** ...@@ -12,15 +12,13 @@ You can kickstart your HAR module development with the module template of the **
} }
} }
``` ```
The value options of **artifactType** are as follows, and the default value is **original**: The value options of **artifactType** are as follows, with the default value being **original**:
- **original**: Code is not obfuscated. - **original**: Code is not obfuscated.
- **obfuscation**: Code is obfuscated using Uglify. - **obfuscation**: Code is obfuscated using Uglify.
When obfuscation is enabled, DevEco Studio compiles, obfuscates, and compresses code during HAR building, thereby protecting your code assets.
> **NOTE** > **NOTE**
> >
> If **artifactType** is set to **obfuscation**, **apiType** must be set to **stageMode**, because obfuscation is available only in the stage model. > Obfuscation is available only in the stage model. Therefore, if **artifactType** is set to **obfuscation**, **apiType** must be set to **stageMode**.
## Precautions for HAR Development ## Precautions for HAR Development
- The HAR does not support the declaration of **abilities** and **extensionAbilities** in its configuration file. - The HAR does not support the declaration of **abilities** and **extensionAbilities** in its configuration file.
...@@ -88,12 +86,12 @@ export { func2 } from './src/main/ts/test' ...@@ -88,12 +86,12 @@ export { func2 } from './src/main/ts/test'
``` ```
### Resources ### Resources
Resources are packed into the HAR when it is being compiled and packaged. During compilation and building of a HAP, DevEco Studio collects resource files from the HAP module and its dependent modules. If the resource files of different modules have the same name, DevEco Studio overwrites the resource files based on the following priorities (in descending order): Resources are packed into the HAR when it is being compiled and packaged. During compilation and building of a HAP, DevEco Studio collects resource files from the HAP module and its dependent modules. If the resource files of different modules have the same name, DevEco Studio overwrites the resource files based on the following priorities (in descending order):
- AppScope (supported only by the stage model of API version 9) - AppScope (only for the stage model of API version 9)
- Modules in the HAP file - Modules in the HAP file
- If resource conflicts occur between dependent HAR modules, they are overwritten based on the dependency sequence. (The module that is higher in the dependency sequence list has higher priority.) - If resource conflicts occur between dependent HAR modules, they are overwritten based on the dependency sequence. (The module that is higher in the dependency sequence list has higher priority.)
## Referencing ArkUI Components, APIs, and Resources in the HAR ## Referencing ArkUI Components, APIs, and Resources in the HAR
To start with, [configure dependency](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-development-npm-package-0000001222578434#section89674298391) on the HAR. To start with, [configure dependency](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/creating_har_api9-0000001518082393-V3#section611662614153) on the HAR.
### Reference ArkUI Components in the HAR ### Reference ArkUI Components in the HAR
...@@ -170,3 +168,7 @@ struct Index { ...@@ -170,3 +168,7 @@ struct Index {
} }
} }
``` ```
## Releasing a HAR
Follow the [instructions](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/creating_har_api9-0000001518082393-V3#section1213451811512) to release a HAR.
...@@ -5,7 +5,7 @@ The in-application HSP is released with the Application Package (App Pack) of th ...@@ -5,7 +5,7 @@ The in-application HSP is released with the Application Package (App Pack) of th
## Developing an In-Application HSP ## Developing an In-Application HSP
You can kickstart your HSP development with the HSP template in DevEco Studio. In this example, an HSP module named **library** is created. The basic project directory structure is as follows: [Create an HSP module in DevEco Studio](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/hsp-0000001521396322-V3#section7717162312546). In this example, an HSP module named **library** is created. The basic project directory structure is as follows:
``` ```
library library
├── src ├── src
...@@ -88,7 +88,7 @@ if **Image("common/example.png")** is used in the HSP module, the **\<Image>** c ...@@ -88,7 +88,7 @@ if **Image("common/example.png")** is used in the HSP module, the **\<Image>** c
### Exporting Native Methods ### Exporting Native Methods
The HSP can contain .so files compiled in C++. The HSP indirectly exports the native method in the .so file. In this example, the **multi** method in the **libnative.so** file is exported. The HSP can contain .so files compiled in C++. The HSP indirectly exports the native method in the .so file. In this example, the **multi** method in the **libnative.so** file is exported.
```ts ```ts
// ibrary/src/main/ets/utils/nativeTest.ts // library/src/main/ets/utils/nativeTest.ts
import native from "libnative.so" import native from "libnative.so"
export function nativeMulti(a: number, b: number) { export function nativeMulti(a: number, b: number) {
...@@ -103,15 +103,9 @@ export { nativeMulti } from './utils/nativeTest' ...@@ -103,15 +103,9 @@ export { nativeMulti } from './utils/nativeTest'
``` ```
## Using the In-Application HSP ## Using the In-Application HSP
To use APIs in the HSP, first configure the dependency on the HSP in the **oh-package.json5** file of the module that needs to call the APIs (called the invoking module). If the HSP and the invoking module are in the same project, the APIs can be referenced locally. The sample code is as follows: To use APIs in the HSP, first [configure the dependency](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/hsp-0000001521396322-V3#section6161154819195) on the HSP in the **oh-package.json5** file of the module that needs to call the APIs (called the invoking module).
```json You can then call the external APIs of the HSP in the same way as calling the APIs in the HAR. In this example, the external APIs are the following ones exported from **library**:
// entry/oh-package.json5
"dependencies": {
"library": "file:../library"
}
```
You can now call the external APIs of the HSP in the same way as calling the APIs in the HAR.
In this example, the external APIs are the following ones exported from **library**:
```ts ```ts
// library/src/main/ets/index.ets // library/src/main/ets/index.ets
export { Log, add, minus } from './utils/test' export { Log, add, minus } from './utils/test'
......
...@@ -302,7 +302,7 @@ Set **icon**, **label**, and **skills** under **abilities** in the **module.json ...@@ -302,7 +302,7 @@ Set **icon**, **label**, and **skills** under **abilities** in the **module.json
| [metadata](#metadata)| Metadata information of the UIAbility component.| Object array| Yes (initial value: left empty)| | [metadata](#metadata)| Metadata information of the UIAbility component.| Object array| Yes (initial value: left empty)|
| exported | Whether the UIAbility component can be called by other applications.<br>- **true**: The UIAbility component can be called by other applications.<br>- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)| | exported | Whether the UIAbility component can be called by other applications.<br>- **true**: The UIAbility component can be called by other applications.<br>- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)|
| continuable | Whether the UIAbility component can be [migrated](../application-models/hop-cross-device-migration.md).<br>- **true**: The UIAbility component can be migrated.<br>- **false**: The UIAbility component cannot be migrated.| Boolean| Yes (initial value: **false**)| | continuable | Whether the UIAbility component can be [migrated](../application-models/hop-cross-device-migration.md).<br>- **true**: The UIAbility component can be migrated.<br>- **false**: The UIAbility component cannot be migrated.| Boolean| Yes (initial value: **false**)|
| [skills](#skills) | Feature set of [wants](../application-models/want-overview.md) that can be received by the current UIAbility or ExtensionAbility component.<br>Configuring rule:<br>- For HAPs of the entry type, you can configure multiple **skills** attributes with the entry capability for an OpenHarmony application. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.)<br>- For HAPs of the feature type, you can configure **skills** attributes with the entry capability for an OpenHarmony application, but not for an OpenHarmony service.| Object array| Yes (initial value: left empty)| | [skills](#skills) | Feature set of [wants](../application-models/want-overview.md) that can be received by the current UIAbility or ExtensionAbility component.<br>Configuration rules:<br>- For HAPs of the entry type, you can configure multiple **skills** attributes with the entry capability for an OpenHarmony application. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.)<br>- For HAPs of the feature type, you can configure **skills** attributes with the entry capability for an OpenHarmony application, but not for an OpenHarmony service. | Object array| Yes (initial value: left empty)|
| backgroundModes | Continuous tasks of the UIAbility component. <br>Continuous tasks are classified into the following types:<br>- **dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices.<br>- **audioPlayback**: audio playback service.<br>- **audioRecording**: audio recording service.<br>- **location**: location and navigation services.<br>- **bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables).<br>- **multiDeviceConnection**: multi-device interconnection service.<br>- **wifiInteraction**: Wi-Fi scanning, connection, and transmission services (as used in the Multi-screen Collaboration and clone features)<br>- **voip**: voice/video call and VoIP services.<br>- **taskKeeping**: computing service.| String array| Yes (initial value: left empty)| | backgroundModes | Continuous tasks of the UIAbility component. <br>Continuous tasks are classified into the following types:<br>- **dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices.<br>- **audioPlayback**: audio playback service.<br>- **audioRecording**: audio recording service.<br>- **location**: location and navigation services.<br>- **bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables).<br>- **multiDeviceConnection**: multi-device interconnection service.<br>- **wifiInteraction**: Wi-Fi scanning, connection, and transmission services (as used in the Multi-screen Collaboration and clone features)<br>- **voip**: voice/video call and VoIP services.<br>- **taskKeeping**: computing service.| String array| Yes (initial value: left empty)|
| startWindowIcon | Index to the icon file of the UIAbility component startup page. Example: **$media:icon**.<br>The value is a string with a maximum of 255 bytes.| String| No| | startWindowIcon | Index to the icon file of the UIAbility component startup page. Example: **$media:icon**.<br>The value is a string with a maximum of 255 bytes.| String| No|
| startWindowBackground | Index to the background color resource file of the UIAbility component startup page. Example: **$color:red**.<br>The value is a string with a maximum of 255 bytes.| String| No| | startWindowBackground | Index to the background color resource file of the UIAbility component startup page. Example: **$color:red**.<br>The value is a string with a maximum of 255 bytes.| String| No|
......
...@@ -10,7 +10,7 @@ Quick fix is a technical means provided by the OpenHarmony system for developers ...@@ -10,7 +10,7 @@ Quick fix is a technical means provided by the OpenHarmony system for developers
* The bundle name and application version number configured in the quick fix package must be the same as those of the installed application. Otherwise, the deployment will fail. * The bundle name and application version number configured in the quick fix package must be the same as those of the installed application. Otherwise, the deployment will fail.
* Make sure the version of the quick fix package to deploy is later than that of the one previously deployed. Otherwise, the deployment will fail. * Make sure the version of the quick fix package to deploy is later than that of the one previously deployed. Otherwise, the deployment will fail.
* The signature information of the quick fix package must be the same as that of the application to be fixed. Otherwise, the deployment will fail. * The signature information of the quick fix package must be the same as that of the application to be fixed. Otherwise, the deployment will fail.
* Installing an application update will delete quick fix package. * Installing an application update will delete the quick fix package.
## Structure of the Quick Fix Package ## Structure of the Quick Fix Package
...@@ -27,7 +27,7 @@ Quick fix is a technical means provided by the OpenHarmony system for developers ...@@ -27,7 +27,7 @@ Quick fix is a technical means provided by the OpenHarmony system for developers
* .abc file: modified TS code in the application, which is a bytecode file created after the build. * .abc file: modified TS code in the application, which is a bytecode file created after the build.
* **libs** directory: a collection of .so.diff files, which are differential files of the .so library files, organized by system CPU architecture, such as arm and x86. * **libs** directory: a collection of .so.diff files, which are differential files of the .so library files, organized by system CPU architecture, such as arm and x86.
* **patch.json**: * **patch.json**:
<br> This file is used to describe the version information of the .hqf file and is filled in by developers. The details are as follows: <br> This file is used to describe the version information of the .hqf file and is filled in by developers. The details are as follows:
```json ```json
{ {
"app" : { "app" : {
......
...@@ -49,22 +49,22 @@ resources ...@@ -49,22 +49,22 @@ resources
**Table 1** Classification of the resources directory **Table 1** Classification of the resources directory
| Category | base Subdirectory | Qualifiers Subdirectory | rawfile Subdirectory | | Category | base Subdirectory | Qualifiers Subdirectory | rawfile Subdirectory |
| ---- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | | ---- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- |
| Structure| The **base** subdirectory is a default directory. If no qualifiers subdirectories in the **resources** directory of the application match the device status, the resource file in the **base** subdirectory will be automatically referenced.<br>Resource group subdirectories are located at the second-level subdirectories in the **base** directory to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectory](#resource-group-subdirectory).| **en_US** and **zh_CN** are two default qualifiers subdirectories. You need to create other qualifiers subdirectories on your own. Each directory name consists of one or more qualifiers that represent the application scenarios or device characteristics. For details, see [Qualifiers Subdirectory](#qualifiers-subdirectory).<br>Resource group subdirectories are located at the second level of qualifiers subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectory](#resource-group-subdirectory).| You can create multiple levels of subdirectories with custom directory names. They can be used to store various resource files.<br>However, resource files in the **rawfile** subdirectory will not be matched based on the device status.| | Structure| The **base** subdirectory is a default directory. If no qualifiers subdirectories in the **resources** directory of the application match the device status, the resource file in the **base** subdirectory will be automatically referenced.<br>Resource group subdirectories are located at the second level of subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectories](#resource-group-subdirectories).| **en_US** and **zh_CN** are two default qualifiers subdirectories. You need to create other qualifiers subdirectories on your own. Each directory name consists of one or more qualifiers that represent the application scenarios or device characteristics. For details, see [Qualifiers Subdirectories](#qualifiers-subdirectories).<br>Resource group subdirectories are located at the second level of subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectories](#resource-group-subdirectories).| You can create multiple levels of subdirectories with custom directory names. They can be used to store various resource files.<br>However, resource files in the **rawfile** subdirectory will not be matched based on the device status.|
| Compilation| Resource files in the subdirectories are compiled into binary files, and each resource file is assigned an ID. | Resource files in the subdirectories are compiled into binary files, and each resource file is assigned an ID. | Resource files in the subdirectory are directly packed into the application without being compiled, and no IDs will be assigned to the resource files. | | Compilation| Resource files in the subdirectory are compiled into binary files, and each resource file is assigned an ID. | Resource files in the subdirectory are compiled into binary files, and each resource file is assigned an ID. | Resource files in the subdirectory are directly packed into the application without being compiled, and no IDs will be assigned to the resource files. |
| Reference| Resource files in the subdirectory are referenced based on the resource type and resource name. | Resource files in the subdirectory are referenced based on the resource type and resource name. | Resource files in the subdirectory are referenced based on the file path and file name. | | Reference| Resource files in the subdirectory are referenced based on the resource type and resource name. | Resource files in the subdirectory are referenced based on the resource type and resource name. | Resource files in the subdirectory are referenced based on the file path and file name. |
### Qualifiers Subdirectory ### Qualifiers Subdirectories
The name of a qualifiers subdirectory consists of one or more qualifiers that represent the application scenarios or device characteristics, covering the mobile country code (MCC), mobile network code (MNC), language, script, country or region, screen orientation, device type, night mode, and screen density. The qualifiers are separated using underscores (\_) or hyphens (\-). When creating a qualifiers subdirectory, you need to understand the directory naming conventions and the rules for matching qualifiers subdirectories and the device status. The name of a qualifiers subdirectory consists of one or more qualifiers that represent the application scenarios or device characteristics, covering the mobile country code (MCC), mobile network code (MNC), language, script, country or region, screen orientation, device type, night mode, and screen density. The qualifiers are separated using underscores (\_) or hyphens (\-). Before creating a qualifiers subdirectory, familiarize yourself with the directory naming conventions and the rules for matching qualifiers subdirectories and the device status.
**Naming Conventions for Qualifiers Subdirectories** **Naming Conventions for Qualifiers Subdirectories**
- Qualifiers are ordered in the following sequence: **\_MCC_MNC-language_script_country/region-orientation-device-color mode-density**. You can select one or multiple qualifiers to name your subdirectory based on your application scenarios and device characteristics. - Qualifiers are ordered in the following sequence: **\_MCC_MNC-language_script_country/region-orientation-device-color mode-density_**. You can select one or multiple qualifiers to name your subdirectory based on your application scenarios and device characteristics.
- Separation between qualifiers: The language, script, and country/region qualifiers are separated using underscores (\_); the MNC and MCC qualifiers are also separated using underscores (\_); other qualifiers are separated using hyphens (-). For example, **zh_Hant_CN** and **zh_CN-car-ldpi**. - Separation between qualifiers: The language, script, and country/region qualifiers are separated using underscores (\_); the MNC and MCC qualifiers are also separated using underscores (\_); other qualifiers are separated using hyphens (\-). For example, **zh_Hant_CN** and **zh_CN-car-ldpi**.
- Value range of qualifiers: The value of each qualifier must meet the requirements specified in the following table. Otherwise, the resource files in the resources directory cannot be matched. - Value range of qualifiers: The value of each qualifier must meet the requirements specified in the following table. Otherwise, the resource files in the resources directory cannot be matched.
...@@ -72,34 +72,34 @@ The name of a qualifiers subdirectory consists of one or more qualifiers that re ...@@ -72,34 +72,34 @@ The name of a qualifiers subdirectory consists of one or more qualifiers that re
| Qualifier Type | Description and Value Range | | Qualifier Type | Description and Value Range |
| ----------- | ---------------------------------------- | | ----------- | ---------------------------------------- |
| MCC&MNC| Mobile country code and mobile network code, which are obtained from the network where the device is registered. The MCC can be either followed by the MNC with an underscore (\_) in between or be used independently. For example, **mcc460** indicates China, and **mcc460\_mnc00** indicates China\_China Mobile.<br>For details about the value range, refer to **ITU-T E.212** (the international identification plan for public networks and subscriptions).| | MCC&MNC| Indicates the MCC and MNC, which are obtained from the network where the device is registered. The MCC can be either followed by the MNC with an underscore (\_) in between or be used independently. For example, **mcc460** indicates China, and **mcc460\_mnc00** indicates China\_China Mobile.<br>For details about the value range, refer to **ITU-T E.212** (the international identification plan for public networks and subscriptions).|
| Language | Language used by the device. The value consists of two or three lowercase letters. for example, **zh** indicates Chinese, en indicates English, and **mai** indicates Maithili.<br>For details about the value range, refer to **ISO 639** (codes for the representation of names of languages).| | Language | Indicates the language used by the device. The value consists of two or three lowercase letters. For example, **zh** indicates Chinese, **en** indicates English, and **mai** indicates Maithili.<br>For details about the value range, refer to **ISO 639** (codes for the representation of names of languages).|
| Script | Script type used by the device. The value starts with one uppercase letter followed by three lowercase letters. For example, **Hans** indicates simplified Chinese, and **Hant** indicates traditional Chinese.<br>For details about the value range, refer to **ISO 15924** (codes for the representation of names of scripts).|| | Text | Indicates the script type used by the device. The value starts with one uppercase letter followed by three lowercase letters. For example, **Hans** indicates simplified Chinese, and **Hant** indicates traditional Chinese.<br>For details about the value range, refer to **ISO 15924** (codes for the representation of names of scripts).|
| Country/Region | Country or region where the user is located. The value consists of two or three uppercase letters or three digits. For example, **CN** indicates China, and **GB** indicates the United Kingdom.<br>For details about the value range, refer to **ISO 3166-1** (codes for the representation of names of countries and their subdivisions).|| | Country/Region | Indicates the country or region where the user is located. The value consists of two or three uppercase letters or three digits. For example, **CN** indicates China, and **GB** indicates the United Kingdom.<br>For details about the value range, refer to **ISO 3166-1** (codes for the representation of names of countries and their subdivisions).|
| Screen orientation | Screen orientation of the device. The value can be:<br>- **vertical**: portrait orientation<br>- **horizontal**: landscape orientation| | Screen orientation | Indicates the screen orientation of the device. The value can be:<br>- **vertical**: portrait orientation<br>- **horizontal**: landscape orientation|
| Type of the registered device. | Device type. The value can be:<br>- **car**: head unit<br>- **tv**: smart TV<br>- **wearable**: smart wearable| | Device type | Indicates the device type. The value can be:<br>- **car**: head unit<br>- **tv**: smart TV<br>- **wearable**: smart wearable|
| Color mode | Color mode of the device. The value can be:<br>- **dark**: dark mode<br>- **light**: light mode| | Color mode | Indicates the color mode of the device. The value can be:<br>- **dark**: dark mode<br>- **light**: light mode|
| Screen density | Screen density of the device, in dpi. The value can be:<br>- **sdpi**: screen density with small-scale dots per inch (SDPI). This value is applicable for devices with a DPI range of (0, 120].<br>- **mdpi**: screen density with medium-scale dots per inch (MDPI). This value is applicable for devices with a DPI range of (120, 160].<br>- **ldpi**: screen density with large-scale dots per inch (LDPI). This value is applicable for devices with a DPI range of (160, 240].<br>- **xldpi**: screen density with extra-large-scale dots per inch (XLDPI). This value is applicable for devices with a DPI range of (240, 320].<br>- **xxldpi**: screen density with extra-extra-large-scale dots per inch (XXLDPI). This value is applicable for devices with a DPI range of (320, 480].<br>- **xxxldpi**: screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI). This value is applicable for devices with a DPI range of (480, 640].| | Screen density | Indicates the screen density of the device, in dpi. The value can be:<br>- **sdpi**: screen density with small-scale dots per inch (SDPI). This value is applicable for devices with a DPI range of (0, 120].<br>- **mdpi**: medium-scale screen density (Medium-scale Dots Per Inch), applicable to DPI whose value is (120, 160] device.<br>- **ldpi**: screen density with large-scale dots per inch (LDPI). This value is applicable for devices with a DPI range of (160, 240].<br>- **xldpi**: screen density with extra-large-scale dots per inch (XLDPI). This value is applicable for devices with a DPI range of (240, 320].<br>- **xxldpi**: screen density with extra-extra-large-scale dots per inch (XXLDPI). This value is applicable for devices with a DPI range of (320, 480].<br>- **xxxldpi**: screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI). This value is applicable for devices with a DPI range of (480, 640].|
**Rules for Matching Qualifiers subdirectories and Device Resources** **Rules for Matching Qualifiers Subdirectories and Device Resources**
- Qualifiers are matched with the device resources in the following priorities: MCC&MNC &gt; locale (options: language, language\_script, language\_country/region, and language\_script\_country/region) &gt; screen orientation &gt; device type &gt; color mode &gt; screen density. - Qualifiers are matched with the device resources in the following priorities: MCC&MNC > locale (options: language, language_script, language_country/region, and language_script_country/region) > screen orientation > device type > color mode > screen density.
- If the qualifiers subdirectories contain the **MCC, MNC, language, script, screen orientation, device type, and color mode** qualifiers, their values must be consistent with the current device status so that the subdirectories can be used for matching the device resources. For example, the qualifiers subdirectory **zh\_CN-car-ldpi** cannot be used for matching the resource files labeled **en\_US**. - If the qualifiers subdirectories contain the **MCC, MNC, language, script, screen orientation, device type, and color mode** qualifiers, their values must be consistent with the current device status so that the subdirectories can be used for matching the device resources. For example, the qualifiers subdirectory **zh_CN-car-ldpi** cannot be used for matching the resource files labeled **en_US**.
### Resource Group Subdirectory ### Resource Group Subdirectories
You can create resource group subdirectories (including element, media, and profile) in the **base** and qualifiers subdirectories to store resource files of specific types. You can create resource group subdirectories (including element, media, and profile) in the **base** and qualifiers subdirectories to store resource files of specific types.
**Table 3** Resource group subdirectories **Table 3** Resource group subdirectories
| Resource Group Subdirectory | Description | Resource File | | Resource Group Subdirectory | Description | Resource File |
| ------- | ---------------------------------------- | ---------------------------------------- | | ------- | ---------------------------------------- | ---------------------------------------- |
| element | Element resources. Each type of data is represented by a JSON file. (Only files are supported in this directory.) The options are as follows:<br>- **boolean**: boolean data<br>- **color**: color data<br>- **float**: floating-point data<br>- **intarray**: array of integers<br>- **integer**: integer data<br>- **pattern**: pattern data<br>- **plural**: plural form data<br>- **strarray**: array of strings<br>- **string**: string data| It is recommended that files in the **element** subdirectory be named the same as the following files, each of which can contain only data of the same type:<br>-&nbsp;boolean.json<br>-&nbsp;color.json<br>-&nbsp;float.json<br>-&nbsp;intarray.json<br>-&nbsp;integer.json<br>-&nbsp;pattern.json<br>-&nbsp;plural.json<br>-&nbsp;strarray.json<br>-&nbsp;string.json | | element | Indicates element resources. Each type of data is represented by a JSON file. (Only files are supported in this directory.) The options are as follows:<br>- **boolean**: boolean data<br>- **color**: color data<br>- **float**: floating-point data<br>- **intarray**: array of integers<br>- **integer**: integer data<br>- **pattern**: pattern data<br>- **plural**: plural form data<br>- **strarray**: array of strings<br>- **string**: string data| It is recommended that files in the **element** subdirectory be named the same as the following files, each of which can contain only data of the same type:<br>- boolean.json<br>- color.json<br>- float.json<br>- intarray.json<br>- integer.json<br>- pattern.json<br>- plural.json<br>- strarray.json<br>- string.json |
| media | Media resources, including non-text files such as images, audios, and videos. (Only files are supported in this directory.) | The file name can be customized, for example, **icon.png**. | | media | Indicates media resources, including non-text files such as images, audios, and videos. (Only files are supported in this directory.) | The file name can be customized, for example, **icon.png**. |
| profile | Custom configuration file. You can obtain the file content by using the [getProfileByAbility](../reference/apis/js-apis-bundleManager.md#bundlemanagergetprofilebyability) API. (Only files are supported in this directory.) | The file name can be customized, for example, **test_profile.json**. | | profile | Indicates a custom configuration file. You can obtain the file content by using the [getProfileByAbility](../reference/apis/js-apis-bundleManager.md#bundlemanagergetprofilebyability) API. (Only files are supported in this directory.) | The file name can be customized, for example, **test_profile.json**. |
**Media Resource Types** **Media Resource Types**
...@@ -212,41 +212,41 @@ The content of the **plural.json** file is as follows: ...@@ -212,41 +212,41 @@ The content of the **plural.json** file is as follows:
**Creating a Resource File** **Creating a Resource File**
You can create a subdirectory and its files under the **resources** directory based on the above descriptions of the qualifiers subdirectories and resource group subdirectories. You can create a subdirectory and its files under the **resources** directory based on the preceding descriptions of the qualifiers subdirectories and resource group subdirectories.
DevEco Studio provides a wizard for you to create resource directories and resource files. DevEco Studio provides a wizard for you to create resource directories and resource files.
- Creating a resource directory and resource file - Creating a Resource Directory and Resource File
Right-click the **resources** directory and choose **New > Resource File**. This operation creates a subdirectory and a resource file simultaneously. If no qualifier is selected, the file is created in a resource type subdirectory under **base**. If one or more qualifiers are selected, the system automatically generates a subdirectory and creates the file in this subdirectory. To select a qualifier, highlight it under **Available qualifiers** and click the right arrow. To deselect a qualifier, highlight it under **Selected qualifiers** and click the left arrow. In **File name**, enter the name of the resource file to create. In **Resource type**, select the type of the resource group, which is **element** by default. In **Root Element**, select a resource type. The created subdirectory is automatically named in the format of *Qualifiers.Resource group type*. For example, if you create a subdirectory by setting **Color Mode** to **Dark** and **Resource type** to **Element**, the system automatically generates a subdirectory named **dark.element**. Right-click the **resources** directory and choose **New > Resource File**. If no qualifier is selected, the file is created in a resource type subdirectory under **base**. If one or more qualifiers are selected, the system automatically generates a subdirectory and creates the file in this subdirectory. To select a qualifier, highlight it under **Available qualifiers** and click the right arrow. To deselect a qualifier, highlight it under **Selected qualifiers** and click the left arrow. In **File name**, enter the name of the resource file to create. In **Resource type**, select the type of the resource group, which is **element** by default. In **Root Element**, select a resource type. The created subdirectory is automatically named in the format of *Qualifiers.Resource group type*. For example, if you create a subdirectory by setting **Color Mode** to **Dark** and **Resource type** to **Element**, the system automatically generates a subdirectory named **dark.element**.
![create-resource-file-1](figures/create-resource-file-1.png) ![create-resource-file-1](figures/create-resource-file-1.png)
- Creating a resource directory - Creating a Resource Directory
Right-click the **resources** directory and choose **New > Resource Directory**. This operation creates a subdirectory only. By default, the **base** subdirectory is created. You can create qualifiers subdirectories as required, by specifying the qualifier and resource group type. After determining the qualifier, select a resource group type. Currently, the resource group type can be **Element**, **Media**, or **Profile**. After a resource group is created, a directory name is automatically generated. Right-click the **resources** directory and choose **New > Resource Directory** to create a subdirectory only. By default, the **base** subdirectory is created. You can create qualifiers subdirectories as required, by specifying the qualifier and resource group type.
![create-resource-file-2](figures/create-resource-file-2.png) ![create-resource-file-2](figures/create-resource-file-2.png)
- Creating a resource file - Creating a Resource File
Right-click a subdirectory under **resources** and choose **New > *example* Resource File**. This operation creates a resource file under this subdirectory. For example, you can create an element resource file in the **element** subdirectory. Right-click a subdirectory under **resources** and choose **New > *XXX* Resource File**. This operation creates a resource file under this subdirectory. For example, you can create an element resource file in the **element** subdirectory.
![create-resource-file-3](figures/create-resource-file-3.png) ![create-resource-file-3](figures/create-resource-file-3.png)
**Accessing Application Resources** **Accessing Application Resources**
To reference an application resource in a project, use the `"$r('app.type.name')"` format. **app** indicates the resource defined in the **resources** directory of the application. **type** indicates the resource type (or the location where the resource is stored). The value can be **color**, **float**, **string**, **plural**, or **media**. **name** indicates the resource name, which you set when defining the resource. To reference an application resource in a project, use the **"$r('app.type.name')"** format. **app** indicates the resource defined in the **resources** directory of the application. **type** indicates the resource type (or the location where the resource is stored). The value can be **color**, **float**, **string**, **plural**, or **media**. **name** indicates the resource name, which you set when defining the resource.
When referencing resources in the **rawfile** subdirectory, use the `"$rawfile('filename')"` format. Wherein **filename** indicates the relative path of a file in the **rawfile** subdirectory, which must contain the file name extension and cannot start with a slash (/). When referencing resources in the **rawfile** subdirectory, use the **"$rawfile('filename')"** format. Wherein **filename** indicates the relative path of a file in the **rawfile** subdirectory, which must contain the file name extension and cannot start with a slash (/).
> **NOTE** > **NOTE**
> >
> Resource descriptors accept only strings, such as `'app.type.name'`, and cannot be combined. > Resource descriptors accept only strings, such as **'app.type.name'**, and cannot be combined.
> >
> The return value of `$r` is a Resource object. You can obtain the corresponding string by using the [getStringValue](../reference/apis/js-apis-resource-manager.md#getstringvalue9) method. > The return value of **$r** is a **Resource** object. You can obtain the corresponding string by using the [getStringValue](../reference/apis/js-apis-resource-manager.md#getstringvalue9) API.
In the ***example*.ets** file, you can use the resources defined in the **resources** directory. The following is a resource usage example based on the resource file examples in [Resource Group Subdirectory](#resource-group-subdirectory): In the **.ets** file, you can use the resources defined in the **resources** directory. As described in [Resource Group Subdirectories](#resource-group-subdirectories), you can reference .json resource files, including **color.json**, **string.json**, and **plural.json**. The usage is as follows:
```ts ```ts
Text($r('app.string.string_hello')) Text($r('app.string.string_hello'))
...@@ -257,13 +257,14 @@ Text($r('app.string.string_world')) ...@@ -257,13 +257,14 @@ Text($r('app.string.string_world'))
.fontColor($r('app.color.color_world')) .fontColor($r('app.color.color_world'))
.fontSize($r('app.float.font_world')) .fontSize($r('app.float.font_world'))
// Reference string resources. The second parameter of $r is used to replace %s, and value is "We will arrive at five of the clock". // Reference string resources. The first parameter of $r indicates the string resource, and the second parameter is used to replace %s in the string.json file.
// In this example, the resultant value is "We will arrive at five of the clock".
Text($r('app.string.message_arrive', "five of the clock")) Text($r('app.string.message_arrive', "five of the clock"))
.fontColor($r('app.color.color_hello')) .fontColor($r('app.color.color_hello'))
.fontSize($r('app.float.font_hello')) .fontSize($r('app.float.font_hello'))
// Reference plural resources. The first parameter indicates the plural resource, the second parameter indicates the number of plural resources, and the third parameter indicates the substitute of %d. // Reference plural resources. The first parameter of $r indicates the plural resource, the second parameter indicates the number of plural resources (for English, **one** indicates singular and is represented by **1**, and **other** indicates plural and is represented by an integer greater than or equal to 1; for Chinese, **other** indicates both singular and plural), and the third parameter is used to replace %d.
// The value is "5 apple" in singular form and "5 apples" in plural form. // In this example, the resultant value is "5 apples".
Text($r('app.plural.eat_apple', 5, 5)) Text($r('app.plural.eat_apple', 5, 5))
.fontColor($r('app.color.color_world')) .fontColor($r('app.color.color_world'))
.fontSize($r('app.float.font_world')) .fontSize($r('app.float.font_world'))
...@@ -279,13 +280,13 @@ Image($rawfile('newDir/newTest.png')) // Reference an image in the rawfile ...@@ -279,13 +280,13 @@ Image($rawfile('newDir/newTest.png')) // Reference an image in the rawfile
System resources include colors, rounded corners, fonts, spacing, character strings, and images. By using system resources, you can develop different applications with the same visual style. System resources include colors, rounded corners, fonts, spacing, character strings, and images. By using system resources, you can develop different applications with the same visual style.
To reference a system resource, use the `"$r('sys.type.resource_id')"` format. Wherein: **sys** indicates a system resource; **type** indicates the resource type, which can be **color**, **float**, **string**, or **media**; **resource_id** indicates the resource ID. To reference a system resource, use the **"$r('sys.type.resource_id')"** format. Wherein: **sys** indicates a system resource; **type** indicates the resource type, which can be **color**, **float**, **string**, or **media**; **resource_id** indicates the resource ID.
> **NOTE** > **NOTE**
> >
> - Use of system resources is supported in the declarative development paradigm, but not in the web-like development paradigm. > - Use of system resources is supported in the declarative development paradigm, but not in the web-like development paradigm.
> >
> - For details about the implementation of preconfigured resources, visit the [OpenHarmony/resources repository](https://gitee.com/openharmony/resources/tree/master/systemres/main/resources). The directory structure there is similar to that of the **resources** directory in the project. Resource qualifiers are used to match resources with different devices and device status. > - For details about the implementation of preconfigured resources, visit the [OpenHarmony/resources repository](https://gitee.com/openharmony/resources/tree/master/systemres/main/resources). The directory structure there is similar to that of the **resources** directory in the project. Resource qualifiers are used to match resources with different devices and device states.
```ts ```ts
Text('Hello') Text('Hello')
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
## Creating an ArkTS Project ## Creating an ArkTS Project
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click Next. 1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**.
![createProject](figures/createProject.png) ![createProject](figures/createProject.png)
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
## Creating an ArkTS Project ## Creating an ArkTS Project
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click Next. 1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**.
![createProject](figures/createProject.png) ![createProject](figures/createProject.png)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
## Creating a JavaScript Project ## Creating a JavaScript Project
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click Next. 1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**.
![createProject](figures/createProject.png) ![createProject](figures/createProject.png)
......
...@@ -370,7 +370,7 @@ Obtains the accessibility application list. This API uses a promise to return th ...@@ -370,7 +370,7 @@ Obtains the accessibility application list. This API uses a promise to return th
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. > This API is supported since API version 7 and deprecated since API version 9.
> You are advised to use[getAccessibilityExtensionList()](#accessibilitygetaccessibilityextensionlist9). > You are advised to use [getAccessibilityExtensionList()](#accessibilitygetaccessibilityextensionlist9).
**System capability**: SystemCapability.BarrierFree.Accessibility.Core **System capability**: SystemCapability.BarrierFree.Accessibility.Core
......
...@@ -19,12 +19,16 @@ A system common event is an event that is published by a system service or syste ...@@ -19,12 +19,16 @@ A system common event is an event that is published by a system service or syste
For details about the definitions of all system common events, see [System Common Events](./commonEvent-definitions.md). For details about the definitions of all system common events, see [System Common Events](./commonEvent-definitions.md).
## CommonEvent.publish ## CommonEvent.publish<sup>(deprecated)</sup>
publish(event: string, callback: AsyncCallback\<void>): void publish(event: string, callback: AsyncCallback\<void>): void
Publishes a common event. This API uses an asynchronous callback to return the result. Publishes a common event. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.publish](js-apis-commonEventManager.md#commoneventmanagerpublish) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
...@@ -50,14 +54,16 @@ function publishCallBack(err) { ...@@ -50,14 +54,16 @@ function publishCallBack(err) {
CommonEvent.publish("event", publishCallBack); CommonEvent.publish("event", publishCallBack);
``` ```
## CommonEvent.publish<sup>(deprecated)</sup>
## CommonEvent.publish
publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\<void>): void publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\<void>): void
Publishes a common event with given attributes. This API uses an asynchronous callback to return the result. Publishes a common event with given attributes. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.publish](js-apis-commonEventManager.md#commoneventmanagerpublish-1) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
...@@ -66,7 +72,7 @@ Publishes a common event with given attributes. This API uses an asynchronous ca ...@@ -66,7 +72,7 @@ Publishes a common event with given attributes. This API uses an asynchronous ca
| -------- | ---------------------- | ---- | ---------------------- | | -------- | ---------------------- | ---- | ---------------------- |
| event | string | Yes | Name of the common event to publish. | | event | string | Yes | Name of the common event to publish. |
| options | [CommonEventPublishData](./js-apis-inner-commonEvent-commonEventPublishData.md) | Yes | Attributes of the common event to publish.| | options | [CommonEventPublishData](./js-apis-inner-commonEvent-commonEventPublishData.md) | Yes | Attributes of the common event to publish.|
| callback | syncCallback\<void> | Yes | Callback used to return the result. | | callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -92,14 +98,16 @@ function publishCallBack(err) { ...@@ -92,14 +98,16 @@ function publishCallBack(err) {
CommonEvent.publish("event", options, publishCallBack); CommonEvent.publish("event", options, publishCallBack);
``` ```
## CommonEvent.publishAsUser<sup>(deprecated)</sup>
## CommonEvent.publishAsUser<sup>8+</sup>
publishAsUser(event: string, userId: number, callback: AsyncCallback\<void>): void publishAsUser(event: string, userId: number, callback: AsyncCallback\<void>): void
Publishes a common event to a specific user. This API uses an asynchronous callback to return the result. Publishes a common event to a specific user. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [commonEventManager.publishAsUser](js-apis-commonEventManager.md#commoneventmanagerpublishasuser) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
...@@ -131,14 +139,16 @@ let userId = 100; ...@@ -131,14 +139,16 @@ let userId = 100;
CommonEvent.publishAsUser("event", userId, publishAsUserCallBack); CommonEvent.publishAsUser("event", userId, publishAsUserCallBack);
``` ```
## CommonEvent.publishAsUser<sup>(deprecated)</sup>
## CommonEvent.publishAsUser<sup>8+</sup>
publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback\<void>): void publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback\<void>): void
Publishes a common event with given attributes to a specific user. This API uses an asynchronous callback to return the result. Publishes a common event with given attributes to a specific user. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [commonEventManager.publishAsUser](js-apis-commonEventManager.md#commoneventmanagerpublishasuser-1) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
...@@ -178,14 +188,16 @@ let userId = 100; ...@@ -178,14 +188,16 @@ let userId = 100;
CommonEvent.publishAsUser("event", userId, options, publishAsUserCallBack); CommonEvent.publishAsUser("event", userId, options, publishAsUserCallBack);
``` ```
## CommonEvent.createSubscriber<sup>(deprecated)</sup>
## CommonEvent.createSubscriber
createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback\<CommonEventSubscriber>): void createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback\<CommonEventSubscriber>): void
Creates a subscriber. This API uses an asynchronous callback to return the result. Creates a subscriber. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.createSubscriber](js-apis-commonEventManager.md#commoneventmanagercreatesubscriber) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
...@@ -220,14 +232,16 @@ function createSubscriberCallBack(err, commonEventSubscriber) { ...@@ -220,14 +232,16 @@ function createSubscriberCallBack(err, commonEventSubscriber) {
CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack); CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack);
``` ```
## CommonEvent.createSubscriber<sup>(deprecated)</sup>
## CommonEvent.createSubscriber
createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventSubscriber> createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventSubscriber>
Creates a subscriber. This API uses a promise to return the result. Creates a subscriber. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.createSubscriber](js-apis-commonEventManager.md#commoneventmanagercreatesubscriber-1) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
...@@ -260,14 +274,16 @@ CommonEvent.createSubscriber(subscribeInfo).then((commonEventSubscriber) => { ...@@ -260,14 +274,16 @@ CommonEvent.createSubscriber(subscribeInfo).then((commonEventSubscriber) => {
}); });
``` ```
## CommonEvent.subscribe<sup>(deprecated)</sup>
## CommonEvent.subscribe
subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEventData>): void subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEventData>): void
Subscribes to common events. This API uses an asynchronous callback to return the result. Subscribes to common events. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.subscribe](js-apis-commonEventManager.md#commoneventmanagersubscribe) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
...@@ -312,14 +328,16 @@ function createSubscriberCallBack(err, commonEventSubscriber) { ...@@ -312,14 +328,16 @@ function createSubscriberCallBack(err, commonEventSubscriber) {
CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack); CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack);
``` ```
## CommonEvent.unsubscribe<sup>(deprecated)</sup>
## CommonEvent.unsubscribe
unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>): void unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>): void
Unsubscribes from common events. This API uses an asynchronous callback to return the result. Unsubscribes from common events. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.subscribe](js-apis-commonEventManager.md#commoneventmanagerunsubscribe) instead.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
...@@ -370,10 +388,10 @@ function unsubscribeCallBack(err) { ...@@ -370,10 +388,10 @@ function unsubscribeCallBack(err) {
} }
// Create a subscriber. // Create a subscriber.
CommonEvent.createSubscriber(subscribeInfo, createCB); CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack);
// Unsubscribe from the common event. // Unsubscribe from the common event.
CommonEvent.unsubscribe(subscriber, unsubscribeCB); CommonEvent.unsubscribe(subscriber, unsubscribeCallBack);
``` ```
## CommonEventSubscriber ## CommonEventSubscriber
......
...@@ -38,8 +38,7 @@ For details about the error codes, see [Event Error Codes](../errorcodes/errorco ...@@ -38,8 +38,7 @@ For details about the error codes, see [Event Error Codes](../errorcodes/errorco
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. | | 1500004 | not System services or System app. |
| 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. | | 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. | | 1500008 | Common Event Service does not complete initialization. |
| 1500009 | error obtaining system parameters. | | 1500009 | error obtaining system parameters. |
...@@ -83,8 +82,7 @@ Publishes a common event with given attributes. This API uses an asynchronous ca ...@@ -83,8 +82,7 @@ Publishes a common event with given attributes. This API uses an asynchronous ca
**Error codes** **Error codes**
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. | | 1500004 | not System services or System app. |
| 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. | | 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. | | 1500008 | Common Event Service does not complete initialization. |
| 1500009 | error obtaining system parameters. | | 1500009 | error obtaining system parameters. |
...@@ -139,9 +137,7 @@ Publishes a common event to a specific user. This API uses an asynchronous callb ...@@ -139,9 +137,7 @@ Publishes a common event to a specific user. This API uses an asynchronous callb
**Error codes** **Error codes**
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 202 | not system app. | | 1500004 | not System services or System app. |
| 401 | The parameter check failed. |
| 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. | | 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. | | 1500008 | Common Event Service does not complete initialization. |
| 1500009 | error obtaining system parameters. | | 1500009 | error obtaining system parameters. |
...@@ -193,9 +189,7 @@ Publishes a common event with given attributes to a specific user. This API uses ...@@ -193,9 +189,7 @@ Publishes a common event with given attributes to a specific user. This API uses
**Error codes** **Error codes**
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 202 | not system app. | | 1500004 | not System services or System app. |
| 401 | The parameter check failed. |
| 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. | | 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. | | 1500008 | Common Event Service does not complete initialization. |
| 1500009 | error obtaining system parameters. | | 1500009 | error obtaining system parameters. |
...@@ -246,14 +240,6 @@ Creates a subscriber. This API uses an asynchronous callback to return the resul ...@@ -246,14 +240,6 @@ Creates a subscriber. This API uses an asynchronous callback to return the resul
| subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information. | | subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information. |
| callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Yes | Callback used to return the result.| | callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
**Example** **Example**
...@@ -304,14 +290,6 @@ Creates a subscriber. This API uses a promise to return the result. ...@@ -304,14 +290,6 @@ Creates a subscriber. This API uses a promise to return the result.
| --------------------------------------------------------- | ---------------- | | --------------------------------------------------------- | ---------------- |
| Promise\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Promise used to return the subscriber object.| | Promise\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Promise used to return the subscriber object.|
**Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
**Example** **Example**
```ts ```ts
...@@ -359,7 +337,6 @@ Subscribes to common events. This API uses an asynchronous callback to return th ...@@ -359,7 +337,6 @@ Subscribes to common events. This API uses an asynchronous callback to return th
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 801 | capability not supported. | | 801 | capability not supported. |
| 1500007 | error sending message to Common Event Service. | | 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. | | 1500008 | Common Event Service does not complete initialization. |
...@@ -431,7 +408,6 @@ Unsubscribes from common events. This API uses an asynchronous callback to retur ...@@ -431,7 +408,6 @@ Unsubscribes from common events. This API uses an asynchronous callback to retur
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 801 | capability not supported. | | 801 | capability not supported. |
| 1500007 | error sending message to Common Event Service. | | 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. | | 1500008 | Common Event Service does not complete initialization. |
...@@ -490,737 +466,6 @@ try { ...@@ -490,737 +466,6 @@ try {
} }
``` ```
## CommonEventSubscriber
### getCode
getCode(callback: AsyncCallback\<number>): void
Obtains the result code of this common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------ |
| callback | AsyncCallback\<number> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 201 | The application dose not have permission to call the interface. |
| 202 | not system app. |
| 401 | The parameter check failed. |
| 1500004 | not system service. |
| 1500007 | The message send error. |
| 1500008 | The CEMS error. |
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for result code obtaining of an ordered common event.
function getCodeCallback(err, Code) {
if (err) {
console.error("getCode failed " + JSON.stringify(err));
} else {
console.info("getCode " + JSON.stringify(Code));
}
}
subscriber.getCode(getCodeCallback);
```
### getCode
getCode(): Promise\<number>
Obtains the result code of this common event. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<number> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 201 | The application dose not have permission to call the interface. |
| 202 | not system app. |
| 401 | The parameter check failed. |
| 1500004 | not system service. |
| 1500007 | The message send error. |
| 1500008 | The CEMS error. |
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.getCode().then((Code) => {
console.info("getCode " + JSON.stringify(Code));
}).catch((err) => {
console.error("getCode failed " + JSON.stringify(err));
});
```
### setCode
setCode(code: number, callback: AsyncCallback\<void>): void
Sets the result code for this common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------------------- |
| code | number | Yes | Result code of the common event. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for result code setting of an ordered common event.
function setCodeCallback(err) {
if (err) {
console.error("setCode failed " + JSON.stringify(err));
} else {
console.info("setCode");
}
}
subscriber.setCode(1, setCodeCallback);
```
### setCode
setCode(code: number): Promise\<void>
Sets the result code for this common event. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ |
| code | number | Yes | Result code of the common event.|
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.setCode(1).then(() => {
console.info("setCode");
}).catch((err) => {
console.error("setCode failed " + JSON.stringify(err));
});
```
### getData
getData(callback: AsyncCallback\<string>): void
Obtains the result data of this common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the result data.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for result data obtaining of an ordered common event.
function getDataCallback(err, Data) {
if (err) {
console.error("getData failed " + JSON.stringify(err));
} else {
console.info("getData " + JSON.stringify(Data));
}
}
subscriber.getData(getDataCallback);
```
### getData
getData(): Promise\<string>
Obtains the result data of this common event. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ---------------- | ------------------ |
| Promise\<string> | Promise used to return the result data.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.getData().then((Data) => {
console.info("getData " + JSON.stringify(Data));
}).catch((err) => {
console.error("getData failed " + JSON.stringify(err));
});
```
### setData
setData(data: string, callback: AsyncCallback\<void>): void
Sets the result data for this common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------- |
| data | string | Yes | Result data of the common event. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for result data setting of an ordered common event
function setDataCallback(err) {
if (err) {
console.error("setData failed " + JSON.stringify(err));
} else {
console.info("setData");
}
}
subscriber.setData("publish_data_changed", setDataCallback);
```
### setData
setData(data: string): Promise\<void>
Sets the result data for this common event. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------- |
| data | string | Yes | Result data of the common event.|
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.setData("publish_data_changed").then(() => {
console.info("setData");
}).catch((err) => {
console.error("setData failed " + JSON.stringify(err));
});
```
### setCodeAndData
setCodeAndData(code: number, data: string, callback:AsyncCallback\<void>): void
Sets the result code and result data for this common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------------------- |
| code | number | Yes | Result code of the common event. |
| data | string | Yes | Result data of the common event. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for result code and result data setting of an ordered common event.
function setCodeDataCallback(err) {
if (err) {
console.error("setCodeAndData failed " + JSON.stringify(err));
} else {
console.info("setCodeDataCallback");
}
}
subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCallback);
```
### setCodeAndData
setCodeAndData(code: number, data: string): Promise\<void>
Sets the result code and result data for this common event. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------- |
| code | number | Yes | Result code of the common event.|
| data | string | Yes | Result data of the common event.|
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.setCodeAndData(1, "publish_data_changed").then(() => {
console.info("setCodeAndData");
}).catch((err) => {
console.info("setCodeAndData failed " + JSON.stringify(err));
});
```
### isOrderedCommonEvent
isOrderedCommonEvent(callback: AsyncCallback\<boolean>): void
Checks whether this common event is an ordered one. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** means that the common event is an ordered one; and **false** means the opposite.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is an ordered one.
function isOrderedCallback(err, isOrdered) {
if (err) {
console.error("isOrderedCommonEvent failed " + JSON.stringify(err));
} else {
console.info("isOrdered " + JSON.stringify(isOrdered));
}
}
subscriber.isOrderedCommonEvent(isOrderedCallback);
```
### isOrderedCommonEvent
isOrderedCommonEvent(): Promise\<boolean>
Checks whether this common event is an ordered one. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ----------------- | -------------------------------- |
| Promise\<boolean> | Promise used to return the result. The value **true** means that the common event is an ordered one; and **false** means the opposite.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.isOrderedCommonEvent().then((isOrdered) => {
console.info("isOrdered " + JSON.stringify(isOrdered));
}).catch((err) => {
console.error("isOrdered failed " + JSON.stringify(err));
});
```
### isStickyCommonEvent
isStickyCommonEvent(callback: AsyncCallback\<boolean>): void
Checks whether this common event is a sticky one. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** means that the common event is a sticky one; and **false** means the opposite.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is a sticky one.
function isStickyCallback(err, isSticky) {
if (err) {
console.error("isStickyCommonEvent failed " + JSON.stringify(err));
} else {
console.info("isSticky " + JSON.stringify(isSticky));
}
}
subscriber.isStickyCommonEvent(isStickyCallback);
```
### isStickyCommonEvent
isStickyCommonEvent(): Promise\<boolean>
Checks whether this common event is a sticky one. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ----------------- | -------------------------------- |
| Promise\<boolean> | Promise used to return the result. The value **true** means that the common event is a sticky one; and **false** means the opposite.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.isStickyCommonEvent().then((isSticky) => {
console.info("isSticky " + JSON.stringify(isSticky));
}).catch((err) => {
console.error("isSticky failed " + JSON.stringify(err));
});
```
### abortCommonEvent
abortCommonEvent(callback: AsyncCallback\<void>): void
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for common event aborting.
function abortCallback(err) {
if (err) {
console.error("abortCommonEvent failed " + JSON.stringify(err));
} else {
console.info("abortCommonEvent");
}
}
subscriber.abortCommonEvent(abortCallback);
```
### abortCommonEvent
abortCommonEvent(): Promise\<void>
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.abortCommonEvent().then(() => {
console.info("abortCommonEvent");
}).catch((err) => {
console.error("abortCommonEvent failed " + JSON.stringify(err));
});
```
### clearAbortCommonEvent
clearAbortCommonEvent(callback: AsyncCallback\<void>): void
Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for clearing the aborted state of the current common event.
function clearAbortCallback(err) {
if (err) {
console.error("clearAbortCommonEvent failed " + JSON.stringify(err));
} else {
console.info("clearAbortCommonEvent");
}
}
subscriber.clearAbortCommonEvent(clearAbortCallback);
```
### clearAbortCommonEvent
clearAbortCommonEvent(): Promise\<void>
Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.clearAbortCommonEvent().then(() => {
console.info("clearAbortCommonEvent");
}).catch((err) => {
console.error("clearAbortCommonEvent failed " + JSON.stringify(err));
});
```
### getAbortCommonEvent
getAbortCommonEvent(callback: AsyncCallback\<boolean>): void
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** means that the ordered common event is in the aborted state; and **false** means the opposite.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is in the aborted state.
function getAbortCallback(err, AbortCommonEvent) {
if (err) {
console.error("getAbortCommonEvent failed " + JSON.stringify(err));
} else {
console.info("AbortCommonEvent " + AbortCommonEvent)
}
}
subscriber.getAbortCommonEvent(getAbortCallback);
```
### getAbortCommonEvent
getAbortCommonEvent(): Promise\<boolean>
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ----------------- | ---------------------------------- |
| Promise\<boolean> | Promise used to return the result. The value **true** means that the ordered common event is in the aborted state; and **false** means the opposite.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.getAbortCommonEvent().then((AbortCommonEvent) => {
console.info("AbortCommonEvent " + JSON.stringify(AbortCommonEvent));
}).catch((err) => {
console.error("getAbortCommonEvent failed " + JSON.stringify(err));
});
```
### getSubscribeInfo
getSubscribeInfo(callback: AsyncCallback\<CommonEventSubscribeInfo>): void
Obtains the subscriber information. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ---------------------- |
| callback | AsyncCallback\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | Yes | Callback used to return the subscriber information.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for subscriber information obtaining.
function getSubscribeInfoCallback(err, SubscribeInfo) {
if (err) {
console.error("getSubscribeInfo failed " + JSON.stringify(err));
} else {
console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo));
}
}
subscriber.getSubscribeInfo(getSubscribeInfoCallback);
```
### getSubscribeInfo
getSubscribeInfo(): Promise\<CommonEventSubscribeInfo>
Obtains the subscriber information. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ------------------------------------------------------------ | ---------------------- |
| Promise\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | Promise used to return the subscriber information.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.getSubscribeInfo().then((SubscribeInfo) => {
console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo));
}).catch((err) => {
console.error("getSubscribeInfo failed " + JSON.stringify(err));
});
```
### finishCommonEvent<sup>9+</sup>
finishCommonEvent(callback: AsyncCallback\<void\>): void
Finishes this ordered common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback returned after the ordered common event is finished.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for ordered common event finishing.
function finishCommonEventCallback(err) {
if (err) {
console.error("finishCommonEvent failed " + JSON.stringify(err));
} else {
console.info("FinishCommonEvent");
}
}
subscriber.finishCommonEvent(finishCommonEventCallback);
```
### finishCommonEvent<sup>9+</sup>
finishCommonEvent(): Promise\<void\>
Finishes this ordered common event. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.finishCommonEvent().then(() => {
console.info("FinishCommonEvent");
}).catch((err) => {
console.error("finishCommonEvent failed " + JSON.stringify(err));
});
```
## CommonEventData ## CommonEventData
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
......
...@@ -232,7 +232,6 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc ...@@ -232,7 +232,6 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 17700004 | The specified user ID is not found. |
| 17700023 | The specified default app does not exist. | | 17700023 | The specified default app does not exist. |
| 17700025 | The specified type is invalid. | | 17700025 | The specified type is invalid. |
...@@ -297,9 +296,9 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc ...@@ -297,9 +296,9 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
```ts ```ts
import defaultAppMgr from '@ohos.bundle.defaultAppManager'; import defaultAppMgr from '@ohos.bundle.defaultAppManager';
defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, { defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
bundleName: "com.example.myapplication", bundleName: "com.test.app",
moduleName: "module01", moduleName: "module01",
abilityName: "EntryAbility" abilityName: "MainAbility"
}).then((data) => { }).then((data) => {
console.info('Operation successful.'); console.info('Operation successful.');
}).catch((error) => { }).catch((error) => {
...@@ -308,9 +307,9 @@ defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, { ...@@ -308,9 +307,9 @@ defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
let userId = 100; let userId = 100;
defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, { defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
bundleName: "com.example.myapplication", bundleName: "com.test.app",
moduleName: "module01", moduleName: "module01",
abilityName: "EntryAbility" abilityName: "MainAbility"
}, userId).then((data) => { }, userId).then((data) => {
console.info('Operation successful.'); console.info('Operation successful.');
}).catch((error) => { }).catch((error) => {
...@@ -318,9 +317,9 @@ defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, { ...@@ -318,9 +317,9 @@ defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
}); });
defaultAppMgr.setDefaultApplication("image/png", { defaultAppMgr.setDefaultApplication("image/png", {
bundleName: "com.example.myapplication", bundleName: "com.test.app",
moduleName: "module01", moduleName: "module01",
abilityName: "EntryAbility" abilityName: "MainAbility"
}, userId).then((data) => { }, userId).then((data) => {
console.info('Operation successful.'); console.info('Operation successful.');
}).catch((error) => { }).catch((error) => {
...@@ -365,9 +364,9 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc ...@@ -365,9 +364,9 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
import defaultAppMgr from '@ohos.bundle.defaultAppManager'; import defaultAppMgr from '@ohos.bundle.defaultAppManager';
let userId = 100; let userId = 100;
defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, { defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
bundleName: "com.example.myapplication", bundleName: "com.test.app",
moduleName: "module01", moduleName: "module01",
abilityName: "EntryAbility" abilityName: "MainAbility"
}, userId, (err, data) => { }, userId, (err, data) => {
if (err) { if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err)); console.error('Operation failed. Cause: ' + JSON.stringify(err));
...@@ -377,9 +376,9 @@ defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, { ...@@ -377,9 +376,9 @@ defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
}); });
defaultAppMgr.setDefaultApplication("image/png", { defaultAppMgr.setDefaultApplication("image/png", {
bundleName: "com.example.myapplication", bundleName: "com.test.app",
moduleName: "module01", moduleName: "module01",
abilityName: "EntryAbility" abilityName: "MainAbility"
}, userId, (err, data) => { }, userId, (err, data) => {
if (err) { if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err)); console.error('Operation failed. Cause: ' + JSON.stringify(err));
...@@ -415,7 +414,6 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc ...@@ -415,7 +414,6 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------------- | | -------- | ---------------------------------------------- |
| 17700004 | The specified user ID is not found. |
| 17700025 | The specified type is invalid. | | 17700025 | The specified type is invalid. |
| 17700028 | The specified ability does not match the type. | | 17700028 | The specified ability does not match the type. |
...@@ -424,9 +422,9 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc ...@@ -424,9 +422,9 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
```ts ```ts
import defaultAppMgr from '@ohos.bundle.defaultAppManager'; import defaultAppMgr from '@ohos.bundle.defaultAppManager';
defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, { defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
bundleName: "com.example.myapplication", bundleName: "com.test.app",
moduleName: "module01", moduleName: "module01",
abilityName: "EntryAbility" abilityName: "MainAbility"
}, (err, data) => { }, (err, data) => {
if (err) { if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err)); console.error('Operation failed. Cause: ' + JSON.stringify(err));
...@@ -436,9 +434,9 @@ defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, { ...@@ -436,9 +434,9 @@ defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
}); });
defaultAppMgr.setDefaultApplication("image/png", { defaultAppMgr.setDefaultApplication("image/png", {
bundleName: "com.example.myapplication", bundleName: "com.test.app",
moduleName: "module01", moduleName: "module01",
abilityName: "EntryAbility" abilityName: "MainAbility"
}, (err, data) => { }, (err, data) => {
if (err) { if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err)); console.error('Operation failed. Cause: ' + JSON.stringify(err));
...@@ -574,7 +572,6 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc ...@@ -574,7 +572,6 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 17700004 | The specified user ID is not found. |
| 17700025 | The specified type is invalid. | | 17700025 | The specified type is invalid. |
**Example** **Example**
......
# @ohos.file.environment (Directory Environment Capability) # @ohos.file.environment (Directory Environment Capability)
The **Environment** module provides APIs for obtaining the root directories of the storage and public files. The **Environment** module provides APIs for obtaining the root directories of the storage and user files.
> **NOTE** > **NOTE**
> >
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module are system APIs and cannot be called by third-party applications. > - The APIs of this module are system APIs and cannot be called by third-party applications.
> - The APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
## Modules to Import ## Modules to Import
...@@ -28,6 +27,15 @@ Obtains the root directory of the storage. This API uses a promise to return the ...@@ -28,6 +27,15 @@ Obtains the root directory of the storage. This API uses a promise to return the
| --------------------- | ---------------- | | --------------------- | ---------------- |
| Promise&lt;string&gt; | Promise used to return the root directory of the storage.| | Promise&lt;string&gt; | Promise used to return the root directory of the storage.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID | Error Message |
| ---------------------------- | ---------- |
| 202 | The caller is not a system application |
| 13900020 | Invalid argument |
| 13900042 | Unknown error |
**Example** **Example**
```js ```js
...@@ -52,6 +60,15 @@ Obtains the root directory of the storage. This API uses an asynchronous callbac ...@@ -52,6 +60,15 @@ Obtains the root directory of the storage. This API uses an asynchronous callbac
| -------- | --------------------------- | ---- | -------------------------------- | | -------- | --------------------------- | ---- | -------------------------------- |
| callback | AsyncCallback&lt;string&gt; | Yes | Asynchronous callback invoked to return the root directory of the storage.| | callback | AsyncCallback&lt;string&gt; | Yes | Asynchronous callback invoked to return the root directory of the storage.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID | Error Message |
| ---------------------------- | ---------- |
| 202 | The caller is not a system application |
| 13900020 | Invalid argument |
| 13900042 | Unknown error |
**Example** **Example**
```js ```js
...@@ -68,7 +85,7 @@ Obtains the root directory of the storage. This API uses an asynchronous callbac ...@@ -68,7 +85,7 @@ Obtains the root directory of the storage. This API uses an asynchronous callbac
getUserDataDir():Promise&lt;string&gt; getUserDataDir():Promise&lt;string&gt;
Obtains the root directory of public files. This API uses a promise to return the result. Obtains the root directory of user files. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.File.Environment **System capability**: SystemCapability.FileManagement.File.Environment
...@@ -76,7 +93,16 @@ Obtains the root directory of public files. This API uses a promise to return th ...@@ -76,7 +93,16 @@ Obtains the root directory of public files. This API uses a promise to return th
| Type | Description | | Type | Description |
| --------------------- | ------------------ | | --------------------- | ------------------ |
| Promise&lt;string&gt; | Promise returned with the root directory of public files.| | Promise&lt;string&gt; | Promise used to return the root directory of user files.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID | Error Message |
| ---------------------------- | ---------- |
| 202 | The caller is not a system application |
| 13900020 | Invalid argument |
| 13900042 | Unknown error |
**Example** **Example**
...@@ -92,7 +118,7 @@ Obtains the root directory of public files. This API uses a promise to return th ...@@ -92,7 +118,7 @@ Obtains the root directory of public files. This API uses a promise to return th
getUserDataDir(callback:AsyncCallback&lt;string&gt;): void getUserDataDir(callback:AsyncCallback&lt;string&gt;): void
Obtains the root directory of public files. This API uses an asynchronous callback to return the result. Obtains the root directory of user files. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.File.Environment **System capability**: SystemCapability.FileManagement.File.Environment
...@@ -100,7 +126,16 @@ Obtains the root directory of public files. This API uses an asynchronous callba ...@@ -100,7 +126,16 @@ Obtains the root directory of public files. This API uses an asynchronous callba
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | -------------------------------- | | -------- | --------------------------- | ---- | -------------------------------- |
| callback | AsyncCallback&lt;string&gt; | Yes | Asynchronous callback used to return the root directory of public files.| | callback | AsyncCallback&lt;string&gt; | Yes | Asynchronous callback used to return the root directory of user files.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID | Error Message |
| ---------------------------- | ---------- |
| 202 | The caller is not a system application |
| 13900020 | Invalid argument |
| 13900042 | Unknown error |
**Example** **Example**
......
...@@ -41,9 +41,9 @@ Obtains the URI of a file in synchronous mode. ...@@ -41,9 +41,9 @@ Obtains the URI of a file in synchronous mode.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------- | ---------- | | ---------------------------- | ---------- |
| string | File URI obtained.| | string | File URI obtained.|
**Error codes** **Error codes**
...@@ -52,7 +52,6 @@ For details about the error codes, see [File Management Error Codes](../errorcod ...@@ -52,7 +52,6 @@ For details about the error codes, see [File Management Error Codes](../errorcod
| ---------------------------- | ---------- | | ---------------------------- | ---------- |
| 401 | The input parameter is invalid | | 401 | The input parameter is invalid |
**Example** **Example**
```js ```js
......
...@@ -14,7 +14,7 @@ import fs from '@ohos.file.fs'; ...@@ -14,7 +14,7 @@ import fs from '@ohos.file.fs';
## Guidelines ## Guidelines
Before using the APIs provided by this module to perform operations on a file or folder, obtain the application sandbox path of the file or folder as follows: Before using the APIs provided by this module to perform operations on a file or directory, obtain the application sandbox path of the file or directory as follows:
**Stage Model** **Stage Model**
...@@ -58,13 +58,13 @@ Obtains detailed file information. This API uses a promise to return the result. ...@@ -58,13 +58,13 @@ Obtains detailed file information. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------- | ---------- | | ---------------------------- | ---------- |
| Promise&lt;[Stat](#stat)&gt; | Promise used to return the file information obtained.| | Promise&lt;[Stat](#stat)&gt; | Promise used to return the file information obtained.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -94,7 +94,7 @@ Obtains detailed file information. This API uses an asynchronous callback to ret ...@@ -94,7 +94,7 @@ Obtains detailed file information. This API uses an asynchronous callback to ret
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -124,13 +124,13 @@ Obtains detailed file information synchronously. ...@@ -124,13 +124,13 @@ Obtains detailed file information synchronously.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------- | ---------- | | ------------- | ---------- |
| [Stat](#stat) | File information obtained.| | [Stat](#stat) | File information obtained.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -155,13 +155,13 @@ Checks whether a file exists. This API uses a promise to return the result. ...@@ -155,13 +155,13 @@ Checks whether a file exists. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means the file exists; the value false means the opposite.| | Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means the file exists; the value **false** means the opposite.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -193,7 +193,7 @@ Checks whether a file exists. This API uses an asynchronous callback to return t ...@@ -193,7 +193,7 @@ Checks whether a file exists. This API uses an asynchronous callback to return t
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -226,13 +226,13 @@ Synchronously checks whether a file exists. ...@@ -226,13 +226,13 @@ Synchronously checks whether a file exists.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| boolean | Returns **true** if the file exists; returns **false** otherwise.| | boolean | Returns **true** if the file exists; returns **false** otherwise.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -259,19 +259,19 @@ Closes a file. This API uses a promise to return the result. ...@@ -259,19 +259,19 @@ Closes a file. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| file | [File](#file)\|number | Yes | File object or FD of the file to close.| | file | [File](#file)\|number | Yes | File object or FD of the file to close.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -296,14 +296,14 @@ Closes a file. This API uses an asynchronous callback to return the result. ...@@ -296,14 +296,14 @@ Closes a file. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ------------ | | -------- | ------------------------- | ---- | ------------ |
| file | [File](#file)\|number | Yes | File object or FD of the file to close.| | file | [File](#file)\|number | Yes | File object or FD of the file to close.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is closed asynchronously.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked immediately after the file is closed.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -329,13 +329,13 @@ Synchronously closes a file. ...@@ -329,13 +329,13 @@ Synchronously closes a file.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| file | [File](#file)\|number | Yes | File object or FD of the file to close.| | file | [File](#file)\|number | Yes | File object or FD of the file to close.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -355,21 +355,21 @@ Copies a file. This API uses a promise to return the result. ...@@ -355,21 +355,21 @@ Copies a file. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | -------------------------- | ---- | ---------------------------------------- | | ---- | -------------------------- | ---- | ---------------------------------------- |
| src | string\|number | Yes | Path or FD of the file to copy. | | src | string\|number | Yes | Path or FD of the file to copy. |
| dest | string\|number | Yes | Destination path of the file or FD of the file created. | | dest | string\|number | Yes | Destination path of the file or FD of the file created. |
| mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: overwrite the file of the same name.| | mode | number | No | Whether to overwrite the file with the same name in the destination directory. The default value is **0**, which is the only value supported.<br>**0**: overwrite the file with the same name.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -393,16 +393,16 @@ Copies a file. This API uses an asynchronous callback to return the result. ...@@ -393,16 +393,16 @@ Copies a file. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------------------------- | ---- | ---------------------------------------- | | -------- | -------------------------- | ---- | ---------------------------------------- |
| src | string\|number | Yes | Path or FD of the file to copy. | | src | string\|number | Yes | Path or FD of the file to copy. |
| dest | string\|number | Yes | Destination path of the file or FD of the file created. | | dest | string\|number | Yes | Destination path of the file or FD of the file created. |
| mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: overwrite the file with the same name and truncate the part that is not overwritten.| | mode | number | No | Whether to overwrite the file with the same name in the destination directory. The default value is **0**, which is the only value supported.<br>**0**: overwrite the file with the same name and truncate the part that is not overwritten.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is copied asynchronously. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked immediately after the file is copied. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -429,15 +429,15 @@ Synchronously copies a file. ...@@ -429,15 +429,15 @@ Synchronously copies a file.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | -------------------------- | ---- | ---------------------------------------- | | ---- | -------------------------- | ---- | ---------------------------------------- |
| src | string\|number | Yes | Path or FD of the file to copy. | | src | string\|number | Yes | Path or FD of the file to copy. |
| dest | string\|number | Yes | Destination path of the file or FD of the file created. | | dest | string\|number | Yes | Destination path of the file or FD of the file created. |
| mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: overwrite the file with the same name and truncate the part that is not overwritten.| | mode | number | No | Whether to overwrite the file with the same name in the destination directory. The default value is **0**, which is the only value supported.<br>**0**: overwrite the file with the same name and truncate the part that is not overwritten.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -463,13 +463,13 @@ Creates a directory. This API uses a promise to return the result. ...@@ -463,13 +463,13 @@ Creates a directory. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -499,7 +499,7 @@ Creates a directory. This API uses an asynchronous callback to return the result ...@@ -499,7 +499,7 @@ Creates a directory. This API uses an asynchronous callback to return the result
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -530,7 +530,7 @@ Synchronously creates a directory. ...@@ -530,7 +530,7 @@ Synchronously creates a directory.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -556,13 +556,13 @@ Opens a file. This API uses a promise to return the result. File uniform resourc ...@@ -556,13 +556,13 @@ Opens a file. This API uses a promise to return the result. File uniform resourc
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ----------- | | --------------------- | ----------- |
| Promise&lt;[File](#file)&gt; | Promise used to return the file object.| | Promise&lt;[File](#file)&gt; | Promise used to return the file object.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -593,7 +593,7 @@ Opens a file. This API uses an asynchronous callback to return the result. File ...@@ -593,7 +593,7 @@ Opens a file. This API uses an asynchronous callback to return the result. File
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -625,13 +625,13 @@ Synchronously opens a file. File URIs are supported. ...@@ -625,13 +625,13 @@ Synchronously opens a file. File URIs are supported.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ----------- | | ------ | ----------- |
| [File](#file) | File object opened.| | [File](#file) | File object opened.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -660,13 +660,13 @@ Reads data from a file. This API uses a promise to return the result. ...@@ -660,13 +660,13 @@ Reads data from a file. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ------ | | ---------------------------------- | ------ |
| Promise&lt;number&gt; | Promise used to return the data read.| | Promise&lt;number&gt; | Promise used to return the data read.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -693,16 +693,16 @@ Reads data from a file. This API uses an asynchronous callback to return the res ...@@ -693,16 +693,16 @@ Reads data from a file. This API uses an asynchronous callback to return the res
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.| | options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is read asynchronously. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is read asynchronously. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -731,21 +731,21 @@ Synchronously reads data from a file. ...@@ -731,21 +731,21 @@ Synchronously reads data from a file.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.| | options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------- | | ------ | -------- |
| number | Length of the data read.| | number | Length of the data read.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -773,13 +773,13 @@ Deletes a directory. This API uses a promise to return the result. ...@@ -773,13 +773,13 @@ Deletes a directory. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -809,7 +809,7 @@ Deletes a directory. This API uses an asynchronous callback to return the result ...@@ -809,7 +809,7 @@ Deletes a directory. This API uses an asynchronous callback to return the result
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -840,7 +840,7 @@ Synchronously deletes a directory. ...@@ -840,7 +840,7 @@ Synchronously deletes a directory.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -865,13 +865,13 @@ Deletes a file. This API uses a promise to return the result. ...@@ -865,13 +865,13 @@ Deletes a file. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -897,11 +897,11 @@ Deletes a file. This API uses an asynchronous callback to return the result. ...@@ -897,11 +897,11 @@ Deletes a file. This API uses an asynchronous callback to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | -------------------------- | | -------- | ------------------------- | ---- | -------------------------- |
| path | string | Yes | Application sandbox path of the file.| | path | string | Yes | Application sandbox path of the file.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is deleted asynchronously. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked immediately after the file is deleted. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -932,7 +932,7 @@ Synchronously deletes a file. ...@@ -932,7 +932,7 @@ Synchronously deletes a file.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -952,21 +952,21 @@ Writes data into a file. This API uses a promise to return the result. ...@@ -952,21 +952,21 @@ Writes data into a file. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------------------- | | ------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| | options | Object | No | The options are as follows:<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | -------- | | --------------------- | -------- |
| Promise&lt;number&gt; | Promise used to return the length of the data written.| | Promise&lt;number&gt; | Promise used to return the length of the data written.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -991,16 +991,16 @@ Writes data into a file. This API uses an asynchronous callback to return the re ...@@ -991,16 +991,16 @@ Writes data into a file. This API uses an asynchronous callback to return the re
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------- | ---- | ---------------------------------------- | | -------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| | options | Object | No | The options are as follows:<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is written asynchronously. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is written asynchronously. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1027,21 +1027,21 @@ Synchronously writes data into a file. ...@@ -1027,21 +1027,21 @@ Synchronously writes data into a file.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------------------- | | ------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| | options | Object | No | The options are as follows:<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------- | | ------ | -------- |
| number | Length of the data written in the file.| | number | Length of the data written in the file.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1070,13 +1070,13 @@ Truncates a file. This API uses a promise to return the result. ...@@ -1070,13 +1070,13 @@ Truncates a file. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1108,7 +1108,7 @@ Truncates a file. This API uses an asynchronous callback to return the result. ...@@ -1108,7 +1108,7 @@ Truncates a file. This API uses an asynchronous callback to return the result.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1141,7 +1141,7 @@ Synchronously truncates a file. ...@@ -1141,7 +1141,7 @@ Synchronously truncates a file.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1168,13 +1168,13 @@ Reads the text content of a file. This API uses a promise to return the result. ...@@ -1168,13 +1168,13 @@ Reads the text content of a file. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------- | | --------------------- | ---------- |
| Promise&lt;string&gt; | Promise used to return the content read.| | Promise&lt;string&gt; | Promise used to return the content read.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1205,7 +1205,7 @@ Reads the text content of a file. This API uses an asynchronous callback to retu ...@@ -1205,7 +1205,7 @@ Reads the text content of a file. This API uses an asynchronous callback to retu
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1237,13 +1237,13 @@ Synchronously reads the text of a file. ...@@ -1237,13 +1237,13 @@ Synchronously reads the text of a file.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------------------- | | ------ | -------------------- |
| string | Promise used to return the content of the file read.| | string | Promise used to return the content of the file read.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1269,13 +1269,13 @@ Obtains information about a symbolic link. This API uses a promise to return the ...@@ -1269,13 +1269,13 @@ Obtains information about a symbolic link. This API uses a promise to return the
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------- | ---------- | | ---------------------------- | ---------- |
| Promise&lt;[Stat](#stat)&gt; | Promise used to return the symbolic link information obtained. For details, see **stat**.| | Promise&lt;[Stat](#stat)&gt; | Promise used to return the symbolic link information obtained. For details, see **stat**.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1305,7 +1305,7 @@ Obtains information about a symbolic link. This API uses an asynchronous callbac ...@@ -1305,7 +1305,7 @@ Obtains information about a symbolic link. This API uses an asynchronous callbac
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1336,13 +1336,13 @@ Obtains information about a symbolic link synchronously. ...@@ -1336,13 +1336,13 @@ Obtains information about a symbolic link synchronously.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------- | ---------- | | ------------- | ---------- |
| [Stat](#stat) | File information obtained.| | [Stat](#stat) | File information obtained.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1355,7 +1355,7 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem ...@@ -1355,7 +1355,7 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem
rename(oldPath: string, newPath: string): Promise&lt;void&gt; rename(oldPath: string, newPath: string): Promise&lt;void&gt;
Renames a file or folder. This API uses a promise to return the result. Renames a file or directory. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO **System capability**: SystemCapability.FileManagement.File.FileIO
...@@ -1363,18 +1363,18 @@ Renames a file or folder. This API uses a promise to return the result. ...@@ -1363,18 +1363,18 @@ Renames a file or folder. This API uses a promise to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ---------------------------- | | ------- | ------ | ---- | ---------------------------- |
| oldPath | string | Yes | Application sandbox path of the file or folder to rename.| | oldPath | string | Yes | Application sandbox path of the file to rename.|
| newPath | string | Yes | Application sandbox path of the renamed file or folder. | | newPath | string | Yes | Application sandbox path of the renamed file. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1392,7 +1392,7 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem ...@@ -1392,7 +1392,7 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem
rename(oldPath: string, newPath: string, callback: AsyncCallback&lt;void&gt;): void rename(oldPath: string, newPath: string, callback: AsyncCallback&lt;void&gt;): void
Renames a file or folder. This API uses an asynchronous callback to return the result. Renames a file or directory. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO **System capability**: SystemCapability.FileManagement.File.FileIO
...@@ -1400,13 +1400,13 @@ Renames a file or folder. This API uses an asynchronous callback to return the r ...@@ -1400,13 +1400,13 @@ Renames a file or folder. This API uses an asynchronous callback to return the r
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------------------------- | | -------- | ------------------------- | ---- | ---------------------------- |
| oldPath | string | Yes | Application sandbox path of the file or folder to rename.| | oldPath | string | Yes | Application sandbox path of the file to rename.|
| newPath | string | Yes | Application sandbox path of the renamed file or folder. | | newPath | string | Yes | Application sandbox path of the renamed file. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file or folder is asynchronously renamed. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is asynchronously renamed. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1426,7 +1426,7 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem ...@@ -1426,7 +1426,7 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem
renameSync(oldPath: string, newPath: string): void renameSync(oldPath: string, newPath: string): void
Renames a file or folder synchronously. Renames a file or directory synchronously.
**System capability**: SystemCapability.FileManagement.File.FileIO **System capability**: SystemCapability.FileManagement.File.FileIO
...@@ -1434,12 +1434,12 @@ Renames a file or folder synchronously. ...@@ -1434,12 +1434,12 @@ Renames a file or folder synchronously.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ---------------------------- | | ------- | ------ | ---- | ---------------------------- |
| oldPath | string | Yes | Application sandbox path of the file or folder to rename.| | oldPath | string | Yes | Application sandbox path of the file to rename.|
| newPath | string | Yes | Application sandbox path of the renamed file or folder. | | newPath | string | Yes | Application sandbox path of the renamed file. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1459,19 +1459,19 @@ Flushes data of a file to disk. This API uses a promise to return the result. ...@@ -1459,19 +1459,19 @@ Flushes data of a file to disk. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | FD of the file.| | fd | number | Yes | FD of the file.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1495,14 +1495,14 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return ...@@ -1495,14 +1495,14 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | --------------- | | -------- | ------------------------- | ---- | --------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| Callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| | Callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file data is synchronized in asynchronous mode.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1530,13 +1530,13 @@ Flushes data of a file to disk synchronously. ...@@ -1530,13 +1530,13 @@ Flushes data of a file to disk synchronously.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | FD of the file.| | fd | number | Yes | FD of the file.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1557,19 +1557,19 @@ Flushes data of a file to disk. This API uses a promise to return the result. ** ...@@ -1557,19 +1557,19 @@ Flushes data of a file to disk. This API uses a promise to return the result. **
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | FD of the file.| | fd | number | Yes | FD of the file.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1594,14 +1594,14 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return ...@@ -1594,14 +1594,14 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------- | ---- | ----------------- | | -------- | ------------------------------- | ---- | ----------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file data is synchronized in asynchronous mode.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1628,13 +1628,13 @@ Synchronizes data in a file synchronously. ...@@ -1628,13 +1628,13 @@ Synchronizes data in a file synchronously.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | FD of the file.| | fd | number | Yes | FD of the file.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1662,13 +1662,13 @@ Creates a symbolic link based on a file path. This API uses a promise to return ...@@ -1662,13 +1662,13 @@ Creates a symbolic link based on a file path. This API uses a promise to return
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1700,7 +1700,7 @@ Creates a symbolic link based on a file path. This API uses an asynchronous call ...@@ -1700,7 +1700,7 @@ Creates a symbolic link based on a file path. This API uses an asynchronous call
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1733,7 +1733,7 @@ Synchronously creates a symbolic link based on a file path. ...@@ -1733,7 +1733,7 @@ Synchronously creates a symbolic link based on a file path.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1756,28 +1756,28 @@ Lists all files in a directory. This API uses a promise to return the result.<br ...@@ -1756,28 +1756,28 @@ Lists all files in a directory. This API uses a promise to return the result.<br
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| path | string | Yes | Application sandbox path of the folder.| | path | string | Yes | Application sandbox path of the folder.|
| options | Object | No | File filtering options. The files are not filtered by default.| | options | Object | No | File filtering options. The files are not filtered by default.|
**options parameters** **options parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| recursion | boolean | No | Whether to list all files in subdirectories recursively. The default value is **false**.| | recursion | boolean | No | Whether to list all files in subdirectories recursively. The default value is **false**.|
| listNum | number | No | Number of file names to list. The default value **0** means to list all files.| | listNum | number | No | Number of file names to list. The default value **0** means to list all files.|
| filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.| | filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------- | | --------------------- | ---------- |
| Promise&lt;string[]&gt; | Promise used to return the files names listed.| | Promise&lt;string[]&gt; | Promise used to return the files names listed.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1813,23 +1813,23 @@ Lists all files in a directory. This API uses an asynchronous callback to return ...@@ -1813,23 +1813,23 @@ Lists all files in a directory. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| path | string | Yes | Application sandbox path of the folder.| | path | string | Yes | Application sandbox path of the folder.|
| options | Object | No | File filtering options. The files are not filtered by default.| | options | Object | No | File filtering options. The files are not filtered by default.|
| callback | AsyncCallback&lt;string[]&gt; | Yes | Callback invoked to return the file names listed. | | callback | AsyncCallback&lt;string[]&gt; | Yes | Callback invoked to return the file names listed. |
**options parameters** **options parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| recursion | boolean | No | Whether to list all files in subdirectories recursively. The default value is **false**.| | recursion | boolean | No | Whether to list all files in subdirectories recursively. The default value is **false**.|
| listNum | number | No | Number of file names to list. The default value **0** means to list all files.| | listNum | number | No | Number of file names to list. The default value **0** means to list all files.|
| filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.| | filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1868,28 +1868,28 @@ Lists all files in a directory synchronously. This API supports recursive listin ...@@ -1868,28 +1868,28 @@ Lists all files in a directory synchronously. This API supports recursive listin
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| path | string | Yes | Application sandbox path of the folder.| | path | string | Yes | Application sandbox path of the folder.|
| options | Object | No | File filtering options. The files are not filtered by default.| | options | Object | No | File filtering options. The files are not filtered by default.|
**options parameters** **options parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| recursion | boolean | No | Whether to list all files in subdirectories recursively. The default value is **false**.| | recursion | boolean | No | Whether to list all files in subdirectories recursively. The default value is **false**.|
| listNum | number | No | Number of file names to list. The default value **0** means to list all files.| | listNum | number | No | Number of file names to list. The default value **0** means to list all files.|
| filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.| | filter | [Filter](#filter) | No | File filtering options. Currently, only the match by file name extension, fuzzy search by file name, and filter by file size or latest modification time are supported.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------- | | --------------------- | ---------- |
| string[] | File names listed.| | string[] | File names listed.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1921,21 +1921,21 @@ Moves a file. This API uses a promise to return the result. ...@@ -1921,21 +1921,21 @@ Moves a file. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| src | string | Yes | Application sandbox path of the source file.| | src | string | Yes | Application sandbox path of the source file.|
| dest | string | Yes | Application sandbox path of the destination file.| | dest | string | Yes | Application sandbox path of the destination file.|
| mode | number | No | Whether to overwrite the file of the same name in the destination directory. The value **0** means to overwrite the file of the same name in the destination directory. The value **1** means to throw an exception if a file of the same name exists in the destination directory. The default value is **0**.| | mode | number | No | Whether to overwrite the file with the same name in the destination directory.<br> The value **0** means to overwrite the file with the same name in the destination directory; the value **1** means to throw an exception.<br> The default value is **0**.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1959,16 +1959,16 @@ Moves a file. This API uses an asynchronous callback to return the result. ...@@ -1959,16 +1959,16 @@ Moves a file. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| src | string | Yes | Application sandbox path of the source file.| | src | string | Yes | Application sandbox path of the source file.|
| dest | string | Yes | Application sandbox path of the destination file.| | dest | string | Yes | Application sandbox path of the destination file.|
| mode | number | No | Whether to overwrite the file of the same name in the destination directory. The value **0** means to overwrite the file of the same name in the destination directory. The value **1** means to throw an exception if a file of the same name exists in the destination directory. The default value is **0**.| | mode | number | No | Whether to overwrite the file with the same name in the destination directory.<br> The value **0** means to overwrite the file with the same name in the destination directory; the value **1** means to throw an exception.<br> The default value is **0**.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is moved. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is moved. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -1994,15 +1994,15 @@ Moves a file synchronously. ...@@ -1994,15 +1994,15 @@ Moves a file synchronously.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| src | string | Yes | Application sandbox path of the source file.| | src | string | Yes | Application sandbox path of the source file.|
| dest | string | Yes | Application sandbox path of the destination file.| | dest | string | Yes | Application sandbox path of the destination file.|
| mode | number | No | Whether to overwrite the file of the same name in the destination directory. The value **0** means to overwrite the file of the same name in the destination directory. The value **1** means to throw an exception if a file of the same name exists in the destination directory. The default value is **0**.| | mode | number | No | Whether to overwrite the file with the same name in the destination directory.<br> The value **0** means to overwrite the file with the same name in the destination directory; the value **1** means to throw an exception.<br> The default value is **0**.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2023,19 +2023,19 @@ Creates a temporary directory. This API uses a promise to return the result. ...@@ -2023,19 +2023,19 @@ Creates a temporary directory. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------- | | --------------------- | ---------- |
| Promise&lt;string&gt; | Promise used to return the unique directory generated.| | Promise&lt;string&gt; | Promise used to return the unique directory generated.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2057,14 +2057,14 @@ Creates a temporary directory. This API uses an asynchronous callback to return ...@@ -2057,14 +2057,14 @@ Creates a temporary directory. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | --------------------------- | | -------- | --------------------------- | ---- | --------------------------- |
| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.|
| callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked when a temporary directory is created asynchronously. | | callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked when a temporary directory is created asynchronously. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2088,25 +2088,25 @@ Synchronously creates a temporary directory. ...@@ -2088,25 +2088,25 @@ Synchronously creates a temporary directory.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ---------- | | ------ | ---------- |
| string | Unique path generated.| | string | Unique path generated.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
```js ```js
let res = fs.mkdtempSync(pathDir + "/XXXXXX"); let res = fs.mkdtempSync(pathDir + "/XXXXXX");
``` ```
## fs.createStream ## fs.createStream
...@@ -2125,13 +2125,13 @@ Creates a stream based on the file path. This API uses a promise to return the r ...@@ -2125,13 +2125,13 @@ Creates a stream based on the file path. This API uses a promise to return the r
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------- | --------- | | --------------------------------- | --------- |
| Promise&lt;[Stream](#stream)&gt; | Promise used to return the result.| | Promise&lt;[Stream](#stream)&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2163,7 +2163,7 @@ Creates a stream based on the file path. This API uses an asynchronous callback ...@@ -2163,7 +2163,7 @@ Creates a stream based on the file path. This API uses an asynchronous callback
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2195,13 +2195,13 @@ Synchronously creates a stream based on the file path. ...@@ -2195,13 +2195,13 @@ Synchronously creates a stream based on the file path.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------ | --------- | | ------------------ | --------- |
| [Stream](#stream) | Stream opened.| | [Stream](#stream) | Stream opened.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2221,20 +2221,20 @@ Opens a stream based on the file descriptor. This API uses a promise to return t ...@@ -2221,20 +2221,20 @@ Opens a stream based on the file descriptor. This API uses a promise to return t
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------------------- | | ---- | ------ | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| | mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------- | --------- | | --------------------------------- | --------- |
| Promise&lt;[Stream](#stream)&gt; | Promise used to return the result.| | Promise&lt;[Stream](#stream)&gt; | Promise used to return the result.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2259,15 +2259,15 @@ Opens a stream based on the file descriptor. This API uses an asynchronous callb ...@@ -2259,15 +2259,15 @@ Opens a stream based on the file descriptor. This API uses an asynchronous callb
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| | mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
| callback | AsyncCallback&lt;[Stream](#stream)&gt; | Yes | Callback invoked when the stream is open asynchronously. | | callback | AsyncCallback&lt;[Stream](#stream)&gt; | Yes | Callback invoked when the stream is opened. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2294,20 +2294,20 @@ Synchronously opens a stream based on the file descriptor. ...@@ -2294,20 +2294,20 @@ Synchronously opens a stream based on the file descriptor.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------------------- | | ---- | ------ | ---- | ---------------------------------------- |
| fd | number | Yes | FD of the file. | | fd | number | Yes | FD of the file. |
| mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| | mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------ | --------- | | ------------------ | --------- |
| [Stream](#stream) | Stream opened.| | [Stream](#stream) | Stream opened.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2327,7 +2327,7 @@ Represents detailed file information. Before calling any API of the **Stat()** c ...@@ -2327,7 +2327,7 @@ Represents detailed file information. Before calling any API of the **Stat()** c
### Attributes ### Attributes
| Name | Type | Readable | Writable | Description | | Name | Type | Readable | Writable | Description |
| ------ | ------ | ---- | ---- | ---------------------------------------- | | ------ | ------ | ---- | ---- | ---------------------------------------- |
| ino | number | Yes | No | File ID. Different files on the same device have different **ino**s.| | | ino | number | Yes | No | File ID. Different files on the same device have different **ino**s.| |
| mode | number | Yes | No | File permissions. The meaning of each bit is as follows:<br>- **0o400**: The owner has the read permission on a regular file or a directory entry.<br>- **0o200**: The owner has the permission to write a regular file or create and delete a directory entry.<br>- **0o100**: The owner has the permission to execute a regular file or search for the specified path in a directory.<br>- **0o040**: The user group has the read permission on a regular file or a directory entry.<br>- **0o020**: The user group has the permission to write a regular file or create and delete a directory entry.<br>- **0o010**: The user group has the permission to execute a regular file or search for the specified path in a directory.<br>- **0o004**: Other users have the permission to read a regular file or read a directory entry.<br>- **0o002**: Other users have the permission to write a regular file or create and delete a directory entry.<br>- **0o001**: Other users have the permission to execute a regular file or search for the specified path in a directory.| | mode | number | Yes | No | File permissions. The meaning of each bit is as follows:<br>- **0o400**: The owner has the read permission on a regular file or a directory entry.<br>- **0o200**: The owner has the permission to write a regular file or create and delete a directory entry.<br>- **0o100**: The owner has the permission to execute a regular file or search for the specified path in a directory.<br>- **0o040**: The user group has the read permission on a regular file or a directory entry.<br>- **0o020**: The user group has the permission to write a regular file or create and delete a directory entry.<br>- **0o010**: The user group has the permission to execute a regular file or search for the specified path in a directory.<br>- **0o004**: Other users have the permission to read a regular file or read a directory entry.<br>- **0o002**: Other users have the permission to write a regular file or create and delete a directory entry.<br>- **0o001**: Other users have the permission to execute a regular file or search for the specified path in a directory.|
| uid | number | Yes | No | ID of the file owner.| | uid | number | Yes | No | ID of the file owner.|
...@@ -2347,13 +2347,13 @@ Checks whether this file is a block special file. A block special file supports ...@@ -2347,13 +2347,13 @@ Checks whether this file is a block special file. A block special file supports
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ---------------- | | ------- | ---------------- |
| boolean | Whether the file is a block special file.| | boolean | Whether the file is a block special file.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2372,13 +2372,13 @@ Checks whether this file is a character special file. A character special file s ...@@ -2372,13 +2372,13 @@ Checks whether this file is a character special file. A character special file s
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------- | | ------- | ----------------- |
| boolean | Whether the file is a character special file.| | boolean | Whether the file is a character special file.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2397,13 +2397,13 @@ Checks whether this file is a directory. ...@@ -2397,13 +2397,13 @@ Checks whether this file is a directory.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ------------- | | ------- | ------------- |
| boolean | Whether the file is a directory.| | boolean | Whether the file is a directory.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2422,13 +2422,13 @@ Checks whether this file is a named pipe (or FIFO). Named pipes are used for int ...@@ -2422,13 +2422,13 @@ Checks whether this file is a named pipe (or FIFO). Named pipes are used for int
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------------- | | ------- | --------------------- |
| boolean | Whether the file is a FIFO.| | boolean | Whether the file is a FIFO.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2447,13 +2447,13 @@ Checks whether this file is a regular file. ...@@ -2447,13 +2447,13 @@ Checks whether this file is a regular file.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------- | | ------- | --------------- |
| boolean | Whether the file is a regular file.| | boolean | Whether the file is a regular file.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2472,13 +2472,13 @@ Checks whether this file is a socket. ...@@ -2472,13 +2472,13 @@ Checks whether this file is a socket.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | -------------- | | ------- | -------------- |
| boolean | Whether the file is a socket.| | boolean | Whether the file is a socket.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2497,13 +2497,13 @@ Checks whether this file is a symbolic link. ...@@ -2497,13 +2497,13 @@ Checks whether this file is a symbolic link.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------- | | ------- | --------------- |
| boolean | Whether the file is a symbolic link.| | boolean | Whether the file is a symbolic link.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2526,13 +2526,13 @@ Closes the stream. This API uses a promise to return the result. ...@@ -2526,13 +2526,13 @@ Closes the stream. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ------------- | | ------------------- | ------------- |
| Promise&lt;void&gt; | Promise used to return the stream close result.| | Promise&lt;void&gt; | Promise used to return the stream close result.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2556,13 +2556,13 @@ Closes the stream. This API uses an asynchronous callback to return the result. ...@@ -2556,13 +2556,13 @@ Closes the stream. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ------------- | | -------- | ------------------------- | ---- | ------------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the stream is closed asynchronously.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked immediately after the stream is closed.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2573,7 +2573,7 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem ...@@ -2573,7 +2573,7 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem
if (err) { if (err) {
console.info("close stream failed with error message: " + err.message + ", error code: " + err.code); console.info("close stream failed with error message: " + err.message + ", error code: " + err.code);
} else { } else {
console.info("close stream success"): console.info("close stream success");
} }
}); });
``` ```
...@@ -2588,7 +2588,7 @@ Synchronously closes the stream. ...@@ -2588,7 +2588,7 @@ Synchronously closes the stream.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2608,13 +2608,13 @@ Flushes the stream. This API uses a promise to return the result. ...@@ -2608,13 +2608,13 @@ Flushes the stream. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ------------- | | ------------------- | ------------- |
| Promise&lt;void&gt; | Promise used to return the stream flushing result.| | Promise&lt;void&gt; | Promise used to return the stream flushing result.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2638,13 +2638,13 @@ Flushes the stream. This API uses an asynchronous callback to return the result. ...@@ -2638,13 +2638,13 @@ Flushes the stream. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | -------------- | | -------- | ------------------------- | ---- | -------------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the stream is asynchronously flushed.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the stream is asynchronously flushed.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2670,7 +2670,7 @@ Synchronously flushes the stream. ...@@ -2670,7 +2670,7 @@ Synchronously flushes the stream.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2690,20 +2690,20 @@ Writes data into the stream. This API uses a promise to return the result. ...@@ -2690,20 +2690,20 @@ Writes data into the stream. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------------------- | | ------- | ------------------------------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **length** (number): length of the data to write. The default value is the buffer length.<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| | options | Object | No | The options are as follows:<br>- **length** (number): length of the data to write. The default value is the buffer length.<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | -------- | | --------------------- | -------- |
| Promise&lt;number&gt; | Promise used to return the length of the data written.| | Promise&lt;number&gt; | Promise used to return the length of the data written.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2727,15 +2727,15 @@ Writes data into the stream. This API uses an asynchronous callback to return th ...@@ -2727,15 +2727,15 @@ Writes data into the stream. This API uses an asynchronous callback to return th
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| | options | Object | No | The options are as follows:<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is written asynchronously. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is written asynchronously. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2763,20 +2763,20 @@ Synchronously writes data into the stream. ...@@ -2763,20 +2763,20 @@ Synchronously writes data into the stream.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------------------- | | ------- | ------------------------------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| | options | Object | No | The options are as follows:<br>- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------- | | ------ | -------- |
| number | Length of the data written in the file.| | number | Length of the data written in the file.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2796,20 +2796,20 @@ Reads data from the stream. This API uses a promise to return the result. ...@@ -2796,20 +2796,20 @@ Reads data from the stream. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer | Yes | Buffer used to store the file read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file read. |
| options | Object | No | The options are as follows:<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): position of the data to read in the file. By default, data is read from the current position.| | options | Object | No | The options are as follows:<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): position of the data to read in the file. By default, data is read from the current position.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ------ | | ---------------------------------- | ------ |
| Promise&lt;number&gt; | Promise used to return the data read.| | Promise&lt;number&gt; | Promise used to return the data read.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2835,15 +2835,15 @@ Reads data from the stream. This API uses an asynchronous callback to return the ...@@ -2835,15 +2835,15 @@ Reads data from the stream. This API uses an asynchronous callback to return the
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer | Yes | Buffer used to store the file read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file read. |
| options | Object | No | The options are as follows:<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.| | options | Object | No | The options are as follows:<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when data is read asynchronously from the stream. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when data is read asynchronously from the stream. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2871,20 +2871,20 @@ Synchronously reads data from the stream. ...@@ -2871,20 +2871,20 @@ Synchronously reads data from the stream.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer | Yes | Buffer used to store the file read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file read. |
| options | Object | No | The options are as follows:<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): position of the data to read in the file. By default, data is read from the current position.<br> | | options | Object | No | The options are as follows:<br>- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.<br>- **offset** (number): position of the data to read in the file. By default, data is read from the current position.<br> |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------- | | ------ | -------- |
| number | Length of the data read.| | number | Length of the data read.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2916,19 +2916,19 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A ...@@ -2916,19 +2916,19 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | | exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ------ | | ---------------------------------- | ------ |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2951,14 +2951,14 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A ...@@ -2951,14 +2951,14 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | | exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is locked. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is locked. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -2983,13 +2983,13 @@ Applies an exclusive lock or a shared lock on this file in non-blocking mode. ...@@ -2983,13 +2983,13 @@ Applies an exclusive lock or a shared lock on this file in non-blocking mode.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | | exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. |
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -3009,7 +3009,7 @@ Unlocks this file synchronously. ...@@ -3009,7 +3009,7 @@ Unlocks this file synchronously.
**Error codes** **Error codes**
For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
......
# @ohos.file.hash (File Hash Processing) # @ohos.file.hash (File Hash Processing)
The **fileHash** module implements hash processing on files. The **FileHash** module implements hash processing on files.
> **NOTE** > **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 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 of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
## Modules to Import ## Modules to Import
...@@ -17,7 +16,7 @@ import Hash from '@ohos.file.hash'; ...@@ -17,7 +16,7 @@ import Hash from '@ohos.file.hash';
Before using the APIs provided by this module to perform operations on a file or directory, obtain the path of the file or directory in the application sandbox as follows: Before using the APIs provided by this module to perform operations on a file or directory, obtain the path of the file or directory in the application sandbox as follows:
**Stage Model** Stage Model
```js ```js
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
...@@ -30,7 +29,7 @@ export default class EntryAbility extends UIAbility { ...@@ -30,7 +29,7 @@ export default class EntryAbility extends UIAbility {
} }
``` ```
**FA Model** FA Model
```js ```js
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
...@@ -64,6 +63,15 @@ Calculates a hash value for a file. This API uses a promise to return the result ...@@ -64,6 +63,15 @@ Calculates a hash value for a file. This API uses a promise to return the result
| --------------------- | -------------------------- | | --------------------- | -------------------------- |
| Promise&lt;string&gt; | Promise used to return the hash value. The hash value is a hexadecimal string consisting of digits and uppercase letters.| | Promise&lt;string&gt; | Promise used to return the hash value. The hash value is a hexadecimal string consisting of digits and uppercase letters.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
| ID| Error Message|
| -------- | -------- |
| 13900020 | Invalid argument |
| 13900042 | Unknown error |
**Example** **Example**
```js ```js
...@@ -89,9 +97,19 @@ Calculates a hash value for a file. This API uses an asynchronous callback to re ...@@ -89,9 +97,19 @@ Calculates a hash value for a file. This API uses an asynchronous callback to re
| --------- | --------------------------- | ---- | ------------------------------------------------------------ | | --------- | --------------------------- | ---- | ------------------------------------------------------------ |
| path | string | Yes | Path of the file in the application sandbox. | | path | string | Yes | Path of the file in the application sandbox. |
| algorithm | string | Yes | Algorithm used to calculate the hash value. The value can be **md5**, **sha1**, or **sha256**. **sha256** is recommended for security purposes.| | algorithm | string | Yes | Algorithm used to calculate the hash value. The value can be **md5**, **sha1**, or **sha256**. **sha256** is recommended for security purposes.|
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the hash value obtained. The hash value is a hexadecimal string consisting of digits and uppercase letters.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the hash value obtained. The hash value is a hexadecimal string consisting of digits and uppercase letters.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
| ID| Error Message|
| -------- | -------- |
| 13900020 | Invalid argument |
| 13900042 | Unknown error |
**Example** **Example**
```js ```js
let filePath = pathDir + "/test.txt"; let filePath = pathDir + "/test.txt";
Hash.hash(filePath, "sha256", (err, str) => { Hash.hash(filePath, "sha256", (err, str) => {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
> 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 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.
## Modules to Import ## Modules to Import
```js ```js
import picker from '@ohos.file.picker'; import picker from '@ohos.file.picker';
``` ```
......
...@@ -4,8 +4,7 @@ The **securityLabel** module provides APIs for managing data security levels of ...@@ -4,8 +4,7 @@ The **securityLabel** module provides APIs for managing data security levels of
> **NOTE** > **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 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 of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
## Modules to Import ## Modules to Import
...@@ -60,9 +59,24 @@ Sets a security label for a file in asynchronous mode. This API uses a promise t ...@@ -60,9 +59,24 @@ Sets a security label for a file in asynchronous mode. This API uses a promise t
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------- | | ------------------- | ---------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
| ID| Error Message|
| -------- | -------- |
| 13900001 | Operation not permitted |
| 13900007 | Arg list too long |
| 13900015 | File exists |
| 13900020 | Invalid argument |
| 13900025 | No space left on device |
| 13900037 | No data available |
| 13900041 | Quota exceeded |
| 13900042 | Unknown error |
**Example** **Example**
...@@ -91,6 +105,21 @@ Sets a security label for a file in asynchronous mode. This API uses an asynchro ...@@ -91,6 +105,21 @@ Sets a security label for a file in asynchronous mode. This API uses an asynchro
| type | DataLevel | Yes | File security level to set, which can be **s0**, **s1**, **s2**, **s3**, or **s4**.| | type | DataLevel | Yes | File security level to set, which can be **s0**, **s1**, **s2**, **s3**, or **s4**.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
| ID| Error Message|
| -------- | -------- |
| 13900001 | Operation not permitted |
| 13900007 | Arg list too long |
| 13900015 | File exists |
| 13900020 | Invalid argument |
| 13900025 | No space left on device |
| 13900037 | No data available |
| 13900041 | Quota exceeded |
| 13900042 | Unknown error |
**Example** **Example**
```js ```js
...@@ -119,6 +148,21 @@ Sets a security label for a file in synchronous mode. ...@@ -119,6 +148,21 @@ Sets a security label for a file in synchronous mode.
| path | string | Yes | Path of the target file. | | path | string | Yes | Path of the target file. |
| type | DataLevel | Yes | File security level to set, which can be **s0**, **s1**, **s2**, **s3**, or **s4**.| | type | DataLevel | Yes | File security level to set, which can be **s0**, **s1**, **s2**, **s3**, or **s4**.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
| ID| Error Message|
| -------- | -------- |
| 13900001 | Operation not permitted |
| 13900007 | Arg list too long |
| 13900015 | File exists |
| 13900020 | Invalid argument |
| 13900025 | No space left on device |
| 13900037 | No data available |
| 13900041 | Quota exceeded |
| 13900042 | Unknown error |
**Example** **Example**
```js ```js
...@@ -136,15 +180,30 @@ Obtains the security label of a file in asynchronous mode. This API uses a promi ...@@ -136,15 +180,30 @@ Obtains the security label of a file in asynchronous mode. This API uses a promi
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------- | | ------ | ------ | ---- | -------- |
| path | string | Yes | Path of the target file.| | path | string | Yes | Path of the target file.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------ | | --------------------- | ------------ |
| Promise&lt;string&gt; | Security label obtained.| | Promise&lt;string&gt; | Security label obtained.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
| ID| Error Message|
| -------- | -------- |
| 13900001 | Operation not permitted |
| 13900007 | Arg list too long |
| 13900015 | File exists |
| 13900020 | Invalid argument |
| 13900025 | No space left on device |
| 13900037 | No data available |
| 13900041 | Quota exceeded |
| 13900042 | Unknown error |
**Example** **Example**
...@@ -167,10 +226,25 @@ Obtains the security label of a file in asynchronous mode. This API uses a callb ...@@ -167,10 +226,25 @@ Obtains the security label of a file in asynchronous mode. This API uses a callb
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | -------------------------- | | -------- | --------------------------- | ---- | -------------------------- |
| path | string | Yes | Path of the target file. | | path | string | Yes | Path of the target file. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the security label obtained.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the security label obtained.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
| ID| Error Message|
| -------- | -------- |
| 13900001 | Operation not permitted |
| 13900007 | Arg list too long |
| 13900015 | File exists |
| 13900020 | Invalid argument |
| 13900025 | No space left on device |
| 13900037 | No data available |
| 13900041 | Quota exceeded |
| 13900042 | Unknown error |
**Example** **Example**
...@@ -184,6 +258,7 @@ Obtains the security label of a file in asynchronous mode. This API uses a callb ...@@ -184,6 +258,7 @@ Obtains the security label of a file in asynchronous mode. This API uses a callb
} }
}); });
``` ```
## securityLabel.getSecurityLabelSync ## securityLabel.getSecurityLabelSync
getSecurityLabelSync(path:string):string getSecurityLabelSync(path:string):string
...@@ -204,6 +279,21 @@ Obtains the security label of a file in synchronous mode. ...@@ -204,6 +279,21 @@ Obtains the security label of a file in synchronous mode.
| ------ | ------------ | | ------ | ------------ |
| string | Security label obtained.| | string | Security label obtained.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
| ID| Error Message|
| -------- | -------- |
| 13900001 | Operation not permitted |
| 13900007 | Arg list too long |
| 13900015 | File exists |
| 13900020 | Invalid argument |
| 13900025 | No space left on device |
| 13900037 | No data available |
| 13900041 | Quota exceeded |
| 13900042 | Unknown error |
**Example** **Example**
```js ```js
......
...@@ -4,14 +4,14 @@ The **statfs** module provides APIs for obtaining file system information, inclu ...@@ -4,14 +4,14 @@ The **statfs** module provides APIs for obtaining file system information, inclu
> **NOTE** > **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 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 of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
## Modules to Import ## Modules to Import
```js ```js
import statvfs from '@ohos.file.statvfs'; import statvfs from '@ohos.file.statvfs';
``` ```
## statvfs.getFreeSize ## statvfs.getFreeSize
getFreeSize(path:string):Promise&lt;number&gt; getFreeSize(path:string):Promise&lt;number&gt;
...@@ -22,15 +22,19 @@ Obtains the number of free bytes of the specified file system in asynchronous mo ...@@ -22,15 +22,19 @@ Obtains the number of free bytes of the specified file system in asynchronous mo
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------------- | | ------ | ------ | ---- | ---------------------------- |
| path | string | Yes | File path of the file system.| | path | string | Yes | File path of the file system.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | -------------- | | --------------------- | -------------- |
| Promise&lt;number&gt; | Promise used to return the number of free bytes obtained.| | Promise&lt;number&gt; | Promise used to return the number of free bytes obtained.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -53,10 +57,14 @@ Obtains the number of free bytes of the specified file system in asynchronous mo ...@@ -53,10 +57,14 @@ Obtains the number of free bytes of the specified file system in asynchronous mo
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------- | | -------- | --------------------------- | ---- | ---------------------------- |
| path | string | Yes | File path of the file system.| | path | string | Yes | File path of the file system.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the number of free bytes obtained.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the number of free bytes obtained.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -81,15 +89,19 @@ Obtains the total number of bytes of the specified file system in asynchronous m ...@@ -81,15 +89,19 @@ Obtains the total number of bytes of the specified file system in asynchronous m
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ---- | ------ | ---- | ---------------------------- | | ---- | ------ | ---- | ---------------------------- |
| path | string | Yes | File path of the file system.| | path | string | Yes | File path of the file system.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------ | | --------------------- | ------------ |
| Promise&lt;number&gt; | Promise used to return the total number of bytes obtained.| | Promise&lt;number&gt; | Promise used to return the total number of bytes obtained.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
...@@ -112,10 +124,14 @@ Obtains the total number of bytes of the specified file system in asynchronous m ...@@ -112,10 +124,14 @@ Obtains the total number of bytes of the specified file system in asynchronous m
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------- | | -------- | --------------------------- | ---- | ---------------------------- |
| path | string | Yes | File path of the file system.| | path | string | Yes | File path of the file system.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total number of bytes obtained. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total number of bytes obtained. |
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example** **Example**
......
...@@ -4,8 +4,8 @@ The **storageStatistics** module provides APIs for obtaining storage space infor ...@@ -4,8 +4,8 @@ The **storageStatistics** module provides APIs for obtaining storage space infor
> **NOTE** > **NOTE**
> >
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
## Modules to Import ## Modules to Import
```js ```js
...@@ -24,7 +24,6 @@ Obtains the total size (in bytes) of the specified volume in an external storage ...@@ -24,7 +24,6 @@ Obtains the total size (in bytes) of the specified volume in an external storage
**System API**: This is a system API. **System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
...@@ -37,6 +36,19 @@ Obtains the total size (in bytes) of the specified volume in an external storage ...@@ -37,6 +36,19 @@ Obtains the total size (in bytes) of the specified volume in an external storage
| --------------------- | ---------------- | | --------------------- | ---------------- |
| Promise&lt;number&gt; | Promise used to return the total volume size obtained.| | Promise&lt;number&gt; | Promise used to return the total volume size obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -60,7 +72,6 @@ Obtains the total size (in bytes) of the specified volume in an external storage ...@@ -60,7 +72,6 @@ Obtains the total size (in bytes) of the specified volume in an external storage
**System API**: This is a system API. **System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -68,6 +79,19 @@ Obtains the total size (in bytes) of the specified volume in an external storage ...@@ -68,6 +79,19 @@ Obtains the total size (in bytes) of the specified volume in an external storage
| volumeUuid | string | Yes | UUID of the volume. | | volumeUuid | string | Yes | UUID of the volume. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total volume size obtained.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total volume size obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -90,7 +114,6 @@ Obtains the available space (in bytes) of the specified volume in an external st ...@@ -90,7 +114,6 @@ Obtains the available space (in bytes) of the specified volume in an external st
**System API**: This is a system API. **System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
...@@ -103,6 +126,19 @@ Obtains the available space (in bytes) of the specified volume in an external st ...@@ -103,6 +126,19 @@ Obtains the available space (in bytes) of the specified volume in an external st
| --------------------- | ------------------ | | --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the available volume space obtained.| | Promise&lt;number&gt; | Promise used to return the available volume space obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -127,7 +163,6 @@ Obtains the available space (in bytes) of the specified volume in an external st ...@@ -127,7 +163,6 @@ Obtains the available space (in bytes) of the specified volume in an external st
**System API**: This is a system API. **System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -135,6 +170,19 @@ Obtains the available space (in bytes) of the specified volume in an external st ...@@ -135,6 +170,19 @@ Obtains the available space (in bytes) of the specified volume in an external st
| volumeUuid | string | Yes | UUID of the volume. | | volumeUuid | string | Yes | UUID of the volume. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available volume space obtained.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available volume space obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -157,7 +205,6 @@ Obtains the space (in bytes) of an application. This API uses a promise to retur ...@@ -157,7 +205,6 @@ Obtains the space (in bytes) of an application. This API uses a promise to retur
**System API**: This is a system API. **System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -170,6 +217,19 @@ Obtains the space (in bytes) of an application. This API uses a promise to retur ...@@ -170,6 +217,19 @@ Obtains the space (in bytes) of an application. This API uses a promise to retur
| ------------------------------------------ | -------------------------- | | ------------------------------------------ | -------------------------- |
| Promise&lt;[Bundlestats](#bundlestats9)&gt; | Promise used to return the application space obtained.| | Promise&lt;[Bundlestats](#bundlestats9)&gt; | Promise used to return the application space obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -193,7 +253,6 @@ Obtains the space (in bytes) of an application. This API uses an asynchronous ca ...@@ -193,7 +253,6 @@ Obtains the space (in bytes) of an application. This API uses an asynchronous ca
**System API**: This is a system API. **System API**: This is a system API.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -201,6 +260,19 @@ Obtains the space (in bytes) of an application. This API uses an asynchronous ca ...@@ -201,6 +260,19 @@ Obtains the space (in bytes) of an application. This API uses an asynchronous ca
| packageName | string | Yes | Bundle name of the application.| | packageName | string | Yes | Bundle name of the application.|
| callback | AsyncCallback&lt;[Bundlestats](#bundlestats9)&gt; | Yes | Callback invoked to return the application space obtained.| | callback | AsyncCallback&lt;[Bundlestats](#bundlestats9)&gt; | Yes | Callback invoked to return the application space obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -225,6 +297,16 @@ Obtains the space (in bytes) of this third-party application. This API uses a pr ...@@ -225,6 +297,16 @@ Obtains the space (in bytes) of this third-party application. This API uses a pr
| ------------------------------------------ | -------------------------- | | ------------------------------------------ | -------------------------- |
| Promise&lt;[Bundlestats](#bundlestats9)&gt; | Promise used to return the application space obtained. | | Promise&lt;[Bundlestats](#bundlestats9)&gt; | Promise used to return the application space obtained. |
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -246,6 +328,16 @@ Obtains the space (in bytes) of this third-party application. This API uses an a ...@@ -246,6 +328,16 @@ Obtains the space (in bytes) of this third-party application. This API uses an a
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ | | -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| callback | AsyncCallback&lt;[BundleStats](#bundlestats9)&gt; | Yes | Callback invoked to return the application space obtained. | | callback | AsyncCallback&lt;[BundleStats](#bundlestats9)&gt; | Yes | Callback invoked to return the application space obtained. |
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -265,7 +357,6 @@ Obtains the space (in bytes) of this third-party application. This API uses an a ...@@ -265,7 +357,6 @@ Obtains the space (in bytes) of this third-party application. This API uses an a
| cacheSize | number | Yes| No| Cache size of the application, in bytes. | | cacheSize | number | Yes| No| Cache size of the application, in bytes. |
| dataSize | number | Yes| No| Total data size of the application, in bytes.| | dataSize | number | Yes| No| Total data size of the application, in bytes.|
## storageStatistics.getTotalSize<sup>9+</sup> ## storageStatistics.getTotalSize<sup>9+</sup>
getTotalSize(): Promise&lt;number&gt; getTotalSize(): Promise&lt;number&gt;
...@@ -284,6 +375,18 @@ Obtains the total size (in bytes) of the built-in storage. This API uses a promi ...@@ -284,6 +375,18 @@ Obtains the total size (in bytes) of the built-in storage. This API uses a promi
| --------------------- | ------------------ | | --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the built-in storage size obtained. | | Promise&lt;number&gt; | Promise used to return the built-in storage size obtained. |
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -309,6 +412,18 @@ Obtains the total size (in bytes) of the built-in storage. This API uses an asyn ...@@ -309,6 +412,18 @@ Obtains the total size (in bytes) of the built-in storage. This API uses an asyn
| -------- | ------------------------------------ | ---- | ------------------------ | | -------- | ------------------------------------ | ---- | ------------------------ |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the built-in storage size obtained.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the built-in storage size obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -318,7 +433,6 @@ Obtains the total size (in bytes) of the built-in storage. This API uses an asyn ...@@ -318,7 +433,6 @@ Obtains the total size (in bytes) of the built-in storage. This API uses an asyn
}); });
``` ```
## storageStatistics.getFreeSize<sup>9+</sup> ## storageStatistics.getFreeSize<sup>9+</sup>
getFreeSize(): Promise&lt;number&gt; getFreeSize(): Promise&lt;number&gt;
...@@ -337,6 +451,18 @@ Obtains the available space (in bytes) of the built-in storage. This API uses a ...@@ -337,6 +451,18 @@ Obtains the available space (in bytes) of the built-in storage. This API uses a
| --------------------- | ------------------ | | --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the available space of the built-in storage obtained.| | Promise&lt;number&gt; | Promise used to return the available space of the built-in storage obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -344,7 +470,6 @@ Obtains the available space (in bytes) of the built-in storage. This API uses a ...@@ -344,7 +470,6 @@ Obtains the available space (in bytes) of the built-in storage. This API uses a
console.info("getFreeSize successfully:"+ JSON.stringify(number)); console.info("getFreeSize successfully:"+ JSON.stringify(number));
``` ```
## storageStatistics.getFreeSize<sup>9+</sup> ## storageStatistics.getFreeSize<sup>9+</sup>
getFreeSize(callback: AsyncCallback&lt;number&gt;): void getFreeSize(callback: AsyncCallback&lt;number&gt;): void
...@@ -363,6 +488,18 @@ Obtains the available space (in bytes) of the built-in storage. This API uses an ...@@ -363,6 +488,18 @@ Obtains the available space (in bytes) of the built-in storage. This API uses an
| -------- | ------------------------------------ | ---- | ------------------------- | | -------- | ------------------------------------ | ---- | ------------------------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available space of the built-in storage obtained.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available space of the built-in storage obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -384,13 +521,24 @@ Obtains the system data space, in bytes. This API uses a promise to return the r ...@@ -384,13 +521,24 @@ Obtains the system data space, in bytes. This API uses a promise to return the r
**System API**: This is a system API. **System API**: This is a system API.
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------------- | | --------------------- | ---------------- |
| Promise&lt;number&gt; | Promise used to return the system data space obtained.| | Promise&lt;number&gt; | Promise used to return the system data space obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -419,6 +567,18 @@ Obtains the system data space, in bytes. This API uses an asynchronous callback ...@@ -419,6 +567,18 @@ Obtains the system data space, in bytes. This API uses an asynchronous callback
| ---------- | ------------------------------------ | ---- | -------------------------- | | ---------- | ------------------------------------ | ---- | -------------------------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the system data space obtained.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the system data space obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -446,6 +606,18 @@ Obtains the storage statistics (in bytes) of this user. This API uses a promise ...@@ -446,6 +606,18 @@ Obtains the storage statistics (in bytes) of this user. This API uses a promise
| --------------------- | ---------------- | | --------------------- | ---------------- |
| Promise&lt;[StorageStats](#storagestats9)&gt; | Promise used to return the information obtained.| | Promise&lt;[StorageStats](#storagestats9)&gt; | Promise used to return the information obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -474,6 +646,18 @@ Obtains the storage statistics (in bytes) of this user. This API uses an asynchr ...@@ -474,6 +646,18 @@ Obtains the storage statistics (in bytes) of this user. This API uses an asynchr
| ---------- | ------------------------------------ | ---- | -------------------------- | | ---------- | ------------------------------------ | ---- | -------------------------- |
| callback | AsyncCallback&lt;[StorageStats](#storagestats9)&gt; | Yes | Callback invoked to return the information obtained.| | callback | AsyncCallback&lt;[StorageStats](#storagestats9)&gt; | Yes | Callback invoked to return the information obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -482,6 +666,9 @@ Obtains the storage statistics (in bytes) of this user. This API uses an asynchr ...@@ -482,6 +666,9 @@ Obtains the storage statistics (in bytes) of this user. This API uses an asynchr
console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats)); console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats));
}); });
``` ```
## storageStatistics.getUserStorageStats<sup>9+</sup>
getUserStorageStats(userId: number): Promise&lt;StorageStats&gt; getUserStorageStats(userId: number): Promise&lt;StorageStats&gt;
Obtains the storage statistics (in bytes) of the specified user. This API uses a promise to return the result. Obtains the storage statistics (in bytes) of the specified user. This API uses a promise to return the result.
...@@ -504,6 +691,19 @@ Obtains the storage statistics (in bytes) of the specified user. This API uses a ...@@ -504,6 +691,19 @@ Obtains the storage statistics (in bytes) of the specified user. This API uses a
| --------------------- | ---------------- | | --------------------- | ---------------- |
| Promise&lt;[StorageStats](#storagestats9)&gt; | Promise used to return the information obtained.| | Promise&lt;[StorageStats](#storagestats9)&gt; | Promise used to return the information obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600009 | User if out of range. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -534,6 +734,19 @@ Obtains the storage statistics (in bytes) of the specified user. This API uses a ...@@ -534,6 +734,19 @@ Obtains the storage statistics (in bytes) of the specified user. This API uses a
| userId | number | Yes | User ID.| | userId | number | Yes | User ID.|
| callback | AsyncCallback&lt;[StorageStats](#storagestats9)&gt; | Yes | Callback invoked to return the information obtained.| | callback | AsyncCallback&lt;[StorageStats](#storagestats9)&gt; | Yes | Callback invoked to return the information obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600009 | User if out of range. |
| 13900032 | Unknown error. |
**Example** **Example**
```js ```js
...@@ -544,7 +757,6 @@ Obtains the storage statistics (in bytes) of the specified user. This API uses a ...@@ -544,7 +757,6 @@ Obtains the storage statistics (in bytes) of the specified user. This API uses a
}); });
``` ```
## StorageStats<sup>9+</sup> ## StorageStats<sup>9+</sup>
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
......
...@@ -6,7 +6,6 @@ The **volumeManager** module provides APIs for volume and disk management, inclu ...@@ -6,7 +6,6 @@ The **volumeManager** module provides APIs for volume and disk management, inclu
> >
> - 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 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 APIs provided by this module are system APIs.
> - The APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
## Modules to Import ## Modules to Import
...@@ -26,9 +25,21 @@ Obtains information about all volumes of this external storage device. This API ...@@ -26,9 +25,21 @@ Obtains information about all volumes of this external storage device. This API
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | -------------------------- | | ---------------------------------- | -------------------------- |
| Promise&lt;[Volume](#volume)[]&gt; | Promise used to return information about all available volumes.| | Promise&lt;[Volume](#volume)[]&gt; | Promise used to return information about all available volumes.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -52,9 +63,21 @@ Obtains information about all volumes of this external storage device. This API ...@@ -52,9 +63,21 @@ Obtains information about all volumes of this external storage device. This API
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------- | ---- | ------------------------------------ | | -------- | ------------------------------------------------- | ---- | ------------------------------------ |
| callback | AsyncCallback&lt;[Volume](#volume)[]&gt; | Yes | Callback invoked to return information about all available volumes.| | callback | AsyncCallback&lt;[Volume](#volume)[]&gt; | Yes | Callback invoked to return information about all available volumes.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -65,7 +88,6 @@ Obtains information about all volumes of this external storage device. This API ...@@ -65,7 +88,6 @@ Obtains information about all volumes of this external storage device. This API
}); });
``` ```
## volumemanager.mount ## volumemanager.mount
mount(volumeId: string): Promise&lt;void&gt; mount(volumeId: string): Promise&lt;void&gt;
...@@ -78,15 +100,31 @@ Asynchronously mounts a volume. This API uses a promise to return the result. Cu ...@@ -78,15 +100,31 @@ Asynchronously mounts a volume. This API uses a promise to return the result. Cu
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
| -------- | ------ | ---- | ---- | | -------- | ------ | ---- | ---- |
| volumeId | string | Yes | Volume ID.| | volumeId | string | Yes | Volume ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------- | ---------- | | ---------------------- | ---------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600002 | Not supported filesystem. |
| 13600003 | Failed to mount. |
| 13600005 | Incorrect volume state. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -111,10 +149,26 @@ Asynchronously mounts a volume. This API uses an asynchronous callback to return ...@@ -111,10 +149,26 @@ Asynchronously mounts a volume. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | -------------------- | | -------- | ------------------------------------- | ---- | -------------------- |
| volumeId | string | Yes | Volume ID. | | volumeId | string | Yes | Volume ID. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600002 | Not supported filesystem. |
| 13600003 | Failed to mount. |
| 13600005 | Incorrect volume state. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -137,15 +191,31 @@ Asynchronously unmounts a volume. This API uses a promise to return the result. ...@@ -137,15 +191,31 @@ Asynchronously unmounts a volume. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
| -------- | ------ | ---- | ---- | | -------- | ------ | ---- | ---- |
| volumeId | string | Yes | Volume ID.| | volumeId | string | Yes | Volume ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------- | ---------- | | ---------------------- | ---------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600002 | Not supported filesystem. |
| 13600004 | Failed to unmount. |
| 13600005 | Incorrect volume state. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -170,10 +240,26 @@ Asynchronously unmounts a volume. This API uses an asynchronous callback to retu ...@@ -170,10 +240,26 @@ Asynchronously unmounts a volume. This API uses an asynchronous callback to retu
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | -------------------- | | -------- | ------------------------------------- | ---- | -------------------- |
| volumeId | string | Yes | Volume ID. | | volumeId | string | Yes | Volume ID. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600002 | Not supported filesystem. |
| 13600004 | Failed to unmount. |
| 13600005 | Incorrect volume state. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -196,15 +282,28 @@ Obtains information about a volume based on the universally unique identifier (U ...@@ -196,15 +282,28 @@ Obtains information about a volume based on the universally unique identifier (U
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
| -------- | ------ | ---- | ---- | | -------- | ------ | ---- | ---- |
| uuid | string | Yes | UUID of the volume.| | uuid | string | Yes | UUID of the volume.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | -------------------------- | | ---------------------------------- | -------------------------- |
| Promise&lt;[Volume](#volume)&gt; | Promise used to return the volume information obtained.| | Promise&lt;[Volume](#volume)&gt; | Promise used to return the volume information obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -229,10 +328,23 @@ Obtains information about a volume based on the UUID. This API uses an asynchron ...@@ -229,10 +328,23 @@ Obtains information about a volume based on the UUID. This API uses an asynchron
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | -------------------- | | -------- | ------------------------------------------------ | ---- | -------------------- |
| uuid | string | Yes | UUID of the volume. | | uuid | string | Yes | UUID of the volume. |
| callback | AsyncCallback&lt;[Volume](#volume)&gt; | Yes | Callback invoked to return the volume information obtained.| | callback | AsyncCallback&lt;[Volume](#volume)&gt; | Yes | Callback invoked to return the volume information obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -255,15 +367,28 @@ Obtains information about a volume based on the volume ID. This API uses a promi ...@@ -255,15 +367,28 @@ Obtains information about a volume based on the volume ID. This API uses a promi
**Parameters** **Parameters**
| Name | Type | Mandatory | Description| | Name | Type | Mandatory | Description|
| -------- | ------ | ---- | ---- | | -------- | ------ | ---- | ---- |
| volumeId | string | Yes | Volume ID.| | volumeId | string | Yes | Volume ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | -------------------------- | | ---------------------------------- | -------------------------- |
| Promise&lt;[Volume](#volume)&gt; | Promise used to return the volume information obtained.| | Promise&lt;[Volume](#volume)&gt; | Promise used to return the volume information obtained.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -288,10 +413,23 @@ Obtains information about a volume based on the volume ID. This API uses an asyn ...@@ -288,10 +413,23 @@ Obtains information about a volume based on the volume ID. This API uses an asyn
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------- | | -------- | ------------------------- | ---- | ----------------------------- |
| volumeId | string | Yes | Volume ID. | | volumeId | string | Yes | Volume ID. |
| callback | AsyncCallback&lt;[Volume](#volume)&gt; | Yes | Callback invoked to return the volume information obtained. | | callback | AsyncCallback&lt;[Volume](#volume)&gt; | Yes | Callback invoked to return the volume information obtained. |
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -314,16 +452,31 @@ Sets volume description. This API uses a promise to return the result. ...@@ -314,16 +452,31 @@ Sets volume description. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
| --------- | ------ | ---- | ---- | | --------- | ------ | ---- | ---- |
| uuid | string | Yes | UUID of the volume.| | uuid | string | Yes | UUID of the volume.|
| description | string | Yes | Volume description to set.| | description | string | Yes | Volume description to set.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------- | -------------------------- | | ---------------------- | -------------------------- |
| Promise&lt;void&gt; | Promise that returns no value. | | Promise&lt;void&gt; | Promise that returns no value. |
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600002 | Not supported filesystem. |
| 13600005 | Incorrect volume state. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -349,11 +502,26 @@ Sets volume description. This API uses an asynchronous callback to return the re ...@@ -349,11 +502,26 @@ Sets volume description. This API uses an asynchronous callback to return the re
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | ---------------- | | ---------- | --------------------------------------- | ---- | ---------------- |
| uuid | string | Yes | UUID of the volume. | | uuid | string | Yes | UUID of the volume. |
| description | string | Yes | Volume description to set. | | description | string | Yes | Volume description to set. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600002 | Not supported filesystem. |
| 13600005 | Incorrect volume state. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -377,16 +545,31 @@ Formats a volume. This API uses a promise to return the result. Currently, only ...@@ -377,16 +545,31 @@ Formats a volume. This API uses a promise to return the result. Currently, only
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
| ----------- | ------ | ---- | ---- | | ----------- | ------ | ---- | ---- |
| volumeId | string | Yes | Volume ID.| | volumeId | string | Yes | Volume ID.|
| fsType | string | Yes | File system type, which can be VFAT or exFAT.| | fsType | string | Yes | File system type, which can be VFAT or exFAT.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------- | ---------- | | ---------------------- | ---------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600002 | Not supported filesystem. |
| 13600005 | Incorrect volume state. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -412,11 +595,26 @@ Formats a volume. This API uses an asynchronous callback to return the result. C ...@@ -412,11 +595,26 @@ Formats a volume. This API uses an asynchronous callback to return the result. C
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------- | | -------- | ------------------------- | ---- | ----------------------------- |
| volumeId | string | Yes | Volume ID. | | volumeId | string | Yes | Volume ID. |
| fsType | string | Yes | File system type, which can be VFAT or exFAT.| | fsType | string | Yes | File system type, which can be VFAT or exFAT.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. |
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600002 | Not supported filesystem. |
| 13600005 | Incorrect volume state. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -440,16 +638,29 @@ Partitions a disk. This API uses a promise to return the result. The system supp ...@@ -440,16 +638,29 @@ Partitions a disk. This API uses a promise to return the result. The system supp
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description|
| ----------- | ------ | ---- | ---- | | ----------- | ------ | ---- | ---- |
| diskId | string | Yes | ID of the disk to partition.| | diskId | string | Yes | ID of the disk to partition.|
| type | number | Yes | Partition type. | | type | number | Yes | Partition type. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ----------------------- | | --------------------- | ----------------------- |
| Promise&lt;void&gt; | Promise used to return the result. | | Promise&lt;void&gt; | Promise used to return the result. |
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
...@@ -475,11 +686,24 @@ Asynchronously partitions a disk. This API uses a callback to return the result. ...@@ -475,11 +686,24 @@ Asynchronously partitions a disk. This API uses a callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ---------------- | | -------- | --------------------------------------- | ---- | ---------------- |
| diskId | string | Yes | ID of the disk to partition. | | diskId | string | Yes | ID of the disk to partition. |
| type | number | Yes | Partition type. | | type | number | Yes | Partition type. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. |
**Error codes**
For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
| ID| Error Message|
| -------- | -------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
| 13600008 | No such object. |
| 13900032 | Unknown error. |
**Example** **Example**
......
# @ohos.fileshare (File Sharing) # @ohos.fileshare (File Sharing)
The **fileShare** module provides APIs for granting the access permissions on a user file to another application by the Uniform Resource Identifier (URI). Then, the authorized application can access the file by using the APIs provided by [@ohos.file.fs](js-apis-file-fs.md). The **fileshare** module provides APIs for granting the access permissions on a user file to another application by the Uniform Resource Identifier (URI). Then, the authorized application can access the file by using the APIs provided by [@ohos.file.fs](js-apis-file-fs.md).
> **NOTE** > **NOTE**
> >
...@@ -31,7 +31,7 @@ Grants permissions on a user file by the URI to an application. This API uses an ...@@ -31,7 +31,7 @@ Grants permissions on a user file by the URI to an application. This API uses an
| uri | string | Yes | URI of a user file.| | uri | string | Yes | URI of a user file.|
| bundleName | string | Yes | Bundle name of the application to be grated with the permissions.| | bundleName | string | Yes | Bundle name of the application to be grated with the permissions.|
| mode | number | Yes | Permissions to grant. For details, see [wantConstant.Flags](js-apis-app-ability-wantConstant.md#wantconstantflags).<br>**wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION**: permission to read the file. <br>**wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION**: permission to write the file.| | mode | number | Yes | Permissions to grant. For details, see [wantConstant.Flags](js-apis-app-ability-wantConstant.md#wantconstantflags).<br>**wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION**: permission to read the file. <br>**wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION**: permission to write the file.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
**Error codes** **Error codes**
...@@ -44,7 +44,6 @@ For details about the error codes, see [File Management Error Codes](../errorcod ...@@ -44,7 +44,6 @@ For details about the error codes, see [File Management Error Codes](../errorcod
| 401 | The input parameter is invalid | | 401 | The input parameter is invalid |
| 143000001 | IPC error | | 143000001 | IPC error |
**Example** **Example**
```js ```js
...@@ -66,7 +65,6 @@ try { ...@@ -66,7 +65,6 @@ try {
} }
``` ```
## fileShare.grantUriPermission ## fileShare.grantUriPermission
grantUriPermission(uri: string, bundleName: string, mode: number): Promise&lt;void&gt; grantUriPermission(uri: string, bundleName: string, mode: number): Promise&lt;void&gt;
...@@ -89,10 +87,9 @@ Grants permissions on a user file by the URI to an application. This API uses a ...@@ -89,10 +87,9 @@ Grants permissions on a user file by the URI to an application. This API uses a
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------- | ---------- | | ---------------------------- | ---------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Error codes** **Error codes**
...@@ -105,7 +102,6 @@ For details about the error codes, see [File Management Error Codes](../errorcod ...@@ -105,7 +102,6 @@ For details about the error codes, see [File Management Error Codes](../errorcod
| 401 | The input parameter is invalid | | 401 | The input parameter is invalid |
| 143000001 | IPC error | | 143000001 | IPC error |
**Example** **Example**
```js ```js
......
# CommonEventData # CommonEventData
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
......
# CommonEventPublishData # CommonEventPublishData
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
......
# CommonEventSubscribeInfo # CommonEventSubscribeInfo
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
......
# CommonEventSubscriber # CommonEventSubscriber
## getCode > **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Usage
Before using the **CommonEventSubscriber** module, you must obtain a **subscriber** object by calling **CommonEvent.createSubscriber**.
```ts ```ts
getCode(callback: AsyncCallback<number>): void import CommonEvent from '@ohos.commonEvent';
let subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information.
let subscribeInfo = {
events: ["event"]
};
// Callback for subscriber creation.
function createCB(err, commonEventSubscriber) {
if (err.code) {
console.error(`createSubscriber failed, code is ${err.code}`);
} else {
console.info("createSubscriber");
subscriber = commonEventSubscriber;
}
}
// Create a subscriber.
CommonEvent.createSubscriber(subscribeInfo, createCB);
``` ```
## getCode
getCode(callback: AsyncCallback\<number>): void
Obtains the code of this common event. This API uses an asynchronous callback to return the result. Obtains the code of this common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
...@@ -19,8 +48,6 @@ Obtains the code of this common event. This API uses an asynchronous callback to ...@@ -19,8 +48,6 @@ Obtains the code of this common event. This API uses an asynchronous callback to
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for result code obtaining of an ordered common event. // Callback for result code obtaining of an ordered common event.
function getCodeCB(err, code) { function getCodeCB(err, code) {
if (err.code) { if (err.code) {
...@@ -34,9 +61,7 @@ subscriber.getCode(getCodeCB); ...@@ -34,9 +61,7 @@ subscriber.getCode(getCodeCB);
## getCode ## getCode
```ts getCode(): Promise\<number>
getCode(): Promise<number>
```
Obtains the code of this common event. This API uses a promise to return the result. Obtains the code of this common event. This API uses a promise to return the result.
...@@ -51,8 +76,6 @@ Obtains the code of this common event. This API uses a promise to return the res ...@@ -51,8 +76,6 @@ Obtains the code of this common event. This API uses a promise to return the res
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.getCode().then((code) => { subscriber.getCode().then((code) => {
console.info("getCode " + JSON.stringify(code)); console.info("getCode " + JSON.stringify(code));
}).catch((err) => { }).catch((err) => {
...@@ -62,9 +85,7 @@ subscriber.getCode().then((code) => { ...@@ -62,9 +85,7 @@ subscriber.getCode().then((code) => {
## setCode ## setCode
```ts setCode(code: number, callback: AsyncCallback\<void>): void
setCode(code: number, callback: AsyncCallback<void>): void
```
Sets the code for this common event. This API uses an asynchronous callback to return the result. Sets the code for this common event. This API uses an asynchronous callback to return the result.
...@@ -80,8 +101,6 @@ Sets the code for this common event. This API uses an asynchronous callback to r ...@@ -80,8 +101,6 @@ Sets the code for this common event. This API uses an asynchronous callback to r
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for result code setting of an ordered common event. // Callback for result code setting of an ordered common event.
function setCodeCB(err) { function setCodeCB(err) {
if (err.code) { if (err.code) {
...@@ -95,9 +114,7 @@ subscriber.setCode(1, setCodeCB); ...@@ -95,9 +114,7 @@ subscriber.setCode(1, setCodeCB);
## setCode ## setCode
```ts setCode(code: number): Promise\<void>
setCode(code: number): Promise<void>
```
Sets the code for this common event. This API uses a promise to return the result. Sets the code for this common event. This API uses a promise to return the result.
...@@ -118,8 +135,6 @@ Sets the code for this common event. This API uses a promise to return the resul ...@@ -118,8 +135,6 @@ Sets the code for this common event. This API uses a promise to return the resul
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.setCode(1).then(() => { subscriber.setCode(1).then(() => {
console.info("setCode"); console.info("setCode");
}).catch((err) => { }).catch((err) => {
...@@ -129,9 +144,7 @@ subscriber.setCode(1).then(() => { ...@@ -129,9 +144,7 @@ subscriber.setCode(1).then(() => {
## getData ## getData
```ts getData(callback: AsyncCallback\<string>): void
getData(callback: AsyncCallback<string>): void
```
Obtains the data of this common event. This API uses an asynchronous callback to return the result. Obtains the data of this common event. This API uses an asynchronous callback to return the result.
...@@ -146,8 +159,6 @@ Obtains the data of this common event. This API uses an asynchronous callback to ...@@ -146,8 +159,6 @@ Obtains the data of this common event. This API uses an asynchronous callback to
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for result data obtaining of an ordered common event. // Callback for result data obtaining of an ordered common event.
function getDataCB(err, data) { function getDataCB(err, data) {
if (err.code) { if (err.code) {
...@@ -161,9 +172,7 @@ subscriber.getData(getDataCB); ...@@ -161,9 +172,7 @@ subscriber.getData(getDataCB);
## getData ## getData
```ts getData(): Promise\<string>
getData(): Promise<string>
```
Obtains the data of this common event. This API uses a promise to return the result. Obtains the data of this common event. This API uses a promise to return the result.
...@@ -178,8 +187,6 @@ Obtains the data of this common event. This API uses a promise to return the res ...@@ -178,8 +187,6 @@ Obtains the data of this common event. This API uses a promise to return the res
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.getData().then((data) => { subscriber.getData().then((data) => {
console.info("getData " + JSON.stringify(data)); console.info("getData " + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
...@@ -205,8 +212,6 @@ Sets the data for this common event. This API uses an asynchronous callback to r ...@@ -205,8 +212,6 @@ Sets the data for this common event. This API uses an asynchronous callback to r
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function setDataCB(err) { function setDataCB(err) {
if (err.code) { if (err.code) {
...@@ -220,9 +225,7 @@ subscriber.setData("publish_data_changed", setDataCB); ...@@ -220,9 +225,7 @@ subscriber.setData("publish_data_changed", setDataCB);
## setData ## setData
```ts setData(data: string): Promise\<void>
setData(data: string): Promise<void>
```
Sets the data for this common event. This API uses a promise to return the result. Sets the data for this common event. This API uses a promise to return the result.
...@@ -243,8 +246,6 @@ Sets the data for this common event. This API uses a promise to return the resul ...@@ -243,8 +246,6 @@ Sets the data for this common event. This API uses a promise to return the resul
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.setData("publish_data_changed").then(() => { subscriber.setData("publish_data_changed").then(() => {
console.info("setData"); console.info("setData");
}).catch((err) => { }).catch((err) => {
...@@ -254,9 +255,7 @@ subscriber.setData("publish_data_changed").then(() => { ...@@ -254,9 +255,7 @@ subscriber.setData("publish_data_changed").then(() => {
## setCodeAndData ## setCodeAndData
```ts setCodeAndData(code: number, data: string, callback:AsyncCallback\<void>): void
setCodeAndData(code: number, data: string, callback:AsyncCallback<void>): void
```
Sets the code and data for this common event. This API uses an asynchronous callback to return the result. Sets the code and data for this common event. This API uses an asynchronous callback to return the result.
...@@ -273,8 +272,6 @@ Sets the code and data for this common event. This API uses an asynchronous call ...@@ -273,8 +272,6 @@ Sets the code and data for this common event. This API uses an asynchronous call
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for code and data setting of an ordered common event. // Callback for code and data setting of an ordered common event.
function setCodeDataCB(err) { function setCodeDataCB(err) {
if (err.code) { if (err.code) {
...@@ -288,9 +285,7 @@ subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCB); ...@@ -288,9 +285,7 @@ subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCB);
## setCodeAndData ## setCodeAndData
```ts setCodeAndData(code: number, data: string): Promise\<void>
setCodeAndData(code: number, data: string): Promise<void>
```
Sets the code and data for this common event. This API uses a promise to return the result. Sets the code and data for this common event. This API uses a promise to return the result.
...@@ -312,8 +307,6 @@ Sets the code and data for this common event. This API uses a promise to return ...@@ -312,8 +307,6 @@ Sets the code and data for this common event. This API uses a promise to return
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.setCodeAndData(1, "publish_data_changed").then(() => { subscriber.setCodeAndData(1, "publish_data_changed").then(() => {
console.info("setCodeAndData"); console.info("setCodeAndData");
}).catch((err) => { }).catch((err) => {
...@@ -323,9 +316,7 @@ subscriber.setCodeAndData(1, "publish_data_changed").then(() => { ...@@ -323,9 +316,7 @@ subscriber.setCodeAndData(1, "publish_data_changed").then(() => {
## isOrderedCommonEvent ## isOrderedCommonEvent
```ts isOrderedCommonEvent(callback: AsyncCallback\<boolean>): void
isOrderedCommonEvent(callback: AsyncCallback<boolean>): void
```
Checks whether this common event is an ordered one. This API uses an asynchronous callback to return the result. Checks whether this common event is an ordered one. This API uses an asynchronous callback to return the result.
...@@ -340,8 +331,6 @@ Checks whether this common event is an ordered one. This API uses an asynchronou ...@@ -340,8 +331,6 @@ Checks whether this common event is an ordered one. This API uses an asynchronou
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is an ordered one. // Callback for checking whether the current common event is an ordered one.
function isOrderedCB(err, isOrdered) { function isOrderedCB(err, isOrdered) {
if (err.code) { if (err.code) {
...@@ -355,9 +344,7 @@ subscriber.isOrderedCommonEvent(isOrderedCB); ...@@ -355,9 +344,7 @@ subscriber.isOrderedCommonEvent(isOrderedCB);
## isOrderedCommonEvent ## isOrderedCommonEvent
```ts isOrderedCommonEvent(): Promise\<boolean>
isOrderedCommonEvent(): Promise<boolean>
```
Checks whether this common event is an ordered one. This API uses a promise to return the result. Checks whether this common event is an ordered one. This API uses a promise to return the result.
...@@ -372,8 +359,6 @@ Checks whether this common event is an ordered one. This API uses a promise to r ...@@ -372,8 +359,6 @@ Checks whether this common event is an ordered one. This API uses a promise to r
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.isOrderedCommonEvent().then((isOrdered) => { subscriber.isOrderedCommonEvent().then((isOrdered) => {
console.info("isOrdered " + JSON.stringify(isOrdered)); console.info("isOrdered " + JSON.stringify(isOrdered));
}).catch((err) => { }).catch((err) => {
...@@ -383,9 +368,7 @@ subscriber.isOrderedCommonEvent().then((isOrdered) => { ...@@ -383,9 +368,7 @@ subscriber.isOrderedCommonEvent().then((isOrdered) => {
## isStickyCommonEvent ## isStickyCommonEvent
```ts isStickyCommonEvent(callback: AsyncCallback\<boolean>): void
isStickyCommonEvent(callback: AsyncCallback<boolean>): void
```
Checks whether this common event is a sticky one. This API uses an asynchronous callback to return the result. Checks whether this common event is a sticky one. This API uses an asynchronous callback to return the result.
...@@ -400,8 +383,6 @@ Checks whether this common event is a sticky one. This API uses an asynchronous ...@@ -400,8 +383,6 @@ Checks whether this common event is a sticky one. This API uses an asynchronous
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is a sticky one. // Callback for checking whether the current common event is a sticky one.
function isStickyCB(err, isSticky) { function isStickyCB(err, isSticky) {
if (err.code) { if (err.code) {
...@@ -415,9 +396,7 @@ subscriber.isStickyCommonEvent(isStickyCB); ...@@ -415,9 +396,7 @@ subscriber.isStickyCommonEvent(isStickyCB);
## isStickyCommonEvent ## isStickyCommonEvent
```ts isStickyCommonEvent(): Promise\<boolean>
isStickyCommonEvent(): Promise<boolean>
```
Checks whether this common event is a sticky one. This API uses a promise to return the result. Checks whether this common event is a sticky one. This API uses a promise to return the result.
...@@ -432,8 +411,6 @@ Checks whether this common event is a sticky one. This API uses a promise to ret ...@@ -432,8 +411,6 @@ Checks whether this common event is a sticky one. This API uses a promise to ret
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.isStickyCommonEvent().then((isSticky) => { subscriber.isStickyCommonEvent().then((isSticky) => {
console.info("isSticky " + JSON.stringify(isSticky)); console.info("isSticky " + JSON.stringify(isSticky));
}).catch((err) => { }).catch((err) => {
...@@ -443,9 +420,7 @@ subscriber.isStickyCommonEvent().then((isSticky) => { ...@@ -443,9 +420,7 @@ subscriber.isStickyCommonEvent().then((isSticky) => {
## abortCommonEvent ## abortCommonEvent
```ts abortCommonEvent(callback: AsyncCallback\<void>): void
abortCommonEvent(callback: AsyncCallback<void>): void
```
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result. Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
...@@ -460,8 +435,6 @@ Aborts this common event. After the abort, the common event is not sent to the n ...@@ -460,8 +435,6 @@ Aborts this common event. After the abort, the common event is not sent to the n
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for common event aborting. // Callback for common event aborting.
function abortCB(err) { function abortCB(err) {
if (err.code) { if (err.code) {
...@@ -475,9 +448,7 @@ subscriber.abortCommonEvent(abortCB); ...@@ -475,9 +448,7 @@ subscriber.abortCommonEvent(abortCB);
## abortCommonEvent ## abortCommonEvent
```ts abortCommonEvent(): Promise\<void>
abortCommonEvent(): Promise<void>
```
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses a promise to return the result. Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses a promise to return the result.
...@@ -492,8 +463,6 @@ Aborts this common event. After the abort, the common event is not sent to the n ...@@ -492,8 +463,6 @@ Aborts this common event. After the abort, the common event is not sent to the n
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.abortCommonEvent().then(() => { subscriber.abortCommonEvent().then(() => {
console.info("abortCommonEvent"); console.info("abortCommonEvent");
}).catch((err) => { }).catch((err) => {
...@@ -503,9 +472,7 @@ subscriber.abortCommonEvent().then(() => { ...@@ -503,9 +472,7 @@ subscriber.abortCommonEvent().then(() => {
## clearAbortCommonEvent ## clearAbortCommonEvent
```ts clearAbortCommonEvent(callback: AsyncCallback\<void>): void
clearAbortCommonEvent(callback: AsyncCallback<void>): void
```
Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result. Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
...@@ -520,8 +487,6 @@ Clears the aborted state of this common event. This API takes effect only for or ...@@ -520,8 +487,6 @@ Clears the aborted state of this common event. This API takes effect only for or
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for clearing the aborted state of the current common event. // Callback for clearing the aborted state of the current common event.
function clearAbortCB(err) { function clearAbortCB(err) {
if (err.code) { if (err.code) {
...@@ -535,9 +500,7 @@ subscriber.clearAbortCommonEvent(clearAbortCB); ...@@ -535,9 +500,7 @@ subscriber.clearAbortCommonEvent(clearAbortCB);
## clearAbortCommonEvent ## clearAbortCommonEvent
```ts clearAbortCommonEvent(): Promise\<void>
clearAbortCommonEvent(): Promise<void>
```
Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses a promise to return the result. Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses a promise to return the result.
...@@ -552,8 +515,6 @@ Clears the aborted state of this common event. This API takes effect only for or ...@@ -552,8 +515,6 @@ Clears the aborted state of this common event. This API takes effect only for or
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.clearAbortCommonEvent().then(() => { subscriber.clearAbortCommonEvent().then(() => {
console.info("clearAbortCommonEvent"); console.info("clearAbortCommonEvent");
}).catch((err) => { }).catch((err) => {
...@@ -563,9 +524,7 @@ subscriber.clearAbortCommonEvent().then(() => { ...@@ -563,9 +524,7 @@ subscriber.clearAbortCommonEvent().then(() => {
## getAbortCommonEvent ## getAbortCommonEvent
```ts getAbortCommonEvent(callback: AsyncCallback\<boolean>): void
getAbortCommonEvent(callback: AsyncCallback<boolean>): void
```
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result. Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
...@@ -580,8 +539,6 @@ Checks whether this common event is in the aborted state. This API takes effect ...@@ -580,8 +539,6 @@ Checks whether this common event is in the aborted state. This API takes effect
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is in the aborted state. // Callback for checking whether the current common event is in the aborted state.
function getAbortCB(err, abortEvent) { function getAbortCB(err, abortEvent) {
if (err.code) { if (err.code) {
...@@ -595,9 +552,7 @@ subscriber.getAbortCommonEvent(getAbortCB); ...@@ -595,9 +552,7 @@ subscriber.getAbortCommonEvent(getAbortCB);
## getAbortCommonEvent ## getAbortCommonEvent
```ts getAbortCommonEvent(): Promise\<boolean>
getAbortCommonEvent(): Promise<boolean>
```
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses a promise to return the result. Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses a promise to return the result.
...@@ -612,8 +567,6 @@ Checks whether this common event is in the aborted state. This API takes effect ...@@ -612,8 +567,6 @@ Checks whether this common event is in the aborted state. This API takes effect
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.getAbortCommonEvent().then((abortEvent) => { subscriber.getAbortCommonEvent().then((abortEvent) => {
console.info("abortCommonEvent " + JSON.stringify(abortEvent)); console.info("abortCommonEvent " + JSON.stringify(abortEvent));
}).catch((err) => { }).catch((err) => {
...@@ -623,9 +576,7 @@ subscriber.getAbortCommonEvent().then((abortEvent) => { ...@@ -623,9 +576,7 @@ subscriber.getAbortCommonEvent().then((abortEvent) => {
## getSubscribeInfo ## getSubscribeInfo
```ts getSubscribeInfo(callback: AsyncCallback\<CommonEventSubscribeInfo>): void
getSubscribeInfo(callback: AsyncCallback<CommonEventSubscribeInfo>): void
```
Obtains the subscriber information. This API uses an asynchronous callback to return the result. Obtains the subscriber information. This API uses an asynchronous callback to return the result.
...@@ -640,8 +591,6 @@ Obtains the subscriber information. This API uses an asynchronous callback to re ...@@ -640,8 +591,6 @@ Obtains the subscriber information. This API uses an asynchronous callback to re
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for subscriber information obtaining. // Callback for subscriber information obtaining.
function getCB(err, subscribeInfo) { function getCB(err, subscribeInfo) {
if (err.code) { if (err.code) {
...@@ -655,9 +604,7 @@ subscriber.getSubscribeInfo(getCB); ...@@ -655,9 +604,7 @@ subscriber.getSubscribeInfo(getCB);
## getSubscribeInfo ## getSubscribeInfo
```ts getSubscribeInfo(): Promise\<CommonEventSubscribeInfo>
getSubscribeInfo(): Promise<CommonEventSubscribeInfo>
```
Obtains the subscriber information. This API uses a promise to return the result. Obtains the subscriber information. This API uses a promise to return the result.
...@@ -672,8 +619,6 @@ Obtains the subscriber information. This API uses a promise to return the result ...@@ -672,8 +619,6 @@ Obtains the subscriber information. This API uses a promise to return the result
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.getSubscribeInfo().then((subscribeInfo) => { subscriber.getSubscribeInfo().then((subscribeInfo) => {
console.info("subscribeInfo " + JSON.stringify(subscribeInfo)); console.info("subscribeInfo " + JSON.stringify(subscribeInfo));
}).catch((err) => { }).catch((err) => {
...@@ -683,9 +628,7 @@ subscriber.getSubscribeInfo().then((subscribeInfo) => { ...@@ -683,9 +628,7 @@ subscriber.getSubscribeInfo().then((subscribeInfo) => {
## finishCommonEvent<sup>9+</sup> ## finishCommonEvent<sup>9+</sup>
```ts finishCommonEvent(callback: AsyncCallback\<void>): void
finishCommonEvent(callback: AsyncCallback<void>): void
```
Finishes this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result. Finishes this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
...@@ -700,14 +643,13 @@ Finishes this common event. This API takes effect only for ordered common events ...@@ -700,14 +643,13 @@ Finishes this common event. This API takes effect only for ordered common events
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
// Callback for ordered common event finishing. // Callback for ordered common event finishing.
function finishCB(err) { function finishCB(err) {
if (err.code) { if (err.code) {
console.error(`finishCommonEvent failed, code is ${err.code}, message is ${err.message}`); console.error(`finishCommonEvent failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("FinishCommonEvent"); console.info("FinishCommonEvent");
}
} }
subscriber.finishCommonEvent(finishCB); subscriber.finishCommonEvent(finishCB);
...@@ -715,9 +657,7 @@ subscriber.finishCommonEvent(finishCB); ...@@ -715,9 +657,7 @@ subscriber.finishCommonEvent(finishCB);
## finishCommonEvent<sup>9+</sup> ## finishCommonEvent<sup>9+</sup>
```ts finishCommonEvent(): Promise\<void>
finishCommonEvent(): Promise<void\>
```
Finishes this common event. This API takes effect only for ordered common events. It uses a promise to return the result. Finishes this common event. This API takes effect only for ordered common events. It uses a promise to return the result.
...@@ -732,8 +672,6 @@ Finishes this common event. This API takes effect only for ordered common events ...@@ -732,8 +672,6 @@ Finishes this common event. This API takes effect only for ordered common events
**Example** **Example**
```ts ```ts
let subscriber; // Subscriber object successfully created.
subscriber.finishCommonEvent().then(() => { subscriber.finishCommonEvent().then(() => {
console.info("FinishCommonEvent"); console.info("FinishCommonEvent");
}).catch((err) => { }).catch((err) => {
......
...@@ -8,9 +8,9 @@ The **NotificationActionButton** module describes the button displayed in the no ...@@ -8,9 +8,9 @@ The **NotificationActionButton** module describes the button displayed in the no
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| --------- | ----------------------------------------------- | --- | ---- | ------------------------- | | --------- | ----------------------------------------------- | --- | ---- | ------------------------- |
| title | string | Yes | Yes | Button title. | | title | string | No | Yes | Button title. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** of the button.| | wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | No | Yes | **WantAgent** of the button.|
| extras | { [key: string]: any } | Yes | Yes | Extra information of the button. | | extras | { [key: string]: any } | No | No | Extra information of the button. |
| userInput<sup>8+</sup> | [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) | Yes | Yes | User input object. | | userInput<sup>8+</sup> | [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) | No | No | User input object. |
...@@ -10,7 +10,7 @@ Provides the bundle information of an application. ...@@ -10,7 +10,7 @@ Provides the bundle information of an application.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Mandatory| Description | | Name | Type | Read-only| Mandatory| Description |
| ------ | ------ |---- | ------ | | ------ | ------ | ---- | ---- | ------ |
| bundle | string | Yes| Bundle information of the application.| | bundle | string | No | Yes| Bundle information of the application.|
| uid | number | No| User ID.| | uid | number | No | No| User ID.|
...@@ -8,13 +8,13 @@ The **NotificationContent** module describes the notification content. ...@@ -8,13 +8,13 @@ The **NotificationContent** module describes the notification content.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ | | ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ |
| contentType | [ContentType](./js-apis-notificationManager.md#contenttype) | Yes | Yes | Notification content type. | | contentType | [ContentType](./js-apis-notificationManager.md#contenttype) | No | Yes | Notification content type. |
| normal | [NotificationBasicContent](#notificationbasiccontent) | Yes | Yes | Normal text. | | normal | [NotificationBasicContent](#notificationbasiccontent) | No | No | Normal text. |
| longText | [NotificationLongTextContent](#notificationlongtextcontent) | Yes | Yes | Long text.| | longText | [NotificationLongTextContent](#notificationlongtextcontent) | No | No | Long text.|
| multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | Yes | Yes | Multi-line text. | | multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | No | No | Multi-line text. |
| picture | [NotificationPictureContent](#notificationpicturecontent) | Yes | Yes | Picture-attached. | | picture | [NotificationPictureContent](#notificationpicturecontent) | No | No | Picture-attached. |
## NotificationBasicContent ## NotificationBasicContent
...@@ -22,11 +22,11 @@ Describes the normal text notification. ...@@ -22,11 +22,11 @@ Describes the normal text notification.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| -------------- | ------ | ---- | ---- | ---------------------------------- | | -------------- | ------ | ---- | ---- | ---------------------------------- |
| title | string | Yes | Yes | Notification title. | | title | string | No | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. | | text | string | No | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.| | additionalText | string | No | No | Additional information of the notification.|
## NotificationLongTextContent ## NotificationLongTextContent
...@@ -35,14 +35,14 @@ Describes the long text notification. ...@@ -35,14 +35,14 @@ Describes the long text notification.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| -------------- | ------ | ---- | --- | -------------------------------- | | -------------- | ------ | ---- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. | | title | string | No | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. | | text | string | No | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.| | additionalText | string | No | No | Additional information of the notification.|
| longText | string | Yes | Yes | Long text of the notification. | | longText | string | No | Yes | Long text of the notification. |
| briefText | string | Yes | Yes | Brief text of the notification.| | briefText | string | No | Yes | Brief text of the notification. |
| expandedTitle | string | Yes | Yes | Title of the notification in the expanded state. | | expandedTitle | string | No | Yes | Title of the notification in the expanded state. |
## NotificationMultiLineContent ## NotificationMultiLineContent
...@@ -53,12 +53,12 @@ Describes the multi-line text notification. ...@@ -53,12 +53,12 @@ Describes the multi-line text notification.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| -------------- | --------------- | --- | --- | -------------------------------- | | -------------- | --------------- | --- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. | | title | string | No | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. | | text | string | No | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.| | additionalText | string | No | No | Additional information of the notification.|
| briefText | string | Yes | Yes | Brief text of the notification.| | briefText | string | No | Yes | Brief text of the notification.|
| longTitle | string | Yes | Yes | Title of the notification in the expanded state. | | longTitle | string | No | Yes | Title of the notification in the expanded state. |
| lines | Array\<string\> | Yes | Yes | Multi-line text of the notification. | | lines | Array\<string\> | No | Yes | Multi-line text of the notification. |
## NotificationPictureContent ## NotificationPictureContent
...@@ -69,9 +69,9 @@ Describes the picture-attached notification. ...@@ -69,9 +69,9 @@ Describes the picture-attached notification.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| -------------- | -------------- | ---- | --- | -------------------------------- | | -------------- | -------------- | ---- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. | | title | string | No | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. | | text | string | No | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.| | additionalText | string | No | No | Additional information of the notification.|
| briefText | string | Yes | Yes | Brief text of the notification.| | briefText | string | No | Yes | Brief text of the notification.|
| expandedTitle | string | Yes | Yes | Title of the notification in the expanded state. | | expandedTitle | string | No | Yes | Title of the notification in the expanded state. |
| picture | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Picture attached to the notification. | | picture | [image.PixelMap](js-apis-image.md#pixelmap7) | No | Yes | Picture attached to the notification. |
...@@ -8,7 +8,7 @@ The **NotificationFlags** module implements a **NotificationFlags** instance. ...@@ -8,7 +8,7 @@ The **NotificationFlags** module implements a **NotificationFlags** instance.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| ---------------- | ---------------------- | ---- | ---- | --------------------------------- | | ---------------- | ---------------------- | ---- | ---- | --------------------------------- |
| soundEnabled | [NotificationFlagStatus](#notificationflagstatus) | Yes | No | Whether to enable the sound alert for the notification. | | soundEnabled | [NotificationFlagStatus](#notificationflagstatus) | Yes | No | Whether to enable the sound alert for the notification. |
| vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus) | Yes | No | Whether to enable vibration for the notification. | | vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus) | Yes | No | Whether to enable vibration for the notification. |
......
...@@ -8,45 +8,45 @@ The **NotificationRequest** module describes the notification request. ...@@ -8,45 +8,45 @@ The **NotificationRequest** module describes the notification request.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| --------------------- | --------------------------------------------- | ---- | --- | -------------------------- | | --------------------- | --------------------------------------------- | ---- | --- | -------------------------- |
| content | [NotificationContent](js-apis-inner-notification-notificationContent.md#notificationcontent) | Yes | Yes | Notification content. | | content | [NotificationContent](js-apis-inner-notification-notificationContent.md#notificationcontent) | No | Yes | Notification content. |
| id | number | Yes | Yes | Notification ID. | | id | number | No | No | Notification ID. |
| slotType | [SlotType](js-apis-notificationManager.md#slottype) | Yes | Yes | Notification slot type. | | slotType | [SlotType](js-apis-notificationManager.md#slottype) | Yes | No | Notification slot type. |
| isOngoing | boolean | Yes | Yes | Whether the notification is an ongoing notification. | | isOngoing | boolean | No | No | Whether the notification is an ongoing notification. |
| isUnremovable | boolean | Yes | Yes | Whether the notification can be removed. | | isUnremovable | boolean | No | No | Whether the notification can be removed. |
| deliveryTime | number | Yes | Yes | Time when the notification is sent. | | deliveryTime | number | No | No | Time when the notification is sent. |
| tapDismissed | boolean | Yes | Yes | Whether the notification is automatically cleared. | | tapDismissed | boolean | No | No | Whether the notification is automatically cleared. |
| autoDeletedTime | number | Yes | Yes | Time when the notification is automatically cleared. | | autoDeletedTime | number | No | No | Time when the notification is automatically cleared. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** instance to which the notification will be redirected after being clicked.| | wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | No | No | **WantAgent** instance to which the notification will be redirected after being clicked.|
| extraInfo | {[key: string]: any} | Yes | Yes | Extended parameters. | | extraInfo | {[key: string]: any} | No | No | Extended parameters. |
| color | number | Yes | Yes | Background color of the notification. Not supported currently.| | color | number | No | No | Background color of the notification. Not supported currently.|
| colorEnabled | boolean | Yes | Yes | Whether the notification background color can be enabled. Not supported currently.| | colorEnabled | boolean | No | No | Whether the notification background color can be enabled. Not supported currently.|
| isAlertOnce | boolean | Yes | Yes | Whether the notification triggers an alert only once.| | isAlertOnce | boolean | No | No | Whether the notification triggers an alert only once.|
| isStopwatch | boolean | Yes | Yes | Whether to display the stopwatch. | | isStopwatch | boolean | No | No | Whether to display the stopwatch. |
| isCountDown | boolean | Yes | Yes | Whether to display the countdown time. | | isCountDown | boolean | No | No | Whether to display the countdown time. |
| isFloatingIcon | boolean | Yes | Yes | Whether the notification is displayed as a floating icon in the status bar. | | isFloatingIcon | boolean | No | No | Whether the notification is displayed as a floating icon in the status bar. |
| label | string | Yes | Yes | Notification label. | | label | string | No | No | Notification label. |
| badgeIconStyle | number | Yes | Yes | Notification badge type. | | badgeIconStyle | number | No | No | Notification badge type. Not supported currently. |
| showDeliveryTime | boolean | Yes | Yes | Whether to display the time when the notification is delivered. | | showDeliveryTime | boolean | No | No | Whether to display the time when the notification is delivered. |
| actionButtons | Array\<[NotificationActionButton](js-apis-inner-notification-notificationActionButton.md)\> | Yes | Yes | Buttons in the notification. Up to three buttons are allowed. | | actionButtons | Array\<[NotificationActionButton](js-apis-inner-notification-notificationActionButton.md)\> | No | No | Buttons in the notification. Up to three buttons are allowed. |
| smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Small notification icon. This field is optional, and the icon size cannot exceed 30 KB.| | smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | No | No | Small notification icon. This field is optional, and the icon size cannot exceed 30 KB.|
| largeIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Large notification icon. This field is optional, and the icon size cannot exceed 30 KB.| | largeIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | No | No | Large notification icon. This field is optional, and the icon size cannot exceed 30 KB.|
| creatorBundleName | string | Yes | No | Name of the bundle that creates the notification. | | creatorBundleName | string | Yes | No | Name of the bundle that creates the notification. |
| creatorUid<sup>8+<sup> | number | Yes | No | UID used for creating the notification. | | creatorUid<sup>8+<sup> | number | Yes | No | UID used for creating the notification. |
| creatorPid | number | Yes | No | PID used for creating the notification. | | creatorPid | number | Yes | No | PID used for creating the notification. |
| creatorUserId| number | Yes | No | ID of the user who creates the notification. | | creatorUserId | number | Yes | No | ID of the user who creates the notification. |
| hashCode | string | Yes | No | Unique ID of the notification. | | hashCode | string | Yes | No | Unique ID of the notification. |
| classification | string | Yes | Yes | Notification category.<br>**System API**: This is a system API and cannot be called by third-party applications. | | classification | string | No | No | Notification category.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| groupName<sup>8+<sup> | string | Yes | Yes | Notification group name. | | groupName<sup>8+<sup> | string | No | No | Notification group name. |
| template<sup>8+<sup> | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | Yes | Yes | Notification template. | | template<sup>8+<sup> | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | No | No | Notification template. |
| isRemoveAllowed<sup>8+<sup> | boolean | Yes | No | Whether the notification can be removed.<br>**System API**: This is a system API and cannot be called by third-party applications. | | isRemoveAllowed<sup>8+<sup> | boolean | Yes | No | Whether the notification can be removed.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| source<sup>8+<sup> | number | Yes | No | Notification source.<br>**System API**: This is a system API and cannot be called by third-party applications. | | source<sup>8+<sup> | number | Yes | No | Notification source.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| distributedOption<sup>8+<sup> | [DistributedOptions](#distributedoptions) | Yes | Yes | Distributed notification options. | | distributedOption<sup>8+<sup> | [DistributedOptions](#distributedoptions) | No | No | Distributed notification options. |
| deviceId<sup>8+<sup> | string | Yes | No | Device ID of the notification source.<br>**System API**: This is a system API and cannot be called by third-party applications. | | deviceId<sup>8+<sup> | string | Yes | No | Device ID of the notification source.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| notificationFlags<sup>8+<sup> | [NotificationFlags](js-apis-inner-notification-notificationflags#notificationFlags) | Yes | No | Notification flags. | | notificationFlags<sup>8+<sup> | [NotificationFlags](js-apis-inner-notification-notificationFlags.md#notificationflags) | Yes | No | Notification flags. |
| removalWantAgent<sup>9+<sup> | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** instance to which the notification will be redirected when it is removed. | | removalWantAgent<sup>9+<sup> | [WantAgent](js-apis-app-ability-wantAgent.md) | No | No | **WantAgent** instance to which the notification will be redirected when it is removed. |
| badgeNumber<sup>9+<sup> | number | Yes | Yes | Number of notifications displayed on the application icon. | | badgeNumber<sup>9+<sup> | number | No | No | Number of notifications displayed on the application icon. |
## DistributedOptions ## DistributedOptions
...@@ -55,9 +55,9 @@ Describes distributed notification options. ...@@ -55,9 +55,9 @@ Describes distributed notification options.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| ---------------------- | -------------- | ---- | ---- | ---------------------------------- | | ---------------------- | -------------- | ---- | ---- | ---------------------------------- |
| isDistributed<sup>8+<sup> | boolean | Yes | Yes | Whether the notification is a distributed notification. | | isDistributed<sup>8+<sup> | boolean | No | No | Whether the notification is a distributed notification. |
| supportDisplayDevices<sup>8+<sup> | Array\<string> | Yes | Yes | List of the devices to which the notification can be synchronized. | | supportDisplayDevices<sup>8+<sup> | Array\<string> | No | No | List of the devices to which the notification can be synchronized. |
| supportOperateDevices<sup>8+<sup> | Array\<string> | Yes | Yes | List of the devices on which the notification can be opened. | | supportOperateDevices<sup>8+<sup> | Array\<string> | No | No | List of the devices on which the notification can be opened. |
| remindType<sup>8+<sup> | number | Yes | No | Notification reminder type.<br>**System API**: This is a system API and cannot be called by third-party applications. | | remindType<sup>8+<sup> | number | Yes | No | Notification reminder type.<br>**System API**: This is a system API and cannot be called by third-party applications. |
...@@ -8,17 +8,17 @@ The **NotificationSlot** module describes the notification slot. ...@@ -8,17 +8,17 @@ The **NotificationSlot** module describes the notification slot.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ | | -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| type | [SlotType](js-apis-notificationManager.md#slottype) | Yes | Yes | Notification slot type. | | type | [SlotType](js-apis-notificationManager.md#slottype) | No | Yes | Notification slot type. |
| level | number | Yes | Yes | Notification level. If this parameter is not set, the default value that corresponds to the notification slot type is used.| | level | number | No | No | Notification level. If this parameter is not set, the default value that corresponds to the notification slot type is used.|
| desc | string | Yes | Yes | Notification slot description. | | desc | string | No | No | Notification slot description. |
| badgeFlag | boolean | Yes | Yes | Whether to display the badge. | | badgeFlag | boolean | No | No | Whether to display the badge. |
| bypassDnd | boolean | Yes | Yes | Whether to bypass DND mode in the system. | | bypassDnd | boolean | No | No | Whether to bypass DND mode in the system. |
| lockscreenVisibility | number | Yes | Yes | Mode for displaying the notification on the lock screen. | | lockscreenVisibility | number | No | No | Mode for displaying the notification on the lock screen. |
| vibrationEnabled | boolean | Yes | Yes | Whether to enable vibration for the notification. | | vibrationEnabled | boolean | No | No | Whether to enable vibration for the notification. |
| sound | string | Yes | Yes | Notification alert tone. | | sound | string | No | No | Notification alert tone. |
| lightEnabled | boolean | Yes | Yes | Whether the indicator blinks for the notification. | | lightEnabled | boolean | No | No | Whether the indicator blinks for the notification. |
| lightColor | number | Yes | Yes | Indicator color of the notification. | | lightColor | number | No | No | Indicator color of the notification. |
| vibrationValues | Array\<number\> | Yes | Yes | Vibration mode of the notification. | | vibrationValues | Array\<number\> | No | No | Vibration mode of the notification. |
| enabled<sup>9+</sup> | boolean | Yes | No | Whether the notification slot is enabled. | | enabled<sup>9+</sup> | boolean | Yes | No | Whether the notification slot is enabled. |
# NotificationSorting
Provides sorting information of active notifications.
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Read-only| Mandatory| Description |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | Yes | Yes | Notification slot type. |
| level | number | Yes | Yes | Notification level. If this parameter is not set, the default value is used based on the notification slot type.|
| desc | string | Yes | Yes | Description of the notification slot. |
# NotificationSortingMap
Provides sorting information of active notifications in all subscribed notifications.
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Read-only| Mandatory| Description |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| sortings | { [key: string]: [NotificationSorting](js-apis-inner-notification-notificationSorting.md) } | Yes | Yes | Array of notification sorting information.|
| sortedHashCode | Array\<string> | Yes | Yes | Hash codes for notification sorting.|
# NotificationSubscribeInfo
Provides the information about the publisher for notification subscription.
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Read-only| Mandatory| Description |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| bundleNames | Array\<string> | No | No | Bundle names of the applications whose notifications are to be subscribed to. |
| userId | number | No | No | User ID. |
...@@ -8,7 +8,7 @@ The **NotificationTemplate** module describes the notification template. ...@@ -8,7 +8,7 @@ The **NotificationTemplate** module describes the notification template.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name| Type | Readable| Writable| Description | | Name| Type | Read-only| Mandatory| Description |
| ---- | ---------------------- | ---- | ---- | ---------- | | ---- | ---------------------- | ---- | ---- | ---------- |
| name | string | Yes | Yes | Template name.| | name | string | No | Yes | Template name.|
| data | {[key:string]: Object} | Yes | Yes | Template data.| | data | {[key:string]: Object} | No | Yes | Template data.|
...@@ -8,6 +8,6 @@ The **NotificationUserInput** module provides the notification user input. ...@@ -8,6 +8,6 @@ The **NotificationUserInput** module provides the notification user input.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description | | Name | Type | Read-only| Mandatory| Description |
| -------- | ------ | --- | ---- | ----------------------------- | | -------- | ------ | --- | ---- | ----------------------------- |
| inputKey | string | Yes | Yes | Key to identify the user input.| | inputKey | string | No | Yes | Key to identify the user input.|
...@@ -586,7 +586,7 @@ Notification.getSlot(slotType).then((data) => { ...@@ -586,7 +586,7 @@ Notification.getSlot(slotType).then((data) => {
## Notification.getSlots ## Notification.getSlots
getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void getSlots(callback: AsyncCallback\<Array\<NotificationSlot>>): void
Obtains all notification slots. This API uses an asynchronous callback to return the result. Obtains all notification slots. This API uses an asynchronous callback to return the result.
...@@ -596,7 +596,7 @@ Obtains all notification slots. This API uses an asynchronous callback to return ...@@ -596,7 +596,7 @@ Obtains all notification slots. This API uses an asynchronous callback to return
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------- | ---- | -------------------- | | -------- | --------------------------------- | ---- | -------------------- |
| callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)\>\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)>> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -1364,7 +1364,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => { ...@@ -1364,7 +1364,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
## Notification.getSlotsByBundle ## Notification.getSlotsByBundle
getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<NotificationSlot\>>): void getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\<Array\<NotificationSlot>>): void
Obtains the notification slots of a specified application. This API uses an asynchronous callback to return the result. Obtains the notification slots of a specified application. This API uses an asynchronous callback to return the result.
...@@ -1379,7 +1379,7 @@ Obtains the notification slots of a specified application. This API uses an asyn ...@@ -1379,7 +1379,7 @@ Obtains the notification slots of a specified application. This API uses an asyn
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | -------------------- | | -------- | ---------------------------------------- | ---- | -------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. |
| callback | AsyncCallback<Array\<[NotificationSlot](#notificationslot)\>> | Yes | Callback used to return the result.| | callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)>> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -1401,7 +1401,7 @@ Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); ...@@ -1401,7 +1401,7 @@ Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
## Notification.getSlotsByBundle ## Notification.getSlotsByBundle
getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>> getSlotsByBundle(bundle: BundleOption): Promise\<Array\<NotificationSlot>>
Obtains the notification slots of a specified application. This API uses a promise to return the result. Obtains the notification slots of a specified application. This API uses a promise to return the result.
...@@ -1421,7 +1421,7 @@ Obtains the notification slots of a specified application. This API uses a promi ...@@ -1421,7 +1421,7 @@ Obtains the notification slots of a specified application. This API uses a promi
| Type | Description | | Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise<Array\<[NotificationSlot](#notificationslot)\>> | Promise used to return the result.| | Promise\<Array\<[NotificationSlot](#notificationslot)>> | Promise used to return the result.|
**Example** **Example**
...@@ -1823,7 +1823,7 @@ Notification.removeAll(userId).then(() => { ...@@ -1823,7 +1823,7 @@ Notification.removeAll(userId).then(() => {
## Notification.getAllActiveNotifications ## Notification.getAllActiveNotifications
getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void getAllActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void
Obtains all active notifications. This API uses an asynchronous callback to return the result. Obtains all active notifications. This API uses an asynchronous callback to return the result.
...@@ -1837,7 +1837,7 @@ Obtains all active notifications. This API uses an asynchronous callback to retu ...@@ -1837,7 +1837,7 @@ Obtains all active notifications. This API uses an asynchronous callback to retu
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------- | | -------- | ------------------------------------------------------------ | ---- | -------------------- |
| callback | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | Yes | Callback used to return the result.| | callback | AsyncCallback\<Array\<[NotificationRequest](#notificationrequest)>> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -1857,7 +1857,7 @@ Notification.getAllActiveNotifications(getAllActiveNotificationsCallback); ...@@ -1857,7 +1857,7 @@ Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
## Notification.getAllActiveNotifications ## Notification.getAllActiveNotifications
getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)>>
Obtains all active notifications. This API uses a promise to return the result. Obtains all active notifications. This API uses a promise to return the result.
...@@ -1871,7 +1871,7 @@ Obtains all active notifications. This API uses a promise to return the result. ...@@ -1871,7 +1871,7 @@ Obtains all active notifications. This API uses a promise to return the result.
| Type | Description | | Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.| | Promise\<Array\<[NotificationRequest](#notificationrequest)>> | Promise used to return the result.|
**Example** **Example**
...@@ -2903,476 +2903,6 @@ Notification.getDeviceRemindType().then((data) => { ...@@ -2903,476 +2903,6 @@ Notification.getDeviceRemindType().then((data) => {
}); });
``` ```
## Notification.publishAsBundle<sup>9+</sup>
publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void
Publishes an agent-powered notification. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------------------- | ------------------------------------------- | ---- | ---------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | Yes | Content and related configuration of the notification to publish.|
| representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent. |
| userId | number | Yes | User ID. |
| callback | AsyncCallback | Yes | Callback used to return the result. |
**Example**
```js
// publishAsBundle callback
function callback(err) {
if (err.code) {
console.info("publishAsBundle failed " + JSON.stringify(err));
} else {
console.info("publishAsBundle success");
}
}
// Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo";
// User ID
let userId = 100;
// NotificationRequest object
let request = {
id: 1,
content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
}
}
};
Notification.publishAsBundle(request, representativeBundle, userId, callback);
```
## Notification.publishAsBundle<sup>9+</sup>
publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number): Promise\<void\>
Publishes a notification through the reminder agent. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | Yes | Content and related configuration of the notification to publish.|
| representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent. |
| userId | number | Yes | User ID. |
**Example**
```js
// Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo";
// User ID
let userId = 100;
// NotificationRequest object
let request = {
id: 1,
content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
}
}
};
Notification.publishAsBundle(request, representativeBundle, userId).then(() => {
console.info("publishAsBundle success");
});
```
## Notification.cancelAsBundle<sup>9+</sup>
cancelAsBundle(id: number, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void
Cancels a notification published by the reminder agent. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------------------- | ------------- | ---- | ------------------------ |
| id | number | Yes | Notification ID. |
| representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent. |
| userId | number | Yes | User ID. |
| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
```js
// cancelAsBundle
function cancelAsBundleCallback(err) {
if (err.code) {
console.info("cancelAsBundle failed " + JSON.stringify(err));
} else {
console.info("cancelAsBundle success");
}
}
// Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo";
// User ID
let userId = 100;
Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback);
```
## Notification.cancelAsBundle<sup>9+</sup>
cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\<void\>
Cancels a notification published by the reminder agent. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------------------- | ------ | ---- | ------------------ |
| id | number | Yes | Notification ID. |
| representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent.|
| userId | number | Yes | User ID.|
**Example**
```js
// Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo";
// User ID
let userId = 100;
Notification.cancelAsBundle(0, representativeBundle, userId).then(() => {
console.info("cancelAsBundle success");
});
```
## Notification.enableNotificationSlot <sup>9+</sup>
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void
Sets the enabled status of a notification slot type for a specified application. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | ---------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. |
| type | [SlotType](#slottype) | Yes | Notification slot type. |
| enable | boolean | Yes | Whether to enable notification. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Example**
```js
// enableNotificationSlot
function enableSlotCallback(err) {
if (err.code) {
console.info("enableNotificationSlot failed " + JSON.stringify(err));
} else {
console.info("enableNotificationSlot success");
}
};
Notification.enableNotificationSlot(
{ bundle: "ohos.samples.notification", },
Notification.SlotType.SOCIAL_COMMUNICATION,
true,
enableSlotCallback);
```
## Notification.enableNotificationSlot <sup>9+</sup>
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\<void>
Sets the enabled status of a notification slot type for a specified application. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. |
| type | [SlotType](#slottype) | Yes | Notification slot type.|
| enable | boolean | Yes | Whether to enable notification. |
**Example**
```js
// enableNotificationSlot
Notification.enableNotificationSlot({ bundle: "ohos.samples.notification", },
Notification.SlotType.SOCIAL_COMMUNICATION,true).then(() => {
console.info("enableNotificationSlot success");
});
```
## Notification.isNotificationSlotEnabled <sup>9+</sup>
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\<boolean\>): void
Checks whether a specified notification slot type is enabled for a specified application. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | ---------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. |
| type | [SlotType](#slottype) | Yes | Notification slot type. |
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.|
**Example**
```js
// isNotificationSlotEnabled
function getEnableSlotCallback(err, data) {
if (err.code) {
console.info("isNotificationSlotEnabled failed " + JSON.stringify(err));
} else {
console.info("isNotificationSlotEnabled success");
}
};
Notification.isNotificationSlotEnabled(
{ bundle: "ohos.samples.notification", },
Notification.SlotType.SOCIAL_COMMUNICATION,
getEnableSlotCallback);
```
## Notification.isNotificationSlotEnabled <sup>9+</sup>
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolean\>
Checks whether a specified notification slot type is enabled for a specified application. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. |
| type | [SlotType](#slottype) | Yes | Notification slot type.|
**Return value**
| Type | Description |
| ------------------ | ------------------------------- |
| Promise\<boolean\> | Promise used to return the result.|
**Example**
```js
// isNotificationSlotEnabled
Notification.isNotificationSlotEnabled({ bundle: "ohos.samples.notification", },
Notification.SlotType.SOCIAL_COMMUNICATION).then((data) => {
console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data));
});
```
## Notification.setSyncNotificationEnabledWithoutApp<sup>9+</sup>
setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: AsyncCallback\<void\>): void
Sets whether to enable the notification sync feature for devices where the application is not installed. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes | User ID. |
| enable | boolean | Yes | Whether the feature is enabled. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Example**
```js
let userId = 100;
let enable = true;
function callback(err) {
if (err.code) {
console.info("setSyncNotificationEnabledWithoutApp failed " + JSON.stringify(err));
} else {
console.info("setSyncNotificationEnabledWithoutApp success");
}
}
Notification.setSyncNotificationEnabledWithoutApp(userId, enable, callback);
```
## Notification.setSyncNotificationEnabledWithoutApp<sup>9+</sup>
setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<void>
Sets whether to enable the notification sync feature for devices where the application is not installed. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes | User ID. |
| enable | boolean | Yes | Whether the feature is enabled. |
**Return value**
| Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<void\> | Promise used to return the result.|
**Example**
```js
let userId = 100;
let enable = true;
Notification.setSyncNotificationEnabledWithoutApp(userId, enable).then(() => {
console.info('setSyncNotificationEnabledWithoutApp success');
}).catch((err) => {
console.info('setSyncNotificationEnabledWithoutApp, err:' + JSON.stringify(err));
});
```
## Notification.getSyncNotificationEnabledWithoutApp<sup>9+</sup>
getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<boolean>): void
Obtains whether the notification sync feature is enabled for devices where the application is not installed. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes | User ID. |
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.|
**Example**
```js
let userId = 100;
function getSyncNotificationEnabledWithoutAppCallback(err, data) {
if (err) {
console.info('getSyncNotificationEnabledWithoutAppCallback, err:' + err);
} else {
console.info('getSyncNotificationEnabledWithoutAppCallback, data:' + data);
}
}
Notification.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEnabledWithoutAppCallback);
```
## Notification.getSyncNotificationEnabledWithoutApp<sup>9+</sup>
getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
Obtains whether the notification sync feature is enabled for devices where the application is not installed. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes | User ID. |
**Return value**
| Type | Description |
| ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
**Example**
```js
let userId = 100;
Notification.getSyncNotificationEnabledWithoutApp(userId).then((data) => {
console.info('getSyncNotificationEnabledWithoutApp, data:' + data);
}).catch((err) => {
console.info('getSyncNotificationEnabledWithoutApp, err:' + err);
});
```
## NotificationSubscriber ## NotificationSubscriber
Provides callbacks for receiving or removing notifications and serves as the input parameter of [subscribe](#notificationsubscribe). Provides callbacks for receiving or removing notifications and serves as the input parameter of [subscribe](#notificationsubscribe).
...@@ -4111,5 +3641,5 @@ Provides the notification user input. ...@@ -4111,5 +3641,5 @@ Provides the notification user input.
| Name | Value | Description | | Name | Value | Description |
| -------------------- | --- | -------------------- | | -------------------- | --- | -------------------- |
| CLICK_REASON_REMOVE | 1 | The notification is removed after a click on it. | | CLICK_REASON_REMOVE<sup>9+</sup> | 1 | The notification is removed after a click on it. |
| CANCEL_REASON_REMOVE | 2 | The notification is removed by the user. | | CANCEL_REASON_REMOVE<sup>9+</sup> | 2 | The notification is removed by the user. |
...@@ -33,7 +33,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -33,7 +33,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -89,8 +88,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -89,8 +88,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -145,8 +142,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -145,8 +142,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -208,8 +203,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -208,8 +203,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 201 | Permission denied. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -263,7 +256,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -263,7 +256,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -306,7 +298,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -306,7 +298,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -343,7 +334,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -343,7 +334,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -379,7 +369,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -379,7 +369,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -420,7 +409,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -420,7 +409,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -460,9 +448,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -460,9 +448,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -511,9 +496,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -511,9 +496,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -553,7 +535,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -553,7 +535,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -594,7 +575,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -594,7 +575,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -634,9 +614,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -634,9 +614,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -689,9 +666,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -689,9 +666,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -735,7 +709,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -735,7 +709,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -783,7 +756,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -783,7 +756,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -801,7 +773,7 @@ Notification.getSlot(slotType).then((data) => { ...@@ -801,7 +773,7 @@ Notification.getSlot(slotType).then((data) => {
## Notification.getSlots ## Notification.getSlots
getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void getSlots(callback: AsyncCallback\<Array\<NotificationSlot>>): void
Obtains all notification slots of this application. This API uses an asynchronous callback to return the result. Obtains all notification slots of this application. This API uses an asynchronous callback to return the result.
...@@ -819,7 +791,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -819,7 +791,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -842,7 +813,7 @@ Notification.getSlots(getSlotsCallback); ...@@ -842,7 +813,7 @@ Notification.getSlots(getSlotsCallback);
## Notification.getSlots ## Notification.getSlots
getSlots(): Promise\<Array\<NotificationSlot\>> getSlots(): Promise\<Array\<NotificationSlot>>
Obtains all notification slots of this application. This API uses a promise to return the result. Obtains all notification slots of this application. This API uses a promise to return the result.
...@@ -860,7 +831,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -860,7 +831,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -896,7 +866,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -896,7 +866,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -938,7 +907,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -938,7 +907,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -974,7 +942,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -974,7 +942,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1008,7 +975,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1008,7 +975,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1049,9 +1015,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1049,9 +1015,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1100,9 +1063,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1100,9 +1063,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1146,9 +1106,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1146,9 +1106,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1202,9 +1159,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1202,9 +1159,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1247,9 +1201,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1247,9 +1201,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1282,11 +1233,93 @@ Checks whether notification is enabled for the current application. This API use ...@@ -1282,11 +1233,93 @@ Checks whether notification is enabled for the current application. This API use
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
**Return value**
| Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ---------------------------------------- |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
**Example**
```ts
notificationManager.isNotificationEnabled().then((data) => {
console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
});
```
## notificationManager.isNotificationEnabled
isNotificationEnabled(userId: number, callback: AsyncCallback\<boolean\>): void
Checks whether notification is enabled for a specified user. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------ |
| userId | number | Yes | User ID.|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. |
| 1600008 | The user is not exist. |
**Example**
```ts
function isNotificationEnabledCallback(err, data) {
if (err) {
console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("isNotificationEnabled success");
}
}
let userId = 1;
notificationManager.isNotificationEnabled(userId, isNotificationEnabledCallback);
```
## notificationManager.isNotificationEnabled
isNotificationEnabled(userId: number): Promise\<boolean\>
Checks whether notification is enabled for a specified user. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application.| | userId | number | Yes | User ID.|
**Return value** **Return value**
...@@ -1300,18 +1333,17 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1300,18 +1333,17 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
| 17700001 | The specified bundle name was not found. | | 1600008 | The user is not exist.. |
**Example** **Example**
```js ```ts
Notification.isNotificationEnabled().then((data) => { let userId = 1;
notificationManager.isNotificationEnabled(userId).then((data) => {
console.info("isNotificationEnabled success, data: " + JSON.stringify(data)); console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1344,9 +1376,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1344,9 +1376,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1395,9 +1424,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1395,9 +1424,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1441,9 +1467,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1441,9 +1467,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1497,9 +1520,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1497,9 +1520,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1542,9 +1562,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1542,9 +1562,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1598,9 +1615,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1598,9 +1615,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1624,7 +1638,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => { ...@@ -1624,7 +1638,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
## Notification.getSlotsByBundle ## Notification.getSlotsByBundle
getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<NotificationSlot\>>): void getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\<Array\<NotificationSlot>>): void
Obtains the notification slots of a specified application. This API uses an asynchronous callback to return the result. Obtains the notification slots of a specified application. This API uses an asynchronous callback to return the result.
...@@ -1647,9 +1661,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1647,9 +1661,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1695,7 +1706,7 @@ Obtains the notification slots of a specified application. This API uses a promi ...@@ -1695,7 +1706,7 @@ Obtains the notification slots of a specified application. This API uses a promi
| Type | Description | | Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\>> | Promise used to return the result.| | Promise\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)>> | Promise used to return the result.|
**Error codes** **Error codes**
...@@ -1703,9 +1714,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1703,9 +1714,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1749,9 +1757,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1749,9 +1757,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1805,9 +1810,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1805,9 +1810,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1829,7 +1831,7 @@ Notification.getSlotNumByBundle(bundle).then((data) => { ...@@ -1829,7 +1831,7 @@ Notification.getSlotNumByBundle(bundle).then((data) => {
## Notification.getAllActiveNotifications ## Notification.getAllActiveNotifications
getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void getAllActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void
Obtains all active notifications. This API uses an asynchronous callback to return the result. Obtains all active notifications. This API uses an asynchronous callback to return the result.
...@@ -1851,9 +1853,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1851,9 +1853,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1898,9 +1897,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1898,9 +1897,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1935,7 +1931,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1935,7 +1931,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1976,7 +1971,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -1976,7 +1971,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -1993,7 +1987,7 @@ Notification.getActiveNotificationCount().then((data) => { ...@@ -1993,7 +1987,7 @@ Notification.getActiveNotificationCount().then((data) => {
## Notification.getActiveNotifications ## Notification.getActiveNotifications
getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void getActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void
Obtains active notifications of this application. This API uses an asynchronous callback to return the result. Obtains active notifications of this application. This API uses an asynchronous callback to return the result.
...@@ -2003,7 +1997,7 @@ Obtains active notifications of this application. This API uses an asynchronous ...@@ -2003,7 +1997,7 @@ Obtains active notifications of this application. This API uses an asynchronous
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------ |
| callback | AsyncCallback<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>> | Yes | Callback used to return the result.| | callback | AsyncCallback\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)>> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -2011,7 +2005,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2011,7 +2005,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2052,7 +2045,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2052,7 +2045,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2088,7 +2080,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2088,7 +2080,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2104,7 +2095,7 @@ function cancelGroupCallback(err) { ...@@ -2104,7 +2095,7 @@ function cancelGroupCallback(err) {
} }
} }
var groupName = "GroupName"; let groupName = "GroupName";
Notification.cancelGroup(groupName, cancelGroupCallback); Notification.cancelGroup(groupName, cancelGroupCallback);
``` ```
...@@ -2131,7 +2122,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2131,7 +2122,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2173,9 +2163,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2173,9 +2163,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2225,9 +2212,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2225,9 +2212,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2270,9 +2254,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2270,9 +2254,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2323,9 +2304,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2323,9 +2304,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2370,9 +2348,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2370,9 +2348,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2427,9 +2402,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2427,9 +2402,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2476,9 +2448,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2476,9 +2448,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2523,9 +2492,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2523,9 +2492,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2564,9 +2530,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2564,9 +2530,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2620,9 +2583,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2620,9 +2583,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2663,9 +2623,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2663,9 +2623,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2710,9 +2667,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2710,9 +2667,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2748,11 +2702,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2748,11 +2702,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
| 1600011 | Read template config failed. |
**Example** **Example**
...@@ -2797,11 +2749,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2797,11 +2749,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
| 1600011 | Read template config failed. |
**Example** **Example**
...@@ -2835,7 +2785,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2835,7 +2785,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2870,7 +2819,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2870,7 +2819,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2910,9 +2858,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2910,9 +2858,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2960,9 +2905,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2960,9 +2905,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -2999,7 +2941,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -2999,7 +2941,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3041,7 +2982,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3041,7 +2982,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3083,9 +3023,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3083,9 +3023,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3139,9 +3076,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3139,9 +3076,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3187,9 +3121,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3187,9 +3121,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3246,9 +3177,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3246,9 +3177,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3292,9 +3220,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3292,9 +3220,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3339,9 +3264,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3339,9 +3264,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3382,9 +3304,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3382,9 +3304,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3451,9 +3370,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3451,9 +3370,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------------- | | -------- | ----------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3516,9 +3432,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3516,9 +3432,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3572,9 +3485,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3572,9 +3485,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3621,9 +3531,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3621,9 +3531,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3674,9 +3581,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3674,9 +3581,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3720,9 +3624,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3720,9 +3624,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3777,9 +3678,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3777,9 +3678,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3822,9 +3720,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3822,9 +3720,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3879,9 +3774,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3879,9 +3774,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3926,9 +3818,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3926,9 +3818,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -3981,9 +3870,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -3981,9 +3870,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
......
...@@ -40,9 +40,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -40,9 +40,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -95,9 +92,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -95,9 +92,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -148,9 +142,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -148,9 +142,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -196,9 +187,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -196,9 +187,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -246,9 +234,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -246,9 +234,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -294,9 +279,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -294,9 +279,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -352,9 +334,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -352,9 +334,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -371,7 +350,7 @@ let notificationKey = { ...@@ -371,7 +350,7 @@ let notificationKey = {
id: 0, id: 0,
label: "label", label: "label",
}; };
let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; let reason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
notificationSubscribe.remove(bundle, notificationKey, reason).then(() => { notificationSubscribe.remove(bundle, notificationKey, reason).then(() => {
console.info("remove success"); console.info("remove success");
}); });
...@@ -393,7 +372,7 @@ Removes a specified notification. This API uses an asynchronous callback to retu ...@@ -393,7 +372,7 @@ Removes a specified notification. This API uses an asynchronous callback to retu
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| hashCode | string | Yes | Unique notification ID. It is the value of **hashCode** in the [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) object of [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) in the [onConsume](#onconsume) callback. | | hashCode | string | Yes | Unique notification ID. It is the **hashCode** in the [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) object of [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) of the [onConsume](js-apis-notification.md#onconsume) callback.|
| reason | [RemoveReason](#removereason) | Yes | Reason for removing the notification. | | reason | [RemoveReason](#removereason) | Yes | Reason for removing the notification. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
...@@ -403,9 +382,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -403,9 +382,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -423,7 +399,7 @@ function removeCallback(err) { ...@@ -423,7 +399,7 @@ function removeCallback(err) {
console.info("remove success"); console.info("remove success");
} }
} }
let reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE; let reason = notificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE;
notificationSubscribe.remove(hashCode, reason, removeCallback); notificationSubscribe.remove(hashCode, reason, removeCallback);
``` ```
...@@ -452,9 +428,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -452,9 +428,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -486,7 +459,7 @@ Removes all notifications for a specified application. This API uses an asynchro ...@@ -486,7 +459,7 @@ Removes all notifications for a specified application. This API uses an asynchro
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ---------------------------- | | -------- | --------------------- | ---- | ---------------------------- |
| bundle | [BundleOption](js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. | | bundle | [BundleOption](js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -495,9 +468,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -495,9 +468,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -516,7 +486,7 @@ function removeAllCallback(err) { ...@@ -516,7 +486,7 @@ function removeAllCallback(err) {
let bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
}; };
NotificationSubscribe.removeAll(bundle, removeAllCallback); notificationSubscribe.removeAll(bundle, removeAllCallback);
``` ```
## NotificationSubscribe.removeAll ## NotificationSubscribe.removeAll
...@@ -543,9 +513,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -543,9 +513,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -588,9 +555,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -588,9 +555,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -630,9 +594,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -630,9 +594,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -678,9 +639,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ...@@ -678,9 +639,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/
| ID| Error Message | | ID| Error Message |
| -------- | ----------------------------------- | | -------- | ----------------------------------- |
| 201 | Permission denied. |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. | | 1600001 | Internal error. |
| 1600002 | Marshalling or unmarshalling error. | | 1600002 | Marshalling or unmarshalling error. |
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
...@@ -702,319 +660,6 @@ let userId = 1; ...@@ -702,319 +660,6 @@ let userId = 1;
notificationSubscribe.removeAll(userId, removeAllCallback); notificationSubscribe.removeAll(userId, removeAllCallback);
``` ```
## NotificationSubscriber
Provides callbacks for receiving or removing notifications and serves as the input parameter of [subscribe](#notificationsubscribesubscribe).
**System API**: This is a system API and cannot be called by third-party applications.
### onConsume
onConsume?: (data: [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)) => void
Called when a notification is received.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) | Yes| Information about the notification received.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onConsumeCallback(data) {
console.info('===> onConsume in test');
let req = data.request;
console.info('===> onConsume callback req.id:' + req.id);
};
let subscriber = {
onConsume: onConsumeCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onCancel
onCancel?:(data: [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)) => void
Called when a notification is canceled.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) | Yes| Information about the notification to cancel.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onCancelCallback(data) {
console.info('===> onCancel in test');
let req = data.request;
console.info('===> onCancel callback req.id:' + req.id);
}
let subscriber = {
onCancel: onCancelCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onUpdate
onUpdate?:(data: [NotificationSortingMap](js-apis-notification.md#notificationsortingmap)) => void
Called when the notification sorting list is updated.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [NotificationSortingMap](js-apis-notification.md#notificationsortingmap)) | Yes| Latest notification sorting list.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onUpdateCallback(map) {
console.info('===> onUpdateCallback map:' + JSON.stringify(map));
}
let subscriber = {
onUpdate: onUpdateCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onConnect
onConnect?:() => void
Called when subscription is complete.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onConnectCallback() {
console.info('===> onConnect in test');
}
let subscriber = {
onConnect: onConnectCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onDisconnect
onDisconnect?:() => void
Called when unsubscription is complete.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function unsubscribeCallback(err) {
if (err.code) {
console.error(`unsubscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("unsubscribeCallback");
}
};
function onConnectCallback() {
console.info('===> onConnect in test');
}
function onDisconnectCallback() {
console.info('===> onDisconnect in test');
}
let subscriber = {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback
};
// The onConnect callback is invoked when subscription to the notification is complete.
notificationSubscribe.subscribe(subscriber, subscribeCallback);
// The onDisconnect callback is invoked when unsubscription to the notification is complete.
notificationSubscribe.unsubscribe(subscriber, unsubscribeCallback);
```
### onDestroy
onDestroy?:() => void
Callback for service disconnection.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onDestroyCallback() {
console.info('===> onDestroy in test');
}
let subscriber = {
onDestroy: onDestroyCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onDoNotDisturbDateChange
onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](js-apis-notificationManager.md#donotdisturbdate)) => void
Called when the DND time setting is updated.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| mode | notification.[DoNotDisturbDate](js-apis-notificationManager.md#DoNotDisturbDate) | Yes| DND time setting updates.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onDoNotDisturbDateChangeCallback(mode) {
console.info('===> onDoNotDisturbDateChange:' + mode);
}
let subscriber = {
onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onEnabledNotificationChanged
onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](js-apis-notification.md#enablednotificationcallbackdata8)) => void
Listens for the notification enabled status changes. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<[EnabledNotificationCallbackData](js-apis-notification.md#enablednotificationcallbackdata8)\> | Yes| Callback used to return the result.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onEnabledNotificationChangedCallback(callbackData) {
console.info("bundle: ", callbackData.bundle);
console.info("uid: ", callbackData.uid);
console.info("enable: ", callbackData.enable);
};
let subscriber = {
onEnabledNotificationChanged: onEnabledNotificationChangedCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
## RemoveReason ## RemoveReason
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
......
...@@ -14,13 +14,6 @@ The **request** module provides applications with basic upload, download, and ba ...@@ -14,13 +14,6 @@ The **request** module provides applications with basic upload, download, and ba
import request from '@ohos.request'; import request from '@ohos.request';
``` ```
## Constraints
Only HTTP requests are supported. HTTPS requests are not supported.
The download server must support the HTTP HEAD method so that the size of the data to download can be obtained through **Content-length**. Otherwise, the download task fails. If this is the case, you can check the failure cause through [on('fail')<sup>7+</sup>](#onfail7).
## Constants ## Constants
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -36,7 +29,7 @@ You can set **networkType** in [DownloadConfig](#downloadconfig) to specify the ...@@ -36,7 +29,7 @@ You can set **networkType** in [DownloadConfig](#downloadconfig) to specify the
| NETWORK_WIFI | number | 0x00010000 | Whether download is allowed on a WLAN.| | NETWORK_WIFI | number | 0x00010000 | Whether download is allowed on a WLAN.|
### Download Error Codes ### Download Error Codes
The table below lists the error codes that may be returned by [on('fail')<sup>7+</sup>](#onfail7)/[off('fail')<sup>7+</sup>](#offfail7)/[getTaskInfo<sup>9+</sup>](#gettaskinfo9). The table below lists the values of **err** in the callback of [on('fail')<sup>7+</sup>](#onfail7) and the values of **failedReason** returned by [getTaskInfo<sup>9+</sup>](#gettaskinfo9).
| Name| Type| Value| Description| | Name| Type| Value| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -54,7 +47,7 @@ The table below lists the error codes that may be returned by [on('fail')<sup>7+ ...@@ -54,7 +47,7 @@ The table below lists the error codes that may be returned by [on('fail')<sup>7+
### Causes of Download Pause ### Causes of Download Pause
The table below lists the causes of download pause that may be returned by [getTaskInfo<sup>9+</sup>](#gettaskinfo9). The table below lists the values of **pausedReason** returned by [getTaskInfo<sup>9+</sup>](#gettaskinfo9).
| Name| Type| Value| Description| | Name| Type| Value| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -65,7 +58,7 @@ The table below lists the causes of download pause that may be returned by [getT ...@@ -65,7 +58,7 @@ The table below lists the causes of download pause that may be returned by [getT
| PAUSED_UNKNOWN<sup>7+</sup> | number | 4 | Download paused due to unknown reasons.| | PAUSED_UNKNOWN<sup>7+</sup> | number | 4 | Download paused due to unknown reasons.|
### Download Task Status Codes ### Download Task Status Codes
The table below lists the download task status codes that may be returned by [getTaskInfo<sup>9+</sup>](#gettaskinfo9). The table below lists the values of **status** returned by [getTaskInfo<sup>9+</sup>](#gettaskinfo9).
| Name| Type| Value| Description| | Name| Type| Value| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -105,7 +98,7 @@ For details about the error codes, see [Upload and Download Error Codes](../erro ...@@ -105,7 +98,7 @@ For details about the error codes, see [Upload and Download Error Codes](../erro
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 13400002 | Bad file path. | | 13400002 | bad file path. |
**Example** **Example**
...@@ -153,7 +146,7 @@ For details about the error codes, see [Upload and Download Error Codes](../erro ...@@ -153,7 +146,7 @@ For details about the error codes, see [Upload and Download Error Codes](../erro
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 13400002 | Bad file path. | | 13400002 | bad file path. |
**Example** **Example**
...@@ -279,7 +272,7 @@ Implements file uploads. Before using any APIs of this class, you must obtain an ...@@ -279,7 +272,7 @@ Implements file uploads. Before using any APIs of this class, you must obtain an
on(type: 'progress', callback:(uploadedSize: number, totalSize: number) =&gt; void): void on(type: 'progress', callback:(uploadedSize: number, totalSize: number) =&gt; void): void
Subscribes to an upload event. This API uses an asynchronous callback to return the result. Subscribes to upload progress events. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -296,16 +289,16 @@ Subscribes to an upload event. This API uses an asynchronous callback to return ...@@ -296,16 +289,16 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| uploadedSize | number | Yes| Size of the uploaded files, in bits. | | uploadedSize | number | Yes| Size of the uploaded files, in bits.|
| totalSize | number | Yes| Total size of the files to upload, in bits. | | totalSize | number | Yes| Total size of the files to upload, in bits.|
**Example** **Example**
```js ```js
uploadTask.on('progress', function callback(uploadedSize, totalSize) { let upProgressCallback = (uploadedSize, totalSize) => {
console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize); console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize);
} };
); uploadTask.on('progress', upProgressCallback);
``` ```
...@@ -313,7 +306,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return ...@@ -313,7 +306,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
on(type: 'headerReceive', callback: (header: object) =&gt; void): void on(type: 'headerReceive', callback: (header: object) =&gt; void): void
Subscribes to an upload event. This API uses an asynchronous callback to return the result. Subscribes to HTTP header events for an upload task. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -335,10 +328,10 @@ Subscribes to an upload event. This API uses an asynchronous callback to return ...@@ -335,10 +328,10 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
**Example** **Example**
```js ```js
uploadTask.on('headerReceive', function callback(headers){ let headerCallback = (headers) => {
console.info("upOnHeader headers:" + JSON.stringify(headers)); console.info("upOnHeader headers:" + JSON.stringify(headers));
} };
); uploadTask.on('headerReceive', headerCallback);
``` ```
...@@ -346,7 +339,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return ...@@ -346,7 +339,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
on(type:'complete' | 'fail', callback: Callback&lt;Array&lt;TaskState&gt;&gt;): void; on(type:'complete' | 'fail', callback: Callback&lt;Array&lt;TaskState&gt;&gt;): void;
Subscribes to an upload event. This API uses an asynchronous callback to return the result. Subscribes to upload completion or failure events. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -368,19 +361,19 @@ Subscribes to an upload event. This API uses an asynchronous callback to return ...@@ -368,19 +361,19 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
**Example** **Example**
```js ```js
uploadTask.on('complete', function callback(taskStates) { let upCompleteCallback = (taskStates) => {
for (let i = 0; i < taskStates.length; i++ ) { for (let i = 0; i < taskStates.length; i++ ) {
console.info("upOnComplete taskState:" + JSON.stringify(taskStates[i])); console.info("upOnComplete taskState:" + JSON.stringify(taskStates[i]));
} }
} };
); uploadTask.on('complete', upCompleteCallback);
uploadTask.on('fail', function callback(taskStates) { let upFailCallback = (taskStates) => {
for (let i = 0; i < taskStates.length; i++ ) { for (let i = 0; i < taskStates.length; i++ ) {
console.info("upOnFail taskState:" + JSON.stringify(taskStates[i])); console.info("upOnFail taskState:" + JSON.stringify(taskStates[i]));
} }
} };
); uploadTask.on('fail', upFailCallback);
``` ```
...@@ -388,7 +381,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return ...@@ -388,7 +381,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) =&gt; void): void off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) =&gt; void): void
Unsubscribes from an upload event. This API uses an asynchronous callback to return the result. Unsubscribes from upload progress events. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -399,22 +392,15 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret ...@@ -399,22 +392,15 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (upload progress).| | type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (upload progress).|
| callback | function | No| Callback for the upload progress event.| | callback | function | No| Callback used to return the result.<br>**uploadedSize**: size of the uploaded files, in bits.<br>**totalSize**: Total size of the files to upload, in bits. |
Parameters of the callback function
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| uploadedSize | number | Yes| Size of the uploaded files, in bits. |
| totalSize | number | Yes| Total size of the files to upload, in bits. |
**Example** **Example**
```js ```js
uploadTask.off('progress', function callback(uploadedSize, totalSize) { let upProgressCallback = (uploadedSize, totalSize) => {
console.info('uploadedSize: ' + uploadedSize, 'totalSize: ' + totalSize); console.info('Upload delete progress notification.' + 'totalSize:' + totalSize + 'uploadedSize:' + uploadedSize);
} };
); uploadTask.off('progress', upProgressCallback);
``` ```
...@@ -422,7 +408,7 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret ...@@ -422,7 +408,7 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret
off(type: 'headerReceive', callback?: (header: object) =&gt; void): void off(type: 'headerReceive', callback?: (header: object) =&gt; void): void
Unsubscribes from an upload event. This API uses an asynchronous callback to return the result. Unsubscribes from HTTP header events for an upload task. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -433,28 +419,22 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret ...@@ -433,28 +419,22 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to unsubscribe from. The value is **'headerReceive'** (response header).| | type | string | Yes| Type of the event to unsubscribe from. The value is **'headerReceive'** (response header).|
| callback | function | No| Callback for the HTTP Response Header event.| | callback | function | No| Callback used to return the result.<br>**header**: HTTP response header.|
Parameters of the callback function
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| header | object | Yes| HTTP Response Header.|
**Example** **Example**
```js ```js
uploadTask.off('headerReceive', function callback(headers) { let headerCallback = (header) => {
console.info("upOnHeader headers:" + JSON.stringify(headers)); console.info(`Upload delete headerReceive notification. header: ${JSON.stringify(header)}`);
} };
); uploadTask.off('headerReceive', headerCallback);
``` ```
### off('complete' | 'fail')<sup>9+</sup> ### off('complete' | 'fail')<sup>9+</sup>
off(type:'complete' | 'fail', callback?: Callback&lt;Array&lt;TaskState&gt;&gt;): void; off(type:'complete' | 'fail', callback?: Callback&lt;Array&lt;TaskState&gt;&gt;): void;
Unsubscribes from an upload event. This API uses an asynchronous callback to return the result. Unsubscribes from upload completion or failure events. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -465,30 +445,26 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret ...@@ -465,30 +445,26 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.| | type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.|
| callback | Callback&lt;Array&lt;TaskState&gt;&gt; | No| Callback used to return the result.| | callback | Callback&lt;Array&lt;TaskState&gt;&gt; | No| Callback used to return the result.<br>**taskstates**: upload task result.|
Parameters of the callback function
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| taskstates | Array&lt;[TaskState](#taskstate9)&gt; | Yes| Upload result.|
**Example** **Example**
```js ```js
uploadTask.off('complete', function callback(taskStates) { let upCompleteCallback = (taskStates) => {
console.info('Upload delete complete notification.');
for (let i = 0; i < taskStates.length; i++ ) { for (let i = 0; i < taskStates.length; i++ ) {
console.info("upOnComplete taskState:" + JSON.stringify(taskStates[i])); console.info('taskState:' + JSON.stringify(taskStates[i]));
} }
} };
); uploadTask.off('complete', upCompleteCallback);
uploadTask.off('fail', function callback(taskStates) { let upFailCallback = (taskStates) => {
console.info('Upload delete fail notification.');
for (let i = 0; i < taskStates.length; i++ ) { for (let i = 0; i < taskStates.length; i++ ) {
console.info("upOnFail taskState:" + JSON.stringify(taskStates[i])); console.info('taskState:' + JSON.stringify(taskStates[i]));
} }
} };
); uploadTask.off('fail', upFailCallback);
``` ```
### delete<sup>9+</sup> ### delete<sup>9+</sup>
...@@ -709,9 +685,9 @@ For details about the error codes, see [Upload and Download Error Codes](../erro ...@@ -709,9 +685,9 @@ For details about the error codes, see [Upload and Download Error Codes](../erro
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 13400001 | File operation error. | | 13400001 | file operation error. |
| 13400002 | Bad file path. | | 13400002 | bad file path. |
| 13400003 | Task manager service error. | | 13400003 | task manager service error. |
**Example** **Example**
...@@ -753,9 +729,9 @@ For details about the error codes, see [Upload and Download Error Codes](../erro ...@@ -753,9 +729,9 @@ For details about the error codes, see [Upload and Download Error Codes](../erro
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 13400001 | File operation error. | | 13400001 | file operation error. |
| 13400002 | Bad file path. | | 13400002 | bad file path. |
| 13400003 | Task manager service error. | | 13400003 | task manager service error. |
**Example** **Example**
...@@ -861,7 +837,7 @@ Implements file downloads. ...@@ -861,7 +837,7 @@ Implements file downloads.
on(type: 'progress', callback:(receivedSize: number, totalSize: number) =&gt; void): void on(type: 'progress', callback:(receivedSize: number, totalSize: number) =&gt; void): void
Subscribes to a download event. This API uses an asynchronous callback to return the result. Subscribes to download progress events. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -872,22 +848,22 @@ Subscribes to a download event. This API uses an asynchronous callback to return ...@@ -872,22 +848,22 @@ Subscribes to a download event. This API uses an asynchronous callback to return
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (download progress).| | type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (download progress).|
| callback | function | Yes| Callback for the download progress event.| | callback | function | Yes| Callback used to return the result.|
Parameters of the callback function Parameters of the callback function
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| receivedSize | number | Yes| Size of the downloaded files, in bits.| | receivedSize | number | Yes| Size of the downloaded files, in bits. |
| totalSize | number | Yes| Total size of the files to download, in bits.| | totalSize | number | Yes| Total size of the files to download, in bits. |
**Example** **Example**
```js ```js
downloadTask.on('progress', function download_callback(receivedSize, totalSize) { let progresCallback = (receivedSize, totalSize) => {
console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize); console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize);
} };
); downloadTask.on('progress', progresCallback);
``` ```
...@@ -895,7 +871,7 @@ Subscribes to a download event. This API uses an asynchronous callback to return ...@@ -895,7 +871,7 @@ Subscribes to a download event. This API uses an asynchronous callback to return
off(type: 'progress', callback?: (receivedSize: number, totalSize: number) =&gt; void): void off(type: 'progress', callback?: (receivedSize: number, totalSize: number) =&gt; void): void
Unsubscribes from a download event. This API uses an asynchronous callback to return the result. Unsubscribes from download progress events. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -906,22 +882,15 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re ...@@ -906,22 +882,15 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (download progress).| | type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (download progress).|
| callback | function | No| Callback for the download progress event.| | callback | function | No| Callback used to return the result.<br>**receivedSize**: size of the downloaded files.<br>**totalSize**: total size of the files to download.|
Parameters of the callback function
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| receivedSize | number | Yes| Size of the downloaded files, in bits.|
| totalSize | number | Yes| Total size of the files to download, in bits.|
**Example** **Example**
```js ```js
downloadTask .off('progress', function download_callback(receivedSize, totalSize) { let progresCallback = (receivedSize, totalSize) => {
console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize); console.info('Download delete progress notification.' + 'receivedSize:' + receivedSize + 'totalSize:' + totalSize);
} };
); downloadTask.off('progress', progresCallback);
``` ```
...@@ -929,7 +898,7 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re ...@@ -929,7 +898,7 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re
on(type: 'complete'|'pause'|'remove', callback:() =&gt; void): void on(type: 'complete'|'pause'|'remove', callback:() =&gt; void): void
Subscribes to a download event. This API uses an asynchronous callback to return the result. Subscribes to download events. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -945,10 +914,20 @@ Subscribes to a download event. This API uses an asynchronous callback to return ...@@ -945,10 +914,20 @@ Subscribes to a download event. This API uses an asynchronous callback to return
**Example** **Example**
```js ```js
downloadTask.on('complete', function callback() { let completeCallback = () => {
console.info('Download task completed.'); console.info('Download task completed.');
} };
); downloadTask.on('complete', completeCallback);
let pauseCallback = () => {
console.info('Download task pause.');
};
downloadTask.on('pause', pauseCallback);
let removeCallback = () => {
console.info('Download task remove.');
};
downloadTask.on('remove', removeCallback);
``` ```
...@@ -956,7 +935,7 @@ Subscribes to a download event. This API uses an asynchronous callback to return ...@@ -956,7 +935,7 @@ Subscribes to a download event. This API uses an asynchronous callback to return
off(type: 'complete'|'pause'|'remove', callback?:() =&gt; void): void off(type: 'complete'|'pause'|'remove', callback?:() =&gt; void): void
Unsubscribes from a download event. This API uses an asynchronous callback to return the result. Unsubscribes from download events. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -972,10 +951,20 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re ...@@ -972,10 +951,20 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re
**Example** **Example**
```js ```js
downloadTask.off('complete', function callback() { let completeCallback = () => {
console.info('Download task completed.'); console.info('Download delete complete notification.');
} };
); downloadTask.off('complete', completeCallback);
let pauseCallback = () => {
console.info('Download delete pause notification.');
};
downloadTask.off('pause', pauseCallback);
let removeCallback = () => {
console.info('Download delete remove notification.');
};
downloadTask.off('remove', removeCallback);
``` ```
...@@ -983,7 +972,7 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re ...@@ -983,7 +972,7 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re
on(type: 'fail', callback: (err: number) =&gt; void): void on(type: 'fail', callback: (err: number) =&gt; void): void
Subscribes to the download task failure event. This API uses an asynchronous callback to return the result. Subscribes to download failure events. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -1004,11 +993,11 @@ Subscribes to the download task failure event. This API uses an asynchronous cal ...@@ -1004,11 +993,11 @@ Subscribes to the download task failure event. This API uses an asynchronous cal
**Example** **Example**
```js ```js
downloadTask.on('fail', function callBack(err) { let failCallback = (err) => {
console.info('Download task failed. Cause:' + err); console.info('Download task failed. Cause:' + err);
} };
); downloadTask.on('fail', failCallback);
``` ```
...@@ -1016,7 +1005,7 @@ Subscribes to the download task failure event. This API uses an asynchronous cal ...@@ -1016,7 +1005,7 @@ Subscribes to the download task failure event. This API uses an asynchronous cal
off(type: 'fail', callback?: (err: number) =&gt; void): void off(type: 'fail', callback?: (err: number) =&gt; void): void
Unsubscribes from the download task failure event. This API uses an asynchronous callback to return the result. Unsubscribes from download failure events. This API uses a callback to return the result synchronously.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -1027,21 +1016,15 @@ Unsubscribes from the download task failure event. This API uses an asynchronous ...@@ -1027,21 +1016,15 @@ Unsubscribes from the download task failure event. This API uses an asynchronous
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to unsubscribe from. The value is **'fail'** (download failure).| | type | string | Yes| Type of the event to unsubscribe from. The value is **'fail'** (download failure).|
| callback | function | No| Callback for the download task failure event.| | callback | function | No| Callback used to return the result.<br>**err**: error code of the download failure. |
Parameters of the callback function
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| err | number | Yes| Error code of the download failure. For details about the error codes, see [Download Error Codes](#download-error-codes).|
**Example** **Example**
```js ```js
downloadTask.off('fail', function callBack(err) { let failCallback = (err) => {
console.info('Download task failed. Cause:' + err); console.info(`Download delete fail notification. err: ${err.message}`);
} };
); downloadTask.off('fail', failCallback);
``` ```
### delete<sup>9+</sup> ### delete<sup>9+</sup>
...@@ -1706,32 +1689,33 @@ Defines the download task configuration. ...@@ -1706,32 +1689,33 @@ Defines the download task configuration.
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| url | string | Yes| Resource URL.| | url | string | Yes| Resource URL.|
| header | Object | No| HTTPS flag header to be included in the download request.<br>The **X-TLS-Version** parameter in **header** specifies the TLS version to be used. If this parameter is not set, the CURL_SSLVERSION_TLSv1_2 version is used. Available options are as follows:<br>CURL_SSLVERSION_TLSv1_0<br>CURL_SSLVERSION_TLSv1_1<br>CURL_SSLVERSION_TLSv1_2<br>CURL_SSLVERSION_TLSv1_3<br>The **X-Cipher-List** parameter in **header** specifies the cipher suite list to be used. If this parameter is not specified, the secure cipher suite list is used. Available options are as follows:<br>- The TLS 1.2 cipher suite list includes the following ciphers:<br>TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,<br>TLS_DHE_DSS_WITH_AES_128_GCM_SHA256,TLS_DSS_RSA_WITH_AES_256_GCM_SHA384,<br>TLS_PSK_WITH_AES_256_GCM_SHA384,TLS_DHE_PSK_WITH_AES_128_GCM_SHA256,<br>TLS_DHE_PSK_WITH_AES_256_GCM_SHA384,TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256,<br>TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,<br>TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,<br>TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256,<br>TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384,<br>TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_128_CCM,<br>TLS_DHE_RSA_WITH_AES_256_CCM,TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256,<br>TLS_PSK_WITH_AES_256_CCM,TLS_DHE_PSK_WITH_AES_128_CCM,<br>TLS_DHE_PSK_WITH_AES_256_CCM,TLS_ECDHE_ECDSA_WITH_AES_128_CCM,<br>TLS_ECDHE_ECDSA_WITH_AES_256_CCM,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256<br>- The TLS 1.3 cipher suite list includes the following ciphers:<br>TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256,TLS_AES_128_CCM_SHA256<br>- The TLS 1.3 cipher suite list adds the Chinese national cryptographic algorithm:<br>TLS_SM4_GCM_SM3,TLS_SM4_CCM_SM3 | | header | Object | No| HTTPS flag header to be included in the download request.<br>The **X-TLS-Version** parameter in **header** specifies the TLS version to be used. If this parameter is not set, the CURL_SSLVERSION_TLSv1_2 version is used. Available options are as follows:<br>CURL_SSLVERSION_TLSv1_0<br>CURL_SSLVERSION_TLSv1_1<br>CURL_SSLVERSION_TLSv1_2<br>CURL_SSLVERSION_TLSv1_3<br>The **X-Cipher-List** parameter in **header** specifies the cipher suite list to be used. If this parameter is not specified, the secure cipher suite list is used. Available options are as follows:<br>- The TLS 1.2 cipher suite list includes the following ciphers:<br>TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,<br>TLS_DHE_DSS_WITH_AES_128_GCM_SHA256,TLS_DSS_RSA_WITH_AES_256_GCM_SHA384,<br>TLS_PSK_WITH_AES_256_GCM_SHA384,TLS_DHE_PSK_WITH_AES_128_GCM_SHA256,<br>TLS_DHE_PSK_WITH_AES_256_GCM_SHA384,TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256,<br>TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,<br>TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,<br>TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256,<br>TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384,<br>TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_128_CCM,<br>TLS_DHE_RSA_WITH_AES_256_CCM,TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256,<br>TLS_PSK_WITH_AES_256_CCM,TLS_DHE_PSK_WITH_AES_128_CCM,<br>TLS_DHE_PSK_WITH_AES_256_CCM,TLS_ECDHE_ECDSA_WITH_AES_128_CCM,<br>TLS_ECDHE_ECDSA_WITH_AES_256_CCM,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256<br>- The TLS 1.3 cipher suite list includes the following ciphers:<br>TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256,TLS_AES_128_CCM_SHA256<br>- The TLS 1.3 cipher suite list adds the Chinese national cryptographic algorithm:<br>TLS_SM4_GCM_SM3,TLS_SM4_CCM_SM3 |
| enableMetered | boolean | No| Whether download is allowed on a metered connection.<br>- **true**: allowed<br>- **false**: not allowed| | enableMetered | boolean | No| Whether download is allowed on a metered connection. The default value is **false**. In general cases, a mobile data connection is metered, while a Wi-Fi connection is not.<br>- **true**: allowed<br>- **false**: not allowed|
| enableRoaming | boolean | No| Whether download is allowed on a roaming network.<br>- **true**: allowed<br>- **false**: not allowed| | enableRoaming | boolean | No| Whether download is allowed on a roaming network. The default value is **false**.<br>- **true**: allowed<br>- **false**: not allowed|
| description | string | No| Description of the download session.| | description | string | No| Description of the download session.|
| filePath<sup>7+</sup> | string | No| Path where the downloaded file is stored.<br>- filePath:'/data/storage/el2/base/haps/entry/files/test.txt': Save the file to an absolute path.<br>- In the FA model, use [context](js-apis-inner-app-context.md#contextgetcachedir) to obtain the cache directory of the application, for example, **\${featureAbility.getContext().getFilesDir()}/test.txt\**, and store the file in this directory.<br>- In the stage model, use [AbilityContext](js-apis-inner-application-context.md) to obtain the file path, for example, **\${globalThis.abilityContext.tempDir}/test.txt\**, and store the file in this path.| | filePath<sup>7+</sup> | string | No| Path where the downloaded file is stored.<br>- In the FA model, use [context](js-apis-inner-app-context.md#contextgetcachedir) to obtain the cache directory of the application, for example, **\${featureAbility.getContext().getFilesDir()}/test.txt\**, and store the file in this directory.<br>- In the stage model, use [AbilityContext](js-apis-inner-application-context.md) to obtain the file path, for example, **\${globalThis.abilityContext.tempDir}/test.txt\**, and store the file in this path.|
| networkType | number | No| Network type allowed for download.<br>- NETWORK_MOBILE: 0x00000001<br>- NETWORK_WIFI: 0x00010000| | networkType | number | No| Network type allowed for download. The default value is **NETWORK_MOBILE and NETWORK_WIFI**.<br>- NETWORK_MOBILE: 0x00000001<br>- NETWORK_WIFI: 0x00010000|
| title | string | No| Download task name.| | title | string | No| Download task name.|
| background<sup>9+</sup> | boolean | No| Whether to enable the background task notification. When this parameter is enabled, the download status is displayed in the notification panel.| | background<sup>9+</sup> | boolean | No| Whether to enable background task notification so that the download status is displayed in the notification panel. The default value is false.|
## DownloadInfo<sup>7+</sup> ## DownloadInfo<sup>7+</sup>
Defines the download task information, which is the callback parameter of the [query<sup>(deprecated)</sup>](#querydeprecated-1) API. Defines the download task information, which is the callback parameter of the [getTaskInfo<sup>9+</sup>](#gettaskinfo9) API.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
| Name| Type| Mandatory| Description| | Name| Type|Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | ------ |---------------- |
| downloadId | number | Yes| ID of the downloaded file.| | downloadId | number |Yes| ID of the download task.|
| failedReason | number | No| Cause of the download failure. The value can be any constant in [Download Error Codes](#download-error-codes).| | failedReason | number|Yes| Cause of the download failure. The value can be any constant in [Download Error Codes](#download-error-codes).|
| fileName | string | Yes| Name of the downloaded file.| | fileName | string |Yes| Name of the downloaded file.|
| filePath | string | Yes| URI of the saved file.| | filePath | string |Yes| URI of the saved file.|
| pausedReason | number | No| Cause of download pause. The value can be any constant in [Causes of Download Pause](#causes-of-download-pause).| | pausedReason | number |Yes| Cause of download pause. The value can be any constant in [Causes of Download Pause](#causes-of-download-pause).|
| status | number | Yes| Download task status code. The value can be any constant in [Download Task Status Codes](#download-task-status-codes).| | status | number |Yes| Download task status code. The value can be any constant in [Download Task Status Codes](#download-task-status-codes).|
| targetURI | string | Yes| URI of the downloaded file.| | targetURI | string |Yes| URI of the downloaded file.|
| downloadTitle | string | Yes| Download task name.| | downloadTitle | string |Yes| Name of the download task.|
| downloadTotalBytes | number | Yes| Total size of the files to download, in bytes.| | downloadTotalBytes | number |Yes| Total size of the files to download, in bytes.|
| description | string | Yes| Description of the file to download.| | description | string |Yes| Description of the download task.|
| downloadedBytes | number | Yes| Size of the files downloaded, in bytes.| | downloadedBytes | number |Yes| Size of the files downloaded, in bytes.|
<!--no_check-->
...@@ -89,7 +89,7 @@ Subscribes to data changes of the compass sensor. If this API is called multiple ...@@ -89,7 +89,7 @@ Subscribes to data changes of the compass sensor. If this API is called multiple
```js ```js
sensor.subscribeCompass({ sensor.subscribeCompass({
success: function(ret) { success: function(ret) {
console.log('get data direction:' + ret.direction); console.log('Get data direction:' + ret.direction);
}, },
fail: function(data, code) { fail: function(data, code) {
console.error('Subscription failed. Code: ' + code + '; Data: ' + data); console.error('Subscription failed. Code: ' + code + '; Data: ' + data);
...@@ -133,7 +133,7 @@ Subscribes to data changes of the proximity sensor. If this API is called multip ...@@ -133,7 +133,7 @@ Subscribes to data changes of the proximity sensor. If this API is called multip
```js ```js
sensor.subscribeProximity({ sensor.subscribeProximity({
success: function(ret) { success: function(ret) {
console.log('get data distance:' + ret.distance); console.log('Get data distance:' + ret.distance);
}, },
fail: function(data, code) { fail: function(data, code) {
console.error('Subscription failed. Code: ' + code + '; Data: ' + data); console.error('Subscription failed. Code: ' + code + '; Data: ' + data);
...@@ -177,7 +177,7 @@ Subscribes to data changes of the ambient light sensor. If this API is called mu ...@@ -177,7 +177,7 @@ Subscribes to data changes of the ambient light sensor. If this API is called mu
```js ```js
sensor.subscribeLight({ sensor.subscribeLight({
success: function(ret) { success: function(ret) {
console.log('get data intensity:' + ret.intensity); console.log('Get data intensity:' + ret.intensity);
}, },
fail: function(data, code) { fail: function(data, code) {
console.error('Subscription failed. Code: ' + code + '; Data: ' + data); console.error('Subscription failed. Code: ' + code + '; Data: ' + data);
...@@ -223,7 +223,7 @@ Subscribes to data changes of the step counter sensor. If this API is called mul ...@@ -223,7 +223,7 @@ Subscribes to data changes of the step counter sensor. If this API is called mul
```js ```js
sensor.subscribeStepCounter({ sensor.subscribeStepCounter({
success: function(ret) { success: function(ret) {
console.log('get step value:' + ret.steps); console.log('Get step value:' + ret.steps);
}, },
fail: function(data, code) { fail: function(data, code) {
console.log('Subscription failed. Code: ' + code + '; Data: ' + data); console.log('Subscription failed. Code: ' + code + '; Data: ' + data);
...@@ -270,7 +270,7 @@ Subscribes to data changes of the barometer sensor. If this API is called multip ...@@ -270,7 +270,7 @@ Subscribes to data changes of the barometer sensor. If this API is called multip
```js ```js
sensor.subscribeBarometer({ sensor.subscribeBarometer({
success: function(ret) { success: function(ret) {
console.log('get data value:' + ret.pressure); console.log('Get data value:' + ret.pressure);
}, },
fail: function(data, code) { fail: function(data, code) {
console.log('Subscription failed. Code: ' + code + '; Data: ' + data); console.log('Subscription failed. Code: ' + code + '; Data: ' + data);
...@@ -318,7 +318,7 @@ Subscribes to data changes of the heart rate sensor. If this API is called multi ...@@ -318,7 +318,7 @@ Subscribes to data changes of the heart rate sensor. If this API is called multi
```js ```js
sensor.subscribeHeartRate({ sensor.subscribeHeartRate({
success: function(ret) { success: function(ret) {
console.log('get heartrate value:' + ret.heartRate); console.log('Get heartrate value:' + ret.heartRate);
}, },
fail: function(data, code) { fail: function(data, code) {
console.log('Subscription failed. Code: ' + code + '; Data: ' + data); console.log('Subscription failed. Code: ' + code + '; Data: ' + data);
...@@ -365,7 +365,7 @@ Subscribes to changes of the wearing state of a wearable device. If this API is ...@@ -365,7 +365,7 @@ Subscribes to changes of the wearing state of a wearable device. If this API is
```js ```js
sensor.subscribeOnBodyState({ sensor.subscribeOnBodyState({
success: function(ret) { success: function(ret) {
console.log('get on-body state value:' + ret.value); console.log('Get on-body state value:' + ret.value);
}, },
fail: function(data, code) { fail: function(data, code) {
console.log('Subscription failed. Code: ' + code + '; Data: ' + data); console.log('Subscription failed. Code: ' + code + '; Data: ' + data);
...@@ -409,7 +409,7 @@ Obtains the wearing state of a wearable device. ...@@ -409,7 +409,7 @@ Obtains the wearing state of a wearable device.
```js ```js
sensor.getOnBodyState({ sensor.getOnBodyState({
success: function(ret) { success: function(ret) {
console.log('on body state: ' + ret.value); console.log('On body state: ' + ret.value);
}, },
fail: function(data, code) { fail: function(data, code) {
console.log('Subscription failed. Code: ' + code + '; Data: ' + data); console.log('Subscription failed. Code: ' + code + '; Data: ' + data);
...@@ -710,7 +710,7 @@ Defines the wearing state. ...@@ -710,7 +710,7 @@ Defines the wearing state.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------- | ---- | ------------------------ | | -------- | ------------------------------------------- | ---- | ------------------------ |
| success | [OnBodyStateResponse](#onbodystateresponse) | No | Callback upon a successful API call.| | success | [OnBodyStateResponse](#onbodystateresponse) | Yes | Callback upon a successful API call.|
| fail | Function | No | Callback upon an API call failure.| | fail | Function | No | Callback upon an API call failure.|
| complete | Function | No | Called when the API call is complete.| | complete | Function | No | Called when the API call is complete.|
......
...@@ -4,8 +4,8 @@ The **userFileManager** module provides user data management capabilities, inclu ...@@ -4,8 +4,8 @@ The **userFileManager** module provides user data management capabilities, inclu
> **NOTE** > **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 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 APIs provided by this module are system APIs.
## Modules to Import ## Modules to Import
...@@ -49,11 +49,8 @@ let mgr = userFileManager.getUserFileMgr(context); ...@@ -49,11 +49,8 @@ let mgr = userFileManager.getUserFileMgr(context);
getPhotoAssets(options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;FileAsset&gt;&gt;): void; getPhotoAssets(options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;FileAsset&gt;&gt;): void;
Obtains image and video assets. This API uses an asynchronous callback to return the result. Obtains image and video assets. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.UserFileManager.Core **System capability**: SystemCapability.FileManagement.UserFileManager.Core
**Required permissions**: ohos.permission.READ_IMAGEVIDEO **Required permissions**: ohos.permission.READ_IMAGEVIDEO
...@@ -92,7 +89,6 @@ async function example() { ...@@ -92,7 +89,6 @@ async function example() {
} }
``` ```
### getPhotoAssets ### getPhotoAssets
getPhotoAssets(options: FetchOptions): Promise&lt;FetchResult&lt;FileAsset&gt;&gt;; getPhotoAssets(options: FetchOptions): Promise&lt;FetchResult&lt;FileAsset&gt;&gt;;
...@@ -141,6 +137,7 @@ async function example() { ...@@ -141,6 +137,7 @@ async function example() {
} }
} }
``` ```
### createPhotoAsset ### createPhotoAsset
createPhotoAsset(displayName: string, albumUri: string, callback: AsyncCallback&lt;FileAsset&gt;): void; createPhotoAsset(displayName: string, albumUri: string, callback: AsyncCallback&lt;FileAsset&gt;): void;
...@@ -261,7 +258,6 @@ async function example() { ...@@ -261,7 +258,6 @@ async function example() {
getPhotoAlbums(options: AlbumFetchOptions, callback: AsyncCallback&lt;FetchResult&lt;Album&gt;&gt;): void; getPhotoAlbums(options: AlbumFetchOptions, callback: AsyncCallback&lt;FetchResult&lt;Album&gt;&gt;): void;
Obtains image and video albums. This API uses an asynchronous callback to return the result. Obtains image and video albums. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.UserFileManager.Core **System capability**: SystemCapability.FileManagement.UserFileManager.Core
...@@ -352,7 +348,6 @@ async function example() { ...@@ -352,7 +348,6 @@ async function example() {
getPrivateAlbum(type: PrivateAlbumType, callback: AsyncCallback&lt;FetchResult&lt;PrivateAlbum&gt;&gt;): void; getPrivateAlbum(type: PrivateAlbumType, callback: AsyncCallback&lt;FetchResult&lt;PrivateAlbum&gt;&gt;): void;
Obtains the system album. This API uses an asynchronous callback to return the result. Obtains the system album. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.UserFileManager.Core **System capability**: SystemCapability.FileManagement.UserFileManager.Core
...@@ -424,7 +419,6 @@ async function example() { ...@@ -424,7 +419,6 @@ async function example() {
getAudioAssets(options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;FileAsset&gt;&gt;): void; getAudioAssets(options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;FileAsset&gt;&gt;): void;
Obtains audio assets. This API uses an asynchronous callback to return the result. Obtains audio assets. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.UserFileManager.Core **System capability**: SystemCapability.FileManagement.UserFileManager.Core
...@@ -469,7 +463,6 @@ async function example() { ...@@ -469,7 +463,6 @@ async function example() {
getAudioAssets(options: FetchOptions): Promise&lt;FetchResult&lt;FileAsset&gt;&gt;; getAudioAssets(options: FetchOptions): Promise&lt;FetchResult&lt;FileAsset&gt;&gt;;
Obtains audio assets. This API uses a promise to return the result. Obtains audio assets. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.UserFileManager.Core **System capability**: SystemCapability.FileManagement.UserFileManager.Core
...@@ -515,6 +508,7 @@ async function example() { ...@@ -515,6 +508,7 @@ async function example() {
} }
} }
``` ```
### delete ### delete
delete(uri: string, callback: AsyncCallback&lt;void&gt;): void; delete(uri: string, callback: AsyncCallback&lt;void&gt;): void;
...@@ -564,6 +558,7 @@ async function example() { ...@@ -564,6 +558,7 @@ async function example() {
}); });
} }
``` ```
### delete ### delete
delete(uri: string): Promise&lt;void&gt;; delete(uri: string): Promise&lt;void&gt;;
...@@ -675,8 +670,8 @@ Unsubscribes from changes of the file management library. This API uses a callba ...@@ -675,8 +670,8 @@ Unsubscribes from changes of the file management library. This API uses a callba
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------------------------------------------ | | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| type | [ChangeEvent](#changeevent) | Yes | Type of event to unsubscribe from.<br>**deviceChange** indicates the device change.<br>**albumChange** indicates the album change.<br>**imageChange** indicates the image change.<br>**audioChange** indicates the audio file change.<br>**videoChange** indicates the video file change.<br>**remoteFileChange** indicates the file change on the registered device. | | type | [ChangeEvent](#changeevent) | Yes | Type of event to subscribe to.<br>**deviceChange** indicates the device change.<br>**albumChange** indicates the album change.<br>**imageChange** indicates the image change.<br>**audioChange** indicates the audio file change.<br>**videoChange** indicates the video file change.<br>**remoteFileChange** indicates the file change on the registered device.|
| callback | Callback&lt;void&gt; | No | Callback for the change. | | callback | Callback&lt;void&gt; | No | Callback that returns no value. |
**Example** **Example**
...@@ -1093,7 +1088,6 @@ Opens this file asset. This API uses an asynchronous callback to return the resu ...@@ -1093,7 +1088,6 @@ Opens this file asset. This API uses an asynchronous callback to return the resu
**Required permissions**: ohos.permission.READ_IMAGEVIDEO, ohos.permission.READ_AUDIO, ohos.permission.WRITE_IMAGEVIDEO, or ohos.permission.WRITE_AUDIO **Required permissions**: ohos.permission.READ_IMAGEVIDEO, ohos.permission.READ_AUDIO, ohos.permission.WRITE_IMAGEVIDEO, or ohos.permission.WRITE_AUDIO
**System capability**: SystemCapability.FileManagement.UserFileManager.Core **System capability**: SystemCapability.FileManagement.UserFileManager.Core
**Parameters** **Parameters**
...@@ -1923,6 +1917,7 @@ async function example() { ...@@ -1923,6 +1917,7 @@ async function example() {
}); });
} }
``` ```
### getPhotoAssets ### getPhotoAssets
getPhotoAssets(options: FetchOptions): Promise&lt;FetchResult&lt;FileAsset&gt;&gt;; getPhotoAssets(options: FetchOptions): Promise&lt;FetchResult&lt;FileAsset&gt;&gt;;
...@@ -2106,6 +2101,7 @@ async function example() { ...@@ -2106,6 +2101,7 @@ async function example() {
} }
``` ```
### getPhotoAssets ### getPhotoAssets
getPhotoAssets(options: FetchOptions): Promise&lt;FetchResult&lt;FileAsset&gt;&gt;; getPhotoAssets(options: FetchOptions): Promise&lt;FetchResult&lt;FileAsset&gt;&gt;;
...@@ -2147,6 +2143,7 @@ async function example() { ...@@ -2147,6 +2143,7 @@ async function example() {
console.info('fetchResult.count = ', count); console.info('fetchResult.count = ', count);
} }
``` ```
### delete ### delete
delete(uri: string, callback: AsyncCallback&lt;void&gt;): void; delete(uri: string, callback: AsyncCallback&lt;void&gt;): void;
...@@ -2190,6 +2187,7 @@ async function example() { ...@@ -2190,6 +2187,7 @@ async function example() {
}); });
} }
``` ```
### delete ### delete
delete(uri: string): Promise&lt;void&gt;; delete(uri: string): Promise&lt;void&gt;;
...@@ -2280,6 +2278,7 @@ async function example() { ...@@ -2280,6 +2278,7 @@ async function example() {
}); });
} }
``` ```
### recover ### recover
recover(uri: string): Promise&lt;void&gt;; recover(uri: string): Promise&lt;void&gt;;
...@@ -2366,7 +2365,6 @@ Defines information about a registered device. ...@@ -2366,7 +2365,6 @@ Defines information about a registered device.
| networkId | string | Yes | No | Network ID of the registered device.| | networkId | string | Yes | No | Network ID of the registered device.|
| isOnline | boolean | Yes | No | Whether the registered device is online. | | isOnline | boolean | Yes | No | Whether the registered device is online. |
## FileType ## FileType
Enumerates media file types. Enumerates media file types.
...@@ -2390,8 +2388,6 @@ Enumerates the system album types. ...@@ -2390,8 +2388,6 @@ Enumerates the system album types.
| TYPE_FAVORITE | 0 | Favorites.| | TYPE_FAVORITE | 0 | Favorites.|
| TYPE_TRASH | 1 | Recycle bin.| | TYPE_TRASH | 1 | Recycle bin.|
## AudioKey ## AudioKey
Defines the key information about an audio file. Defines the key information about an audio file.
...@@ -2445,7 +2441,6 @@ Defines the key album information. ...@@ -2445,7 +2441,6 @@ Defines the key album information.
| DATE_ADDED | date_added | Date when the file was added. The value is the number of seconds elapsed since the Epoch time. | | DATE_ADDED | date_added | Date when the file was added. The value is the number of seconds elapsed since the Epoch time. |
| DATE_MODIFIED | date_modified | Date when the file content (not the file name) was last modified. The value is the number of seconds elapsed since the Epoch time.| | DATE_MODIFIED | date_modified | Date when the file content (not the file name) was last modified. The value is the number of seconds elapsed since the Epoch time.|
## FetchOptions ## FetchOptions
Defines the options for fetching media files. Defines the options for fetching media files.
......
...@@ -39,7 +39,7 @@ In addition to the [universal events](ts-universal-events-click.md), the followi ...@@ -39,7 +39,7 @@ In addition to the [universal events](ts-universal-events-click.md), the followi
| Name | Description | | Name | Description |
| -------------------------------------------- | ------------------------------------------------------------ | | -------------------------------------------- | ------------------------------------------------------------ |
| onChange(callback: (value: boolean) => void) | Triggered when the selected status of the check box changes due to a manual operation.<br>- The value **true** means that the check box is selected.<br>- The value **false** means that the check box is not selected.<br>Since API version 9, this API is supported in ArkTS widgets.| | onChange(callback: (value: boolean) => void) | Triggered when the selected status of the check box changes.<br>- The value **true** means that the check box is selected.<br>- The value **false** means that the check box is not selected.<br>Since API version 9, this API is supported in ArkTS widgets. |
## Example ## Example
......
...@@ -39,7 +39,7 @@ In addition to the [universal events](ts-universal-events-click.md), the followi ...@@ -39,7 +39,7 @@ In addition to the [universal events](ts-universal-events-click.md), the followi
| Name| Description| | Name| Description|
| -------- | -------- | | -------- | -------- |
| onChange (callback: (event: [CheckboxGroupResult](#checkboxgroupresult)) => void ) |Triggered when the selected status of the check box group or any check box wherein changes due to a manual operation.<br>Since API version 9, this API is supported in ArkTS widgets.| | onChange (callback: (event: [CheckboxGroupResult](#checkboxgroupresult)) => void ) |Triggered when the selected status of the check box group or any check box wherein changes.<br>Since API version 9, this API is supported in ArkTS widgets.|
## CheckboxGroupResult ## CheckboxGroupResult
......
...@@ -139,7 +139,7 @@ Scrolls to the item with the specified index. ...@@ -139,7 +139,7 @@ Scrolls to the item with the specified index.
> **NOTE** > **NOTE**
> >
> Only the **\<Grid>** and **\<List>** components are supported. > Only the **\<Grid>**, **\<List>**, and **\<WaterFlow>** components are supported.
**Parameters** **Parameters**
......
...@@ -11,29 +11,29 @@ Bind different types of gesture events to components and set response methods fo ...@@ -11,29 +11,29 @@ Bind different types of gesture events to components and set response methods fo
Use the following attributes to bind gesture recognition to a component. When a gesture is recognized, the event callback is invoked to notify the component. Use the following attributes to bind gesture recognition to a component. When a gesture is recognized, the event callback is invoked to notify the component.
| Name | Type | Default Value | Description | | Name| Type| Default Value| Description|
| --------------- | ---------------------------------------- | --------------------------------------- | ---------------------------------------- | | -------- | -------- | -------- | -------- |
| gesture | gesture: [GestureType](#gesturetype),<br>mask?: [GestureMask](#gesturemask) | gesture: -,<br>mask: GestureMask.Normal | Gesture to bind.<br>- **gesture**: type of the gesture to bind.<br>- **mask**: event response setting. | | gesture | gesture: [GestureType](#gesturetype),<br>mask?: [GestureMask](#gesturemask) | gesture: -,<br>mask: GestureMask.Normal | Gesture to bind.<br>- **gesture**: type of the gesture to bind.<br>- **mask**: mask for gesture events.|
| priorityGesture | gesture: [GestureType](#gesturetype),<br>mask?: [GestureMask](#gesturemask) | gesture: -,<br>mask: GestureMask.Normal | Gesture to preferentially recognize.<br>- **gesture**: type of the gesture to bind.<br>- **mask**: event response setting.<br>By default, a component recognizes gestures bound through **gesture**. When **priorityGesture** is configured for its parent component, the component preferentially recognizes gestures bound through **priorityGesture**. | | priorityGesture | gesture: [GestureType](#gesturetype),<br>mask?: [GestureMask](#gesturemask) | gesture: -,<br>mask: GestureMask.Normal | Gesture to preferentially recognize.<br>- **gesture**: type of the gesture to bind.<br>- **mask**: mask for gesture events.<br>1. By default, the child component preferentially recognizes the gesture specified by **gesture**, and the parent component preferentially recognizes the gesture specified by **priorityGesture** (if set).<br>2. With regard to long press gestures, the component with the shortest minimum hold-down time responds first, ignoring the **priorityGesture** settings.|
| parallelGesture | gesture: [GestureType](#gesturetype),<br>mask?: [GestureMask](#gesturemask) | gesture: -,<br>mask: GestureMask.Normal | Gesture that can be triggered together with the child component gesture.<br>- **gesture**: type of the gesture to bind. <br>- **mask**: event response setting.<br>The gesture event is not a bubbling event. When **parallelGesture** is set for the parent component, gesture events that are the same for the parent and child components can be triggered, thereby implementing a bubbling effect. If both the single-tap gesture event and the double-tap gesture event are bound to the parent and child components, only the single-tap gesture event is responded. | | parallelGesture | gesture: [GestureType](#gesturetype),<br>mask?: [GestureMask](#gesturemask) | gesture: -,<br>mask: GestureMask.Normal | Gesture that can be triggered together with the child component gesture.<br>- **gesture**: type of the gesture to bind. <br>- **mask**: mask for gesture events.<br>The gesture event is not a bubbling event. When **parallelGesture** is set for the parent component, gesture events that are the same for the parent and child components can be triggered, thereby implementing a bubbling effect. If both the single-tap gesture event and the double-tap gesture event are bound to the parent and child components, only the single-tap gesture event is responded.|
## GestureType ## GestureType
| Name | Description | | Name| Description|
| ---------------------------------------- | ---------------------------------------- | | -------- | -------- |
| [TapGesture](ts-basic-gestures-tapgesture.md) | Tap gesture, which can be a single-tap or multi-tap gesture. | | [TapGesture](ts-basic-gestures-tapgesture.md) | Tap gesture, which can be a single-tap or multi-tap gesture.|
| [LongPressGesture](ts-basic-gestures-longpressgesture.md) | Long press gesture. | | [LongPressGesture](ts-basic-gestures-longpressgesture.md) | Long press gesture.|
| [PanGesture](ts-basic-gestures-pangesture.md) | Pan gesture, which requires a minimum 5 vp movement distance of a finger on the screen. | | [PanGesture](ts-basic-gestures-pangesture.md) | Pan gesture, which requires a minimum 5 vp movement distance of a finger on the screen.|
| [PinchGesture](ts-basic-gestures-pinchgesture.md) | Pinch gesture. | | [PinchGesture](ts-basic-gestures-pinchgesture.md) | Pinch gesture.|
| [RotationGesture](ts-basic-gestures-rotationgesture.md) | Rotation gesture. | | [RotationGesture](ts-basic-gestures-rotationgesture.md) | Rotation gesture.|
| [SwipeGesture](ts-basic-gestures-swipegesture.md) | Swipe gesture, which can be recognized when the swipe speed is 100 vp/s or higher. | | [SwipeGesture](ts-basic-gestures-swipegesture.md) | Swipe gesture, which can be recognized when the swipe speed is 100 vp/s or higher.|
| [GestureGroup](ts-combined-gestures.md) | A group of gestures. Continuous recognition, parallel recognition, and exclusive recognition are supported. | | [GestureGroup](ts-combined-gestures.md) | A group of gestures. Continuous recognition, parallel recognition, and exclusive recognition are supported.|
## GestureMask ## GestureMask
| Name | Description | | Name| Description|
| -------------- | ---------------------------------------- | | -------- | -------- |
| Normal | The gestures of child components are not ignored and are recognized based on the default gesture recognition sequence. | | Normal | The gestures of child components are not ignored and are recognized based on the default gesture recognition sequence.|
| IgnoreInternal | The gestures of child components are ignored, including the built-in gestures. For example, if the child component is **\<List>**, its built-in swipe gesture is also ignored.| | IgnoreInternal | The gestures of child components are ignored, including the built-in gestures. For example, if the child component is **\<List>**, its built-in swipe gesture is also ignored.|
## Gesture Response Event ## Gesture Response Event
...@@ -42,52 +42,52 @@ The component binds gesture objects of different **GestureType**s through gestur ...@@ -42,52 +42,52 @@ The component binds gesture objects of different **GestureType**s through gestur
**TapGesture** **TapGesture**
| Name | Description | | Name| Description|
| ---------------------------------------- | ---------------------------------------- | | -------- | -------- |
| onAction((event?:GestureEvent) =&gt; void) | Callback invoked when a tap gesture is recognized. | | onAction((event?:GestureEvent) =&gt; void) | Callback invoked when a tap gesture is recognized.|
## GestureEvent ## GestureEvent
| Name | Type | Description | | Name| Type| Description|
| ----------------------- | ---------------------------------------- | ---------------------------------------- | | -------- | -------- | -------- |
| repeat | boolean | Whether the event is triggered repeatedly. This attribute is used for the **LongPressGesture** event. | | repeat | boolean | Whether the event is triggered repeatedly. This attribute is used for the **LongPressGesture** event.|
| offsetX | number | Offset of the gesture event on the x-axis, in vp. This attribute is used for the **PanGesture** event. A positive value means to pan from left to right, and a negative value means the opposite. | | offsetX | number | Offset of the gesture event on the x-axis, in vp. This attribute is used for the **PanGesture** event. A positive value means to pan from left to right, and a negative value means the opposite.|
| offsetY | number | Offset of the gesture event on the y-axis, in vp. This attribute is used for the **PanGesture** event. A positive value means to pan from top to bottom, and a negative value means the opposite. | | offsetY | number | Offset of the gesture event on the y-axis, in vp. This attribute is used for the **PanGesture** event. A positive value means to pan from top to bottom, and a negative value means the opposite.|
| angle | number | Rotation angle for the **RotationGesture** event;<br>angle of the swipe gesture for the **SwipeGesture** event, that is, the change in the included angle between the line segment created by the two fingers and the horizontal direction.<br>**NOTE**<br>Angle calculation method: After a swipe gesture is recognized, a line connecting the two fingers is identified as the initial line. As the fingers swipe, the line between the fingers rotates. Based on the coordinates of the initial line's and current line's end points, an arc tangent function is used to calculate the respective included angle of the points relative to the horizontal direction by using the following formula: Rotation angle = arctan2(cy2-cy1,cx2-cx1) – arctan2(y2-y1,x2-x1) The initial line is used as the coordinate system. The clockwise rotation is 0 to 180 degrees, and the counter-clockwise rotation is –180 to 0 degrees. | | angle | number | Rotation angle for the **RotationGesture** event;<br>angle of the swipe gesture for the **SwipeGesture** event, that is, the change in the included angle between the line segment created by the two fingers and the horizontal direction.<br>**NOTE**<br>Angle calculation method: After a swipe gesture is recognized, a line connecting the two fingers is identified as the initial line. As the fingers swipe, the line between the fingers rotates. Based on the coordinates of the initial line's and current line's end points, an arc tangent function is used to calculate the respective included angle of the points relative to the horizontal direction by using the following formula: Rotation angle = arctan2(cy2-cy1,cx2-cx1) – arctan2(y2-y1,x2-x1) The initial line is used as the coordinate system. The clockwise rotation is 0 to 180 degrees, and the counter-clockwise rotation is –180 to 0 degrees.|
| scale | number | Scale ratio. This attribute is used for the **PinchGesture** event. | | scale | number | Scale ratio. This attribute is used for the **PinchGesture** event.|
| pinchCenterX | number | X-coordinate of the center of the pinch gesture, in px relative to the upper left corner of the current component. This attribute is used for the **PinchGesture** event. | | pinchCenterX | number | X-coordinate of the center of the pinch gesture, in vp, relative to the upper left corner of the current component. This attribute is used for the **PinchGesture** event.|
| pinchCenterY | number | Y-coordinate of the center of the pinch gesture, in px relative to the upper left corner of the current component. This attribute is used for the **PinchGesture** event. | | pinchCenterY | number | Y-coordinate of the center of the pinch gesture, in vp, relative to the upper left corner of the current component. This attribute is used for the **PinchGesture** event.|
| speed<sup>8+</sup> | number | Swipe gesture speed, that is, the average swipe speed of all fingers. The unit is vp/s. This attribute is used for the **SwipeGesture** event. | | speed<sup>8+</sup> | number | Swipe gesture speed, that is, the average swipe speed of all fingers. The unit is vp/s. This attribute is used for the **SwipeGesture** event.|
| fingerList<sup>8+</sup> | [FingerInfo](#fingerinfo)[] | Information about all fingers that trigger the event, which is used for the **LongPressGesture** and **TapGesture** events. | | fingerList<sup>8+</sup> | [FingerInfo](#fingerinfo)[] | Information about all fingers that trigger the event. This attribute is used for the **LongPressGesture** and **TapGesture** events.|
| timestamp<sup>8+</sup> | number | Timestamp of the event. | | timestamp<sup>8+</sup> | number | Timestamp of the event.|
| target<sup>8+</sup> | [EventTarget](ts-universal-events-click.md#eventtarget8) | Display area of the element that triggers the gesture event. | | target<sup>8+</sup> | [EventTarget](ts-universal-events-click.md#eventtarget8) | Display area of the element that triggers the gesture event.|
| source<sup>8+</sup> | [SourceType](#sourcetype) | Event input device. | | source<sup>8+</sup> | [SourceType](#sourcetype) | Event input device.|
| pressure<sup>9+</sup> | number | Press pressure. | | pressure<sup>9+</sup> | number | Press pressure.|
| tiltX<sup>9+</sup> | number | Angle between the projection of the stylus on the device plane and the x-axis. | | tiltX<sup>9+</sup> | number | Angle between the projection of the stylus on the device plane and the x-axis.|
| tiltY<sup>9+</sup> | number | Angle between the projection of the stylus on the device plane and the y-axis. | | tiltY<sup>9+</sup> | number | Angle between the projection of the stylus on the device plane and the y-axis.|
| sourceTool<sup>9+</sup> | [SourceTool](#sourcetool) | Event input source. | | sourceTool<sup>9+</sup> | [SourceTool](#sourcetool) | Event input source.|
## SourceType ## SourceType
| Name | Description | | Name| Description|
| ----------- | -------------------- | | -------- | -------- |
| Unknown | Unknown device type. | | Unknown | Unknown device type.|
| Mouse | Mouse. | | Mouse | Mouse.|
| TouchScreen | Touchscreen. | | TouchScreen | Touchscreen.|
## FingerInfo ## FingerInfo
| Name | Type | Description | | Name| Type| Description|
| ------- | ------ | ---------------------------------------- | | -------- | -------- | -------- |
| id | number | Index of a finger. | | id | number | Index of a finger.|
| globalX | number | X-coordinate relative to the upper left corner of the application window. | | globalX | number | X-coordinate relative to the upper left corner of the application window.|
| globalY | number | Y-coordinate relative to the upper left corner of the application window. | | globalY | number | Y-coordinate relative to the upper left corner of the application window.|
| localX | number | X-coordinate relative to the upper left corner of the current component. | | localX | number | X-coordinate relative to the upper left corner of the current component.|
| localY | number | Y-coordinate relative to the upper left corner of the current component. | | localY | number | Y-coordinate relative to the upper left corner of the current component.|
## SourceTool ## SourceTool
| Name | Description | | Name| Description|
| ------- | --------------------- | | -------- | -------- |
| Unknown | Unknown input source. | | Unknown | Unknown input source.|
| Finger | Finger input. | | Finger | Finger input.|
| Pen | Stylus input. | | Pen | Stylus input.|
## Example ## Example
......
...@@ -4,9 +4,14 @@ ...@@ -4,9 +4,14 @@
> >
> This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md). > This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md).
The error codes of the file management subsystem consist of the following:<br>- Basic file I/O error codes<br>- User data management error codes<br>- User file access error codes<br>- Spatial statistics error codes The error codes of the file management subsystem include the following:
## Basic File I/O Error Codes - [Basic File IO Error Codes](#basic-file-io-error-codes)
- [User Data Management Error Codes](#user-data-management-error-code)
- [User File Access Error Codes](#user-file-access-error-codes)
- [Space Statistics Error Codes](#space-statistics-error-codes)
## Basic File IO Error Codes
### 13900001 Operation Not Permitted ### 13900001 Operation Not Permitted
...@@ -49,6 +54,7 @@ The process does not exist. ...@@ -49,6 +54,7 @@ The process does not exist.
**Solution** **Solution**
1. Check whether the process is killed unexpectedly. 1. Check whether the process is killed unexpectedly.
2. Check whether the service related to the process has started. 2. Check whether the service related to the process has started.
### 13900004 System Call Interrupted ### 13900004 System Call Interrupted
...@@ -64,6 +70,7 @@ The system call is interrupted by another thread. ...@@ -64,6 +70,7 @@ The system call is interrupted by another thread.
**Solution** **Solution**
1. Check the multi-thread code logic. 1. Check the multi-thread code logic.
2. Invoke the system call again. 2. Invoke the system call again.
### 13900005 I/O Error ### 13900005 I/O Error
...@@ -161,7 +168,9 @@ Out of memory ...@@ -161,7 +168,9 @@ Out of memory
A memory overflow occurs. A memory overflow occurs.
**Solution** **Solution**
1. Check the memory overhead. 1. Check the memory overhead.
2. Control the memory overhead. 2. Control the memory overhead.
### 13900012 Permission Denied ### 13900012 Permission Denied
...@@ -172,13 +181,14 @@ Permission denied ...@@ -172,13 +181,14 @@ Permission denied
**Possible Causes** **Possible Causes**
1. You do not have the permission to operate the file. 1. You do not have the permission to operate the file.
2. The file sandbox path is incorrect. 2. The file sandbox path is incorrect.
**Solution** **Solution**
1. Check that you have the permission to operate the file.
1. Check that the required permission is available.
2. Check that the file sandbox path is correct. 2. Check that the file sandbox path is correct.
### 13900013 Incorrect Address ### 13900013 Incorrect Address
...@@ -375,7 +385,7 @@ Seek is used in pipe or FIFO. ...@@ -375,7 +385,7 @@ Seek is used in pipe or FIFO.
**Solution** **Solution**
Check the use of seek. Check the use of **seek()**.
### 13900027 Read-Only File System ### 13900027 Read-Only File System
...@@ -460,6 +470,7 @@ The specified directory is not empty. ...@@ -460,6 +470,7 @@ The specified directory is not empty.
**Solution** **Solution**
1. Check the directory. 1. Check the directory.
2. Ensure that the directory is empty. 2. Ensure that the directory is empty.
### 13900033 Too Many Symbol Links ### 13900033 Too Many Symbol Links
...@@ -516,7 +527,7 @@ The device pointed to by the file descriptor is not a character stream device. ...@@ -516,7 +527,7 @@ The device pointed to by the file descriptor is not a character stream device.
**Solution** **Solution**
Check whether the file descriptor points to a stream device. Check whether the file descriptor points to a stream.
### 13900037 No Data Available ### 13900037 No Data Available
...@@ -599,7 +610,9 @@ Unknown error ...@@ -599,7 +610,9 @@ Unknown error
The error is unidentified. The error is unidentified.
**Solution** **Solution**
1. Call the API again. 1. Call the API again.
2. Restart the service. 2. Restart the service.
## User Data Management Error Codes ## User Data Management Error Codes
...@@ -636,7 +649,7 @@ Use the obtained URI. ...@@ -636,7 +649,7 @@ Use the obtained URI.
**Error Message** **Error Message**
Invalid file extension Invalid file name extension
**Possible Causes** **Possible Causes**
...@@ -660,7 +673,7 @@ The file is moved to the Recycle Bin. ...@@ -660,7 +673,7 @@ The file is moved to the Recycle Bin.
Check whether the file is in the Recycle Bin. Check whether the file is in the Recycle Bin.
## Spatial Statistics Error Codes ## Space Statistics Error Codes
### 13600001 IPC Failed ### 13600001 IPC Failed
...@@ -680,7 +693,7 @@ Check whether the service is started. ...@@ -680,7 +693,7 @@ Check whether the service is started.
**Error Message** **Error Message**
Not supported file system Not supported filesystem
**Possible Causes** **Possible Causes**
...@@ -767,11 +780,15 @@ Check whether the specified directory or node exists. ...@@ -767,11 +780,15 @@ Check whether the specified directory or node exists.
No such object No such object
**Possible Causes** **Possible Causes**
1. The specified volume ID is incorrect. 1. The specified volume ID is incorrect.
2. The specified bundle name is incorrect. 2. The specified bundle name is incorrect.
**Solution** **Solution**
1. Check whether the specified volume exists. 1. Check whether the specified volume exists.
2. Check whether the specified bundle name exists. 2. Check whether the specified bundle name exists.
### 13600009 Invalid User ID ### 13600009 Invalid User ID
...@@ -799,6 +816,7 @@ IPC error ...@@ -799,6 +816,7 @@ IPC error
**Possible Causes** **Possible Causes**
1. The server service does not exist. 1. The server service does not exist.
2. The extension mechanism is abnormal. 2. The extension mechanism is abnormal.
**Solution** **Solution**
...@@ -854,7 +872,9 @@ Check the data returned by the server. ...@@ -854,7 +872,9 @@ Check the data returned by the server.
Fail to register notification Fail to register notification
**Possible Causes** **Possible Causes**
1. The server service does not exist. 1. The server service does not exist.
2. The extension mechanism is abnormal. 2. The extension mechanism is abnormal.
**Solution** **Solution**
...@@ -868,7 +888,9 @@ Check that the server service exists. ...@@ -868,7 +888,9 @@ Check that the server service exists.
Fail to remove notification Fail to remove notification
**Possible Causes** **Possible Causes**
1. The server service does not exist. 1. The server service does not exist.
2. The extension mechanism is abnormal. 2. The extension mechanism is abnormal.
**Solution** **Solution**
...@@ -896,47 +918,11 @@ Check whether the specified Notify agent is registered. ...@@ -896,47 +918,11 @@ Check whether the specified Notify agent is registered.
Fail to notify agent Fail to notify agent
**Possible Causes** **Possible Causes**
1. The service does not exist. 1. The service does not exist.
2. The extension mechanism is abnormal. 2. The extension mechanism is abnormal.
**Solution** **Solution**
Check whether the client is normal. Check whether the client is normal.
## Error Code Adaptation
The APIs provided by the file management subsystem support exception handling.
Sample code for exception handling in a synchronous API:
```js
import fs from '@ohos.file.fs'
try {
let file = fs.openSync(path, fs.OpenMode.READ_ONLY);
} catch (err) {
console.error("openSync errCode:" + err.code + ", errMessage:" + err.message);
}
```
Sample code for exception handling in an asynchronous API (promise):
```js
import fs from '@ohos.file.fs'
try {
let file = await fs.open(path, fs.OpenMode.READ_ONLY);
} catch (err) {
console.error("open promise errCode:" + err.code + ", errMessage:" + err.message);
}
```
Sample code for exception handling in an asynchronous API (callback):
```js
import fs from '@ohos.file.fs'
try {
fs.open(path, fs.OpenMode.READ_ONLY, function(e, file){ // Asynchronous thread (such as the system call) errors are obtained via a callback.
if (e) {
console.error("open in async errCode:" + e.code + ", errMessage:" + e.message);
}
});
} catch (err) {// Main thread errors (such as invalid parameters) are obtained by try catch.
console.error("open callback errCode:" + err.code + ", errMessage:" + err.message);
}
```
...@@ -117,7 +117,7 @@ Data sources of the archived type can be classified into local resources, online ...@@ -117,7 +117,7 @@ Data sources of the archived type can be classified into local resources, online
} }
} }
``` ```
2. Check the format of the URL obtained from the media library is as follows: 2. Check the format of the URL obtained from the media library:
```ts ```ts
Image('datashare:///media/5') Image('datashare:///media/5')
......
# Layout Update Animation # Layout Update Animation
[Attribute animation](../reference/arkui-ts/ts-animatorproperty.md) (animation) and [explicit animation](../reference/arkui-ts/ts-explicit-animation.md) (animateTo) are the most basic and common animation features provided by ArkUI. When the layout attributes (such as the [size](../reference/arkui-ts/ts-universal-attributes-size.md) and [position](../reference/arkui-ts/ts-universal-attributes-location.md)) attributes change, you can use the attribute animation or explicit animation to transit to the new layout parameter status based on the animation parameters. [Explicit animation](../reference/arkui-ts/ts-explicit-animation.md) (**animateTo**) and [attribute animation](../reference/arkui-ts/ts-animatorproperty.md) (**animation**) are the most basic and common animation features provided by ArkUI. When the layout attributes (such as the [size](../reference/arkui-ts/ts-universal-attributes-size.md) and [position](../reference/arkui-ts/ts-universal-attributes-location.md)) attributes change, you can use the attribute animation or explicit animation to transit to the new layout parameter status based on the animation parameters.
| Animation Type| Description | Application Scenario | | Animation Type| Description |
| ---- | ---------------------------------------- | -------- | | ---- | ---------------------------------------- |
| Attribute animation| The animation setting is simple. The animation is automatically triggered when the attribute changes. | Simple animation scenario| | Explicit animation| Triggered by changes in a closure, including component addition and deletion caused by data changes and component attribute changes.| Complex animation scenarios|
| Explicit animation| Changes in a closure trigger animations, including component addition and deletion caused by data changes and component attribute changes. Complex animations can be performed.| Complex animation scenarios| | Attribute animation| Triggered when the attribute changes. The animation setting is simple. |
## Using Explicit Animation to Generate Layout Update Animation ## Using Explicit Animation to Create Layout Update Animation
The API for explicit animation is as follows: The API for explicit animation is as follows:
...@@ -21,7 +21,7 @@ animateTo(value: AnimateParam, event: () => void): void ...@@ -21,7 +21,7 @@ animateTo(value: AnimateParam, event: () => void): void
The first parameter specifies the animation parameter, and the second parameter is the closure function of the animation. The first parameter specifies the animation parameter, and the second parameter is the closure function of the animation.
The following is an example of using explicit animation to produce a layout update animation. In the example, after the alignItems attribute of the Column component is changed, the layout of its child components changes. As long as the attribute is modified in the closure function of **animateTo**, all changes caused by the attribute are performed to the end value according to the animation parameter of animateTo. The following is an example of using explicit animation to create a layout update animation. In the example, when the **\<Column>** component's **alignItems** attribute is updated, the layout of its child components changes. As long as the attribute is updated in the closure function of **animateTo**, animation is performed as configured through **animateTo** for all changes caused by the attribute toward the end value.
```ts ```ts
...@@ -50,7 +50,7 @@ struct LayoutChange { ...@@ -50,7 +50,7 @@ struct LayoutChange {
// The animation duration is 1000 ms, and the curve is EaseInOut. // The animation duration is 1000 ms, and the curve is EaseInOut.
animateTo({ duration: 1000, curve: Curve.EaseInOut }, () => { animateTo({ duration: 1000, curve: Curve.EaseInOut }, () => {
this.alignIndex = (this.alignIndex + 1) % this.allAlign.length; this.alignIndex = (this.alignIndex + 1) % this.allAlign.length;
// Modify the this.itemAlign parameter in the closure function to change the layout of children in the Column container. Use an animation to transition to the new position. // Modify the this.itemAlign parameter in the closure function to change the layout of child elements in the <Column> container. The animation for transition to the new position is applied.
this.itemAlign = this.allAlign[this.alignIndex]; this.itemAlign = this.allAlign[this.alignIndex];
}); });
}) })
...@@ -65,7 +65,7 @@ struct LayoutChange { ...@@ -65,7 +65,7 @@ struct LayoutChange {
![layoutChange1](figures/layoutChange1.gif) ![layoutChange1](figures/layoutChange1.gif)
In addition to directly changing the layout mode, you can also directly change the width, height, and position of a component. In addition to directly changing the layout, you can also change the width, height, and position of a component.
...@@ -75,7 +75,7 @@ In addition to directly changing the layout mode, you can also directly change t ...@@ -75,7 +75,7 @@ In addition to directly changing the layout mode, you can also directly change t
struct LayoutChange2 { struct LayoutChange2 {
@State myWidth: number = 100; @State myWidth: number = 100;
@State myHeight: number = 50; @State myHeight: number = 50;
// Flag. true and false correspond to a group of myWidth and myHeight values respectively. // Flag. true and false correspond to a group of myWidth and myHeight values, respectively.
@State flag: boolean = false; @State flag: boolean = false;
build() { build() {
...@@ -90,7 +90,7 @@ struct LayoutChange2 { ...@@ -90,7 +90,7 @@ struct LayoutChange2 {
.margin(20) .margin(20)
.onClick(() => { .onClick(() => {
animateTo({ duration: 1000, curve: Curve.Ease }, () => { animateTo({ duration: 1000, curve: Curve.Ease }, () => {
// In the animation closure, the state variable that controls the width and height of the first button is changed based on the flag bit so that the width and height of the first button are animated. // In the animation closure, the state variables that control the width and height of the first button are changed based on the flag settings so that the width and height of the first button are animated.
if (this.flag) { if (this.flag) {
this.myWidth = 100; this.myWidth = 100;
this.myHeight = 50; this.myHeight = 50;
...@@ -109,16 +109,16 @@ struct LayoutChange2 { ...@@ -109,16 +109,16 @@ struct LayoutChange2 {
``` ```
In the click event of the second button, the **animateTo** API is used to modify the **this.myWidth** and **this.myHeight** state variables in the closure. The two state variables are the width and height attribute values of the first button. Therefore, the width and height animation is performed for the first button. The display effect is shown below. In the click event of the second button, the **animateTo** API is used to modify the **this.myWidth** and **this.myHeight** state variables in the closure. As these two state variables set the width and height of the first button, the width and height animation is performed for the first button. The display effect is shown below.
![layoutChange2_animateTo](figures/layoutChange2_animateTo.gif) ![layoutChange2_animateTo](figures/layoutChange2_animateTo.gif)
At the same time, the second button also produces a position animation. After the width and height of the first button are changed, the layout of other components in the column is also changed. The layout of the second button is also changed because the width and height of the first button are changed in the closure. At the same time, the second button also produces a position animation. After the width and height of the first button are changed, the layout of other components in the column is also changed, and the second button is among those other components.
If you do not want the second button to have an animation effect, you can use either of the following methods: 1. Add a container outside the first button so that the sizes before and after the animation are within the range of the container. In this way, the position of the second button is not affected by the position of the first button. The modified key code is as follows: If you do not want the second button to have an animation effect, you can use either of the following methods: 1. Add a container outside the first button so that the sizes before and after the animation are within the range of the container. In this way, the position of the second button is not affected by the position of the first button. The key code is as follows:
...@@ -139,7 +139,7 @@ Column({ space: 10 }) { ...@@ -139,7 +139,7 @@ Column({ space: 10 }) {
.fontSize(12) .fontSize(12)
.onClick(() => { .onClick(() => {
animateTo({ duration: 1000, curve: Curve.Ease }, () => { animateTo({ duration: 1000, curve: Curve.Ease }, () => {
// In the animation closure, the state variable that controls the width and height of the first button is changed based on the flag bit so that the width and height of the first button are animated. // In the animation closure, the state variables that control the width and height of the first button are changed based on the flag settings so that the width and height of the first button are animated.
if (this.flag) { if (this.flag) {
this.myWidth = 100; this.myWidth = 100;
this.myHeight = 50; this.myHeight = 50;
...@@ -159,7 +159,7 @@ Column({ space: 10 }) { ...@@ -159,7 +159,7 @@ Column({ space: 10 }) {
![layoutChange2_animateTo_change](figures/layoutChange2_animateTo_change.gif) ![layoutChange2_animateTo_change](figures/layoutChange2_animateTo_change.gif)
2. Add layout constraints to the second button, for example, position constraints, so that the position of the second button is not affected by the width and height of the first button. Sample code: 2. Add layout constraints to the second button. For example, add position constraints so that the position of the second button is not affected by the width and height of the first button. The sample code is as follows:
...@@ -173,11 +173,11 @@ Column({ space: 10 }) { ...@@ -173,11 +173,11 @@ Column({ space: 10 }) {
Button("area: click me") Button("area: click me")
.fontSize(12) .fontSize(12)
// Set the position attribute to a fixed value so that the layout position is not affected by the width and height of the first button. // Set the position attribute to a fixed value so that the position of the second button is not affected by the width and height of the first button.
.position({ x: "30%", y: 200 }) .position({ x: "30%", y: 200 })
.onClick(() => { .onClick(() => {
animateTo({ duration: 1000, curve: Curve.Ease }, () => { animateTo({ duration: 1000, curve: Curve.Ease }, () => {
// In the animation closure, the state variable that controls the width and height of the first button is changed based on the flag bit so that the width and height of the first button are animated. // In the animation closure, the state variables that control the width and height of the first button are changed based on the flag settings so that the width and height of the first button are animated.
if (this.flag) { if (this.flag) {
this.myWidth = 100; this.myWidth = 100;
this.myHeight = 50; this.myHeight = 50;
...@@ -196,7 +196,7 @@ Column({ space: 10 }) { ...@@ -196,7 +196,7 @@ Column({ space: 10 }) {
## Using Attribute Animation to Generate Layout Update Animation ## Using Attribute Animation to Generate Layout Update Animation
The explicit animation places the modification of the attribute of the animation to be executed in the closure function to trigger the animation. The attribute animation does not need to use the closure. You only need to add the animation attribute to the end of the attribute of the component to be executed. Unlike explicit animation, which requires the attribute changes for triggering animation to be placed in the closure function, attribute animation does not need to use the closure. You only need to append the **animation** attribute to the target component attribute.
The API of the attribute animation is as follows: The API of the attribute animation is as follows:
...@@ -205,7 +205,7 @@ The API of the attribute animation is as follows: ...@@ -205,7 +205,7 @@ The API of the attribute animation is as follows:
animation(value: AnimateParam) animation(value: AnimateParam)
``` ```
The input parameter is an animation parameter. If you want the component to generate an animation with the change of an attribute value, you need to add this attribute before the animation attribute. Some attribute changes do not want to generate attribute animations through animations. Therefore, attribute animations can be placed after animations. The example of explicit animation above is easily changed to be implemented with property animation. Sample code: This API accepts an animation parameter as its argument. If you want the component to generate an animation with the value change of an attribute, add this attribute before the **animation** attribute. Otherwise, you can place the attribute after the **animation** attribute. The previous example of explicit animation can be easily implemented with attribute animation. The sample code is as follows:
...@@ -224,11 +224,11 @@ struct LayoutChange2 { ...@@ -224,11 +224,11 @@ struct LayoutChange2 {
.type(ButtonType.Normal) .type(ButtonType.Normal)
.width(this.myWidth) .width(this.myWidth)
.height(this.myHeight) .height(this.myHeight)
// Animation takes effect only for the type, width, and height attributes. The duration is 1000 ms, and the curve is Ease. // The animation takes effect only for the type, width, and height attributes. The duration is 1000 ms, and the curve is Ease.
.animation({ duration: 1000, curve: Curve.Ease }) .animation({ duration: 1000, curve: Curve.Ease })
// The animation does not take effect for the backgroundColor and margin attributes.
.backgroundColor(this.myColor) .backgroundColor(this.myColor)
.margin(20) .margin(20)
// Animation does not take effect for the backgroundColor and margin attributes.
Button("area: click me") Button("area: click me")
.fontSize(12) .fontSize(12)
...@@ -251,7 +251,7 @@ struct LayoutChange2 { ...@@ -251,7 +251,7 @@ struct LayoutChange2 {
``` ```
In the preceding example, the animation attribute of the first button takes effect only for the type, width, and height attributes written before the animation, but does not take effect for the backgroundColor and margin attributes written after the animation. In the running result, the width and height attributes execute the animation based on the animation parameters. However, the backgroundColor directly jumps and no animation is generated. The display effect is shown below. In the preceding example, the **animation** attribute of the first button takes effect only for the **type**, **width**, and **height** attributes written before the **animation** attribute, but does not take effect for the **backgroundColor** and **margin** attributes written after. In the running result, the **width** and **height** attributes execute the animation based on the **animation** settings, while the **backgroundColor** attribute changes without any animation applied. The display effect is shown below.
...@@ -263,8 +263,8 @@ In the preceding example, the animation attribute of the first button takes effe ...@@ -263,8 +263,8 @@ In the preceding example, the animation attribute of the first button takes effe
>**NOTE** >**NOTE**
> >
> 1. When the attribute animation is used, the animation is executed according to the specified attribute animation parameters. Each component can configure attribute animations with different parameters for its own attributes. > 1. Attribute animations are executed according to the configured attribute animation settings. Each component can have its own attribute animation settings.
> >
> 2. Explicit animations are executed on all GUI differences caused before and after animation closures, and the same animation parameters are used. Therefore, explicit animations are applicable to scenarios where animations are executed in a unified manner. In addition, explicit animations can also be used for animations caused by non-attribute variables, such as if/else conditions and deletion of array elements used by Forach. > 2. Explicit animations are executed on all GUI differences caused before and after animation closures, and they share the same animation settings. Therefore, explicit animations are applicable to scenarios where animations are executed in a unified manner. Explicit animations can also be used for animations caused by non-attribute variables, such as **if/else** statements and deletion of array elements used by **ForEach**.
> >
> 3. If an attribute animation is configured for an attribute and the attribute value is changed in the explicit animation closure, the attribute animation takes effect first and the animation parameters of the attribute animation are used. > 3. If an attribute animation is configured for an attribute and the attribute value is changed in the explicit animation closure, the attribute animation takes precedence, under the configured animation settings.
...@@ -138,8 +138,8 @@ ...@@ -138,8 +138,8 @@
- [Continuation Overview](application-models/inter-device-interaction-hop-overview.md) - [Continuation Overview](application-models/inter-device-interaction-hop-overview.md)
- [Cross-Device Migration (for System Applications Only)](application-models/hop-cross-device-migration.md) - [Cross-Device Migration (for System Applications Only)](application-models/hop-cross-device-migration.md)
- [Multi-device Collaboration (for System Applications Only)](application-models/hop-multi-device-collaboration.md) - [Multi-device Collaboration (for System Applications Only)](application-models/hop-multi-device-collaboration.md)
- IPC - Process Model
- [Process Model](application-models/process-model-stage.md) - [Process Model Overview](application-models/process-model-stage.md)
- Common Events - Common Events
- [Introduction to Common Events](application-models/common-event-overview.md) - [Introduction to Common Events](application-models/common-event-overview.md)
- Common Event Subscription - Common Event Subscription
...@@ -149,8 +149,8 @@ ...@@ -149,8 +149,8 @@
- [Unsubscribing from Common Events](application-models/common-event-unsubscription.md) - [Unsubscribing from Common Events](application-models/common-event-unsubscription.md)
- [Publishing Common Events](application-models/common-event-publish.md) - [Publishing Common Events](application-models/common-event-publish.md)
- [Background Services](application-models/background-services.md) - [Background Services](application-models/background-services.md)
- Inter-Thread Communication - Thread Model
- [Thread Model](application-models/thread-model-stage.md) - [Thread Model Overview](application-models/thread-model-stage.md)
- [Using Emitter for Inter-Thread Communication](application-models/itc-with-emitter.md) - [Using Emitter for Inter-Thread Communication](application-models/itc-with-emitter.md)
- [Using Worker for Inter-Thread Communication](application-models/itc-with-worker.md) - [Using Worker for Inter-Thread Communication](application-models/itc-with-worker.md)
- Mission Management - Mission Management
...@@ -193,12 +193,12 @@ ...@@ -193,12 +193,12 @@
- [Context](application-models/application-context-fa.md) - [Context](application-models/application-context-fa.md)
- [Want](application-models/want-fa.md) - [Want](application-models/want-fa.md)
- [Component Startup Rules](application-models/component-startup-rules-fa.md) - [Component Startup Rules](application-models/component-startup-rules-fa.md)
- IPC - Process Model
- [Process Model](application-models/process-model-fa.md) - [Process Model Overview](application-models/process-model-fa.md)
- [Common Events](application-models/common-event-fa.md) - [Common Events](application-models/common-event-fa.md)
- [Background Services](application-models/rpc.md) - [Background Services](application-models/rpc.md)
- Inter-Thread Communication - Thread Model
- [Thread Model](application-models/thread-model-fa.md) - [Thread Model Overview](application-models/thread-model-fa.md)
- [Inter-Thread Communication](application-models/itc-fa-overview.md) - [Inter-Thread Communication](application-models/itc-fa-overview.md)
- [Mission Management](application-models/mission-management-fa.md) - [Mission Management](application-models/mission-management-fa.md)
- Development of Component Interaction Between the FA Model and Stage Model - Development of Component Interaction Between the FA Model and Stage Model
...@@ -575,9 +575,13 @@ ...@@ -575,9 +575,13 @@
- [Development of Application Event Logging](dfx/hiappevent-guidelines.md) - [Development of Application Event Logging](dfx/hiappevent-guidelines.md)
- [Development of Performance Tracing](dfx/hitracemeter-guidelines.md) - [Development of Performance Tracing](dfx/hitracemeter-guidelines.md)
- [Development of Distributed Call Chain Tracing](dfx/hitracechain-guidelines.md) - [Development of Distributed Call Chain Tracing](dfx/hitracechain-guidelines.md)
- [HiLog Development (Native)](dfx/hilog-guidelines.md)
- Error Management - Error Management
- [Development of Error Manager](dfx/errormanager-guidelines.md) - [Development of Error Manager](dfx/errormanager-guidelines.md)
- [Development of Application Recovery](dfx/apprecovery-guidelines.md) - [Development of Application Recovery](dfx/apprecovery-guidelines.md)
- Log Analysis
- [Application Freeze (appfreeze) Log Analysis](dfx/appfreeze-guidelines.md)
- [cppcrash Log Analysis](dfx/cppcrash-guidelines.md)
- Internationalization - Internationalization
- [Internationalization Overview](internationalization/international-overview.md) - [Internationalization Overview](internationalization/international-overview.md)
- [Internationalization Development (intl)](internationalization/intl-guidelines.md) - [Internationalization Development (intl)](internationalization/intl-guidelines.md)
...@@ -1164,7 +1168,6 @@ ...@@ -1164,7 +1168,6 @@
- [@ohos.net.connection (Network Connection Management)](reference/apis/js-apis-net-connection.md) - [@ohos.net.connection (Network Connection Management)](reference/apis/js-apis-net-connection.md)
- [@ohos.net.ethernet (Ethernet Connection Management)](reference/apis/js-apis-net-ethernet.md) - [@ohos.net.ethernet (Ethernet Connection Management)](reference/apis/js-apis-net-ethernet.md)
- [@ohos.net.http (Data Request)](reference/apis/js-apis-http.md) - [@ohos.net.http (Data Request)](reference/apis/js-apis-http.md)
- [@ohos.net.policy (Network Policy Management)](reference/apis/js-apis-net-policy.md)
- [@ohos.net.sharing (Network Sharing)](reference/apis/js-apis-net-sharing.md) - [@ohos.net.sharing (Network Sharing)](reference/apis/js-apis-net-sharing.md)
- [@ohos.net.socket (Socket Connection)](reference/apis/js-apis-socket.md) - [@ohos.net.socket (Socket Connection)](reference/apis/js-apis-socket.md)
- [@ohos.net.webSocket (WebSocket Connection)](reference/apis/js-apis-webSocket.md) - [@ohos.net.webSocket (WebSocket Connection)](reference/apis/js-apis-webSocket.md)
...@@ -1391,7 +1394,6 @@ ...@@ -1391,7 +1394,6 @@
- [Network Connection Management Error Codes](reference/errorcodes/errorcode-net-connection.md) - [Network Connection Management Error Codes](reference/errorcodes/errorcode-net-connection.md)
- [Ethernet Connection Management Error Codes](reference/errorcodes/errorcode-net-ethernet.md) - [Ethernet Connection Management Error Codes](reference/errorcodes/errorcode-net-ethernet.md)
- [Network Sharing Error Codes](reference/errorcodes/errorcode-net-sharing.md) - [Network Sharing Error Codes](reference/errorcodes/errorcode-net-sharing.md)
- [Network Policy Management Error Codes](reference/errorcodes/errorcode-net-policy.md)
- Connectivity - Connectivity
- [NFC Error Codes](reference/errorcodes/errorcode-nfc.md) - [NFC Error Codes](reference/errorcodes/errorcode-nfc.md)
- [RPC Error Codes](reference/errorcodes/errorcode-rpc.md) - [RPC Error Codes](reference/errorcodes/errorcode-rpc.md)
...@@ -1533,6 +1535,8 @@ ...@@ -1533,6 +1535,8 @@
- [Full SDK Compilation Guide](quick-start/full-sdk-compile-guide.md) - [Full SDK Compilation Guide](quick-start/full-sdk-compile-guide.md)
- [Guide to Switching to Full SDK](quick-start/full-sdk-switch-guide.md) - [Guide to Switching to Full SDK](quick-start/full-sdk-switch-guide.md)
- [Ability Development](faqs/faqs-ability.md) - [Ability Development](faqs/faqs-ability.md)
- [ArkUI Development](faqs/faqs-arkui.md)
- [Web Development](faqs/faqs-arkui-web.md)
- [Bundle Management Development](faqs/faqs-bundle-management.md) - [Bundle Management Development](faqs/faqs-bundle-management.md)
- [Resource Manager Development](faqs/faqs-globalization.md) - [Resource Manager Development](faqs/faqs-globalization.md)
- [Common Event and Notification Development](faqs/faqs-event-notification.md) - [Common Event and Notification Development](faqs/faqs-event-notification.md)
...@@ -1548,4 +1552,5 @@ ...@@ -1548,4 +1552,5 @@
- [Pan-Sensor Development](faqs/faqs-sensor.md) - [Pan-Sensor Development](faqs/faqs-sensor.md)
- [Startup Development](faqs/faqs-startup.md) - [Startup Development](faqs/faqs-startup.md)
- [Distributed Device Development](faqs/faqs-distributed-device-profile.md) - [Distributed Device Development](faqs/faqs-distributed-device-profile.md)
- [SDK Usage](faqs/faqs-sdk.md)
- [Usage of Third- and Fourth-Party Libraries](faqs/faqs-third-fourth-party-library.md) - [Usage of Third- and Fourth-Party Libraries](faqs/faqs-third-fourth-party-library.md)
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
## cl.filemanagement.1 environment Module Change ## cl.filemanagement.1 environment Module Change
The file management subsystem **d.ts** file has been archived and moved to the **file** directory. The **environment** module supports error code handling. The file management subsystem **d.ts** file has been archived and moved to the **file** directory. The **environment** module supports error code processing.
**Change Impact** **Change Impact**
If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **environment** module supports error code handling. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md). If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **environment** module supports error code processing. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md) for more details.
**Key API/Component Changes** **Key API/Component Changes**
...@@ -24,11 +24,11 @@ import environment from '@ohos.file.environment'; ...@@ -24,11 +24,11 @@ import environment from '@ohos.file.environment';
## cl.filemanagement.2 securityLabel Change ## cl.filemanagement.2 securityLabel Change
Moved the file management subsystem **d.ts** file to the **file** directory. The **securityLabel** module supports error code handling. Moved the file management subsystem **d.ts** file to the **file** directory. The **securityLabel** module supports error code processing.
**Change Impact** **Change Impact**
If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **securityLabel** module supports error code handling. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md). If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **securityLabel** module supports error code processing. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md) for more details.
**Key API/Component Changes** **Key API/Component Changes**
...@@ -58,11 +58,11 @@ The type of the **ino** attribute of **Stat** is changed from number to BigInt. ...@@ -58,11 +58,11 @@ The type of the **ino** attribute of **Stat** is changed from number to BigInt.
## cl.filemanagement.4 fileAccess Change ## cl.filemanagement.4 fileAccess Change
Moved the file management subsystem **d.ts** file to the **file** directory. The **fileAccess** module supports error code handling. Moved the file management subsystem **d.ts** file to the **file** directory. The **fileAccess** module supports error code processing.
**Change Impact** **Change Impact**
If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **fileAccess** module supports error code handling. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md). If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **fileAccess** module supports error code processing. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md) for more details.
**Key API/Component Changes** **Key API/Component Changes**
...@@ -80,11 +80,11 @@ import fileAccess from '@ohos.file.fileAccess'; ...@@ -80,11 +80,11 @@ import fileAccess from '@ohos.file.fileAccess';
## cl.filemanagement.5 fileExtensionInfo Change ## cl.filemanagement.5 fileExtensionInfo Change
Moved the file management subsystem **d.ts** file to the **file** directory. The **fileExtensionInfo** module supports error code handling. Moved the file management subsystem **d.ts** file to the **file** directory. The **fileExtensionInfo** module supports error code processing.
**Change Impact** **Change Impact**
If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **fileExtensionInfo** module supports error code handling. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md). If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **fileExtensionInfo** module supports error code processing. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md) for more details.
**Key API/Component Changes** **Key API/Component Changes**
...@@ -102,11 +102,11 @@ import fileExtensionInfo from '@ohos.file.fileExtensionInfo'; ...@@ -102,11 +102,11 @@ import fileExtensionInfo from '@ohos.file.fileExtensionInfo';
## cl.filemanagement.6 storageStatistics Change ## cl.filemanagement.6 storageStatistics Change
Moved the file management subsystem **d.ts** file to the **file** directory. The **fileExtensionInfo** module supports error code handling. Moved the file management subsystem **d.ts** file to the **file** directory. The **fileExtensionInfo** module supports error code processing.
**Change Impact** **Change Impact**
If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **storageStatistics** module supports error code handling. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md). If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **storageStatistics** module supports error code processing. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md) for more details.
**Key API/Component Changes** **Key API/Component Changes**
...@@ -124,11 +124,11 @@ import storageStatistics from '@ohos.file.storageStatistics'; ...@@ -124,11 +124,11 @@ import storageStatistics from '@ohos.file.storageStatistics';
## cl.filemanagement.7 volumeManager Change ## cl.filemanagement.7 volumeManager Change
Moved the file management subsystem **d.ts** file to the **file** directory. The **fileExtensionInfo** module supports error code handling. Moved the file management subsystem **d.ts** file to the **file** directory. The **fileExtensionInfo** module supports error code processing.
**Change Impact** **Change Impact**
If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **volumeManager** module supports error code handling. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md). If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **volumeManager** module supports error code processing. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md) for more details.
**Key API/Component Changes** **Key API/Component Changes**
......
...@@ -12,12 +12,27 @@ AccessibilityExtensionAbility基于ExtensionAbility框架,提供无障碍扩 ...@@ -12,12 +12,27 @@ AccessibilityExtensionAbility基于ExtensionAbility框架,提供无障碍扩
本文档将从以下场景来介绍AccessibilityExtensionAbility的基本开发: 本文档将从以下场景来介绍AccessibilityExtensionAbility的基本开发:
- [AccessibilityExtensionAbility概述](#accessibilityextensionability概述)
- [如何创建一个无障碍扩展服务](#如何创建一个无障碍扩展服务) - [如何创建一个无障碍扩展服务](#如何创建一个无障碍扩展服务)
- [如何处理一个无障碍事件](#如何处理一个无障碍事件) - [如何处理一个无障碍事件](#如何处理一个无障碍事件)
- [如何声明无障碍扩展服务具备的能力](#如何声明无障碍扩展服务具备的能力) - [如何声明无障碍扩展服务具备的能力](#如何声明无障碍扩展服务具备的能力)
- [如何开启自定义的无障碍扩展服务](#如何开启自定义的无障碍扩展服务) - [如何开启自定义的无障碍扩展服务](#如何开启自定义的无障碍扩展服务)
- [相关示例](#相关示例) - [相关示例](#相关示例)
## AccessibilityExtensionAbility概述
“信息无障碍”译自“Accessibility”,是指任何人在任何情况下都能平等、方便地获取信息并利用信息。其目的是缩小全社会不同阶层、不同地区、不同年龄、不同健康状况的人群在信息理解、信息交互、信息利用方面的数字鸿沟,使其更加方便地参与社会生活,享受数字发展带来的便利。
AccessibilityExtensionAbility为无障碍扩展服务框架,允许三方开发自己的扩展服务,提供在应用程序和扩展服务之间交换信息的标准机制,以便为各种障碍人群和障碍场景提供辅助能力,增强用户的无障碍使用体验。例如在使用微信时,利用辅助应用旁白,用户可以“听见”当前屏幕内容。
![AccessibilityFramework](figures/AccessibilityFramework.png)
1. Accessibility App:开发者基于无障碍扩展服务框架扩展出来的扩展服务应用,如视障用户使用的读屏App。
2. Tartget App:被Accessibility App辅助的目标应用。
3. AccessibilityAbilityManagerService(AAMS):无障碍扩展服务框架主服务,用于对Accessibility App生命周期进行管理,同时为Accessibility App和Target App提供信息交互的桥梁。
4. AccessibilityAbility(AAkit):Accessibility App利用AAkit构建扩展服务Ability运行环境,并为Accessibility App提供可查询和操作Target App的接口,如查询节点信息、对节点执行点击/长按操作等。
5. AccessibilitySystemAbilityClient(ASACkit):Target App通过ASACkit向AAMS发送无障碍事件,如内容变化事件等,同时响应Accessibility App通过AAMS请求的指令,如查询节点信息、对节点执行点击/长按操作等。
## 如何创建一个无障碍扩展服务 ## 如何创建一个无障碍扩展服务
开发者在创建一个无障碍扩展服务时,如工程满足环境要求,开发者可自主选择是否跳过创建工程步骤,在已有工程中新增无障碍扩展服务。 开发者在创建一个无障碍扩展服务时,如工程满足环境要求,开发者可自主选择是否跳过创建工程步骤,在已有工程中新增无障碍扩展服务。
......
...@@ -56,3 +56,5 @@ ArkTS卡片相较于JS卡片具备了更加丰富的能力,但也增加了使 ...@@ -56,3 +56,5 @@ ArkTS卡片相较于JS卡片具备了更加丰富的能力,但也增加了使
- 不支持import,会在后续版本支持。 - 不支持import,会在后续版本支持。
- 不支持极速预览,会在后续版本支持。 - 不支持极速预览,会在后续版本支持。
- 不支持Hot Reload热重载,会在后续版本支持。
# ServiceExtensionAbility # ServiceExtensionAbility
- [概述](#概述)
- [生命周期](#生命周期)
- [实现一个后台服务(仅对系统应用开放)](#实现一个后台服务仅对系统应用开放)
- [开发准备](#开发准备)
- [定义IDL接口](#定义idl接口)
- [创建ServiceExtensionAbility](#创建serviceextensionability)
- [启动一个后台服务(仅对系统应用开放)](#启动一个后台服务仅对系统应用开放)
- [连接一个后台服务](#连接一个后台服务)
- [客户端与服务端通信](#客户端与服务端通信)
- [服务端对客户端身份校验](#服务端对客户端身份校验)
- [相关示例](#相关示例)
## 概述 ## 概述
[ServiceExtensionAbility](../reference/apis/js-apis-app-ability-serviceExtensionAbility.md)是SERVICE类型的ExtensionAbility组件,提供后台服务能力,其内部持有了一个[ServiceExtensionContext](../reference/apis/js-apis-inner-application-serviceExtensionContext.md),通过[ServiceExtensionContext](../reference/apis/js-apis-inner-application-serviceExtensionContext.md)提供了丰富的接口供外部使用。 [ServiceExtensionAbility](../reference/apis/js-apis-app-ability-serviceExtensionAbility.md)是SERVICE类型的ExtensionAbility组件,提供后台服务能力,其内部持有了一个[ServiceExtensionContext](../reference/apis/js-apis-inner-application-serviceExtensionContext.md),通过[ServiceExtensionContext](../reference/apis/js-apis-inner-application-serviceExtensionContext.md)提供了丰富的接口供外部使用。
......
...@@ -70,6 +70,8 @@ httpRequest.request( ...@@ -70,6 +70,8 @@ httpRequest.request(
// data.header为HTTP响应头,可根据业务需要进行解析 // data.header为HTTP响应头,可根据业务需要进行解析
console.info('header:' + JSON.stringify(data.header)); console.info('header:' + JSON.stringify(data.header));
console.info('cookies:' + JSON.stringify(data.cookies)); // 8+ console.info('cookies:' + JSON.stringify(data.cookies)); // 8+
// 当该请求使用完毕时,调用destroy方法主动销毁
httpRequest.destroy();
} else { } else {
console.info('error:' + JSON.stringify(err)); console.info('error:' + JSON.stringify(err));
// 取消订阅HTTP响应头事件 // 取消订阅HTTP响应头事件
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
开发者通过[DevEco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio)工具按照业务的需要创建多个Module,在相应的Module中完成自身业务的开发。 开发者通过[DevEco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio)工具按照业务的需要创建多个Module,在相应的Module中完成自身业务的开发。
## 调试 ## 调试
通过DevEco Studio编译打包,生成单个或者多个HAP,即可基于HAP进行调试。在调试前,需要先安装或更新HAP,以下介绍具体做法。 通过DevEco Studio编译打包,生成单个或者多个HAP,即可基于HAP进行调试。如需根据不同的部署环境、目标人群、运行环境等,将同一个HAP定制编译为不同版本,请参见[定制编译指导](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/customized-multi-targets-and-products-0000001430013853-V3?catalogVersion=V3)
在调试前,需要先安装或更新HAP,以下介绍具体做法。
* 使用DevEco Studio进行调试 * 使用DevEco Studio进行调试
使用指导可参考[应用程序包调试方法](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-debugging-and-running-0000001263040487#section10491183521520),其中包括了单HAP与多HAP通过DevEco Studio工具的安装调试方法。 使用指导可参考[应用程序包调试方法](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-debugging-and-running-0000001263040487#section10491183521520),其中包括了单HAP与多HAP通过DevEco Studio工具的安装调试方法。
......
...@@ -37,14 +37,14 @@ ...@@ -37,14 +37,14 @@
- **AppScope > app.json5**:应用的全局配置信息。 - **AppScope > app.json5**:应用的全局配置信息。
- **entry**:OpenHarmony工程模块,编译构建生成一个[HAP](../../glossary.md#hap)包。 - **entry**:OpenHarmony工程模块,编译构建生成一个[HAP](../../glossary.md#hap)包。
- **oh_modules**:用于存放三方库依赖信息。关于原npm工程适配ohpm操作,请参考[历史工程手动迁移](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/project_overview-0000001053822398-V3#section108143331212)
- **src &gt; main &gt; ets**:用于存放ArkTS源码。 - **src &gt; main &gt; ets**:用于存放ArkTS源码。
- **src &gt; main &gt; ets &gt; entryability**:应用/服务的入口。 - **src &gt; main &gt; ets &gt; entryability**:应用/服务的入口。
- **src &gt; main &gt; ets &gt; pages**:应用/服务包含的页面。 - **src &gt; main &gt; ets &gt; pages**:应用/服务包含的页面。
- **src &gt; main &gt; resources**:用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。关于资源文件,详见[资源文件的分类](resource-categories-and-access.md#资源分类) - **src &gt; main &gt; resources**:用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。关于资源文件,详见[资源文件的分类](resource-categories-and-access.md#资源分类)
- **src &gt; main &gt; module.json5**:模块配置文件。主要包含HAP的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。具体的配置文件说明,详见[module.json5配置文件](module-configuration-file.md) - **src &gt; main &gt; module.json5**:模块配置文件。主要包含HAP的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。具体的配置文件说明,详见[module.json5配置文件](module-configuration-file.md)
- **build-profile.json5**:当前的模块信息 、编译信息配置项,包括buildOption、targets配置等。其中targets中可配置当前运行环境,默认为HarmonyOS。若需开发OpenHarmony应用,则需开发者自行修改为OpenHarmony。 - **build-profile.json5**:当前的模块信息 、编译信息配置项,包括buildOption、targets配置等。其中targets中可配置当前运行环境,默认为HarmonyOS。若需开发OpenHarmony应用,则需开发者自行修改为OpenHarmony。
- **hvigorfile.ts**:模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。 - **hvigorfile.ts**:模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。
- **oh_modules**:用于存放三方库依赖信息。关于原npm工程适配ohpm操作,请参考[历史工程手动迁移](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/project_overview-0000001053822398-V3#section108143331212)
- **build-profile.json5**:应用级配置信息,包括签名、产品配置等。 - **build-profile.json5**:应用级配置信息,包括签名、产品配置等。
- **hvigorfile.ts**:应用级编译构建任务脚本。 - **hvigorfile.ts**:应用级编译构建任务脚本。
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
> **说明:** > **说明:**
> >
> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
> 该模块不支持在[UIAbility](./js-apis-app-ability-uiAbility.md)中使用。
## 导入模块 ## 导入模块
......
...@@ -53,6 +53,8 @@ httpRequest.request( ...@@ -53,6 +53,8 @@ httpRequest.request(
// data.header为HTTP响应头,可根据业务需要进行解析 // data.header为HTTP响应头,可根据业务需要进行解析
console.info('header:' + JSON.stringify(data.header)); console.info('header:' + JSON.stringify(data.header));
console.info('cookies:' + JSON.stringify(data.cookies)); // 8+ console.info('cookies:' + JSON.stringify(data.cookies)); // 8+
// 当该请求使用完毕时,调用destroy方法主动销毁
httpRequest.destroy();
} else { } else {
console.info('error:' + JSON.stringify(err)); console.info('error:' + JSON.stringify(err));
// 取消订阅HTTP响应头事件 // 取消订阅HTTP响应头事件
......
...@@ -609,7 +609,7 @@ try { ...@@ -609,7 +609,7 @@ try {
**系统能力**:以下各项对应的系统能力均为SystemCapability.BarrierFree.Accessibility.Core **系统能力**:以下各项对应的系统能力均为SystemCapability.BarrierFree.Accessibility.Core
## attributeNames ### attributeNames
attributeNames\<T extends keyof ElementAttributeValues>(): Promise\<Array\<T>>; attributeNames\<T extends keyof ElementAttributeValues>(): Promise\<Array\<T>>;
...@@ -635,7 +635,7 @@ rootElement.attributeNames().then((data) => { ...@@ -635,7 +635,7 @@ rootElement.attributeNames().then((data) => {
console.log('failed to get attribute names, because ' + JSON.stringify(err)); console.log('failed to get attribute names, because ' + JSON.stringify(err));
}); });
``` ```
## attributeNames ### attributeNames
attributeNames\<T extends keyof ElementAttributeValues>(callback: AsyncCallback\<Array\<T>>): void; attributeNames\<T extends keyof ElementAttributeValues>(callback: AsyncCallback\<Array\<T>>): void;
...@@ -663,7 +663,7 @@ rootElement.attributeNames((err, data) => { ...@@ -663,7 +663,7 @@ rootElement.attributeNames((err, data) => {
console.info('get attribute names success'); console.info('get attribute names success');
}); });
``` ```
## AccessibilityElement.attributeValue ### attributeValue
attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T): Promise\<ElementAttributeValues[T]>; attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T): Promise\<ElementAttributeValues[T]>;
...@@ -708,7 +708,7 @@ try { ...@@ -708,7 +708,7 @@ try {
console.log('failed to get attribute value, because ' + JSON.stringify(exception)); console.log('failed to get attribute value, because ' + JSON.stringify(exception));
} }
``` ```
## AccessibilityElement.attributeValue ### attributeValue
attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T, attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T,
callback: AsyncCallback\<ElementAttributeValues[T]>): void; callback: AsyncCallback\<ElementAttributeValues[T]>): void;
...@@ -751,7 +751,7 @@ try { ...@@ -751,7 +751,7 @@ try {
console.log('failed to get attribute value, because ' + JSON.stringify(exception)); console.log('failed to get attribute value, because ' + JSON.stringify(exception));
} }
``` ```
## actionNames ### actionNames
actionNames(): Promise\<Array\<string>>; actionNames(): Promise\<Array\<string>>;
...@@ -777,7 +777,7 @@ rootElement.actionNames().then((data) => { ...@@ -777,7 +777,7 @@ rootElement.actionNames().then((data) => {
console.log('failed to get action names because ' + JSON.stringify(err)); console.log('failed to get action names because ' + JSON.stringify(err));
}); });
``` ```
## actionNames ### actionNames
actionNames(callback: AsyncCallback\<Array\<string>>): void; actionNames(callback: AsyncCallback\<Array\<string>>): void;
...@@ -805,7 +805,7 @@ rootElement.actionNames((err, data) => { ...@@ -805,7 +805,7 @@ rootElement.actionNames((err, data) => {
console.info('get action names success'); console.info('get action names success');
}); });
``` ```
## performAction ### performAction
performAction(actionName: string, parameters?: object): Promise\<void>; performAction(actionName: string, parameters?: object): Promise\<void>;
...@@ -848,7 +848,7 @@ try { ...@@ -848,7 +848,7 @@ try {
console.log('failed to perform action, because ' + JSON.stringify(exception)); console.log('failed to perform action, because ' + JSON.stringify(exception));
} }
``` ```
## performAction ### performAction
performAction(actionName: string, callback: AsyncCallback\<void>): void; performAction(actionName: string, callback: AsyncCallback\<void>): void;
...@@ -887,7 +887,7 @@ try { ...@@ -887,7 +887,7 @@ try {
console.log('failed to perform action, because ' + JSON.stringify(exception)); console.log('failed to perform action, because ' + JSON.stringify(exception));
} }
``` ```
## performAction ### performAction
performAction(actionName: string, parameters: object, callback: AsyncCallback\<void>): void; performAction(actionName: string, parameters: object, callback: AsyncCallback\<void>): void;
...@@ -931,7 +931,7 @@ try { ...@@ -931,7 +931,7 @@ try {
console.log('failed to perform action, because ' + JSON.stringify(exception)); console.log('failed to perform action, because ' + JSON.stringify(exception));
} }
``` ```
## findElement('content') ### findElement('content')
findElement(type: 'content', condition: string): Promise\<Array\<AccessibilityElement>>; findElement(type: 'content', condition: string): Promise\<Array\<AccessibilityElement>>;
...@@ -970,7 +970,7 @@ try { ...@@ -970,7 +970,7 @@ try {
console.log('failed to find element, because ' + JSON.stringify(exception)); console.log('failed to find element, because ' + JSON.stringify(exception));
} }
``` ```
## findElement('content') ### findElement('content')
findElement(type: 'content', condition: string, callback: AsyncCallback\<Array\<AccessibilityElement>>): void; findElement(type: 'content', condition: string, callback: AsyncCallback\<Array\<AccessibilityElement>>): void;
...@@ -1006,7 +1006,7 @@ try { ...@@ -1006,7 +1006,7 @@ try {
console.log('failed to find element, because ' + JSON.stringify(exception)); console.log('failed to find element, because ' + JSON.stringify(exception));
} }
``` ```
## findElement('focusType') ### findElement('focusType')
findElement(type: 'focusType', condition: FocusType): Promise\<AccessibilityElement>; findElement(type: 'focusType', condition: FocusType): Promise\<AccessibilityElement>;
...@@ -1045,7 +1045,7 @@ try { ...@@ -1045,7 +1045,7 @@ try {
console.log('failed to find element, because ' + JSON.stringify(exception)); console.log('failed to find element, because ' + JSON.stringify(exception));
} }
``` ```
## findElement('focusType') ### findElement('focusType')
findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback\<AccessibilityElement>): void; findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback\<AccessibilityElement>): void;
...@@ -1081,7 +1081,7 @@ try { ...@@ -1081,7 +1081,7 @@ try {
console.log('failed to find element, because ' + JSON.stringify(exception)); console.log('failed to find element, because ' + JSON.stringify(exception));
} }
``` ```
## findElement('focusDirection') ### findElement('focusDirection')
findElement(type: 'focusDirection', condition: FocusDirection): Promise\<AccessibilityElement>; findElement(type: 'focusDirection', condition: FocusDirection): Promise\<AccessibilityElement>;
...@@ -1120,7 +1120,7 @@ try { ...@@ -1120,7 +1120,7 @@ try {
console.log('failed to find element, because ' + JSON.stringify(exception)); console.log('failed to find element, because ' + JSON.stringify(exception));
} }
``` ```
## findElement('focusDirection') ### findElement('focusDirection')
findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCallback\<AccessibilityElement>): void; findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCallback\<AccessibilityElement>): void;
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
> **说明:** > **说明:**
> >
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 > 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
>
> 该模块不支持在[UIAbility](./js-apis-app-ability-uiAbility.md)中使用。
## 导入模块 ## 导入模块
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
> **说明:** > **说明:**
> >
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
> 该模块不支持在[UIAbility](./js-apis-app-ability-uiAbility.md)中使用。
## 导入模块 ## 导入模块
......
...@@ -6689,7 +6689,7 @@ registerDeathRecipient(recipient: DeathRecipient, flags: number): void ...@@ -6689,7 +6689,7 @@ registerDeathRecipient(recipient: DeathRecipient, flags: number): void
} }
``` ```
### addDeathRecippient<sup>(deprecated)</sup> ### addDeathRecipient<sup>(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[registerDeathRecipient](#registerdeathrecipient9)类替代。 >从API version 9 开始不再维护,建议使用[registerDeathRecipient](#registerdeathrecipient9)类替代。
...@@ -6744,7 +6744,7 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean ...@@ -6744,7 +6744,7 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean
globalThis.context.connectServiceExtensionAbility(want, connect); globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的addDeathRecippient接口方法新增死亡回调 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的addDeathRecipient接口方法新增死亡回调
```ts ```ts
class MyDeathRecipient { class MyDeathRecipient {
...@@ -7146,7 +7146,7 @@ isAsync(): boolean; ...@@ -7146,7 +7146,7 @@ isAsync(): boolean;
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ---------------------------------------- | | ------- | ---------------------------------------- |
| boolean | true:同步调用成功,false:异步调用成功。| | boolean | true:异步调用成功,false:同步调用成功。|
**示例:** **示例:**
......
...@@ -158,7 +158,7 @@ getCurrentTime(isNano?: boolean): Promise&lt;number&gt; ...@@ -158,7 +158,7 @@ getCurrentTime(isNano?: boolean): Promise&lt;number&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------- | ---- | ------------------------- | | ------ | ------- | ---- | ------------------------- |
| isNano | boolean | 否 | 返回结果是否为纳秒数。<br/>- true:表示返回结果为纳秒数(ns)。 <br/>- false:表示返回结果为毫秒数(ms)。 | | isNano | boolean | 否 | 返回结果是否为纳秒数。<br/>默认值为false。<br>- true:表示返回结果为纳秒数(ns)。 <br/>- false:表示返回结果为毫秒数(ms)。 |
**返回值:** **返回值:**
...@@ -253,7 +253,7 @@ getRealActiveTime(isNano?: boolean): Promise&lt;number&gt; ...@@ -253,7 +253,7 @@ getRealActiveTime(isNano?: boolean): Promise&lt;number&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------- | ---- | ----------------------------------- | | ------ | ------- | ---- | ----------------------------------- |
| isNano | boolean | 否 | 返回结果是否为纳秒数。<br/>- true:表示返回结果为纳秒数(ns)。 <br/>- false:表示返回结果为毫秒数(ms)。 | | isNano | boolean | 否 | 返回结果是否为纳秒数。<br/>默认值为false。<br/>- true:表示返回结果为纳秒数(ns)。 <br/>- false:表示返回结果为毫秒数(ms)。 |
**返回值:** **返回值:**
...@@ -348,7 +348,7 @@ getRealTime(isNano?: boolean): Promise&lt;number&gt; ...@@ -348,7 +348,7 @@ getRealTime(isNano?: boolean): Promise&lt;number&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------- | ---- | ------------------------------- | | ------ | ------- | ---- | ------------------------------- |
| isNano | boolean | 否 | 返回结果是否为纳秒数。<br/>- true:表示返回结果为纳秒数(ns)。 <br/>- false:表示返回结果为毫秒数(ms)。 | | isNano | boolean | 否 | 返回结果是否为纳秒数。<br/>默认值为false。<br/>- true:表示返回结果为纳秒数(ns)。 <br/>- false:表示返回结果为毫秒数(ms)。 |
**返回值:** **返回值:**
......
...@@ -191,7 +191,7 @@ getCurrentTime(isNano?: boolean): Promise&lt;number&gt; ...@@ -191,7 +191,7 @@ getCurrentTime(isNano?: boolean): Promise&lt;number&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------- | ---- | ------------------------------------------------------------ | | ------ | ------- | ---- | ------------------------------------------------------------ |
| isNano | boolean | 否 | 返回结果是否为纳秒数。<br/>- true:表示返回结果为纳秒数(ns)。 <br/>- false:表示返回结果为毫秒数(ms)。 | | isNano | boolean | 否 | 返回结果是否为纳秒数。<br/>默认值为false。<br/>- true:表示返回结果为纳秒数(ns)。 <br/>- false:表示返回结果为毫秒数(ms)。 |
**返回值:** **返回值:**
...@@ -310,7 +310,7 @@ getRealActiveTime(isNano?: boolean): Promise&lt;number&gt; ...@@ -310,7 +310,7 @@ getRealActiveTime(isNano?: boolean): Promise&lt;number&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------- | ---- | ------------------------------------------------------------ | | ------ | ------- | ---- | ------------------------------------------------------------ |
| isNano | boolean | 否 | 返回结果是否为纳秒数。<br/>- true:表示返回结果为纳秒数(ns)。 <br/>- false:表示返回结果为毫秒数(ms)。 | | isNano | boolean | 否 | 返回结果是否为纳秒数。<br/>默认值为false。<br/>- true:表示返回结果为纳秒数(ns)。 <br/>- false:表示返回结果为毫秒数(ms)。 |
**返回值:** **返回值:**
...@@ -429,7 +429,7 @@ getRealTime(isNano?: boolean): Promise&lt;number&gt; ...@@ -429,7 +429,7 @@ getRealTime(isNano?: boolean): Promise&lt;number&gt;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------- | ---- | ------------------------------------------------------------ | | ------ | ------- | ---- | ------------------------------------------------------------ |
| isNano | boolean | 否 | 返回结果是否为纳秒数。<br/>- true:表示返回结果为纳秒数(ns)。 <br/>- false:表示返回结果为毫秒数(ms)。 | | isNano | boolean | 否 | 返回结果是否为纳秒数。<br/>默认值为false。<br/>- true:表示返回结果为纳秒数(ns)。 <br/>- false:表示返回结果为毫秒数(ms)。 |
**返回值:** **返回值:**
......
...@@ -23,9 +23,9 @@ Gauge(options:{value: number, min?: number, max?: number}) ...@@ -23,9 +23,9 @@ Gauge(options:{value: number, min?: number, max?: number})
| 参数名 | 参数类型 | 必填 | 参数描述 | | 参数名 | 参数类型 | 必填 | 参数描述 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | number | 是 | 量规图的当前数据值,即图中指针指向位置。用于组件创建时量规图初始值的预置。 | | value | number | 是 | 量规图的当前数据值,即图中指针指向位置。用于组件创建时量规图初始值的预置。<br/>**说明:** <br/>value不在min和max范围内时使用min作为默认值。 |
| min | number | 否 | 当前数据段最小值。<br/>默认值:0 | | min | number | 否 | 当前数据段最小值。<br/>默认值:0 |
| max | number | 否 | 当前数据段最大值。<br/>默认值:100 | | max | number | 否 | 当前数据段最大值。<br/>默认值:100<br/>**说明:** <br/>max小于min时使用默认值0和100。<br/>max和min支持负数。 |
## 属性 ## 属性
...@@ -36,8 +36,8 @@ Gauge(options:{value: number, min?: number, max?: number}) ...@@ -36,8 +36,8 @@ Gauge(options:{value: number, min?: number, max?: number})
| value | number | 设置量规图的数据值,可用于动态修改量规图的数据值。<br/>默认值:0<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | value | number | 设置量规图的数据值,可用于动态修改量规图的数据值。<br/>默认值:0<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| startAngle | number | 设置起始角度位置,时钟0点为0度,顺时针方向为正角度。<br/>默认值:0<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | startAngle | number | 设置起始角度位置,时钟0点为0度,顺时针方向为正角度。<br/>默认值:0<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| endAngle | number | 设置终止角度位置,时钟0点为0度,顺时针方向为正角度。<br/>默认值:360<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | endAngle | number | 设置终止角度位置,时钟0点为0度,顺时针方向为正角度。<br/>默认值:360<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| colors | Array&lt;[ColorStop](#colorstop)&gt; | 设置量规图的颜色,支持分段颜色设置。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | colors | Array&lt;[ColorStop](#colorstop)&gt; | 设置量规图的颜色,支持分段颜色设置。<br/>默认值:Color.Black<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| strokeWidth | Length | 设置环形量规图的环形厚度。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | strokeWidth | Length | 设置环形量规图的环形厚度。<br/>默认值:4<br/>单位:vp<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br/>**说明:** <br/>设置小于0的值时,按默认值显示。<br/>不支持百分比。 |
## ColorStop ## ColorStop
......
...@@ -412,3 +412,86 @@ struct LoadImageExample { ...@@ -412,3 +412,86 @@ struct LoadImageExample {
} }
} }
``` ```
### 为图片增加滤镜
```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)
\ No newline at end of file
...@@ -19,7 +19,7 @@ Search(options?: { value?: string; placeholder?: string; icon?: string; controll ...@@ -19,7 +19,7 @@ Search(options?: { value?: string; placeholder?: string; icon?: string; controll
| 参数名 | 参数类型 | 必填 | 参数描述 | | 参数名 | 参数类型 | 必填 | 参数描述 |
| ---------- | ---------------- | ---- | ------------------------------------------------------------ | | ---------- | ---------------- | ---- | ------------------------------------------------------------ |
| value | string | 否 | 设置当前显示的搜索文本内容。 | | value | string | 否 | 设置当前显示的搜索文本内容。 |
| icon | string | 否 | 设置搜索图标路径,默认使用系统搜索图标。<br/>图标所支持的图片类型能力参考[Image](ts-basic-components-image.md)组件。 | | icon | string | 否 | 设置搜索图标路径,默认使用系统搜索图标。<br/>**说明:** <br/>icon的数据源,支持本地图片和网络图片。<br/>-&nbsp;支持的图片格式包括png、jpg、bmp、svg、gif和pixelmap。<br/>-&nbsp;支持Base64字符串。格式data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data], 其中[base64 data]为Base64字符串数据。 |
| controller | SearchController | 否 | 设置Search组件控制器。 | | controller | SearchController | 否 | 设置Search组件控制器。 |
## 属性 ## 属性
......
...@@ -57,7 +57,7 @@ Slider(options?: {value?: number, min?: number, max?: number, step?: number, sty ...@@ -57,7 +57,7 @@ Slider(options?: {value?: number, min?: number, max?: number, step?: number, sty
| 名称 | 功能描述 | | 名称 | 功能描述 |
| -------- | -------- | | -------- | -------- |
| onChange(callback:&nbsp;(value:&nbsp;number,&nbsp;mode:&nbsp;SliderChangeMode)&nbsp;=&gt;&nbsp;void) | Slider拖到或点击时触发事件回调。<br/>value:当前滑动进度值。若返回值有小数,可使用number.toFixed()方法将数据处理为预期的精度。<br/>mode:事件触发的相关状态值。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br/>**说明:** <br/>Begin和End状态当手势点击时都会触发,Moving和Click状态当value值发生变换时触发。<br/>当连贯动作为拖动动作时,不触发Click状态。<br/>value值的变化范围为对应步长steps数组。 | | onChange(callback:&nbsp;(value:&nbsp;number,&nbsp;mode:&nbsp;SliderChangeMode)&nbsp;=&gt;&nbsp;void) | Slider拖动或点击时触发事件回调。<br/>value:当前滑动进度值。若返回值有小数,可使用number.toFixed()方法将数据处理为预期的精度。<br/>mode:事件触发的相关状态值。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br/>**说明:** <br/>Begin和End状态当手势点击时都会触发,Moving和Click状态当value值发生变化时触发。<br/>当连贯动作为拖动动作时,不触发Click状态。<br/>value值的变化范围为对应步长steps数组。 |
## SliderChangeMode枚举说明 ## SliderChangeMode枚举说明
......
...@@ -24,7 +24,7 @@ StepperItem() ...@@ -24,7 +24,7 @@ StepperItem()
| -------- | -------- | -------- | | -------- | -------- | -------- |
| prevLabel | string | 设置左侧文本按钮内容,第一页没有左侧文本按钮,当步骤导航器大于一页时,除第一页外默认值都为“返回”。 | | prevLabel | string | 设置左侧文本按钮内容,第一页没有左侧文本按钮,当步骤导航器大于一页时,除第一页外默认值都为“返回”。 |
| nextLabel | string | 设置右侧文本按钮内容,最后一页默认值为“开始”,其余页默认值为“下一步”。 | | nextLabel | string | 设置右侧文本按钮内容,最后一页默认值为“开始”,其余页默认值为“下一步”。 |
| status | ItemState | 步骤导航器nextLabel的显示状态<br/>默认值:ItemState.Normal | | status | [ItemState](#itemstate枚举说明) | 步骤导航器nextLabel的显示状态,参数可选<br/>默认值:ItemState.Normal |
## ItemState枚举说明 ## ItemState枚举说明
......
...@@ -30,7 +30,7 @@ Text(content?: string | Resource) ...@@ -30,7 +30,7 @@ Text(content?: string | Resource)
| 名称 | 参数类型 | 描述 | | 名称 | 参数类型 | 描述 |
| ----------------------- | ----------------------------------- | ------------------------------------------- | | ----------------------- | ----------------------------------- | ------------------------------------------- |
| textAlign | [TextAlign](ts-appendix-enums.md#textalign) | 设置文本段落在水平方向的对齐方式<br/>默认值:TextAlign.Start<br/>说明:<br/>文本段落宽度占满Text组件宽度;可通过[align](ts-universal-attributes-location.md)属性控制文本段落在垂直方向上的位置。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | textAlign | [TextAlign](ts-appendix-enums.md#textalign) | 设置文本段落在水平方向的对齐方式<br/>默认值:TextAlign.Start<br/>说明:<br/>文本段落宽度占满Text组件宽度;可通过[align](ts-universal-attributes-location.md)属性控制文本段落在垂直方向上的位置,此组件中不可通过align属性控制文本段落在水平方向上的位置,即align属性中Alignment.TopStart、Alignment.Top、Alignment.TopEnd效果相同,控制内容在顶部,Alignment.Start、Alignment.Center、Alignment.End效果相同,控制内容垂直居中,Alignment.BottomStart、Alignment.Bottom、Alignment.BottomEnd效果相同,控制内容在底部。结合TextAlign属性可控制内容在水平方向的位置<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| textOverflow | {overflow:&nbsp;[TextOverflow](ts-appendix-enums.md#textoverflow)} | 设置文本超长时的显示方式。<br/>默认值:{overflow:&nbsp;TextOverflow.Clip}<br/>**说明:**<br/>文本截断是按字截断。例如,英文以单词为最小单位进行截断,若需要以字母为单位进行截断,可在字母间添加零宽空格:\u200B。<br />需配合`maxLines`使用,单独设置不生效。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | textOverflow | {overflow:&nbsp;[TextOverflow](ts-appendix-enums.md#textoverflow)} | 设置文本超长时的显示方式。<br/>默认值:{overflow:&nbsp;TextOverflow.Clip}<br/>**说明:**<br/>文本截断是按字截断。例如,英文以单词为最小单位进行截断,若需要以字母为单位进行截断,可在字母间添加零宽空格:\u200B。<br />需配合`maxLines`使用,单独设置不生效。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| maxLines | number | 设置文本的最大行数。<br />默认值:Infinity<br/>**说明:**<br />默认情况下,文本是自动折行的,如果指定此参数,则文本最多不会超过指定的行。如果有多余的文本,可以通过 `textOverflow`来指定截断方式。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | maxLines | number | 设置文本的最大行数。<br />默认值:Infinity<br/>**说明:**<br />默认情况下,文本是自动折行的,如果指定此参数,则文本最多不会超过指定的行。如果有多余的文本,可以通过 `textOverflow`来指定截断方式。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| lineHeight | string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;[Resource](ts-types.md#resource) | 设置文本的文本行高,设置值不大于0时,不限制文本行高,自适应字体大小,Length为number类型时单位为fp。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | lineHeight | string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;[Resource](ts-types.md#resource) | 设置文本的文本行高,设置值不大于0时,不限制文本行高,自适应字体大小,Length为number类型时单位为fp。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
......
...@@ -44,7 +44,7 @@ Swiper(controller?: SwiperController) ...@@ -44,7 +44,7 @@ Swiper(controller?: SwiperController)
| displayMode | SwiperDisplayMode | 主轴方向上元素排列的模式,优先以displayCount设置的个数显示,displayCount未设置时本属性生效。<br/>默认值:SwiperDisplayMode.Stretch | | displayMode | SwiperDisplayMode | 主轴方向上元素排列的模式,优先以displayCount设置的个数显示,displayCount未设置时本属性生效。<br/>默认值:SwiperDisplayMode.Stretch |
| cachedCount<sup>8+</sup> | number | 设置预加载子组件个数。<br/>默认值:1<br/>**说明:** <br/>cachedCount已经做了预加载的优化,不建议与[LazyForEach](../../quick-start/arkts-rendering-control-lazyforeach.md)一起使用。 | | cachedCount<sup>8+</sup> | number | 设置预加载子组件个数。<br/>默认值:1<br/>**说明:** <br/>cachedCount已经做了预加载的优化,不建议与[LazyForEach](../../quick-start/arkts-rendering-control-lazyforeach.md)一起使用。 |
| disableSwipe<sup>8+</sup> | boolean | 禁用组件滑动切换功能。<br/>默认值:false | | disableSwipe<sup>8+</sup> | boolean | 禁用组件滑动切换功能。<br/>默认值:false |
| curve<sup>8+</sup> | [Curve](ts-appendix-enums.md#curve) \| string | 设置Swiper的动画曲线,默认为淡入淡出曲线,常用曲线参考[Curve枚举说明](ts-appendix-enums.md#curve),也可以通过[插值计算](../apis/js-apis-curve.md)模块提供的接口创建自定义的插值曲线对象。<br/>默认值:Curve.Ease | | curve<sup>8+</sup> | [Curve](ts-appendix-enums.md#curve) \| string | 设置Swiper的动画曲线,默认为淡入淡出曲线,常用曲线参考[Curve枚举说明](ts-appendix-enums.md#curve),也可以通过[插值计算](../apis/js-apis-curve.md)模块提供的接口创建自定义的插值曲线对象。<br/>默认值:Curve.Linear |
| indicatorStyle<sup>8+</sup> | {<br/>left?:&nbsp;[Length](ts-types.md#length),<br/>top?:&nbsp;[Length](ts-types.md#length),<br/>right?:&nbsp;[Length](ts-types.md#length),<br/>bottom?:&nbsp;[Length](ts-types.md#length),<br/>size?:&nbsp;[Length](ts-types.md#length),<br/>mask?:&nbsp;boolean,<br/>color?:&nbsp;[ResourceColor](ts-types.md),<br/>selectedColor?:&nbsp;[ResourceColor](ts-types.md)<br/>} | 设置导航点样式:<br/>\- left: 设置导航点距离Swiper组件左边的距离。<br/>\- top: 设置导航点距离Swiper组件顶部的距离。<br/>\- right: 设置导航点距离Swiper组件右边的距离。<br/>\- bottom: 设置导航点距离Swiper组件底部的距离。<br/>\- size: 设置导航点的直径。<br/>\- mask: 设置是否显示导航点蒙层样式。<br/>\- color: 设置导航点的颜色。<br/>\- selectedColor: 设置选中的导航点的颜色。 | | indicatorStyle<sup>8+</sup> | {<br/>left?:&nbsp;[Length](ts-types.md#length),<br/>top?:&nbsp;[Length](ts-types.md#length),<br/>right?:&nbsp;[Length](ts-types.md#length),<br/>bottom?:&nbsp;[Length](ts-types.md#length),<br/>size?:&nbsp;[Length](ts-types.md#length),<br/>mask?:&nbsp;boolean,<br/>color?:&nbsp;[ResourceColor](ts-types.md),<br/>selectedColor?:&nbsp;[ResourceColor](ts-types.md)<br/>} | 设置导航点样式:<br/>\- left: 设置导航点距离Swiper组件左边的距离。<br/>\- top: 设置导航点距离Swiper组件顶部的距离。<br/>\- right: 设置导航点距离Swiper组件右边的距离。<br/>\- bottom: 设置导航点距离Swiper组件底部的距离。<br/>\- size: 设置导航点的直径。<br/>\- mask: 设置是否显示导航点蒙层样式。<br/>\- color: 设置导航点的颜色。<br/>\- selectedColor: 设置选中的导航点的颜色。 |
| displayCount<sup>8+</sup> | number\|string | 设置一页内元素显示个数。<br/>默认值:1<br/>**说明:** <br/>字符串类型仅支持设置为'auto',显示效果同SwiperDisplayMode.AutoLinear。<br/>使用number类型时,子组件按照主轴均分Swiper宽度(减去displayCount-1的itemSpace)的方式进行主轴拉伸(收缩)布局。 | | displayCount<sup>8+</sup> | number\|string | 设置一页内元素显示个数。<br/>默认值:1<br/>**说明:** <br/>字符串类型仅支持设置为'auto',显示效果同SwiperDisplayMode.AutoLinear。<br/>使用number类型时,子组件按照主轴均分Swiper宽度(减去displayCount-1的itemSpace)的方式进行主轴拉伸(收缩)布局。 |
| effectMode<sup>8+</sup> | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 滑动效果,目前支持的滑动效果参见EdgeEffect的枚举说明。<br/>默认值:EdgeEffect.Spring<br/>**说明:** <br/>控制器接口调用时不生效回弹。 | | effectMode<sup>8+</sup> | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 滑动效果,目前支持的滑动效果参见EdgeEffect的枚举说明。<br/>默认值:EdgeEffect.Spring<br/>**说明:** <br/>控制器接口调用时不生效回弹。 |
...@@ -172,4 +172,4 @@ struct SwiperExample { ...@@ -172,4 +172,4 @@ struct SwiperExample {
} }
``` ```
![swiper](figures/swiper.gif) ![swiper](figures/swiper.gif)
\ No newline at end of file
...@@ -41,8 +41,8 @@ Tabs(value?: {barPosition?: BarPosition, index?: number, controller?: [TabsContr ...@@ -41,8 +41,8 @@ Tabs(value?: {barPosition?: BarPosition, index?: number, controller?: [TabsContr
| vertical | boolean | 设置为false是为横向Tabs,设置为true时为纵向Tabs。<br/>默认值:false | | vertical | boolean | 设置为false是为横向Tabs,设置为true时为纵向Tabs。<br/>默认值:false |
| scrollable | boolean | 设置为true时可以通过滑动页面进行页面切换,为false时不可滑动切换页面。<br/>默认值:true | | scrollable | boolean | 设置为true时可以通过滑动页面进行页面切换,为false时不可滑动切换页面。<br/>默认值:true |
| barMode | BarMode | TabBar布局模式,具体描述见BarMode枚举说明。<br/>默认值:BarMode.Fixed | | barMode | BarMode | TabBar布局模式,具体描述见BarMode枚举说明。<br/>默认值:BarMode.Fixed |
| barWidth | number&nbsp;\|&nbsp;Length<sup>8+</sup> | TabBar的宽度值<br/>**说明:** <br/>设置为小于0或大于Tabs宽度值时,按默认值显示。 | | barWidth | number&nbsp;\|&nbsp;Length<sup>8+</sup> | TabBar的宽度值。<br/>默认值:<br/>未设置带样式的TabBar且vertical属性为false时,默认值为Tabs的宽度。<br/>未设置带样式的TabBar且vertical属性为true时,默认值为56vp。<br/>设置SubTabbarStyle样式且vertical属性为false时,默认值为Tabs的宽度。<br/>设置SubTabbarStyle样式且vertical属性为true时,默认值为56vp。<br/>设置BottomTabbarStyle样式且vertical属性为true时,默认值为96vp。<br/>设置BottomTabbarStyle样式且vertical属性为false时,默认值为Tabs的宽度<br/>**说明:** <br/>设置为小于0或大于Tabs宽度值时,按默认值显示。 |
| barHeight | number&nbsp;\|&nbsp;Length<sup>8+</sup> | TabBar的高度值。<br/>**说明:** <br/>设置为小于0或大于Tabs宽度值时,按默认值显示。 | | barHeight | number&nbsp;\|&nbsp;Length<sup>8+</sup> | TabBar的高度值。<br/>默认值:<br/>未设置带样式的TabBar且vertical属性为false时,默认值为56vp。<br/>未设置带样式的TabBar且vertical属性为true时,默认值为Tabs的高度。<br/>设置SubTabbarStyle样式且vertical属性为false时,默认值为56vp。<br/>设置SubTabbarStyle样式且vertical属性为true时,默认值为Tabs的高度。<br/>设置BottomTabbarStyle样式且vertical属性为true时,默认值为Tabs的高度。<br/>设置BottomTabbarStyle样式且vertical属性为false时,默认值为56vp。<br/>**说明:** <br/>设置为小于0或大于Tabs高度值时,按默认值显示。|
| animationDuration | number | TabContent滑动动画时长。不设置时,点击切换页签无动画,滑动切换有动画;设置时,点击切换和滑动切换都有动画。<br/>默认值:300<br/>**说明:** <br/>设置为小于0或百分比时,按默认值显示。 | | animationDuration | number | TabContent滑动动画时长。不设置时,点击切换页签无动画,滑动切换有动画;设置时,点击切换和滑动切换都有动画。<br/>默认值:300<br/>**说明:** <br/>设置为小于0或百分比时,按默认值显示。 |
## BarMode枚举说明 ## BarMode枚举说明
......
...@@ -106,9 +106,10 @@ struct CustomDialogUser { ...@@ -106,9 +106,10 @@ struct CustomDialogUser {
customStyle: false customStyle: false
}) })
// 在自定义组件即将析构销毁时将dialogControlle删除和置空
aboutToDisappear() { aboutToDisappear() {
delete this.dialogController, delete this.dialogController, // 删除dialogController
this.dialogController = undefined this.dialogController = undefined // 将dialogController置空
} }
onCancel() { onCancel() {
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
| flexGrow | number | 设置父容器的剩余空间分配给此属性所在组件的比例。<br/>默认值:0<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | flexGrow | number | 设置父容器的剩余空间分配给此属性所在组件的比例。<br/>默认值:0<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| flexShrink | number | 设置父容器压缩尺寸分配给此属性所在组件的比例。<br/>父容器为Row、Column时,默认值:0<br/> 父容器为flex时,默认值:1<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | flexShrink | number | 设置父容器压缩尺寸分配给此属性所在组件的比例。<br/>父容器为Row、Column时,默认值:0<br/> 父容器为flex时,默认值:1<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| alignSelf | [ItemAlign](ts-appendix-enums.md#itemalign) | 子组件在父容器交叉轴的对齐格式,会覆盖Flex布局容器中的alignItems设置。<br/>默认值:ItemAlign.Auto<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | alignSelf | [ItemAlign](ts-appendix-enums.md#itemalign) | 子组件在父容器交叉轴的对齐格式,会覆盖Flex布局容器中的alignItems设置。<br/>默认值:ItemAlign.Auto<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| layoutWeight | number&nbsp;\|&nbsp;string | 父容器尺寸确定时,设置了layoutWeight属性的子元素与兄弟元素占主轴尺寸按照权重进行分配,忽略元素本身尺寸设置,表示自适应占满剩余空间。<br>默认值:0<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br/>**说明:**<br/>仅在Row/Column/Flex布局中生效。<br/>可选值为大于等于0的数字,或者可以转换为数字的字符串。 |
## 示例 ## 示例
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
| padding | [Padding](ts-types.md#padding)&nbsp;\|&nbsp;[Length](ts-types.md#length) | 设置内边距属性。<br/>参数为Length类型时,四个方向内边距同时生效。<br>默认值:0 <br>padding设置百分比时,上下左右内边距均以父容器的width作为基础值。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | padding | [Padding](ts-types.md#padding)&nbsp;\|&nbsp;[Length](ts-types.md#length) | 设置内边距属性。<br/>参数为Length类型时,四个方向内边距同时生效。<br>默认值:0 <br>padding设置百分比时,上下左右内边距均以父容器的width作为基础值。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| margin | [Margin](ts-types.md#margin)&nbsp;\|&nbsp;[Length](ts-types.md#length) | 设置外边距属性。<br/>参数为Length类型时,四个方向外边距同时生效。<br>默认值:0 <br>margin设置百分比时,上下左右外边距均以父容器的width作为基础值。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | margin | [Margin](ts-types.md#margin)&nbsp;\|&nbsp;[Length](ts-types.md#length) | 设置外边距属性。<br/>参数为Length类型时,四个方向外边距同时生效。<br>默认值:0 <br>margin设置百分比时,上下左右外边距均以父容器的width作为基础值。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| constraintSize | {<br/>minWidth?:&nbsp;[Length](ts-types.md#length),<br/>maxWidth?:&nbsp;[Length](ts-types.md#length),<br/>minHeight?:&nbsp;[Length](ts-types.md#length),<br/>maxHeight?:&nbsp;[Length](ts-types.md#length)<br/>} | 设置约束尺寸,组件布局时,进行尺寸范围限制。constraintSize的优先级高于Width和Height。若设置的minWidth大于maxWidth,则minWidth生效,minHeight与maxHeight同理。<br>默认值:<br>{<br/>minWidth:&nbsp;0,<br/>maxWidth:&nbsp;Infinity,<br/>minHeight:&nbsp;0,<br/>maxHeight:&nbsp;Infinity<br/>}<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | constraintSize | {<br/>minWidth?:&nbsp;[Length](ts-types.md#length),<br/>maxWidth?:&nbsp;[Length](ts-types.md#length),<br/>minHeight?:&nbsp;[Length](ts-types.md#length),<br/>maxHeight?:&nbsp;[Length](ts-types.md#length)<br/>} | 设置约束尺寸,组件布局时,进行尺寸范围限制。constraintSize的优先级高于Width和Height。若设置的minWidth大于maxWidth,则minWidth生效,minHeight与maxHeight同理。<br>默认值:<br>{<br/>minWidth:&nbsp;0,<br/>maxWidth:&nbsp;Infinity,<br/>minHeight:&nbsp;0,<br/>maxHeight:&nbsp;Infinity<br/>}<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| layoutWeight | number&nbsp;\|&nbsp;string | 父容器尺寸确定时,设置了layoutWeight属性的子元素与兄弟元素占主轴尺寸按照权重进行分配,忽略元素本身尺寸设置,表示自适应占满剩余空间。<br>默认值:0<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br/>**说明:**<br/>仅在Row/Column/Flex布局中生效。<br/>可选值为大于等于0的数字,或者可以转换为数字的字符串。 |
## 示例 ## 示例
......
...@@ -157,7 +157,7 @@ pageTransition() { ...@@ -157,7 +157,7 @@ pageTransition() {
```ts ```ts
// page A // PageTransitionSrc1
import router from '@ohos.router'; import router from '@ohos.router';
@Entry @Entry
@Component @Component
...@@ -209,7 +209,7 @@ struct PageTransitionSrc1 { ...@@ -209,7 +209,7 @@ struct PageTransitionSrc1 {
```ts ```ts
// page B // PageTransitionDst1
import router from '@ohos.router'; import router from '@ohos.router';
@Entry @Entry
@Component @Component
...@@ -267,7 +267,7 @@ struct PageTransitionDst1 { ...@@ -267,7 +267,7 @@ struct PageTransitionDst1 {
```ts ```ts
// page A // PageTransitionSrc2
import router from '@ohos.router'; import router from '@ohos.router';
@Entry @Entry
@Component @Component
...@@ -313,7 +313,7 @@ struct PageTransitionSrc2 { ...@@ -313,7 +313,7 @@ struct PageTransitionSrc2 {
```ts ```ts
// page B // PageTransitionDst2
import router from '@ohos.router'; import router from '@ohos.router';
@Entry @Entry
@Component @Component
......
...@@ -28,7 +28,7 @@ Button('click for Menu') ...@@ -28,7 +28,7 @@ Button('click for Menu')
## 创建自定义样式的菜单 ## 创建自定义样式的菜单
当默认样式不满足开发需求时,可使用\@CustomBuilder自定义菜单内容。可通过bindContextMenu接口进行菜单的自定义。 当默认样式不满足开发需求时,可使用\@CustomBuilder自定义菜单内容。可通过bindMenu接口进行菜单的自定义。
### \@Builder开发菜单内的内容 ### \@Builder开发菜单内的内容
...@@ -70,7 +70,7 @@ MyMenu(){ ...@@ -70,7 +70,7 @@ MyMenu(){
startIcon: $r("app.media.view_list_filled"), startIcon: $r("app.media.view_list_filled"),
content: "菜单选项", content: "菜单选项",
endIcon: $r("app.media.arrow_right_filled"), endIcon: $r("app.media.arrow_right_filled"),
builder: this.SubMenu.bind(this)\ builder: this.SubMenu.bind(this)
}) })
} }
MenuItem({ MenuItem({
...@@ -101,7 +101,7 @@ Button('click for Menu') ...@@ -101,7 +101,7 @@ Button('click for Menu')
通过bindContextMenu接口进行菜单的自定义及菜单弹出的触发方式:右键或长按。使用bindContextMenu弹出的菜单项是在独立子窗口内的,可显示在应用窗口外部。 通过bindContextMenu接口进行菜单的自定义及菜单弹出的触发方式:右键或长按。使用bindContextMenu弹出的菜单项是在独立子窗口内的,可显示在应用窗口外部。
- [@Builder开发菜单内的内容](#builder开发菜单内的内容)与上文写法相同。 - @Builder开发菜单内的内容与上文写法相同。
- 确认菜单的弹出方式,使用bindContextMenu属性绑定组件。示例中为右键弹出菜单。 - 确认菜单的弹出方式,使用bindContextMenu属性绑定组件。示例中为右键弹出菜单。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册