diff --git a/en/application-dev/application-models/Readme-EN.md b/en/application-dev/application-models/Readme-EN.md index b5dd76aea6715dc3bc2e7ad1b8f7cae974343d7c..05cdc41e5d2027e9e3bfba373ed14916b3e790a1 100644 --- a/en/application-dev/application-models/Readme-EN.md +++ b/en/application-dev/application-models/Readme-EN.md @@ -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 diff --git a/en/application-dev/application-models/arkts-ui-widget-image-update.md b/en/application-dev/application-models/arkts-ui-widget-image-update.md index 00c00a744afd8422274617005a50583fef5d92ee..4862fbf747c0275d179eb4a2f988280379f2d262 100644 --- a/en/application-dev/application-models/arkts-ui-widget-image-update.md +++ b/en/application-dev/application-models/arkts-ui-widget-image-update.md @@ -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. diff --git a/en/application-dev/application-models/config-file-stage.md b/en/application-dev/application-models/config-file-stage.md new file mode 100644 index 0000000000000000000000000000000000000000..66cabf4a99fd4a3f5138c0a8ef1bbf2cefbe15c0 --- /dev/null +++ b/en/application-dev/application-models/config-file-stage.md @@ -0,0 +1,6 @@ +# 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). + diff --git a/en/application-dev/application-models/figures/mission-and-multiton.png b/en/application-dev/application-models/figures/mission-and-multiton.png new file mode 100644 index 0000000000000000000000000000000000000000..e50f9d44d475711c17bfe56394fddd8a6c7b784c Binary files /dev/null and b/en/application-dev/application-models/figures/mission-and-multiton.png differ diff --git a/en/application-dev/application-models/figures/mission-and-standard.png b/en/application-dev/application-models/figures/mission-and-standard.png deleted file mode 100644 index feeed48f41371bf22abbee8dbae4695b11ed2514..0000000000000000000000000000000000000000 Binary files a/en/application-dev/application-models/figures/mission-and-standard.png and /dev/null differ diff --git a/en/application-dev/application-models/figures/mission-list-recent.png b/en/application-dev/application-models/figures/mission-list-recent.png new file mode 100644 index 0000000000000000000000000000000000000000..bfc35532ad4907fd3a1bfcb61110ed393ea19d1c Binary files /dev/null and b/en/application-dev/application-models/figures/mission-list-recent.png differ diff --git a/en/application-dev/application-models/figures/mission-set-task-snapshot-icon.png b/en/application-dev/application-models/figures/mission-set-task-snapshot-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..9d1ba2503f4e1a5d3b2aafdd93923c3f6c411998 Binary files /dev/null and b/en/application-dev/application-models/figures/mission-set-task-snapshot-icon.png differ diff --git a/en/application-dev/application-models/figures/mission-set-task-snapshot-label.png b/en/application-dev/application-models/figures/mission-set-task-snapshot-label.png new file mode 100644 index 0000000000000000000000000000000000000000..c8348685cc0fd521186aa10e8d04495422fc0206 Binary files /dev/null and b/en/application-dev/application-models/figures/mission-set-task-snapshot-label.png differ diff --git a/en/application-dev/application-models/mission-management-launch-type.md b/en/application-dev/application-models/mission-management-launch-type.md index 6bad0ba0079e7087406000cd1a5e5ffb54a4f17c..ac8af200aef03876ee9aa9f0f3219f3a856afbbd 100644 --- a/en/application-dev/application-models/mission-management-launch-type.md +++ b/en/application-dev/application-models/mission-management-launch-type.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. - diff --git a/en/application-dev/application-models/mission-management-overview.md b/en/application-dev/application-models/mission-management-overview.md index 8d219cf935b0f4cae4093b33ed760a3603538ecc..785a9f8291ea43e756ebed07843ceef23570160d 100644 --- a/en/application-dev/application-models/mission-management-overview.md +++ b/en/application-dev/application-models/mission-management-overview.md @@ -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"); + }) + ``` + + diff --git a/en/application-dev/application-models/mission-set-icon-name-for-task-snapshot.md b/en/application-dev/application-models/mission-set-icon-name-for-task-snapshot.md new file mode 100644 index 0000000000000000000000000000000000000000..c98d39ff8348f330d58138db89afcc2a0d5995ca --- /dev/null +++ b/en/application-dev/application-models/mission-set-icon-name-for-task-snapshot.md @@ -0,0 +1,51 @@ +# 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) diff --git a/en/application-dev/application-models/process-model-fa.md b/en/application-dev/application-models/process-model-fa.md index 699643031121521fbf95d26a949df906fa175a18..ce4c9778d3bf678c7ecb8094477050a42eebb7d7 100644 --- a/en/application-dev/application-models/process-model-fa.md +++ b/en/application-dev/application-models/process-model-fa.md @@ -1,4 +1,4 @@ -# Process Model (FA Model) +# Process Model Overview (FA Model) The OpenHarmony process model is shown below. diff --git a/en/application-dev/application-models/process-model-stage.md b/en/application-dev/application-models/process-model-stage.md index 03da480722de124a1ede58da52e74cd48c5f23f0..cf758d94636773dfd190366d0e215de655902abd 100644 --- a/en/application-dev/application-models/process-model-stage.md +++ b/en/application-dev/application-models/process-model-stage.md @@ -1,4 +1,4 @@ -# Process Model (Stage Model) +# Process Model Overview (Stage Model) The OpenHarmony process model is shown below. diff --git a/en/application-dev/application-models/subscribe-system-environment-variable-changes.md b/en/application-dev/application-models/subscribe-system-environment-variable-changes.md new file mode 100644 index 0000000000000000000000000000000000000000..c231f483e9bcd8f83faf49d40007730d0f854de5 --- /dev/null +++ b/en/application-dev/application-models/subscribe-system-environment-variable-changes.md @@ -0,0 +1,172 @@ +# 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)}`); + } + + // ... +} +``` diff --git a/en/application-dev/application-models/thread-model-fa.md b/en/application-dev/application-models/thread-model-fa.md index 56cf8c94732acede5ee03cf9f9b79553e0183b49..0f11cddb48792e887a14a2d5011dbdcd4736340d 100644 --- a/en/application-dev/application-models/thread-model-fa.md +++ b/en/application-dev/application-models/thread-model-fa.md @@ -1,4 +1,4 @@ -# Thread Model (FA Model) +# Thread Model Overview (FA Model) There are three types of threads in the FA model: diff --git a/en/application-dev/application-models/thread-model-stage.md b/en/application-dev/application-models/thread-model-stage.md index 4ca9fb3ed369f78cf12054c7b6da085b8640b1db..7343b9b619a5d68354e65e254a22a2b078ca44ee 100644 --- a/en/application-dev/application-models/thread-model-stage.md +++ b/en/application-dev/application-models/thread-model-stage.md @@ -1,4 +1,4 @@ -# Thread Model (Stage Model) +# Thread Model Overview (Stage Model) For an OpenHarmony application, each process has a main thread to provide the following functionalities: diff --git a/en/application-dev/database/share-data-by-silent-access.md b/en/application-dev/database/share-data-by-silent-access.md index 142642f98646003c675fcbd15d9369b6664948a6..50ff03f084c889a807c6caf4d7c369bfbe0d2a51 100644 --- a/en/application-dev/database/share-data-by-silent-access.md +++ b/en/application-dev/database/share-data-by-silent-access.md @@ -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. diff --git a/en/application-dev/file-management/share-app-file.md b/en/application-dev/file-management/share-app-file.md index 4261861bad51dc312d0ccfc5ab0a7f4d8f404426..c2f8f8d12f5ff056e043fb632cff9752c95256ce 100644 --- a/en/application-dev/file-management/share-app-file.md +++ b/en/application-dev/file-management/share-app-file.md @@ -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 diff --git a/en/application-dev/quick-start/arkts-observed-and-objectlink.md b/en/application-dev/quick-start/arkts-observed-and-objectlink.md index 8b9beadc5fec17c0196dfeaae2ef28caea648042..1282545cc1d65a1acdc90da3ac5a2828cf611ca9 100644 --- a/en/application-dev/quick-start/arkts-observed-and-objectlink.md +++ b/en/application-dev/quick-start/arkts-observed-and-objectlink.md @@ -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 { -Declare a class that extends from** Array**: **class StringArray extends Array\ {}** 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\ {}** and create an instance of **StringArray**. The use of the **new** operator is required for the \@Observed class decorator to work properly. ```ts diff --git a/en/application-dev/quick-start/arkts-page-custom-components-lifecycle.md b/en/application-dev/quick-start/arkts-page-custom-components-lifecycle.md index 7d3b591d7d0af07443d62f70015f94af651f5d44..90a06cc468f5dc383ec3cf15a9f2d8a894f63239 100644 --- a/en/application-dev/quick-start/arkts-page-custom-components-lifecycle.md +++ b/en/application-dev/quick-start/arkts-page-custom-components-lifecycle.md @@ -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; }) diff --git a/en/application-dev/quick-start/arkts-rendering-control-lazyforeach.md b/en/application-dev/quick-start/arkts-rendering-control-lazyforeach.md index 7086569f912a0c447228643958c38b3bd16e0045..95b6665c834a4bdf281b4712717e71f51659c112 100644 --- a/en/application-dev/quick-start/arkts-rendering-control-lazyforeach.md +++ b/en/application-dev/quick-start/arkts-rendering-control-lazyforeach.md @@ -75,15 +75,17 @@ interface DataChangeListener { } ``` -| Declaration | Parameter Type | Description | -| ---------------------------------------- | -------------------------------------- | ---------------------------------------- | -| onDataReloaded(): void | - | Invoked when all data is reloaded. | -| onDataAdded(index: number):void | number | Invoked when data is added to the position indicated by the specified index.
**index**: index of the position where data is added. | -| onDataMoved(from: number, to: number): void | from: number,
to: number | Invoked when data is moved.
**from**: original position of data; **to**: target position of data.
**NOTE**
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: number): void | number | Invoked when data in the position indicated by the specified index is changed.
**index**: listener for data changes. | -| onDataAdd(index: number): void | number | Invoked when data is added to the position indicated by the specified index.
**index**: index of the position where data is added. | -| onDataMove(from: number, to: number): void | from: number,
to: number | Invoked when data is moved.
**from**: original position of data; **to**: target position of data.
**NOTE**
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: number): void | number | Invoked when data in the position indicated by the specified index is changed.
**index**: index of the position where data is changed.| +| Declaration | Parameter Type | Description | +| ------------------------------------------------------------ | -------------------------------------- | ------------------------------------------------------------ | +| onDataReloaded(): void | - | Invoked when all data is reloaded. | +| onDataAdded(index: number):void(deprecated) | number | Invoked when data is added to the position indicated by the specified index.
This API is deprecated since API version 8. You are advised to use **onDataAdd** instead.
**index**: index of the position where data is added.| +| onDataMoved(from: number, to: number): void(deprecated) | from: number,
to: number | Invoked when data is moved.
This API is deprecated since API version 8. You are advised to use **onDataMove** instead.
**from**: original position of data; **to**: target position of data.
**NOTE**
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(deprecated) | number | Invoked when data is deleted from the position indicated by the specified index. LazyForEach will update the displayed content accordingly.
This API is deprecated since API version 8. You are advised to use **onDataDelete** instead.
**index**: index of the position where data is deleted.| +| onDataChanged(index: number): void(deprecated) | number | Invoked when data in the position indicated by the specified index is changed.
This API is deprecated since API version 8. You are advised to use **onDataChange** instead.
**index**: listener for data changes.| +| onDataAdd(index: number): void8+ | number | Invoked when data is added to the position indicated by the specified index.
**index**: index of the position where data is added.| +| onDataMove(from: number, to: number): void8+ | from: number,
to: number | Invoked when data is moved.
**from**: original position of data; **to**: target position of data.
**NOTE**
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):void8+ | number | Invoked when data is deleted from the position indicated by the specified index. LazyForEach will update the displayed content accordingly.
**index**: index of the position where data is deleted.
**NOTE**
Before **onDataDelete** is called, ensure that the corresponding data in **dataSource** has been deleted. Otherwise, undefined behavior will occur during page rendering.| +| onDataChange(index: number): void8+ | number | Invoked when data in the position indicated by the specified index is changed.
**index**: index of the position where data is changed.| ## Restrictions diff --git a/en/application-dev/quick-start/arkts-state-management-overview.md b/en/application-dev/quick-start/arkts-state-management-overview.md index 440cceac78c9f5b6d4773e211f790596e5c24ed6..09db3f3183cd8156d532be741698fcc2fbfd26ef 100644 --- a/en/application-dev/quick-start/arkts-state-management-overview.md +++ b/en/application-dev/quick-start/arkts-state-management-overview.md @@ -106,6 +106,10 @@ Decorators for [managing the state owned by a component](arkts-state.md): - \@ObjectLink: An \@ObjectLink decorated variable, when used with an \@Observed decorated class of the parent component, is for two-way data synchronization in scenarios involving multiple levels of nested objects or arrays in the class. +> **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): diff --git a/en/application-dev/quick-start/arkts-state.md b/en/application-dev/quick-start/arkts-state.md index f2d9774861a8a4180856f03ba2714df8feef9f53..6ac35e388df8471d78245fd52fa82aa8a5a7f580 100644 --- a/en/application-dev/quick-start/arkts-state.md +++ b/en/application-dev/quick-start/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 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(() => { diff --git a/en/application-dev/quick-start/har-package.md b/en/application-dev/quick-start/har-package.md index 63b5fcfd10437ac2140a17bcc1daf690e780c791..587af49e108ed1cfedbd9a190ea7858bc470073c 100644 --- a/en/application-dev/quick-start/har-package.md +++ b/en/application-dev/quick-start/har-package.md @@ -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. diff --git a/en/application-dev/quick-start/in-app-hsp.md b/en/application-dev/quick-start/in-app-hsp.md index 4c0cc3c7dffc1c41d0011dd644a94a84424808dc..cb31cbc5b703c3caec5c34b4e0702657b56d26f5 100644 --- a/en/application-dev/quick-start/in-app-hsp.md +++ b/en/application-dev/quick-start/in-app-hsp.md @@ -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 **\** 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' diff --git a/en/application-dev/quick-start/module-configuration-file.md b/en/application-dev/quick-start/module-configuration-file.md index 58342507a06818c5cdb84996d63fe777c9eb34a5..65907daeaa07d2ce42ff7d4bedb17e199928f1c0 100644 --- a/en/application-dev/quick-start/module-configuration-file.md +++ b/en/application-dev/quick-start/module-configuration-file.md @@ -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.
- **true**: The UIAbility component can be called by other applications.
- **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).
- **true**: The UIAbility component can be migrated.
- **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.
Configuring rule:
- 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.)
- 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.
Configuration rules:
- 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.)
- 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.
Continuous tasks are classified into the following types:
- **dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices.
- **audioPlayback**: audio playback service.
- **audioRecording**: audio recording service.
- **location**: location and navigation services.
- **bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables).
- **multiDeviceConnection**: multi-device interconnection service.
- **wifiInteraction**: Wi-Fi scanning, connection, and transmission services (as used in the Multi-screen Collaboration and clone features)
- **voip**: voice/video call and VoIP services.
- **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**.
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**.
The value is a string with a maximum of 255 bytes.| String| No| diff --git a/en/application-dev/quick-start/quickfix-principles.md b/en/application-dev/quick-start/quickfix-principles.md index 53cb1c3fa2848cb4576a12838d45313d9005c6ed..ef9608ce20cdd54a451162d2a1194b81d3b54338 100644 --- a/en/application-dev/quick-start/quickfix-principles.md +++ b/en/application-dev/quick-start/quickfix-principles.md @@ -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**: -
This file is used to describe the version information of the .hqf file and is filled in by developers. The details are as follows: +
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" : { diff --git a/en/application-dev/quick-start/resource-categories-and-access.md b/en/application-dev/quick-start/resource-categories-and-access.md index b8b2d912bf19f66fa97f5e65901b8985a8aaa6bd..f87ae3594a44b17b34233adfd0d8127a2be34028 100644 --- a/en/application-dev/quick-start/resource-categories-and-access.md +++ b/en/application-dev/quick-start/resource-categories-and-access.md @@ -49,22 +49,22 @@ resources **Table 1** Classification of the resources directory -| Category | base Subdirectory | Qualifiers Subdirectory | rawfile Subdirectory | +| Category | base Subdirectory | Qualifiers Subdirectory | rawfile Subdirectory | | ---- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | -| Structure| The **base** subdirectory is a default directory. If no qualifiers subdirectories in the **resources** directory of the application match the device status, the resource file in the **base** subdirectory will be automatically referenced.
Resource group subdirectories are located at the second-level subdirectories in the **base** directory to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectory](#resource-group-subdirectory).| **en_US** and **zh_CN** are two default qualifiers subdirectories. You need to create other qualifiers subdirectories on your own. Each directory name consists of one or more qualifiers that represent the application scenarios or device characteristics. For details, see [Qualifiers Subdirectory](#qualifiers-subdirectory).
Resource group subdirectories are located at the second level of qualifiers subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectory](#resource-group-subdirectory).| You can create multiple levels of subdirectories with custom directory names. They can be used to store various resource files.
However, resource files in the **rawfile** subdirectory will not be matched based on the device status.| -| Compilation| Resource files in the subdirectories are compiled into binary files, and each resource file is assigned an ID. | Resource files in the subdirectories are compiled into binary files, and each resource file is assigned an ID. | Resource files in the subdirectory are directly packed into the application without being compiled, and no IDs will be assigned to the resource files. | -| Reference| Resource files in the subdirectory are referenced based on the resource type and resource name. | Resource files in the subdirectory are referenced based on the resource type and resource name. | Resource files in the subdirectory are referenced based on the file path and file name. | +| Structure| The **base** subdirectory is a default directory. If no qualifiers subdirectories in the **resources** directory of the application match the device status, the resource file in the **base** subdirectory will be automatically referenced.
Resource group subdirectories are located at the second level of subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectories](#resource-group-subdirectories).| **en_US** and **zh_CN** are two default qualifiers subdirectories. You need to create other qualifiers subdirectories on your own. Each directory name consists of one or more qualifiers that represent the application scenarios or device characteristics. For details, see [Qualifiers Subdirectories](#qualifiers-subdirectories).
Resource group subdirectories are located at the second level of subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectories](#resource-group-subdirectories).| You can create multiple levels of subdirectories with custom directory names. They can be used to store various resource files.
However, resource files in the **rawfile** subdirectory will not be matched based on the device status.| +| Compilation| Resource files in the subdirectory are compiled into binary files, and each resource file is assigned an ID. | Resource files in the subdirectory are compiled into binary files, and each resource file is assigned an ID. | Resource files in the subdirectory are directly packed into the application without being compiled, and no IDs will be assigned to the resource files. | +| Reference| Resource files in the subdirectory are referenced based on the resource type and resource name. | Resource files in the subdirectory are referenced based on the resource type and resource name. | Resource files in the subdirectory are referenced based on the file path and file name. | -### Qualifiers Subdirectory +### Qualifiers Subdirectories -The name of a qualifiers subdirectory consists of one or more qualifiers that represent the application scenarios or device characteristics, covering the mobile country code (MCC), mobile network code (MNC), language, script, country or region, screen orientation, device type, night mode, and screen density. The qualifiers are separated using underscores (\_) or hyphens (\-). When creating a qualifiers subdirectory, you need to understand the directory naming conventions and the rules for matching qualifiers subdirectories and the device status. +The name of a qualifiers subdirectory consists of one or more qualifiers that represent the application scenarios or device characteristics, covering the mobile country code (MCC), mobile network code (MNC), language, script, country or region, screen orientation, device type, night mode, and screen density. The qualifiers are separated using underscores (\_) or hyphens (\-). Before creating a qualifiers subdirectory, familiarize yourself with the directory naming conventions and the rules for matching qualifiers subdirectories and the device status. **Naming Conventions for Qualifiers Subdirectories** -- Qualifiers are ordered in the following sequence: **\_MCC_MNC-language_script_country/region-orientation-device-color mode-density**. You can select one or multiple qualifiers to name your subdirectory based on your application scenarios and device characteristics. +- Qualifiers are ordered in the following sequence: **\_MCC_MNC-language_script_country/region-orientation-device-color mode-density_**. You can select one or multiple qualifiers to name your subdirectory based on your application scenarios and device characteristics. -- Separation between qualifiers: The language, script, and country/region qualifiers are separated using underscores (\_); the MNC and MCC qualifiers are also separated using underscores (\_); other qualifiers are separated using hyphens (-). For example, **zh_Hant_CN** and **zh_CN-car-ldpi**. +- Separation between qualifiers: The language, script, and country/region qualifiers are separated using underscores (\_); the MNC and MCC qualifiers are also separated using underscores (\_); other qualifiers are separated using hyphens (\-). For example, **zh_Hant_CN** and **zh_CN-car-ldpi**. - Value range of qualifiers: The value of each qualifier must meet the requirements specified in the following table. Otherwise, the resource files in the resources directory cannot be matched. @@ -72,34 +72,34 @@ The name of a qualifiers subdirectory consists of one or more qualifiers that re | Qualifier Type | Description and Value Range | | ----------- | ---------------------------------------- | -| MCC&MNC| Mobile country code and mobile network code, which are obtained from the network where the device is registered. The MCC can be either followed by the MNC with an underscore (\_) in between or be used independently. For example, **mcc460** indicates China, and **mcc460\_mnc00** indicates China\_China Mobile.
For details about the value range, refer to **ITU-T E.212** (the international identification plan for public networks and subscriptions).| -| Language | Language used by the device. The value consists of two or three lowercase letters. for example, **zh** indicates Chinese, en indicates English, and **mai** indicates Maithili.
For details about the value range, refer to **ISO 639** (codes for the representation of names of languages).| -| Script | Script type used by the device. The value starts with one uppercase letter followed by three lowercase letters. For example, **Hans** indicates simplified Chinese, and **Hant** indicates traditional Chinese.
For details about the value range, refer to **ISO 15924** (codes for the representation of names of scripts).|| -| Country/Region | Country or region where the user is located. The value consists of two or three uppercase letters or three digits. For example, **CN** indicates China, and **GB** indicates the United Kingdom.
For details about the value range, refer to **ISO 3166-1** (codes for the representation of names of countries and their subdivisions).|| -| Screen orientation | Screen orientation of the device. The value can be:
- **vertical**: portrait orientation
- **horizontal**: landscape orientation| -| Type of the registered device. | Device type. The value can be:
- **car**: head unit
- **tv**: smart TV
- **wearable**: smart wearable| -| Color mode | Color mode of the device. The value can be:
- **dark**: dark mode
- **light**: light mode| -| Screen density | Screen density of the device, in dpi. The value can be:
- **sdpi**: screen density with small-scale dots per inch (SDPI). This value is applicable for devices with a DPI range of (0, 120].
- **mdpi**: screen density with medium-scale dots per inch (MDPI). This value is applicable for devices with a DPI range of (120, 160].
- **ldpi**: screen density with large-scale dots per inch (LDPI). This value is applicable for devices with a DPI range of (160, 240].
- **xldpi**: screen density with extra-large-scale dots per inch (XLDPI). This value is applicable for devices with a DPI range of (240, 320].
- **xxldpi**: screen density with extra-extra-large-scale dots per inch (XXLDPI). This value is applicable for devices with a DPI range of (320, 480].
- **xxxldpi**: screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI). This value is applicable for devices with a DPI range of (480, 640].| +| MCC&MNC| Indicates the MCC and MNC, which are obtained from the network where the device is registered. The MCC can be either followed by the MNC with an underscore (\_) in between or be used independently. For example, **mcc460** indicates China, and **mcc460\_mnc00** indicates China\_China Mobile.
For details about the value range, refer to **ITU-T E.212** (the international identification plan for public networks and subscriptions).| +| Language | Indicates the language used by the device. The value consists of two or three lowercase letters. For example, **zh** indicates Chinese, **en** indicates English, and **mai** indicates Maithili.
For details about the value range, refer to **ISO 639** (codes for the representation of names of languages).| +| Text | Indicates the script type used by the device. The value starts with one uppercase letter followed by three lowercase letters. For example, **Hans** indicates simplified Chinese, and **Hant** indicates traditional Chinese.
For details about the value range, refer to **ISO 15924** (codes for the representation of names of scripts).| +| Country/Region | Indicates the country or region where the user is located. The value consists of two or three uppercase letters or three digits. For example, **CN** indicates China, and **GB** indicates the United Kingdom.
For details about the value range, refer to **ISO 3166-1** (codes for the representation of names of countries and their subdivisions).| +| Screen orientation | Indicates the screen orientation of the device. The value can be:
- **vertical**: portrait orientation
- **horizontal**: landscape orientation| +| Device type | Indicates the device type. The value can be:
- **car**: head unit
- **tv**: smart TV
- **wearable**: smart wearable| +| Color mode | Indicates the color mode of the device. The value can be:
- **dark**: dark mode
- **light**: light mode| +| Screen density | Indicates the screen density of the device, in dpi. The value can be:
- **sdpi**: screen density with small-scale dots per inch (SDPI). This value is applicable for devices with a DPI range of (0, 120].
- **mdpi**: medium-scale screen density (Medium-scale Dots Per Inch), applicable to DPI whose value is (120, 160] device.
- **ldpi**: screen density with large-scale dots per inch (LDPI). This value is applicable for devices with a DPI range of (160, 240].
- **xldpi**: screen density with extra-large-scale dots per inch (XLDPI). This value is applicable for devices with a DPI range of (240, 320].
- **xxldpi**: screen density with extra-extra-large-scale dots per inch (XXLDPI). This value is applicable for devices with a DPI range of (320, 480].
- **xxxldpi**: screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI). This value is applicable for devices with a DPI range of (480, 640].| -**Rules for Matching Qualifiers subdirectories and Device Resources** +**Rules for Matching Qualifiers Subdirectories and Device Resources** -- Qualifiers are matched with the device resources in the following priorities: MCC&MNC > locale (options: language, language\_script, language\_country/region, and language\_script\_country/region) > screen orientation > device type > color mode > screen density. +- Qualifiers are matched with the device resources in the following priorities: MCC&MNC > locale (options: language, language_script, language_country/region, and language_script_country/region) > screen orientation > device type > color mode > screen density. -- If the qualifiers subdirectories contain the **MCC, MNC, language, script, screen orientation, device type, and color mode** qualifiers, their values must be consistent with the current device status so that the subdirectories can be used for matching the device resources. For example, the qualifiers subdirectory **zh\_CN-car-ldpi** cannot be used for matching the resource files labeled **en\_US**. +- If the qualifiers subdirectories contain the **MCC, MNC, language, script, screen orientation, device type, and color mode** qualifiers, their values must be consistent with the current device status so that the subdirectories can be used for matching the device resources. For example, the qualifiers subdirectory **zh_CN-car-ldpi** cannot be used for matching the resource files labeled **en_US**. -### Resource Group Subdirectory +### Resource Group Subdirectories -You can create resource group subdirectories (including element, media, and profile) in the **base** and qualifiers subdirectories to store resource files of specific types. +You can create resource group subdirectories (including element, media, and profile) in the **base** and qualifiers subdirectories to store resource files of specific types. **Table 3** Resource group subdirectories | Resource Group Subdirectory | Description | Resource File | | ------- | ---------------------------------------- | ---------------------------------------- | -| element | Element resources. Each type of data is represented by a JSON file. (Only files are supported in this directory.) The options are as follows:
- **boolean**: boolean data
- **color**: color data
- **float**: floating-point data
- **intarray**: array of integers
- **integer**: integer data
- **pattern**: pattern data
- **plural**: plural form data
- **strarray**: array of strings
- **string**: string data| It is recommended that files in the **element** subdirectory be named the same as the following files, each of which can contain only data of the same type:
- boolean.json
- color.json
- float.json
- intarray.json
- integer.json
- pattern.json
- plural.json
- strarray.json
- string.json | -| media | Media resources, including non-text files such as images, audios, and videos. (Only files are supported in this directory.) | The file name can be customized, for example, **icon.png**. | -| profile | Custom configuration file. You can obtain the file content by using the [getProfileByAbility](../reference/apis/js-apis-bundleManager.md#bundlemanagergetprofilebyability) API. (Only files are supported in this directory.) | The file name can be customized, for example, **test_profile.json**. | +| element | Indicates element resources. Each type of data is represented by a JSON file. (Only files are supported in this directory.) The options are as follows:
- **boolean**: boolean data
- **color**: color data
- **float**: floating-point data
- **intarray**: array of integers
- **integer**: integer data
- **pattern**: pattern data
- **plural**: plural form data
- **strarray**: array of strings
- **string**: string data| It is recommended that files in the **element** subdirectory be named the same as the following files, each of which can contain only data of the same type:
- boolean.json
- color.json
- float.json
- intarray.json
- integer.json
- pattern.json
- plural.json
- strarray.json
- string.json | +| media | Indicates media resources, including non-text files such as images, audios, and videos. (Only files are supported in this directory.) | The file name can be customized, for example, **icon.png**. | +| profile | Indicates a custom configuration file. You can obtain the file content by using the [getProfileByAbility](../reference/apis/js-apis-bundleManager.md#bundlemanagergetprofilebyability) API. (Only files are supported in this directory.) | The file name can be customized, for example, **test_profile.json**. | **Media Resource Types** @@ -212,41 +212,41 @@ The content of the **plural.json** file is as follows: **Creating a Resource File** -You can create a subdirectory and its files under the **resources** directory based on the above descriptions of the qualifiers subdirectories and resource group subdirectories. +You can create a subdirectory and its files under the **resources** directory based on the preceding descriptions of the qualifiers subdirectories and resource group subdirectories. DevEco Studio provides a wizard for you to create resource directories and resource files. -- Creating a resource directory and resource file +- Creating a Resource Directory and Resource File - Right-click the **resources** directory and choose **New > Resource File**. This operation creates a subdirectory and a resource file simultaneously. If no qualifier is selected, the file is created in a resource type subdirectory under **base**. If one or more qualifiers are selected, the system automatically generates a subdirectory and creates the file in this subdirectory. To select a qualifier, highlight it under **Available qualifiers** and click the right arrow. To deselect a qualifier, highlight it under **Selected qualifiers** and click the left arrow. In **File name**, enter the name of the resource file to create. In **Resource type**, select the type of the resource group, which is **element** by default. In **Root Element**, select a resource type. The created subdirectory is automatically named in the format of *Qualifiers.Resource group type*. For example, if you create a subdirectory by setting **Color Mode** to **Dark** and **Resource type** to **Element**, the system automatically generates a subdirectory named **dark.element**. + Right-click the **resources** directory and choose **New > Resource File**. If no qualifier is selected, the file is created in a resource type subdirectory under **base**. If one or more qualifiers are selected, the system automatically generates a subdirectory and creates the file in this subdirectory. To select a qualifier, highlight it under **Available qualifiers** and click the right arrow. To deselect a qualifier, highlight it under **Selected qualifiers** and click the left arrow. In **File name**, enter the name of the resource file to create. In **Resource type**, select the type of the resource group, which is **element** by default. In **Root Element**, select a resource type. The created subdirectory is automatically named in the format of *Qualifiers.Resource group type*. For example, if you create a subdirectory by setting **Color Mode** to **Dark** and **Resource type** to **Element**, the system automatically generates a subdirectory named **dark.element**. ![create-resource-file-1](figures/create-resource-file-1.png) -- Creating a resource directory +- Creating a Resource Directory - Right-click the **resources** directory and choose **New > Resource Directory**. This operation creates a subdirectory only. By default, the **base** subdirectory is created. You can create qualifiers subdirectories as required, by specifying the qualifier and resource group type. After determining the qualifier, select a resource group type. Currently, the resource group type can be **Element**, **Media**, or **Profile**. After a resource group is created, a directory name is automatically generated. + Right-click the **resources** directory and choose **New > Resource Directory** to create a subdirectory only. By default, the **base** subdirectory is created. You can create qualifiers subdirectories as required, by specifying the qualifier and resource group type. ![create-resource-file-2](figures/create-resource-file-2.png) -- Creating a resource file +- Creating a Resource File - Right-click a subdirectory under **resources** and choose **New > *example* Resource File**. This operation creates a resource file under this subdirectory. For example, you can create an element resource file in the **element** subdirectory. + Right-click a subdirectory under **resources** and choose **New > *XXX* Resource File**. This operation creates a resource file under this subdirectory. For example, you can create an element resource file in the **element** subdirectory. ![create-resource-file-3](figures/create-resource-file-3.png) **Accessing Application Resources** -To reference an application resource in a project, use the `"$r('app.type.name')"` format. **app** indicates the resource defined in the **resources** directory of the application. **type** indicates the resource type (or the location where the resource is stored). The value can be **color**, **float**, **string**, **plural**, or **media**. **name** indicates the resource name, which you set when defining the resource. +To reference an application resource in a project, use the **"$r('app.type.name')"** format. **app** indicates the resource defined in the **resources** directory of the application. **type** indicates the resource type (or the location where the resource is stored). The value can be **color**, **float**, **string**, **plural**, or **media**. **name** indicates the resource name, which you set when defining the resource. -When referencing resources in the **rawfile** subdirectory, use the `"$rawfile('filename')"` format. Wherein **filename** indicates the relative path of a file in the **rawfile** subdirectory, which must contain the file name extension and cannot start with a slash (/). +When referencing resources in the **rawfile** subdirectory, use the **"$rawfile('filename')"** format. Wherein **filename** indicates the relative path of a file in the **rawfile** subdirectory, which must contain the file name extension and cannot start with a slash (/). > **NOTE** > -> Resource descriptors accept only strings, such as `'app.type.name'`, and cannot be combined. +> Resource descriptors accept only strings, such as **'app.type.name'**, and cannot be combined. > -> The return value of `$r` is a Resource object. You can obtain the corresponding string by using the [getStringValue](../reference/apis/js-apis-resource-manager.md#getstringvalue9) method. +> The return value of **$r** is a **Resource** object. You can obtain the corresponding string by using the [getStringValue](../reference/apis/js-apis-resource-manager.md#getstringvalue9) API. -In the ***example*.ets** file, you can use the resources defined in the **resources** directory. The following is a resource usage example based on the resource file examples in [Resource Group Subdirectory](#resource-group-subdirectory): +In the **.ets** file, you can use the resources defined in the **resources** directory. As described in [Resource Group Subdirectories](#resource-group-subdirectories), you can reference .json resource files, including **color.json**, **string.json**, and **plural.json**. The usage is as follows: ```ts Text($r('app.string.string_hello')) @@ -257,13 +257,14 @@ Text($r('app.string.string_world')) .fontColor($r('app.color.color_world')) .fontSize($r('app.float.font_world')) -// Reference string resources. The second parameter of $r is used to replace %s, and value is "We will arrive at five of the clock". +// Reference string resources. The first parameter of $r indicates the string resource, and the second parameter is used to replace %s in the string.json file. +// In this example, the resultant value is "We will arrive at five of the clock". Text($r('app.string.message_arrive', "five of the clock")) .fontColor($r('app.color.color_hello')) .fontSize($r('app.float.font_hello')) -// Reference plural resources. The first parameter indicates the plural resource, the second parameter indicates the number of plural resources, and the third parameter indicates the substitute of %d. -// The value is "5 apple" in singular form and "5 apples" in plural form. +// Reference plural resources. The first parameter of $r indicates the plural resource, the second parameter indicates the number of plural resources (for English, **one** indicates singular and is represented by **1**, and **other** indicates plural and is represented by an integer greater than or equal to 1; for Chinese, **other** indicates both singular and plural), and the third parameter is used to replace %d. +// In this example, the resultant value is "5 apples". Text($r('app.plural.eat_apple', 5, 5)) .fontColor($r('app.color.color_world')) .fontSize($r('app.float.font_world')) @@ -279,13 +280,13 @@ Image($rawfile('newDir/newTest.png')) // Reference an image in the rawfile System resources include colors, rounded corners, fonts, spacing, character strings, and images. By using system resources, you can develop different applications with the same visual style. -To reference a system resource, use the `"$r('sys.type.resource_id')"` format. Wherein: **sys** indicates a system resource; **type** indicates the resource type, which can be **color**, **float**, **string**, or **media**; **resource_id** indicates the resource ID. +To reference a system resource, use the **"$r('sys.type.resource_id')"** format. Wherein: **sys** indicates a system resource; **type** indicates the resource type, which can be **color**, **float**, **string**, or **media**; **resource_id** indicates the resource ID. > **NOTE** > > - Use of system resources is supported in the declarative development paradigm, but not in the web-like development paradigm. > -> - For details about the implementation of preconfigured resources, visit the [OpenHarmony/resources repository](https://gitee.com/openharmony/resources/tree/master/systemres/main/resources). The directory structure there is similar to that of the **resources** directory in the project. Resource qualifiers are used to match resources with different devices and device status. +> - For details about the implementation of preconfigured resources, visit the [OpenHarmony/resources repository](https://gitee.com/openharmony/resources/tree/master/systemres/main/resources). The directory structure there is similar to that of the **resources** directory in the project. Resource qualifiers are used to match resources with different devices and device states. ```ts Text('Hello') diff --git a/en/application-dev/quick-start/start-with-ets-fa.md b/en/application-dev/quick-start/start-with-ets-fa.md index 019490d354b8d7c6b6ff7771065aae1b7534b76c..36fe7adfb84fa9ea5a5e735a61d71ca44dbe6dab 100644 --- a/en/application-dev/quick-start/start-with-ets-fa.md +++ b/en/application-dev/quick-start/start-with-ets-fa.md @@ -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) diff --git a/en/application-dev/quick-start/start-with-ets-stage.md b/en/application-dev/quick-start/start-with-ets-stage.md index d18a01875cf2e52abd45b493f8223c596912276d..978ffd47a206abc5f5b3e047a8d7f3dcc0e599e9 100644 --- a/en/application-dev/quick-start/start-with-ets-stage.md +++ b/en/application-dev/quick-start/start-with-ets-stage.md @@ -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) diff --git a/en/application-dev/quick-start/start-with-js-fa.md b/en/application-dev/quick-start/start-with-js-fa.md index abb27d9fb942a406e22d98285626984bdc63d197..812be6247b4ed3aae55dd1f67b0ee5bb47f01065 100644 --- a/en/application-dev/quick-start/start-with-js-fa.md +++ b/en/application-dev/quick-start/start-with-js-fa.md @@ -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) diff --git a/en/application-dev/reference/apis/js-apis-accessibility.md b/en/application-dev/reference/apis/js-apis-accessibility.md index cf4443c60f4b58a17986bdb7ae5160fd6a95347c..edd869ff076cf3b87920505470fb228759ce5980 100644 --- a/en/application-dev/reference/apis/js-apis-accessibility.md +++ b/en/application-dev/reference/apis/js-apis-accessibility.md @@ -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 diff --git a/en/application-dev/reference/apis/js-apis-commonEvent.md b/en/application-dev/reference/apis/js-apis-commonEvent.md index 1551404f13c5d662cda9cf77b25155f7e9d04e92..d77715182ee3c166d571b95f84ef0ed683dfad4d 100644 --- a/en/application-dev/reference/apis/js-apis-commonEvent.md +++ b/en/application-dev/reference/apis/js-apis-commonEvent.md @@ -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(deprecated) publish(event: string, callback: AsyncCallback\): 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(deprecated) publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\): 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\ | Yes | Callback used to return the result. | +| callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -92,14 +98,16 @@ function publishCallBack(err) { CommonEvent.publish("event", options, publishCallBack); ``` - - -## CommonEvent.publishAsUser8+ +## CommonEvent.publishAsUser(deprecated) publishAsUser(event: string, userId: number, callback: AsyncCallback\): 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.publishAsUser8+ +## CommonEvent.publishAsUser(deprecated) publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback\): 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(deprecated) createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback\): 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(deprecated) createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\ 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(deprecated) subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\): 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(deprecated) unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\): 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 diff --git a/en/application-dev/reference/apis/js-apis-commonEventManager.md b/en/application-dev/reference/apis/js-apis-commonEventManager.md index 225bd59b0ae8e7fa2b33b50efaa875bdb82705be..f58c4096876b4a63dc1ed54d541c7fc6f9c9283b 100644 --- a/en/application-dev/reference/apis/js-apis-commonEventManager.md +++ b/en/application-dev/reference/apis/js-apis-commonEventManager.md @@ -38,8 +38,7 @@ For details about the error codes, see [Event Error Codes](../errorcodes/errorco | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | -| 1500004 | not System services. | +| 1500004 | not System services or System app. | | 1500007 | error sending message to Common Event Service. | | 1500008 | Common Event Service does not complete initialization. | | 1500009 | error obtaining system parameters. | @@ -83,8 +82,7 @@ Publishes a common event with given attributes. This API uses an asynchronous ca **Error codes** | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | -| 1500004 | not System services. | +| 1500004 | not System services or System app. | | 1500007 | error sending message to Common Event Service. | | 1500008 | Common Event Service does not complete initialization. | | 1500009 | error obtaining system parameters. | @@ -139,9 +137,7 @@ Publishes a common event to a specific user. This API uses an asynchronous callb **Error codes** | ID| Error Message | | -------- | ----------------------------------- | -| 202 | not system app. | -| 401 | The parameter check failed. | -| 1500004 | not System services. | +| 1500004 | not System services or System app. | | 1500007 | error sending message to Common Event Service. | | 1500008 | Common Event Service does not complete initialization. | | 1500009 | error obtaining system parameters. | @@ -193,9 +189,7 @@ Publishes a common event with given attributes to a specific user. This API uses **Error codes** | ID| Error Message | | -------- | ----------------------------------- | -| 202 | not system app. | -| 401 | The parameter check failed. | -| 1500004 | not System services. | +| 1500004 | not System services or System app. | | 1500007 | error sending message to Common Event Service. | | 1500008 | Common Event Service does not complete initialization. | | 1500009 | error obtaining system parameters. | @@ -246,14 +240,6 @@ Creates a subscriber. This API uses an asynchronous callback to return the resul | subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information. | | callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Yes | Callback used to return the result.| -**Error codes** - - For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). - -| ID| Error Message | -| -------- | ----------------------------------- | -| 401 | The parameter check failed. | - **Example** @@ -304,14 +290,6 @@ Creates a subscriber. This API uses a promise to return the result. | --------------------------------------------------------- | ---------------- | | Promise\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Promise used to return the subscriber object.| -**Error codes** - - For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). - -| ID| Error Message | -| -------- | ----------------------------------- | -| 401 | The parameter check failed. | - **Example** ```ts @@ -359,7 +337,6 @@ Subscribes to common events. This API uses an asynchronous callback to return th | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 801 | capability not supported. | | 1500007 | error sending message to Common Event Service. | | 1500008 | Common Event Service does not complete initialization. | @@ -431,7 +408,6 @@ Unsubscribes from common events. This API uses an asynchronous callback to retur | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 801 | capability not supported. | | 1500007 | error sending message to Common Event Service. | | 1500008 | Common Event Service does not complete initialization. | @@ -490,737 +466,6 @@ try { } ``` -## CommonEventSubscriber - -### getCode - -getCode(callback: AsyncCallback\): void - -Obtains the result code of this common event. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Notification.CommonEvent - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ------------------ | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Error codes** - - For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). - -| ID| Error Message | -| -------- | ----------------------------------- | -| 201 | The application dose not have permission to call the interface. | -| 202 | not system app. | -| 401 | The parameter check failed. | -| 1500004 | not system service. | -| 1500007 | The message send error. | -| 1500008 | The CEMS error. | - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -// Callback for result code obtaining of an ordered common event. -function getCodeCallback(err, Code) { - if (err) { - console.error("getCode failed " + JSON.stringify(err)); - } else { - console.info("getCode " + JSON.stringify(Code)); - } -} -subscriber.getCode(getCodeCallback); -``` - -### getCode - -getCode(): Promise\ - -Obtains the result code of this common event. This API uses a promise to return the result. - -**System capability**: SystemCapability.Notification.CommonEvent - -**Return value** - -| Type | Description | -| ---------------- | -------------------- | -| Promise\ | Promise used to return the result.| - -**Error codes** - - For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). - -| ID| Error Message | -| -------- | ----------------------------------- | -| 201 | The application dose not have permission to call the interface. | -| 202 | not system app. | -| 401 | The parameter check failed. | -| 1500004 | not system service. | -| 1500007 | The message send error. | -| 1500008 | The CEMS error. | - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -subscriber.getCode().then((Code) => { - console.info("getCode " + JSON.stringify(Code)); -}).catch((err) => { - console.error("getCode failed " + JSON.stringify(err)); -}); -``` - -### setCode - -setCode(code: number, callback: AsyncCallback\): void - -Sets the result code for this common event. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Notification.CommonEvent - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ---------------------- | -| code | number | Yes | Result code of the common event. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -// Callback for result code setting of an ordered common event. -function setCodeCallback(err) { - if (err) { - console.error("setCode failed " + JSON.stringify(err)); - } else { - console.info("setCode"); - } -} -subscriber.setCode(1, setCodeCallback); -``` - -### setCode - -setCode(code: number): Promise\ - -Sets the result code for this common event. This API uses a promise to return the result. - -**System capability**: SystemCapability.Notification.CommonEvent - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------ | -| code | number | Yes | Result code of the common event.| - -**Return value** - -| Type | Description | -| ---------------- | -------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -subscriber.setCode(1).then(() => { - console.info("setCode"); -}).catch((err) => { - console.error("setCode failed " + JSON.stringify(err)); -}); -``` - -### getData - -getData(callback: AsyncCallback\): void - -Obtains the result data of this common event. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Notification.CommonEvent - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | -------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result data.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -// Callback for result data obtaining of an ordered common event. -function getDataCallback(err, Data) { - if (err) { - console.error("getData failed " + JSON.stringify(err)); - } else { - console.info("getData " + JSON.stringify(Data)); - } -} -subscriber.getData(getDataCallback); -``` - -### getData - -getData(): Promise\ - -Obtains the result data of this common event. This API uses a promise to return the result. - -**System capability**: SystemCapability.Notification.CommonEvent - -**Return value** - -| Type | Description | -| ---------------- | ------------------ | -| Promise\ | Promise used to return the result data.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -subscriber.getData().then((Data) => { - console.info("getData " + JSON.stringify(Data)); -}).catch((err) => { - console.error("getData failed " + JSON.stringify(err)); -}); -``` - -### setData - -setData(data: string, callback: AsyncCallback\): void - -Sets the result data for this common event. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Notification.CommonEvent - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | -------------------- | -| data | string | Yes | Result data of the common event. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -// Callback for result data setting of an ordered common event -function setDataCallback(err) { - if (err) { - console.error("setData failed " + JSON.stringify(err)); - } else { - console.info("setData"); - } -} -subscriber.setData("publish_data_changed", setDataCallback); -``` - -### setData - -setData(data: string): Promise\ - -Sets the result data for this common event. This API uses a promise to return the result. - -**System capability**: SystemCapability.Notification.CommonEvent - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | -------------------- | -| data | string | Yes | Result data of the common event.| - -**Return value** - -| Type | Description | -| ---------------- | -------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -subscriber.setData("publish_data_changed").then(() => { - console.info("setData"); -}).catch((err) => { - console.error("setData failed " + JSON.stringify(err)); -}); -``` - -### setCodeAndData - -setCodeAndData(code: number, data: string, callback:AsyncCallback\): void - -Sets the result code and result data for this common event. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Notification.CommonEvent - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ---------------------- | -| code | number | Yes | Result code of the common event. | -| data | string | Yes | Result data of the common event. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -// Callback for result code and result data setting of an ordered common event. -function setCodeDataCallback(err) { - if (err) { - console.error("setCodeAndData failed " + JSON.stringify(err)); - } else { - console.info("setCodeDataCallback"); - } -} -subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCallback); -``` - -### setCodeAndData - -setCodeAndData(code: number, data: string): Promise\ - -Sets the result code and result data for this common event. This API uses a promise to return the result. - -**System capability**: SystemCapability.Notification.CommonEvent - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | -------------------- | -| code | number | Yes | Result code of the common event.| -| data | string | Yes | Result data of the common event.| - -**Return value** - -| Type | Description | -| ---------------- | -------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -subscriber.setCodeAndData(1, "publish_data_changed").then(() => { - console.info("setCodeAndData"); -}).catch((err) => { - console.info("setCodeAndData failed " + JSON.stringify(err)); -}); -``` - -### isOrderedCommonEvent - -isOrderedCommonEvent(callback: AsyncCallback\): void - -Checks whether this common event is an ordered one. This API uses an asynchronous callback to return the result. - - - -**System capability**: SystemCapability.Notification.CommonEvent - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ----------------------- | ---- | ---------------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result. The value **true** means that the common event is an ordered one; and **false** means the opposite.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -// Callback for checking whether the current common event is an ordered one. -function isOrderedCallback(err, isOrdered) { - if (err) { - console.error("isOrderedCommonEvent failed " + JSON.stringify(err)); - } else { - console.info("isOrdered " + JSON.stringify(isOrdered)); - } -} -subscriber.isOrderedCommonEvent(isOrderedCallback); -``` - -### isOrderedCommonEvent - -isOrderedCommonEvent(): Promise\ - -Checks whether this common event is an ordered one. This API uses a promise to return the result. - - - -**System capability**: SystemCapability.Notification.CommonEvent - -**Return value** - -| Type | Description | -| ----------------- | -------------------------------- | -| Promise\ | Promise used to return the result. The value **true** means that the common event is an ordered one; and **false** means the opposite.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -subscriber.isOrderedCommonEvent().then((isOrdered) => { - console.info("isOrdered " + JSON.stringify(isOrdered)); -}).catch((err) => { - console.error("isOrdered failed " + JSON.stringify(err)); -}); -``` - -### isStickyCommonEvent - -isStickyCommonEvent(callback: AsyncCallback\): void - -Checks whether this common event is a sticky one. This API uses an asynchronous callback to return the result. - - - -**System capability**: SystemCapability.Notification.CommonEvent - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ----------------------- | ---- | ---------------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result. The value **true** means that the common event is a sticky one; and **false** means the opposite.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -// Callback for checking whether the current common event is a sticky one. -function isStickyCallback(err, isSticky) { - if (err) { - console.error("isStickyCommonEvent failed " + JSON.stringify(err)); - } else { - console.info("isSticky " + JSON.stringify(isSticky)); - } -} -subscriber.isStickyCommonEvent(isStickyCallback); -``` - -### isStickyCommonEvent - -isStickyCommonEvent(): Promise\ - -Checks whether this common event is a sticky one. This API uses a promise to return the result. - - - -**System capability**: SystemCapability.Notification.CommonEvent - -**Return value** - -| Type | Description | -| ----------------- | -------------------------------- | -| Promise\ | Promise used to return the result. The value **true** means that the common event is a sticky one; and **false** means the opposite.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -subscriber.isStickyCommonEvent().then((isSticky) => { - console.info("isSticky " + JSON.stringify(isSticky)); -}).catch((err) => { - console.error("isSticky failed " + JSON.stringify(err)); -}); -``` - -### abortCommonEvent - -abortCommonEvent(callback: AsyncCallback\): void - -Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Notification.CommonEvent - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | -------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -// Callback for common event aborting. -function abortCallback(err) { - if (err) { - console.error("abortCommonEvent failed " + JSON.stringify(err)); - } else { - console.info("abortCommonEvent"); - } -} -subscriber.abortCommonEvent(abortCallback); -``` - -### abortCommonEvent - -abortCommonEvent(): Promise\ - -Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses a promise to return the result. - -**System capability**: SystemCapability.Notification.CommonEvent - -**Return value** - -| Type | Description | -| ---------------- | -------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -subscriber.abortCommonEvent().then(() => { - console.info("abortCommonEvent"); -}).catch((err) => { - console.error("abortCommonEvent failed " + JSON.stringify(err)); -}); -``` - -### clearAbortCommonEvent - -clearAbortCommonEvent(callback: AsyncCallback\): void - -Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Notification.CommonEvent - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | -------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -// Callback for clearing the aborted state of the current common event. -function clearAbortCallback(err) { - if (err) { - console.error("clearAbortCommonEvent failed " + JSON.stringify(err)); - } else { - console.info("clearAbortCommonEvent"); - } -} -subscriber.clearAbortCommonEvent(clearAbortCallback); -``` - -### clearAbortCommonEvent - -clearAbortCommonEvent(): Promise\ - -Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses a promise to return the result. - -**System capability**: SystemCapability.Notification.CommonEvent - -**Return value** - -| Type | Description | -| ---------------- | -------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -subscriber.clearAbortCommonEvent().then(() => { - console.info("clearAbortCommonEvent"); -}).catch((err) => { - console.error("clearAbortCommonEvent failed " + JSON.stringify(err)); -}); -``` - -### getAbortCommonEvent - -getAbortCommonEvent(callback: AsyncCallback\): void - -Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Notification.CommonEvent - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ----------------------- | ---- | ---------------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result. The value **true** means that the ordered common event is in the aborted state; and **false** means the opposite.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -// Callback for checking whether the current common event is in the aborted state. -function getAbortCallback(err, AbortCommonEvent) { - if (err) { - console.error("getAbortCommonEvent failed " + JSON.stringify(err)); - } else { - console.info("AbortCommonEvent " + AbortCommonEvent) - } -} -subscriber.getAbortCommonEvent(getAbortCallback); -``` - -### getAbortCommonEvent - -getAbortCommonEvent(): Promise\ - -Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses a promise to return the result. - -**System capability**: SystemCapability.Notification.CommonEvent - -**Return value** - -| Type | Description | -| ----------------- | ---------------------------------- | -| Promise\ | Promise used to return the result. The value **true** means that the ordered common event is in the aborted state; and **false** means the opposite.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -subscriber.getAbortCommonEvent().then((AbortCommonEvent) => { - console.info("AbortCommonEvent " + JSON.stringify(AbortCommonEvent)); -}).catch((err) => { - console.error("getAbortCommonEvent failed " + JSON.stringify(err)); -}); -``` - -### getSubscribeInfo - -getSubscribeInfo(callback: AsyncCallback\): void - -Obtains the subscriber information. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Notification.CommonEvent - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------------------ | ---- | ---------------------- | -| callback | AsyncCallback\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | Yes | Callback used to return the subscriber information.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -// Callback for subscriber information obtaining. -function getSubscribeInfoCallback(err, SubscribeInfo) { - if (err) { - console.error("getSubscribeInfo failed " + JSON.stringify(err)); - } else { - console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo)); - } -} -subscriber.getSubscribeInfo(getSubscribeInfoCallback); -``` - -### getSubscribeInfo - -getSubscribeInfo(): Promise\ - -Obtains the subscriber information. This API uses a promise to return the result. - -**System capability**: SystemCapability.Notification.CommonEvent - -**Return value** - -| Type | Description | -| ------------------------------------------------------------ | ---------------------- | -| Promise\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | Promise used to return the subscriber information.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -subscriber.getSubscribeInfo().then((SubscribeInfo) => { - console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo)); -}).catch((err) => { - console.error("getSubscribeInfo failed " + JSON.stringify(err)); -}); -``` - -### finishCommonEvent9+ - -finishCommonEvent(callback: AsyncCallback\): void - -Finishes this ordered common event. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Notification.CommonEvent - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | -------------------------------- | -| callback | AsyncCallback\ | Yes | Callback returned after the ordered common event is finished.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -// Callback for ordered common event finishing. -function finishCommonEventCallback(err) { - if (err) { - console.error("finishCommonEvent failed " + JSON.stringify(err)); -} else { - console.info("FinishCommonEvent"); -} -} -subscriber.finishCommonEvent(finishCommonEventCallback); -``` - -### finishCommonEvent9+ - -finishCommonEvent(): Promise\ - -Finishes this ordered common event. This API uses a promise to return the result. - -**System capability**: SystemCapability.Notification.CommonEvent - -**Return value** - -| Type | Description | -| ---------------- | -------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```ts -var subscriber; // Subscriber object successfully created. - -subscriber.finishCommonEvent().then(() => { - console.info("FinishCommonEvent"); -}).catch((err) => { - console.error("finishCommonEvent failed " + JSON.stringify(err)); -}); -``` - ## CommonEventData **System capability**: SystemCapability.Notification.CommonEvent diff --git a/en/application-dev/reference/apis/js-apis-defaultAppManager.md b/en/application-dev/reference/apis/js-apis-defaultAppManager.md index ad8ab9f54dfd43754e6e00cdfbe5ba5c9e1d39c4..cd2d0daf6d09dbe0d688255add12ce44d0004075 100644 --- a/en/application-dev/reference/apis/js-apis-defaultAppManager.md +++ b/en/application-dev/reference/apis/js-apis-defaultAppManager.md @@ -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** diff --git a/en/application-dev/reference/apis/js-apis-file-environment.md b/en/application-dev/reference/apis/js-apis-file-environment.md index c87c8465d7909f495baf6babad02e8e5b118424c..fb48f1a4103cb29bff4fb48e076ef2d87c717ab2 100644 --- a/en/application-dev/reference/apis/js-apis-file-environment.md +++ b/en/application-dev/reference/apis/js-apis-file-environment.md @@ -1,12 +1,11 @@ # @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<string> | 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<string> | 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<string> -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<string> | Promise returned with the root directory of public files.| +| Promise<string> | 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<string>): 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<string> | Yes | Asynchronous callback used to return the root directory of public files.| +| callback | AsyncCallback<string> | 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** diff --git a/en/application-dev/reference/apis/js-apis-file-fileuri.md b/en/application-dev/reference/apis/js-apis-file-fileuri.md index f8c6717fab58f9ca5eacac6ebc3963a6faae63fa..1aa5fe9cf08005980285bd04ae87763e58de8751 100644 --- a/en/application-dev/reference/apis/js-apis-file-fileuri.md +++ b/en/application-dev/reference/apis/js-apis-file-fileuri.md @@ -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 diff --git a/en/application-dev/reference/apis/js-apis-file-fs.md b/en/application-dev/reference/apis/js-apis-file-fs.md index c8ed1ccd4af2aaf2713c98388b65c991e4c24c06..7f55fb64daecf5c341a39f0e3a79f76df2372c61 100644 --- a/en/application-dev/reference/apis/js-apis-file-fs.md +++ b/en/application-dev/reference/apis/js-apis-file-fs.md @@ -14,7 +14,7 @@ import fs from '@ohos.file.fs'; ## Guidelines -Before using the APIs provided by this module to perform operations on a file or folder, obtain the application sandbox path of the file or folder as follows: +Before using the APIs provided by this module to perform operations on a file or directory, obtain the application sandbox path of the file or directory as follows: **Stage Model** @@ -58,13 +58,13 @@ Obtains detailed file information. This API uses a promise to return the result. **Return value** -| Type | Description | -| ---------------------------- | ---------- | -| Promise<[Stat](#stat)> | Promise used to return the file information obtained.| + | Type | Description | + | ---------------------------- | ---------- | + | Promise<[Stat](#stat)> | Promise used to return the file information obtained.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -94,7 +94,7 @@ Obtains detailed file information. This API uses an asynchronous callback to ret **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -124,13 +124,13 @@ Obtains detailed file information synchronously. **Return value** -| Type | Description | -| ------------- | ---------- | -| [Stat](#stat) | File information obtained.| + | Type | Description | + | ------------- | ---------- | + | [Stat](#stat) | File information obtained.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -155,13 +155,13 @@ Checks whether a file exists. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<boolean> | Promise used to return the result. The value **true** means the file exists; the value false means the opposite.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<boolean> | Promise used to return the result. The value **true** means the file exists; the value **false** means the opposite.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -193,7 +193,7 @@ Checks whether a file exists. This API uses an asynchronous callback to return t **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -226,13 +226,13 @@ Synchronously checks whether a file exists. **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| boolean | Returns **true** if the file exists; returns **false** otherwise.| + | Type | Description | + | ------------------- | ---------------------------- | + | boolean | Returns **true** if the file exists; returns **false** otherwise.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -259,19 +259,19 @@ Closes a file. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------------ | -| file | [File](#file)\|number | Yes | File object or FD of the file to close.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | file | [File](#file)\|number | Yes | File object or FD of the file to close.| **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -296,14 +296,14 @@ Closes a file. This API uses an asynchronous callback to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | ------------ | -| file | [File](#file)\|number | Yes | File object or FD of the file to close.| -| callback | AsyncCallback<void> | Yes | Callback invoked when the file is closed asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ------------ | + | file | [File](#file)\|number | Yes | File object or FD of the file to close.| + | callback | AsyncCallback<void> | Yes | Callback invoked immediately after the file is closed.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -329,13 +329,13 @@ Synchronously closes a file. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------------ | -| file | [File](#file)\|number | Yes | File object or FD of the file to close.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | file | [File](#file)\|number | Yes | File object or FD of the file to close.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -355,21 +355,21 @@ Copies a file. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | -------------------------- | ---- | ---------------------------------------- | -| src | string\|number | Yes | Path or FD of the file to copy. | -| dest | string\|number | Yes | Destination path of the file or FD of the file created. | -| mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: overwrite the file of the same name.| + | Name | Type | Mandatory | Description | + | ---- | -------------------------- | ---- | ---------------------------------------- | + | src | string\|number | Yes | Path or FD of the file to copy. | + | dest | string\|number | Yes | Destination path of the file or FD of the file created. | + | mode | number | No | Whether to overwrite the file with the same name in the destination directory. The default value is **0**, which is the only value supported.
**0**: overwrite the file with the same name.| **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -393,16 +393,16 @@ Copies a file. This API uses an asynchronous callback to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------------------------- | ---- | ---------------------------------------- | -| src | string\|number | Yes | Path or FD of the file to copy. | -| dest | string\|number | Yes | Destination path of the file or FD of the file created. | -| mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: overwrite the file with the same name and truncate the part that is not overwritten.| -| callback | AsyncCallback<void> | Yes | Callback invoked when the file is copied asynchronously. | + | Name | Type | Mandatory | Description | + | -------- | -------------------------- | ---- | ---------------------------------------- | + | src | string\|number | Yes | Path or FD of the file to copy. | + | dest | string\|number | Yes | Destination path of the file or FD of the file created. | + | mode | number | No | Whether to overwrite the file with the same name in the destination directory. The default value is **0**, which is the only value supported.
**0**: overwrite the file with the same name and truncate the part that is not overwritten.| + | callback | AsyncCallback<void> | Yes | Callback invoked immediately after the file is copied. | **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -429,15 +429,15 @@ Synchronously copies a file. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | -------------------------- | ---- | ---------------------------------------- | -| src | string\|number | Yes | Path or FD of the file to copy. | -| dest | string\|number | Yes | Destination path of the file or FD of the file created. | -| mode | number | No | Whether to overwrite the file of the same name in the destination path. The default value is **0**, which is the only value supported.
**0**: overwrite the file with the same name and truncate the part that is not overwritten.| + | Name | Type | Mandatory | Description | + | ---- | -------------------------- | ---- | ---------------------------------------- | + | src | string\|number | Yes | Path or FD of the file to copy. | + | dest | string\|number | Yes | Destination path of the file or FD of the file created. | + | mode | number | No | Whether to overwrite the file with the same name in the destination directory. The default value is **0**, which is the only value supported.
**0**: overwrite the file with the same name and truncate the part that is not overwritten.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -463,13 +463,13 @@ Creates a directory. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -499,7 +499,7 @@ Creates a directory. This API uses an asynchronous callback to return the result **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -530,7 +530,7 @@ Synchronously creates a directory. **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -556,13 +556,13 @@ Opens a file. This API uses a promise to return the result. File uniform resourc **Return value** -| Type | Description | -| --------------------- | ----------- | -| Promise<[File](#file)> | Promise used to return the file object.| + | Type | Description | + | --------------------- | ----------- | + | Promise<[File](#file)> | Promise used to return the file object.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -593,7 +593,7 @@ Opens a file. This API uses an asynchronous callback to return the result. File **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -625,13 +625,13 @@ Synchronously opens a file. File URIs are supported. **Return value** -| Type | Description | -| ------ | ----------- | -| [File](#file) | File object opened.| + | Type | Description | + | ------ | ----------- | + | [File](#file) | File object opened.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -660,13 +660,13 @@ Reads data from a file. This API uses a promise to return the result. **Return value** -| Type | Description | -| ---------------------------------- | ------ | -| Promise<number> | Promise used to return the data read.| + | Type | Description | + | ---------------------------------- | ------ | + | Promise<number> | Promise used to return the data read.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -693,16 +693,16 @@ Reads data from a file. This API uses an asynchronous callback to return the res **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | -| options | Object | No | The options are as follows:
- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.| -| callback | AsyncCallback<number> | Yes | Callback invoked when the data is read asynchronously. | + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.| + | callback | AsyncCallback<number> | Yes | Callback invoked when the data is read asynchronously. | **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -731,21 +731,21 @@ Synchronously reads data from a file. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ----------- | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | -| options | Object | No | The options are as follows:
- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.| + | Name | Type | Mandatory | Description | + | ------- | ----------- | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | + | options | Object | No | The options are as follows:
- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.| **Return value** -| Type | Description | -| ------ | -------- | -| number | Length of the data read.| + | Type | Description | + | ------ | -------- | + | number | Length of the data read.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -773,13 +773,13 @@ Deletes a directory. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -809,7 +809,7 @@ Deletes a directory. This API uses an asynchronous callback to return the result **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -840,7 +840,7 @@ Synchronously deletes a directory. **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -865,13 +865,13 @@ Deletes a file. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -897,11 +897,11 @@ Deletes a file. This API uses an asynchronous callback to return the result. | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | -------------------------- | | path | string | Yes | Application sandbox path of the file.| -| callback | AsyncCallback<void> | Yes | Callback invoked when the file is deleted asynchronously. | +| callback | AsyncCallback<void> | Yes | Callback invoked immediately after the file is deleted. | **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -932,7 +932,7 @@ Synchronously deletes a file. **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -952,21 +952,21 @@ Writes data into a file. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ------------------------------- | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | -| options | Object | No | The options are as follows:
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| + | Name | Type | Mandatory | Description | + | ------- | ------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| **Return value** -| Type | Description | -| --------------------- | -------- | -| Promise<number> | Promise used to return the length of the data written.| + | Type | Description | + | --------------------- | -------- | + | Promise<number> | Promise used to return the length of the data written.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -991,16 +991,16 @@ Writes data into a file. This API uses an asynchronous callback to return the re **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------- | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | -| options | Object | No | The options are as follows:
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| -| callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | + | Name | Type | Mandatory | Description | + | -------- | ------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| + | callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1027,21 +1027,21 @@ Synchronously writes data into a file. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ------------------------------- | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | -| options | Object | No | The options are as follows:
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| + | Name | Type | Mandatory | Description | + | ------- | ------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| **Return value** -| Type | Description | -| ------ | -------- | -| number | Length of the data written in the file.| + | Type | Description | + | ------ | -------- | + | number | Length of the data written in the file.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1070,13 +1070,13 @@ Truncates a file. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1108,7 +1108,7 @@ Truncates a file. This API uses an asynchronous callback to return the result. **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1141,7 +1141,7 @@ Synchronously truncates a file. **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1168,13 +1168,13 @@ Reads the text content of a file. This API uses a promise to return the result. **Return value** -| Type | Description | -| --------------------- | ---------- | -| Promise<string> | Promise used to return the content read.| + | Type | Description | + | --------------------- | ---------- | + | Promise<string> | Promise used to return the content read.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1205,7 +1205,7 @@ Reads the text content of a file. This API uses an asynchronous callback to retu **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1237,13 +1237,13 @@ Synchronously reads the text of a file. **Return value** -| Type | Description | -| ------ | -------------------- | -| string | Promise used to return the content of the file read.| + | Type | Description | + | ------ | -------------------- | + | string | Promise used to return the content of the file read.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1269,13 +1269,13 @@ Obtains information about a symbolic link. This API uses a promise to return the **Return value** -| Type | Description | -| ---------------------------- | ---------- | -| Promise<[Stat](#stat)> | Promise used to return the symbolic link information obtained. For details, see **stat**.| + | Type | Description | + | ---------------------------- | ---------- | + | Promise<[Stat](#stat)> | Promise used to return the symbolic link information obtained. For details, see **stat**.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1305,7 +1305,7 @@ Obtains information about a symbolic link. This API uses an asynchronous callbac **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1336,13 +1336,13 @@ Obtains information about a symbolic link synchronously. **Return value** -| Type | Description | -| ------------- | ---------- | -| [Stat](#stat) | File information obtained.| + | Type | Description | + | ------------- | ---------- | + | [Stat](#stat) | File information obtained.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1355,7 +1355,7 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem rename(oldPath: string, newPath: string): Promise<void> -Renames a file or folder. This API uses a promise to return the result. +Renames a file or directory. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO @@ -1363,18 +1363,18 @@ Renames a file or folder. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | ------- | ------ | ---- | ---------------------------- | -| oldPath | string | Yes | Application sandbox path of the file or folder to rename.| -| newPath | string | Yes | Application sandbox path of the renamed file or folder. | +| oldPath | string | Yes | Application sandbox path of the file to rename.| +| newPath | string | Yes | Application sandbox path of the renamed file. | **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1392,7 +1392,7 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem rename(oldPath: string, newPath: string, callback: AsyncCallback<void>): void -Renames a file or folder. This API uses an asynchronous callback to return the result. +Renames a file or directory. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.FileManagement.File.FileIO @@ -1400,13 +1400,13 @@ Renames a file or folder. This API uses an asynchronous callback to return the r | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ---------------------------- | -| oldPath | string | Yes | Application sandbox path of the file or folder to rename.| -| newPath | string | Yes | Application sandbox path of the renamed file or folder. | -| callback | AsyncCallback<void> | Yes | Callback invoked when the file or folder is asynchronously renamed. | +| oldPath | string | Yes | Application sandbox path of the file to rename.| +| newPath | string | Yes | Application sandbox path of the renamed file. | +| callback | AsyncCallback<void> | Yes | Callback invoked when the file is asynchronously renamed. | **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1426,7 +1426,7 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem renameSync(oldPath: string, newPath: string): void -Renames a file or folder synchronously. +Renames a file or directory synchronously. **System capability**: SystemCapability.FileManagement.File.FileIO @@ -1434,12 +1434,12 @@ Renames a file or folder synchronously. | Name | Type | Mandatory| Description | | ------- | ------ | ---- | ---------------------------- | -| oldPath | string | Yes | Application sandbox path of the file or folder to rename.| -| newPath | string | Yes | Application sandbox path of the renamed file or folder. | +| oldPath | string | Yes | Application sandbox path of the file to rename.| +| newPath | string | Yes | Application sandbox path of the renamed file. | **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1459,19 +1459,19 @@ Flushes data of a file to disk. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------------ | -| fd | number | Yes | FD of the file.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | FD of the file.| **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1495,14 +1495,14 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | --------------- | -| fd | number | Yes | FD of the file. | -| Callback | AsyncCallback<void> | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | --------------- | + | fd | number | Yes | FD of the file. | + | Callback | AsyncCallback<void> | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1530,13 +1530,13 @@ Flushes data of a file to disk synchronously. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------------ | -| fd | number | Yes | FD of the file.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | FD of the file.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1557,19 +1557,19 @@ Flushes data of a file to disk. This API uses a promise to return the result. ** **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------------ | -| fd | number | Yes | FD of the file.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | FD of the file.| **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1594,14 +1594,14 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------- | ---- | ----------------- | -| fd | number | Yes | FD of the file. | -| callback | AsyncCallback<void> | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------------- | ---- | ----------------- | + | fd | number | Yes | FD of the file. | + | callback | AsyncCallback<void> | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1628,13 +1628,13 @@ Synchronizes data in a file synchronously. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ------------ | -| fd | number | Yes | FD of the file.| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ------------ | + | fd | number | Yes | FD of the file.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1662,13 +1662,13 @@ Creates a symbolic link based on a file path. This API uses a promise to return **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1700,7 +1700,7 @@ Creates a symbolic link based on a file path. This API uses an asynchronous call **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1733,7 +1733,7 @@ Synchronously creates a symbolic link based on a file path. **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1756,28 +1756,28 @@ Lists all files in a directory. This API uses a promise to return the result.
The value **0** means to overwrite the file with the same name in the destination directory; the value **1** means to throw an exception.
The default value is **0**.| **Return value** -| Type | Description | -| ------------------- | ---------------------------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------------------- | + | Promise<void> | Promise that returns no value.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1959,16 +1959,16 @@ Moves a file. This API uses an asynchronous callback to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | --------------------------- | -| src | string | Yes | Application sandbox path of the source file.| -| dest | string | Yes | Application sandbox path of the destination file.| -| mode | number | No | Whether to overwrite the file of the same name in the destination directory. The value **0** means to overwrite the file of the same name in the destination directory. The value **1** means to throw an exception if a file of the same name exists in the destination directory. The default value is **0**.| -| callback | AsyncCallback<void> | Yes | Callback invoked when the file is moved. | + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | src | string | Yes | Application sandbox path of the source file.| + | dest | string | Yes | Application sandbox path of the destination file.| + | mode | number | No | Whether to overwrite the file with the same name in the destination directory.
The value **0** means to overwrite the file with the same name in the destination directory; the value **1** means to throw an exception.
The default value is **0**.| + | callback | AsyncCallback<void> | Yes | Callback invoked when the file is moved. | **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -1994,15 +1994,15 @@ Moves a file synchronously. **Parameters** -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | --------------------------- | -| src | string | Yes | Application sandbox path of the source file.| -| dest | string | Yes | Application sandbox path of the destination file.| -| mode | number | No | Whether to overwrite the file of the same name in the destination directory. The value **0** means to overwrite the file of the same name in the destination directory. The value **1** means to throw an exception if a file of the same name exists in the destination directory. The default value is **0**.| + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | src | string | Yes | Application sandbox path of the source file.| + | dest | string | Yes | Application sandbox path of the destination file.| + | mode | number | No | Whether to overwrite the file with the same name in the destination directory.
The value **0** means to overwrite the file with the same name in the destination directory; the value **1** means to throw an exception.
The default value is **0**.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2023,19 +2023,19 @@ Creates a temporary directory. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | --------------------------- | -| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| **Return value** -| Type | Description | -| --------------------- | ---------- | -| Promise<string> | Promise used to return the unique directory generated.| + | Type | Description | + | --------------------- | ---------- | + | Promise<string> | Promise used to return the unique directory generated.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2057,14 +2057,14 @@ Creates a temporary directory. This API uses an asynchronous callback to return **Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------------- | ---- | --------------------------- | -| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| -| callback | AsyncCallback<string> | Yes | Callback invoked when a temporary directory is created asynchronously. | + | Name | Type | Mandatory | Description | + | -------- | --------------------------- | ---- | --------------------------- | + | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| + | callback | AsyncCallback<string> | Yes | Callback invoked when a temporary directory is created asynchronously. | **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2088,25 +2088,25 @@ Synchronously creates a temporary directory. **Parameters** -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | --------------------------- | -| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| + | Name | Type | Mandatory | Description | + | ------ | ------ | ---- | --------------------------- | + | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| **Return value** -| Type | Description | -| ------ | ---------- | -| string | Unique path generated.| + | Type | Description | + | ------ | ---------- | + | string | Unique path generated.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** ```js let res = fs.mkdtempSync(pathDir + "/XXXXXX"); - ``` + ``` ## fs.createStream @@ -2125,13 +2125,13 @@ Creates a stream based on the file path. This API uses a promise to return the r **Return value** -| Type | Description | -| --------------------------------- | --------- | -| Promise<[Stream](#stream)> | Promise used to return the result.| + | Type | Description | + | --------------------------------- | --------- | + | Promise<[Stream](#stream)> | Promise used to return the result.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2163,7 +2163,7 @@ Creates a stream based on the file path. This API uses an asynchronous callback **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2195,13 +2195,13 @@ Synchronously creates a stream based on the file path. **Return value** -| Type | Description | -| ------------------ | --------- | -| [Stream](#stream) | Stream opened.| + | Type | Description | + | ------------------ | --------- | + | [Stream](#stream) | Stream opened.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2221,20 +2221,20 @@ Opens a stream based on the file descriptor. This API uses a promise to return t **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| **Return value** -| Type | Description | -| --------------------------------- | --------- | -| Promise<[Stream](#stream)> | Promise used to return the result.| + | Type | Description | + | --------------------------------- | --------- | + | Promise<[Stream](#stream)> | Promise used to return the result.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2259,15 +2259,15 @@ Opens a stream based on the file descriptor. This API uses an asynchronous callb **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| -| callback | AsyncCallback<[Stream](#stream)> | Yes | Callback invoked when the stream is open asynchronously. | + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| + | callback | AsyncCallback<[Stream](#stream)> | Yes | Callback invoked when the stream is opened. | **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2294,20 +2294,20 @@ Synchronously opens a stream based on the file descriptor. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ---------------------------------------- | -| fd | number | Yes | FD of the file. | -| mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| + | Name | Type | Mandatory | Description | + | ---- | ------ | ---- | ---------------------------------------- | + | fd | number | Yes | FD of the file. | + | mode | string | Yes | - **r**: Open a file for reading. The file must exist.
- **r+**: Open a file for both reading and writing. The file must exist.
- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.
- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.
- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).
- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| **Return value** -| Type | Description | -| ------------------ | --------- | -| [Stream](#stream) | Stream opened.| + | Type | Description | + | ------------------ | --------- | + | [Stream](#stream) | Stream opened.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2327,7 +2327,7 @@ Represents detailed file information. Before calling any API of the **Stat()** c ### Attributes | Name | Type | Readable | Writable | Description | -| ------ | ------ | ---- | ---- | ---------------------------------------- | +| ------ | ------ | ---- | ---- | ---------------------------------------- | | ino | number | Yes | No | File ID. Different files on the same device have different **ino**s.| | | mode | number | Yes | No | File permissions. The meaning of each bit is as follows:
- **0o400**: The owner has the read permission on a regular file or a directory entry.
- **0o200**: The owner has the permission to write a regular file or create and delete a directory entry.
- **0o100**: The owner has the permission to execute a regular file or search for the specified path in a directory.
- **0o040**: The user group has the read permission on a regular file or a directory entry.
- **0o020**: The user group has the permission to write a regular file or create and delete a directory entry.
- **0o010**: The user group has the permission to execute a regular file or search for the specified path in a directory.
- **0o004**: Other users have the permission to read a regular file or read a directory entry.
- **0o002**: Other users have the permission to write a regular file or create and delete a directory entry.
- **0o001**: Other users have the permission to execute a regular file or search for the specified path in a directory.| | uid | number | Yes | No | ID of the file owner.| @@ -2347,13 +2347,13 @@ Checks whether this file is a block special file. A block special file supports **Return value** -| Type | Description | -| ------- | ---------------- | -| boolean | Whether the file is a block special file.| + | Type | Description | + | ------- | ---------------- | + | boolean | Whether the file is a block special file.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2372,13 +2372,13 @@ Checks whether this file is a character special file. A character special file s **Return value** -| Type | Description | -| ------- | ----------------- | -| boolean | Whether the file is a character special file.| + | Type | Description | + | ------- | ----------------- | + | boolean | Whether the file is a character special file.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2397,13 +2397,13 @@ Checks whether this file is a directory. **Return value** -| Type | Description | -| ------- | ------------- | -| boolean | Whether the file is a directory.| + | Type | Description | + | ------- | ------------- | + | boolean | Whether the file is a directory.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2422,13 +2422,13 @@ Checks whether this file is a named pipe (or FIFO). Named pipes are used for int **Return value** -| Type | Description | -| ------- | --------------------- | -| boolean | Whether the file is a FIFO.| + | Type | Description | + | ------- | --------------------- | + | boolean | Whether the file is a FIFO.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2447,13 +2447,13 @@ Checks whether this file is a regular file. **Return value** -| Type | Description | -| ------- | --------------- | -| boolean | Whether the file is a regular file.| + | Type | Description | + | ------- | --------------- | + | boolean | Whether the file is a regular file.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2472,13 +2472,13 @@ Checks whether this file is a socket. **Return value** -| Type | Description | -| ------- | -------------- | -| boolean | Whether the file is a socket.| + | Type | Description | + | ------- | -------------- | + | boolean | Whether the file is a socket.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2497,13 +2497,13 @@ Checks whether this file is a symbolic link. **Return value** -| Type | Description | -| ------- | --------------- | -| boolean | Whether the file is a symbolic link.| + | Type | Description | + | ------- | --------------- | + | boolean | Whether the file is a symbolic link.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2526,13 +2526,13 @@ Closes the stream. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ------------- | -| Promise<void> | Promise used to return the stream close result.| + | Type | Description | + | ------------------- | ------------- | + | Promise<void> | Promise used to return the stream close result.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2556,13 +2556,13 @@ Closes the stream. This API uses an asynchronous callback to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | ------------- | -| callback | AsyncCallback<void> | Yes | Callback invoked when the stream is closed asynchronously.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | ------------- | + | callback | AsyncCallback<void> | Yes | Callback invoked immediately after the stream is closed.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2573,7 +2573,7 @@ For details about error codes, see "Basic File I/O Error Codes" in [File Managem if (err) { console.info("close stream failed with error message: " + err.message + ", error code: " + err.code); } else { - console.info("close stream success"): + console.info("close stream success"); } }); ``` @@ -2588,7 +2588,7 @@ Synchronously closes the stream. **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2608,13 +2608,13 @@ Flushes the stream. This API uses a promise to return the result. **Return value** -| Type | Description | -| ------------------- | ------------- | -| Promise<void> | Promise used to return the stream flushing result.| + | Type | Description | + | ------------------- | ------------- | + | Promise<void> | Promise used to return the stream flushing result.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2638,13 +2638,13 @@ Flushes the stream. This API uses an asynchronous callback to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | -------------- | -| callback | AsyncCallback<void> | Yes | Callback invoked when the stream is asynchronously flushed.| + | Name | Type | Mandatory | Description | + | -------- | ------------------------- | ---- | -------------- | + | callback | AsyncCallback<void> | Yes | Callback invoked when the stream is asynchronously flushed.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2670,7 +2670,7 @@ Synchronously flushes the stream. **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2690,20 +2690,20 @@ Writes data into the stream. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ------------------------------- | ---- | ---------------------------------------- | -| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | -| options | Object | No | The options are as follows:
- **length** (number): length of the data to write. The default value is the buffer length.
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| + | Name | Type | Mandatory | Description | + | ------- | ------------------------------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **length** (number): length of the data to write. The default value is the buffer length.
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| **Return value** -| Type | Description | -| --------------------- | -------- | -| Promise<number> | Promise used to return the length of the data written.| + | Type | Description | + | --------------------- | -------- | + | Promise<number> | Promise used to return the length of the data written.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2727,15 +2727,15 @@ Writes data into the stream. This API uses an asynchronous callback to return th **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------- | ---- | ------------------------------------------------------------ | -| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | -| options | Object | No | The options are as follows:
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| -| callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | + | Name | Type | Mandatory| Description | + | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | + | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| + | callback | AsyncCallback<number> | Yes | Callback invoked when the data is written asynchronously. | **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2763,20 +2763,20 @@ Synchronously writes data into the stream. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ------------------------------- | ---- | ---------------------------------------- | -| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | -| options | Object | No | The options are as follows:
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| + | Name | Type | Mandatory | Description | + | ------- | ------------------------------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | + | options | Object | No | The options are as follows:
- **length** (number): length of the data to write. This parameter is optional. The default value is the buffer length.
- **offset** (number): start position to write the data in the file. This parameter is optional. By default, data is written from the current position.
- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.| **Return value** -| Type | Description | -| ------ | -------- | -| number | Length of the data written in the file.| + | Type | Description | + | ------ | -------- | + | number | Length of the data written in the file.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2796,20 +2796,20 @@ Reads data from the stream. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ----------- | ---- | ---------------------------------------- | -| buffer | ArrayBuffer | Yes | Buffer used to store the file read. | -| options | Object | No | The options are as follows:
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.
- **offset** (number): position of the data to read in the file. By default, data is read from the current position.| + | Name | Type | Mandatory | Description | + | ------- | ----------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | + | options | Object | No | The options are as follows:
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.
- **offset** (number): position of the data to read in the file. By default, data is read from the current position.| **Return value** -| Type | Description | -| ---------------------------------- | ------ | -| Promise<number> | Promise used to return the data read.| + | Type | Description | + | ---------------------------------- | ------ | + | Promise<number> | Promise used to return the data read.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2835,15 +2835,15 @@ Reads data from the stream. This API uses an asynchronous callback to return the **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| buffer | ArrayBuffer | Yes | Buffer used to store the file read. | -| options | Object | No | The options are as follows:
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.
- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.| -| callback | AsyncCallback<number> | Yes | Callback invoked when data is read asynchronously from the stream. | + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | + | options | Object | No | The options are as follows:
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.
- **offset** (number): position of the data to read in the file. This parameter is optional. By default, data is read from the current position.| + | callback | AsyncCallback<number> | Yes | Callback invoked when data is read asynchronously from the stream. | **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2871,20 +2871,20 @@ Synchronously reads data from the stream. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ----------- | ---- | ---------------------------------------- | -| buffer | ArrayBuffer | Yes | Buffer used to store the file read. | -| options | Object | No | The options are as follows:
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.
- **offset** (number): position of the data to read in the file. By default, data is read from the current position.
| + | Name | Type | Mandatory | Description | + | ------- | ----------- | ---- | ---------------------------------------- | + | buffer | ArrayBuffer | Yes | Buffer used to store the file read. | + | options | Object | No | The options are as follows:
- **length** (number): length of the data to read. This parameter is optional. The default value is the buffer length.
- **offset** (number): position of the data to read in the file. By default, data is read from the current position.
| **Return value** -| Type | Description | -| ------ | -------- | -| number | Length of the data read.| + | Type | Description | + | ------ | -------- | + | number | Length of the data read.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2916,19 +2916,19 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ----------- | ---- | ---------------------------------------- | -| exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | + | Name | Type | Mandatory | Description | + | ------- | ----------- | ---- | ---------------------------------------- | + | exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | **Return value** -| Type | Description | -| ---------------------------------- | ------ | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ---------------------------------- | ------ | + | Promise<void> | Promise that returns no value.| **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2951,14 +2951,14 @@ Applies an exclusive lock or a shared lock on this file in blocking mode. This A **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ----------- | ---- | ---------------------------------------- | -| exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | -| callback | AsyncCallback<void> | Yes | Callback invoked when the file is locked. | + | Name | Type | Mandatory | Description | + | ------- | ----------- | ---- | ---------------------------------------- | + | exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | + | callback | AsyncCallback<void> | Yes | Callback invoked when the file is locked. | **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -2983,13 +2983,13 @@ Applies an exclusive lock or a shared lock on this file in non-blocking mode. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ----------- | ---- | ---------------------------------------- | -| exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | + | Name | Type | Mandatory | Description | + | ------- | ----------- | ---- | ---------------------------------------- | + | exclusive | boolean | No | Lock to apply. The value **true** means an exclusive lock, and the value **false** (default) means a shared lock. | **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** @@ -3009,7 +3009,7 @@ Unlocks this file synchronously. **Error codes** -For details about error codes, see "Basic File I/O Error Codes" in [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). +For details about the error codes, see [Basic File IO Error Codes](../errorcodes/errorcode-filemanagement.md#basic-file-io-error-codes). **Example** diff --git a/en/application-dev/reference/apis/js-apis-file-hash.md b/en/application-dev/reference/apis/js-apis-file-hash.md index eb9247ab3ccc6ee628fbd12e8a8a51413abbda01..87592b5b9f7ea94fc46dac6e72c25803d2c658d2 100644 --- a/en/application-dev/reference/apis/js-apis-file-hash.md +++ b/en/application-dev/reference/apis/js-apis-file-hash.md @@ -1,11 +1,10 @@ # @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<string> | 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<string> | Yes | Callback used to return the hash value obtained. The hash value is a hexadecimal string consisting of digits and uppercase letters.| +| callback | AsyncCallback<string> | 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) => { diff --git a/en/application-dev/reference/apis/js-apis-file-picker.md b/en/application-dev/reference/apis/js-apis-file-picker.md index c61b79455e006756aa65993b1b0ebdf7da9d7b70..f08294549c59a444bd8b7f3d8d72e34533c9d59b 100644 --- a/en/application-dev/reference/apis/js-apis-file-picker.md +++ b/en/application-dev/reference/apis/js-apis-file-picker.md @@ -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'; ``` diff --git a/en/application-dev/reference/apis/js-apis-file-securityLabel.md b/en/application-dev/reference/apis/js-apis-file-securityLabel.md index c564516e66c0119dbec070c4a9eab744350d130f..d0005ee159065701ec3f6e483817a095b08c65b9 100644 --- a/en/application-dev/reference/apis/js-apis-file-securityLabel.md +++ b/en/application-dev/reference/apis/js-apis-file-securityLabel.md @@ -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<void> | Promise that returns no value.| + | Type | Description | + | ------------------- | ---------------- | + | Promise<void> | 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<void> | 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<string> | Security label obtained.| + | Type | Description | + | --------------------- | ------------ | + | Promise<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** @@ -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<string> | Yes | Callback invoked to return the security label obtained.| + | Name | Type | Mandatory| Description | + | -------- | --------------------------- | ---- | -------------------------- | + | path | string | Yes | Path of the target file. | + | callback | AsyncCallback<string> | 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 diff --git a/en/application-dev/reference/apis/js-apis-file-statvfs.md b/en/application-dev/reference/apis/js-apis-file-statvfs.md index f431f3cb17d8d82a88a0b9bde7e2a3e3d8e66c86..34282138f7bddeadb0b9e3e2de45dc600c65c5ff 100644 --- a/en/application-dev/reference/apis/js-apis-file-statvfs.md +++ b/en/application-dev/reference/apis/js-apis-file-statvfs.md @@ -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<number> @@ -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<number> | Promise used to return the number of free bytes obtained.| + | Type | Description | + | --------------------- | -------------- | + | Promise<number> | 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<number> | 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<number> | 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<number> | Promise used to return the total number of bytes obtained.| + | Type | Description | + | --------------------- | ------------ | + | Promise<number> | 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<number> | 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<number> | 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** diff --git a/en/application-dev/reference/apis/js-apis-file-storage-statistics.md b/en/application-dev/reference/apis/js-apis-file-storage-statistics.md index 716e0da462bf4e59d0cd969deb561e0adc23a351..01ffbea245309d4d2babf3ae81ec64e998dfeb67 100644 --- a/en/application-dev/reference/apis/js-apis-file-storage-statistics.md +++ b/en/application-dev/reference/apis/js-apis-file-storage-statistics.md @@ -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<number> | 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<number> | 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<number> | 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<number> | 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<[Bundlestats](#bundlestats9)> | 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<[Bundlestats](#bundlestats9)> | 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<[Bundlestats](#bundlestats9)> | 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<[BundleStats](#bundlestats9)> | 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.getTotalSize9+ getTotalSize(): Promise<number> @@ -284,6 +375,18 @@ Obtains the total size (in bytes) of the built-in storage. This API uses a promi | --------------------- | ------------------ | | Promise<number> | 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<number> | 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.getFreeSize9+ getFreeSize(): Promise<number> @@ -337,6 +451,18 @@ Obtains the available space (in bytes) of the built-in storage. This API uses a | --------------------- | ------------------ | | Promise<number> | 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.getFreeSize9+ getFreeSize(callback: AsyncCallback<number>): void @@ -363,6 +488,18 @@ Obtains the available space (in bytes) of the built-in storage. This API uses an | -------- | ------------------------------------ | ---- | ------------------------- | | callback | AsyncCallback<number> | 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<number> | 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<number> | 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<[StorageStats](#storagestats9)> | 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<[StorageStats](#storagestats9)> | 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.getUserStorageStats9+ + getUserStorageStats(userId: number): Promise<StorageStats> 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<[StorageStats](#storagestats9)> | 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<[StorageStats](#storagestats9)> | 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 }); ``` - ## StorageStats9+ **System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics diff --git a/en/application-dev/reference/apis/js-apis-file-volumemanager.md b/en/application-dev/reference/apis/js-apis-file-volumemanager.md index c2628ce063d93233af5ee6f6641a422e1a163c37..bec02a0f6780883260a9e152441558f58039d59b 100644 --- a/en/application-dev/reference/apis/js-apis-file-volumemanager.md +++ b/en/application-dev/reference/apis/js-apis-file-volumemanager.md @@ -6,7 +6,6 @@ The **volumeManager** module provides APIs for volume and disk management, inclu > > - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The APIs provided by this module are system APIs. -> - The APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). ## Modules to Import @@ -26,9 +25,21 @@ Obtains information about all volumes of this external storage device. This API **Return value** -| Type | Description | -| ---------------------------------- | -------------------------- | -| Promise<[Volume](#volume)[]> | Promise used to return information about all available volumes.| + | Type | Description | + | ---------------------------------- | -------------------------- | + | Promise<[Volume](#volume)[]> | Promise used to return information about all available volumes.| + +**Error codes** + +For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). + +| ID| Error Message| +| -------- | -------- | +| 201 | Permission verification failed. | +| 202 | The caller is not a system application. | +| 401 | The input parameter is invalid. | +| 13600001 | IPC error. | +| 13900032 | Unknown error. | **Example** @@ -52,9 +63,21 @@ Obtains information about all volumes of this external storage device. This API **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------- | ---- | ------------------------------------ | -| callback | AsyncCallback<[Volume](#volume)[]> | Yes | Callback invoked to return information about all available volumes.| + | Name | Type | Mandatory| Description | + | -------- | ------------------------------------------------- | ---- | ------------------------------------ | + | callback | AsyncCallback<[Volume](#volume)[]> | Yes | Callback invoked to return information about all available volumes.| + +**Error codes** + +For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). + +| ID| Error Message| +| -------- | -------- | +| 201 | Permission verification failed. | +| 202 | The caller is not a system application. | +| 401 | The input parameter is invalid. | +| 13600001 | IPC error. | +| 13900032 | Unknown error. | **Example** @@ -65,7 +88,6 @@ Obtains information about all volumes of this external storage device. This API }); ``` - ## volumemanager.mount mount(volumeId: string): Promise<void> @@ -78,15 +100,31 @@ Asynchronously mounts a volume. This API uses a promise to return the result. Cu **Parameters** -| Name | Type | Mandatory| Description| -| -------- | ------ | ---- | ---- | -| volumeId | string | Yes | Volume ID.| + | Name | Type | Mandatory| Description| + | -------- | ------ | ---- | ---- | + | volumeId | string | Yes | Volume ID.| **Return value** -| Type | Description | -| ---------------------- | ---------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ---------------------- | ---------- | + | Promise<void> | Promise that returns no value.| + +**Error codes** + +For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). + +| ID| Error Message| +| -------- | -------- | +| 201 | Permission verification failed. | +| 202 | The caller is not a system application. | +| 401 | The input parameter is invalid. | +| 13600001 | IPC error. | +| 13600002 | Not supported filesystem. | +| 13600003 | Failed to mount. | +| 13600005 | Incorrect volume state. | +| 13600008 | No such object. | +| 13900032 | Unknown error. | **Example** @@ -111,10 +149,26 @@ Asynchronously mounts a volume. This API uses an asynchronous callback to return **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------- | ---- | -------------------- | -| volumeId | string | Yes | Volume ID. | -| callback | AsyncCallback<void> | Yes | Callback that returns no value.| + | Name | Type | Mandatory| Description | + | -------- | ------------------------------------- | ---- | -------------------- | + | volumeId | string | Yes | Volume ID. | + | callback | AsyncCallback<void> | Yes | Callback that returns no value.| + +**Error codes** + +For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). + +| ID| Error Message| +| -------- | -------- | +| 201 | Permission verification failed. | +| 202 | The caller is not a system application. | +| 401 | The input parameter is invalid. | +| 13600001 | IPC error. | +| 13600002 | Not supported filesystem. | +| 13600003 | Failed to mount. | +| 13600005 | Incorrect volume state. | +| 13600008 | No such object. | +| 13900032 | Unknown error. | **Example** @@ -137,15 +191,31 @@ Asynchronously unmounts a volume. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory| Description| -| -------- | ------ | ---- | ---- | -| volumeId | string | Yes | Volume ID.| + | Name | Type | Mandatory| Description| + | -------- | ------ | ---- | ---- | + | volumeId | string | Yes | Volume ID.| **Return value** -| Type | Description | -| ---------------------- | ---------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ---------------------- | ---------- | + | Promise<void> | Promise that returns no value.| + +**Error codes** + +For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). + +| ID| Error Message| +| -------- | -------- | +| 201 | Permission verification failed. | +| 202 | The caller is not a system application. | +| 401 | The input parameter is invalid. | +| 13600001 | IPC error. | +| 13600002 | Not supported filesystem. | +| 13600004 | Failed to unmount. | +| 13600005 | Incorrect volume state. | +| 13600008 | No such object. | +| 13900032 | Unknown error. | **Example** @@ -170,10 +240,26 @@ Asynchronously unmounts a volume. This API uses an asynchronous callback to retu **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------- | ---- | -------------------- | -| volumeId | string | Yes | Volume ID. | -| callback | AsyncCallback<void> | Yes | Callback that returns no value.| + | Name | Type | Mandatory| Description | + | -------- | ------------------------------------- | ---- | -------------------- | + | volumeId | string | Yes | Volume ID. | + | callback | AsyncCallback<void> | Yes | Callback that returns no value.| + +**Error codes** + +For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). + +| ID| Error Message| +| -------- | -------- | +| 201 | Permission verification failed. | +| 202 | The caller is not a system application. | +| 401 | The input parameter is invalid. | +| 13600001 | IPC error. | +| 13600002 | Not supported filesystem. | +| 13600004 | Failed to unmount. | +| 13600005 | Incorrect volume state. | +| 13600008 | No such object. | +| 13900032 | Unknown error. | **Example** @@ -196,15 +282,28 @@ Obtains information about a volume based on the universally unique identifier (U **Parameters** -| Name | Type | Mandatory| Description| -| -------- | ------ | ---- | ---- | -| uuid | string | Yes | UUID of the volume.| + | Name | Type | Mandatory| Description| + | -------- | ------ | ---- | ---- | + | uuid | string | Yes | UUID of the volume.| **Return value** -| Type | Description | -| ---------------------------------- | -------------------------- | -| Promise<[Volume](#volume)> | Promise used to return the volume information obtained.| + | Type | Description | + | ---------------------------------- | -------------------------- | + | Promise<[Volume](#volume)> | Promise used to return the volume information obtained.| + +**Error codes** + +For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). + +| ID| Error Message| +| -------- | -------- | +| 201 | Permission verification failed. | +| 202 | The caller is not a system application. | +| 401 | The input parameter is invalid. | +| 13600001 | IPC error. | +| 13600008 | No such object. | +| 13900032 | Unknown error. | **Example** @@ -229,10 +328,23 @@ Obtains information about a volume based on the UUID. This API uses an asynchron **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------ | ---- | -------------------- | -| uuid | string | Yes | UUID of the volume. | -| callback | AsyncCallback<[Volume](#volume)> | Yes | Callback invoked to return the volume information obtained.| + | Name | Type | Mandatory| Description | + | -------- | ------------------------------------------------ | ---- | -------------------- | + | uuid | string | Yes | UUID of the volume. | + | callback | AsyncCallback<[Volume](#volume)> | Yes | Callback invoked to return the volume information obtained.| + +**Error codes** + +For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). + +| ID| Error Message| +| -------- | -------- | +| 201 | Permission verification failed. | +| 202 | The caller is not a system application. | +| 401 | The input parameter is invalid. | +| 13600001 | IPC error. | +| 13600008 | No such object. | +| 13900032 | Unknown error. | **Example** @@ -255,15 +367,28 @@ Obtains information about a volume based on the volume ID. This API uses a promi **Parameters** -| Name | Type | Mandatory | Description| -| -------- | ------ | ---- | ---- | -| volumeId | string | Yes | Volume ID.| + | Name | Type | Mandatory | Description| + | -------- | ------ | ---- | ---- | + | volumeId | string | Yes | Volume ID.| **Return value** -| Type | Description | -| ---------------------------------- | -------------------------- | -| Promise<[Volume](#volume)> | Promise used to return the volume information obtained.| + | Type | Description | + | ---------------------------------- | -------------------------- | + | Promise<[Volume](#volume)> | Promise used to return the volume information obtained.| + +**Error codes** + +For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). + +| ID| Error Message| +| -------- | -------- | +| 201 | Permission verification failed. | +| 202 | The caller is not a system application. | +| 401 | The input parameter is invalid. | +| 13600001 | IPC error. | +| 13600008 | No such object. | +| 13900032 | Unknown error. | **Example** @@ -288,10 +413,23 @@ Obtains information about a volume based on the volume ID. This API uses an asyn **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------- | ---- | ----------------------------- | -| volumeId | string | Yes | Volume ID. | -| callback | AsyncCallback<[Volume](#volume)> | Yes | Callback invoked to return the volume information obtained. | + | Name | Type | Mandatory| Description | + | -------- | ------------------------- | ---- | ----------------------------- | + | volumeId | string | Yes | Volume ID. | + | callback | AsyncCallback<[Volume](#volume)> | Yes | Callback invoked to return the volume information obtained. | + +**Error codes** + +For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). + +| ID| Error Message| +| -------- | -------- | +| 201 | Permission verification failed. | +| 202 | The caller is not a system application. | +| 401 | The input parameter is invalid. | +| 13600001 | IPC error. | +| 13600008 | No such object. | +| 13900032 | Unknown error. | **Example** @@ -314,16 +452,31 @@ Sets volume description. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory| Description| -| --------- | ------ | ---- | ---- | -| uuid | string | Yes | UUID of the volume.| -| description | string | Yes | Volume description to set.| + | Name | Type | Mandatory| Description| + | --------- | ------ | ---- | ---- | + | uuid | string | Yes | UUID of the volume.| + | description | string | Yes | Volume description to set.| **Return value** -| Type | Description | -| ---------------------- | -------------------------- | -| Promise<void> | Promise that returns no value. | + | Type | Description | + | ---------------------- | -------------------------- | + | Promise<void> | Promise that returns no value. | + +**Error codes** + +For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). + +| ID| Error Message| +| -------- | -------- | +| 201 | Permission verification failed. | +| 202 | The caller is not a system application. | +| 401 | The input parameter is invalid. | +| 13600001 | IPC error. | +| 13600002 | Not supported filesystem. | +| 13600005 | Incorrect volume state. | +| 13600008 | No such object. | +| 13900032 | Unknown error. | **Example** @@ -349,11 +502,26 @@ Sets volume description. This API uses an asynchronous callback to return the re **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | --------------------------------------- | ---- | ---------------- | -| uuid | string | Yes | UUID of the volume. | -| description | string | Yes | Volume description to set. | -| callback | AsyncCallback<void> | Yes | Callback that returns no value.| + | Name | Type | Mandatory| Description | + | ---------- | --------------------------------------- | ---- | ---------------- | + | uuid | string | Yes | UUID of the volume. | + | description | string | Yes | Volume description to set. | + | callback | AsyncCallback<void> | Yes | Callback that returns no value.| + +**Error codes** + +For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). + +| ID| Error Message| +| -------- | -------- | +| 201 | Permission verification failed. | +| 202 | The caller is not a system application. | +| 401 | The input parameter is invalid. | +| 13600001 | IPC error. | +| 13600002 | Not supported filesystem. | +| 13600005 | Incorrect volume state. | +| 13600008 | No such object. | +| 13900032 | Unknown error. | **Example** @@ -377,16 +545,31 @@ Formats a volume. This API uses a promise to return the result. Currently, only **Parameters** -| Name | Type | Mandatory| Description| -| ----------- | ------ | ---- | ---- | -| volumeId | string | Yes | Volume ID.| -| fsType | string | Yes | File system type, which can be VFAT or exFAT.| + | Name | Type | Mandatory| Description| + | ----------- | ------ | ---- | ---- | + | volumeId | string | Yes | Volume ID.| + | fsType | string | Yes | File system type, which can be VFAT or exFAT.| **Return value** -| Type | Description | -| ---------------------- | ---------- | -| Promise<void> | Promise that returns no value.| + | Type | Description | + | ---------------------- | ---------- | + | Promise<void> | Promise that returns no value.| + +**Error codes** + +For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). + +| ID| Error Message| +| -------- | -------- | +| 201 | Permission verification failed. | +| 202 | The caller is not a system application. | +| 401 | The input parameter is invalid. | +| 13600001 | IPC error. | +| 13600002 | Not supported filesystem. | +| 13600005 | Incorrect volume state. | +| 13600008 | No such object. | +| 13900032 | Unknown error. | **Example** @@ -412,11 +595,26 @@ Formats a volume. This API uses an asynchronous callback to return the result. C **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------- | ---- | ----------------------------- | -| volumeId | string | Yes | Volume ID. | -| fsType | string | Yes | File system type, which can be VFAT or exFAT.| -| callback | AsyncCallback<void> | Yes | Callback that returns no value. | + | Name | Type | Mandatory| Description | + | -------- | ------------------------- | ---- | ----------------------------- | + | volumeId | string | Yes | Volume ID. | + | fsType | string | Yes | File system type, which can be VFAT or exFAT.| + | callback | AsyncCallback<void> | Yes | Callback that returns no value. | + +**Error codes** + +For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). + +| ID| Error Message| +| -------- | -------- | +| 201 | Permission verification failed. | +| 202 | The caller is not a system application. | +| 401 | The input parameter is invalid. | +| 13600001 | IPC error. | +| 13600002 | Not supported filesystem. | +| 13600005 | Incorrect volume state. | +| 13600008 | No such object. | +| 13900032 | Unknown error. | **Example** @@ -440,16 +638,29 @@ Partitions a disk. This API uses a promise to return the result. The system supp **Parameters** -| Name | Type | Mandatory| Description| -| ----------- | ------ | ---- | ---- | -| diskId | string | Yes | ID of the disk to partition.| -| type | number | Yes | Partition type. | + | Name | Type | Mandatory| Description| + | ----------- | ------ | ---- | ---- | + | diskId | string | Yes | ID of the disk to partition.| + | type | number | Yes | Partition type. | **Return value** -| Type | Description | -| --------------------- | ----------------------- | -| Promise<void> | Promise used to return the result. | + | Type | Description | + | --------------------- | ----------------------- | + | Promise<void> | Promise used to return the result. | + +**Error codes** + +For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). + +| ID| Error Message| +| -------- | -------- | +| 201 | Permission verification failed. | +| 202 | The caller is not a system application. | +| 401 | The input parameter is invalid. | +| 13600001 | IPC error. | +| 13600008 | No such object. | +| 13900032 | Unknown error. | **Example** @@ -475,11 +686,24 @@ Asynchronously partitions a disk. This API uses a callback to return the result. **Parameters** -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------------- | -| diskId | string | Yes | ID of the disk to partition. | -| type | number | Yes | Partition type. | -| callback | AsyncCallback<void> | Yes | Callback that returns no value. | + | Name | Type | Mandatory| Description | + | -------- | --------------------------------------- | ---- | ---------------- | + | diskId | string | Yes | ID of the disk to partition. | + | type | number | Yes | Partition type. | + | callback | AsyncCallback<void> | Yes | Callback that returns no value. | + +**Error codes** + +For details about the error codes, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). + +| ID| Error Message| +| -------- | -------- | +| 201 | Permission verification failed. | +| 202 | The caller is not a system application. | +| 401 | The input parameter is invalid. | +| 13600001 | IPC error. | +| 13600008 | No such object. | +| 13900032 | Unknown error. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-fileShare.md b/en/application-dev/reference/apis/js-apis-fileShare.md index 0939a88194756ad10417063ab36e341792234467..2d0d66de9f6e9860e16820d40d13908767359127 100644 --- a/en/application-dev/reference/apis/js-apis-fileShare.md +++ b/en/application-dev/reference/apis/js-apis-fileShare.md @@ -1,6 +1,6 @@ # @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).
**wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION**: permission to read the file.
**wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION**: permission to write the file.| -| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | + | callback | AsyncCallback<void> | 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<void> @@ -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<void> | Promise that returns no value.| - + | Type | Description | + | ---------------------------- | ---------- | + | Promise<void> | 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 diff --git a/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventData.md b/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventData.md index a73c80d7c5fa09e19f901b3c947f445eb61989e1..a8afc035794c4e35fbdf9d68a715fe2bb67e7b36 100644 --- a/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventData.md +++ b/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventData.md @@ -1,5 +1,10 @@ # 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 | diff --git a/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventPublishData.md b/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventPublishData.md index 94963860fe1b57a6abfd6fff6fdba38816a63294..332fd934c7ee9799d4356acc45996d3632b4f9d2 100644 --- a/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventPublishData.md +++ b/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventPublishData.md @@ -1,5 +1,9 @@ # 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 | diff --git a/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscribeInfo.md b/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscribeInfo.md index 2b9db9ec46f479d5d0607c33f07601b1ef721446..c5de47b81e6b928a7d26909a54aa9ba798078417 100644 --- a/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscribeInfo.md +++ b/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscribeInfo.md @@ -1,5 +1,9 @@ # 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 | diff --git a/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscriber.md b/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscriber.md index 18eeac506b75dc96b27b56b9369070215ff8892a..02112d5b265e73139c9cd662246a819bc16c0b1f 100644 --- a/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscriber.md +++ b/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscriber.md @@ -1,11 +1,40 @@ # CommonEventSubscriber -## getCode +> **NOTE** +> +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Usage + +Before using the **CommonEventSubscriber** module, you must obtain a **subscriber** object by calling **CommonEvent.createSubscriber**. ```ts -getCode(callback: AsyncCallback): void +import CommonEvent from '@ohos.commonEvent'; +let subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. + +// Subscriber information. +let subscribeInfo = { + events: ["event"] +}; + +// Callback for subscriber creation. +function createCB(err, commonEventSubscriber) { + if (err.code) { + console.error(`createSubscriber failed, code is ${err.code}`); + } else { + console.info("createSubscriber"); + subscriber = commonEventSubscriber; + } +} + +// Create a subscriber. +CommonEvent.createSubscriber(subscribeInfo, createCB); ``` +## getCode + +getCode(callback: AsyncCallback\): void + Obtains the code of this common event. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.CommonEvent @@ -19,8 +48,6 @@ Obtains the code of this common event. This API uses an asynchronous callback to **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for result code obtaining of an ordered common event. function getCodeCB(err, code) { if (err.code) { @@ -34,9 +61,7 @@ subscriber.getCode(getCodeCB); ## getCode -```ts -getCode(): Promise -``` +getCode(): Promise\ Obtains the code of this common event. This API uses a promise to return the result. @@ -51,8 +76,6 @@ Obtains the code of this common event. This API uses a promise to return the res **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.getCode().then((code) => { console.info("getCode " + JSON.stringify(code)); }).catch((err) => { @@ -62,9 +85,7 @@ subscriber.getCode().then((code) => { ## setCode -```ts -setCode(code: number, callback: AsyncCallback): void -``` +setCode(code: number, callback: AsyncCallback\): void Sets the code for this common event. This API uses an asynchronous callback to return the result. @@ -80,8 +101,6 @@ Sets the code for this common event. This API uses an asynchronous callback to r **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for result code setting of an ordered common event. function setCodeCB(err) { if (err.code) { @@ -95,9 +114,7 @@ subscriber.setCode(1, setCodeCB); ## setCode -```ts -setCode(code: number): Promise -``` +setCode(code: number): Promise\ Sets the code for this common event. This API uses a promise to return the result. @@ -118,8 +135,6 @@ Sets the code for this common event. This API uses a promise to return the resul **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.setCode(1).then(() => { console.info("setCode"); }).catch((err) => { @@ -129,9 +144,7 @@ subscriber.setCode(1).then(() => { ## getData -```ts -getData(callback: AsyncCallback): void -``` +getData(callback: AsyncCallback\): void Obtains the data of this common event. This API uses an asynchronous callback to return the result. @@ -146,8 +159,6 @@ Obtains the data of this common event. This API uses an asynchronous callback to **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for result data obtaining of an ordered common event. function getDataCB(err, data) { if (err.code) { @@ -161,9 +172,7 @@ subscriber.getData(getDataCB); ## getData -```ts -getData(): Promise -``` +getData(): Promise\ Obtains the data of this common event. This API uses a promise to return the result. @@ -178,8 +187,6 @@ Obtains the data of this common event. This API uses a promise to return the res **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.getData().then((data) => { console.info("getData " + JSON.stringify(data)); }).catch((err) => { @@ -205,8 +212,6 @@ Sets the data for this common event. This API uses an asynchronous callback to r **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for result data setting of an ordered common event function setDataCB(err) { if (err.code) { @@ -220,9 +225,7 @@ subscriber.setData("publish_data_changed", setDataCB); ## setData -```ts -setData(data: string): Promise -``` +setData(data: string): Promise\ Sets the data for this common event. This API uses a promise to return the result. @@ -243,8 +246,6 @@ Sets the data for this common event. This API uses a promise to return the resul **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.setData("publish_data_changed").then(() => { console.info("setData"); }).catch((err) => { @@ -254,9 +255,7 @@ subscriber.setData("publish_data_changed").then(() => { ## setCodeAndData -```ts -setCodeAndData(code: number, data: string, callback:AsyncCallback): void -``` +setCodeAndData(code: number, data: string, callback:AsyncCallback\): void Sets the code and data for this common event. This API uses an asynchronous callback to return the result. @@ -273,8 +272,6 @@ Sets the code and data for this common event. This API uses an asynchronous call **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for code and data setting of an ordered common event. function setCodeDataCB(err) { if (err.code) { @@ -288,9 +285,7 @@ subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCB); ## setCodeAndData -```ts -setCodeAndData(code: number, data: string): Promise -``` +setCodeAndData(code: number, data: string): Promise\ Sets the code and data for this common event. This API uses a promise to return the result. @@ -312,8 +307,6 @@ Sets the code and data for this common event. This API uses a promise to return **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.setCodeAndData(1, "publish_data_changed").then(() => { console.info("setCodeAndData"); }).catch((err) => { @@ -323,9 +316,7 @@ subscriber.setCodeAndData(1, "publish_data_changed").then(() => { ## isOrderedCommonEvent -```ts -isOrderedCommonEvent(callback: AsyncCallback): void -``` +isOrderedCommonEvent(callback: AsyncCallback\): void Checks whether this common event is an ordered one. This API uses an asynchronous callback to return the result. @@ -340,8 +331,6 @@ Checks whether this common event is an ordered one. This API uses an asynchronou **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for checking whether the current common event is an ordered one. function isOrderedCB(err, isOrdered) { if (err.code) { @@ -355,9 +344,7 @@ subscriber.isOrderedCommonEvent(isOrderedCB); ## isOrderedCommonEvent -```ts -isOrderedCommonEvent(): Promise -``` +isOrderedCommonEvent(): Promise\ Checks whether this common event is an ordered one. This API uses a promise to return the result. @@ -372,8 +359,6 @@ Checks whether this common event is an ordered one. This API uses a promise to r **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.isOrderedCommonEvent().then((isOrdered) => { console.info("isOrdered " + JSON.stringify(isOrdered)); }).catch((err) => { @@ -383,9 +368,7 @@ subscriber.isOrderedCommonEvent().then((isOrdered) => { ## isStickyCommonEvent -```ts -isStickyCommonEvent(callback: AsyncCallback): void -``` +isStickyCommonEvent(callback: AsyncCallback\): void Checks whether this common event is a sticky one. This API uses an asynchronous callback to return the result. @@ -400,8 +383,6 @@ Checks whether this common event is a sticky one. This API uses an asynchronous **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for checking whether the current common event is a sticky one. function isStickyCB(err, isSticky) { if (err.code) { @@ -415,9 +396,7 @@ subscriber.isStickyCommonEvent(isStickyCB); ## isStickyCommonEvent -```ts -isStickyCommonEvent(): Promise -``` +isStickyCommonEvent(): Promise\ Checks whether this common event is a sticky one. This API uses a promise to return the result. @@ -432,8 +411,6 @@ Checks whether this common event is a sticky one. This API uses a promise to ret **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.isStickyCommonEvent().then((isSticky) => { console.info("isSticky " + JSON.stringify(isSticky)); }).catch((err) => { @@ -443,9 +420,7 @@ subscriber.isStickyCommonEvent().then((isSticky) => { ## abortCommonEvent -```ts -abortCommonEvent(callback: AsyncCallback): void -``` +abortCommonEvent(callback: AsyncCallback\): void Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result. @@ -460,8 +435,6 @@ Aborts this common event. After the abort, the common event is not sent to the n **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for common event aborting. function abortCB(err) { if (err.code) { @@ -475,9 +448,7 @@ subscriber.abortCommonEvent(abortCB); ## abortCommonEvent -```ts -abortCommonEvent(): Promise -``` +abortCommonEvent(): Promise\ Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses a promise to return the result. @@ -492,8 +463,6 @@ Aborts this common event. After the abort, the common event is not sent to the n **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.abortCommonEvent().then(() => { console.info("abortCommonEvent"); }).catch((err) => { @@ -503,9 +472,7 @@ subscriber.abortCommonEvent().then(() => { ## clearAbortCommonEvent -```ts -clearAbortCommonEvent(callback: AsyncCallback): void -``` +clearAbortCommonEvent(callback: AsyncCallback\): void Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result. @@ -520,8 +487,6 @@ Clears the aborted state of this common event. This API takes effect only for or **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for clearing the aborted state of the current common event. function clearAbortCB(err) { if (err.code) { @@ -535,9 +500,7 @@ subscriber.clearAbortCommonEvent(clearAbortCB); ## clearAbortCommonEvent -```ts -clearAbortCommonEvent(): Promise -``` +clearAbortCommonEvent(): Promise\ Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses a promise to return the result. @@ -552,8 +515,6 @@ Clears the aborted state of this common event. This API takes effect only for or **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.clearAbortCommonEvent().then(() => { console.info("clearAbortCommonEvent"); }).catch((err) => { @@ -563,9 +524,7 @@ subscriber.clearAbortCommonEvent().then(() => { ## getAbortCommonEvent -```ts -getAbortCommonEvent(callback: AsyncCallback): void -``` +getAbortCommonEvent(callback: AsyncCallback\): void Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result. @@ -580,8 +539,6 @@ Checks whether this common event is in the aborted state. This API takes effect **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for checking whether the current common event is in the aborted state. function getAbortCB(err, abortEvent) { if (err.code) { @@ -595,9 +552,7 @@ subscriber.getAbortCommonEvent(getAbortCB); ## getAbortCommonEvent -```ts -getAbortCommonEvent(): Promise -``` +getAbortCommonEvent(): Promise\ Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses a promise to return the result. @@ -612,8 +567,6 @@ Checks whether this common event is in the aborted state. This API takes effect **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.getAbortCommonEvent().then((abortEvent) => { console.info("abortCommonEvent " + JSON.stringify(abortEvent)); }).catch((err) => { @@ -623,9 +576,7 @@ subscriber.getAbortCommonEvent().then((abortEvent) => { ## getSubscribeInfo -```ts -getSubscribeInfo(callback: AsyncCallback): void -``` +getSubscribeInfo(callback: AsyncCallback\): void Obtains the subscriber information. This API uses an asynchronous callback to return the result. @@ -640,8 +591,6 @@ Obtains the subscriber information. This API uses an asynchronous callback to re **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for subscriber information obtaining. function getCB(err, subscribeInfo) { if (err.code) { @@ -655,9 +604,7 @@ subscriber.getSubscribeInfo(getCB); ## getSubscribeInfo -```ts -getSubscribeInfo(): Promise -``` +getSubscribeInfo(): Promise\ Obtains the subscriber information. This API uses a promise to return the result. @@ -672,8 +619,6 @@ Obtains the subscriber information. This API uses a promise to return the result **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.getSubscribeInfo().then((subscribeInfo) => { console.info("subscribeInfo " + JSON.stringify(subscribeInfo)); }).catch((err) => { @@ -683,9 +628,7 @@ subscriber.getSubscribeInfo().then((subscribeInfo) => { ## finishCommonEvent9+ -```ts -finishCommonEvent(callback: AsyncCallback): void -``` +finishCommonEvent(callback: AsyncCallback\): void Finishes this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result. @@ -700,14 +643,13 @@ Finishes this common event. This API takes effect only for ordered common events **Example** ```ts -let subscriber; // Subscriber object successfully created. - // Callback for ordered common event finishing. function finishCB(err) { if (err.code) { console.error(`finishCommonEvent failed, code is ${err.code}, message is ${err.message}`); -} else { + } else { console.info("FinishCommonEvent"); + } } subscriber.finishCommonEvent(finishCB); @@ -715,9 +657,7 @@ subscriber.finishCommonEvent(finishCB); ## finishCommonEvent9+ -```ts -finishCommonEvent(): Promise -``` +finishCommonEvent(): Promise\ Finishes this common event. This API takes effect only for ordered common events. It uses a promise to return the result. @@ -732,8 +672,6 @@ Finishes this common event. This API takes effect only for ordered common events **Example** ```ts -let subscriber; // Subscriber object successfully created. - subscriber.finishCommonEvent().then(() => { console.info("FinishCommonEvent"); }).catch((err) => { diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationActionButton.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationActionButton.md index 88e58e4bea766398e24ae1870c061e0dc385953a..ee7f0e37c7d85cdfdde76ae9b852bb05964af358 100644 --- a/en/application-dev/reference/apis/js-apis-inner-notification-notificationActionButton.md +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationActionButton.md @@ -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. | -| userInput8+ | [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. | +| userInput8+ | [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) | No | No | User input object. | diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationCommonDef.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationCommonDef.md index dcd2a4ce8de27431ea343b27bb933d829fcad74c..48f8c4cc28912aab4b3cc0446c951fe539b6ba4e 100644 --- a/en/application-dev/reference/apis/js-apis-inner-notification-notificationCommonDef.md +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationCommonDef.md @@ -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.| diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationContent.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationContent.md index 7c2b3a78da9b2c22c7ae9967552655f6e70a6c8c..9f5de8d911f2533c0dd789fd3bce1eeaf1adeef6 100644 --- a/en/application-dev/reference/apis/js-apis-inner-notification-notificationContent.md +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationContent.md @@ -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\ | 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\ | 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. | diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationFlags.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationFlags.md index f7e1a995b51bcc193e2cd21115eb8e934233eec5..e0b84a9fbac8e59070b598960bdb447c9cc24dbe 100644 --- a/en/application-dev/reference/apis/js-apis-inner-notification-notificationFlags.md +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationFlags.md @@ -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. | diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationRequest.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationRequest.md index 205a6c04bdf7fff97c80e44b882fb487712e2c01..ac3646f424f7701e2fa85c671a76ba90c511d212 100644 --- a/en/application-dev/reference/apis/js-apis-inner-notification-notificationRequest.md +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationRequest.md @@ -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. | | creatorUid8+ | 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.
**System API**: This is a system API and cannot be called by third-party applications. | -| groupName8+ | string | Yes | Yes | Notification group name. | -| template8+ | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | Yes | Yes | Notification template. | +| classification | string | No | No | Notification category.
**System API**: This is a system API and cannot be called by third-party applications. | +| groupName8+ | string | No | No | Notification group name. | +| template8+ | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | No | No | Notification template. | | isRemoveAllowed8+ | boolean | Yes | No | Whether the notification can be removed.
**System API**: This is a system API and cannot be called by third-party applications. | | source8+ | number | Yes | No | Notification source.
**System API**: This is a system API and cannot be called by third-party applications. | -| distributedOption8+ | [DistributedOptions](#distributedoptions) | Yes | Yes | Distributed notification options. | +| distributedOption8+ | [DistributedOptions](#distributedoptions) | No | No | Distributed notification options. | | deviceId8+ | string | Yes | No | Device ID of the notification source.
**System API**: This is a system API and cannot be called by third-party applications. | -| notificationFlags8+ | [NotificationFlags](js-apis-inner-notification-notificationflags#notificationFlags) | Yes | No | Notification flags. | -| removalWantAgent9+ | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** instance to which the notification will be redirected when it is removed. | -| badgeNumber9+ | number | Yes | Yes | Number of notifications displayed on the application icon. | +| notificationFlags8+ | [NotificationFlags](js-apis-inner-notification-notificationFlags.md#notificationflags) | Yes | No | Notification flags. | +| removalWantAgent9+ | [WantAgent](js-apis-app-ability-wantAgent.md) | No | No | **WantAgent** instance to which the notification will be redirected when it is removed. | +| badgeNumber9+ | 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 | | ---------------------- | -------------- | ---- | ---- | ---------------------------------- | -| isDistributed8+ | boolean | Yes | Yes | Whether the notification is a distributed notification. | -| supportDisplayDevices8+ | Array\ | Yes | Yes | List of the devices to which the notification can be synchronized. | -| supportOperateDevices8+ | Array\ | Yes | Yes | List of the devices on which the notification can be opened. | +| isDistributed8+ | boolean | No | No | Whether the notification is a distributed notification. | +| supportDisplayDevices8+ | Array\ | No | No | List of the devices to which the notification can be synchronized. | +| supportOperateDevices8+ | Array\ | No | No | List of the devices on which the notification can be opened. | | remindType8+ | number | Yes | No | Notification reminder type.
**System API**: This is a system API and cannot be called by third-party applications. | diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationSlot.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationSlot.md index 8bf9e286d59504be03ff8454d59ce60c31a9a597..9757ef2c007501439c509adc691e8f57aa3b354c 100644 --- a/en/application-dev/reference/apis/js-apis-inner-notification-notificationSlot.md +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationSlot.md @@ -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\ | 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\ | No | No | Vibration mode of the notification. | | enabled9+ | boolean | Yes | No | Whether the notification slot is enabled. | diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationSorting.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationSorting.md new file mode 100644 index 0000000000000000000000000000000000000000..8062a16f3ac0305025130bcd73f91bd41ba6abdf --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationSorting.md @@ -0,0 +1,17 @@ +# 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. | diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationSortingMap.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationSortingMap.md new file mode 100644 index 0000000000000000000000000000000000000000..0e75e98d2ce00b55aefc7d640f6590332782b451 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationSortingMap.md @@ -0,0 +1,17 @@ +# NotificationSortingMap + +Provides sorting information of active notifications in all subscribed notifications. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +**System capability**: SystemCapability.Notification.Notification + +**System API**: This is a system API and cannot be called by third-party applications. + +| Name | Type | Read-only| Mandatory| Description | +| -------------------- | --------------------- | ---- | --- | ------------------------------------------ | +| sortings | { [key: string]: [NotificationSorting](js-apis-inner-notification-notificationSorting.md) } | Yes | Yes | Array of notification sorting information.| +| sortedHashCode | Array\ | Yes | Yes | Hash codes for notification sorting.| + diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationSubscribeInfo.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationSubscribeInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..8bd477d99c99ba3cc5f494b12fb83c993b0ca682 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationSubscribeInfo.md @@ -0,0 +1,16 @@ +# NotificationSubscribeInfo + +Provides the information about the publisher for notification subscription. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +**System capability**: SystemCapability.Notification.Notification + +**System API**: This is a system API and cannot be called by third-party applications. + +| Name | Type | Read-only| Mandatory| Description | +| -------------------- | --------------------- | ---- | --- | ------------------------------------------ | +| bundleNames | Array\ | No | No | Bundle names of the applications whose notifications are to be subscribed to. | +| userId | number | No | No | User ID. | diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationTemplate.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationTemplate.md index 557fad664de00eb37567cb2d055c0c0ec2f8d484..3f9825e1d8cf63848d70e2282498e0d85f37cab0 100644 --- a/en/application-dev/reference/apis/js-apis-inner-notification-notificationTemplate.md +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationTemplate.md @@ -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.| diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationUserInput.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationUserInput.md index 76e673c886d4208354b680501c6ddbb0000e6438..bfda17b7872a816c4eb05a3af9fc5c10098f0a90 100644 --- a/en/application-dev/reference/apis/js-apis-inner-notification-notificationUserInput.md +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationUserInput.md @@ -8,6 +8,6 @@ The **NotificationUserInput** module provides the notification user input. **System capability**: SystemCapability.Notification.Notification -| Name | Type | Readable| Writable| Description | +| Name | Type | Read-only| Mandatory| Description | | -------- | ------ | --- | ---- | ----------------------------- | -| inputKey | string | Yes | Yes | Key to identify the user input.| +| inputKey | string | No | Yes | Key to identify the user input.| diff --git a/en/application-dev/reference/apis/js-apis-notification.md b/en/application-dev/reference/apis/js-apis-notification.md index 7cdf0119a33ed1724fa99d7ffc783bf2ef357d67..c5301e9ca4b5d7257d591bce88d705c63fc5e202 100644 --- a/en/application-dev/reference/apis/js-apis-notification.md +++ b/en/application-dev/reference/apis/js-apis-notification.md @@ -586,7 +586,7 @@ Notification.getSlot(slotType).then((data) => { ## Notification.getSlots -getSlots(callback: AsyncCallback>): void +getSlots(callback: AsyncCallback\>): void Obtains all notification slots. This API uses an asynchronous callback to return the result. @@ -596,7 +596,7 @@ Obtains all notification slots. This API uses an asynchronous callback to return | Name | Type | Mandatory| Description | | -------- | --------------------------------- | ---- | -------------------- | -| callback | AsyncCallback\\> | Yes | Callback used to return the result.| +| callback | AsyncCallback\> | Yes | Callback used to return the result.| **Example** @@ -1364,7 +1364,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => { ## Notification.getSlotsByBundle -getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback>): void +getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\>): void Obtains the notification slots of a specified application. This API uses an asynchronous callback to return the result. @@ -1379,7 +1379,7 @@ Obtains the notification slots of a specified application. This API uses an asyn | Name | Type | Mandatory| Description | | -------- | ---------------------------------------- | ---- | -------------------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | -| callback | AsyncCallback> | Yes | Callback used to return the result.| +| callback | AsyncCallback\> | Yes | Callback used to return the result.| **Example** @@ -1401,7 +1401,7 @@ Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); ## Notification.getSlotsByBundle -getSlotsByBundle(bundle: BundleOption): Promise> +getSlotsByBundle(bundle: BundleOption): Promise\> Obtains the notification slots of a specified application. This API uses a promise to return the result. @@ -1421,7 +1421,7 @@ Obtains the notification slots of a specified application. This API uses a promi | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise> | Promise used to return the result.| +| Promise\> | Promise used to return the result.| **Example** @@ -1823,7 +1823,7 @@ Notification.removeAll(userId).then(() => { ## Notification.getAllActiveNotifications -getAllActiveNotifications(callback: AsyncCallback>): void +getAllActiveNotifications(callback: AsyncCallback\>): void Obtains all active notifications. This API uses an asynchronous callback to return the result. @@ -1837,7 +1837,7 @@ Obtains all active notifications. This API uses an asynchronous callback to retu | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | -------------------- | -| callback | AsyncCallback> | Yes | Callback used to return the result.| +| callback | AsyncCallback\> | Yes | Callback used to return the result.| **Example** @@ -1857,7 +1857,7 @@ Notification.getAllActiveNotifications(getAllActiveNotificationsCallback); ## Notification.getAllActiveNotifications -getAllActiveNotifications(): Promise\\> +getAllActiveNotifications(): Promise\> Obtains all active notifications. This API uses a promise to return the result. @@ -1871,7 +1871,7 @@ Obtains all active notifications. This API uses a promise to return the result. | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\\> | Promise used to return the result.| +| Promise\> | Promise used to return the result.| **Example** @@ -2903,476 +2903,6 @@ Notification.getDeviceRemindType().then((data) => { }); ``` - -## Notification.publishAsBundle9+ - -publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number, callback: AsyncCallback\): void - -Publishes an agent-powered notification. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Notification.Notification - -**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER - -**System API**: This is a system API and cannot be called by third-party applications. - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------------------- | ------------------------------------------- | ---- | ---------------------------------------- | -| request | [NotificationRequest](#notificationrequest) | Yes | Content and related configuration of the notification to publish.| -| representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent. | -| userId | number | Yes | User ID. | -| callback | AsyncCallback | Yes | Callback used to return the result. | - -**Example** - -```js -// publishAsBundle callback -function callback(err) { - if (err.code) { - console.info("publishAsBundle failed " + JSON.stringify(err)); - } else { - console.info("publishAsBundle success"); - } -} -// Bundle name of the application whose notification function is taken over by the reminder agent -let representativeBundle = "com.example.demo"; -// User ID -let userId = 100; -// NotificationRequest object -let request = { - id: 1, - content: { - contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, - normal: { - title: "test_title", - text: "test_text", - additionalText: "test_additionalText" - } - } -}; - -Notification.publishAsBundle(request, representativeBundle, userId, callback); -``` - -## Notification.publishAsBundle9+ - -publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number): Promise\ - -Publishes a notification through the reminder agent. This API uses a promise to return the result. - -**System capability**: SystemCapability.Notification.Notification - -**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER - -**System API**: This is a system API and cannot be called by third-party applications. - -**Parameters** - - -| Name | Type | Mandatory| Description | -| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- | -| request | [NotificationRequest](#notificationrequest) | Yes | Content and related configuration of the notification to publish.| -| representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent. | -| userId | number | Yes | User ID. | - -**Example** - -```js -// Bundle name of the application whose notification function is taken over by the reminder agent -let representativeBundle = "com.example.demo"; -// User ID -let userId = 100; -// NotificationRequest object -let request = { - id: 1, - content: { - contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, - normal: { - title: "test_title", - text: "test_text", - additionalText: "test_additionalText" - } - } -}; - -Notification.publishAsBundle(request, representativeBundle, userId).then(() => { - console.info("publishAsBundle success"); -}); -``` - -## Notification.cancelAsBundle9+ - -cancelAsBundle(id: number, representativeBundle: string, userId: number, callback: AsyncCallback\): void - -Cancels a notification published by the reminder agent. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Notification.Notification - -**System API**: This is a system API and cannot be called by third-party applications. - -**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER - -**System API**: This is a system API and cannot be called by third-party applications. - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------------------- | ------------- | ---- | ------------------------ | -| id | number | Yes | Notification ID. | -| representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent. | -| userId | number | Yes | User ID. | -| callback | AsyncCallback | Yes | Callback used to return the result.| - -**Example** - -```js -// cancelAsBundle -function cancelAsBundleCallback(err) { - if (err.code) { - console.info("cancelAsBundle failed " + JSON.stringify(err)); - } else { - console.info("cancelAsBundle success"); - } -} -// Bundle name of the application whose notification function is taken over by the reminder agent -let representativeBundle = "com.example.demo"; -// User ID -let userId = 100; - -Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback); -``` - -## Notification.cancelAsBundle9+ - -cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\ - -Cancels a notification published by the reminder agent. This API uses a promise to return the result. - -**System capability**: SystemCapability.Notification.Notification - -**System API**: This is a system API and cannot be called by third-party applications. - -**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER - -**System API**: This is a system API and cannot be called by third-party applications. - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------------------- | ------ | ---- | ------------------ | -| id | number | Yes | Notification ID. | -| representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent.| -| userId | number | Yes | User ID.| - -**Example** - -```js -// Bundle name of the application whose notification function is taken over by the reminder agent -let representativeBundle = "com.example.demo"; -// User ID -let userId = 100; - -Notification.cancelAsBundle(0, representativeBundle, userId).then(() => { - console.info("cancelAsBundle success"); -}); -``` - -## Notification.enableNotificationSlot 9+ - -enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\): void - -Sets the enabled status of a notification slot type for a specified application. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Notification.Notification - -**System API**: This is a system API and cannot be called by third-party applications. - -**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ----------------------------- | ---- | ---------------------- | -| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | -| type | [SlotType](#slottype) | Yes | Notification slot type. | -| enable | boolean | Yes | Whether to enable notification. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -// enableNotificationSlot -function enableSlotCallback(err) { - if (err.code) { - console.info("enableNotificationSlot failed " + JSON.stringify(err)); - } else { - console.info("enableNotificationSlot success"); - } -}; - -Notification.enableNotificationSlot( - { bundle: "ohos.samples.notification", }, - Notification.SlotType.SOCIAL_COMMUNICATION, - true, - enableSlotCallback); -``` - -## Notification.enableNotificationSlot 9+ - -enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\ - -Sets the enabled status of a notification slot type for a specified application. This API uses a promise to return the result. - -**System capability**: SystemCapability.Notification.Notification - -**System API**: This is a system API and cannot be called by third-party applications. - -**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | ----------------------------- | ---- | -------------- | -| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | -| type | [SlotType](#slottype) | Yes | Notification slot type.| -| enable | boolean | Yes | Whether to enable notification. | - -**Example** - -```js -// enableNotificationSlot -Notification.enableNotificationSlot({ bundle: "ohos.samples.notification", }, - Notification.SlotType.SOCIAL_COMMUNICATION,true).then(() => { - console.info("enableNotificationSlot success"); -}); -``` - -## Notification.isNotificationSlotEnabled 9+ - -isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\): void - -Checks whether a specified notification slot type is enabled for a specified application. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Notification.Notification - -**System API**: This is a system API and cannot be called by third-party applications. - -**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ----------------------------- | ---- | ---------------------- | -| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | -| type | [SlotType](#slottype) | Yes | Notification slot type. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -// isNotificationSlotEnabled -function getEnableSlotCallback(err, data) { - if (err.code) { - console.info("isNotificationSlotEnabled failed " + JSON.stringify(err)); - } else { - console.info("isNotificationSlotEnabled success"); - } -}; - -Notification.isNotificationSlotEnabled( - { bundle: "ohos.samples.notification", }, - Notification.SlotType.SOCIAL_COMMUNICATION, - getEnableSlotCallback); -``` - -## Notification.isNotificationSlotEnabled 9+ - -isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\ - -Checks whether a specified notification slot type is enabled for a specified application. This API uses a promise to return the result. - -**System capability**: SystemCapability.Notification.Notification - -**System API**: This is a system API and cannot be called by third-party applications. - -**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | ----------------------------- | ---- | -------------- | -| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | -| type | [SlotType](#slottype) | Yes | Notification slot type.| - -**Return value** - -| Type | Description | -| ------------------ | ------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -// isNotificationSlotEnabled -Notification.isNotificationSlotEnabled({ bundle: "ohos.samples.notification", }, - Notification.SlotType.SOCIAL_COMMUNICATION).then((data) => { - console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data)); -}); -``` - - -## Notification.setSyncNotificationEnabledWithoutApp9+ - -setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: AsyncCallback\): void - -Sets whether to enable the notification sync feature for devices where the application is not installed. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Notification.Notification - -**System API**: This is a system API and cannot be called by third-party applications. - -**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | ----------------------------- | ---- | -------------- | -| userId | number | Yes | User ID. | -| enable | boolean | Yes | Whether the feature is enabled. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -let userId = 100; -let enable = true; - -function callback(err) { - if (err.code) { - console.info("setSyncNotificationEnabledWithoutApp failed " + JSON.stringify(err)); - } else { - console.info("setSyncNotificationEnabledWithoutApp success"); - } -} - -Notification.setSyncNotificationEnabledWithoutApp(userId, enable, callback); -``` - - -## Notification.setSyncNotificationEnabledWithoutApp9+ - -setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\ - -Sets whether to enable the notification sync feature for devices where the application is not installed. This API uses a promise to return the result. - -**System capability**: SystemCapability.Notification.Notification - -**System API**: This is a system API and cannot be called by third-party applications. - -**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | ----------------------------- | ---- | -------------- | -| userId | number | Yes | User ID. | -| enable | boolean | Yes | Whether the feature is enabled. | - -**Return value** - -| Type | Description | -| ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -let userId = 100; -let enable = true; - -Notification.setSyncNotificationEnabledWithoutApp(userId, enable).then(() => { - console.info('setSyncNotificationEnabledWithoutApp success'); -}).catch((err) => { - console.info('setSyncNotificationEnabledWithoutApp, err:' + JSON.stringify(err)); -}); -``` - - -## Notification.getSyncNotificationEnabledWithoutApp9+ - -getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\): void - -Obtains whether the notification sync feature is enabled for devices where the application is not installed. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Notification.Notification - -**System API**: This is a system API and cannot be called by third-party applications. - -**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | ----------------------------- | ---- | -------------- | -| userId | number | Yes | User ID. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -let userId = 100; - -function getSyncNotificationEnabledWithoutAppCallback(err, data) { - if (err) { - console.info('getSyncNotificationEnabledWithoutAppCallback, err:' + err); - } else { - console.info('getSyncNotificationEnabledWithoutAppCallback, data:' + data); - } -} - -Notification.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEnabledWithoutAppCallback); -``` - - -## Notification.getSyncNotificationEnabledWithoutApp9+ - -getSyncNotificationEnabledWithoutApp(userId: number): Promise\ - -Obtains whether the notification sync feature is enabled for devices where the application is not installed. This API uses a promise to return the result. - -**System capability**: SystemCapability.Notification.Notification - -**System API**: This is a system API and cannot be called by third-party applications. - -**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | ----------------------------- | ---- | -------------- | -| userId | number | Yes | User ID. | - -**Return value** - -| Type | Description | -| ------------------ | ------------------------------------------------------------ | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -let userId = 100; -Notification.getSyncNotificationEnabledWithoutApp(userId).then((data) => { - console.info('getSyncNotificationEnabledWithoutApp, data:' + data); -}).catch((err) => { - console.info('getSyncNotificationEnabledWithoutApp, err:' + err); -}); -``` - - - ## NotificationSubscriber Provides callbacks for receiving or removing notifications and serves as the input parameter of [subscribe](#notificationsubscribe). @@ -4111,5 +3641,5 @@ Provides the notification user input. | Name | Value | Description | | -------------------- | --- | -------------------- | -| CLICK_REASON_REMOVE | 1 | The notification is removed after a click on it. | -| CANCEL_REASON_REMOVE | 2 | The notification is removed by the user. | +| CLICK_REASON_REMOVE9+ | 1 | The notification is removed after a click on it. | +| CANCEL_REASON_REMOVE9+ | 2 | The notification is removed by the user. | diff --git a/en/application-dev/reference/apis/js-apis-notificationManager.md b/en/application-dev/reference/apis/js-apis-notificationManager.md index 875b6129d039e09172fa9a1e366bd48a813749fc..0c136cad2373439709255dea4e829b5d3ec1eb7c 100644 --- a/en/application-dev/reference/apis/js-apis-notificationManager.md +++ b/en/application-dev/reference/apis/js-apis-notificationManager.md @@ -33,7 +33,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -89,8 +88,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------------- | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -145,8 +142,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------------- | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -208,8 +203,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------------- | -| 201 | Permission denied. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -263,7 +256,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -306,7 +298,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -343,7 +334,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -379,7 +369,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -420,7 +409,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -460,9 +448,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -511,9 +496,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -553,7 +535,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -594,7 +575,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -634,9 +614,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -689,9 +666,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -735,7 +709,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -783,7 +756,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -801,7 +773,7 @@ Notification.getSlot(slotType).then((data) => { ## Notification.getSlots -getSlots(callback: AsyncCallback>): void +getSlots(callback: AsyncCallback\>): void Obtains all notification slots of this application. This API uses an asynchronous callback to return the result. @@ -819,7 +791,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -842,7 +813,7 @@ Notification.getSlots(getSlotsCallback); ## Notification.getSlots -getSlots(): Promise\> +getSlots(): Promise\> Obtains all notification slots of this application. This API uses a promise to return the result. @@ -860,7 +831,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -896,7 +866,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -938,7 +907,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -974,7 +942,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1008,7 +975,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1049,9 +1015,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1100,9 +1063,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1146,9 +1106,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1202,9 +1159,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1247,9 +1201,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1282,11 +1233,93 @@ Checks whether notification is enabled for the current application. This API use **System API**: This is a system API and cannot be called by third-party applications. +**Return value** + +| Type | Description | +| ----------------------------------------------------------- | ------------------------------------------------------------ | +| Promise\ | Promise used to return the result.| + +**Error codes** + +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + +| ID| Error Message | +| -------- | ---------------------------------------- | +| 1600001 | Internal error. | +| 1600002 | Marshalling or unmarshalling error. | +| 1600003 | Failed to connect service. | + +**Example** + +```ts +notificationManager.isNotificationEnabled().then((data) => { + console.info("isNotificationEnabled success, data: " + JSON.stringify(data)); +}); +``` + +## notificationManager.isNotificationEnabled + +isNotificationEnabled(userId: number, callback: AsyncCallback\): void + +Checks whether notification is enabled for a specified user. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Notification.Notification + +**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ------------------------ | +| userId | number | Yes | User ID.| +| callback | AsyncCallback\ | Yes | Callback used to return the result.| + +**Error codes** + +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + +| ID| Error Message | +| -------- | ----------------------------------- | +| 1600001 | Internal error. | +| 1600002 | Marshalling or unmarshalling error. | +| 1600003 | Failed to connect service. | +| 1600008 | The user is not exist. | + +**Example** + +```ts +function isNotificationEnabledCallback(err, data) { + if (err) { + console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`); + } else { + console.info("isNotificationEnabled success"); + } +} + +let userId = 1; + +notificationManager.isNotificationEnabled(userId, isNotificationEnabledCallback); +``` + +## notificationManager.isNotificationEnabled + +isNotificationEnabled(userId: number): Promise\ + +Checks whether notification is enabled for a specified user. This API uses a promise to return the result. + +**System capability**: SystemCapability.Notification.Notification + +**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER + +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name | Type | Mandatory| Description | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle of the application.| +| userId | number | Yes | User ID.| **Return value** @@ -1300,18 +1333,17 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | -| 17700001 | The specified bundle name was not found. | +| 1600008 | The user is not exist.. | **Example** -```js -Notification.isNotificationEnabled().then((data) => { +```ts +let userId = 1; + +notificationManager.isNotificationEnabled(userId).then((data) => { console.info("isNotificationEnabled success, data: " + JSON.stringify(data)); }); ``` @@ -1344,9 +1376,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1395,9 +1424,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1441,9 +1467,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1497,9 +1520,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1542,9 +1562,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1598,9 +1615,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1624,7 +1638,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => { ## Notification.getSlotsByBundle -getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback>): void +getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\>): void Obtains the notification slots of a specified application. This API uses an asynchronous callback to return the result. @@ -1647,9 +1661,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1695,7 +1706,7 @@ Obtains the notification slots of a specified application. This API uses a promi | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise> | Promise used to return the result.| +| Promise\> | Promise used to return the result.| **Error codes** @@ -1703,9 +1714,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1749,9 +1757,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1805,9 +1810,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1829,7 +1831,7 @@ Notification.getSlotNumByBundle(bundle).then((data) => { ## Notification.getAllActiveNotifications -getAllActiveNotifications(callback: AsyncCallback>): void +getAllActiveNotifications(callback: AsyncCallback\>): void Obtains all active notifications. This API uses an asynchronous callback to return the result. @@ -1851,9 +1853,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1898,9 +1897,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1935,7 +1931,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1976,7 +1971,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1993,7 +1987,7 @@ Notification.getActiveNotificationCount().then((data) => { ## Notification.getActiveNotifications -getActiveNotifications(callback: AsyncCallback>): void +getActiveNotifications(callback: AsyncCallback\>): void Obtains active notifications of this application. This API uses an asynchronous callback to return the result. @@ -2003,7 +1997,7 @@ Obtains active notifications of this application. This API uses an asynchronous | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------ | -| callback | AsyncCallback> | Yes | Callback used to return the result.| +| callback | AsyncCallback\> | Yes | Callback used to return the result.| **Error codes** @@ -2011,7 +2005,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2052,7 +2045,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2088,7 +2080,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2104,7 +2095,7 @@ function cancelGroupCallback(err) { } } -var groupName = "GroupName"; +let groupName = "GroupName"; Notification.cancelGroup(groupName, cancelGroupCallback); ``` @@ -2131,7 +2122,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2173,9 +2163,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2225,9 +2212,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2270,9 +2254,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2323,9 +2304,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2370,9 +2348,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2427,9 +2402,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2476,9 +2448,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2523,9 +2492,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2564,9 +2530,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2620,9 +2583,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2663,9 +2623,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2710,9 +2667,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2748,11 +2702,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | -| 1600011 | Read template config failed. | **Example** @@ -2797,11 +2749,9 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | -| 1600011 | Read template config failed. | **Example** @@ -2835,7 +2785,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2870,7 +2819,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2910,9 +2858,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2960,9 +2905,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2999,7 +2941,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3041,7 +2982,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3083,9 +3023,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3139,9 +3076,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3187,9 +3121,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3246,9 +3177,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3292,9 +3220,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3339,9 +3264,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3382,9 +3304,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3451,9 +3370,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3516,9 +3432,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3572,9 +3485,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3621,9 +3531,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3674,9 +3581,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3720,9 +3624,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3777,9 +3678,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3822,9 +3720,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3879,9 +3774,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3926,9 +3818,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3981,9 +3870,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | diff --git a/en/application-dev/reference/apis/js-apis-notificationSubscribe.md b/en/application-dev/reference/apis/js-apis-notificationSubscribe.md index 4380c521dc82bf34771c17e238e4a7b56809276a..1ca931fa6f5671e6c7a9cdb4032910983745a516 100644 --- a/en/application-dev/reference/apis/js-apis-notificationSubscribe.md +++ b/en/application-dev/reference/apis/js-apis-notificationSubscribe.md @@ -40,9 +40,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -95,9 +92,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -148,9 +142,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -196,9 +187,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -246,9 +234,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -294,9 +279,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -352,9 +334,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -371,7 +350,7 @@ let notificationKey = { id: 0, label: "label", }; -let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; +let reason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; notificationSubscribe.remove(bundle, notificationKey, reason).then(() => { console.info("remove success"); }); @@ -393,7 +372,7 @@ Removes a specified notification. This API uses an asynchronous callback to retu | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | -------------------- | -| hashCode | string | Yes | Unique notification ID. It is the value of **hashCode** in the [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) object of [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) in the [onConsume](#onconsume) callback. | +| hashCode | string | Yes | Unique notification ID. It is the **hashCode** in the [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) object of [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) of the [onConsume](js-apis-notification.md#onconsume) callback.| | reason | [RemoveReason](#removereason) | Yes | Reason for removing the notification. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| @@ -403,9 +382,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -423,7 +399,7 @@ function removeCallback(err) { console.info("remove success"); } } -let reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE; +let reason = notificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE; notificationSubscribe.remove(hashCode, reason, removeCallback); ``` @@ -452,9 +428,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -486,7 +459,7 @@ Removes all notifications for a specified application. This API uses an asynchro | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ---------------------------- | -| bundle | [BundleOption](js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. | +| bundle | [BundleOption](js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Error codes** @@ -495,9 +468,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -516,7 +486,7 @@ function removeAllCallback(err) { let bundle = { bundle: "bundleName1", }; -NotificationSubscribe.removeAll(bundle, removeAllCallback); +notificationSubscribe.removeAll(bundle, removeAllCallback); ``` ## NotificationSubscribe.removeAll @@ -543,9 +513,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -588,9 +555,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ---------------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -630,9 +594,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -678,9 +639,6 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ | ID| Error Message | | -------- | ----------------------------------- | -| 201 | Permission denied. | -| 202 | Not system application to call the interface. | -| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -702,319 +660,6 @@ let userId = 1; notificationSubscribe.removeAll(userId, removeAllCallback); ``` -## NotificationSubscriber - -Provides callbacks for receiving or removing notifications and serves as the input parameter of [subscribe](#notificationsubscribesubscribe). - -**System API**: This is a system API and cannot be called by third-party applications. - -### onConsume - -onConsume?: (data: [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)) => void - -Called when a notification is received. - -**System capability**: SystemCapability.Notification.Notification - -**System API**: This is a system API and cannot be called by third-party applications. - -**Parameters** - -| Name| Type| Mandatory| Description| -| ------------ | ------------------------ | ---- | -------------------------- | -| data | [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) | Yes| Information about the notification received.| - -**Example** - -```javascript -function subscribeCallback(err) { - if (err) { - console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`); - } else { - console.info("subscribeCallback"); - } -}; - -function onConsumeCallback(data) { - console.info('===> onConsume in test'); - let req = data.request; - console.info('===> onConsume callback req.id:' + req.id); -}; - -let subscriber = { - onConsume: onConsumeCallback -}; - -notificationSubscribe.subscribe(subscriber, subscribeCallback); -``` - -### onCancel - -onCancel?:(data: [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)) => void - -Called when a notification is canceled. - -**System capability**: SystemCapability.Notification.Notification - -**System API**: This is a system API and cannot be called by third-party applications. - -**Parameters** - -| Name| Type| Mandatory| Description| -| ------------ | ------------------------ | ---- | -------------------------- | -| data | [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) | Yes| Information about the notification to cancel.| - -**Example** - -```javascript -function subscribeCallback(err) { - if (err) { - console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`); - } else { - console.info("subscribeCallback"); - } -}; - -function onCancelCallback(data) { - console.info('===> onCancel in test'); - let req = data.request; - console.info('===> onCancel callback req.id:' + req.id); -} - -let subscriber = { - onCancel: onCancelCallback -}; - -notificationSubscribe.subscribe(subscriber, subscribeCallback); -``` - -### onUpdate - -onUpdate?:(data: [NotificationSortingMap](js-apis-notification.md#notificationsortingmap)) => void - -Called when the notification sorting list is updated. - -**System capability**: SystemCapability.Notification.Notification - -**System API**: This is a system API and cannot be called by third-party applications. - -**Parameters** - -| Name| Type| Mandatory| Description| -| ------------ | ------------------------ | ---- | -------------------------- | -| data | [NotificationSortingMap](js-apis-notification.md#notificationsortingmap)) | Yes| Latest notification sorting list.| - -**Example** - -```javascript -function subscribeCallback(err) { - if (err) { - console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`); - } else { - console.info("subscribeCallback"); - } -}; - -function onUpdateCallback(map) { - console.info('===> onUpdateCallback map:' + JSON.stringify(map)); -} - -let subscriber = { - onUpdate: onUpdateCallback -}; - -notificationSubscribe.subscribe(subscriber, subscribeCallback); -``` - -### onConnect - -onConnect?:() => void - -Called when subscription is complete. - -**System capability**: SystemCapability.Notification.Notification - -**System API**: This is a system API and cannot be called by third-party applications. - -**Example** - -```javascript -function subscribeCallback(err) { - if (err) { - console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`); - } else { - console.info("subscribeCallback"); - } -}; - -function onConnectCallback() { - console.info('===> onConnect in test'); -} - -let subscriber = { - onConnect: onConnectCallback -}; - -notificationSubscribe.subscribe(subscriber, subscribeCallback); -``` - -### onDisconnect - -onDisconnect?:() => void - -Called when unsubscription is complete. - -**System capability**: SystemCapability.Notification.Notification - -**System API**: This is a system API and cannot be called by third-party applications. - -**Example** - -```javascript -function subscribeCallback(err) { - if (err) { - console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`); - } else { - console.info("subscribeCallback"); - } -}; -function unsubscribeCallback(err) { - if (err.code) { - console.error(`unsubscribe failed, code is ${err.code}, message is ${err.message}`); - } else { - console.info("unsubscribeCallback"); - } -}; - -function onConnectCallback() { - console.info('===> onConnect in test'); -} -function onDisconnectCallback() { - console.info('===> onDisconnect in test'); -} - -let subscriber = { - onConnect: onConnectCallback, - onDisconnect: onDisconnectCallback -}; - -// The onConnect callback is invoked when subscription to the notification is complete. -notificationSubscribe.subscribe(subscriber, subscribeCallback); -// The onDisconnect callback is invoked when unsubscription to the notification is complete. -notificationSubscribe.unsubscribe(subscriber, unsubscribeCallback); -``` - -### onDestroy - -onDestroy?:() => void - -Callback for service disconnection. - -**System capability**: SystemCapability.Notification.Notification - -**System API**: This is a system API and cannot be called by third-party applications. - -**Example** - -```javascript -function subscribeCallback(err) { - if (err) { - console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`); - } else { - console.info("subscribeCallback"); - } -}; - -function onDestroyCallback() { - console.info('===> onDestroy in test'); -} - -let subscriber = { - onDestroy: onDestroyCallback -}; - -notificationSubscribe.subscribe(subscriber, subscribeCallback); -``` - -### onDoNotDisturbDateChange - -onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](js-apis-notificationManager.md#donotdisturbdate)) => void - -Called when the DND time setting is updated. - -**System capability**: SystemCapability.Notification.Notification - -**System API**: This is a system API and cannot be called by third-party applications. - -**Parameters** - -| Name| Type| Mandatory| Description| -| ------------ | ------------------------ | ---- | -------------------------- | -| mode | notification.[DoNotDisturbDate](js-apis-notificationManager.md#DoNotDisturbDate) | Yes| DND time setting updates.| - -**Example** - -```javascript -function subscribeCallback(err) { - if (err) { - console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`); - } else { - console.info("subscribeCallback"); - } -}; - -function onDoNotDisturbDateChangeCallback(mode) { - console.info('===> onDoNotDisturbDateChange:' + mode); -} - -let subscriber = { - onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback -}; - -notificationSubscribe.subscribe(subscriber, subscribeCallback); -``` - - -### onEnabledNotificationChanged - -onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](js-apis-notification.md#enablednotificationcallbackdata8)) => void - -Listens for the notification enabled status changes. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Notification.Notification - -**System API**: This is a system API and cannot be called by third-party applications. - -**Parameters** - -| Name| Type| Mandatory| Description| -| ------------ | ------------------------ | ---- | -------------------------- | -| callback | AsyncCallback\<[EnabledNotificationCallbackData](js-apis-notification.md#enablednotificationcallbackdata8)\> | Yes| Callback used to return the result.| - -**Example** - -```javascript -function subscribeCallback(err) { - if (err) { - console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`); - } else { - console.info("subscribeCallback"); - } -}; - -function onEnabledNotificationChangedCallback(callbackData) { - console.info("bundle: ", callbackData.bundle); - console.info("uid: ", callbackData.uid); - console.info("enable: ", callbackData.enable); -}; - -let subscriber = { - onEnabledNotificationChanged: onEnabledNotificationChangedCallback -}; - -notificationSubscribe.subscribe(subscriber, subscribeCallback); -``` - ## RemoveReason **System capability**: SystemCapability.Notification.Notification diff --git a/en/application-dev/reference/apis/js-apis-request.md b/en/application-dev/reference/apis/js-apis-request.md index 0751c7aa94c518f40ac1c5ae3e0d1fca6ccac62f..e6a48d95be3adc18f14ba168ca207c5eceea9e07 100644 --- a/en/application-dev/reference/apis/js-apis-request.md +++ b/en/application-dev/reference/apis/js-apis-request.md @@ -14,13 +14,6 @@ The **request** module provides applications with basic upload, download, and ba import request from '@ohos.request'; ``` - -## Constraints - -Only HTTP requests are supported. HTTPS requests are not supported. - -The download server must support the HTTP HEAD method so that the size of the data to download can be obtained through **Content-length**. Otherwise, the download task fails. If this is the case, you can check the failure cause through [on('fail')7+](#onfail7). - ## Constants **Required permissions**: ohos.permission.INTERNET @@ -36,7 +29,7 @@ You can set **networkType** in [DownloadConfig](#downloadconfig) to specify the | NETWORK_WIFI | number | 0x00010000 | Whether download is allowed on a WLAN.| ### Download Error Codes -The table below lists the error codes that may be returned by [on('fail')7+](#onfail7)/[off('fail')7+](#offfail7)/[getTaskInfo9+](#gettaskinfo9). +The table below lists the values of **err** in the callback of [on('fail')7+](#onfail7) and the values of **failedReason** returned by [getTaskInfo9+](#gettaskinfo9). | Name| Type| Value| Description| | -------- | -------- | -------- | -------- | @@ -54,7 +47,7 @@ The table below lists the error codes that may be returned by [on('fail')7+ ### Causes of Download Pause -The table below lists the causes of download pause that may be returned by [getTaskInfo9+](#gettaskinfo9). +The table below lists the values of **pausedReason** returned by [getTaskInfo9+](#gettaskinfo9). | Name| Type| Value| Description| | -------- | -------- | -------- | -------- | @@ -65,7 +58,7 @@ The table below lists the causes of download pause that may be returned by [getT | PAUSED_UNKNOWN7+ | number | 4 | Download paused due to unknown reasons.| ### Download Task Status Codes -The table below lists the download task status codes that may be returned by [getTaskInfo9+](#gettaskinfo9). +The table below lists the values of **status** returned by [getTaskInfo9+](#gettaskinfo9). | Name| Type| Value| Description| | -------- | -------- | -------- | -------- | @@ -105,7 +98,7 @@ For details about the error codes, see [Upload and Download Error Codes](../erro | ID| Error Message| | -------- | -------- | -| 13400002 | Bad file path. | +| 13400002 | bad file path. | **Example** @@ -153,7 +146,7 @@ For details about the error codes, see [Upload and Download Error Codes](../erro | ID| Error Message| | -------- | -------- | -| 13400002 | Bad file path. | +| 13400002 | bad file path. | **Example** @@ -279,7 +272,7 @@ Implements file uploads. Before using any APIs of this class, you must obtain an on(type: 'progress', callback:(uploadedSize: number, totalSize: number) => void): void -Subscribes to an upload event. This API uses an asynchronous callback to return the result. +Subscribes to upload progress events. This API uses a callback to return the result synchronously. **Required permissions**: ohos.permission.INTERNET @@ -296,16 +289,16 @@ Subscribes to an upload event. This API uses an asynchronous callback to return | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| uploadedSize | number | Yes| Size of the uploaded files, in bits. | -| totalSize | number | Yes| Total size of the files to upload, in bits. | +| uploadedSize | number | Yes| Size of the uploaded files, in bits.| +| totalSize | number | Yes| Total size of the files to upload, in bits.| **Example** ```js - uploadTask.on('progress', function callback(uploadedSize, totalSize) { + let upProgressCallback = (uploadedSize, totalSize) => { console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize); - } - ); + }; + uploadTask.on('progress', upProgressCallback); ``` @@ -313,7 +306,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return on(type: 'headerReceive', callback: (header: object) => void): void -Subscribes to an upload event. This API uses an asynchronous callback to return the result. +Subscribes to HTTP header events for an upload task. This API uses a callback to return the result synchronously. **Required permissions**: ohos.permission.INTERNET @@ -335,10 +328,10 @@ Subscribes to an upload event. This API uses an asynchronous callback to return **Example** ```js - uploadTask.on('headerReceive', function callback(headers){ + let headerCallback = (headers) => { console.info("upOnHeader headers:" + JSON.stringify(headers)); - } - ); + }; + uploadTask.on('headerReceive', headerCallback); ``` @@ -346,7 +339,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return on(type:'complete' | 'fail', callback: Callback<Array<TaskState>>): void; -Subscribes to an upload event. This API uses an asynchronous callback to return the result. +Subscribes to upload completion or failure events. This API uses a callback to return the result synchronously. **Required permissions**: ohos.permission.INTERNET @@ -368,19 +361,19 @@ Subscribes to an upload event. This API uses an asynchronous callback to return **Example** ```js - uploadTask.on('complete', function callback(taskStates) { + let upCompleteCallback = (taskStates) => { for (let i = 0; i < taskStates.length; i++ ) { - console.info("upOnComplete taskState:" + JSON.stringify(taskStates[i])); + console.info("upOnComplete taskState:" + JSON.stringify(taskStates[i])); } - } - ); + }; + uploadTask.on('complete', upCompleteCallback); - uploadTask.on('fail', function callback(taskStates) { + let upFailCallback = (taskStates) => { for (let i = 0; i < taskStates.length; i++ ) { console.info("upOnFail taskState:" + JSON.stringify(taskStates[i])); } - } - ); + }; + uploadTask.on('fail', upFailCallback); ``` @@ -388,7 +381,7 @@ Subscribes to an upload event. This API uses an asynchronous callback to return off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) => void): void -Unsubscribes from an upload event. This API uses an asynchronous callback to return the result. +Unsubscribes from upload progress events. This API uses a callback to return the result synchronously. **Required permissions**: ohos.permission.INTERNET @@ -399,22 +392,15 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (upload progress).| -| callback | function | No| Callback for the upload progress event.| - - Parameters of the callback function - -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| uploadedSize | number | Yes| Size of the uploaded files, in bits. | -| totalSize | number | Yes| Total size of the files to upload, in bits. | +| callback | function | No| Callback used to return the result.
**uploadedSize**: size of the uploaded files, in bits.
**totalSize**: Total size of the files to upload, in bits. | **Example** ```js - uploadTask.off('progress', function callback(uploadedSize, totalSize) { - console.info('uploadedSize: ' + uploadedSize, 'totalSize: ' + totalSize); - } - ); + let upProgressCallback = (uploadedSize, totalSize) => { + console.info('Upload delete progress notification.' + 'totalSize:' + totalSize + 'uploadedSize:' + uploadedSize); + }; + uploadTask.off('progress', upProgressCallback); ``` @@ -422,7 +408,7 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret off(type: 'headerReceive', callback?: (header: object) => void): void -Unsubscribes from an upload event. This API uses an asynchronous callback to return the result. +Unsubscribes from HTTP header events for an upload task. This API uses a callback to return the result synchronously. **Required permissions**: ohos.permission.INTERNET @@ -433,28 +419,22 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Type of the event to unsubscribe from. The value is **'headerReceive'** (response header).| -| callback | function | No| Callback for the HTTP Response Header event.| - - Parameters of the callback function - -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| header | object | Yes| HTTP Response Header.| +| callback | function | No| Callback used to return the result.
**header**: HTTP response header.| **Example** ```js - uploadTask.off('headerReceive', function callback(headers) { - console.info("upOnHeader headers:" + JSON.stringify(headers)); - } - ); + let headerCallback = (header) => { + console.info(`Upload delete headerReceive notification. header: ${JSON.stringify(header)}`); + }; + uploadTask.off('headerReceive', headerCallback); ``` ### off('complete' | 'fail')9+ off(type:'complete' | 'fail', callback?: Callback<Array<TaskState>>): void; -Unsubscribes from an upload event. This API uses an asynchronous callback to return the result. +Unsubscribes from upload completion or failure events. This API uses a callback to return the result synchronously. **Required permissions**: ohos.permission.INTERNET @@ -465,30 +445,26 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.| -| callback | Callback<Array<TaskState>> | No| Callback used to return the result.| - - Parameters of the callback function - -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| taskstates | Array<[TaskState](#taskstate9)> | Yes| Upload result.| +| callback | Callback<Array<TaskState>> | No| Callback used to return the result.
**taskstates**: upload task result.| **Example** ```js - uploadTask.off('complete', function callback(taskStates) { + let upCompleteCallback = (taskStates) => { + console.info('Upload delete complete notification.'); for (let i = 0; i < taskStates.length; i++ ) { - console.info("upOnComplete taskState:" + JSON.stringify(taskStates[i])); + console.info('taskState:' + JSON.stringify(taskStates[i])); } - } - ); + }; + uploadTask.off('complete', upCompleteCallback); - uploadTask.off('fail', function callback(taskStates) { + let upFailCallback = (taskStates) => { + console.info('Upload delete fail notification.'); for (let i = 0; i < taskStates.length; i++ ) { - console.info("upOnFail taskState:" + JSON.stringify(taskStates[i])); + console.info('taskState:' + JSON.stringify(taskStates[i])); } - } - ); + }; + uploadTask.off('fail', upFailCallback); ``` ### delete9+ @@ -709,9 +685,9 @@ For details about the error codes, see [Upload and Download Error Codes](../erro | ID| Error Message| | -------- | -------- | -| 13400001 | File operation error. | -| 13400002 | Bad file path. | -| 13400003 | Task manager service error. | +| 13400001 | file operation error. | +| 13400002 | bad file path. | +| 13400003 | task manager service error. | **Example** @@ -753,9 +729,9 @@ For details about the error codes, see [Upload and Download Error Codes](../erro | ID| Error Message| | -------- | -------- | -| 13400001 | File operation error. | -| 13400002 | Bad file path. | -| 13400003 | Task manager service error. | +| 13400001 | file operation error. | +| 13400002 | bad file path. | +| 13400003 | task manager service error. | **Example** @@ -861,7 +837,7 @@ Implements file downloads. on(type: 'progress', callback:(receivedSize: number, totalSize: number) => void): void -Subscribes to a download event. This API uses an asynchronous callback to return the result. +Subscribes to download progress events. This API uses a callback to return the result synchronously. **Required permissions**: ohos.permission.INTERNET @@ -872,22 +848,22 @@ Subscribes to a download event. This API uses an asynchronous callback to return | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (download progress).| -| callback | function | Yes| Callback for the download progress event.| +| callback | function | Yes| Callback used to return the result.| Parameters of the callback function | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| receivedSize | number | Yes| Size of the downloaded files, in bits.| -| totalSize | number | Yes| Total size of the files to download, in bits.| +| receivedSize | number | Yes| Size of the downloaded files, in bits. | +| totalSize | number | Yes| Total size of the files to download, in bits. | **Example** ```js - downloadTask.on('progress', function download_callback(receivedSize, totalSize) { + let progresCallback = (receivedSize, totalSize) => { console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize); - } - ); + }; + downloadTask.on('progress', progresCallback); ``` @@ -895,7 +871,7 @@ Subscribes to a download event. This API uses an asynchronous callback to return off(type: 'progress', callback?: (receivedSize: number, totalSize: number) => void): void -Unsubscribes from a download event. This API uses an asynchronous callback to return the result. +Unsubscribes from download progress events. This API uses a callback to return the result synchronously. **Required permissions**: ohos.permission.INTERNET @@ -906,22 +882,15 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (download progress).| -| callback | function | No| Callback for the download progress event.| - - Parameters of the callback function - -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| receivedSize | number | Yes| Size of the downloaded files, in bits.| -| totalSize | number | Yes| Total size of the files to download, in bits.| +| callback | function | No| Callback used to return the result.
**receivedSize**: size of the downloaded files.
**totalSize**: total size of the files to download.| **Example** ```js - downloadTask .off('progress', function download_callback(receivedSize, totalSize) { - console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize); - } - ); + let progresCallback = (receivedSize, totalSize) => { + console.info('Download delete progress notification.' + 'receivedSize:' + receivedSize + 'totalSize:' + totalSize); + }; + downloadTask.off('progress', progresCallback); ``` @@ -929,7 +898,7 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re on(type: 'complete'|'pause'|'remove', callback:() => void): void -Subscribes to a download event. This API uses an asynchronous callback to return the result. +Subscribes to download events. This API uses a callback to return the result synchronously. **Required permissions**: ohos.permission.INTERNET @@ -945,10 +914,20 @@ Subscribes to a download event. This API uses an asynchronous callback to return **Example** ```js - downloadTask.on('complete', function callback() { + let completeCallback = () => { console.info('Download task completed.'); - } - ); + }; + downloadTask.on('complete', completeCallback); + + let pauseCallback = () => { + console.info('Download task pause.'); + }; + downloadTask.on('pause', pauseCallback); + + let removeCallback = () => { + console.info('Download task remove.'); + }; + downloadTask.on('remove', removeCallback); ``` @@ -956,7 +935,7 @@ Subscribes to a download event. This API uses an asynchronous callback to return off(type: 'complete'|'pause'|'remove', callback?:() => void): void -Unsubscribes from a download event. This API uses an asynchronous callback to return the result. +Unsubscribes from download events. This API uses a callback to return the result synchronously. **Required permissions**: ohos.permission.INTERNET @@ -972,10 +951,20 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re **Example** ```js - downloadTask.off('complete', function callback() { - console.info('Download task completed.'); - } - ); + let completeCallback = () => { + console.info('Download delete complete notification.'); + }; + downloadTask.off('complete', completeCallback); + + let pauseCallback = () => { + console.info('Download delete pause notification.'); + }; + downloadTask.off('pause', pauseCallback); + + let removeCallback = () => { + console.info('Download delete remove notification.'); + }; + downloadTask.off('remove', removeCallback); ``` @@ -983,7 +972,7 @@ Unsubscribes from a download event. This API uses an asynchronous callback to re on(type: 'fail', callback: (err: number) => void): void -Subscribes to the download task failure event. This API uses an asynchronous callback to return the result. +Subscribes to download failure events. This API uses a callback to return the result synchronously. **Required permissions**: ohos.permission.INTERNET @@ -1004,11 +993,11 @@ Subscribes to the download task failure event. This API uses an asynchronous cal **Example** - ```js - downloadTask.on('fail', function callBack(err) { + ```js + let failCallback = (err) => { console.info('Download task failed. Cause:' + err); - } - ); + }; + downloadTask.on('fail', failCallback); ``` @@ -1016,7 +1005,7 @@ Subscribes to the download task failure event. This API uses an asynchronous cal off(type: 'fail', callback?: (err: number) => void): void -Unsubscribes from the download task failure event. This API uses an asynchronous callback to return the result. +Unsubscribes from download failure events. This API uses a callback to return the result synchronously. **Required permissions**: ohos.permission.INTERNET @@ -1027,21 +1016,15 @@ Unsubscribes from the download task failure event. This API uses an asynchronous | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Type of the event to unsubscribe from. The value is **'fail'** (download failure).| -| callback | function | No| Callback for the download task failure event.| - - Parameters of the callback function - -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| err | number | Yes| Error code of the download failure. For details about the error codes, see [Download Error Codes](#download-error-codes).| +| callback | function | No| Callback used to return the result.
**err**: error code of the download failure. | **Example** ```js - downloadTask.off('fail', function callBack(err) { - console.info('Download task failed. Cause:' + err); - } - ); + let failCallback = (err) => { + console.info(`Download delete fail notification. err: ${err.message}`); + }; + downloadTask.off('fail', failCallback); ``` ### delete9+ @@ -1706,32 +1689,33 @@ Defines the download task configuration. | -------- | -------- | -------- | -------- | | url | string | Yes| Resource URL.| | header | Object | No| HTTPS flag header to be included in the download request.
The **X-TLS-Version** parameter in **header** specifies the TLS version to be used. If this parameter is not set, the CURL_SSLVERSION_TLSv1_2 version is used. Available options are as follows:
CURL_SSLVERSION_TLSv1_0
CURL_SSLVERSION_TLSv1_1
CURL_SSLVERSION_TLSv1_2
CURL_SSLVERSION_TLSv1_3
The **X-Cipher-List** parameter in **header** specifies the cipher suite list to be used. If this parameter is not specified, the secure cipher suite list is used. Available options are as follows:
- The TLS 1.2 cipher suite list includes the following ciphers:
TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,
TLS_DHE_DSS_WITH_AES_128_GCM_SHA256,TLS_DSS_RSA_WITH_AES_256_GCM_SHA384,
TLS_PSK_WITH_AES_256_GCM_SHA384,TLS_DHE_PSK_WITH_AES_128_GCM_SHA256,
TLS_DHE_PSK_WITH_AES_256_GCM_SHA384,TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256,
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256,
TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384,
TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_128_CCM,
TLS_DHE_RSA_WITH_AES_256_CCM,TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
TLS_PSK_WITH_AES_256_CCM,TLS_DHE_PSK_WITH_AES_128_CCM,
TLS_DHE_PSK_WITH_AES_256_CCM,TLS_ECDHE_ECDSA_WITH_AES_128_CCM,
TLS_ECDHE_ECDSA_WITH_AES_256_CCM,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
- The TLS 1.3 cipher suite list includes the following ciphers:
TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256,TLS_AES_128_CCM_SHA256
- The TLS 1.3 cipher suite list adds the Chinese national cryptographic algorithm:
TLS_SM4_GCM_SM3,TLS_SM4_CCM_SM3 | -| enableMetered | boolean | No| Whether download is allowed on a metered connection.
- **true**: allowed
- **false**: not allowed| -| enableRoaming | boolean | No| Whether download is allowed on a roaming network.
- **true**: allowed
- **false**: not allowed| +| enableMetered | boolean | No| Whether download is allowed on a metered connection. The default value is **false**. In general cases, a mobile data connection is metered, while a Wi-Fi connection is not.
- **true**: allowed
- **false**: not allowed| +| enableRoaming | boolean | No| Whether download is allowed on a roaming network. The default value is **false**.
- **true**: allowed
- **false**: not allowed| | description | string | No| Description of the download session.| -| filePath7+ | string | No| Path where the downloaded file is stored.
- filePath:'/data/storage/el2/base/haps/entry/files/test.txt': Save the file to an absolute path.
- In the FA model, use [context](js-apis-inner-app-context.md#contextgetcachedir) to obtain the cache directory of the application, for example, **\${featureAbility.getContext().getFilesDir()}/test.txt\**, and store the file in this directory.
- In the stage model, use [AbilityContext](js-apis-inner-application-context.md) to obtain the file path, for example, **\${globalThis.abilityContext.tempDir}/test.txt\**, and store the file in this path.| -| networkType | number | No| Network type allowed for download.
- NETWORK_MOBILE: 0x00000001
- NETWORK_WIFI: 0x00010000| +| filePath7+ | string | No| Path where the downloaded file is stored.
- In the FA model, use [context](js-apis-inner-app-context.md#contextgetcachedir) to obtain the cache directory of the application, for example, **\${featureAbility.getContext().getFilesDir()}/test.txt\**, and store the file in this directory.
- In the stage model, use [AbilityContext](js-apis-inner-application-context.md) to obtain the file path, for example, **\${globalThis.abilityContext.tempDir}/test.txt\**, and store the file in this path.| +| networkType | number | No| Network type allowed for download. The default value is **NETWORK_MOBILE and NETWORK_WIFI**.
- NETWORK_MOBILE: 0x00000001
- NETWORK_WIFI: 0x00010000| | title | string | No| Download task name.| -| background9+ | boolean | No| Whether to enable the background task notification. When this parameter is enabled, the download status is displayed in the notification panel.| +| background9+ | boolean | No| Whether to enable background task notification so that the download status is displayed in the notification panel. The default value is false.| ## DownloadInfo7+ -Defines the download task information, which is the callback parameter of the [query(deprecated)](#querydeprecated-1) API. +Defines the download task information, which is the callback parameter of the [getTaskInfo9+](#gettaskinfo9) API. **Required permissions**: ohos.permission.INTERNET **System capability**: SystemCapability.MiscServices.Download -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| downloadId | number | Yes| ID of the downloaded file.| -| failedReason | number | No| Cause of the download failure. The value can be any constant in [Download Error Codes](#download-error-codes).| -| fileName | string | Yes| Name of the downloaded file.| -| filePath | string | Yes| URI of the saved file.| -| pausedReason | number | No| Cause of download pause. The value can be any constant in [Causes of Download Pause](#causes-of-download-pause).| -| status | number | Yes| Download task status code. The value can be any constant in [Download Task Status Codes](#download-task-status-codes).| -| targetURI | string | Yes| URI of the downloaded file.| -| downloadTitle | string | Yes| Download task name.| -| downloadTotalBytes | number | Yes| Total size of the files to download, in bytes.| -| description | string | Yes| Description of the file to download.| -| downloadedBytes | number | Yes| Size of the files downloaded, in bytes.| +| Name| Type|Mandatory| Description| +| -------- | ------ |---------------- | +| downloadId | number |Yes| ID of the download task.| +| failedReason | number|Yes| Cause of the download failure. The value can be any constant in [Download Error Codes](#download-error-codes).| +| fileName | string |Yes| Name of the downloaded file.| +| filePath | string |Yes| URI of the saved file.| +| pausedReason | number |Yes| Cause of download pause. The value can be any constant in [Causes of Download Pause](#causes-of-download-pause).| +| status | number |Yes| Download task status code. The value can be any constant in [Download Task Status Codes](#download-task-status-codes).| +| targetURI | string |Yes| URI of the downloaded file.| +| downloadTitle | string |Yes| Name of the download task.| +| downloadTotalBytes | number |Yes| Total size of the files to download, in bytes.| +| description | string |Yes| Description of the download task.| +| downloadedBytes | number |Yes| Size of the files downloaded, in bytes.| + diff --git a/en/application-dev/reference/apis/js-apis-system-sensor.md b/en/application-dev/reference/apis/js-apis-system-sensor.md index ccf4be2ce7e5a660ef1622e90bce2c204634906e..945be8c89d79e74cb6bc284e90089edad1709b4e 100644 --- a/en/application-dev/reference/apis/js-apis-system-sensor.md +++ b/en/application-dev/reference/apis/js-apis-system-sensor.md @@ -89,7 +89,7 @@ Subscribes to data changes of the compass sensor. If this API is called multiple ```js sensor.subscribeCompass({ success: function(ret) { - console.log('get data direction:' + ret.direction); + console.log('Get data direction:' + ret.direction); }, fail: function(data, code) { console.error('Subscription failed. Code: ' + code + '; Data: ' + data); @@ -133,7 +133,7 @@ Subscribes to data changes of the proximity sensor. If this API is called multip ```js sensor.subscribeProximity({ success: function(ret) { - console.log('get data distance:' + ret.distance); + console.log('Get data distance:' + ret.distance); }, fail: function(data, code) { console.error('Subscription failed. Code: ' + code + '; Data: ' + data); @@ -177,7 +177,7 @@ Subscribes to data changes of the ambient light sensor. If this API is called mu ```js sensor.subscribeLight({ success: function(ret) { - console.log('get data intensity:' + ret.intensity); + console.log('Get data intensity:' + ret.intensity); }, fail: function(data, code) { console.error('Subscription failed. Code: ' + code + '; Data: ' + data); @@ -223,7 +223,7 @@ Subscribes to data changes of the step counter sensor. If this API is called mul ```js sensor.subscribeStepCounter({ success: function(ret) { - console.log('get step value:' + ret.steps); + console.log('Get step value:' + ret.steps); }, fail: function(data, code) { console.log('Subscription failed. Code: ' + code + '; Data: ' + data); @@ -270,7 +270,7 @@ Subscribes to data changes of the barometer sensor. If this API is called multip ```js sensor.subscribeBarometer({ success: function(ret) { - console.log('get data value:' + ret.pressure); + console.log('Get data value:' + ret.pressure); }, fail: function(data, code) { console.log('Subscription failed. Code: ' + code + '; Data: ' + data); @@ -318,7 +318,7 @@ Subscribes to data changes of the heart rate sensor. If this API is called multi ```js sensor.subscribeHeartRate({ success: function(ret) { - console.log('get heartrate value:' + ret.heartRate); + console.log('Get heartrate value:' + ret.heartRate); }, fail: function(data, code) { console.log('Subscription failed. Code: ' + code + '; Data: ' + data); @@ -365,7 +365,7 @@ Subscribes to changes of the wearing state of a wearable device. If this API is ```js sensor.subscribeOnBodyState({ success: function(ret) { - console.log('get on-body state value:' + ret.value); + console.log('Get on-body state value:' + ret.value); }, fail: function(data, code) { console.log('Subscription failed. Code: ' + code + '; Data: ' + data); @@ -409,7 +409,7 @@ Obtains the wearing state of a wearable device. ```js sensor.getOnBodyState({ success: function(ret) { - console.log('on body state: ' + ret.value); + console.log('On body state: ' + ret.value); }, fail: function(data, code) { console.log('Subscription failed. Code: ' + code + '; Data: ' + data); @@ -710,7 +710,7 @@ Defines the wearing state. | Name | Type | Mandatory| Description | | -------- | ------------------------------------------- | ---- | ------------------------ | -| success | [OnBodyStateResponse](#onbodystateresponse) | No | Callback upon a successful API call.| +| success | [OnBodyStateResponse](#onbodystateresponse) | Yes | Callback upon a successful API call.| | fail | Function | No | Callback upon an API call failure.| | complete | Function | No | Called when the API call is complete.| diff --git a/en/application-dev/reference/apis/js-apis-userFileManager.md b/en/application-dev/reference/apis/js-apis-userFileManager.md index 04df43b3450c73bf072833d845b04dbfd1c9d0ec..a676fb1f3b86439ee314feceace04810bb5052da 100644 --- a/en/application-dev/reference/apis/js-apis-userFileManager.md +++ b/en/application-dev/reference/apis/js-apis-userFileManager.md @@ -4,8 +4,8 @@ The **userFileManager** module provides user data management capabilities, 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 provided by this module are system APIs. +> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> - The APIs provided by this module are system APIs. ## Modules to Import @@ -49,11 +49,8 @@ let mgr = userFileManager.getUserFileMgr(context); getPhotoAssets(options: FetchOptions, callback: AsyncCallback<FetchResult<FileAsset>>): void; - Obtains image and video assets. This API uses an asynchronous callback to return the result. - - **System capability**: SystemCapability.FileManagement.UserFileManager.Core **Required permissions**: ohos.permission.READ_IMAGEVIDEO @@ -92,7 +89,6 @@ async function example() { } ``` - ### getPhotoAssets getPhotoAssets(options: FetchOptions): Promise<FetchResult<FileAsset>>; @@ -141,6 +137,7 @@ async function example() { } } ``` + ### createPhotoAsset createPhotoAsset(displayName: string, albumUri: string, callback: AsyncCallback<FileAsset>): void; @@ -261,7 +258,6 @@ async function example() { getPhotoAlbums(options: AlbumFetchOptions, callback: AsyncCallback<FetchResult<Album>>): void; - Obtains image and video albums. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.FileManagement.UserFileManager.Core @@ -352,7 +348,6 @@ async function example() { getPrivateAlbum(type: PrivateAlbumType, callback: AsyncCallback<FetchResult<PrivateAlbum>>): void; - Obtains the system album. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.FileManagement.UserFileManager.Core @@ -424,7 +419,6 @@ async function example() { getAudioAssets(options: FetchOptions, callback: AsyncCallback<FetchResult<FileAsset>>): void; - Obtains audio assets. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.FileManagement.UserFileManager.Core @@ -469,7 +463,6 @@ async function example() { getAudioAssets(options: FetchOptions): Promise<FetchResult<FileAsset>>; - Obtains audio assets. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.UserFileManager.Core @@ -515,6 +508,7 @@ async function example() { } } ``` + ### delete delete(uri: string, callback: AsyncCallback<void>): void; @@ -564,6 +558,7 @@ async function example() { }); } ``` + ### delete delete(uri: string): Promise<void>; @@ -675,8 +670,8 @@ Unsubscribes from changes of the file management library. This API uses a callba | Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | ------------------------------------------------------------ | -| type | [ChangeEvent](#changeevent) | Yes | Type of event to unsubscribe from.
**deviceChange** indicates the device change.
**albumChange** indicates the album change.
**imageChange** indicates the image change.
**audioChange** indicates the audio file change.
**videoChange** indicates the video file change.
**remoteFileChange** indicates the file change on the registered device. | -| callback | Callback<void> | No | Callback for the change. | +| type | [ChangeEvent](#changeevent) | Yes | Type of event to subscribe to.
**deviceChange** indicates the device change.
**albumChange** indicates the album change.
**imageChange** indicates the image change.
**audioChange** indicates the audio file change.
**videoChange** indicates the video file change.
**remoteFileChange** indicates the file change on the registered device.| +| callback | Callback<void> | No | Callback that returns no value. | **Example** @@ -1093,7 +1088,6 @@ Opens this file asset. This API uses an asynchronous callback to return the resu **Required permissions**: ohos.permission.READ_IMAGEVIDEO, ohos.permission.READ_AUDIO, ohos.permission.WRITE_IMAGEVIDEO, or ohos.permission.WRITE_AUDIO - **System capability**: SystemCapability.FileManagement.UserFileManager.Core **Parameters** @@ -1923,6 +1917,7 @@ async function example() { }); } ``` + ### getPhotoAssets getPhotoAssets(options: FetchOptions): Promise<FetchResult<FileAsset>>; @@ -2106,6 +2101,7 @@ async function example() { } ``` + ### getPhotoAssets getPhotoAssets(options: FetchOptions): Promise<FetchResult<FileAsset>>; @@ -2147,6 +2143,7 @@ async function example() { console.info('fetchResult.count = ', count); } ``` + ### delete delete(uri: string, callback: AsyncCallback<void>): void; @@ -2190,6 +2187,7 @@ async function example() { }); } ``` + ### delete delete(uri: string): Promise<void>; @@ -2280,6 +2278,7 @@ async function example() { }); } ``` + ### recover recover(uri: string): Promise<void>; @@ -2366,7 +2365,6 @@ Defines information about a registered device. | networkId | string | Yes | No | Network ID of the registered device.| | isOnline | boolean | Yes | No | Whether the registered device is online. | - ## FileType Enumerates media file types. @@ -2390,8 +2388,6 @@ Enumerates the system album types. | TYPE_FAVORITE | 0 | Favorites.| | TYPE_TRASH | 1 | Recycle bin.| - - ## AudioKey Defines the key information about an audio file. @@ -2445,7 +2441,6 @@ Defines the key album information. | DATE_ADDED | date_added | Date when the file was added. The value is the number of seconds elapsed since the Epoch time. | | DATE_MODIFIED | date_modified | Date when the file content (not the file name) was last modified. The value is the number of seconds elapsed since the Epoch time.| - ## FetchOptions Defines the options for fetching media files. diff --git a/en/application-dev/reference/arkui-js/figures/tab.gif b/en/application-dev/reference/arkui-js/figures/tab.gif index fea6fcac566df71d32643b81579a59bbe4e1b580..525ea0d263d29509fdcefb7165bc3029d31aacf6 100644 Binary files a/en/application-dev/reference/arkui-js/figures/tab.gif and b/en/application-dev/reference/arkui-js/figures/tab.gif differ diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md b/en/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md index 4166399915b6f694fc58779dbf4579b950c835b9..ae02854f74f44e25e4df36d940f3f80e8b9fb211 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md @@ -39,7 +39,7 @@ In addition to the [universal events](ts-universal-events-click.md), the followi | Name | Description | | -------------------------------------------- | ------------------------------------------------------------ | -| onChange(callback: (value: boolean) => void) | Triggered when the selected status of the check box changes due to a manual operation.
- The value **true** means that the check box is selected.
- The value **false** means that the check box is not selected.
Since API version 9, this API is supported in ArkTS widgets.| +| onChange(callback: (value: boolean) => void) | Triggered when the selected status of the check box changes.
- The value **true** means that the check box is selected.
- The value **false** means that the check box is not selected.
Since API version 9, this API is supported in ArkTS widgets. | ## Example diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md b/en/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md index cd81ae7f9f31c0cfcd6e7a5cc904223590a28fe2..f9a19ff39cd6a3df2276850b922690e9bf626b4c 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md @@ -39,7 +39,7 @@ In addition to the [universal events](ts-universal-events-click.md), the followi | Name| Description| | -------- | -------- | -| onChange (callback: (event: [CheckboxGroupResult](#checkboxgroupresult)) => void ) |Triggered when the selected status of the check box group or any check box wherein changes due to a manual operation.
Since API version 9, this API is supported in ArkTS widgets.| +| onChange (callback: (event: [CheckboxGroupResult](#checkboxgroupresult)) => void ) |Triggered when the selected status of the check box group or any check box wherein changes.
Since API version 9, this API is supported in ArkTS widgets.| ## CheckboxGroupResult diff --git a/en/application-dev/reference/arkui-ts/ts-container-scroll.md b/en/application-dev/reference/arkui-ts/ts-container-scroll.md index d54ecbf1d4a50be563e2c712648ae0a56dc19daa..e56281bb9e1915186abcc64e4a9911a99aea18d7 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-scroll.md +++ b/en/application-dev/reference/arkui-ts/ts-container-scroll.md @@ -139,7 +139,7 @@ Scrolls to the item with the specified index. > **NOTE** > -> Only the **\** and **\** components are supported. +> Only the **\**, **\**, and **\** components are supported. **Parameters** diff --git a/en/application-dev/reference/arkui-ts/ts-gesture-settings.md b/en/application-dev/reference/arkui-ts/ts-gesture-settings.md index 8268db6dca2ea26db846b343060cc001294905f0..6b37f324306957502522eddda9c14be98bee3797 100644 --- a/en/application-dev/reference/arkui-ts/ts-gesture-settings.md +++ b/en/application-dev/reference/arkui-ts/ts-gesture-settings.md @@ -11,29 +11,29 @@ Bind different types of gesture events to components and set response methods fo Use the following attributes to bind gesture recognition to a component. When a gesture is recognized, the event callback is invoked to notify the component. -| Name | Type | Default Value | Description | -| --------------- | ---------------------------------------- | --------------------------------------- | ---------------------------------------- | -| gesture | gesture: [GestureType](#gesturetype),
mask?: [GestureMask](#gesturemask) | gesture: -,
mask: GestureMask.Normal | Gesture to bind.
- **gesture**: type of the gesture to bind.
- **mask**: event response setting. | -| priorityGesture | gesture: [GestureType](#gesturetype),
mask?: [GestureMask](#gesturemask) | gesture: -,
mask: GestureMask.Normal | Gesture to preferentially recognize.
- **gesture**: type of the gesture to bind.
- **mask**: event response setting.
By default, a component recognizes gestures bound through **gesture**. When **priorityGesture** is configured for its parent component, the component preferentially recognizes gestures bound through **priorityGesture**. | -| parallelGesture | gesture: [GestureType](#gesturetype),
mask?: [GestureMask](#gesturemask) | gesture: -,
mask: GestureMask.Normal | Gesture that can be triggered together with the child component gesture.
- **gesture**: type of the gesture to bind.
- **mask**: event response setting.
The gesture event is not a bubbling event. When **parallelGesture** is set for the parent component, gesture events that are the same for the parent and child components can be triggered, thereby implementing a bubbling effect. If both the single-tap gesture event and the double-tap gesture event are bound to the parent and child components, only the single-tap gesture event is responded. | +| Name| Type| Default Value| Description| +| -------- | -------- | -------- | -------- | +| gesture | gesture: [GestureType](#gesturetype),
mask?: [GestureMask](#gesturemask) | gesture: -,
mask: GestureMask.Normal | Gesture to bind.
- **gesture**: type of the gesture to bind.
- **mask**: mask for gesture events.| +| priorityGesture | gesture: [GestureType](#gesturetype),
mask?: [GestureMask](#gesturemask) | gesture: -,
mask: GestureMask.Normal | Gesture to preferentially recognize.
- **gesture**: type of the gesture to bind.
- **mask**: mask for gesture events.
1. By default, the child component preferentially recognizes the gesture specified by **gesture**, and the parent component preferentially recognizes the gesture specified by **priorityGesture** (if set).
2. With regard to long press gestures, the component with the shortest minimum hold-down time responds first, ignoring the **priorityGesture** settings.| +| parallelGesture | gesture: [GestureType](#gesturetype),
mask?: [GestureMask](#gesturemask) | gesture: -,
mask: GestureMask.Normal | Gesture that can be triggered together with the child component gesture.
- **gesture**: type of the gesture to bind.
- **mask**: mask for gesture events.
The gesture event is not a bubbling event. When **parallelGesture** is set for the parent component, gesture events that are the same for the parent and child components can be triggered, thereby implementing a bubbling effect. If both the single-tap gesture event and the double-tap gesture event are bound to the parent and child components, only the single-tap gesture event is responded.| ## GestureType -| Name | Description | -| ---------------------------------------- | ---------------------------------------- | -| [TapGesture](ts-basic-gestures-tapgesture.md) | Tap gesture, which can be a single-tap or multi-tap gesture. | -| [LongPressGesture](ts-basic-gestures-longpressgesture.md) | Long press gesture. | -| [PanGesture](ts-basic-gestures-pangesture.md) | Pan gesture, which requires a minimum 5 vp movement distance of a finger on the screen. | -| [PinchGesture](ts-basic-gestures-pinchgesture.md) | Pinch gesture. | -| [RotationGesture](ts-basic-gestures-rotationgesture.md) | Rotation gesture. | -| [SwipeGesture](ts-basic-gestures-swipegesture.md) | Swipe gesture, which can be recognized when the swipe speed is 100 vp/s or higher. | -| [GestureGroup](ts-combined-gestures.md) | A group of gestures. Continuous recognition, parallel recognition, and exclusive recognition are supported. | +| Name| Description| +| -------- | -------- | +| [TapGesture](ts-basic-gestures-tapgesture.md) | Tap gesture, which can be a single-tap or multi-tap gesture.| +| [LongPressGesture](ts-basic-gestures-longpressgesture.md) | Long press gesture.| +| [PanGesture](ts-basic-gestures-pangesture.md) | Pan gesture, which requires a minimum 5 vp movement distance of a finger on the screen.| +| [PinchGesture](ts-basic-gestures-pinchgesture.md) | Pinch gesture.| +| [RotationGesture](ts-basic-gestures-rotationgesture.md) | Rotation gesture.| +| [SwipeGesture](ts-basic-gestures-swipegesture.md) | Swipe gesture, which can be recognized when the swipe speed is 100 vp/s or higher.| +| [GestureGroup](ts-combined-gestures.md) | A group of gestures. Continuous recognition, parallel recognition, and exclusive recognition are supported.| ## GestureMask -| Name | Description | -| -------------- | ---------------------------------------- | -| Normal | The gestures of child components are not ignored and are recognized based on the default gesture recognition sequence. | +| Name| Description| +| -------- | -------- | +| Normal | The gestures of child components are not ignored and are recognized based on the default gesture recognition sequence.| | IgnoreInternal | The gestures of child components are ignored, including the built-in gestures. For example, if the child component is **\**, its built-in swipe gesture is also ignored.| ## Gesture Response Event @@ -42,52 +42,52 @@ The component binds gesture objects of different **GestureType**s through gestur **TapGesture** -| Name | Description | -| ---------------------------------------- | ---------------------------------------- | -| onAction((event?:GestureEvent) => void) | Callback invoked when a tap gesture is recognized. | +| Name| Description| +| -------- | -------- | +| onAction((event?:GestureEvent) => void) | Callback invoked when a tap gesture is recognized.| ## GestureEvent -| Name | Type | Description | -| ----------------------- | ---------------------------------------- | ---------------------------------------- | -| repeat | boolean | Whether the event is triggered repeatedly. This attribute is used for the **LongPressGesture** event. | -| offsetX | number | Offset of the gesture event on the x-axis, in vp. This attribute is used for the **PanGesture** event. A positive value means to pan from left to right, and a negative value means the opposite. | -| offsetY | number | Offset of the gesture event on the y-axis, in vp. This attribute is used for the **PanGesture** event. A positive value means to pan from top to bottom, and a negative value means the opposite. | -| angle | number | Rotation angle for the **RotationGesture** event;
angle of the swipe gesture for the **SwipeGesture** event, that is, the change in the included angle between the line segment created by the two fingers and the horizontal direction.
**NOTE**
Angle calculation method: After a swipe gesture is recognized, a line connecting the two fingers is identified as the initial line. As the fingers swipe, the line between the fingers rotates. Based on the coordinates of the initial line's and current line's end points, an arc tangent function is used to calculate the respective included angle of the points relative to the horizontal direction by using the following formula: Rotation angle = arctan2(cy2-cy1,cx2-cx1) – arctan2(y2-y1,x2-x1) The initial line is used as the coordinate system. The clockwise rotation is 0 to 180 degrees, and the counter-clockwise rotation is –180 to 0 degrees. | -| scale | number | Scale ratio. This attribute is used for the **PinchGesture** event. | -| pinchCenterX | number | X-coordinate of the center of the pinch gesture, in px relative to the upper left corner of the current component. This attribute is used for the **PinchGesture** event. | -| pinchCenterY | number | Y-coordinate of the center of the pinch gesture, in px relative to the upper left corner of the current component. This attribute is used for the **PinchGesture** event. | -| speed8+ | number | Swipe gesture speed, that is, the average swipe speed of all fingers. The unit is vp/s. This attribute is used for the **SwipeGesture** event. | -| fingerList8+ | [FingerInfo](#fingerinfo)[] | Information about all fingers that trigger the event, which is used for the **LongPressGesture** and **TapGesture** events. | -| timestamp8+ | number | Timestamp of the event. | -| target8+ | [EventTarget](ts-universal-events-click.md#eventtarget8) | Display area of the element that triggers the gesture event. | -| source8+ | [SourceType](#sourcetype) | Event input device. | -| pressure9+ | number | Press pressure. | -| tiltX9+ | number | Angle between the projection of the stylus on the device plane and the x-axis. | -| tiltY9+ | number | Angle between the projection of the stylus on the device plane and the y-axis. | -| sourceTool9+ | [SourceTool](#sourcetool) | Event input source. | +| Name| Type| Description| +| -------- | -------- | -------- | +| repeat | boolean | Whether the event is triggered repeatedly. This attribute is used for the **LongPressGesture** event.| +| offsetX | number | Offset of the gesture event on the x-axis, in vp. This attribute is used for the **PanGesture** event. A positive value means to pan from left to right, and a negative value means the opposite.| +| offsetY | number | Offset of the gesture event on the y-axis, in vp. This attribute is used for the **PanGesture** event. A positive value means to pan from top to bottom, and a negative value means the opposite.| +| angle | number | Rotation angle for the **RotationGesture** event;
angle of the swipe gesture for the **SwipeGesture** event, that is, the change in the included angle between the line segment created by the two fingers and the horizontal direction.
**NOTE**
Angle calculation method: After a swipe gesture is recognized, a line connecting the two fingers is identified as the initial line. As the fingers swipe, the line between the fingers rotates. Based on the coordinates of the initial line's and current line's end points, an arc tangent function is used to calculate the respective included angle of the points relative to the horizontal direction by using the following formula: Rotation angle = arctan2(cy2-cy1,cx2-cx1) – arctan2(y2-y1,x2-x1) The initial line is used as the coordinate system. The clockwise rotation is 0 to 180 degrees, and the counter-clockwise rotation is –180 to 0 degrees.| +| scale | number | Scale ratio. This attribute is used for the **PinchGesture** event.| +| pinchCenterX | number | X-coordinate of the center of the pinch gesture, in vp, relative to the upper left corner of the current component. This attribute is used for the **PinchGesture** event.| +| pinchCenterY | number | Y-coordinate of the center of the pinch gesture, in vp, relative to the upper left corner of the current component. This attribute is used for the **PinchGesture** event.| +| speed8+ | number | Swipe gesture speed, that is, the average swipe speed of all fingers. The unit is vp/s. This attribute is used for the **SwipeGesture** event.| +| fingerList8+ | [FingerInfo](#fingerinfo)[] | Information about all fingers that trigger the event. This attribute is used for the **LongPressGesture** and **TapGesture** events.| +| timestamp8+ | number | Timestamp of the event.| +| target8+ | [EventTarget](ts-universal-events-click.md#eventtarget8) | Display area of the element that triggers the gesture event.| +| source8+ | [SourceType](#sourcetype) | Event input device.| +| pressure9+ | number | Press pressure.| +| tiltX9+ | number | Angle between the projection of the stylus on the device plane and the x-axis.| +| tiltY9+ | number | Angle between the projection of the stylus on the device plane and the y-axis.| +| sourceTool9+ | [SourceTool](#sourcetool) | Event input source.| ## SourceType -| Name | Description | -| ----------- | -------------------- | -| Unknown | Unknown device type. | -| Mouse | Mouse. | -| TouchScreen | Touchscreen. | +| Name| Description| +| -------- | -------- | +| Unknown | Unknown device type.| +| Mouse | Mouse.| +| TouchScreen | Touchscreen.| ## FingerInfo -| Name | Type | Description | -| ------- | ------ | ---------------------------------------- | -| id | number | Index of a finger. | -| globalX | number | X-coordinate relative to the upper left corner of the application window. | -| globalY | number | Y-coordinate relative to the upper left corner of the application window. | -| localX | number | X-coordinate relative to the upper left corner of the current component. | -| localY | number | Y-coordinate relative to the upper left corner of the current component. | +| Name| Type| Description| +| -------- | -------- | -------- | +| id | number | Index of a finger.| +| globalX | number | X-coordinate relative to the upper left corner of the application window.| +| globalY | number | Y-coordinate relative to the upper left corner of the application window.| +| localX | number | X-coordinate relative to the upper left corner of the current component.| +| localY | number | Y-coordinate relative to the upper left corner of the current component.| ## SourceTool -| Name | Description | -| ------- | --------------------- | -| Unknown | Unknown input source. | -| Finger | Finger input. | -| Pen | Stylus input. | +| Name| Description| +| -------- | -------- | +| Unknown | Unknown input source.| +| Finger | Finger input.| +| Pen | Stylus input.| ## Example diff --git a/en/application-dev/reference/errorcodes/errorcode-filemanagement.md b/en/application-dev/reference/errorcodes/errorcode-filemanagement.md index 4f45c7d0057984677b67f5a494667462e4a3fedb..219f56460536de918a7bf5b631000e562ce2e507 100644 --- a/en/application-dev/reference/errorcodes/errorcode-filemanagement.md +++ b/en/application-dev/reference/errorcodes/errorcode-filemanagement.md @@ -4,9 +4,14 @@ > > This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md). -The error codes of the file management subsystem consist of the following:
- Basic file I/O error codes
- User data management error codes
- User file access error codes
- Spatial statistics error codes +The error codes of the file management subsystem include the following: -## Basic File I/O Error Codes +- [Basic File IO Error Codes](#basic-file-io-error-codes) +- [User Data Management Error Codes](#user-data-management-error-code) +- [User File Access Error Codes](#user-file-access-error-codes) +- [Space Statistics Error Codes](#space-statistics-error-codes) + +## Basic File IO Error Codes ### 13900001 Operation Not Permitted @@ -49,6 +54,7 @@ The process does not exist. **Solution** 1. Check whether the process is killed unexpectedly. + 2. Check whether the service related to the process has started. ### 13900004 System Call Interrupted @@ -64,6 +70,7 @@ The system call is interrupted by another thread. **Solution** 1. Check the multi-thread code logic. + 2. Invoke the system call again. ### 13900005 I/O Error @@ -161,7 +168,9 @@ Out of memory A memory overflow occurs. **Solution** + 1. Check the memory overhead. + 2. Control the memory overhead. ### 13900012 Permission Denied @@ -172,13 +181,14 @@ Permission denied **Possible Causes** - - 1. You do not have the permission to operate the file. + 2. The file sandbox path is incorrect. **Solution** -1. Check that you have the permission to operate the file. + +1. Check that the required permission is available. + 2. Check that the file sandbox path is correct. ### 13900013 Incorrect Address @@ -375,7 +385,7 @@ Seek is used in pipe or FIFO. **Solution** -Check the use of seek. +Check the use of **seek()**. ### 13900027 Read-Only File System @@ -460,6 +470,7 @@ The specified directory is not empty. **Solution** 1. Check the directory. + 2. Ensure that the directory is empty. ### 13900033 Too Many Symbol Links @@ -516,7 +527,7 @@ The device pointed to by the file descriptor is not a character stream device. **Solution** -Check whether the file descriptor points to a stream device. +Check whether the file descriptor points to a stream. ### 13900037 No Data Available @@ -599,7 +610,9 @@ Unknown error The error is unidentified. **Solution** + 1. Call the API again. + 2. Restart the service. ## User Data Management Error Codes @@ -636,7 +649,7 @@ Use the obtained URI. **Error Message** -Invalid file extension +Invalid file name extension **Possible Causes** @@ -660,7 +673,7 @@ The file is moved to the Recycle Bin. Check whether the file is in the Recycle Bin. -## Spatial Statistics Error Codes +## Space Statistics Error Codes ### 13600001 IPC Failed @@ -680,7 +693,7 @@ Check whether the service is started. **Error Message** -Not supported file system +Not supported filesystem **Possible Causes** @@ -767,11 +780,15 @@ Check whether the specified directory or node exists. No such object **Possible Causes** + 1. The specified volume ID is incorrect. + 2. The specified bundle name is incorrect. **Solution** + 1. Check whether the specified volume exists. + 2. Check whether the specified bundle name exists. ### 13600009 Invalid User ID @@ -799,6 +816,7 @@ IPC error **Possible Causes** 1. The server service does not exist. + 2. The extension mechanism is abnormal. **Solution** @@ -854,7 +872,9 @@ Check the data returned by the server. Fail to register notification **Possible Causes** + 1. The server service does not exist. + 2. The extension mechanism is abnormal. **Solution** @@ -868,7 +888,9 @@ Check that the server service exists. Fail to remove notification **Possible Causes** + 1. The server service does not exist. + 2. The extension mechanism is abnormal. **Solution** @@ -896,47 +918,11 @@ Check whether the specified Notify agent is registered. Fail to notify agent **Possible Causes** + 1. The service does not exist. + 2. The extension mechanism is abnormal. **Solution** Check whether the client is normal. - -## Error Code Adaptation -The APIs provided by the file management subsystem support exception handling. -Sample code for exception handling in a synchronous API: -```js -import fs from '@ohos.file.fs' - -try { - let file = fs.openSync(path, fs.OpenMode.READ_ONLY); -} catch (err) { - console.error("openSync errCode:" + err.code + ", errMessage:" + err.message); -} -``` -Sample code for exception handling in an asynchronous API (promise): -```js -import fs from '@ohos.file.fs' - -try { - let file = await fs.open(path, fs.OpenMode.READ_ONLY); -} catch (err) { - console.error("open promise errCode:" + err.code + ", errMessage:" + err.message); -} -``` - -Sample code for exception handling in an asynchronous API (callback): -```js -import fs from '@ohos.file.fs' - -try { - fs.open(path, fs.OpenMode.READ_ONLY, function(e, file){ // Asynchronous thread (such as the system call) errors are obtained via a callback. - if (e) { - console.error("open in async errCode:" + e.code + ", errMessage:" + e.message); - } - }); -} catch (err) {// Main thread errors (such as invalid parameters) are obtained by try catch. - console.error("open callback errCode:" + err.code + ", errMessage:" + err.message); -} -``` diff --git a/en/application-dev/ui/arkts-graphics-display.md b/en/application-dev/ui/arkts-graphics-display.md index 28279e73f5642f6c32994e4af94edbd87eb755b5..2817d4386729c57725c3a488931553b6f4f17f45 100644 --- a/en/application-dev/ui/arkts-graphics-display.md +++ b/en/application-dev/ui/arkts-graphics-display.md @@ -117,7 +117,7 @@ Data sources of the archived type can be classified into local resources, online } } ``` - 2. Check the format of the URL obtained from the media library is as follows: + 2. Check the format of the URL obtained from the media library: ​ ```ts Image('datashare:///media/5') diff --git a/en/application-dev/ui/arkts-layout-update-animation.md b/en/application-dev/ui/arkts-layout-update-animation.md index 839a55543a88deaa497a42da475abec4820e02b1..d5110e2eac29cd3dfe6b235479b75969cf541d54 100644 --- a/en/application-dev/ui/arkts-layout-update-animation.md +++ b/en/application-dev/ui/arkts-layout-update-animation.md @@ -1,16 +1,16 @@ # Layout Update Animation -[Attribute animation](../reference/arkui-ts/ts-animatorproperty.md) (animation) and [explicit animation](../reference/arkui-ts/ts-explicit-animation.md) (animateTo) are the most basic and common animation features provided by ArkUI. When the layout attributes (such as the [size](../reference/arkui-ts/ts-universal-attributes-size.md) and [position](../reference/arkui-ts/ts-universal-attributes-location.md)) attributes change, you can use the attribute animation or explicit animation to transit to the new layout parameter status based on the animation parameters. +[Explicit animation](../reference/arkui-ts/ts-explicit-animation.md) (**animateTo**) and [attribute animation](../reference/arkui-ts/ts-animatorproperty.md) (**animation**) are the most basic and common animation features provided by ArkUI. When the layout attributes (such as the [size](../reference/arkui-ts/ts-universal-attributes-size.md) and [position](../reference/arkui-ts/ts-universal-attributes-location.md)) attributes change, you can use the attribute animation or explicit animation to transit to the new layout parameter status based on the animation parameters. -| Animation Type| Description | Application Scenario | -| ---- | ---------------------------------------- | -------- | -| Attribute animation| The animation setting is simple. The animation is automatically triggered when the attribute changes. | Simple animation scenario| -| Explicit animation| Changes in a closure trigger animations, including component addition and deletion caused by data changes and component attribute changes. Complex animations can be performed.| Complex animation scenarios| +| Animation Type| Description | +| ---- | ---------------------------------------- | +| Explicit animation| Triggered by changes in a closure, including component addition and deletion caused by data changes and component attribute changes.| Complex animation scenarios| +| Attribute animation| Triggered when the attribute changes. The animation setting is simple. | -## Using Explicit Animation to Generate Layout Update Animation +## Using Explicit Animation to Create Layout Update Animation The API for explicit animation is as follows: @@ -21,7 +21,7 @@ animateTo(value: AnimateParam, event: () => void): void The first parameter specifies the animation parameter, and the second parameter is the closure function of the animation. -The following is an example of using explicit animation to produce a layout update animation. In the example, after the alignItems attribute of the Column component is changed, the layout of its child components changes. As long as the attribute is modified in the closure function of **animateTo**, all changes caused by the attribute are performed to the end value according to the animation parameter of animateTo. +The following is an example of using explicit animation to create a layout update animation. In the example, when the **\** component's **alignItems** attribute is updated, the layout of its child components changes. As long as the attribute is updated in the closure function of **animateTo**, animation is performed as configured through **animateTo** for all changes caused by the attribute toward the end value. ```ts @@ -50,7 +50,7 @@ struct LayoutChange { // The animation duration is 1000 ms, and the curve is EaseInOut. animateTo({ duration: 1000, curve: Curve.EaseInOut }, () => { this.alignIndex = (this.alignIndex + 1) % this.allAlign.length; - // Modify the this.itemAlign parameter in the closure function to change the layout of children in the Column container. Use an animation to transition to the new position. + // Modify the this.itemAlign parameter in the closure function to change the layout of child elements in the container. The animation for transition to the new position is applied. this.itemAlign = this.allAlign[this.alignIndex]; }); }) @@ -65,7 +65,7 @@ struct LayoutChange { ![layoutChange1](figures/layoutChange1.gif) -In addition to directly changing the layout mode, you can also directly change the width, height, and position of a component. +In addition to directly changing the layout, you can also change the width, height, and position of a component. @@ -75,7 +75,7 @@ In addition to directly changing the layout mode, you can also directly change t struct LayoutChange2 { @State myWidth: number = 100; @State myHeight: number = 50; - // Flag. true and false correspond to a group of myWidth and myHeight values respectively. + // Flag. true and false correspond to a group of myWidth and myHeight values, respectively. @State flag: boolean = false; build() { @@ -90,7 +90,7 @@ struct LayoutChange2 { .margin(20) .onClick(() => { animateTo({ duration: 1000, curve: Curve.Ease }, () => { - // In the animation closure, the state variable that controls the width and height of the first button is changed based on the flag bit so that the width and height of the first button are animated. + // In the animation closure, the state variables that control the width and height of the first button are changed based on the flag settings so that the width and height of the first button are animated. if (this.flag) { this.myWidth = 100; this.myHeight = 50; @@ -109,16 +109,16 @@ struct LayoutChange2 { ``` -In the click event of the second button, the **animateTo** API is used to modify the **this.myWidth** and **this.myHeight** state variables in the closure. The two state variables are the width and height attribute values of the first button. Therefore, the width and height animation is performed for the first button. The display effect is shown below. +In the click event of the second button, the **animateTo** API is used to modify the **this.myWidth** and **this.myHeight** state variables in the closure. As these two state variables set the width and height of the first button, the width and height animation is performed for the first button. The display effect is shown below. ![layoutChange2_animateTo](figures/layoutChange2_animateTo.gif) -At the same time, the second button also produces a position animation. After the width and height of the first button are changed, the layout of other components in the column is also changed. The layout of the second button is also changed because the width and height of the first button are changed in the closure. +At the same time, the second button also produces a position animation. After the width and height of the first button are changed, the layout of other components in the column is also changed, and the second button is among those other components. -If you do not want the second button to have an animation effect, you can use either of the following methods: 1. Add a container outside the first button so that the sizes before and after the animation are within the range of the container. In this way, the position of the second button is not affected by the position of the first button. The modified key code is as follows: +If you do not want the second button to have an animation effect, you can use either of the following methods: 1. Add a container outside the first button so that the sizes before and after the animation are within the range of the container. In this way, the position of the second button is not affected by the position of the first button. The key code is as follows: @@ -139,7 +139,7 @@ Column({ space: 10 }) { .fontSize(12) .onClick(() => { animateTo({ duration: 1000, curve: Curve.Ease }, () => { - // In the animation closure, the state variable that controls the width and height of the first button is changed based on the flag bit so that the width and height of the first button are animated. + // In the animation closure, the state variables that control the width and height of the first button are changed based on the flag settings so that the width and height of the first button are animated. if (this.flag) { this.myWidth = 100; this.myHeight = 50; @@ -159,7 +159,7 @@ Column({ space: 10 }) { ![layoutChange2_animateTo_change](figures/layoutChange2_animateTo_change.gif) -2. Add layout constraints to the second button, for example, position constraints, so that the position of the second button is not affected by the width and height of the first button. Sample code: +2. Add layout constraints to the second button. For example, add position constraints so that the position of the second button is not affected by the width and height of the first button. The sample code is as follows: @@ -173,11 +173,11 @@ Column({ space: 10 }) { Button("area: click me") .fontSize(12) - // Set the position attribute to a fixed value so that the layout position is not affected by the width and height of the first button. + // Set the position attribute to a fixed value so that the position of the second button is not affected by the width and height of the first button. .position({ x: "30%", y: 200 }) .onClick(() => { animateTo({ duration: 1000, curve: Curve.Ease }, () => { - // In the animation closure, the state variable that controls the width and height of the first button is changed based on the flag bit so that the width and height of the first button are animated. + // In the animation closure, the state variables that control the width and height of the first button are changed based on the flag settings so that the width and height of the first button are animated. if (this.flag) { this.myWidth = 100; this.myHeight = 50; @@ -196,7 +196,7 @@ Column({ space: 10 }) { ## Using Attribute Animation to Generate Layout Update Animation -The explicit animation places the modification of the attribute of the animation to be executed in the closure function to trigger the animation. The attribute animation does not need to use the closure. You only need to add the animation attribute to the end of the attribute of the component to be executed. +Unlike explicit animation, which requires the attribute changes for triggering animation to be placed in the closure function, attribute animation does not need to use the closure. You only need to append the **animation** attribute to the target component attribute. The API of the attribute animation is as follows: @@ -205,7 +205,7 @@ The API of the attribute animation is as follows: animation(value: AnimateParam) ``` -The input parameter is an animation parameter. If you want the component to generate an animation with the change of an attribute value, you need to add this attribute before the animation attribute. Some attribute changes do not want to generate attribute animations through animations. Therefore, attribute animations can be placed after animations. The example of explicit animation above is easily changed to be implemented with property animation. Sample code: +This API accepts an animation parameter as its argument. If you want the component to generate an animation with the value change of an attribute, add this attribute before the **animation** attribute. Otherwise, you can place the attribute after the **animation** attribute. The previous example of explicit animation can be easily implemented with attribute animation. The sample code is as follows: @@ -224,11 +224,11 @@ struct LayoutChange2 { .type(ButtonType.Normal) .width(this.myWidth) .height(this.myHeight) - // Animation takes effect only for the type, width, and height attributes. The duration is 1000 ms, and the curve is Ease. + // The animation takes effect only for the type, width, and height attributes. The duration is 1000 ms, and the curve is Ease. .animation({ duration: 1000, curve: Curve.Ease }) + // The animation does not take effect for the backgroundColor and margin attributes. .backgroundColor(this.myColor) .margin(20) - // Animation does not take effect for the backgroundColor and margin attributes. Button("area: click me") .fontSize(12) @@ -251,7 +251,7 @@ struct LayoutChange2 { ``` -In the preceding example, the animation attribute of the first button takes effect only for the type, width, and height attributes written before the animation, but does not take effect for the backgroundColor and margin attributes written after the animation. In the running result, the width and height attributes execute the animation based on the animation parameters. However, the backgroundColor directly jumps and no animation is generated. The display effect is shown below. +In the preceding example, the **animation** attribute of the first button takes effect only for the **type**, **width**, and **height** attributes written before the **animation** attribute, but does not take effect for the **backgroundColor** and **margin** attributes written after. In the running result, the **width** and **height** attributes execute the animation based on the **animation** settings, while the **backgroundColor** attribute changes without any animation applied. The display effect is shown below. @@ -263,8 +263,8 @@ In the preceding example, the animation attribute of the first button takes effe >**NOTE** > -> 1. When the attribute animation is used, the animation is executed according to the specified attribute animation parameters. Each component can configure attribute animations with different parameters for its own attributes. +> 1. Attribute animations are executed according to the configured attribute animation settings. Each component can have its own attribute animation settings. > -> 2. Explicit animations are executed on all GUI differences caused before and after animation closures, and the same animation parameters are used. Therefore, explicit animations are applicable to scenarios where animations are executed in a unified manner. In addition, explicit animations can also be used for animations caused by non-attribute variables, such as if/else conditions and deletion of array elements used by Forach. +> 2. Explicit animations are executed on all GUI differences caused before and after animation closures, and they share the same animation settings. Therefore, explicit animations are applicable to scenarios where animations are executed in a unified manner. Explicit animations can also be used for animations caused by non-attribute variables, such as **if/else** statements and deletion of array elements used by **ForEach**. > -> 3. If an attribute animation is configured for an attribute and the attribute value is changed in the explicit animation closure, the attribute animation takes effect first and the animation parameters of the attribute animation are used. +> 3. If an attribute animation is configured for an attribute and the attribute value is changed in the explicit animation closure, the attribute animation takes precedence, under the configured animation settings. diff --git a/en/application-dev/ui/figures/layoutChange1.gif b/en/application-dev/ui/figures/layoutChange1.gif new file mode 100644 index 0000000000000000000000000000000000000000..3e03ce67601e2c8b1b4702ede58a7b95c9c65414 Binary files /dev/null and b/en/application-dev/ui/figures/layoutChange1.gif differ diff --git a/en/application-dev/ui/figures/layoutChange2_animateTo.gif b/en/application-dev/ui/figures/layoutChange2_animateTo.gif new file mode 100644 index 0000000000000000000000000000000000000000..ad94cb26c2874bc45ca84a2aaf5d58bbcd864685 Binary files /dev/null and b/en/application-dev/ui/figures/layoutChange2_animateTo.gif differ diff --git a/en/application-dev/ui/figures/layoutChange2_animateTo_change.gif b/en/application-dev/ui/figures/layoutChange2_animateTo_change.gif new file mode 100644 index 0000000000000000000000000000000000000000..14d804c7a0f1e843f218b2551af6f8b51dc421bb Binary files /dev/null and b/en/application-dev/ui/figures/layoutChange2_animateTo_change.gif differ diff --git a/en/application-dev/ui/figures/size-change-animation.gif b/en/application-dev/ui/figures/size-change-animation.gif new file mode 100644 index 0000000000000000000000000000000000000000..fe95f4162af64d2f5cbf4c71645a0317a8fff019 Binary files /dev/null and b/en/application-dev/ui/figures/size-change-animation.gif differ diff --git a/en/application-dev/website.md b/en/application-dev/website.md index 8f1055355da7fda11979cfdc3226b46b1475610c..f1cde6dfbf47e5e4f681b37b18bb75b9868a598b 100644 --- a/en/application-dev/website.md +++ b/en/application-dev/website.md @@ -138,8 +138,8 @@ - [Continuation Overview](application-models/inter-device-interaction-hop-overview.md) - [Cross-Device Migration (for System Applications Only)](application-models/hop-cross-device-migration.md) - [Multi-device Collaboration (for System Applications Only)](application-models/hop-multi-device-collaboration.md) - - IPC - - [Process Model](application-models/process-model-stage.md) + - Process Model + - [Process Model Overview](application-models/process-model-stage.md) - Common Events - [Introduction to Common Events](application-models/common-event-overview.md) - Common Event Subscription @@ -149,8 +149,8 @@ - [Unsubscribing from Common Events](application-models/common-event-unsubscription.md) - [Publishing Common Events](application-models/common-event-publish.md) - [Background Services](application-models/background-services.md) - - Inter-Thread Communication - - [Thread Model](application-models/thread-model-stage.md) + - Thread Model + - [Thread Model Overview](application-models/thread-model-stage.md) - [Using Emitter for Inter-Thread Communication](application-models/itc-with-emitter.md) - [Using Worker for Inter-Thread Communication](application-models/itc-with-worker.md) - Mission Management @@ -193,12 +193,12 @@ - [Context](application-models/application-context-fa.md) - [Want](application-models/want-fa.md) - [Component Startup Rules](application-models/component-startup-rules-fa.md) - - IPC - - [Process Model](application-models/process-model-fa.md) + - Process Model + - [Process Model Overview](application-models/process-model-fa.md) - [Common Events](application-models/common-event-fa.md) - [Background Services](application-models/rpc.md) - - Inter-Thread Communication - - [Thread Model](application-models/thread-model-fa.md) + - Thread Model + - [Thread Model Overview](application-models/thread-model-fa.md) - [Inter-Thread Communication](application-models/itc-fa-overview.md) - [Mission Management](application-models/mission-management-fa.md) - Development of Component Interaction Between the FA Model and Stage Model @@ -575,9 +575,13 @@ - [Development of Application Event Logging](dfx/hiappevent-guidelines.md) - [Development of Performance Tracing](dfx/hitracemeter-guidelines.md) - [Development of Distributed Call Chain Tracing](dfx/hitracechain-guidelines.md) + - [HiLog Development (Native)](dfx/hilog-guidelines.md) - Error Management - [Development of Error Manager](dfx/errormanager-guidelines.md) - [Development of Application Recovery](dfx/apprecovery-guidelines.md) + - Log Analysis + - [Application Freeze (appfreeze) Log Analysis](dfx/appfreeze-guidelines.md) + - [cppcrash Log Analysis](dfx/cppcrash-guidelines.md) - Internationalization - [Internationalization Overview](internationalization/international-overview.md) - [Internationalization Development (intl)](internationalization/intl-guidelines.md) @@ -1164,7 +1168,6 @@ - [@ohos.net.connection (Network Connection Management)](reference/apis/js-apis-net-connection.md) - [@ohos.net.ethernet (Ethernet Connection Management)](reference/apis/js-apis-net-ethernet.md) - [@ohos.net.http (Data Request)](reference/apis/js-apis-http.md) - - [@ohos.net.policy (Network Policy Management)](reference/apis/js-apis-net-policy.md) - [@ohos.net.sharing (Network Sharing)](reference/apis/js-apis-net-sharing.md) - [@ohos.net.socket (Socket Connection)](reference/apis/js-apis-socket.md) - [@ohos.net.webSocket (WebSocket Connection)](reference/apis/js-apis-webSocket.md) @@ -1391,7 +1394,6 @@ - [Network Connection Management Error Codes](reference/errorcodes/errorcode-net-connection.md) - [Ethernet Connection Management Error Codes](reference/errorcodes/errorcode-net-ethernet.md) - [Network Sharing Error Codes](reference/errorcodes/errorcode-net-sharing.md) - - [Network Policy Management Error Codes](reference/errorcodes/errorcode-net-policy.md) - Connectivity - [NFC Error Codes](reference/errorcodes/errorcode-nfc.md) - [RPC Error Codes](reference/errorcodes/errorcode-rpc.md) @@ -1533,6 +1535,8 @@ - [Full SDK Compilation Guide](quick-start/full-sdk-compile-guide.md) - [Guide to Switching to Full SDK](quick-start/full-sdk-switch-guide.md) - [Ability Development](faqs/faqs-ability.md) + - [ArkUI Development](faqs/faqs-arkui.md) + - [Web Development](faqs/faqs-arkui-web.md) - [Bundle Management Development](faqs/faqs-bundle-management.md) - [Resource Manager Development](faqs/faqs-globalization.md) - [Common Event and Notification Development](faqs/faqs-event-notification.md) @@ -1548,4 +1552,5 @@ - [Pan-Sensor Development](faqs/faqs-sensor.md) - [Startup Development](faqs/faqs-startup.md) - [Distributed Device Development](faqs/faqs-distributed-device-profile.md) + - [SDK Usage](faqs/faqs-sdk.md) - [Usage of Third- and Fourth-Party Libraries](faqs/faqs-third-fourth-party-library.md) diff --git a/en/release-notes/changelogs/v3.2-beta5/changelogs-filemanagement.md b/en/release-notes/changelogs/v3.2-beta5/changelogs-filemanagement.md index d032a9fe065b5de692cede9dfb420fe1631ea27c..850e9a739a321d035575e9e8f142542c3d4a94c7 100644 --- a/en/release-notes/changelogs/v3.2-beta5/changelogs-filemanagement.md +++ b/en/release-notes/changelogs/v3.2-beta5/changelogs-filemanagement.md @@ -2,11 +2,11 @@ ## cl.filemanagement.1 environment Module Change -The file management subsystem **d.ts** file has been archived and moved to the **file** directory. The **environment** module supports error code handling. +The file management subsystem **d.ts** file has been archived and moved to the **file** directory. The **environment** module supports error code processing. **Change Impact** -If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **environment** module supports error code handling. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md). +If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **environment** module supports error code processing. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md) for more details. **Key API/Component Changes** @@ -24,11 +24,11 @@ import environment from '@ohos.file.environment'; ## cl.filemanagement.2 securityLabel Change -Moved the file management subsystem **d.ts** file to the **file** directory. The **securityLabel** module supports error code handling. +Moved the file management subsystem **d.ts** file to the **file** directory. The **securityLabel** module supports error code processing. **Change Impact** -If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **securityLabel** module supports error code handling. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md). +If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **securityLabel** module supports error code processing. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md) for more details. **Key API/Component Changes** @@ -58,11 +58,11 @@ The type of the **ino** attribute of **Stat** is changed from number to BigInt. ## cl.filemanagement.4 fileAccess Change -Moved the file management subsystem **d.ts** file to the **file** directory. The **fileAccess** module supports error code handling. +Moved the file management subsystem **d.ts** file to the **file** directory. The **fileAccess** module supports error code processing. **Change Impact** -If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **fileAccess** module supports error code handling. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md). +If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **fileAccess** module supports error code processing. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md) for more details. **Key API/Component Changes** @@ -80,11 +80,11 @@ import fileAccess from '@ohos.file.fileAccess'; ## cl.filemanagement.5 fileExtensionInfo Change -Moved the file management subsystem **d.ts** file to the **file** directory. The **fileExtensionInfo** module supports error code handling. +Moved the file management subsystem **d.ts** file to the **file** directory. The **fileExtensionInfo** module supports error code processing. **Change Impact** -If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **fileExtensionInfo** module supports error code handling. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md). +If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **fileExtensionInfo** module supports error code processing. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md) for more details. **Key API/Component Changes** @@ -102,11 +102,11 @@ import fileExtensionInfo from '@ohos.file.fileExtensionInfo'; ## cl.filemanagement.6 storageStatistics Change -Moved the file management subsystem **d.ts** file to the **file** directory. The **fileExtensionInfo** module supports error code handling. +Moved the file management subsystem **d.ts** file to the **file** directory. The **fileExtensionInfo** module supports error code processing. **Change Impact** -If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **storageStatistics** module supports error code handling. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md). +If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **storageStatistics** module supports error code processing. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md) for more details. **Key API/Component Changes** @@ -124,11 +124,11 @@ import storageStatistics from '@ohos.file.storageStatistics'; ## cl.filemanagement.7 volumeManager Change -Moved the file management subsystem **d.ts** file to the **file** directory. The **fileExtensionInfo** module supports error code handling. +Moved the file management subsystem **d.ts** file to the **file** directory. The **fileExtensionInfo** module supports error code processing. **Change Impact** -If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **volumeManager** module supports error code handling. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md). +If your application is developed based on earlier versions, note that the **d.ts** file location and the name of the module to be imported are changed. The **volumeManager** module supports error code processing. See [Adaptation Guide](../v3.2-beta4/changelogs-filemanagement.md) for more details. **Key API/Component Changes** diff --git a/zh-cn/application-dev/application-models/accessibilityextensionability.md b/zh-cn/application-dev/application-models/accessibilityextensionability.md index 50ee0f2ef546d08d98cce06f2b442eb1004cd14c..6b8a899c9620a9c768591e3f7bd8256188f519e9 100644 --- a/zh-cn/application-dev/application-models/accessibilityextensionability.md +++ b/zh-cn/application-dev/application-models/accessibilityextensionability.md @@ -12,12 +12,27 @@ AccessibilityExtensionAbility基于ExtensionAbility框架,提供无障碍扩 本文档将从以下场景来介绍AccessibilityExtensionAbility的基本开发: +- [AccessibilityExtensionAbility概述](#accessibilityextensionability概述) - [如何创建一个无障碍扩展服务](#如何创建一个无障碍扩展服务) - [如何处理一个无障碍事件](#如何处理一个无障碍事件) - [如何声明无障碍扩展服务具备的能力](#如何声明无障碍扩展服务具备的能力) - [如何开启自定义的无障碍扩展服务](#如何开启自定义的无障碍扩展服务) - [相关示例](#相关示例) +## AccessibilityExtensionAbility概述 + +“信息无障碍”译自“Accessibility”,是指任何人在任何情况下都能平等、方便地获取信息并利用信息。其目的是缩小全社会不同阶层、不同地区、不同年龄、不同健康状况的人群在信息理解、信息交互、信息利用方面的数字鸿沟,使其更加方便地参与社会生活,享受数字发展带来的便利。 + +AccessibilityExtensionAbility为无障碍扩展服务框架,允许三方开发自己的扩展服务,提供在应用程序和扩展服务之间交换信息的标准机制,以便为各种障碍人群和障碍场景提供辅助能力,增强用户的无障碍使用体验。例如在使用微信时,利用辅助应用旁白,用户可以“听见”当前屏幕内容。 + +![AccessibilityFramework](figures/AccessibilityFramework.png) + +1. Accessibility App:开发者基于无障碍扩展服务框架扩展出来的扩展服务应用,如视障用户使用的读屏App。 +2. Tartget App:被Accessibility App辅助的目标应用。 +3. AccessibilityAbilityManagerService(AAMS):无障碍扩展服务框架主服务,用于对Accessibility App生命周期进行管理,同时为Accessibility App和Target App提供信息交互的桥梁。 +4. AccessibilityAbility(AAkit):Accessibility App利用AAkit构建扩展服务Ability运行环境,并为Accessibility App提供可查询和操作Target App的接口,如查询节点信息、对节点执行点击/长按操作等。 +5. AccessibilitySystemAbilityClient(ASACkit):Target App通过ASACkit向AAMS发送无障碍事件,如内容变化事件等,同时响应Accessibility App通过AAMS请求的指令,如查询节点信息、对节点执行点击/长按操作等。 + ## 如何创建一个无障碍扩展服务 开发者在创建一个无障碍扩展服务时,如工程满足环境要求,开发者可自主选择是否跳过创建工程步骤,在已有工程中新增无障碍扩展服务。 diff --git a/zh-cn/application-dev/application-models/arkts-ui-widget-working-principles.md b/zh-cn/application-dev/application-models/arkts-ui-widget-working-principles.md index a9fe611ff2dab83d847e9cbea3db9c401f35a4e0..d6f1aea78f0f0c625df6cf46c59a4750c2f081d5 100644 --- a/zh-cn/application-dev/application-models/arkts-ui-widget-working-principles.md +++ b/zh-cn/application-dev/application-models/arkts-ui-widget-working-principles.md @@ -56,3 +56,5 @@ ArkTS卡片相较于JS卡片具备了更加丰富的能力,但也增加了使 - 不支持import,会在后续版本支持。 - 不支持极速预览,会在后续版本支持。 + +- 不支持Hot Reload热重载,会在后续版本支持。 diff --git a/zh-cn/application-dev/application-models/figures/AccessibilityFramework.png b/zh-cn/application-dev/application-models/figures/AccessibilityFramework.png new file mode 100644 index 0000000000000000000000000000000000000000..786233e6ac160972f62b9786397eb077f7ee767c Binary files /dev/null and b/zh-cn/application-dev/application-models/figures/AccessibilityFramework.png differ diff --git a/zh-cn/application-dev/application-models/serviceextensionability.md b/zh-cn/application-dev/application-models/serviceextensionability.md index a94629215d8c537f94f107101db9effa4eb93dee..ad1b0d5e7d1281a2eefda39b23c9698da960199a 100644 --- a/zh-cn/application-dev/application-models/serviceextensionability.md +++ b/zh-cn/application-dev/application-models/serviceextensionability.md @@ -1,17 +1,5 @@ # ServiceExtensionAbility -- [概述](#概述) -- [生命周期](#生命周期) -- [实现一个后台服务(仅对系统应用开放)](#实现一个后台服务仅对系统应用开放) - - [开发准备](#开发准备) - - [定义IDL接口](#定义idl接口) - - [创建ServiceExtensionAbility](#创建serviceextensionability) -- [启动一个后台服务(仅对系统应用开放)](#启动一个后台服务仅对系统应用开放) -- [连接一个后台服务](#连接一个后台服务) -- [客户端与服务端通信](#客户端与服务端通信) -- [服务端对客户端身份校验](#服务端对客户端身份校验) -- [相关示例](#相关示例) - ## 概述 [ServiceExtensionAbility](../reference/apis/js-apis-app-ability-serviceExtensionAbility.md)是SERVICE类型的ExtensionAbility组件,提供后台服务能力,其内部持有了一个[ServiceExtensionContext](../reference/apis/js-apis-inner-application-serviceExtensionContext.md),通过[ServiceExtensionContext](../reference/apis/js-apis-inner-application-serviceExtensionContext.md)提供了丰富的接口供外部使用。 diff --git a/zh-cn/application-dev/connectivity/http-request.md b/zh-cn/application-dev/connectivity/http-request.md index ff59559ef3036f24b52f8376b3ed63a93155ef62..ec495f6b55c8bc05bc0501fd28401900b774b4ef 100644 --- a/zh-cn/application-dev/connectivity/http-request.md +++ b/zh-cn/application-dev/connectivity/http-request.md @@ -70,6 +70,8 @@ httpRequest.request( // data.header为HTTP响应头,可根据业务需要进行解析 console.info('header:' + JSON.stringify(data.header)); console.info('cookies:' + JSON.stringify(data.cookies)); // 8+ + // 当该请求使用完毕时,调用destroy方法主动销毁 + httpRequest.destroy(); } else { console.info('error:' + JSON.stringify(err)); // 取消订阅HTTP响应头事件 diff --git a/zh-cn/application-dev/quick-start/multi-hap-release-deployment.md b/zh-cn/application-dev/quick-start/multi-hap-release-deployment.md index d592140c8371f4a16346248d401cc3f39a91d303..3fa01718df7eb39c4446365247dc187de27a221d 100644 --- a/zh-cn/application-dev/quick-start/multi-hap-release-deployment.md +++ b/zh-cn/application-dev/quick-start/multi-hap-release-deployment.md @@ -9,7 +9,9 @@ 开发者通过[DevEco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio)工具按照业务的需要创建多个Module,在相应的Module中完成自身业务的开发。 ## 调试 -通过DevEco Studio编译打包,生成单个或者多个HAP,即可基于HAP进行调试。在调试前,需要先安装或更新HAP,以下介绍具体做法。 +通过DevEco Studio编译打包,生成单个或者多个HAP,即可基于HAP进行调试。如需根据不同的部署环境、目标人群、运行环境等,将同一个HAP定制编译为不同版本,请参见[定制编译指导](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/customized-multi-targets-and-products-0000001430013853-V3?catalogVersion=V3)。 + +在调试前,需要先安装或更新HAP,以下介绍具体做法。 * 使用DevEco Studio进行调试 使用指导可参考[应用程序包调试方法](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-debugging-and-running-0000001263040487#section10491183521520),其中包括了单HAP与多HAP通过DevEco Studio工具的安装调试方法。 diff --git a/zh-cn/application-dev/quick-start/start-with-ets-stage.md b/zh-cn/application-dev/quick-start/start-with-ets-stage.md index 8fcf87f0f79c324924ecfbddef3efb5db94733d5..4ebd11ba03a96828fd31457093a0cce1161708ba 100644 --- a/zh-cn/application-dev/quick-start/start-with-ets-stage.md +++ b/zh-cn/application-dev/quick-start/start-with-ets-stage.md @@ -37,14 +37,14 @@ - **AppScope > app.json5**:应用的全局配置信息。 - **entry**:OpenHarmony工程模块,编译构建生成一个[HAP](../../glossary.md#hap)包。 -- **oh_modules**:用于存放三方库依赖信息。关于原npm工程适配ohpm操作,请参考[历史工程手动迁移](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/project_overview-0000001053822398-V3#section108143331212)。 - **src > main > ets**:用于存放ArkTS源码。 - **src > main > ets > entryability**:应用/服务的入口。 - **src > main > ets > pages**:应用/服务包含的页面。 - **src > main > resources**:用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。关于资源文件,详见[资源文件的分类](resource-categories-and-access.md#资源分类)。 - **src > main > module.json5**:模块配置文件。主要包含HAP的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。具体的配置文件说明,详见[module.json5配置文件](module-configuration-file.md)。 - **build-profile.json5**:当前的模块信息 、编译信息配置项,包括buildOption、targets配置等。其中targets中可配置当前运行环境,默认为HarmonyOS。若需开发OpenHarmony应用,则需开发者自行修改为OpenHarmony。 -- **hvigorfile.ts**:模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。 + - **hvigorfile.ts**:模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。 +- **oh_modules**:用于存放三方库依赖信息。关于原npm工程适配ohpm操作,请参考[历史工程手动迁移](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/project_overview-0000001053822398-V3#section108143331212)。 - **build-profile.json5**:应用级配置信息,包括签名、产品配置等。 - **hvigorfile.ts**:应用级编译构建任务脚本。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-animator.md b/zh-cn/application-dev/reference/apis/js-apis-animator.md index 2e7620ae854bd8f532fe8447040f3fff02160e5b..60f48b95676728d8e43f7c15edf5fbc7d374232d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-animator.md +++ b/zh-cn/application-dev/reference/apis/js-apis-animator.md @@ -5,6 +5,8 @@ > **说明:** > > 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> +> 该模块不支持在[UIAbility](./js-apis-app-ability-uiAbility.md)中使用。 ## 导入模块 diff --git a/zh-cn/application-dev/reference/apis/js-apis-http.md b/zh-cn/application-dev/reference/apis/js-apis-http.md index c0fa67b8b718043bed764f1265f79313a7789aad..78ac346581b15e768aa4de4dfb9920b781406512 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-http.md +++ b/zh-cn/application-dev/reference/apis/js-apis-http.md @@ -53,6 +53,8 @@ httpRequest.request( // data.header为HTTP响应头,可根据业务需要进行解析 console.info('header:' + JSON.stringify(data.header)); console.info('cookies:' + JSON.stringify(data.cookies)); // 8+ + // 当该请求使用完毕时,调用destroy方法主动销毁 + httpRequest.destroy(); } else { console.info('error:' + JSON.stringify(err)); // 取消订阅HTTP响应头事件 diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md index 27320dfe20f24b683e2f9b383d7d209a9a7f2964..09cce449e829f63daae338bd157625d584200e70 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md @@ -609,7 +609,7 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.BarrierFree.Accessibility.Core -## attributeNames +### attributeNames attributeNames\(): Promise\>; @@ -635,7 +635,7 @@ rootElement.attributeNames().then((data) => { console.log('failed to get attribute names, because ' + JSON.stringify(err)); }); ``` -## attributeNames +### attributeNames attributeNames\(callback: AsyncCallback\>): void; @@ -663,7 +663,7 @@ rootElement.attributeNames((err, data) => { console.info('get attribute names success'); }); ``` -## AccessibilityElement.attributeValue +### attributeValue attributeValue\(attributeName: T): Promise\; @@ -708,7 +708,7 @@ try { console.log('failed to get attribute value, because ' + JSON.stringify(exception)); } ``` -## AccessibilityElement.attributeValue +### attributeValue attributeValue\(attributeName: T, callback: AsyncCallback\): void; @@ -751,7 +751,7 @@ try { console.log('failed to get attribute value, because ' + JSON.stringify(exception)); } ``` -## actionNames +### actionNames actionNames(): Promise\>; @@ -777,7 +777,7 @@ rootElement.actionNames().then((data) => { console.log('failed to get action names because ' + JSON.stringify(err)); }); ``` -## actionNames +### actionNames actionNames(callback: AsyncCallback\>): void; @@ -805,7 +805,7 @@ rootElement.actionNames((err, data) => { console.info('get action names success'); }); ``` -## performAction +### performAction performAction(actionName: string, parameters?: object): Promise\; @@ -848,7 +848,7 @@ try { console.log('failed to perform action, because ' + JSON.stringify(exception)); } ``` -## performAction +### performAction performAction(actionName: string, callback: AsyncCallback\): void; @@ -887,7 +887,7 @@ try { console.log('failed to perform action, because ' + JSON.stringify(exception)); } ``` -## performAction +### performAction performAction(actionName: string, parameters: object, callback: AsyncCallback\): void; @@ -931,7 +931,7 @@ try { console.log('failed to perform action, because ' + JSON.stringify(exception)); } ``` -## findElement('content') +### findElement('content') findElement(type: 'content', condition: string): Promise\>; @@ -970,7 +970,7 @@ try { console.log('failed to find element, because ' + JSON.stringify(exception)); } ``` -## findElement('content') +### findElement('content') findElement(type: 'content', condition: string, callback: AsyncCallback\>): void; @@ -1006,7 +1006,7 @@ try { console.log('failed to find element, because ' + JSON.stringify(exception)); } ``` -## findElement('focusType') +### findElement('focusType') findElement(type: 'focusType', condition: FocusType): Promise\; @@ -1045,7 +1045,7 @@ try { console.log('failed to find element, because ' + JSON.stringify(exception)); } ``` -## findElement('focusType') +### findElement('focusType') findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback\): void; @@ -1081,7 +1081,7 @@ try { console.log('failed to find element, because ' + JSON.stringify(exception)); } ``` -## findElement('focusDirection') +### findElement('focusDirection') findElement(type: 'focusDirection', condition: FocusDirection): Promise\; @@ -1120,7 +1120,7 @@ try { console.log('failed to find element, because ' + JSON.stringify(exception)); } ``` -## findElement('focusDirection') +### findElement('focusDirection') findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCallback\): void; diff --git a/zh-cn/application-dev/reference/apis/js-apis-mediaquery.md b/zh-cn/application-dev/reference/apis/js-apis-mediaquery.md index 5244b2c693a4c372a6cdf2e0e5a2272f9b36cd67..44a24be4f6bed086ce2a089b45b752f3b537035d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-mediaquery.md +++ b/zh-cn/application-dev/reference/apis/js-apis-mediaquery.md @@ -5,6 +5,8 @@ > **说明:** > > 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> +> 该模块不支持在[UIAbility](./js-apis-app-ability-uiAbility.md)中使用。 ## 导入模块 diff --git a/zh-cn/application-dev/reference/apis/js-apis-promptAction.md b/zh-cn/application-dev/reference/apis/js-apis-promptAction.md index 475a00dded42d4b0054ea1a683bd2c9063ced302..833d6b3c6d1540dec036521f4589d5577c9be541 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-promptAction.md +++ b/zh-cn/application-dev/reference/apis/js-apis-promptAction.md @@ -5,6 +5,8 @@ > **说明:** > > 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> +> 该模块不支持在[UIAbility](./js-apis-app-ability-uiAbility.md)中使用。 ## 导入模块 diff --git a/zh-cn/application-dev/reference/apis/js-apis-rpc.md b/zh-cn/application-dev/reference/apis/js-apis-rpc.md index 50e1bd4a24adfb1ff36ef9116d3522219006bb75..5dc1fae9b0bccf29409663e58fcab9d401422336 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-rpc.md +++ b/zh-cn/application-dev/reference/apis/js-apis-rpc.md @@ -6689,7 +6689,7 @@ registerDeathRecipient(recipient: DeathRecipient, flags: number): void } ``` -### addDeathRecippient(deprecated) +### addDeathRecipient(deprecated) >从API version 9 开始不再维护,建议使用[registerDeathRecipient](#registerdeathrecipient9)类替代。 @@ -6744,7 +6744,7 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean globalThis.context.connectServiceExtensionAbility(want, connect); ``` - 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的addDeathRecippient接口方法新增死亡回调 + 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的addDeathRecipient接口方法新增死亡回调 ```ts class MyDeathRecipient { @@ -7146,7 +7146,7 @@ isAsync(): boolean; | 类型 | 说明 | | ------- | ---------------------------------------- | - | boolean | true:同步调用成功,false:异步调用成功。| + | boolean | true:异步调用成功,false:同步调用成功。| **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-date-time.md b/zh-cn/application-dev/reference/apis/js-apis-system-date-time.md index 8d4015e345a50ece149775ae90c792f29f8a4755..23a8fd6e687c69b04d3f1e88600eb747be0e4d0d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-date-time.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-date-time.md @@ -158,7 +158,7 @@ getCurrentTime(isNano?: boolean): Promise<number> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------- | ---- | ------------------------- | -| isNano | boolean | 否 | 返回结果是否为纳秒数。
- true:表示返回结果为纳秒数(ns)。
- false:表示返回结果为毫秒数(ms)。 | +| isNano | boolean | 否 | 返回结果是否为纳秒数。
默认值为false。
- true:表示返回结果为纳秒数(ns)。
- false:表示返回结果为毫秒数(ms)。 | **返回值:** @@ -253,7 +253,7 @@ getRealActiveTime(isNano?: boolean): Promise<number> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------- | ---- | ----------------------------------- | -| isNano | boolean | 否 | 返回结果是否为纳秒数。
- true:表示返回结果为纳秒数(ns)。
- false:表示返回结果为毫秒数(ms)。 | +| isNano | boolean | 否 | 返回结果是否为纳秒数。
默认值为false。
- true:表示返回结果为纳秒数(ns)。
- false:表示返回结果为毫秒数(ms)。 | **返回值:** @@ -348,7 +348,7 @@ getRealTime(isNano?: boolean): Promise<number> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------- | ---- | ------------------------------- | -| isNano | boolean | 否 | 返回结果是否为纳秒数。
- true:表示返回结果为纳秒数(ns)。
- false:表示返回结果为毫秒数(ms)。 | +| isNano | boolean | 否 | 返回结果是否为纳秒数。
默认值为false。
- true:表示返回结果为纳秒数(ns)。
- false:表示返回结果为毫秒数(ms)。 | **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-time.md b/zh-cn/application-dev/reference/apis/js-apis-system-time.md index 4bdd08c1ea1e7123d10f48c814d84132297349ba..397a6ef7e73e464350be9bc5d9484e3796aeb7ed 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-time.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-time.md @@ -191,7 +191,7 @@ getCurrentTime(isNano?: boolean): Promise<number> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------- | ---- | ------------------------------------------------------------ | -| isNano | boolean | 否 | 返回结果是否为纳秒数。
- true:表示返回结果为纳秒数(ns)。
- false:表示返回结果为毫秒数(ms)。 | +| isNano | boolean | 否 | 返回结果是否为纳秒数。
默认值为false。
- true:表示返回结果为纳秒数(ns)。
- false:表示返回结果为毫秒数(ms)。 | **返回值:** @@ -310,7 +310,7 @@ getRealActiveTime(isNano?: boolean): Promise<number> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------- | ---- | ------------------------------------------------------------ | -| isNano | boolean | 否 | 返回结果是否为纳秒数。
- true:表示返回结果为纳秒数(ns)。
- false:表示返回结果为毫秒数(ms)。 | +| isNano | boolean | 否 | 返回结果是否为纳秒数。
默认值为false。
- true:表示返回结果为纳秒数(ns)。
- false:表示返回结果为毫秒数(ms)。 | **返回值:** @@ -429,7 +429,7 @@ getRealTime(isNano?: boolean): Promise<number> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------- | ---- | ------------------------------------------------------------ | -| isNano | boolean | 否 | 返回结果是否为纳秒数。
- true:表示返回结果为纳秒数(ns)。
- false:表示返回结果为毫秒数(ms)。 | +| isNano | boolean | 否 | 返回结果是否为纳秒数。
默认值为false。
- true:表示返回结果为纳秒数(ns)。
- false:表示返回结果为毫秒数(ms)。 | **返回值:** diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/colorFilter.gif b/zh-cn/application-dev/reference/arkui-ts/figures/colorFilter.gif new file mode 100644 index 0000000000000000000000000000000000000000..e326b328a292ca96b3c2b687128d51cce1106d27 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/colorFilter.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-gauge.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-gauge.md index 8f2609ef6a4828d2703f7066e08036266a107ca9..f0cdf20e57b7dba240039a1cb6add8de68ae0959 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-gauge.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-gauge.md @@ -23,9 +23,9 @@ Gauge(options:{value: number, min?: number, max?: number}) | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| value | number | 是 | 量规图的当前数据值,即图中指针指向位置。用于组件创建时量规图初始值的预置。 | +| value | number | 是 | 量规图的当前数据值,即图中指针指向位置。用于组件创建时量规图初始值的预置。
**说明:**
value不在min和max范围内时使用min作为默认值。 | | min | number | 否 | 当前数据段最小值。
默认值:0 | -| max | number | 否 | 当前数据段最大值。
默认值:100 | +| max | number | 否 | 当前数据段最大值。
默认值:100
**说明:**
max小于min时使用默认值0和100。
max和min支持负数。 | ## 属性 @@ -36,8 +36,8 @@ Gauge(options:{value: number, min?: number, max?: number}) | value | number | 设置量规图的数据值,可用于动态修改量规图的数据值。
默认值:0
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | startAngle | number | 设置起始角度位置,时钟0点为0度,顺时针方向为正角度。
默认值:0
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | endAngle | number | 设置终止角度位置,时钟0点为0度,顺时针方向为正角度。
默认值:360
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| colors | Array<[ColorStop](#colorstop)> | 设置量规图的颜色,支持分段颜色设置。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| strokeWidth | Length | 设置环形量规图的环形厚度。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| colors | Array<[ColorStop](#colorstop)> | 设置量规图的颜色,支持分段颜色设置。
默认值:Color.Black
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| strokeWidth | Length | 设置环形量规图的环形厚度。
默认值:4
单位:vp
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
设置小于0的值时,按默认值显示。
不支持百分比。 | ## ColorStop diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md index 09680577598c2cb8ed6cd5498f2162d8af8c7e03..ac2b8ce856ca1b10a1bde757791b1d3ccf398c59 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md @@ -412,3 +412,86 @@ struct LoadImageExample { } } ``` + +### 为图片增加滤镜 + +```ts +// xxx.ets +@Entry +@Component +struct colorFilterExample { + @State colorFilterR: number = 0 + @State colorFilterG: number = 0 + @State colorFilterB: number = 0 + @State colorFilterA: number = 0 + + build() { + Row() { + Column() { + Image($r('app.media.sky')) + .width(200) + .height(200) + Image($r('app.media.sky')) + .width(200) + .height(200) + .colorFilter([ + this.colorFilterR, 0, this.colorFilterR, 0, 0, + 0, this.colorFilterG, this.colorFilterG, 0, 0, + this.colorFilterB, 0, this.colorFilterB, 0, 0, + 0, 0, this.colorFilterA, 0, 0 + ]) + + Row() { + Text('R') + Slider({ + min: 0, + max: 1, + step: 0.01 + }) + .onChange((valueR) => { + this.colorFilterR = valueR + }) + } + + Row() { + Text('G') + Slider({ + min: 0, + max: 1, + step: 0.01 + }) + .onChange((valueG) => { + this.colorFilterG = valueG + }) + } + + Row() { + Text('B') + Slider({ + min: 0, + max: 1, + step: 0.01 + }) + .onChange((valueB) => { + this.colorFilterB = valueB + }) + } + + Row() { + Text('A') + Slider({ + min: 0, + max: 1, + step: 0.01 + }) + .onChange((valueA) => { + this.colorFilterA = valueA + }) + } + }.width('90%').alignItems(HorizontalAlign.Center) + }.height('100%').width('100%').justifyContent(FlexAlign.Center) + } +} +``` + +![colorFilter](figures/colorFilter.gif) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-search.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-search.md index 9bba97431d15080161a26f6296ca95f998284f27..0673316f1db8dfa3c7beb6c5875c94ad0afee79e 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-search.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-search.md @@ -19,7 +19,7 @@ Search(options?: { value?: string; placeholder?: string; icon?: string; controll | 参数名 | 参数类型 | 必填 | 参数描述 | | ---------- | ---------------- | ---- | ------------------------------------------------------------ | | value | string | 否 | 设置当前显示的搜索文本内容。 | -| icon | string | 否 | 设置搜索图标路径,默认使用系统搜索图标。
图标所支持的图片类型能力参考[Image](ts-basic-components-image.md)组件。 | +| icon | string | 否 | 设置搜索图标路径,默认使用系统搜索图标。
**说明:**
icon的数据源,支持本地图片和网络图片。
- 支持的图片格式包括png、jpg、bmp、svg、gif和pixelmap。
- 支持Base64字符串。格式data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data], 其中[base64 data]为Base64字符串数据。 | | controller | SearchController | 否 | 设置Search组件控制器。 | ## 属性 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md index 081f513dc6585832ee0a22b6cbdeac93e7850db8..6461f7f00eb609d7202a71cf6216558b7cd3bde3 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md @@ -57,7 +57,7 @@ Slider(options?: {value?: number, min?: number, max?: number, step?: number, sty | 名称 | 功能描述 | | -------- | -------- | -| onChange(callback: (value: number, mode: SliderChangeMode) => void) | Slider拖到或点击时触发事件回调。
value:当前滑动进度值。若返回值有小数,可使用number.toFixed()方法将数据处理为预期的精度。
mode:事件触发的相关状态值。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
Begin和End状态当手势点击时都会触发,Moving和Click状态当value值发生变换时触发。
当连贯动作为拖动动作时,不触发Click状态。
value值的变化范围为对应步长steps数组。 | +| onChange(callback: (value: number, mode: SliderChangeMode) => void) | Slider拖动或点击时触发事件回调。
value:当前滑动进度值。若返回值有小数,可使用number.toFixed()方法将数据处理为预期的精度。
mode:事件触发的相关状态值。
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
Begin和End状态当手势点击时都会触发,Moving和Click状态当value值发生变化时触发。
当连贯动作为拖动动作时,不触发Click状态。
value值的变化范围为对应步长steps数组。 | ## SliderChangeMode枚举说明 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepperitem.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepperitem.md index 2dcd381ba8e505f7525ec7a4c7ba38838046aae6..b044077108773c9cdaf2f3623ebd1b78f6fa7131 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepperitem.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepperitem.md @@ -24,7 +24,7 @@ StepperItem() | -------- | -------- | -------- | | prevLabel | string | 设置左侧文本按钮内容,第一页没有左侧文本按钮,当步骤导航器大于一页时,除第一页外默认值都为“返回”。 | | nextLabel | string | 设置右侧文本按钮内容,最后一页默认值为“开始”,其余页默认值为“下一步”。 | -| status | ItemState | 步骤导航器nextLabel的显示状态。
默认值:ItemState.Normal | +| status | [ItemState](#itemstate枚举说明) | 步骤导航器nextLabel的显示状态,参数可选。
默认值:ItemState.Normal | ## ItemState枚举说明 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md index 787893fd3bdce2ae341be72e2d6448eb9e3e8985..ccd4a9a0cf68f54d1f49b8356c7a8ed96e1af00d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md @@ -30,7 +30,7 @@ Text(content?: string | Resource) | 名称 | 参数类型 | 描述 | | ----------------------- | ----------------------------------- | ------------------------------------------- | -| textAlign | [TextAlign](ts-appendix-enums.md#textalign) | 设置文本段落在水平方向的对齐方式
默认值:TextAlign.Start
说明:
文本段落宽度占满Text组件宽度;可通过[align](ts-universal-attributes-location.md)属性控制文本段落在垂直方向上的位置。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| textAlign | [TextAlign](ts-appendix-enums.md#textalign) | 设置文本段落在水平方向的对齐方式
默认值:TextAlign.Start
说明:
文本段落宽度占满Text组件宽度;可通过[align](ts-universal-attributes-location.md)属性控制文本段落在垂直方向上的位置,此组件中不可通过align属性控制文本段落在水平方向上的位置,即align属性中Alignment.TopStart、Alignment.Top、Alignment.TopEnd效果相同,控制内容在顶部,Alignment.Start、Alignment.Center、Alignment.End效果相同,控制内容垂直居中,Alignment.BottomStart、Alignment.Bottom、Alignment.BottomEnd效果相同,控制内容在底部。结合TextAlign属性可控制内容在水平方向的位置。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | textOverflow | {overflow: [TextOverflow](ts-appendix-enums.md#textoverflow)} | 设置文本超长时的显示方式。
默认值:{overflow: TextOverflow.Clip}
**说明:**
文本截断是按字截断。例如,英文以单词为最小单位进行截断,若需要以字母为单位进行截断,可在字母间添加零宽空格:\u200B。
需配合`maxLines`使用,单独设置不生效。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | maxLines | number | 设置文本的最大行数。
默认值:Infinity
**说明:**
默认情况下,文本是自动折行的,如果指定此参数,则文本最多不会超过指定的行。如果有多余的文本,可以通过 `textOverflow`来指定截断方式。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | lineHeight | string \| number \| [Resource](ts-types.md#resource) | 设置文本的文本行高,设置值不大于0时,不限制文本行高,自适应字体大小,Length为number类型时单位为fp。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-swiper.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-swiper.md index 38863585ac5ba858585b233413aeb51c665f8642..57856ff847e30f92332185e4ae2f2ebb7ceea913 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-swiper.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-swiper.md @@ -44,7 +44,7 @@ Swiper(controller?: SwiperController) | displayMode | SwiperDisplayMode | 主轴方向上元素排列的模式,优先以displayCount设置的个数显示,displayCount未设置时本属性生效。
默认值:SwiperDisplayMode.Stretch | | cachedCount8+ | number | 设置预加载子组件个数。
默认值:1
**说明:**
cachedCount已经做了预加载的优化,不建议与[LazyForEach](../../quick-start/arkts-rendering-control-lazyforeach.md)一起使用。 | | disableSwipe8+ | boolean | 禁用组件滑动切换功能。
默认值:false | -| curve8+ | [Curve](ts-appendix-enums.md#curve) \| string | 设置Swiper的动画曲线,默认为淡入淡出曲线,常用曲线参考[Curve枚举说明](ts-appendix-enums.md#curve),也可以通过[插值计算](../apis/js-apis-curve.md)模块提供的接口创建自定义的插值曲线对象。
默认值:Curve.Ease | +| curve8+ | [Curve](ts-appendix-enums.md#curve) \| string | 设置Swiper的动画曲线,默认为淡入淡出曲线,常用曲线参考[Curve枚举说明](ts-appendix-enums.md#curve),也可以通过[插值计算](../apis/js-apis-curve.md)模块提供的接口创建自定义的插值曲线对象。
默认值:Curve.Linear | | indicatorStyle8+ | {
left?: [Length](ts-types.md#length),
top?: [Length](ts-types.md#length),
right?: [Length](ts-types.md#length),
bottom?: [Length](ts-types.md#length),
size?: [Length](ts-types.md#length),
mask?: boolean,
color?: [ResourceColor](ts-types.md),
selectedColor?: [ResourceColor](ts-types.md)
} | 设置导航点样式:
\- left: 设置导航点距离Swiper组件左边的距离。
\- top: 设置导航点距离Swiper组件顶部的距离。
\- right: 设置导航点距离Swiper组件右边的距离。
\- bottom: 设置导航点距离Swiper组件底部的距离。
\- size: 设置导航点的直径。
\- mask: 设置是否显示导航点蒙层样式。
\- color: 设置导航点的颜色。
\- selectedColor: 设置选中的导航点的颜色。 | | displayCount8+ | number\|string | 设置一页内元素显示个数。
默认值:1
**说明:**
字符串类型仅支持设置为'auto',显示效果同SwiperDisplayMode.AutoLinear。
使用number类型时,子组件按照主轴均分Swiper宽度(减去displayCount-1的itemSpace)的方式进行主轴拉伸(收缩)布局。 | | effectMode8+ | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 滑动效果,目前支持的滑动效果参见EdgeEffect的枚举说明。
默认值:EdgeEffect.Spring
**说明:**
控制器接口调用时不生效回弹。 | @@ -172,4 +172,4 @@ struct SwiperExample { } ``` -![swiper](figures/swiper.gif) \ No newline at end of file +![swiper](figures/swiper.gif) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-tabs.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-tabs.md index f581240637f85ca6755aee811c1e74269849039c..a9fd752dca423a263c72c7ccba002346c3b86035 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-tabs.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-tabs.md @@ -41,8 +41,8 @@ Tabs(value?: {barPosition?: BarPosition, index?: number, controller?: [TabsContr | vertical | boolean | 设置为false是为横向Tabs,设置为true时为纵向Tabs。
默认值:false | | scrollable | boolean | 设置为true时可以通过滑动页面进行页面切换,为false时不可滑动切换页面。
默认值:true | | barMode | BarMode | TabBar布局模式,具体描述见BarMode枚举说明。
默认值:BarMode.Fixed | -| barWidth | number \| Length8+ | TabBar的宽度值。
**说明:**
设置为小于0或大于Tabs宽度值时,按默认值显示。 | -| barHeight | number \| Length8+ | TabBar的高度值。
**说明:**
设置为小于0或大于Tabs宽度值时,按默认值显示。 | +| barWidth | number \| Length8+ | TabBar的宽度值。
默认值:
未设置带样式的TabBar且vertical属性为false时,默认值为Tabs的宽度。
未设置带样式的TabBar且vertical属性为true时,默认值为56vp。
设置SubTabbarStyle样式且vertical属性为false时,默认值为Tabs的宽度。
设置SubTabbarStyle样式且vertical属性为true时,默认值为56vp。
设置BottomTabbarStyle样式且vertical属性为true时,默认值为96vp。
设置BottomTabbarStyle样式且vertical属性为false时,默认值为Tabs的宽度。
**说明:**
设置为小于0或大于Tabs宽度值时,按默认值显示。 | +| barHeight | number \| Length8+ | TabBar的高度值。
默认值:
未设置带样式的TabBar且vertical属性为false时,默认值为56vp。
未设置带样式的TabBar且vertical属性为true时,默认值为Tabs的高度。
设置SubTabbarStyle样式且vertical属性为false时,默认值为56vp。
设置SubTabbarStyle样式且vertical属性为true时,默认值为Tabs的高度。
设置BottomTabbarStyle样式且vertical属性为true时,默认值为Tabs的高度。
设置BottomTabbarStyle样式且vertical属性为false时,默认值为56vp。
**说明:**
设置为小于0或大于Tabs高度值时,按默认值显示。| | animationDuration | number | TabContent滑动动画时长。不设置时,点击切换页签无动画,滑动切换有动画;设置时,点击切换和滑动切换都有动画。
默认值:300
**说明:**
设置为小于0或百分比时,按默认值显示。 | ## BarMode枚举说明 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md index 150cbd8e7a7adb4d8f19c1ccc7cea53d70995418..21481345c784244a9c1bf10e73c70014f28b539b 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md @@ -106,9 +106,10 @@ struct CustomDialogUser { customStyle: false }) + // 在自定义组件即将析构销毁时将dialogControlle删除和置空 aboutToDisappear() { - delete this.dialogController, - this.dialogController = undefined + delete this.dialogController, // 删除dialogController + this.dialogController = undefined // 将dialogController置空 } onCancel() { diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md index 23eab101db6fd7ecf73fb14e796b73d184735b73..487fc0911d36f0ad03ac8fc1ae92cc6c1a605681 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md @@ -14,7 +14,7 @@ | flexGrow | number | 设置父容器的剩余空间分配给此属性所在组件的比例。
默认值:0
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | flexShrink | number | 设置父容器压缩尺寸分配给此属性所在组件的比例。
父容器为Row、Column时,默认值:0
父容器为flex时,默认值:1
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | alignSelf | [ItemAlign](ts-appendix-enums.md#itemalign) | 子组件在父容器交叉轴的对齐格式,会覆盖Flex布局容器中的alignItems设置。
默认值:ItemAlign.Auto
从API version 9开始,该接口支持在ArkTS卡片中使用。 | - +| layoutWeight | number \| string | 父容器尺寸确定时,设置了layoutWeight属性的子元素与兄弟元素占主轴尺寸按照权重进行分配,忽略元素本身尺寸设置,表示自适应占满剩余空间。
默认值:0
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
仅在Row/Column/Flex布局中生效。
可选值为大于等于0的数字,或者可以转换为数字的字符串。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-size.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-size.md index ae2a96ee9a199d25f891ccb2c566a7d85d8d4495..efd26c7cbcd184301266e11437a636b8ff48505c 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-size.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-size.md @@ -18,7 +18,6 @@ | padding | [Padding](ts-types.md#padding) \| [Length](ts-types.md#length) | 设置内边距属性。
参数为Length类型时,四个方向内边距同时生效。
默认值:0
padding设置百分比时,上下左右内边距均以父容器的width作为基础值。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | margin | [Margin](ts-types.md#margin) \| [Length](ts-types.md#length) | 设置外边距属性。
参数为Length类型时,四个方向外边距同时生效。
默认值:0
margin设置百分比时,上下左右外边距均以父容器的width作为基础值。
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | constraintSize | {
minWidth?: [Length](ts-types.md#length),
maxWidth?: [Length](ts-types.md#length),
minHeight?: [Length](ts-types.md#length),
maxHeight?: [Length](ts-types.md#length)
} | 设置约束尺寸,组件布局时,进行尺寸范围限制。constraintSize的优先级高于Width和Height。若设置的minWidth大于maxWidth,则minWidth生效,minHeight与maxHeight同理。
默认值:
{
minWidth: 0,
maxWidth: Infinity,
minHeight: 0,
maxHeight: Infinity
}
从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| layoutWeight | number \| string | 父容器尺寸确定时,设置了layoutWeight属性的子元素与兄弟元素占主轴尺寸按照权重进行分配,忽略元素本身尺寸设置,表示自适应占满剩余空间。
默认值:0
从API version 9开始,该接口支持在ArkTS卡片中使用。
**说明:**
仅在Row/Column/Flex布局中生效。
可选值为大于等于0的数字,或者可以转换为数字的字符串。 | ## 示例 diff --git a/zh-cn/application-dev/ui/arkts-page-transition-animation.md b/zh-cn/application-dev/ui/arkts-page-transition-animation.md index 8e9880cf37168c705e94f9db4e80dbda2495bb26..637638fcdb23d68ee0b7945af210a378aa95ca9a 100644 --- a/zh-cn/application-dev/ui/arkts-page-transition-animation.md +++ b/zh-cn/application-dev/ui/arkts-page-transition-animation.md @@ -157,7 +157,7 @@ pageTransition() { ```ts -// page A +// PageTransitionSrc1 import router from '@ohos.router'; @Entry @Component @@ -209,7 +209,7 @@ struct PageTransitionSrc1 { ```ts -// page B +// PageTransitionDst1 import router from '@ohos.router'; @Entry @Component @@ -267,7 +267,7 @@ struct PageTransitionDst1 { ```ts -// page A +// PageTransitionSrc2 import router from '@ohos.router'; @Entry @Component @@ -313,7 +313,7 @@ struct PageTransitionSrc2 { ```ts -// page B +// PageTransitionDst2 import router from '@ohos.router'; @Entry @Component diff --git a/zh-cn/application-dev/ui/arkts-popup-and-menu-components-menu.md b/zh-cn/application-dev/ui/arkts-popup-and-menu-components-menu.md index 1431af7662a57ee4f796a40a459b7f67279965e6..08231b5832981c9db33a280b026f7fd1279cf79f 100644 --- a/zh-cn/application-dev/ui/arkts-popup-and-menu-components-menu.md +++ b/zh-cn/application-dev/ui/arkts-popup-and-menu-components-menu.md @@ -28,7 +28,7 @@ Button('click for Menu') ## 创建自定义样式的菜单 -当默认样式不满足开发需求时,可使用\@CustomBuilder自定义菜单内容。可通过bindContextMenu接口进行菜单的自定义。 +当默认样式不满足开发需求时,可使用\@CustomBuilder自定义菜单内容。可通过bindMenu接口进行菜单的自定义。 ### \@Builder开发菜单内的内容 @@ -70,7 +70,7 @@ MyMenu(){ startIcon: $r("app.media.view_list_filled"), content: "菜单选项", endIcon: $r("app.media.arrow_right_filled"), - builder: this.SubMenu.bind(this)\ + builder: this.SubMenu.bind(this) }) } MenuItem({ @@ -101,7 +101,7 @@ Button('click for Menu') 通过bindContextMenu接口进行菜单的自定义及菜单弹出的触发方式:右键或长按。使用bindContextMenu弹出的菜单项是在独立子窗口内的,可显示在应用窗口外部。 -- [@Builder开发菜单内的内容](#builder开发菜单内的内容)与上文写法相同。 +- @Builder开发菜单内的内容与上文写法相同。 - 确认菜单的弹出方式,使用bindContextMenu属性绑定组件。示例中为右键弹出菜单。