提交 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 @@
- ExtensionAbility Component
- [ExtensionAbility Component Overview](extensionability-overview.md)
- [ServiceExtensionAbility](serviceextensionability.md)
- [DataShareExtensionAbility (for System Applications Only)](datashareextensionability.md)
- [AccessibilityExtensionAbility](accessibilityextensionability.md)
- [EnterpriseAdminExtensionAbility](enterprise-extensionAbility.md)
- [InputMethodExtensionAbility](inputmethodextentionability.md)
......@@ -37,9 +36,9 @@
- [Applying Custom Drawing in the Widget](arkts-ui-widget-page-custom-drawing.md)
- Widget Event Development
- [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 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 Overview](arkts-ui-widget-interaction-overview.md)
- [Configuring a Widget to Update Periodically](arkts-ui-widget-update-by-time.md)
......@@ -61,8 +60,9 @@
- [Continuation Overview](inter-device-interaction-hop-overview.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)
- IPC
- [Process Model](process-model-stage.md)
- [Subscribing to System Environment Variable Changes](subscribe-system-environment-variable-changes.md)
- Process Model
- [Process Model Overview](process-model-stage.md)
- Common Events
- [Introduction to Common Events](common-event-overview.md)
- Common Event Subscription
......@@ -72,14 +72,16 @@
- [Unsubscribing from Common Events](common-event-unsubscription.md)
- [Publishing Common Events](common-event-publish.md)
- [Background Services](background-services.md)
- Inter-Thread Communication
- [Thread Model](thread-model-stage.md)
- Thread Model
- [Thread Model Overview](thread-model-stage.md)
- [Using Emitter for Inter-Thread Communication](itc-with-emitter.md)
- [Using Worker for Inter-Thread Communication](itc-with-worker.md)
- Mission Management
- [Mission Management Scenarios](mission-management-overview.md)
- [Mission Management and Launch Type](mission-management-launch-type.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 Overview](fa-model-development-overview.md)
- FA Mode Application Components
......@@ -116,12 +118,12 @@
- [Context](application-context-fa.md)
- [Want](want-fa.md)
- [Component Startup Rules](component-startup-rules-fa.md)
- IPC
- [Process Model](process-model-fa.md)
- Process Model
- [Process Model Overview](process-model-fa.md)
- [Common Events](common-event-fa.md)
- [Background Services](rpc.md)
- Inter-Thread Communication
- [Thread Model](thread-model-fa.md)
- Thread Model
- [Thread Model Overview](thread-model-fa.md)
- [Inter-Thread Communication](itc-fa-overview.md)
- [Mission Management](mission-management-fa.md)
- Development of Component Interaction Between the FA Model and Stage Model
......
......@@ -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.
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.
......
# 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
![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
![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
......@@ -33,4 +33,3 @@ Every mission retains a snapshot of the UIAbility instance. After the UIAbility
> **NOTE**
>
> The **specified** mode is supported in the stage model only.
......@@ -4,7 +4,7 @@
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.
......@@ -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**.
**Figure 1** Mission management
![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
- 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.
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).
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'
let listener = {
// Listen for mission creation.
onMissionCreated: function (mission) {
console.info("--------onMissionCreated-------")
},
// Listen for mission destruction.
onMissionDestroyed: function (mission) {
console.info("--------onMissionDestroyed-------")
},
// Listen for mission snapshot changes.
onMissionSnapshotChanged: function (mission) {
console.info("--------onMissionSnapshotChanged-------")
},
// Listen for switching the mission to the foreground.
onMissionMovedToFront: function (mission) {
console.info("--------onMissionMovedToFront-------")
},
// Listen for mission icon changes.
onMissionIconUpdated: function (mission, icon) {
console.info("--------onMissionIconUpdated-------")
},
// Listen for mission name changes.
onMissionLabelUpdated: function (mission) {
console.info("--------onMissionLabelUpdated-------")
},
// Listen for mission closure events.
onMissionClosed: function (mission) {
console.info("--------onMissionClosed-------")
}
};
// 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) => {
console.info("getMissionInfos is called, error.code = " + error.code);
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.
let mission = missionManager.getMissionInfo("", missionId).catch(function (err) {
console.info(err);
});
// 4. Obtain the mission snapshot.
missionManager.getMissionSnapShot("", missionId, (error, snapshot) => {
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) => {
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(() => {
console.info("lockMission is called ");
});
missionManager.unlockMission(missionId).then(() => {
console.info("unlockMission is called ");
});
// 7. Switch the mission to the foreground.
missionManager.moveMissionToFront(missionId).then(() => {
console.info("moveMissionToFront is called ");
});
// 8. Clear a single mission.
missionManager.clearMission(missionId).then(() => {
console.info("clearMission is called ");
});
// 9. Clear all missions.
missionManager.clearAllMissions().catch(function (err) {
console.info(err);
});
// 10. Deregister the mission change listener.
missionManager.off('mission', listenerId, (error) => {
console.info("unregisterMissionListener");
})
```
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).
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.
```ts
import missionManager from '@ohos.app.ability.missionManager'
let listener = {
// Listen for mission creation.
onMissionCreated: function (mission) {
console.info("--------onMissionCreated-------")
},
// Listen for mission destruction.
onMissionDestroyed: function (mission) {
console.info("--------onMissionDestroyed-------")
},
// Listen for mission snapshot changes.
onMissionSnapshotChanged: function (mission) {
console.info("--------onMissionSnapshotChanged-------")
},
// Listen for switching the mission to the foreground.
onMissionMovedToFront: function (mission) {
console.info("--------onMissionMovedToFront-------")
},
// Listen for mission icon changes.
onMissionIconUpdated: function (mission, icon) {
console.info("--------onMissionIconUpdated-------")
},
// Listen for mission name changes.
onMissionLabelUpdated: function (mission) {
console.info("--------onMissionLabelUpdated-------")
},
// Listen for mission closure events.
onMissionClosed: function (mission) {
console.info("--------onMissionClosed-------")
}
};
// 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) => {
console.info("getMissionInfos is called, error.code = " + error.code);
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.
let mission = missionManager.getMissionInfo("", missionId).catch(function (err) {
console.info(err);
});
// 4. Obtain the mission snapshot.
missionManager.getMissionSnapShot("", missionId, (error, snapshot) => {
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) => {
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(() => {
console.info("lockMission is called ");
});
missionManager.unlockMission(missionId).then(() => {
console.info("unlockMission is called ");
});
// 7. Switch the mission to the foreground.
missionManager.moveMissionToFront(missionId).then(() => {
console.info("moveMissionToFront is called ");
});
// 8. Clear a single mission.
missionManager.clearMission(missionId).then(() => {
console.info("clearMission is called ");
});
// 9. Clear all missions.
missionManager.clearAllMissions().catch(function (err) {
console.info(err);
});
// 10. Deregister the mission change listener.
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.
......
# Process Model (Stage Model)
# Process Model Overview (Stage Model)
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:
......
# Thread Model (Stage Model)
# Thread Model Overview (Stage Model)
For an OpenHarmony application, each process has a main thread to provide the following functionalities:
......
......@@ -3,7 +3,7 @@
## 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.
......
......@@ -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 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
......
......@@ -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.
## 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
| \@Observed Decorator| Description |
......@@ -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.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**:
......@@ -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.
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
......@@ -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
......
......@@ -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.
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.
......@@ -129,11 +129,11 @@ struct MyComponent {
build() {
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) {
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(() => {
this.showChild = false;
})
......
......@@ -75,15 +75,17 @@ interface DataChangeListener {
}
```
| Declaration | Parameter Type | Description |
| ---------------------------------------- | -------------------------------------- | ---------------------------------------- |
| 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. |
| 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.|
| 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. |
| 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. |
| 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.|
| 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.|
| Declaration | Parameter Type | Description |
| ------------------------------------------------------------ | -------------------------------------- | ------------------------------------------------------------ |
| onDataReloaded():&nbsp;void | - | Invoked when all data is reloaded. |
| 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<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.|
| 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.|
| 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.|
| 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.|
| 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
......
......@@ -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.
> **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):
......
......@@ -231,7 +231,7 @@ struct MyComponent {
Text(`${this.title.value}`)
Button(`Click to change title`).onClick(() => {
// 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(() => {
......
......@@ -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.
## 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
{
......@@ -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.
- **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**
>
> 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
- 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'
```
### 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):
- 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
- 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
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
......@@ -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
## 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
├── src
......@@ -88,7 +88,7 @@ if **Image("common/example.png")** is used in the HSP module, the **\<Image>** c
### 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.
```ts
// ibrary/src/main/ets/utils/nativeTest.ts
// library/src/main/ets/utils/nativeTest.ts
import native from "libnative.so"
export function nativeMulti(a: number, b: number) {
......@@ -103,15 +103,9 @@ export { nativeMulti } from './utils/nativeTest'
```
## 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:
```json
// 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**:
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).
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**:
```ts
// library/src/main/ets/index.ets
export { Log, add, minus } from './utils/test'
......
......@@ -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)|
| 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**)|
| [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)|
| 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|
......
......@@ -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.
* 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.
* 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
......@@ -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.
* **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**:
<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
{
"app" : {
......
......@@ -10,7 +10,7 @@
## 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)
......
......@@ -10,7 +10,7 @@
## 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)
......
......@@ -8,7 +8,7 @@
## 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)
......
......@@ -370,7 +370,7 @@ Obtains the accessibility application list. This API uses a promise to return th
> **NOTE**
>
> 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
......
......@@ -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).
## CommonEvent.publish
## CommonEvent.publish<sup>(deprecated)</sup>
publish(event: string, callback: AsyncCallback\<void>): void
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
**Parameters**
......@@ -50,14 +54,16 @@ function publishCallBack(err) {
CommonEvent.publish("event", publishCallBack);
```
## CommonEvent.publish
## CommonEvent.publish<sup>(deprecated)</sup>
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.
> **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
**Parameters**
......@@ -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. |
| 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**
......@@ -92,14 +98,16 @@ function publishCallBack(err) {
CommonEvent.publish("event", options, publishCallBack);
```
## CommonEvent.publishAsUser<sup>8+</sup>
## CommonEvent.publishAsUser<sup>(deprecated)</sup>
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.
> **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 API**: This is a system API and cannot be called by third-party applications.
......@@ -131,14 +139,16 @@ let userId = 100;
CommonEvent.publishAsUser("event", userId, publishAsUserCallBack);
```
## CommonEvent.publishAsUser<sup>8+</sup>
## CommonEvent.publishAsUser<sup>(deprecated)</sup>
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.
> **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 API**: This is a system API and cannot be called by third-party applications.
......@@ -178,14 +188,16 @@ let userId = 100;
CommonEvent.publishAsUser("event", userId, options, publishAsUserCallBack);
```
## CommonEvent.createSubscriber
## CommonEvent.createSubscriber<sup>(deprecated)</sup>
createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback\<CommonEventSubscriber>): void
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
**Parameters**
......@@ -220,14 +232,16 @@ function createSubscriberCallBack(err, commonEventSubscriber) {
CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack);
```
## CommonEvent.createSubscriber
## CommonEvent.createSubscriber<sup>(deprecated)</sup>
createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventSubscriber>
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
**Parameters**
......@@ -260,14 +274,16 @@ CommonEvent.createSubscriber(subscribeInfo).then((commonEventSubscriber) => {
});
```
## CommonEvent.subscribe
## CommonEvent.subscribe<sup>(deprecated)</sup>
subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEventData>): void
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
**Parameters**
......@@ -312,14 +328,16 @@ function createSubscriberCallBack(err, commonEventSubscriber) {
CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack);
```
## CommonEvent.unsubscribe
## CommonEvent.unsubscribe<sup>(deprecated)</sup>
unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>): void
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
**Parameters**
......@@ -370,10 +388,10 @@ function unsubscribeCallBack(err) {
}
// Create a subscriber.
CommonEvent.createSubscriber(subscribeInfo, createCB);
CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack);
// Unsubscribe from the common event.
CommonEvent.unsubscribe(subscriber, unsubscribeCB);
CommonEvent.unsubscribe(subscriber, unsubscribeCallBack);
```
## CommonEventSubscriber
......
......@@ -232,7 +232,6 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message |
| -------- | ----------------------------------------- |
| 17700004 | The specified user ID is not found. |
| 17700023 | The specified default app does not exist. |
| 17700025 | The specified type is invalid. |
......@@ -297,9 +296,9 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
```ts
import defaultAppMgr from '@ohos.bundle.defaultAppManager';
defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
bundleName: "com.example.myapplication",
bundleName: "com.test.app",
moduleName: "module01",
abilityName: "EntryAbility"
abilityName: "MainAbility"
}).then((data) => {
console.info('Operation successful.');
}).catch((error) => {
......@@ -308,9 +307,9 @@ defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
let userId = 100;
defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
bundleName: "com.example.myapplication",
bundleName: "com.test.app",
moduleName: "module01",
abilityName: "EntryAbility"
abilityName: "MainAbility"
}, userId).then((data) => {
console.info('Operation successful.');
}).catch((error) => {
......@@ -318,9 +317,9 @@ defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
});
defaultAppMgr.setDefaultApplication("image/png", {
bundleName: "com.example.myapplication",
bundleName: "com.test.app",
moduleName: "module01",
abilityName: "EntryAbility"
abilityName: "MainAbility"
}, userId).then((data) => {
console.info('Operation successful.');
}).catch((error) => {
......@@ -365,9 +364,9 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
import defaultAppMgr from '@ohos.bundle.defaultAppManager';
let userId = 100;
defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
bundleName: "com.example.myapplication",
bundleName: "com.test.app",
moduleName: "module01",
abilityName: "EntryAbility"
abilityName: "MainAbility"
}, userId, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
......@@ -377,9 +376,9 @@ defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
});
defaultAppMgr.setDefaultApplication("image/png", {
bundleName: "com.example.myapplication",
bundleName: "com.test.app",
moduleName: "module01",
abilityName: "EntryAbility"
abilityName: "MainAbility"
}, userId, (err, data) => {
if (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
| ID| Error Message |
| -------- | ---------------------------------------------- |
| 17700004 | The specified user ID is not found. |
| 17700025 | The specified type is invalid. |
| 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
```ts
import defaultAppMgr from '@ohos.bundle.defaultAppManager';
defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
bundleName: "com.example.myapplication",
bundleName: "com.test.app",
moduleName: "module01",
abilityName: "EntryAbility"
abilityName: "MainAbility"
}, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
......@@ -436,9 +434,9 @@ defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, {
});
defaultAppMgr.setDefaultApplication("image/png", {
bundleName: "com.example.myapplication",
bundleName: "com.test.app",
moduleName: "module01",
abilityName: "EntryAbility"
abilityName: "MainAbility"
}, (err, data) => {
if (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
| ID| Error Message |
| -------- | ----------------------------------- |
| 17700004 | The specified user ID is not found. |
| 17700025 | The specified type is invalid. |
**Example**
......
# @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**
>
> - 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 support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
## Modules to Import
......@@ -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.|
**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**
```js
......@@ -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.|
**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**
```js
......@@ -68,7 +85,7 @@ Obtains the root directory of the storage. This API uses an asynchronous callbac
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
......@@ -76,7 +93,16 @@ Obtains the root directory of public files. This API uses a promise to return th
| 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**
......@@ -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
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
......@@ -100,7 +126,16 @@ Obtains the root directory of public files. This API uses an asynchronous callba
| 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**
......
......@@ -41,9 +41,9 @@ Obtains the URI of a file in synchronous mode.
**Return value**
| Type | Description |
| ---------------------------- | ---------- |
| string | File URI obtained.|
| Type | Description |
| ---------------------------- | ---------- |
| string | File URI obtained.|
**Error codes**
......@@ -52,7 +52,6 @@ For details about the error codes, see [File Management Error Codes](../errorcod
| ---------------------------- | ---------- |
| 401 | The input parameter is invalid |
**Example**
```js
......
# @ohos.file.hash (File Hash Processing)
The **fileHash** module implements hash processing on files.
The **FileHash** module implements hash processing on files.
> **NOTE**
>
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
> 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
......@@ -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:
**Stage Model**
Stage Model
```js
import UIAbility from '@ohos.app.ability.UIAbility';
......@@ -30,7 +29,7 @@ export default class EntryAbility extends UIAbility {
}
```
**FA Model**
FA Model
```js
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
| --------------------- | -------------------------- |
| 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**
```js
......@@ -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. |
| 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**
```js
let filePath = pathDir + "/test.txt";
Hash.hash(filePath, "sha256", (err, str) => {
......
......@@ -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.
## Modules to Import
```js
import picker from '@ohos.file.picker';
```
......
......@@ -4,8 +4,7 @@ The **securityLabel** module provides APIs for managing data security levels of
> **NOTE**
>
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
> 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
......@@ -60,9 +59,24 @@ Sets a security label for a file in asynchronous mode. This API uses a promise t
**Return value**
| Type | Description |
| ------------------- | ---------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
| Type | Description |
| ------------------- | ---------------- |
| 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**
......@@ -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**.|
| 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**
```js
......@@ -119,6 +148,21 @@ Sets a security label for a file in synchronous mode.
| 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**.|
**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**
```js
......@@ -136,15 +180,30 @@ Obtains the security label of a file in asynchronous mode. This API uses a promi
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------- |
| path | string | Yes | Path of the target file.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------- |
| path | string | Yes | Path of the target file.|
**Return value**
| Type | Description |
| --------------------- | ------------ |
| Promise&lt;string&gt; | Security label obtained.|
| Type | Description |
| --------------------- | ------------ |
| 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**
......@@ -167,10 +226,25 @@ Obtains the security label of a file in asynchronous mode. This API uses a callb
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | -------------------------- |
| path | string | Yes | Path of the target file. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the security label obtained.|
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | -------------------------- |
| path | string | Yes | Path of the target file. |
| 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**
......@@ -184,6 +258,7 @@ Obtains the security label of a file in asynchronous mode. This API uses a callb
}
});
```
## securityLabel.getSecurityLabelSync
getSecurityLabelSync(path:string):string
......@@ -204,6 +279,21 @@ Obtains the security label of a file in synchronous mode.
| ------ | ------------ |
| 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**
```js
......
......@@ -4,14 +4,14 @@ The **statfs** module provides APIs for obtaining file system information, inclu
> **NOTE**
>
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
> 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
```js
import statvfs from '@ohos.file.statvfs';
```
## statvfs.getFreeSize
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
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------------- |
| path | string | Yes | File path of the file system.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------------- |
| path | string | Yes | File path of the file system.|
**Return value**
| Type | Description |
| --------------------- | -------------- |
| Promise&lt;number&gt; | Promise used to return the number of free bytes obtained.|
| Type | Description |
| --------------------- | -------------- |
| 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**
......@@ -53,10 +57,14 @@ Obtains the number of free bytes of the specified file system in asynchronous mo
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------- |
| 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.|
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------- |
| 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.|
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example**
......@@ -81,15 +89,19 @@ Obtains the total number of bytes of the specified file system in asynchronous m
**Parameters**
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | ---------------------------- |
| path | string | Yes | File path of the file system.|
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | ---------------------------- |
| path | string | Yes | File path of the file system.|
**Return value**
| Type | Description |
| --------------------- | ------------ |
| Promise&lt;number&gt; | Promise used to return the total number of bytes obtained.|
| Type | Description |
| --------------------- | ------------ |
| 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**
......@@ -112,10 +124,14 @@ Obtains the total number of bytes of the specified file system in asynchronous m
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------- |
| 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. |
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------- |
| 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. |
**Error codes**
For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes).
**Example**
......
......@@ -4,8 +4,8 @@ The **storageStatistics** module provides APIs for obtaining storage space infor
> **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 APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
> 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.
## Modules to Import
```js
......@@ -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.
**Parameters**
| Name | Type | Mandatory| Description|
......@@ -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.|
**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**
```js
......@@ -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.
**Parameters**
| Name | Type | Mandatory| Description |
......@@ -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. |
| 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**
```js
......@@ -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.
**Parameters**
| Name | Type | Mandatory| Description|
......@@ -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.|
**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**
```js
......@@ -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.
**Parameters**
| Name | Type | Mandatory| Description |
......@@ -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. |
| 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**
```js
......@@ -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.
**Parameters**
| Name | Type | Mandatory| Description |
......@@ -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.|
**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**
```js
......@@ -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.
**Parameters**
| Name | Type | Mandatory| Description |
......@@ -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.|
| 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**
```js
......@@ -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. |
**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**
```js
......@@ -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. |
**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**
```js
......@@ -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. |
| dataSize | number | Yes| No| Total data size of the application, in bytes.|
## storageStatistics.getTotalSize<sup>9+</sup>
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
| --------------------- | ------------------ |
| 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**
```js
......@@ -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.|
**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**
```js
......@@ -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>
getFreeSize(): Promise&lt;number&gt;
......@@ -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.|
**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**
```js
......@@ -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));
```
## storageStatistics.getFreeSize<sup>9+</sup>
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
| -------- | ------------------------------------ | ---- | ------------------------- |
| 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**
```js
......@@ -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.
**Return value**
| Type | Description |
| --------------------- | ---------------- |
| 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**
```js
......@@ -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.|
**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**
```js
......@@ -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.|
**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**
```js
......@@ -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.|
**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**
```js
......@@ -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));
});
```
## storageStatistics.getUserStorageStats<sup>9+</sup>
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.
......@@ -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.|
**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**
```js
......@@ -534,6 +734,19 @@ Obtains the storage statistics (in bytes) of the specified user. This API uses a
| userId | number | Yes | User ID.|
| 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**
```js
......@@ -544,7 +757,6 @@ Obtains the storage statistics (in bytes) of the specified user. This API uses a
});
```
## StorageStats<sup>9+</sup>
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
......
# @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**
>
......@@ -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.|
| 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.|
| 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**
......@@ -44,7 +44,6 @@ For details about the error codes, see [File Management Error Codes](../errorcod
| 401 | The input parameter is invalid |
| 143000001 | IPC error |
**Example**
```js
......@@ -66,7 +65,6 @@ try {
}
```
## fileShare.grantUriPermission
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
**Return value**
| Type | Description |
| ---------------------------- | ---------- |
| Promise&lt;void&gt; | Promise that returns no value.|
| Type | Description |
| ---------------------------- | ---------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
......@@ -105,7 +102,6 @@ For details about the error codes, see [File Management Error Codes](../errorcod
| 401 | The input parameter is invalid |
| 143000001 | IPC error |
**Example**
```js
......
# 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
| Name | Type | Readable| Writable| Description |
......
# 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
| Name | Type | Readable| Writable| Description |
......
# 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
| Name | Type | Readable| Writable| Description |
......
......@@ -8,9 +8,9 @@ The **NotificationActionButton** module describes the button displayed in the no
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| Name | Type | Read-only| Mandatory| Description |
| --------- | ----------------------------------------------- | --- | ---- | ------------------------- |
| title | string | Yes | Yes | Button title. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** of the button.|
| extras | { [key: string]: any } | Yes | Yes | Extra information of the button. |
| userInput<sup>8+</sup> | [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) | Yes | Yes | User input object. |
| title | string | No | Yes | Button title. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | No | Yes | **WantAgent** 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) | No | No | User input object. |
......@@ -10,7 +10,7 @@ Provides the bundle information of an application.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Mandatory| Description |
| ------ | ------ |---- | ------ |
| bundle | string | Yes| Bundle information of the application.|
| uid | number | No| User ID.|
| Name | Type | Read-only| Mandatory| Description |
| ------ | ------ | ---- | ---- | ------ |
| bundle | string | No | Yes| Bundle information of the application.|
| uid | number | No | No| User ID.|
......@@ -8,13 +8,13 @@ The **NotificationContent** module describes the notification content.
**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. |
| normal | [NotificationBasicContent](#notificationbasiccontent) | Yes | Yes | Normal text. |
| longText | [NotificationLongTextContent](#notificationlongtextcontent) | Yes | Yes | Long text.|
| multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | Yes | Yes | Multi-line text. |
| picture | [NotificationPictureContent](#notificationpicturecontent) | Yes | Yes | Picture-attached. |
| contentType | [ContentType](./js-apis-notificationManager.md#contenttype) | No | Yes | Notification content type. |
| normal | [NotificationBasicContent](#notificationbasiccontent) | No | No | Normal text. |
| longText | [NotificationLongTextContent](#notificationlongtextcontent) | No | No | Long text.|
| multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | No | No | Multi-line text. |
| picture | [NotificationPictureContent](#notificationpicturecontent) | No | No | Picture-attached. |
## NotificationBasicContent
......@@ -22,11 +22,11 @@ Describes the normal text notification.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| Name | Type | Read-only| Mandatory| Description |
| -------------- | ------ | ---- | ---- | ---------------------------------- |
| title | string | Yes | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.|
| title | string | No | Yes | Notification title. |
| text | string | No | Yes | Notification content. |
| additionalText | string | No | No | Additional information of the notification.|
## NotificationLongTextContent
......@@ -35,14 +35,14 @@ Describes the long text notification.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| Name | Type | Read-only| Mandatory| Description |
| -------------- | ------ | ---- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.|
| longText | string | Yes | Yes | Long text of the notification. |
| briefText | string | Yes | Yes | Brief text of the notification.|
| expandedTitle | string | Yes | Yes | Title of the notification in the expanded state. |
| title | string | No | Yes | Notification title. |
| text | string | No | Yes | Notification content. |
| additionalText | string | No | No | Additional information of the notification.|
| longText | string | No | Yes | Long text of the notification. |
| briefText | string | No | Yes | Brief text of the notification. |
| expandedTitle | string | No | Yes | Title of the notification in the expanded state. |
## NotificationMultiLineContent
......@@ -53,12 +53,12 @@ Describes the multi-line text notification.
| Name | Type | Readable| Writable| Description |
| -------------- | --------------- | --- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.|
| briefText | string | Yes | Yes | Brief text of the notification.|
| longTitle | string | Yes | Yes | Title of the notification in the expanded state. |
| lines | Array\<string\> | Yes | Yes | Multi-line text of the notification. |
| title | string | No | Yes | Notification title. |
| text | string | No | Yes | Notification content. |
| additionalText | string | No | No | Additional information of the notification.|
| briefText | string | No | Yes | Brief text of the notification.|
| longTitle | string | No | Yes | Title of the notification in the expanded state. |
| lines | Array\<string\> | No | Yes | Multi-line text of the notification. |
## NotificationPictureContent
......@@ -69,9 +69,9 @@ Describes the picture-attached notification.
| Name | Type | Readable| Writable| Description |
| -------------- | -------------- | ---- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.|
| briefText | string | Yes | Yes | Brief text of the notification.|
| expandedTitle | string | Yes | Yes | Title of the notification in the expanded state. |
| picture | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Picture attached to the notification. |
| title | string | No | Yes | Notification title. |
| text | string | No | Yes | Notification content. |
| additionalText | string | No | No | Additional information of the notification.|
| briefText | string | No | Yes | Brief text of the notification.|
| expandedTitle | string | No | Yes | Title of the notification in the expanded state. |
| 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.
**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. |
| vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus) | Yes | No | Whether to enable vibration for the notification. |
......
......@@ -8,45 +8,45 @@ The **NotificationRequest** module describes the notification request.
**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. |
| id | number | Yes | Yes | Notification ID. |
| slotType | [SlotType](js-apis-notificationManager.md#slottype) | Yes | Yes | Notification slot type. |
| isOngoing | boolean | Yes | Yes | Whether the notification is an ongoing notification. |
| isUnremovable | boolean | Yes | Yes | Whether the notification can be removed. |
| deliveryTime | number | Yes | Yes | Time when the notification is sent. |
| tapDismissed | boolean | Yes | Yes | Whether the notification is automatically cleared. |
| autoDeletedTime | number | Yes | Yes | 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.|
| extraInfo | {[key: string]: any} | Yes | Yes | Extended parameters. |
| color | number | Yes | Yes | Background color of the notification. Not supported currently.|
| colorEnabled | boolean | Yes | Yes | Whether the notification background color can be enabled. Not supported currently.|
| isAlertOnce | boolean | Yes | Yes | Whether the notification triggers an alert only once.|
| isStopwatch | boolean | Yes | Yes | Whether to display the stopwatch. |
| isCountDown | boolean | Yes | Yes | Whether to display the countdown time. |
| isFloatingIcon | boolean | Yes | Yes | Whether the notification is displayed as a floating icon in the status bar. |
| label | string | Yes | Yes | Notification label. |
| badgeIconStyle | number | Yes | Yes | Notification badge type. |
| showDeliveryTime | boolean | Yes | Yes | 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. |
| 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.|
| 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.|
| content | [NotificationContent](js-apis-inner-notification-notificationContent.md#notificationcontent) | No | Yes | Notification content. |
| id | number | No | No | Notification ID. |
| slotType | [SlotType](js-apis-notificationManager.md#slottype) | Yes | No | Notification slot type. |
| isOngoing | boolean | No | No | Whether the notification is an ongoing notification. |
| isUnremovable | boolean | No | No | Whether the notification can be removed. |
| deliveryTime | number | No | No | Time when the notification is sent. |
| tapDismissed | boolean | No | No | Whether the notification is automatically cleared. |
| autoDeletedTime | number | No | No | Time when the notification is automatically cleared. |
| 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} | No | No | Extended parameters. |
| color | number | No | No | Background color of the notification. Not supported currently.|
| colorEnabled | boolean | No | No | Whether the notification background color can be enabled. Not supported currently.|
| isAlertOnce | boolean | No | No | Whether the notification triggers an alert only once.|
| isStopwatch | boolean | No | No | Whether to display the stopwatch. |
| isCountDown | boolean | No | No | Whether to display the countdown time. |
| isFloatingIcon | boolean | No | No | Whether the notification is displayed as a floating icon in the status bar. |
| label | string | No | No | Notification label. |
| badgeIconStyle | number | No | No | Notification badge type. Not supported currently. |
| showDeliveryTime | boolean | No | No | Whether to display the time when the notification is delivered. |
| 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) | 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) | 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. |
| creatorUid<sup>8+<sup> | number | Yes | No | UID 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. |
| classification | string | Yes | Yes | 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. |
| template<sup>8+<sup> | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | Yes | Yes | Notification template. |
| 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 | No | No | Notification group name. |
| 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. |
| 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. |
| notificationFlags<sup>8+<sup> | [NotificationFlags](js-apis-inner-notification-notificationflags#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. |
| badgeNumber<sup>9+<sup> | number | Yes | Yes | Number of notifications displayed on the application icon. |
| 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) | No | No | **WantAgent** instance to which the notification will be redirected when it is removed. |
| badgeNumber<sup>9+<sup> | number | No | No | Number of notifications displayed on the application icon. |
## DistributedOptions
......@@ -55,9 +55,9 @@ Describes distributed notification options.
**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. |
| supportDisplayDevices<sup>8+<sup> | Array\<string> | Yes | Yes | 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. |
| isDistributed<sup>8+<sup> | boolean | No | No | Whether the notification is a distributed notification. |
| 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> | 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. |
......@@ -8,17 +8,17 @@ The **NotificationSlot** module describes the notification slot.
**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. |
| level | number | Yes | Yes | 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. |
| badgeFlag | boolean | Yes | Yes | Whether to display the badge. |
| bypassDnd | boolean | Yes | Yes | Whether to bypass DND mode in the system. |
| lockscreenVisibility | number | Yes | Yes | Mode for displaying the notification on the lock screen. |
| vibrationEnabled | boolean | Yes | Yes | Whether to enable vibration for the notification. |
| sound | string | Yes | Yes | Notification alert tone. |
| lightEnabled | boolean | Yes | Yes | Whether the indicator blinks for the notification. |
| lightColor | number | Yes | Yes | Indicator color of the notification. |
| vibrationValues | Array\<number\> | Yes | Yes | Vibration mode of the notification. |
| type | [SlotType](js-apis-notificationManager.md#slottype) | No | Yes | Notification slot type. |
| 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 | No | No | Notification slot description. |
| badgeFlag | boolean | No | No | Whether to display the badge. |
| bypassDnd | boolean | No | No | Whether to bypass DND mode in the system. |
| lockscreenVisibility | number | No | No | Mode for displaying the notification on the lock screen. |
| vibrationEnabled | boolean | No | No | Whether to enable vibration for the notification. |
| sound | string | No | No | Notification alert tone. |
| lightEnabled | boolean | No | No | Whether the indicator blinks for the notification. |
| lightColor | number | No | No | Indicator color 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. |
# 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. |
......@@ -8,7 +8,7 @@ The **NotificationTemplate** module describes the notification template.
**System capability**: SystemCapability.Notification.Notification
| Name| Type | Readable| Writable| Description |
| Name| Type | Read-only| Mandatory| Description |
| ---- | ---------------------- | ---- | ---- | ---------- |
| name | string | Yes | Yes | Template name.|
| data | {[key:string]: Object} | Yes | Yes | Template data.|
| name | string | No | Yes | Template name.|
| data | {[key:string]: Object} | No | Yes | Template data.|
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册