diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md
index 32c2d5b1d1d7d78c1247a375cf17d53505050478..9e23ba2b1555dd0935c3d70be2658544fdc40ec2 100644
--- a/en/application-dev/reference/apis/Readme-EN.md
+++ b/en/application-dev/reference/apis/Readme-EN.md
@@ -1,64 +1,137 @@
# APIs
- [API Reference Document Description](development-intro.md)
+
- Ability Framework
- - FA Model
- - [@ohos.ability.featureAbility](js-apis-featureAbility.md)
- - [@ohos.ability.particleAbility](js-apis-particleAbility.md)
- - ability/[dataAbilityHelper](js-apis-dataAbilityHelper.md)
- - app/[context](js-apis-Context.md)
- - Stage Model
+ - Stage Model (Recommended)
+ - [@ohos.app.ability.Ability](js-apis-app-ability-ability.md)
+ - [@ohos.app.ability.AbilityConstant](js-apis-app-ability-abilityConstant.md)
+ - [@ohos.app.ability.abilityLifecycleCallback](js-apis-app-ability-abilityLifecycleCallback.md)
+ - [@ohos.app.ability.AbilityStage](js-apis-app-ability-abilityStage.md)
+ - [@ohos.app.ability.common](js-apis-app-ability-common.md)
+ - [@ohos.app.ability.contextConstant](js-apis-app-ability-contextConstant.md)
+ - [@ohos.app.ability.EnvironmentCallback](js-apis-app-ability-environmentCallback.md)
+ - [@ohos.app.ability.ExtensionAbility](js-apis-app-ability-extensionAbility.md)
+ - [@ohos.app.ability.ServiceExtensionAbility](js-apis-app-ability-serviceExtensionAbility.md)
+ - [@ohos.app.ability.StartOptions](js-apis-app-ability-startOptions.md)
+ - [@ohos.app.ability.UIAbility](js-apis-app-ability-uiAbility.md)
+ - [@ohos.app.form.FormExtensionAbility](js-apis-app-form-formExtensionAbility.md)
+ - [@ohos.application.DataShareExtensionAbility](js-apis-application-dataShareExtensionAbility.md)
+ - [@ohos.application.StaticSubscriberExtensionAbility](js-apis-application-staticSubscriberExtensionAbility.md)
+ - Stage Model (To Be Deprecated Soon)
- [@ohos.application.Ability](js-apis-application-ability.md)
- [@ohos.application.AbilityConstant](js-apis-application-abilityConstant.md)
- - [@ohos.application.AbilityStage](js-apis-application-abilitystage.md)
- - [@ohos.application.abilityLifecycleCallback](js-apis-application-abilityLifecycleCallback.md)
- - [@ohos.application.DataShareExtensionAbility](js-apis-application-DataShareExtensionAbility.md)
- - [@ohos.application.EnvironmentCallback](js-apis-application-EnvironmentCallback.md)
- - [@ohos.application.FormExtension](js-apis-formextension.md)
- - [@ohos.application.ServiceExtensionAbility](js-apis-service-extension-ability.md)
- - [@ohos.application.StartOptions](js-apis-application-StartOptions.md)
- - [@ohos.application.StaticSubscriberExtensionAbility](js-apis-application-staticSubscriberExtensionAbility.md)
- - [@ohos.application.WindowExtensionAbility](js-apis-application-WindowExtensionAbility.md)
- - application/[AbilityContext](js-apis-ability-context.md)
- - application/[ApplicationContext](js-apis-application-applicationContext.md)
- - application/[AbilityStageContext](js-apis-abilitystagecontext.md)
- - application/[Context](js-apis-application-context.md)
- - application/[ExtensionContext](js-apis-extension-context.md)
- - application/[FormExtensionContext](js-apis-formextensioncontext.md)
- - application/[PermissionRequestResult](js-apis-permissionrequestresult.md)
- - application/[ServiceExtensionContext](js-apis-service-extension-context.md)
- - FA and Stage Models
- - [@ohos.ability.dataUriUtils](js-apis-DataUriUtils.md)
+ - [@ohos.application.AbilityLifecycleCallback](js-apis-application-abilityLifecycleCallback.md)
+ - [@ohos.application.AbilityStage](js-apis-application-abilityStage.md)
+ - [@ohos.application.context](js-apis-application-context.md)
+ - [@ohos.application.EnvironmentCallback](js-apis-application-environmentCallback.md)
+ - [@ohos.application.ExtensionAbility](js-apis-application-extensionAbility.md)
+ - [@ohos.application.FormExtension](js-apis-application-formExtension.md)
+ - [@ohos.application.ServiceExtensionAbility](js-apis-application-serviceExtensionAbility.md)
+ - [@ohos.application.StartOptions](js-apis-application-startOptions.md)
+ - FA Model
+ - [@ohos.ability.ability](js-apis-ability-ability.md)
+ - [@ohos.ability.featureAbility](js-apis-ability-featureAbility.md)
+ - [@ohos.ability.particleAbility](js-apis-ability-particleAbility.md)
+ - Both Models (Recommended)
+ - [@ohos.app.ability.abilityDelegatorRegistry](js-apis-app-ability-abilityDelegatorRegistry.md)
+ - [@ohos.app.ability.abilityManager](js-apis-app-ability-abilityManager.md)
+ - [@ohos.app.ability.appManager](js-apis-app-ability-appManager.md)
+ - [@ohos.app.ability.appRecovery](js-apis-app-ability-appRecovery.md)
+ - [@ohos.app.ability.Configuration](js-apis-app-ability-configuration.md)
+ - [@ohos.app.ability.ConfigurationConstant](js-apis-app-ability-configurationConstant.md)
+ - [@ohos.app.ability.errorManager](js-apis-app-ability-errorManager.md)
+ - [@ohos.app.ability.missionManager](js-apis-app-ability-missionManager.md)
+ - [@ohos.app.ability.quickFixManager](js-apis-app-ability-quickFixManager.md)
+ - [@ohos.app.ability.Want](js-apis-app-ability-want.md)
+ - [@ohos.app.ability.wantAgent](js-apis-app-ability-wantAgent.md)
+ - [@ohos.app.ability.wantConstant](js-apis-app-ability-wantConstant.md)
+ - [@ohos.app.form.formBindingData](js-apis-app-form-formBindingData.md)
+ - [@ohos.app.form.formHost](js-apis-app-form-formHost.md)
+ - [@ohos.app.form.formInfo](js-apis-app-form-formInfo.md)
+ - [@ohos.app.form.formProvider](js-apis-app-form-formProvider.md)
+ - Both Models (To Be Deprecated Soon)
+ - [@ohos.ability.dataUriUtils](js-apis-ability-dataUriUtils.md)
- [@ohos.ability.errorCode](js-apis-ability-errorCode.md)
- [@ohos.ability.wantConstant](js-apis-ability-wantConstant.md)
- - [@ohos.application.abilityDelegatorRegistry](js-apis-abilityDelegatorRegistry.md)
+ - [@ohos.application.abilityDelegatorRegistry](js-apis-application-abilityDelegatorRegistry.md)
- [@ohos.application.abilityManager](js-apis-application-abilityManager.md)
- - [@ohos.application.appManager](js-apis-appmanager.md)
- - [@ohos.application.errorManager](js-apis-errorManager.md)
- - [@ohos.application.formBindingData](js-apis-formbindingdata.md)
- - [@ohos.application.formError](js-apis-formerror.md)
- - [@ohos.application.formHost](js-apis-formhost.md)
- - [@ohos.application.formInfo](js-apis-formInfo.md)
- - [@ohos.application.formProvider](js-apis-formprovider.md)
- - [@ohos.application.missionManager](js-apis-missionManager.md)
- - [@ohos.application.quickFixManager](js-apis-application-quickFixManager.md)
- - [@ohos.application.Want](js-apis-application-Want.md)
- - [@ohos.continuation.continuationManager](js-apis-continuation-continuationManager.md)
+ - [@ohos.application.appManager](js-apis-application-appManager.md)
+ - [@ohos.application.Configuration](js-apis-application-configuration.md)
+ - [@ohos.application.ConfigurationConstant](js-apis-application-configurationConstant.md)
+ - [@ohos.application.errorManager)](js-apis-application-errorManager.md)
+ - [@ohos.application.formBindingData](js-apis-application-formBindingData.md)
+ - [@ohos.application.formError](js-apis-application-formError.md)
+ - [@ohos.application.formHost](js-apis-application-formHost.md)
+ - [@ohos.application.formInfo](js-apis-application-formInfo.md)
+ - [@ohos.application.formProvider](js-apis-application-formProvider.md)
+ - [@ohos.application.missionManager](js-apis-application-missionManager.md)
+ - [@ohos.application.Want](js-apis-application-want.md)
- [@ohos.wantAgent](js-apis-wantAgent.md)
- - application/[abilityDelegator](js-apis-application-abilityDelegator.md)
- - application/[abilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md)
- - application/[abilityMonitor](js-apis-application-abilityMonitor.md)
- - application/[AbilityRunningInfo](js-apis-abilityrunninginfo.md)
- - application/[ExtensionRunningInfo](js-apis-extensionrunninginfo.md)
- - application/[MissionSnapshot](js-apis-application-MissionSnapshot.md)
- - application/[ProcessRunningInformation](js-apis-processrunninginformation.md)
- - application/[shellCmdResult](js-apis-application-shellCmdResult.md)
- - continuation/[continuationExtraParams](js-apis-continuation-continuationExtraParams.md)
- - continuation/[ContinuationResult](js-apis-continuation-continuationResult.md)
+ - Dependent Elements and Definitions
+ - ability
+ - [abilityResult](js-apis-inner-ability-abilityResult.md)
+ - [connectOptions](js-apis-inner-ability-connectOptions.md)
+ - [dataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md)
+ - [dataAbilityOperation](js-apis-inner-ability-dataAbilityOperation.md)
+ - [dataAbilityResult](js-apis-inner-ability-dataAbilityResult.md)
+ - [startAbilityParameter](js-apis-inner-ability-startAbilityParameter.md)
+ - [want](js-apis-inner-ability-want.md)
+ - app
+ - [appVersionInfo](js-apis-inner-app-appVersionInfo.md)
+ - [context](js-apis-inner-app-context.md)
+ - [processInfo](js-apis-inner-app-processInfo.md)
+ - application
+ - [AbilityContext](js-apis-ability-context.md)
+ - [abilityDelegator](js-apis-inner-application-abilityDelegator.md)
+ - [abilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md)
+ - [abilityMonitor](js-apis-inner-application-abilityMonitor.md)
+ - [AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo.md)
+ - [AbilityStageContext](js-apis-inner-application-abilityStageContext.md)
+ - [AbilityStateData](js-apis-inner-application-abilityStateData.md)
+ - [abilityStageMonitor](js-apis-inner-application-abilityStageMonitor.md)
+ - [ApplicationContext](js-apis-inner-application-applicationContext.md)
+ - [ApplicationStateObserver](js-apis-inner-application-applicationStateObserver.md)
+ - [AppStateData](js-apis-inner-application-appStateData.md)
+ - [BaseContext](js-apis-inner-application-baseContext.md)
+ - [Context](js-apis-inner-application-context.md)
+ - [ContinueCallback](js-apis-inner-application-continueCallback.md)
+ - [ContinueDeviceInfo](js-apis-inner-application-continueDeviceInfo.md)
+ - [ErrorObserver](js-apis-inner-application-errorObserver.md)
+ - [ExtensionContext](js-apis-inner-application-extensionContext.md)
+ - [ExtensionRunningInfo](js-apis-inner-application-extensionRunningInfo.md)
+ - [FormExtensionContext](js-apis-inner-application-formExtensionContext.md)
+ - [MissionCallbacks](js-apis-inner-application-missionCallbacks.md)
+ - [MissionDeviceInfo](js-apis-inner-application-missionDeviceInfo.md)
+ - [MissionInfo](js-apis-inner-application-missionInfo.md)
+ - [MissionListener](js-apis-inner-application-missionListener.md)
+ - [MissionParameter](js-apis-inner-application-missionParameter.md)
+ - [MissionSnapshot](js-apis-inner-application-missionSnapshot.md)
+ - [PermissionRequestResult](js-apis-inner-application-permissionRequestResult.md)
+ - [ProcessData](js-apis-inner-application-processData.md)
+ - [ProcessRunningInfo](js-apis-inner-application-processRunningInfo.md)
+ - [ProcessRunningInformation](js-apis-inner-application-processRunningInformation.md)
+ - [ServiceExtensionContext](js-apis-inner-application-serviceExtensionContext.md)
+ - [UIAbilityContext](js-apis-inner-application-uiAbilityContext.md)
+ - [shellCmdResult](js-apis-inner-application-shellCmdResult.md)
+ - wantAgent
+ - [triggerInfo](js-apis-inner-wantAgent-triggerInfo.md)
+ - [wantAgentInfo](js-apis-inner-wantAgent-wantAgentInfo.md)
+ - Continuation
+ - [@ohos.continuation.continuationManager (continuationManager)](js-apis-continuation-continuationManager.md)
+ - continuation
+ - [continuationExtraParams](js-apis-continuation-continuationExtraParams.md)
+ - [continuationResult](js-apis-continuation-continuationResult.md)
+
- Common Event and Notification
+ - [@ohos.commonEventManager (Recommended)](js-apis-commonEventManager.md)
- [@ohos.events.emitter](js-apis-emitter.md)
+ - [@ohos.notificationManager (Recommended)](js-apis-notificationManager.md)
+ - [@ohos.notificationSubscribe (Recommended)](js-apis-notificationSubscribe.md)
+ - [@ohos.commonEvent (To Be Deprecated Soon)](js-apis-commonEvent.md)
- [@ohos.notification](js-apis-notification.md)
- - application/[EventHub](js-apis-eventhub.md)
+ - application
+ - [EventHub](js-apis-inner-application-eventHub.md)
- Bundle Management
- [@ohos.bundle.appControl](js-apis-appControl.md)
- [@ohos.bundle.bundleManager](js-apis-bundleManager.md)
@@ -69,36 +142,42 @@
- [@ohos.bundle.installer](js-apis-installer.md)
- [@ohos.bundle.launcherBundleManager](js-apis-launcherBundleManager.md)
- [@ohos.zlib](js-apis-zlib.md)
- - bundleManager/[abilityInfo](js-apis-bundleManager-abilityInfo.md)
- - bundleManager/[applicationInfo](js-apis-bundleManager-applicationInfo.md)
- - bundleManager/[bundleInfo](js-apis-bundleManager-bundleInfo.md)
- - bundleManager/[dispatchInfo](js-apis-bundleManager-dispatchInfo.md)
- - bundleManager/[elementName](js-apis-bundleManager-elementName.md)
- - bundleManager/[extensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)
- - bundleManager/[hapModuleInfo](js-apis-bundleManager-hapModuleInfo.md)
- - bundleManager/[launcherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)
- - bundleManager/[metadata](js-apis-bundleManager-metadata.md)
- - bundleManager/[packInfo](js-apis-bundleManager-packInfo.md)
- - bundleManager/[permissionDef](js-apis-bundleManager-permissionDef.md)
- - bundleManager/[remoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)
- - bundleManager/[shortcutInfo](js-apis-bundleManager-shortcutInfo.md)
+ - bundleManager
+ - [abilityInfo](js-apis-bundleManager-abilityInfo.md)
+ - [applicationInfo](js-apis-bundleManager-applicationInfo.md)
+ - [bundleInfo](js-apis-bundleManager-bundleInfo.md)
+ - [dispatchInfo](js-apis-bundleManager-dispatchInfo.md)
+ - [elementName](js-apis-bundleManager-elementName.md)
+ - [extensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)
+ - [hapModuleInfo](js-apis-bundleManager-hapModuleInfo.md)
+ - [launcherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)
+ - [metadata](js-apis-bundleManager-metadata.md)
+ - [packInfo](js-apis-bundleManager-packInfo.md)
+ - [permissionDef](js-apis-bundleManager-permissionDef.md)
+ - [remoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)
+ - [shortcutInfo](js-apis-bundleManager-shortcutInfo.md)
- UI Page
- [@ohos.animator](js-apis-animator.md)
+ - [@ohos.curves](js-apis-curve.md)
+ - [@ohos.matrix4](js-apis-matrix4.md)
- [@ohos.mediaquery](js-apis-mediaquery.md)
- [@ohos.promptAction](js-apis-promptAction.md)
- [@ohos.router](js-apis-router.md)
- Graphics
- [@ohos.animation.windowAnimationManager](js-apis-windowAnimationManager.md)
+ - [@ohos.application.WindowExtensionAbility](js-apis-application-windowExtensionAbility.md)
- [@ohos.display ](js-apis-display.md)
- [@ohos.effectKit](js-apis-effectKit.md)
- [@ohos.graphics.colorSpaceManager](js-apis-colorSpaceManager.md)
- [@ohos.screen](js-apis-screen.md)
- [@ohos.screenshot](js-apis-screenshot.md)
- [@ohos.window](js-apis-window.md)
- - [webgl](js-apis-webgl.md)
- - [webgl2](js-apis-webgl2.md)
+ - webgl
+ - [webgl](js-apis-webgl.md)
+ - [webgl2](js-apis-webgl2.md)
- Media
- [@ohos.multimedia.audio](js-apis-audio.md)
+ - [@ohos.multimedia.avsession](js-apis-avsession.md)
- [@ohos.multimedia.camera](js-apis-camera.md)
- [@ohos.multimedia.image](js-apis-image.md)
- [@ohos.multimedia.media](js-apis-media.md)
@@ -114,30 +193,33 @@
- [@ohos.resourceschedule.usageStatistics](js-apis-resourceschedule-deviceUsageStatistics.md)
- [@ohos.WorkSchedulerExtensionAbility](js-apis-WorkSchedulerExtensionAbility.md)
- Security
- - [@ohos.abilityAccessCtrl](js-apis-abilityAccessCtrl.md)
- - [@ohos.privacyManager](js-apis-privacyManager.md)
- - [@ohos.security.cryptoFramework](js-apis-cryptoFramework.md)
- - [@ohos.security.huks ](js-apis-huks.md)
- - [@ohos.userIAM.faceAuth](js-apis-useriam-faceauth.md)
- - [@ohos.userIAM.userAuth ](js-apis-useriam-userauth.md)
- - [@system.cipher](js-apis-system-cipher.md)
+ - [@ohos.abilityAccessCtrl (Ability Access Control)](js-apis-abilityAccessCtrl.md)
+ - [@ohos.privacyManager (Privacy Management)](js-apis-privacyManager.md)
+ - [@ohos.security.cert (Certificate)](js-apis-cert.md)
+ - [@ohos.security.cryptoFramework (Crypto Framework)](js-apis-cryptoFramework.md)
+ - [@ohos.security.huks (HUKS)](js-apis-huks.md)
+ - [@ohos.userIAM.faceAuth (Facial Authentication)](js-apis-useriam-faceauth.md)
+ - [@ohos.userIAM.userAuth (User Authentication)](js-apis-useriam-userauth.md)
+ - [@system.cipher (Cipher Algorithm)](js-apis-system-cipher.md)
- Data Management
- - [@ohos.data.dataAbility ](js-apis-data-ability.md)
- - [@ohos.data.dataShare](js-apis-data-dataShare.md)
- - [@ohos.data.dataSharePredicates](js-apis-data-dataSharePredicates.md)
- - [@ohos.data.dataShareResultSet](js-apis-data-DataShareResultSet.md)
- - [@ohos.data.distributedDataObject](js-apis-data-distributedobject.md)
- - [@ohos.data.preferences](js-apis-data-preferences.md)
- - [@ohos.data.rdb](js-apis-data-rdb.md)
- - [@ohos.data.ValuesBucket](js-apis-data-ValuesBucket.md)
- - data/rdb/[resultSet](js-apis-data-resultset.md)
+ - [@ohos.data.dataAbility (DataAbility Predicates)](js-apis-data-ability.md)
+ - [@ohos.data.dataShare (DataShare)](js-apis-data-dataShare.md)
+ - [@ohos.data.dataSharePredicates (DataShare Predicates)](js-apis-data-dataSharePredicates.md)
+ - [@ohos.data.dataShareResultSet (DataShare Result Set)](js-apis-data-DataShareResultSet.md)
+ - [@ohos.data.distributedDataObject (Distributed Data Object)](js-apis-data-distributedobject.md)
+ - [@ohos.data.distributedKVStore (Distributed KV Store)](js-apis-distributedKVStore.md)
+ - [@ohos.data.preferences (Preferences)](js-apis-data-preferences.md)
+ - [@ohos.data.rdb (RDB)](js-apis-data-rdb.md)
+ - [@ohos.data.ValuesBucket (Value Bucket)](js-apis-data-valuesBucket.md)
+ - data/rdb
+ - [resultSet](js-apis-data-resultset.md)
- File Management
- [@ohos.document](js-apis-document.md)
- [@ohos.environment](js-apis-environment.md)
- [@ohos.data.fileAccess](js-apis-fileAccess.md)
- [@ohos.fileExtensionInfo](js-apis-fileExtensionInfo.md)
- [@ohos.fileio](js-apis-fileio.md)
- - [@ohos.filemanagement.userfile_manager](js-apis-userfilemanager.md)
+ - [@ohos.filemanagement.userFileManager](js-apis-userFileManager.md)
- [@ohos.multimedia.medialibrary](js-apis-medialibrary.md)
- [@ohos.securityLabel](js-apis-securityLabel.md)
- [@ohos.statfs](js-apis-statfs.md)
@@ -166,14 +248,19 @@
- [@ohos.nfc.controller](js-apis-nfcController.md)
- [@ohos.nfc.tag](js-apis-nfcTag.md)
- [@ohos.rpc](js-apis-rpc.md)
+ - [@ohos.wifiManager (WLAN)](js-apis-wifiManager.md)
+ - [@ohos.wifiManagerExt](js-apis-wifiManagerExt.md)
- [@ohos.wifi](js-apis-wifi.md)
- [@ohos.wifiext](js-apis-wifiext.md)
- - tag/[nfctech](js-apis-nfctech.md)
- - tag/[tagSession](js-apis-tagSession.md)
+ - tag
+ - [nfctech](js-apis-nfctech.md)
+ - [tagSession](js-apis-tagSession.md)
- Basic Features
- [@ohos.accessibility](js-apis-accessibility.md)
- [@ohos.accessibility.config](js-apis-accessibility-config.md)
- - [@ohos.application.AccessibilityExtensionAbility](js-apis-application-AccessibilityExtensionAbility.md)
+ - [@ohos.accessibility.GesturePat](js-apis-accessibility-GesturePath.md)
+ - [@ohos.accessibility.GesturePoint](js-apis-accessibility-GesturePoint.md)
+ - [@ohos.application.AccessibilityExtensionAbility](js-apis-application-accessibilityExtensionAbility.md)
- [@ohos.faultLogger](js-apis-faultLogger.md)
- [@ohos.hichecker](js-apis-hichecker.md)
- [@ohos.hidebug](js-apis-hidebug.md)
@@ -181,23 +268,29 @@
- [@ohos.hiSysEvent](js-apis-hisysevent.md)
- [@ohos.hiTraceChain](js-apis-hitracechain.md)
- [@ohos.hiTraceMeter](js-apis-hitracemeter.md)
- - [@ohos.inputMethod](js-apis-inputmethod.md)
- - [@ohos.inputMethodEngine](js-apis-inputmethodengine.md)
+ - [@ohos.hiviewdfx.hiAppEvent](js-apis-hiviewdfx-hiappevent.md)
+ - [@ohos.inputmethod](js-apis-inputmethod.md)
+ - [@ohos.inputmethodengine](js-apis-inputmethodengine.md)
- [@ohos.inputmethodextensionability](js-apis-inputmethod-extension-ability.md)
- [@ohos.inputmethodextensioncontext](js-apis-inputmethod-extension-context.md)
+ - [@ohos.inputmethodsubtype](js-apis-inputmethod-subtype.md)
- [@ohos.pasteboard](js-apis-pasteboard.md)
- [@ohos.screenLock](js-apis-screen-lock.md)
- [@ohos.systemTime](js-apis-system-time.md)
- [@ohos.systemTimer](js-apis-system-timer.md)
- [@ohos.wallpaper](js-apis-wallpaper.md)
+ - [@ohos.web.webview](js-apis-webview.md)
- [console](js-apis-logs.md)
- [Timer](js-apis-timer.md)
- - application/[AccessibilityExtensionContext](js-apis-accessibility-extension-context.md)
+ - application
+ - [AccessibilityExtensionContext](js-apis-inner-application-accessibilityExtensionContext.md)
- Device Management
- [@ohos.batteryInfo ](js-apis-battery-info.md)
+ - [@ohos.batteryStatistics](js-apis-batteryStatistics.md)
- [@ohos.brightness](js-apis-brightness.md)
- [@ohos.deviceInfo](js-apis-device-info.md)
- [@ohos.distributedHardware.deviceManager](js-apis-device-manager.md)
+ - [@ohos.geoLocationManager](js-apis-geoLocationManager.md)
- [@ohos.multimodalInput.inputConsumer](js-apis-inputconsumer.md)
- [@ohos.multimodalInput.inputDevice](js-apis-inputdevice.md)
- [@ohos.multimodalInput.inputDeviceCooperate](js-apis-cooperate.md)
@@ -213,6 +306,8 @@
- [@ohos.runningLock](js-apis-runninglock.md)
- [@ohos.sensor](js-apis-sensor.md)
- [@ohos.settings](js-apis-settings.md)
+ - [@ohos.stationary](js-apis-stationary.md)
+ - [@ohos.systemCapability (SystemCapability)](js-apis-system-capability.md)
- [@ohos.systemParameterV9](js-apis-system-parameterV9.md)
- [@ohos.thermal](js-apis-thermal.md)
- [@ohos.update](js-apis-update.md)
@@ -224,9 +319,12 @@
- [@ohos.account.osAccount](js-apis-osAccount.md)
- Custom Management
- [@ohos.configPolicy](js-apis-configPolicy.md)
- - [@ohos.EnterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md)
+ - [@ohos.enterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md)
+ - [@ohos.enterprise.adminManager](js-apis-enterprise-adminManager.md)
+ - [@ohos.enterprise.dateTimeManager](js-apis-enterprise-dateTimeManager.md)
+
- Language Base Class Library
- - [@ohos.buffer](js-apis-buffer.md)
+ - [@ohos.buffer (Buffer)](js-apis-buffer.md)
- [@ohos.convertxml](js-apis-convertxml.md)
- [@ohos.process](js-apis-process.md)
- [@ohos.uri](js-apis-uri.md)
@@ -249,15 +347,14 @@
- [@ohos.worker](js-apis-worker.md)
- [@ohos.xml](js-apis-xml.md)
- Test
- - [@ohos.application.testRunner](js-apis-testRunner.md)
+ - [@ohos.application.testRunner](js-apis-application-testRunner.md)
- [@ohos.uitest](js-apis-uitest.md)
-- APIs No Longer Maintained
+- APIs No Longer Maintained
- [@ohos.backgroundTaskManager](js-apis-backgroundTaskManager.md)
- [@ohos.bundle](js-apis-Bundle.md)
- [@ohos.bundle.innerBundleManager](js-apis-Bundle-InnerBundleManager.md)
- [@ohos.bundleState](js-apis-deviceUsageStatistics.md)
- [@ohos.bytrace](js-apis-bytrace.md)
- - [@ohos.commonEvent](js-apis-commonEvent.md)
- [@ohos.data.storage](js-apis-data-storage.md)
- [@ohos.data.distributedData](js-apis-distributed-data.md)
- [@ohos.distributedBundle](js-apis-Bundle-distributedBundle.md)
@@ -267,6 +364,7 @@
- [@ohos.prompt](js-apis-prompt.md)
- [@ohos.reminderAgent](js-apis-reminderAgent.md)
- [@ohos.systemParameter](js-apis-system-parameter.md)
+ - [@ohos.usb](js-apis-usb-deprecated.md)
- [@ohos.workScheduler](js-apis-workScheduler.md)
- [@system.app](js-apis-system-app.md)
- [@system.battery](js-apis-system-battery.md)
@@ -287,17 +385,17 @@
- [@system.sensor](js-apis-system-sensor.md)
- [@system.storage](js-apis-system-storage.md)
- [@system.vibrator](js-apis-system-vibrate.md)
- - application/[ProcessRunningInfo](js-apis-processrunninginfo.md)
- - bundle/[abilityInfo](js-apis-bundle-AbilityInfo.md)
- - bundle/[applicationInfo](js-apis-bundle-ApplicationInfo.md)
- - bundle/[bundleInfo](js-apis-bundle-BundleInfo.md)
- - bundle/[bundleInstaller](js-apis-bundle-BundleInstaller.md)
- - bundle/[bundleStatusCallback](js-apis-Bundle-BundleStatusCallback.md)
- - bundle/[customizeData](js-apis-bundle-CustomizeData.md)
- - bundle/[elementName](js-apis-bundle-ElementName.md)
- - bundle/[hapModuleInfo](js-apis-bundle-HapModuleInfo.md)
- - bundle/[launcherAbilityInfo](js-apis-bundle-LauncherAbilityInfo.md)
- - bundle/[moduleInfo](js-apis-bundle-ModuleInfo.md)
- - bundle/[PermissionDef](js-apis-bundle-PermissionDef.md)
- - bundle/[remoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)
- - bundle/[shortcutInfo](js-apis-bundle-ShortcutInfo.md)
+ - bundle
+ - [abilityInfo](js-apis-bundle-AbilityInfo.md)
+ - [applicationInfo](js-apis-bundle-ApplicationInfo.md)
+ - [bundleInfo](js-apis-bundle-BundleInfo.md)
+ - [bundleInstaller](js-apis-bundle-BundleInstaller.md)
+ - [bundleStatusCallback](js-apis-Bundle-BundleStatusCallback.md)
+ - [customizeData](js-apis-bundle-CustomizeData.md)
+ - [elementName](js-apis-bundle-ElementName.md)
+ - [hapModuleInfo](js-apis-bundle-HapModuleInfo.md)
+ - [launcherAbilityInfo](js-apis-bundle-LauncherAbilityInfo.md)
+ - [moduleInfo](js-apis-bundle-ModuleInfo.md)
+ - [PermissionDef](js-apis-bundle-PermissionDef.md)
+ - [remoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)
+ - [shortcutInfo](js-apis-bundle-ShortcutInfo.md)
diff --git a/en/application-dev/reference/apis/development-intro.md b/en/application-dev/reference/apis/development-intro.md
index aaeab2f2961f4254f4bbd8d634ee0f773f996ab4..281fa66969891561b062b7cfd7185d25f7c7f474 100644
--- a/en/application-dev/reference/apis/development-intro.md
+++ b/en/application-dev/reference/apis/development-intro.md
@@ -9,9 +9,9 @@ In API references, the earliest versions of APIs and components are specified in
- For a new API or component, the version information is provided at the beginning of the reference document. Example: "The initial APIs of this module are supported since API version 7."
- For a new feature of an existing API or component, a superscript is added following the feature. For example, "uid8+" indicates that the **uid** attribute is supported since API version 8.
-## Ability Framework Model Description
+## Application Model Description
-Ability is the minimum unit for the system to schedule applications. An application can contain one or more `Ability` instances. Ability framework models are classified into the FA model and stage model. For details, see [Ability Framework Overview](../../ability/ability-brief.md).
+Along its evolution, OpenHarmony has provided two application models: FA model and stage model. For their differences, see [Interpretation of the Application Model](../../application-models/application-model-description.md).
- If all the APIs of a module support only one model, the following description is provided at the beginning of the reference document: "The APIs of this module can be used only in the FA model." or "The APIs of this module can be used only in the stage model."
- If certain APIs of a module support only one model, the following description is provided individually for these APIs: "This API can be used only in the FA model." or "This API can be used only in the stage model."
@@ -19,18 +19,18 @@ Ability is the minimum unit for the system to schedule applications. An applicat
## Available APIs
-Certain APIs provided by OpenHarmony are system APIs, which can be used only by original equipment manufacturers (OEMs) and cannot be used by non-system applications.
+Certain APIs provided by OpenHarmony are system APIs, which can be used only by original equipment manufacturers (OEMs) and cannot be used by common applications.
A description regarding system APIs will be provided in the document.
- If all the APIs of a module are system APIs, the following description is provided at the beginning of the reference document: "All the APIs of this module are system APIs."
- If a specific API of a module is a system API, the following description is provided individually for the API: "This is a system API."
-Non-system applications are applications whose Ability Privilege Level (APL) is **normal**. The default application level is **normal**.
+A common application is an application whose application type is **hos_normal_app** in the HarmonyAppProvision configuration file. **hos_normal_app** is the default value for project creation.
-For details about the APL and how to declare the APL of an application higher than **normal**, see [Access Control Overview - App APLs](../../security/accesstoken-overview.md#app-apls).
-
-The public SDK, which does not include system APIs, is provided as standard in DevEco Studio. To use system APIs, switch to the full SDK. For details on the operation, see [Guide to Switching to Full SDK](../../quick-start/full-sdk-switch-guide.md).
+The public SDK, which does not include system APIs, is provided as standard in DevEco Studio. To use the system APIs, you must:
+- Switch the public SDK to the full SDK by following the instructions provided in [Guide to Switching to Full SDK] (../../quick-start/full-sdk-switch-guide.md).
+- Change the value of **app-feature** in the HarmonyAppProvision configuration file to **hos_system_app**. For details, see [HarmonyAppProvision Configuration File](../../security/app-provision-structure.md).
## Permission Description
@@ -41,17 +41,19 @@ To call APIs to access these resources, you must apply for the corresponding per
- If an application can call an API only after it has obtained a specific permission, the following description is provided for the API: "**Required permissions**: ohos.permission.xxxx"
- If an application can call an API without any permission, no special description is provided.
-To determine whether an application can apply for a specific permission, see [Permission List](../../security/permission-list.md).
+To determine whether an application can request a specific permission, see [Permission Application and Use](../../security/accesstoken-overview.md#permission-application-and-use).
## System Capability Description
-System capability refers to a relatively independent feature in the operating system. Different devices provide different system capabilities, and multiple APIs implement a system capability. You can determine whether an API can be used based on system capabilities. For details, see [SysCap](../../quick-start/syscap.md).
+System capability refers to a relatively independent feature in the operating system. Different devices provide different system capabilities, and multiple APIs implement a system capability. You can determine whether an API can be used based on system capabilities. For details, see [SystemCapability](../syscap.md).
The following description is provided for each API in the reference document to describe the system capability of the API: "**System capability**: SystemCapability.xxx.xxx"
+You can use the [SystemCapability List](../syscap-list.md) to query the devices supported by a specific capability set.
+
## Sample Code Language Description
OpenHarmony supports two development languages: JS and TS.
-- When a code block is labeled with `js`, the sample code can be used in the JS and ArkTS projects.
-- When a code block is labeled with `ts`, the sample code can be used only in the ArkTS project.
+- When a code block is labeled with **js**, the sample code can be used in the JS and ArkTS projects.
+- When a code block is labeled with **ts**, the sample code can be used only in the ArkTS project.
diff --git a/en/application-dev/reference/apis/figures/en-us_image_0000001118642902.png b/en/application-dev/reference/apis/figures/en-us_image_0000001118642902.png
new file mode 100644
index 0000000000000000000000000000000000000000..36eab44e87c075e01baa66bfc48a86ba703b7835
Binary files /dev/null and b/en/application-dev/reference/apis/figures/en-us_image_0000001118642902.png differ
diff --git a/en/application-dev/reference/apis/figures/en-us_image_0000001174104410.gif b/en/application-dev/reference/apis/figures/en-us_image_0000001174104410.gif
new file mode 100644
index 0000000000000000000000000000000000000000..df8e47d8359338f9d0412cacfe12b847c28c2a84
Binary files /dev/null and b/en/application-dev/reference/apis/figures/en-us_image_0000001174104410.gif differ
diff --git a/en/application-dev/reference/apis/figures/en-us_image_0000001174422898.png b/en/application-dev/reference/apis/figures/en-us_image_0000001174422898.png
new file mode 100644
index 0000000000000000000000000000000000000000..1dc7d8d7beda862221b05a9247723a3f74bf323d
Binary files /dev/null and b/en/application-dev/reference/apis/figures/en-us_image_0000001174422898.png differ
diff --git a/en/application-dev/reference/apis/figures/en-us_image_0000001219662645.png b/en/application-dev/reference/apis/figures/en-us_image_0000001219662645.png
new file mode 100644
index 0000000000000000000000000000000000000000..747b8f915f2d40803ce6a7937de1add5deb8e640
Binary files /dev/null and b/en/application-dev/reference/apis/figures/en-us_image_0000001219662645.png differ
diff --git a/en/application-dev/reference/apis/figures/en-us_image_0000001219744181.png b/en/application-dev/reference/apis/figures/en-us_image_0000001219744181.png
new file mode 100644
index 0000000000000000000000000000000000000000..605c0a1ddc0e2bace2e4c9a23fc2391af9ebf5bf
Binary files /dev/null and b/en/application-dev/reference/apis/figures/en-us_image_0000001219744181.png differ
diff --git a/en/application-dev/reference/apis/figures/en-us_image_0000001219864131.png b/en/application-dev/reference/apis/figures/en-us_image_0000001219864131.png
new file mode 100644
index 0000000000000000000000000000000000000000..5c0ada67867ec3765eeb53af5c62369762d0bac4
Binary files /dev/null and b/en/application-dev/reference/apis/figures/en-us_image_0000001219864131.png differ
diff --git a/en/application-dev/reference/apis/figures/en-us_image_0000001219864133.PNG b/en/application-dev/reference/apis/figures/en-us_image_0000001219864133.PNG
new file mode 100644
index 0000000000000000000000000000000000000000..14f81499ff0b1b8ef46257bc35a79e94775cd2ba
Binary files /dev/null and b/en/application-dev/reference/apis/figures/en-us_image_0000001219864133.PNG differ
diff --git a/en/application-dev/reference/apis/figures/en-us_image_00007.gif b/en/application-dev/reference/apis/figures/en-us_image_00007.gif
new file mode 100644
index 0000000000000000000000000000000000000000..8c43bdf5b331963459154d4f0400fad7b17b34e8
Binary files /dev/null and b/en/application-dev/reference/apis/figures/en-us_image_00007.gif differ
diff --git a/en/application-dev/reference/apis/js-apis-Bundle-InnerBundleManager.md b/en/application-dev/reference/apis/js-apis-Bundle-InnerBundleManager.md
index 9d023410fff66869318fca78d3cae361ff71217b..40725aefbf65838c8da46d75a13368c68118df0d 100644
--- a/en/application-dev/reference/apis/js-apis-Bundle-InnerBundleManager.md
+++ b/en/application-dev/reference/apis/js-apis-Bundle-InnerBundleManager.md
@@ -1,8 +1,8 @@
-# innerBundleManager(deprecated)
+# @ohos.bundle.innerBundleManager
The **innerBundleManager** module provides APIs for the **Home Screen** application.
->
+>
> 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.
> This module is deprecated since API version 9. You are advised to use [launcherBundleManager](js-apis-launcherBundleManager.md) and [bundleMonitor](js-apis-bundleMonitor.md) instead.
@@ -41,7 +41,7 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- |
| bundleName | string | Yes | Bundle name of an application. |
-| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
+| userId | number | Yes | User ID. The value must be greater than or equal to 0.|
| callback | AsyncCallback\> | Yes | Callback used to return an array of the launcher ability information. |
@@ -69,7 +69,7 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ----------------------------------------------------- |
| bundleName | string | Yes | Bundle name of an application. |
-| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
+| userId | number | Yes | User ID. The value must be greater than or equal to 0.|
**Return value**
@@ -216,7 +216,7 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- |
-| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
+| userId | number | Yes | User ID. The value must be greater than or equal to 0.|
| callback | AsyncCallback\> | Yes | Callback used to return an array of the launcher ability information. |
## innerBundleManager.getAllLauncherAbilityInfos(deprecated)
@@ -242,7 +242,7 @@ This is a system API and cannot be called by third-party applications.
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ----------------------------------------------------- |
-| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
+| userId | number | Yes | User ID. The value must be greater than or equal to 0.|
**Return value**
diff --git a/en/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md b/en/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md
index 8701a6b80d7d54dc8bf6a30850c3551a741e77ed..493b263bd25d74fa7cfa5d9c59a45659fb4b5740 100644
--- a/en/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md
+++ b/en/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md
@@ -46,7 +46,7 @@ This is a system API and cannot be called by third-party applications.
**Parameters**
-| Name | Type | Mandatory| Description |
+| Name | Type | Mandatory| Description |
| ----------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
| elementName | [ElementName](js-apis-bundle-ElementName.md) | Yes | **ElementName**. |
| callback | AsyncCallback<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)> | Yes | Callback used to return the remote ability information.|
@@ -75,7 +75,7 @@ This is a system API and cannot be called by third-party applications.
**Parameters**
-| Name | Type | Mandatory| Description |
+| Name | Type | Mandatory| Description |
| ----------- | -------------------------------------------- | ---- | ----------------------- |
| elementName | [ElementName](js-apis-bundle-ElementName.md) | Yes | **ElementName**.|
@@ -107,10 +107,10 @@ This is a system API and cannot be called by third-party applications.
**Parameters**
-| Name | Type | Mandatory| Description |
+| Name | Type | Mandatory| Description |
| ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
| elementNames | Array<[ElementName](js-apis-bundle-ElementName.md)> | Yes | **ElementName** array, whose maximum length is 10. |
-| callback | AsyncCallback< Array<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)>> | Yes | Callback used to return the remote ability information.|
+| callback | AsyncCallback< Array<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)>> | Yes | Callback used to return an array of the remote ability information.|
@@ -136,7 +136,7 @@ This is a system API and cannot be called by third-party applications.
**Parameters**
-| Name | Type | Mandatory| Description |
+| Name | Type | Mandatory| Description |
| ------------ | --------------------------------------------------- | ---- | ----------------------- |
| elementNames | Array<[ElementName](js-apis-bundle-ElementName.md)> | Yes | **ElementName** array, whose maximum length is 10.|
diff --git a/en/application-dev/reference/apis/js-apis-Bundle.md b/en/application-dev/reference/apis/js-apis-Bundle.md
index 52a10b74d2346bc15d2fc17ce196b190bfbfa521..83cf9c77d2899e1c0c0969be8199c602e4374816 100644
--- a/en/application-dev/reference/apis/js-apis-Bundle.md
+++ b/en/application-dev/reference/apis/js-apis-Bundle.md
@@ -1,24 +1,24 @@
-# Bundle
+# @ohos.bundle
-The **Bundle** module provides APIs for querying the information about bundles, applications, abilities, Extension abilities, and application states.
+The **bundle** module provides APIs for obtaining information about an application, including [bundle information](js-apis-bundle-BundleInfo.md), [application information](js-apis-bundle-ApplicationInfo.md), and [ability information](js-apis-bundle-AbilityInfo.md). It also provides APIs to obtain and set the application disabling state.
> **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.
## Modules to Import
-```js
+```ts
import bundle from '@ohos.bundle';
```
## Required Permissions
-| Required Permissions | Permission Level | Description |
-| ------------------------------------------ | ------------ | ------------------ |
-| ohos.permission.GET_BUNDLE_INFO | normal | Permission to query information about a specified application. |
-| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED| system_basic | Permission to query information about all applications.|
-| ohos.permission.INSTALL_BUNDLE | system_core | Permission to install or uninstall applications. |
-| ohos.permission.MANAGE_DISPOSED_APP_STATUS | system_core | Permission to set and query the application disposal status. |
+| Required Permissions | Permission Level | Description |
+|--------------------------------------------|--------------|---------------|
+| ohos.permission.GET_BUNDLE_INFO | normal | Permission to query information about a specified bundle. |
+| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED| system_basic | Permission to query information about all bundles. |
+| ohos.permission.INSTALL_BUNDLE | system_core | Permission to install or uninstall bundles. |
+| ohos.permission.MANAGE_DISPOSED_APP_STATUS | system_core | Permission to set and query the application disposal status.|
For details, see [Permission Levels](../../security/accesstoken-overview.md#permission-levels).
@@ -30,6 +30,8 @@ getApplicationInfo(bundleName: string, bundleFlags: number, userId?: number): Pr
Obtains the application information based on a given bundle name. This API uses a promise to return the result.
+No permission is required for obtaining the caller's own information.
+
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
@@ -42,8 +44,8 @@ SystemCapability.BundleManager.BundleFramework
| Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | ------------------------------------------------------------ |
-| bundleName | string | Yes | Bundle name of an application. |
-| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).|
+| bundleName | string | Yes | Bundle name of the application. |
+| bundleFlags | number | Yes | Type of information that will be returned. For details about the available enumerated values, see the application information flags in [BundleFlag](#bundleflagdeprecated).|
| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
**Return value**
@@ -54,7 +56,7 @@ SystemCapability.BundleManager.BundleFramework
**Example**
-```js
+```ts
let bundleName = "com.example.myapplication";
let bundleFlags = 0;
let userId = 100;
@@ -74,6 +76,8 @@ getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, call
Obtains the application information of the specified user based on a given bundle name. This API uses an asynchronous callback to return the result.
+No permission is required for obtaining the caller's own information.
+
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
@@ -86,14 +90,14 @@ SystemCapability.BundleManager.BundleFramework
| Name | Type | Mandatory| Description |
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
-| bundleName | string | Yes | Bundle name of an application. |
-| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).|
-| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
+| bundleName | string | Yes | Bundle name of the application. |
+| bundleFlags | number | Yes | Type of information that will be returned. For details about the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).|
+| userId | number | Yes | User ID. The value must be greater than or equal to 0. |
| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Yes | Callback used to return the application information. |
**Example**
-```js
+```ts
let bundleName = "com.example.myapplication";
let bundleFlags = 0;
let userId = 100;
@@ -115,6 +119,8 @@ getApplicationInfo(bundleName: string, bundleFlags: number, callback: AsyncCallb
Obtains the application information based on a given bundle name. This API uses an asynchronous callback to return the result.
+No permission is required for obtaining the caller's own information.
+
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
@@ -127,13 +133,13 @@ SystemCapability.BundleManager.BundleFramework
| Name | Type | Mandatory| Description |
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
-| bundleName | string | Yes | Bundle name of an application. |
-| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).|
+| bundleName | string | Yes | Bundle name of the application. |
+| bundleFlags | number | Yes | Type of information that will be returned. For details about the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).|
| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Yes | Callback used to return the application information. |
**Example**
-```js
+```ts
let bundleName = "com.example.myapplication";
let bundleFlags = 0;
bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => {
@@ -152,7 +158,7 @@ bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => {
getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise>
-Obtains the information of all available bundles of the specified user in the system. This API uses a promise to return the result.
+Obtains the information of all bundles of the specified user. This API uses a promise to return the result.
**Required permissions**
@@ -166,7 +172,7 @@ SystemCapability.BundleManager.BundleFramework
| Name | Type | Mandatory| Description |
| ---------- | ---------- | ---- | ------------------------------------------------------------ |
-| bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
+| bundleFlag | BundleFlag | Yes | Type of information that will be returned. For details about the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
**Return value**
@@ -177,7 +183,7 @@ SystemCapability.BundleManager.BundleFramework
**Example**
-```js
+```ts
let bundleFlag = 0;
let userId = 100;
bundle.getAllBundleInfo(bundleFlag, userId)
@@ -195,7 +201,7 @@ bundle.getAllBundleInfo(bundleFlag, userId)
getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback>): void
-Obtains the information of all available bundles in the system. This API uses an asynchronous callback to return the result.
+Obtains the information of all bundles of the current user. This API uses an asynchronous callback to return the result.
**Required permissions**
@@ -209,12 +215,12 @@ SystemCapability.BundleManager.BundleFramework
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
-| bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
-| callback | AsyncCallback> | Yes | Callback used to return the information of all available bundles. |
+| bundleFlag | BundleFlag | Yes | Type of information that will be returned. For details about the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
+| callback | AsyncCallback> | Yes | Callback used to return the information of all bundles. |
**Example**
-```js
+```ts
let bundleFlag = 0;
bundle.getAllBundleInfo(bundleFlag, (err, data) => {
if (err) {
@@ -232,7 +238,7 @@ bundle.getAllBundleInfo(bundleFlag, (err, data) => {
getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback>): void
-Obtains the information of all available bundles of the specified user in the system. This API uses an asynchronous callback to return the result.
+Obtains the information of all bundles of the specified user. This API uses an asynchronous callback to return the result.
**Required permissions**
@@ -244,15 +250,16 @@ SystemCapability.BundleManager.BundleFramework
**Parameters**
-| Name | Type | Mandatory| Description |
-| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
-| bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
-| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
-| callback | AsyncCallback> | Yes | Callback used to return the information of all available bundles. |
+| Name | Type | Mandatory | Description |
+|------------|-------------------------------------------------------------------|-----|---------------------------------------------------------------------|
+| bundleFlag | BundleFlag | Yes | Type of information that will be returned. For details about the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
+| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
+| callback | AsyncCallback> | Yes | Callback used to return the information of all bundles. |
+|
**Example**
-```js
+```ts
let bundleFlag = 0;
let userId = 100;
bundle.getAllBundleInfo(bundleFlag, userId, (err, data) => {
@@ -273,6 +280,8 @@ getBundleInfo(bundleName: string, bundleFlags: number, options?: BundleOptions):
Obtains the bundle information based on a given bundle name. This API uses a promise to return the result.
+No permission is required for obtaining the caller's own information.
+
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
@@ -283,11 +292,11 @@ SystemCapability.BundleManager.BundleFramework
**Parameters**
-| Name | Type | Mandatory | Description |
-| ----------- | ------------- | ---- | --------------------------------------- |
-| bundleName | string | Yes | Bundle name of an application. |
-| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
-| options | [BundleOptions](#bundleoptions) | No | Includes **userId**. |
+| Name | Type | Mandatory | Description |
+| ----------- | ------------- | ---- |---------------------------------------------------------------------|
+| bundleName | string | Yes | Bundle name of the application. |
+| bundleFlags | number | Yes | Type of information that will be returned. For details about the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
+| options | [BundleOptions](#bundleoptions) | No | Options that contain the user ID. |
**Return value**
@@ -297,7 +306,7 @@ SystemCapability.BundleManager.BundleFramework
**Example**
-```js
+```ts
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
let options = {
@@ -319,6 +328,8 @@ getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<
Obtains the bundle information based on a given bundle name. This API uses an asynchronous callback to return the result.
+No permission is required for obtaining the caller's own information.
+
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
@@ -329,15 +340,15 @@ SystemCapability.BundleManager.BundleFramework
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
-| bundleName | string | Yes | Bundle name of an application. |
-| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
-| callback | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes | Callback used to return the bundle information. |
+| Name | Type | Mandatory| Description |
+| ----------- | ---------------------------------------------------------- | ---- |---------------------------------------------------------------------|
+| bundleName | string | Yes | Bundle name of the application. |
+| bundleFlags | number | Yes | Type of information that will be returned. For details about the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
+| callback | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes | Callback used to return the bundle information. |
**Example**
-```js
+```ts
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
bundle.getBundleInfo(bundleName, bundleFlags, (err, data) => {
@@ -358,6 +369,8 @@ getBundleInfo(bundleName: string, bundleFlags: number, options: BundleOptions, c
Obtains the bundle information based on a given bundle name and bundle options. This API uses an asynchronous callback to return the result.
+No permission is required for obtaining the caller's own information.
+
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
@@ -370,14 +383,14 @@ SystemCapability.BundleManager.BundleFramework
| Name | Type | Mandatory| Description |
| ----------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
-| bundleName | string | Yes | Bundle name of an application. |
-| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
+| bundleName | string | Yes | Bundle name of the application. |
+| bundleFlags | number | Yes | Type of information that will be returned. For details about the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
| options | [BundleOptions](#bundleoptions) | Yes | Includes **userId**. |
| callback | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes | Callback used to return the bundle information. |
**Example**
-```js
+```ts
let bundleName = "com.example.myapplication";
let bundleFlags = 1;
let options = {
@@ -400,7 +413,7 @@ bundle.getBundleInfo(bundleName, bundleFlags, options, (err, data) => {
getBundleInstaller(): Promise<BundleInstaller>;
-Obtains the installation package information. This API uses a promise to return the result.
+Obtains the installation package. This API uses a promise to return the result.
**Required permissions**
@@ -418,7 +431,17 @@ This is a system API and cannot be called by third-party applications.
| Type | Description |
| ------------------------------------------------------------ | -------------------------------------------- |
-| Promise<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | Promise used to return the installation package information.|
+| Promise<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | Promise used to return the installation package.|
+
+**Example**
+
+```ts
+bundle.getBundleInstaller().then((data) => {
+ console.info('getBundleInstaller successfully.');
+}).catch((error) => {
+ console.error('getBundleInstaller failed.');
+});
+```
## bundle.getBundleInstallerdeprecated
@@ -426,7 +449,7 @@ This is a system API and cannot be called by third-party applications.
getBundleInstaller(callback: AsyncCallback<BundleInstaller>): void;
-Obtains the installation package information. This API uses an asynchronous callback to return the result.
+Obtains the installation package. This API uses an asynchronous callback to return the result.
**Required permissions**
@@ -444,8 +467,19 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ---------------- |
-| callback | AsyncCallback<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | Yes | Callback used to return the installation package information.|
+| callback | AsyncCallback<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | Yes | Callback used to return the installation package.|
+
+**Example**
+```ts
+bundle.getBundleInstaller((err, data) => {
+ if (err.code == 0) {
+ console.error('getBundleInstaller failed.');
+ } else {
+ console.info('getBundleInstaller successfully');
+ }
+});
+```
## bundle.cleanBundleCacheFiles8+ deprecated
> This API is deprecated since API version 9. You are advised to use [bundleManager.cleanBundleCacheFiles](js-apis-bundleManager.md#bundlemanagercleanbundlecachefiles) instead.
@@ -470,9 +504,23 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| ---------- | ------------------- | ---- | ------------------------------------- |
-| bundleName | string | Yes | Bundle name of an application.|
+| bundleName | string | Yes | Bundle name of the application.|
| callback | AsyncCallback\ | Yes | Callback used to return the result. |
+**Example**
+
+```ts
+let bundleName = "com.example.myapplication";
+
+bundle.cleanBundleCacheFiles(bundleName, err => {
+ if (err) {
+ console.error('cleanBundleCacheFiles failed.');
+ } else {
+ console.info('cleanBundleCacheFiles successfully.');
+ }
+});
+```
+
## bundle.cleanBundleCacheFiles8+ deprecated
> This API is deprecated since API version 9. You are advised to use [bundleManager.cleanBundleCacheFiles](js-apis-bundleManager.md#bundlemanagercleanbundlecachefiles) instead.
@@ -497,7 +545,7 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ------------------------------------- |
-| bundleName | string | Yes | Bundle name of an application.|
+| bundleName | string | Yes | Bundle name of the application.|
**Return value**
@@ -505,6 +553,18 @@ This is a system API and cannot be called by third-party applications.
| ------------- | ------------------------------------ |
| Promise\ | Promise that returns no value.|
+**Example**
+
+```ts
+let bundleName = "com.example.myapplication";
+
+bundle.cleanBundleCacheFiles(bundleName).then(()=> {
+ console.info('cleanBundleCacheFiles successfully.');
+}).catch(err=> {
+ console.error('cleanBundleCacheFiles failed.');
+});
+```
+
## bundle.setApplicationEnabled8+ deprecated
> This API is deprecated since API version 9. You are advised to use [bundleManager.setApplicationEnabled](js-apis-bundleManager.md#bundlemanagersetapplicationenabled) instead.
@@ -527,11 +587,25 @@ This is a system API and cannot be called by third-party applications.
**Parameters**
-| Name | Type | Mandatory| Description |
-| ---------- | ------------------- | ---- | ----------------------------------------------- |
-| bundleName | string | Yes | Bundle name of an application. |
+| Name | Type | Mandatory| Description |
+| ---------- | ------------------- | ---- |--------------------------------|
+| bundleName | string | Yes | Bundle name of the application. |
| isEnable | boolean | Yes | Whether to enable the application. The value **true** means to enable the application, and **false** means the opposite.|
-| callback | AsyncCallback\ | Yes | Callback used to return the result. |
+| callback | AsyncCallback\ | Yes | Callback used to return the result. |
+
+**Example**
+
+```ts
+let bundleName = "com.example.myapplication";
+
+bundle.setApplicationEnabled(bundleName, false, err => {
+ if (err) {
+ console.error('setApplicationEnabled failed.');
+ } else {
+ console.info('setApplicationEnabled successfully.');
+ }
+});
+```
## bundle.setApplicationEnabled8+ deprecated
@@ -555,9 +629,9 @@ This is a system API and cannot be called by third-party applications.
**Parameters**
-| Name | Type | Mandatory| Description |
-| ---------- | ------- | ---- | ----------------------------------------------- |
-| bundleName | string | Yes | Bundle name of an application. |
+| Name | Type | Mandatory| Description |
+| ---------- | ------- | ---- |------------------------------|
+| bundleName | string | Yes | Bundle name of the application. |
| isEnable | boolean | Yes | Whether to enable the application. The value **true** means to enable the application, and **false** means the opposite.|
**Return value**
@@ -566,6 +640,18 @@ This is a system API and cannot be called by third-party applications.
| ------------- | ------------------------------------ |
| Promise\ | Promise that returns no value.|
+**Example**
+
+```ts
+let bundleName = "com.example.myapplication";
+
+bundleManager.setApplicationEnabled(bundleName, false).then(()=> {
+ console.info('setApplicationEnabled successfully.');
+}).catch(err=> {
+ console.error('setApplicationEnabled failed.');
+});
+```
+
## bundle.setAbilityEnabled8+ deprecated
> This API is deprecated since API version 9. You are advised to use [bundleManager.setAbilityEnabled](js-apis-bundleManager.md#bundlemanagersetabilityenabled) instead.
@@ -627,6 +713,28 @@ This is a system API and cannot be called by third-party applications.
| ------------- | ------------------------------------ |
| Promise\ | Promise that returns no value.|
+**Example**
+
+```ts
+let flag = bundle.BundleFlag.GET_ABILITY_INFO_WITH_PERMISSION;
+let userId = 100;
+let want = {
+ bundleName : "com.example.myapplication",
+ abilityName : "com.example.myapplication.MainAbility"
+};
+
+bundle.getAbilityInfo(want, flag, userId).then((abilityInfo) => {
+ console.info('getAbilityInfo successfully. Data: ' + JSON.stringify(abilityInfo));
+
+ bundle.setAbilityEnabled(abilityInfo, false).then(data => {
+ console.info('setAbilityEnabled successfully.');
+ }).catch(err => {
+ console.error('setAbilityEnabled failed:' + JSON.stringify(err));
+ })
+}).catch(error => {
+ console.error('getAbilityInfo failed. Cause: ' + JSON.stringify(error));
+});
+```
## bundle.getPermissionDef8+ deprecated
> This API is deprecated since API version 9. You are advised to use [bundleManager.getPermissionDef](js-apis-bundleManager.md#bundlemanagergetpermissiondef) instead.
@@ -654,6 +762,19 @@ This is a system API and cannot be called by third-party applications.
| permissionName | string | Yes | Name of the permission. |
| callback | AsyncCallback<[PermissionDef](js-apis-bundle-PermissionDef)> | Yes | Callback used to return the permission details.|
+**Example**
+
+```ts
+let permission = "ohos.permission.GET_BUNDLE_INFO";
+bundleManager.getPermissionDef(permission, (err, data) => {
+ if (err) {
+ console.error('getPermissionDef failed:' + err.message);
+ } else {
+ console.info('getPermissionDef successfully:' + JSON.stringify(data));
+ }
+});
+```
+
## bundle.getPermissionDef8+ deprecated
> This API is deprecated since API version 9. You are advised to use [bundleManager.getPermissionDef](js-apis-bundleManager.md#bundlemanagergetpermissiondef) instead.
@@ -686,6 +807,16 @@ This is a system API and cannot be called by third-party applications.
| ------------------------------------------------------ | ------------------------------------------------------ |
| Promise<[PermissionDef](js-apis-bundle-PermissionDef)> | Promise used to return the permission details.|
+**Example**
+
+```ts
+let permissionName = "ohos.permission.GET_BUNDLE_INFO";
+bundle.getPermissionDef(permissionName).then((data) => {
+ console.info('getPermissionDef successfully. Data: ' + JSON.stringify(data));
+}).catch(error => {
+ console.error('getPermissionDef failed. Cause: ' + error.message);
+});
+```
## bundle.getAllApplicationInfodeprecated
@@ -707,8 +838,8 @@ SystemCapability.BundleManager.BundleFramework
| Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | ------------------------------------------------------------ |
-| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).|
-| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
+| bundleFlags | number | Yes | Type of information that will be returned. For details about the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).|
+| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
**Return value**
@@ -718,7 +849,7 @@ SystemCapability.BundleManager.BundleFramework
**Example**
-```js
+```ts
let bundleFlags = 8;
let userId = 100;
bundle.getAllApplicationInfo(bundleFlags, userId)
@@ -735,7 +866,7 @@ bundle.getAllApplicationInfo(bundleFlags, userId)
getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback>): void
-Obtains the information about all applications of the specified user. This API uses an asynchronous callback to return the result.
+Obtains the information about all applications. This API uses an asynchronous callback to return the result.
**Required permissions**
@@ -749,14 +880,14 @@ SystemCapability.BundleManager.BundleFramework
| Name | Type | Mandatory| Description |
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
-| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).|
+| bundleFlags | number | Yes | Type of information that will be returned. For details about the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).|
| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
| callback | AsyncCallback> | Yes | Callback used to return the application information. |
**Example**
-```js
-let bundleFlags = 8;
+```ts
+let bundleFlags = bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
let userId = 100;
bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => {
if (err) {
@@ -774,7 +905,7 @@ bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => {
getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback>) : void;
-Obtains the information about all applications. This API uses an asynchronous callback to return the result.
+Obtains the information about all applications of the current user. This API uses an asynchronous callback to return the result.
**Required permissions**
@@ -788,13 +919,13 @@ SystemCapability.BundleManager.BundleFramework
| Name | Type | Mandatory| Description |
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
-| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. For details on the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).|
+| bundleFlags | number | Yes | Type of information that will be returned. For details about the available enumerated values, see the application information flags in [BundleFlag](#bundleflag).|
| callback | AsyncCallback> | Yes | Callback used to return the application information. |
**Example**
-```js
-let bundleFlags = 8;
+```ts
+let bundleFlags = bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION;
bundle.getAllApplicationInfo(bundleFlags, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + JSON.stringify(err));
@@ -820,8 +951,8 @@ SystemCapability.BundleManager.BundleFramework
| Name | Type | Mandatory | Description |
| ---------- | ------ | ---- | ------------ |
-| hapFilePath | string | Yes | Path where the HAP file is stored. The path should point to the relative directory of the current application's data directory.|
-| bundleFlags | number | Yes | Flags used to specify information contained in the **BundleInfo** object that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
+| hapFilePath | string | Yes | Path where the HAP file is stored. The absolute path of the application and the data directory sandbox path are supported.|
+| bundleFlags | number | Yes | Flags used to specify information contained in the **BundleInfo** object that will be returned. For details about the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
**Return value**
| Type | Description |
@@ -830,8 +961,8 @@ SystemCapability.BundleManager.BundleFramework
**Example**
-```js
-let hapFilePath = "/data/xxx/test.hap";
+```ts
+let hapFilePath = "/data/storage/el2/base/test.hap";
let bundleFlags = 0;
bundle.getBundleArchiveInfo(hapFilePath, bundleFlags)
.then((data) => {
@@ -857,14 +988,14 @@ SystemCapability.BundleManager.BundleFramework
| Name | Type | Mandatory | Description |
| ---------- | ------ | ---- | ------------ |
-| hapFilePath | string | Yes | Path where the HAP file is stored. The path should point to the relative directory of the current application's data directory.|
-| bundleFlags | number | Yes | Flags used to specify information contained in the **BundleInfo** object that will be returned. The default value is **0**. For details on the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
+| hapFilePath | string | Yes | Path where the HAP file is stored.. The absolute path of the application and the data directory sandbox path are supported.|
+| bundleFlags | number | Yes | Flags used to specify information contained in the **BundleInfo** object that will be returned. For details about the available enumerated values, see the bundle information flags in [BundleFlag](#bundleflag).|
| callback| AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes | Callback used to return the information about the bundles.|
**Example**
-```js
-let hapFilePath = "/data/xxx/test.hap";
+```ts
+let hapFilePath = "/data/storage/el2/base/test.hap";
let bundleFlags = 0;
bundle.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => {
if (err) {
@@ -884,6 +1015,8 @@ getAbilityInfo(bundleName: string, abilityName: string): Promise\
Obtains the ability information based on a given bundle name and ability name. This API uses a promise to return the result.
+No permission is required for obtaining the caller's own information.
+
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
@@ -894,9 +1027,9 @@ SystemCapability.BundleManager.BundleFramework
**Parameters**
-| Name | Type | Mandatory | Description |
-| ----------- | ------ | ---- | ---------------- |
-| bundleName | string | Yes | Bundle name of an application. |
+| Name | Type | Mandatory | Description |
+| ----------- | ------ | ---- |------------|
+| bundleName | string | Yes | Bundle name of the application. |
| abilityName | string | Yes | Ability name.|
**Return value**
@@ -907,7 +1040,7 @@ SystemCapability.BundleManager.BundleFramework
**Example**
-```js
+```ts
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityInfo(bundleName, abilityName)
@@ -926,6 +1059,8 @@ getAbilityInfo(bundleName: string, abilityName: string, callback: AsyncCallback\
Obtains the ability information based on a given bundle name and ability name. This API uses an asynchronous callback to return the result.
+No permission is required for obtaining the caller's own information.
+
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
@@ -936,15 +1071,15 @@ SystemCapability.BundleManager.BundleFramework
**Parameters**
-| Name | Type | Mandatory | Description |
-| ----------- | ------------ | ---- | ---------------- |
-| bundleName | string | Yes | Bundle name of an application. |
-| abilityName | string | Yes | Ability name.|
+| Name | Type | Mandatory | Description |
+| ----------- | ------------ | ---- |----------------------------|
+| bundleName | string | Yes | Bundle name of the application. |
+| abilityName | string | Yes | Ability name. |
| callback | AsyncCallback\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Yes | Callback used to return the ability information.|
**Example**
-```js
+```ts
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityInfo(bundleName, abilityName, (err, data) => {
@@ -964,6 +1099,8 @@ getAbilityLabel(bundleName: string, abilityName: string): Promise\
Obtains the application name based on a given bundle name and ability name. This API uses a promise to return the result.
+No permission is required for obtaining the caller's own information.
+
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
@@ -974,10 +1111,10 @@ SystemCapability.BundleManager.BundleFramework
**Parameters**
-| Name | Type | Mandatory | Description |
-| ----------- | ------ | ---- | ---------------- |
-| bundleName | string | Yes | Bundle name of an application. |
-| abilityName | string | Yes | Ability name.|
+| Name | Type | Mandatory | Description |
+|-------------|--------|-----|------------|
+| bundleName | string | Yes | Bundle name of the application. |
+| abilityName | string | Yes | Ability name.|
**Return value**
@@ -987,7 +1124,7 @@ SystemCapability.BundleManager.BundleFramework
**Example**
-```js
+```ts
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityLabel(bundleName, abilityName)
@@ -1006,6 +1143,8 @@ getAbilityLabel(bundleName: string, abilityName: string, callback : AsyncCallbac
Obtains the application name based on a given bundle name and ability name. This API uses an asynchronous callback to return the result.
+No permission is required for obtaining the caller's own information.
+
**Required permissions**
ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
@@ -1016,15 +1155,15 @@ SystemCapability.BundleManager.BundleFramework
**Parameters**
-| Name | Type | Mandatory | Description |
-| ----------- | ---------------------- | ---- | ---------------- |
-| bundleName | string | Yes | Bundle name of an application. |
-| abilityName | string | Yes | Ability name.|
-| callback | AsyncCallback\ | Yes | Callback used to return the application name. |
+| Name | Type | Mandatory | Description |
+|-------------|------------------------|-----|-------------------------|
+| bundleName | string | Yes | Bundle name of the application. |
+| abilityName | string | Yes | Ability name. |
+| callback | AsyncCallback\ | Yes | Callback used to return the application name.|
**Example**
-```js
+```ts
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityLabel(bundleName, abilityName, (err, data) => {
@@ -1062,7 +1201,7 @@ SystemCapability.BundleManager.BundleFramework
**Example**
-```js
+```ts
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{
@@ -1095,7 +1234,7 @@ SystemCapability.BundleManager.BundleFramework
**Example**
-```js
+```ts
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{
@@ -1125,17 +1264,17 @@ SystemCapability.BundleManager.BundleFramework
| Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ------------------------ |
-| bundleName | string | Yes | Bundle name of an application.|
+| bundleName | string | Yes | Bundle name of the application.|
**Return value**
| Type | Description |
| ----------------- | ------------------------- |
-| Promise\ | Promise used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned.|
+| Promise\ | Promise used to return whether the application is enabled. If the application is enabled, **true** will be returned; otherwise, **false** will be returned.|
**Example**
-```js
+```ts
let bundleName = "com.example.myapplication";
bundle.isApplicationEnabled(bundleName)
.then((data) => {
@@ -1161,12 +1300,12 @@ SystemCapability.BundleManager.BundleFramework
| Name | Type | Mandatory| Description |
| ---------- | ----------------------- | ---- | ------------------------ |
-| bundleName | string | Yes | Bundle name of an application.|
-| callback | AsyncCallback\ | Yes | Callback used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned. |
+| bundleName | string | Yes | Bundle name of the application.|
+| callback | AsyncCallback\ | Yes | Callback used to return whether the application is enabled. If the application is enabled, **true** will be returned; otherwise, **false** will be returned. |
**Example**
-```js
+```ts
let bundleName = "com.example.myapplication";
bundle.isApplicationEnabled(bundleName, (err, data) => {
if (err) {
@@ -1185,6 +1324,8 @@ queryAbilityByWant(want: Want, bundleFlags: number, userId?: number): Promise> | Yes | Callback used to return the ability information. |
+| Name | Type | Mandatory | Description |
+|-------------|---------------------------------------------------------------------|-----|-------------------------------------------------------------------------|
+| want | [Want](js-apis-application-want.md) | Yes | Want that contains the bundle name. |
+| bundleFlags | number | Yes | Ability information to be returned. For details about the available enumerated values, see the ability information flags in [BundleFlag](#bundleflag).|
+| userId | number | Yes | User ID. The value must be greater than or equal to 0. |
+| callback | AsyncCallback> | Yes | Callback used to return the ability information. |
**Example**
-```js
+```ts
let bundleFlags = 0;
let userId = 100;
let want = {
@@ -1277,6 +1420,8 @@ queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback> | Yes | Callback used to return the ability information. |
+| Name | Type | Mandatory | Description |
+|-------------|---------------------------------------------------------------------|-----|-------------------------------------------------------------------------|
+| want | [Want](js-apis-application-want.md) | Yes | Want that contains the bundle name. |
+| bundleFlags | number | Yes | Ability information to be returned. For details about the available enumerated values, see the ability information flags in [BundleFlag](#bundleflag).|
+| callback | AsyncCallback> | Yes | Callback used to return the ability information. |
**Example**
-```js
+```ts
let bundleFlags = 0;
let want = {
bundleName : "com.example.myapplication",
@@ -1332,16 +1477,16 @@ SystemCapability.BundleManager.BundleFramework
| Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ------------------------ |
-| bundleName | string | Yes | Bundle name of an application.|
+| bundleName | string | Yes | Bundle name of the application.|
**Return value**
| Type | Description |
| -------------- | -------------------------------------- |
-| Promise\<[Want](js-apis-application-Want.md)> | Promise used to return the **Want** object.|
+| Promise\<[Want](js-apis-application-want.md)> | Promise used to return the **Want** object.|
**Example**
-```js
+```ts
let bundleName = "com.example.myapplication";
bundle.getLaunchWantForBundle(bundleName)
.then((data) => {
@@ -1371,12 +1516,12 @@ SystemCapability.BundleManager.BundleFramework
| Name | Type | Mandatory| Description |
| ---------- | --------------------------------------------------- | ---- | -------------------------------------------------------- |
-| bundleName | string | Yes | Bundle name of an application. |
-| callback | AsyncCallback\<[Want](js-apis-application-Want.md)> | Yes | Callback used to return the **Want** object.|
+| bundleName | string | Yes | Bundle name of the application. |
+| callback | AsyncCallback\<[Want](js-apis-application-want.md)> | Yes | Callback used to return the **Want** object.|
**Example**
-```js
+```ts
let bundleName = "com.example.myapplication";
bundle.getLaunchWantForBundle(bundleName, (err, data) => {
if (err) {
@@ -1413,7 +1558,7 @@ SystemCapability.BundleManager.BundleFramework
**Example**
-```js
+```ts
let uid = 20010005;
bundle.getNameForUid(uid)
.then((data) => {
@@ -1437,14 +1582,14 @@ SystemCapability.BundleManager.BundleFramework
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ---------------------- | ---- | ----------------------------------------------- |
-| uid | number | Yes | UID based on which the bundle name is to obtain. |
+| Name | Type | Mandatory | Description |
+|----------|------------------------|-----|----------------------------|
+| uid | number | Yes | UID based on which the bundle name is to obtain. |
| callback | AsyncCallback\ | Yes | Callback used to return the bundle name.|
**Example**
-```js
+```ts
let uid = 20010005;
bundle.getNameForUid(uid, (err, data) => {
if (err) {
@@ -1464,6 +1609,8 @@ getAbilityIcon(bundleName: string, abilityName: string): Promise\ | Yes | Callback used to return the [pixel map](js-apis-image.md).|
**Example**
-```js
+```ts
let bundleName = "com.example.myapplication";
let abilityName = "com.example.myapplication.MainAbility";
bundle.getAbilityIcon(bundleName, abilityName, (err, data) => {
@@ -1536,7 +1686,7 @@ bundle.getAbilityIcon(bundleName, abilityName, (err, data) => {
```
## InstallErrorCodedeprecated
-> This API is deprecated since API version 9. You are not advised to use it anymore.
+> This API is deprecated since API version 9. You are not advised using it anymore.
**System capability**: SystemCapability.BundleManager.BundleFramework
@@ -1567,7 +1717,11 @@ bundle.getAbilityIcon(bundleName, abilityName, (err, data) => {
> This API is deprecated since API version 9. You are advised to use [bundleManager.BundleFlag](js-apis-bundleManager.md#bundleflag) instead.
-Enumerates bundle flags.
+Enumerates the bundle flags, which indicate the type of bundle information to obtain.
+
+If an API does not match the flag, the flag is ignored. For example, using **GET_ABILITY_INFO_WITH_PERMISSION** to obtain the application information does not affect the result.
+
+Flags can be used together. For example, you can use the combination of **GET_APPLICATION_INFO_WITH_PERMISSION** and **GET_APPLICATION_INFO_WITH_DISABLE** to obtain the result that contains both application permission information and disabled application information.
**System capability**: SystemCapability.BundleManager.BundleFramework
@@ -1587,9 +1741,9 @@ Enumerates bundle flags.
| GET_ALL_APPLICATION_INFO | 0xFFFF0000 | Obtains all application information. |
## BundleOptionsdeprecated
-> This API is deprecated since API version 9. You are not advised to use it anymore.
+> This API is deprecated since API version 9. You are not advised using it anymore.
-Describes the bundle options.
+Options that contain the user ID.
**System capability**: SystemCapability.BundleManager.BundleFramework
@@ -1601,7 +1755,7 @@ Describes the bundle options.
> This API is deprecated since API version 9. You are advised to use [bundleManager.AbilityType](js-apis-bundleManager.md#abilitytype) instead.
-Enumerates ability types.
+Enumerates the ability types.
**System capability**: SystemCapability.BundleManager.BundleFramework
@@ -1630,7 +1784,7 @@ Enumerates display orientations.
> This API is deprecated since API version 9. You are advised to use [bundleManager.LaunchType](js-apis-bundleManager.md#launchtype) instead.
-Enumerates launch modes.
+Enumerates the ability launch modes.
**System capability**: SystemCapability.BundleManager.BundleFramework
@@ -1640,9 +1794,9 @@ Enumerates launch modes.
| STANDARD | 1 | The ability can have multiple instances. |
## AbilitySubTypedeprecated
-> This API is deprecated since API version 9. You are not advised to use it anymore.
+> This API is deprecated since API version 9. You are not advised using it anymore.
-Enumerates ability subtypes.
+Enumerates the ability subtypes.
**System capability**: SystemCapability.BundleManager.BundleFramework
@@ -1652,9 +1806,9 @@ Enumerates ability subtypes.
| CA | 1 | Ability that has a UI.|
## ColorModedeprecated
-> This API is deprecated since API version 9. You are not advised to use it anymore.
+> This API is deprecated since API version 9. You are not advised using it anymore.
-Enumerates color modes.
+Enumerates the color modes of applications and widgets.
**System capability**: SystemCapability.BundleManager.BundleFramework
@@ -1669,7 +1823,7 @@ Enumerates color modes.
> This API is deprecated since API version 9. You are advised to use [bundleManager.PermissionGrantState](js-apis-bundleManager.md#permissiongrantstate) instead.
-Enumerates permission grant states.
+Enumerates the permission grant states.
**System capability**: SystemCapability.BundleManager.BundleFramework
diff --git a/en/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md b/en/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md
index 7732457b6f32608db4c51f55e1cfa5ff0ee28ae8..a55ab990ef39072d83989526e66723eab794ca63 100644
--- a/en/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md
@@ -1,4 +1,4 @@
-# EnterpriseAdminExtensionAbility
+# @ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)
The **EnterpriseAdminExtensionAbility** module provides Extension abilities for enterprise administrators.
@@ -13,7 +13,7 @@ To have the capabilities provided by the module, for example, receiving the appl
## Modules to Import
```ts
-import EnterpriseAdminExtensionAbility from '@ohos.EnterpriseAdminExtensionAbility'
+import EnterpriseAdminExtensionAbility from '@ohos.enterprise.EnterpriseAdminExtensionAbility'
```
## EnterpriseAdminExtensionAbility.onAdminEnabled
@@ -24,6 +24,8 @@ Called when an enterprise administrator is enabled.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
+**System API**: This is a system API.
+
**Example**
```ts
@@ -41,6 +43,8 @@ Called when an enterprise administrator is disabled.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
+**System API**: This is a system API.
+
**Example**
```ts
@@ -58,6 +62,8 @@ Called when a bundle is added.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
+**System API**: This is a system API.
+
**Parameters**
| Parameter | Type | Mandatory | Description |
@@ -82,6 +88,8 @@ Called when a bundle is removed.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
+**System API**: This is a system API.
+
**Parameters**
| Parameter | Type | Mandatory | Description |
diff --git a/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md b/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md
index e7be32c9b840dbe67f99e120e3798ad5ecd9fcd4..a22f7b48a977066e085da4b9ddfcdeb24f21463f 100644
--- a/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md
@@ -1,4 +1,4 @@
-# Work Scheduler Callbacks
+# @ohos.WorkSchedulerExtensionAbility (Work Scheduler Callbacks)
The **WorkSchedulerExtensionAbility** module provides callbacks for Work Scheduler tasks.
diff --git a/en/application-dev/reference/apis/js-apis-ability-ability.md b/en/application-dev/reference/apis/js-apis-ability-ability.md
new file mode 100644
index 0000000000000000000000000000000000000000..37bf04c704a91f0580fddf99b14f9f52fb94d683
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-ability-ability.md
@@ -0,0 +1,39 @@
+# @ohos.ability.ability (Ability)
+
+The **Ability** module provides all level-2 module APIs for developers to export.
+
+> **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 can be used only in the FA model.
+
+## Modules to Import
+
+```ts
+import ability from '@ohos.ability.ability'
+```
+
+**System capability**: SystemCapability.Ability.AbilityBase
+
+| Name | Type | Mandatory| Description |
+| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
+| DataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | No | Level-2 module **DataAbilityHelper**. |
+| PacMap | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#PacMap) | No | Level-2 module **PacMap**.|
+| DataAbilityOperation | [DataAbilityOperation](js-apis-inner-ability-dataAbilityOperation.md) | No | Level-2 module **DataAbilityOperation**.|
+| DataAbilityResult | [DataAbilityResult](js-apis-inner-ability-dataAbilityResult.md) | No | Level-2 module **DataAbilityResult**.|
+| AbilityResult | [AbilityResult](js-apis-inner-ability-abilityResult.md) | No | Level-2 module **AbilityResult**.|
+| ConnectOptions | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | No | Level-2 module **ConnectOptions**.|
+| StartAbilityParameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | No | Level-2 module **StartAbilityParameter**.|
+
+**Example**
+```ts
+import ability from '@ohos.ability.ability';
+
+let dataAbilityHelper: ability.DataAbilityHelper;
+let pacMap: ability.PacMap;
+let dataAbilityOperation: ability.DataAbilityOperation;
+let dataAbilityResult: ability.DataAbilityResult;
+let abilityResult: ability.AbilityResult;
+let connectOptions: ability.ConnectOptions;
+let startAbilityParameter: ability.StartAbilityParameter;
+```
diff --git a/en/application-dev/reference/apis/js-apis-ability-context.md b/en/application-dev/reference/apis/js-apis-ability-context.md
index 40110bb6f928b5d76a9f916340cc7fce07975152..d345bbb9db0739da16156ecfc0bd4fe344989149 100644
--- a/en/application-dev/reference/apis/js-apis-ability-context.md
+++ b/en/application-dev/reference/apis/js-apis-ability-context.md
@@ -14,10 +14,10 @@ This module provides APIs for accessing ability-specific resources. You can use
Before using the **AbilityContext** module, you must define a child class that inherits from **Ability**.
```ts
-import Ability from '@ohos.app.ability.UIAbility';
+import UIAbility from '@ohos.app.ability.UIAbility';
- let context = undefined;
-class MainAbility extends Ability {
+let context = undefined;
+class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) {
context = this.context;
}
@@ -30,9 +30,9 @@ class MainAbility extends Ability {
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| abilityInfo | AbilityInfo | Yes| No| Ability information.|
-| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.|
-| config | [Configuration](js-apis-configuration.md) | Yes| No| Configuration information.|
+| abilityInfo | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes| No| Ability information.|
+| currentHapModuleInfo | [HapModuleInfo](js-apis-bundleManager-hapModuleInfo.md) | Yes| No| Information about the current HAP.|
+| config | [Configuration](js-apis-application-configuration.md) | Yes| No| Configuration information.|
## AbilityContext.startAbility
@@ -40,27 +40,33 @@ startAbility(want: Want, callback: AsyncCallback<void>): void;
Starts an ability. This API uses an asynchronous callback to return the result.
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
+
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
+| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
- bundleName: "com.example.myapp",
+ bundleName: "com.example.myapplication",
abilityName: "MyAbility"
};
@@ -89,30 +95,36 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void&
Starts an ability with the start options specified. This API uses an asynchronous callback to return the result.
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
+
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
-| options | [StartOptions](js-apis-application-StartOptions.md) | Yes| Parameters used for starting the ability.|
+| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
+| options | [StartOptions](js-apis-application-startOptions.md) | Yes| Parameters used for starting the ability.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
deviceId: "",
- bundleName: "com.extreme.test",
- abilityName: "MainAbility"
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
};
var options = {
windowMode: 0
@@ -142,14 +154,19 @@ startAbility(want: Want, options?: StartOptions): Promise<void>;
Starts an ability. This API uses a promise to return the result.
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
+
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
-| options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.|
+| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
+| options | [StartOptions](js-apis-application-startOptions.md) | No| Parameters used for starting the ability.|
**Return value**
@@ -161,14 +178,15 @@ Starts an ability. This API uses a promise to return the result.
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
- bundleName: "com.example.myapp",
+ bundleName: "com.example.myapplication",
abilityName: "MyAbility"
};
var options = {
@@ -198,7 +216,12 @@ Starts an ability. This API uses a promise to return the result.
startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): void;
-Starts an ability. This API uses an asynchronous callback to return the result when the ability is terminated.
+Starts an ability. After the ability is started, you can call [terminateSelfWithResult](#abilitycontextterminateselfwithresult) to terminate the ability and return the result to the caller. If an exception occurs, for example, the ability is killed, exception information is returned to the caller. This API uses an asynchronous callback to return the result.
+
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -206,23 +229,24 @@ Starts an ability. This API uses an asynchronous callback to return the result w
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want |[Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
-| callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.|
+| want |[Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
+| callback | AsyncCallback<[AbilityResult](js-apis-inner-ability-abilityResult.md)> | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
deviceId: "",
- bundleName: "com.extreme.test",
- abilityName: "MainAbility"
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
};
try {
@@ -248,7 +272,12 @@ Starts an ability. This API uses an asynchronous callback to return the result w
startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback<AbilityResult>): void;
-Starts an ability with start options specified. This API uses an asynchronous callback to return the result when the ability is terminated.
+Starts an ability with the start options specified. After the ability is started, you can call [terminateSelfWithResult](#abilitycontextterminateselfwithresult) to terminate the ability and return the result to the caller. If an exception occurs, for example, the ability is killed, exception information is returned to the caller. This API uses an asynchronous callback to return the result.
+
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -256,24 +285,25 @@ Starts an ability with start options specified. This API uses an asynchronous ca
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want |[Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
-| options | [StartOptions](js-apis-application-StartOptions.md) | Yes| Parameters used for starting the ability.|
-| callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.|
+| want |[Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
+| options | [StartOptions](js-apis-application-startOptions.md) | Yes| Parameters used for starting the ability.|
+| callback | AsyncCallback<[AbilityResult](js-apis-inner-ability-abilityResult.md)> | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
deviceId: "",
- bundleName: "com.extreme.test",
- abilityName: "MainAbility"
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
};
var options = {
windowMode: 0,
@@ -303,7 +333,12 @@ Starts an ability with start options specified. This API uses an asynchronous ca
startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityResult>;
-Starts an ability. This API uses a promise to return the result when the ability is terminated.
+Starts an ability. After the ability is started, you can call [terminateSelfWithResult](#abilitycontextterminateselfwithresult) to terminate the ability and return the result to the caller. If an exception occurs, for example, the ability is killed, exception information is returned to the caller. This API uses a promise to return the result.
+
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -311,28 +346,29 @@ Starts an ability. This API uses a promise to return the result when the ability
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
-| options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.|
+| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
+| options | [StartOptions](js-apis-application-startOptions.md) | No| Parameters used for starting the ability.|
**Return value**
| Type| Description|
| -------- | -------- |
-| Promise<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Promise used to return the result.|
+| Promise<[AbilityResult](js-apis-inner-ability-abilityResult.md)> | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
- bundleName: "com.example.myapp",
+ bundleName: "com.example.myapplication",
abilityName: "MyAbility"
};
var options = {
@@ -361,9 +397,14 @@ Starts an ability. This API uses a promise to return the result when the ability
startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback\): void;
-Starts an ability. This API uses an asynchronous callback to return the result when the account of the ability is destroyed.
+Starts an ability with the account ID specified. This API uses an asynchronous callback to return the result when the ability is terminated.
+
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
+**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -373,24 +414,25 @@ Starts an ability. This API uses an asynchronous callback to return the result w
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
+| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
-| callback | AsyncCallback\ | Yes| Callback used to return the result.|
+| callback | AsyncCallback\<[AbilityResult](js-apis-inner-ability-abilityResult.md)\> | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
deviceId: "",
- bundleName: "com.extreme.test",
- abilityName: "MainAbility"
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
};
var accountId = 100;
@@ -418,9 +460,14 @@ Starts an ability. This API uses an asynchronous callback to return the result w
startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback\): void;
-Starts an ability with start options specified. This API uses an asynchronous callback to return the result when the account of the ability is destroyed.
+Starts an ability with the start options and account ID specified. This API uses an asynchronous callback to return the result when the ability is terminated.
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
+
+**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -430,25 +477,26 @@ Starts an ability with start options specified. This API uses an asynchronous ca
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
+| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
-| options | [StartOptions](js-apis-application-StartOptions.md) | Yes| Parameters used for starting the ability.|
+| options | [StartOptions](js-apis-application-startOptions.md) | Yes| Parameters used for starting the ability.|
| callback | AsyncCallback\ | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
deviceId: "",
- bundleName: "com.extreme.test",
- abilityName: "MainAbility"
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
};
var accountId = 100;
var options = {
@@ -479,9 +527,14 @@ Starts an ability with start options specified. This API uses an asynchronous ca
startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartOptions): Promise\;
-Starts an ability with start options specified. This API uses a promise to return the result when the account of the ability is destroyed.
+Starts an ability with the account ID specified. This API uses a promise to return the result when the ability is terminated.
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
+
+**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -491,30 +544,31 @@ Starts an ability with start options specified. This API uses a promise to retur
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
+| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
-| options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.|
+| options | [StartOptions](js-apis-application-startOptions.md) | No| Parameters used for starting the ability.|
**Return value**
| Type| Description|
| -------- | -------- |
-| Promise<AbilityResult> | Promise used to return the result.|
+| Promise<[AbilityResult](js-apis-inner-ability-abilityResult.md)> | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
deviceId: "",
- bundleName: "com.extreme.test",
- abilityName: "MainAbility"
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
};
var accountId = 100;
var options = {
@@ -543,7 +597,7 @@ Starts an ability with start options specified. This API uses a promise to retur
startServiceExtensionAbility(want: Want, callback: AsyncCallback\): void;
-Starts a new Service Extension ability. This API uses an asynchronous callback to return the result.
+Starts a ServiceExtensionAbility. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -553,23 +607,24 @@ Starts a new Service Extension ability. This API uses an asynchronous callback t
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
+| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| callback | AsyncCallback\ | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
deviceId: "",
- bundleName: "com.extreme.test",
- abilityName: "MainAbility"
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
};
try {
@@ -594,7 +649,7 @@ Starts a new Service Extension ability. This API uses an asynchronous callback t
startServiceExtensionAbility(want: Want): Promise\;
-Starts a new Service Extension ability. This API uses a promise to return the result.
+Starts a ServiceExtensionAbility. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -604,22 +659,23 @@ Starts a new Service Extension ability. This API uses a promise to return the re
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
+| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
deviceId: "",
- bundleName: "com.extreme.test",
- abilityName: "MainAbility"
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
};
try {
@@ -644,9 +700,9 @@ Starts a new Service Extension ability. This API uses a promise to return the re
startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\): void;
-Starts a new Service Extension ability with the account ID specified. This API uses an asynchronous callback to return the result.
+Starts a ServiceExtensionAbility with the account ID specified. This API uses an asynchronous callback to return the result.
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
+**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -656,7 +712,7 @@ Starts a new Service Extension ability with the account ID specified. This API u
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
+| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
| callback | AsyncCallback\ | Yes| Callback used to return the result.|
@@ -664,16 +720,17 @@ Starts a new Service Extension ability with the account ID specified. This API u
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
deviceId: "",
- bundleName: "com.extreme.test",
- abilityName: "MainAbility"
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
};
var accountId = 100;
@@ -699,9 +756,9 @@ Starts a new Service Extension ability with the account ID specified. This API u
startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\;
-Starts a new Service Extension ability with the account ID specified. This API uses a promise to return the result.
+Starts a ServiceExtensionAbility with the account ID specified. This API uses a promise to return the result.
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
+**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -711,23 +768,24 @@ Starts a new Service Extension ability with the account ID specified. This API u
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
+| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
deviceId: "",
- bundleName: "com.extreme.test",
- abilityName: "MainAbility"
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
};
var accountId = 100;
@@ -752,7 +810,7 @@ Starts a new Service Extension ability with the account ID specified. This API u
stopServiceExtensionAbility(want: Want, callback: AsyncCallback\): void;
-Stops a Service Extension ability in the same application. This API uses an asynchronous callback to return the result.
+Stops a ServiceExtensionAbility in the same application. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -762,28 +820,35 @@ Stops a Service Extension ability in the same application. This API uses an asyn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
+| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| callback | AsyncCallback\ | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
deviceId: "",
- bundleName: "com.extreme.test",
- abilityName: "MainAbility"
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
};
try {
+ this.context.startAbility(want, (error) => {
+ if (error.code != 0) {
+ console.log("start ability fail, err: " + JSON.stringify(err));
+ }
+ })
+
this.context.stopServiceExtensionAbility(want, (error) => {
- if (error.code) {
+ if (error.code != 0) {
// Process service logic errors.
console.log('stopServiceExtensionAbility failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
@@ -803,7 +868,7 @@ Stops a Service Extension ability in the same application. This API uses an asyn
stopServiceExtensionAbility(want: Want): Promise\;
-Stops a Service Extension ability in the same application. This API uses a promise to return the result.
+Stops a ServiceExtensionAbility in the same application. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -813,25 +878,32 @@ Stops a Service Extension ability in the same application. This API uses a promi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
+| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
deviceId: "",
- bundleName: "com.extreme.test",
- abilityName: "MainAbility"
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
};
try {
+ this.context.startAbility(want, (error) => {
+ if (error.code != 0) {
+ console.log("start ability fail, err: " + JSON.stringify(err));
+ }
+ })
+
this.context.stopServiceExtensionAbility(want)
.then((data) => {
// Carry out normal service processing.
@@ -853,9 +925,9 @@ Stops a Service Extension ability in the same application. This API uses a promi
stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\): void;
-Stops a Service Extension ability in the same application with the account ID specified. This API uses an asynchronous callback to return the result.
+Stops a ServiceExtensionAbility in the same application with the account ID specified. This API uses an asynchronous callback to return the result.
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
+**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -865,7 +937,7 @@ Stops a Service Extension ability in the same application with the account ID sp
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
+| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
| callback | AsyncCallback\ | Yes| Callback used to return the result.|
@@ -873,20 +945,27 @@ Stops a Service Extension ability in the same application with the account ID sp
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
deviceId: "",
- bundleName: "com.extreme.test",
- abilityName: "MainAbility"
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
};
var accountId = 100;
try {
+ this.context.startAbilityWithAccount(want, accountId, (error) => {
+ if (error.code != 0) {
+ console.log("start ability fail, err: " + JSON.stringify(err));
+ }
+ })
+
this.context.stopServiceExtensionAbilityWithAccount(want, accountId, (error) => {
if (error.code) {
// Process service logic errors.
@@ -908,9 +987,9 @@ Stops a Service Extension ability in the same application with the account ID sp
stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\;
-Stops a Service Extension ability in the same application with the account ID specified. This API uses a promise to return the result.
+Stops a ServiceExtensionAbility in the same application with the account ID specified. This API uses a promise to return the result.
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
+**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -920,27 +999,34 @@ Stops a Service Extension ability in the same application with the account ID sp
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
+| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
deviceId: "",
- bundleName: "com.extreme.test",
- abilityName: "MainAbility"
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
};
var accountId = 100;
try {
+ this.context.startAbilityWithAccount(want, accountId, (error) => {
+ if (error.code != 0) {
+ console.log("start ability fail, err: " + JSON.stringify(err));
+ }
+ })
+
this.context.stopServiceExtensionAbilityWithAccount(want, accountId)
.then((data) => {
// Carry out normal service processing.
@@ -976,8 +1062,9 @@ Terminates this ability. This API uses an asynchronous callback to return the re
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
@@ -1013,8 +1100,9 @@ Terminates this ability. This API uses a promise to return the result.
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
@@ -1034,7 +1122,7 @@ Terminates this ability. This API uses a promise to return the result.
terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<void>): void;
-Terminates this ability. This API uses an asynchronous callback to return the ability result information. It is used together with **startAbilityForResult**.
+Terminates this ability. If the ability is started by calling [startAbilityForResult](#abilitycontextstartabilityforresult), the result is returned to the caller in the form of a callback when **terminateSelfWithResult** is called. Otherwise, no result is returned to the caller when **terminateSelfWithResult** is called.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -1042,15 +1130,16 @@ Terminates this ability. This API uses an asynchronous callback to return the ab
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.|
+| parameter | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Yes| Information returned to the caller.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
@@ -1088,8 +1177,7 @@ Terminates this ability. This API uses an asynchronous callback to return the ab
## AbilityContext.terminateSelfWithResult
terminateSelfWithResult(parameter: AbilityResult): Promise<void>;
-
-Terminates this ability. This API uses a promise to return the ability result information. It is used together with **startAbilityForResult**.
+Terminates this ability. If the ability is started by calling [startAbilityForResult](#abilitycontextstartabilityforresult), the result is returned to the caller in the form of a promise when **terminateSelfWithResult** is called. Otherwise, no result is returned to the caller when **terminateSelfWithResult** is called.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -1097,7 +1185,7 @@ Terminates this ability. This API uses a promise to return the ability result in
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.|
+| parameter | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Yes| Information returned to the caller.|
**Return value**
@@ -1109,8 +1197,9 @@ Terminates this ability. This API uses a promise to return the ability result in
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
@@ -1153,12 +1242,14 @@ Uses the **AbilityInfo.AbilityType.SERVICE** template to connect this ability to
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
-| options | [ConnectOptions](js-apis-featureAbility.md#connectoptions) | Yes| Parameters for the connection.|
+| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
+| options | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | Yes| Parameters for the connection.|
**Return value**
@@ -1170,16 +1261,17 @@ Uses the **AbilityInfo.AbilityType.SERVICE** template to connect this ability to
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
deviceId: "",
- bundleName: "com.extreme.test",
- abilityName: "MainAbility"
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
};
var options = {
onConnect(elementName, remote) { console.log('----------- onConnect -----------') },
@@ -1202,9 +1294,9 @@ Uses the **AbilityInfo.AbilityType.SERVICE** template to connect this ability to
connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number;
-Uses the **AbilityInfo.AbilityType.SERVICE** template and account ID to connect this ability to another ability with the account ID specified.
+Uses the **AbilityInfo.AbilityType.SERVICE** template to connect this ability to another ability with the account ID specified.
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
+**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -1214,9 +1306,9 @@ Uses the **AbilityInfo.AbilityType.SERVICE** template and account ID to connect
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
+| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
-| options | [ConnectOptions](js-apis-featureAbility.md#connectoptions) | Yes| Parameters for the connection.|
+| options | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | Yes| Parameters for the connection.|
**Return value**
@@ -1228,16 +1320,17 @@ Uses the **AbilityInfo.AbilityType.SERVICE** template and account ID to connect
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
deviceId: "",
- bundleName: "com.extreme.test",
- abilityName: "MainAbility"
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
};
var accountId = 100;
var options = {
@@ -1280,13 +1373,14 @@ Disconnects a connection. This API uses a promise to return the result.
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
- // connection is the return value of connectAbility.
+ // connection is the return value of connectServiceExtensionAbility.
var connection = 1;
try {
@@ -1326,8 +1420,9 @@ Disconnects a connection. This API uses an asynchronous callback to return the r
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
@@ -1359,6 +1454,11 @@ startAbilityByCall(want: Want): Promise<Caller>;
Starts an ability in the foreground or background and obtains the caller object for communicating with the ability.
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - The rules for using this API in the same-device and cross-device scenarios are different. For details, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
+
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
@@ -1367,7 +1467,7 @@ Starts an ability in the foreground or background and obtains the caller object
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, including **abilityName**, **moduleName**, **bundleName**, **deviceId** (optional), and **parameters** (optional). If **deviceId** is left blank or null, the local ability is started. If **parameters** is left blank or null, the ability is started in the background.|
+| want | [Want](js-apis-application-want.md) | Yes| Information about the ability to start, including **abilityName**, **moduleName**, **bundleName**, **deviceId** (optional), and **parameters** (optional). If **deviceId** is left blank or null, the local ability is started. If **parameters** is left blank or null, the ability is started in the background.|
**Return value**
@@ -1386,7 +1486,7 @@ Starts an ability in the foreground or background and obtains the caller object
var wantBackground = {
bundleName: "com.example.myservice",
moduleName: "entry",
- abilityName: "MainAbility",
+ abilityName: "EntryAbility",
deviceId: ""
};
@@ -1417,7 +1517,7 @@ Starts an ability in the foreground or background and obtains the caller object
var wantForeground = {
bundleName: "com.example.myservice",
moduleName: "entry",
- abilityName: "MainAbility",
+ abilityName: "EntryAbility",
deviceId: "",
parameters: {
"ohos.aafwk.param.callAbilityToForeground": true
@@ -1448,7 +1548,12 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<
Starts an ability with the account ID specified. This API uses an asynchronous callback to return the result.
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
+
+**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -1458,7 +1563,7 @@ Starts an ability with the account ID specified. This API uses an asynchronous c
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
+| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
| callback | AsyncCallback\ | Yes| Callback used to return the result.|
@@ -1466,16 +1571,17 @@ Starts an ability with the account ID specified. This API uses an asynchronous c
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
deviceId: "",
- bundleName: "com.extreme.test",
- abilityName: "MainAbility"
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
};
var accountId = 100;
@@ -1504,7 +1610,12 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca
Starts an ability with the account ID and start options specified. This API uses an asynchronous callback to return the result.
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
+
+**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -1514,25 +1625,26 @@ Starts an ability with the account ID and start options specified. This API uses
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
+| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
-| options | [StartOptions](js-apis-application-StartOptions.md) | Yes| Parameters used for starting the ability.|
+| options | [StartOptions](js-apis-application-startOptions.md) | Yes| Parameters used for starting the ability.|
| callback | AsyncCallback\ | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
deviceId: "",
- bundleName: "com.extreme.test",
- abilityName: "MainAbility"
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
};
var accountId = 100;
var options = {
@@ -1564,7 +1676,12 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions):
Starts an ability with the account ID specified. This API uses a promise to return the result.
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
+
+**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -1574,24 +1691,25 @@ Starts an ability with the account ID specified. This API uses a promise to retu
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Want information about the target ability.|
+| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
-| options | [StartOptions](js-apis-application-StartOptions.md) | Yes| Parameters used for starting the ability.|
+| options | [StartOptions](js-apis-application-startOptions.md) | No| Parameters used for starting the ability.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| Other IDs| See [Ability Error Codes](../errorcodes/errorcode-ability.md).|
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
var want = {
deviceId: "",
- bundleName: "com.extreme.test",
- abilityName: "MainAbility"
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
};
var accountId = 100;
var options = {
@@ -1616,65 +1734,6 @@ Starts an ability with the account ID specified. This API uses a promise to retu
}
```
-## AbilityContext.requestPermissionsFromUser
-
-requestPermissionsFromUser(permissions: Array<string>, requestCallback: AsyncCallback<PermissionRequestResult>) : void;
-
-Requests permissions from the user by displaying a dialog box. This API uses an asynchronous callback to return the result.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| permissions | Array<string> | Yes| Permissions to request.|
-| callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Yes| Callback used to return the result.|
-
-**Example**
-
- ```ts
- var permissions=['com.example.permission']
- this.context.requestPermissionsFromUser(permissions,(result) => {
- console.log('requestPermissionsFromUserresult:' + JSON.stringify(result));
- });
-
- ```
-
-
-## AbilityContext.requestPermissionsFromUser
-
-requestPermissionsFromUser(permissions: Array<string>) : Promise<PermissionRequestResult>;
-
-Requests permissions from the user by displaying a dialog box. This API uses a promise to return the result.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| permissions | Array<string> | Yes| Permissions to request.|
-
-**Return value**
-
-| Type| Description|
-| -------- | -------- |
-| Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Promise used to return the result.|
-
-**Example**
-
- ```ts
- var permissions=['com.example.permission']
- this.context.requestPermissionsFromUser(permissions).then((data) => {
- console.log('success:' + JSON.stringify(data));
- }).catch((error) => {
- console.log('failed:' + JSON.stringify(error));
- });
-
- ```
-
-
## AbilityContext.setMissionLabel
setMissionLabel(label: string, callback:AsyncCallback<void>): void;
@@ -1694,7 +1753,7 @@ Sets a label for this ability in the mission. This API uses an asynchronous call
```ts
this.context.setMissionLabel("test",(result) => {
- console.log('requestPermissionsFromUserresult:' + JSON.stringify(result));
+ console.log('setMissionLabel result:' + JSON.stringify(result));
});
```
@@ -1742,7 +1801,7 @@ Sets an icon for this ability in the mission. This API uses an asynchronous call
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| icon | image.PixelMap | Yes| Icon of the ability to set.|
+| icon | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes| Icon of the ability to set.|
| callback | AsyncCallback\ | Yes| Callback used to return the result.|
**Example**
@@ -1784,7 +1843,7 @@ Sets an icon for this ability in the mission. This API uses a promise to return
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| icon | image.PixelMap | Yes| Icon of the ability to set.|
+| icon | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes| Icon of the ability to set.|
**Return value**
diff --git a/en/application-dev/reference/apis/js-apis-DataUriUtils.md b/en/application-dev/reference/apis/js-apis-ability-dataUriUtils.md
similarity index 71%
rename from en/application-dev/reference/apis/js-apis-DataUriUtils.md
rename to en/application-dev/reference/apis/js-apis-ability-dataUriUtils.md
index 18cfa0cdc0c54ea8e8aa85fc43fcf61b3d63fc7a..f1301ad877dcf5a0bd2fec5ad5be10452ee88716 100644
--- a/en/application-dev/reference/apis/js-apis-DataUriUtils.md
+++ b/en/application-dev/reference/apis/js-apis-ability-dataUriUtils.md
@@ -1,6 +1,6 @@
-# DataUriUtils
+# @ohos.ability.dataUriUtils (dataUriUtils)
-The **DataUriUtils** module provides APIs to handle utility classes for objects using the **DataAbilityHelper** schema. You can use the APIs to attach an ID to the end of a given URI and obtain, delete, or update the ID attached to the end of a given URI.
+The **DataUriUtils** module provides APIs to process URI objects. You can use the APIs to attach an ID to the end of a given URI and obtain, delete, or update the ID attached to the end of a given URI. This module will be replaced by the **app.ability.dataUriUtils** module in the near future. You are advised to use the **[@ohos.app.ability.dataUriUtils](js-apis-app-ability-dataUriUtils.md)** module.
> **NOTE**
>
@@ -8,7 +8,7 @@ The **DataUriUtils** module provides APIs to handle utility classes for objects
## Modules to Import
-```js
+```ts
import dataUriUtils from '@ohos.ability.dataUriUtils';
```
@@ -24,18 +24,18 @@ Obtains the ID attached to the end of a given URI.
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- |
-| uri | string | Yes | URI object from which the ID is to be obtained.|
+| uri | string | Yes | Target URI object.|
**Return value**
| Type | Description |
| ------ | ------------------------ |
-| number | ID obtained from the URI object.|
+| number | ID obtained.|
**Example**
-```js
-dataUriUtils.getId("com.example.dataUriUtils/1221")
+```ts
+let id = dataUriUtils.getId("com.example.dataUriUtils/1221");
```
@@ -52,7 +52,7 @@ Attaches an ID to the end of a given URI.
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- |
-| uri | string | Yes | URI object to which an ID is to be attached.|
+| uri | string | Yes | Target URI object.|
| id | number | Yes | ID to be attached. |
**Return value**
@@ -63,11 +63,11 @@ Attaches an ID to the end of a given URI.
**Example**
-```js
-var idint = 1122;
-dataUriUtils.attachId(
+```ts
+let id = 1122;
+let uri = dataUriUtils.attachId(
"com.example.dataUriUtils",
- idint,
+ id,
)
```
@@ -95,8 +95,8 @@ Deletes the ID from the end of a given URI.
**Example**
-```js
-dataUriUtils.deleteId("com.example.dataUriUtils/1221")
+```ts
+let uri = dataUriUtils.deleteId("com.example.dataUriUtils/1221")
```
@@ -113,7 +113,7 @@ Updates the ID in a given URI.
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | ------------------- |
-| uri | string | Yes | URI object to be updated.|
+| uri | string | Yes | Target URI object.|
| id | number | Yes | New ID. |
**Return value**
@@ -124,10 +124,10 @@ Updates the ID in a given URI.
**Example**
-```js
-var idint = 1122;
-dataUriUtils.updateId(
- "com.example.dataUriUtils",
- idint
+```ts
+let id = 1122;
+let uri = dataUriUtils.updateId(
+ "com.example.dataUriUtils/1221",
+ id
)
```
diff --git a/en/application-dev/reference/apis/js-apis-ability-errorCode.md b/en/application-dev/reference/apis/js-apis-ability-errorCode.md
index 6a131521d3c447cfb2df65b53a592c5be89678be..dc0e8ae8928a9191f70b555e84a3f58b09e4b876 100644
--- a/en/application-dev/reference/apis/js-apis-ability-errorCode.md
+++ b/en/application-dev/reference/apis/js-apis-ability-errorCode.md
@@ -1,6 +1,6 @@
-# ErrorCode
+# @ohos.ability.errorCode (ErrorCode)
-The **ErrorCode** module defines the error codes that can be used when the ability is started.
+The **ErrorCode** module defines the error codes that may be returned when an ability is started.
> **NOTE**
>
@@ -8,19 +8,19 @@ The **ErrorCode** module defines the error codes that can be used when the abili
## Modules to Import
-```
+```ts
import errorCode from '@ohos.ability.errorCode'
```
## ErrorCode
-Defines the error codes used when the ability is started.
+Enumerates the error codes that may be returned when an ability is started.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ------------------------------ | ---- | ---------------------------------------- |
-| NO_ERROR | 0 | No error occurs. |
+| NO_ERROR | 0 | No error. |
| INVALID_PARAMETER | -1 | Invalid parameter.|
| ABILITY_NOT_FOUND | -2 | The ability is not found.|
| PERMISSION_DENY | -3 | Permission denied. |
diff --git a/en/application-dev/reference/apis/js-apis-featureAbility.md b/en/application-dev/reference/apis/js-apis-ability-featureAbility.md
similarity index 63%
rename from en/application-dev/reference/apis/js-apis-featureAbility.md
rename to en/application-dev/reference/apis/js-apis-ability-featureAbility.md
index 66999a98279dc43aa0fee542883a6ed70ad5ee8d..b527edfcf7911fec83b4e8d5a01a2761772e95f1 100644
--- a/en/application-dev/reference/apis/js-apis-featureAbility.md
+++ b/en/application-dev/reference/apis/js-apis-ability-featureAbility.md
@@ -1,6 +1,6 @@
-# FeatureAbility
+# @ohos.ability.featureAbility (FeatureAbility)
-The **FeatureAbility** module provides a UI for interacting with users. You can use APIs of this module to start a new ability, obtain the **dataAbilityHelper**, set a Page ability, obtain the window corresponding to this ability, and connect to a Service ability.
+The **FeatureAbility** module provides APIs that enable user interaction. You can use the APIs to start or terminate an ability, obtain a **dataAbilityHelper** object, obtain the window corresponding to the current ability, and connect to or disconnect from a ServiceAbility.
> **NOTE**
>
@@ -9,11 +9,11 @@ The **FeatureAbility** module provides a UI for interacting with users. You can
## Constraints
-APIs of the **FeatureAbility** module can be called only by Page abilities.
+The APIs of the **FeatureAbility** module can be called only by PageAbilities.
## Modules to Import
-```
+```ts
import featureAbility from '@ohos.ability.featureAbility';
```
@@ -23,18 +23,23 @@ startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\)
Starts an ability. This API uses an asynchronous callback to return the result.
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
+
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
-| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
+| parameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | Yes | Ability to start.|
| callback | AsyncCallback\ | Yes | Callback used to return the result. |
**Example**
-```javascript
+```ts
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
featureAbility.startAbility(
@@ -48,7 +53,7 @@ featureAbility.startAbility(
deviceId: "",
bundleName: "com.example.myapplication",
/* In the FA model, abilityName consists of package and ability names. */
- abilityName: "com.example.entry.secondAbility",
+ abilityName: "com.example.myapplication.secondAbility",
uri: ""
},
},
@@ -66,17 +71,28 @@ startAbility(parameter: StartAbilityParameter): Promise\
Starts an ability. This API uses a promise to return the result.
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
+
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
-| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
+| parameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | Yes | Ability to start.|
+
+**Return value**
+
+| Type | Description |
+| ---------------------------------------- | ------- |
+| Promise\ | Promise used to return the result.|
**Example**
-```javascript
+```ts
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
featureAbility.startAbility(
@@ -90,7 +106,7 @@ featureAbility.startAbility(
deviceId: "",
bundleName: "com.example.myapplication",
/* In the FA model, abilityName consists of package and ability names. */
- abilityName: "com.example.entry.secondAbility",
+ abilityName: "com.example.myapplication.secondAbility",
uri: ""
},
}
@@ -105,6 +121,12 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper
Obtains a **dataAbilityHelper** object.
+Observe the following when using this API:
+ - To access a DataAbility of another application, the target application must be configured with associated startup (**AssociateWakeUp** set to **true**).
+ - If an application running in the background needs to call this API to access a DataAbility, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
+
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -117,11 +139,11 @@ Obtains a **dataAbilityHelper** object.
| Type | Description |
| ----------------- | ------------------------------- |
-| DataAbilityHelper | A utility class used to help other abilities access the Data ability.|
+| [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | A utility class used to help other abilities access the Data ability.|
**Example**
-```javascript
+```ts
import featureAbility from '@ohos.ability.featureAbility';
var dataAbilityHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
@@ -132,7 +154,12 @@ var dataAbilityHelper = featureAbility.acquireDataAbilityHelper(
startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback\): void
-Starts an ability. This API uses an asynchronous callback to return the execution result when the ability is destroyed.
+Starts an ability. After the ability is started, you can call [terminateSelfWithResult](#featureabilityterminateselfwithresult7) to terminate the ability and return the result to the caller. If an exception occurs, for example, the ability is killed, exception information is returned to the caller. This API uses an asynchronous callback to return the result.
+
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
@@ -140,12 +167,12 @@ Starts an ability. This API uses an asynchronous callback to return the executio
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
-| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
-| callback | AsyncCallback\<[AbilityResult](#abilityresult)> | Yes | Callback used to return the result. |
+| parameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | Yes | Ability to start.|
+| callback | AsyncCallback\<[AbilityResult](js-apis-inner-ability-abilityResult.md)> | Yes | Callback used to return the result. |
**Example**
-```javascript
+```ts
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
featureAbility.startAbilityForResult(
@@ -159,7 +186,7 @@ featureAbility.startAbilityForResult(
deviceId: "",
bundleName: "com.example.myapplication",
/* In the FA model, abilityName consists of package and ability names. */
- abilityName: "com.example.entry.secondAbility",
+ abilityName: "com.example.myapplication.secondAbility",
uri:""
},
},
@@ -173,7 +200,12 @@ featureAbility.startAbilityForResult(
startAbilityForResult(parameter: StartAbilityParameter): Promise\
-Starts an ability. This API uses a promise to return the execution result when the ability is destroyed.
+Starts an ability. After the ability is started, you can call [terminateSelfWithResult](#featureabilityterminateselfwithresult7) to terminate the ability and return the result to the caller. If an exception occurs, for example, the ability is killed, exception information is returned to the caller. This API uses a promise to return the result.
+
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
@@ -181,17 +213,17 @@ Starts an ability. This API uses a promise to return the execution result when t
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | ------------- |
-| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
+| parameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | Yes | Ability to start.|
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
-| Promise\<[AbilityResult](#abilityresult)> | Promised returned with the execution result.|
+| Promise\<[AbilityResult](js-apis-inner-ability-abilityResult.md)> | Promise used to return the result.|
**Example**
-```javascript
+```ts
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
featureAbility.startAbilityForResult(
@@ -205,7 +237,7 @@ featureAbility.startAbilityForResult(
deviceId: "",
bundleName: "com.example.myapplication",
/* In the FA model, abilityName consists of package and ability names. */
- abilityName: "com.example.entry.secondAbility",
+ abilityName: "com.example.myapplication.secondAbility",
uri:"",
parameters:
{
@@ -229,7 +261,7 @@ featureAbility.startAbilityForResult(
terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback\): void
-Destroys this Page ability, with the result code and data sent to the caller. This API uses an asynchronous callback to return the result.
+Terminates this ability. If the ability is started by calling [startAbilityForResult](#featureabilitystartabilityforresult7), the result is returned to the caller in the form of a callback when **terminateSelfWithResult** is called. Otherwise, no result is returned to the caller when **terminateSelfWithResult** is called.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
@@ -237,12 +269,12 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
| Name | Type | Mandatory | Description |
| --------- | ------------------------------- | ---- | -------------- |
-| parameter | [AbilityResult](#abilityresult) | Yes | Ability to destroy.|
+| parameter | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Yes | Result returned after the ability is terminated.|
| callback | AsyncCallback\ | Yes | Callback used to return the result. |
**Example**
-```javascript
+```ts
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
featureAbility.terminateSelfWithResult(
@@ -257,7 +289,7 @@ featureAbility.terminateSelfWithResult(
deviceId: "",
bundleName: "com.example.myapplication",
/* In the FA model, abilityName consists of package and ability names. */
- abilityName: "com.example.entry.secondAbility",
+ abilityName: "com.example.myapplication.secondAbility",
uri:"",
parameters: {
mykey0: 2222,
@@ -281,7 +313,7 @@ featureAbility.terminateSelfWithResult(
terminateSelfWithResult(parameter: AbilityResult): Promise\
-Destroys this Page ability, with the result code and data sent to the caller. This API uses a promise to return the result.
+Terminates this ability. If the ability is started by calling [startAbilityForResult](#featureabilitystartabilityforresult7), the result is returned to the caller in the form of a promise when **terminateSelfWithResult** is called. Otherwise, no result is returned to the caller when **terminateSelfWithResult** is called.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
@@ -289,7 +321,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
| Name | Type | Mandatory | Description |
| --------- | ------------------------------- | ---- | ------------- |
-| parameter | [AbilityResult](#abilityresult) | Yes | Ability to destroy.|
+| parameter | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Yes | Result returned after the ability is terminated.|
**Return value**
@@ -299,7 +331,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Example**
-```javascript
+```ts
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
featureAbility.terminateSelfWithResult(
@@ -314,7 +346,7 @@ featureAbility.terminateSelfWithResult(
deviceId: "",
bundleName: "com.example.myapplication",
/* In the FA model, abilityName consists of package and ability names. */
- abilityName: "com.example.entry.secondAbility",
+ abilityName: "com.example.myapplication.secondAbility",
uri:"",
parameters: {
mykey0: 2222,
@@ -345,11 +377,11 @@ Checks whether the main window of this ability has the focus. This API uses an a
| Name | Type | Mandatory | Description |
| -------- | ----------------------- | ---- | ---------------------------------------- |
-| callback | AsyncCallback\ | Yes | Callback used to return the result.
Returns **true** if the main window of this ability has the focus; returns **false** otherwise.|
+| callback | AsyncCallback\ | Yes | Callback used to return the result.
If the main window has the focus, **true** is returned. Otherwise, **false** is returned.|
**Example**
-```javascript
+```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.hasWindowFocus((err, data) => {
console.info("hasWindowFocus err: " + JSON.stringify(err) + "data: " + JSON.stringify(data));
@@ -368,11 +400,11 @@ Checks whether the main window of this ability has the focus. This API uses a pr
| Type | Description |
| ----------------- | ------------------------------------- |
-| Promise\ | Returns **true** if the main window of this ability has the focus; returns **false** otherwise.|
+| Promise\ | Promise used to return the result. If the main window has the focus, **true** is returned. Otherwise, **false** is returned.|
**Example**
-```javascript
+```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.hasWindowFocus().then((data) => {
console.info("hasWindowFocus data: " + JSON.stringify(data));
@@ -383,7 +415,7 @@ featureAbility.hasWindowFocus().then((data) => {
getWant(callback: AsyncCallback\): void
-Obtains the **Want** object sent from this ability. This API uses an asynchronous callback to return the result.
+Obtains the Want corresponding to the ability to start. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
@@ -391,11 +423,11 @@ Obtains the **Want** object sent from this ability. This API uses an asynchronou
| Name | Type | Mandatory | Description |
| -------- | ----------------------------- | ---- | --------- |
-| callback | AsyncCallback\<[Want](js-apis-application-Want.md)> | Yes | Callback used to return the result.|
+| callback | AsyncCallback\<[Want](js-apis-application-want.md)> | Yes | Callback used to return the Want.|
**Example**
-```javascript
+```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.getWant((err, data) => {
console.info("getWant err: " + JSON.stringify(err) + "data: " + JSON.stringify(data));
@@ -406,7 +438,7 @@ featureAbility.getWant((err, data) => {
getWant(): Promise\
-Obtains the **Want** object sent from this ability. This API uses a promise to return the result.
+Obtains the Want corresponding to the ability to start. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
@@ -414,11 +446,11 @@ Obtains the **Want** object sent from this ability. This API uses a promise to r
| Type | Description |
| ----------------------- | ---------------- |
-| Promise\<[Want](js-apis-application-Want.md)> | Promise used to return the result.|
+| Promise\<[Want](js-apis-application-want.md)> | Promise used to return the Want.|
**Example**
-```javascript
+```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.getWant().then((data) => {
console.info("getWant data: " + JSON.stringify(data));
@@ -441,7 +473,7 @@ Obtains the application context.
**Example**
-```javascript
+```ts
import featureAbility from '@ohos.ability.featureAbility';
var context = featureAbility.getContext()
context.getBundleName((err, data) => {
@@ -453,7 +485,7 @@ context.getBundleName((err, data) => {
terminateSelf(callback: AsyncCallback\): void
-Destroys this Page ability, with the result code and data sent to the caller. This API uses an asynchronous callback to return the result.
+Terminates this ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
@@ -465,7 +497,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Example**
-```javascript
+```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.terminateSelf(
(err) => {
@@ -478,7 +510,7 @@ featureAbility.terminateSelf(
terminateSelf(): Promise\
-Destroys this Page ability, with the result code and data sent to the caller. This API uses a promise to return the result.
+Terminates this ability. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
@@ -490,7 +522,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Example**
-```javascript
+```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.terminateSelf().then((data) => {
console.info("==========================>terminateSelf=======================>");
@@ -501,7 +533,13 @@ featureAbility.terminateSelf().then((data) => {
connectAbility(request: Want, options:ConnectOptions): number
-Connects this ability to a specific Service ability. This API uses an asynchronous callback to return the result.
+Connects this ability to a ServiceAbility.
+
+Observe the following when using this API:
+ - To connect to a ServiceAbility of another application, the target application must be configured with associated startup (**AssociateWakeUp** set to **true**)..
+ - If an application running in the background needs to call this API to connect to a ServiceAbility, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
@@ -509,30 +547,18 @@ Connects this ability to a specific Service ability. This API uses an asynchrono
| Name | Type | Mandatory | Description |
| ------- | -------------- | ---- | --------------------- |
-| request | [Want](js-apis-application-Want.md) | Yes | Service ability to connect.|
-| options | [ConnectOptions](#connectoptions) | Yes | Callback used to return the result. |
-
-## ConnectOptions
-
-Describes the connection options.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-| Name | Readable|Writable| Type | Mandatory | Description |
-| ------------ | -- | -- | -------- | ---- | ------------------------- |
-| onConnect7+ | Yes|No | function | Yes | Callback invoked when the connection is successful. |
-| onDisconnect7+ | Yes|No | function | Yes | Callback invoked when the connection fails. |
-| onFailed7+ | Yes|No | function | Yes | Callback invoked when **connectAbility** fails to be called.|
+| request | [Want](js-apis-application-want.md) | Yes | ServiceAbility to connect.|
+| options | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | Yes | Connection options. |
**Return value**
| Type | Description |
| ------ | -------------------- |
-| number | ID of the Service ability connected.|
+| number | ID of the connected ServiceAbility. The ID starts from 0 and is incremented by 1 each time a connection is set up.|
**Example**
-```javascript
+```ts
import rpc from '@ohos.rpc';
import featureAbility from '@ohos.ability.featureAbility';
function onConnectCallback(element, remote){
@@ -548,7 +574,7 @@ var connectId = featureAbility.connectAbility(
{
deviceId: "",
bundleName: "com.ix.ServiceAbility",
- abilityName: "ServiceAbilityA",
+ abilityName: "com.ix.ServiceAbility.ServiceAbilityA",
},
{
onConnect: onConnectCallback,
@@ -562,7 +588,7 @@ var connectId = featureAbility.connectAbility(
disconnectAbility(connection: number, callback:AsyncCallback\): void
-Disconnects this ability from a specific Service ability. This API uses an asynchronous callback to return the result.
+Disconnects this ability from a specific ServiceAbility. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
@@ -570,12 +596,12 @@ Disconnects this ability from a specific Service ability. This API uses an async
| Name | Type | Mandatory | Description |
| ---------- | -------------------- | ---- | ----------------------- |
-| connection | number | Yes | ID of the Service ability to disconnect.|
+| connection | number | Yes | ID of the ServiceAbility to disconnect.|
| callback | AsyncCallback\ | Yes | Callback used to return the result. |
**Example**
-```javascript
+```ts
import rpc from '@ohos.rpc';
import featureAbility from '@ohos.ability.featureAbility';
function onConnectCallback(element, remote){
@@ -590,7 +616,7 @@ function onFailedCallback(code){
var connectId = featureAbility.connectAbility(
{
bundleName: "com.ix.ServiceAbility",
- abilityName: "ServiceAbilityA",
+ abilityName: "com.ix.ServiceAbility.ServiceAbilityA",
},
{
onConnect: onConnectCallback,
@@ -609,7 +635,7 @@ var result = featureAbility.disconnectAbility(connectId,
disconnectAbility(connection: number): Promise\
-Disconnects this ability from a specific Service ability. This API uses a promise to return the result.
+Disconnects this ability from a specific ServiceAbility. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
@@ -617,7 +643,7 @@ Disconnects this ability from a specific Service ability. This API uses a promis
| Name | Type | Mandatory | Description |
| ---------- | ------ | ---- | ----------------------- |
-| connection | number | Yes | ID of the Service ability to disconnect.|
+| connection | number | Yes | ID of the ServiceAbility to disconnect.|
**Return value**
@@ -627,7 +653,7 @@ Disconnects this ability from a specific Service ability. This API uses a promis
**Example**
-```javascript
+```ts
import rpc from '@ohos.rpc';
import featureAbility from '@ohos.ability.featureAbility';
function onConnectCallback(element, remote){
@@ -642,7 +668,7 @@ function onFailedCallback(code){
var connectId = featureAbility.connectAbility(
{
bundleName: "com.ix.ServiceAbility",
- abilityName: "ServiceAbilityA",
+ abilityName: "com.ix.ServiceAbility.ServiceAbilityA",
},
{
onConnect: onConnectCallback,
@@ -671,11 +697,11 @@ Obtains the window corresponding to this ability. This API uses an asynchronous
| Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | ----------------------------- |
-| callback | AsyncCallback\ | Yes | Callback used to return the window.|
+| callback | AsyncCallback\<[window.Window](js-apis-window.md#window)> | Yes | Callback used to return the window.|
**Example**
-```javascript
+```ts
featureAbility.getWindow((err, data) => {
console.info("getWindow err: " + JSON.stringify(err) + "data: " + typeof(data));
});
@@ -693,150 +719,19 @@ Obtains the window corresponding to this ability. This API uses a promise to ret
| Type | Description |
| ----------------------- | ----------------------------- |
-| Promise\ | Promise used to return the window.|
+| Promise\<[window.Window](js-apis-window.md#window)> | Promise used to return the window.|
**Example**
-```javascript
+```ts
featureAbility.getWindow().then((data) => {
console.info("getWindow data: " + typeof(data));
});
```
-## ConnectOptions.onConnect7+
-
-onConnect(elementName: ElementName, remote: rpc.IRemoteObject): void;
-
-Callback invoked when the connection is successful.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| ----------- | ----------------- | ---- | -------- |
-| elementName | ElementName | Yes | Element name. |
-| remote | rpc.IRemoteObject | Yes | RPC remote object.|
-
-**Example**
-
-```javascript
-import rpc from '@ohos.rpc';
-import featureAbility from '@ohos.ability.featureAbility';
-function onConnectCallback(element, remote){
- console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
-}
-function onDisconnectCallback(element){
- console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
-}
-function onFailedCallback(code){
- console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code)
-}
-var connectId = featureAbility.connectAbility(
- {
- deviceId: "",
- bundleName: "com.ix.ServiceAbility",
- abilityName: "ServiceAbilityA",
- },
- {
- onConnect: onConnectCallback,
- onDisconnect: onDisconnectCallback,
- onFailed: onFailedCallback,
- },
-);
-```
-
-## ConnectOptions.onDisconnect7+
-
-onDisconnect(elementName: ElementName): void;
-
-Callback invoked when the connection fails.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| ----------- | ----------- | ---- | ---- |
-| elementName | ElementName | Yes | Element name.|
-
-**Example**
-
-```javascript
-import rpc from '@ohos.rpc';
-import featureAbility from '@ohos.ability.featureAbility';
-function onConnectCallback(element, remote){
- console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
-}
-function onDisconnectCallback(element){
- console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
-}
-function onFailedCallback(code){
- console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code)
-}
-var connectId = featureAbility.connectAbility(
- {
- deviceId: "",
- bundleName: "com.ix.ServiceAbility",
- abilityName: "ServiceAbilityA",
- },
- {
- onConnect: onConnectCallback,
- onDisconnect: onDisconnectCallback,
- onFailed: onFailedCallback,
- },
-);
-```
-
-## ConnectOptions.onFailed7+
-
-onFailed(code: number): void;
-
-Callback invoked when **connectAbility** fails to be called.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| ---- | ------ | ---- | --------- |
-| code | number | Yes | Number type.|
-
-**Example**
-
-```javascript
-import rpc from '@ohos.rpc';
-import featureAbility from '@ohos.ability.featureAbility';
-function onConnectCallback(element, remote){
- console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
-}
-function onDisconnectCallback(element){
- console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
-}
-function onFailedCallback(code){
- console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code)
-}
-var connectId = featureAbility.connectAbility(
- {
- deviceId: "",
- bundleName: "com.ix.ServiceAbility",
- abilityName: "ServiceAbilityA",
- },
- {
- onConnect: onConnectCallback,
- onDisconnect: onDisconnectCallback,
- onFailed: onFailedCallback,
- },
-);
-```
-
-
-
-
-
## AbilityWindowConfiguration
-The value is obtained through the **featureAbility.AbilityWindowConfiguration** API.
+Defines the window configuration corresponding to this ability. The configuration is obtained through **featureAbility.AbilityWindowConfiguration**.
**Example**
@@ -848,18 +743,18 @@ featureAbility.AbilityWindowConfiguration.WINDOW_MODE_UNDEFINED
| Name | Value | Description |
| ---------------------------------------- | ---- | ---------------------------------------- |
-| WINDOW_MODE_UNDEFINED7+ | 0 | The Page ability is in an undefined window display mode.|
-| WINDOW_MODE_FULLSCREEN7+ | 1 | The Page ability is in full screen mode. |
-| WINDOW_MODE_SPLIT_PRIMARY7+ | 100 | The Page ability is displayed in the primary window when it is in split-screen mode.|
-| WINDOW_MODE_SPLIT_SECONDARY7+ | 101 | The Page ability is displayed in the secondary window when it is in split-screen mode.|
-| WINDOW_MODE_FLOATING7+ | 102 | The Page ability is displayed in floating window mode.|
+| WINDOW_MODE_UNDEFINED7+ | 0 | The PageAbility is in an undefined window display mode.|
+| WINDOW_MODE_FULLSCREEN7+ | 1 | The PageAbility is in full screen mode. |
+| WINDOW_MODE_SPLIT_PRIMARY7+ | 100 | The PageAbility is displayed in the primary window when it is in split-screen mode.|
+| WINDOW_MODE_SPLIT_SECONDARY7+ | 101 | The PageAbility is displayed in the secondary window when it is in split-screen mode.|
+| WINDOW_MODE_FLOATING7+ | 102 | The PageAbility is displayed in floating window mode.|
## AbilityStartSetting
-The **AbilityStartSetting** attribute is an object defined as [key: string]: any. The key is a type of **AbilityStartSetting**, and the value is a type of **AbilityWindowConfiguration**.
+Defines the window attribute corresponding to this ability. The **abilityStartSetting** attribute is an object defined in the format of [**key: string]: any**, where **key** is an enumerated value of **AbilityStartSetting** and **value** is an enumerated value of **AbilityWindowConfiguration**.
-The value is obtained through the **featureAbility.AbilityStartSetting** API.
+The value is obtained through **featureAbility.AbilityStartSetting**.
**Example**
@@ -877,7 +772,7 @@ featureAbility.AbilityStartSetting.BOUNDS_KEY
## ErrorCode
-Enumerates error codes.
+Enumerates the error codes.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
@@ -886,12 +781,12 @@ Enumerates error codes.
| NO_ERROR7+ | 0 | No error occurs.|
| INVALID_PARAMETER7+ | -1 | Invalid parameter.|
| ABILITY_NOT_FOUND7+ | -2 | The ability is not found.|
-| PERMISSION_DENY7+ | -3 | The request is denied.|
+| PERMISSION_DENY7+ | -3 | Permission denied.|
## DataAbilityOperationType
-Enumerates operation types of the Data ability.
+Enumerates the operation types of a DataAbility. The DataAbility can use an enumerated value to specify the operation type when operating data in batches.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
@@ -902,45 +797,27 @@ Enumerates operation types of the Data ability.
| TYPE_DELETE7+ | 3 | Deletion operation.|
| TYPE_ASSERT7+ | 4 | Assert operation.|
-
-
-## AbilityResult
-
-**System capability**: SystemCapability.Ability.AbilityBase
-
-| Name | Type | Readable| Writable | Mandatory | Description |
-| --------------- |-------- | ------ | ------------- | ---- | ------------------------------------- |
-| resultCode7+| number| Yes | No | Yes | Result code returned after the ability is destroyed. The feature for defining error-specific result codes is coming soon.|
-| want7+ | [Want](js-apis-application-Want.md)| Yes | No| No | Data returned after the ability is destroyed. You can define the data to be returned. This parameter can be **null**. |
-
-## StartAbilityParameter
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
-
-| Name | Type | Readable| Writable | Mandatory | Description |
-| ------------------- | -------- | -------------------- | ---- | -------------------------------------- |
-| want | [Want](js-apis-application-Want.md)| Yes | No | Yes | Information about the ability to start. |
-| abilityStartSetting | {[key: string]: any} | Yes |No | No | Special attribute of the ability to start. This attribute can be passed in the method call.|
-
## flags
+Enumerates the flags that specify how the Want will be handled.
+
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Value | Description |
| ------------------------------------ | ---------- | ---------------------------------------- |
-| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. |
-| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI. |
+| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Grants the permission to read the URI. |
+| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Grants the permission to write data to the URI. |
| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability. |
-| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be migrated to a remote device. |
+| FLAG_ABILITY_CONTINUATION | 0x00000008 | Continues the ability on a remote device. |
| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS. |
-| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates whether to enable an ability. |
-| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.
**System API**: This is a system API and cannot be called by third-party applications. |
-| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.
**System API**: This is a system API and cannot be called by third-party applications. |
-| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler. |
-| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started.
**System API**: This is a system API and cannot be called by third-party applications. |
+| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates whether the FormAbility is enabled. |
+| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Grants the permission to make the URI persistent.
**System API**: This is a system API and cannot be called by third-party applications. |
+| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Grants the permission to verify URIs by prefix matching.
**System API**: This is a system API and cannot be called by third-party applications. |
+| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Indicates the support for cross-device startup in the distributed scheduler. |
+| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the ability is started in the foreground regardless of whether the host application is started.
**System API**: This is a system API and cannot be called by third-party applications. |
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible. |
| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. |
| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. |
| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object in the **startAbility** API passed to [ohos.app.Context](js-apis-ability-context.md) and must be used together with **flag_ABILITY_NEW_MISSION**.|
-| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the historical mission stack. |
-| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.|
+| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on an existing mission stack. |
+| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Reuses an ability instance if it is on the top of an existing mission stack; creates an ability instance otherwise.|
diff --git a/en/application-dev/reference/apis/js-apis-particleAbility.md b/en/application-dev/reference/apis/js-apis-ability-particleAbility.md
similarity index 60%
rename from en/application-dev/reference/apis/js-apis-particleAbility.md
rename to en/application-dev/reference/apis/js-apis-ability-particleAbility.md
index 75b6378962fb1f3c25bcf7e12a0a2df20a151628..7d00454ea5ce5b0051c2fff6856f9653be89b455 100644
--- a/en/application-dev/reference/apis/js-apis-particleAbility.md
+++ b/en/application-dev/reference/apis/js-apis-ability-particleAbility.md
@@ -1,6 +1,6 @@
-# particleAbility
+# @ohos.ability.particleAbility (ParticleAbility)
-The **particleAbility** module provides APIs for Service abilities. You can use the APIs to start and terminate a Particle ability, obtain a **dataAbilityHelper** object, connect the current ability to a specific Service ability, and disconnect the current ability from a specific Service ability.
+The **particleAbility** module provides APIs for operating a ServiceAbility. You can use the APIs to start and terminate a ParticleAbility, obtain a **dataAbilityHelper** object, and connect to or disconnect from a ServiceAbility.
> **NOTE**
>
@@ -13,7 +13,7 @@ The ParticleAbility module is used to perform operations on abilities of the Dat
## Modules to Import
-```js
+```ts
import particleAbility from '@ohos.ability.particleAbility'
```
@@ -21,25 +21,30 @@ import particleAbility from '@ohos.ability.particleAbility'
startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\): void
-Starts a Particle ability. This API uses an asynchronous callback to return the result.
+Starts a ParticleAbility. This API uses an asynchronous callback to return the result.
+
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
-
| Name | Type | Mandatory| Description |
| --------- | ----------------------------------------------- | ---- | ----------------- |
-| parameter | [StartAbilityParameter](js-apis-featureAbility.md#startabilityparameter) | Yes | Ability to start.|
+| parameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | Yes | Ability to start.|
| callback | AsyncCallback\ | Yes | Callback used to return the result. |
**Example**
-```js
+```ts
import particleAbility from '@ohos.ability.particleAbility'
import wantConstant from '@ohos.ability.wantConstant'
+
particleAbility.startAbility(
- {
+ {
want:
{
action: "action.system.home",
@@ -48,32 +53,34 @@ particleAbility.startAbility(
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "",
bundleName: "com.example.Data",
- abilityName: "com.example.Data.MainAbility",
- uri:""
+ abilityName: "EntryAbility",
+ uri: ""
},
},
(error, result) => {
- console.log('particleAbility startAbility errCode:' + error + 'result:' + result)
+ console.log('particleAbility startAbility errCode:' + error + 'result:' + result)
},
)
```
-
-
## particleAbility.startAbility
startAbility(parameter: StartAbilityParameter): Promise\;
-Starts a Particle ability. This API uses a promise to return the result.
+Starts a ParticleAbility. This API uses a promise to return the result.
+
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
-
| Name | Type | Mandatory| Description |
| --------- | ----------------------------------------------- | ---- | ----------------- |
-| parameter | [StartAbilityParameter](js-apis-featureAbility.md#startabilityparameter) | Yes | Ability to start.|
+| parameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | Yes | Ability to start.|
**Return value**
@@ -83,11 +90,12 @@ Starts a Particle ability. This API uses a promise to return the result.
**Example**
-```js
+```ts
import particleAbility from '@ohos.ability.particleAbility'
import wantConstant from '@ohos.ability.wantConstant'
+
particleAbility.startAbility(
- {
+ {
want:
{
action: "action.system.home",
@@ -96,8 +104,8 @@ particleAbility.startAbility(
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "",
bundleName: "com.example.Data",
- abilityName: "com.example. Data.MainAbility",
- uri:""
+ abilityName: "EntryAbility",
+ uri: ""
},
},
).then((data) => {
@@ -105,13 +113,11 @@ particleAbility.startAbility(
});
```
-
-
## particleAbility.terminateSelf
terminateSelf(callback: AsyncCallback\): void
-Terminates this Particle ability. This API uses an asynchronous callback to return the result.
+Terminates this ParticleAbility. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
@@ -123,22 +129,21 @@ Terminates this Particle ability. This API uses an asynchronous callback to retu
**Example**
-```js
+```ts
import particleAbility from '@ohos.ability.particleAbility'
+
particleAbility.terminateSelf(
(error, result) => {
- console.log('particleAbility terminateSelf errCode:' + error + 'result:' + result)
+ console.log('particleAbility terminateSelf errCode:' + error + 'result:' + result)
}
)
```
-
-
## particleAbility.terminateSelf
terminateSelf(): Promise\
-Terminates this Particle ability. This API uses a promise to return the result.
+Terminates this ParticleAbility. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
@@ -150,8 +155,9 @@ Terminates this Particle ability. This API uses a promise to return the result.
**Example**
-```js
+```ts
import particleAbility from '@ohos.ability.particleAbility'
+
particleAbility.terminateSelf().then((data) => {
console.info("particleAbility terminateSelf");
});
@@ -165,6 +171,12 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper
Obtains a **dataAbilityHelper** object.
+Observe the following when using this API:
+ - To access a DataAbility of another application, the target application must be configured with associated startup (**AssociateWakeUp** set to **true**).
+ - If an application running in the background needs to call this API to access a DataAbility, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
+
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
@@ -177,12 +189,13 @@ Obtains a **dataAbilityHelper** object.
| Type | Description |
| ----------------- | -------------------------------------------- |
-| DataAbilityHelper | A utility class used to help other abilities access a Data ability.|
+| [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | A utility class used to help other abilities access a DataAbility.|
**Example**
-```js
-import particleAbility from '@ohos.ability.particleAbility'
+```ts
+import particleAbility from '@ohos.ability.particleAbility'
+
var uri = "";
particleAbility.acquireDataAbilityHelper(uri)
```
@@ -208,7 +221,7 @@ Requests a continuous task from the system. This API uses an asynchronous callba
**Example**
-```js
+```ts
import notification from '@ohos.notification';
import particleAbility from '@ohos.ability.particleAbility';
import wantAgent from '@ohos.wantAgent';
@@ -225,7 +238,7 @@ let wantAgentInfo = {
wants: [
{
bundleName: "com.example.myapplication",
- abilityName: "com.example.myapplication.MainAbility"
+ abilityName: "EntryAbility"
}
],
operationType: wantAgent.OperationType.START_ABILITY,
@@ -277,7 +290,7 @@ Requests a continuous task from the system. This API uses a promise to return th
**Example**
-```js
+```ts
import notification from '@ohos.notification';
import particleAbility from '@ohos.ability.particleAbility';
import wantAgent from '@ohos.wantAgent';
@@ -286,7 +299,7 @@ let wantAgentInfo = {
wants: [
{
bundleName: "com.example.myapplication",
- abilityName: "com.example.myapplication.MainAbility"
+ abilityName: "EntryAbility"
}
],
operationType: wantAgent.OperationType.START_ABILITY,
@@ -333,7 +346,7 @@ Requests to cancel a continuous task from the system. This API uses an asynchron
**Example**
-```js
+```ts
import particleAbility from '@ohos.ability.particleAbility';
function callback(err, data) {
@@ -352,7 +365,7 @@ particleAbility.cancelBackgroundRunning(callback);
cancelBackgroundRunning(): Promise<void>;
-Requests a continuous task from the system. This API uses a promise to return the result. You are advised to use the new API [backgroundTaskManager.stopBackgroundRunning](js-apis-backgroundTaskManager.md#backgroundtaskmanagerstopbackgroundrunning8-1).
+Requests to cancel a continuous task from the system. This API uses a promise to return the result. You are advised to use the new API [backgroundTaskManager.stopBackgroundRunning](js-apis-backgroundTaskManager.md#backgroundtaskmanagerstopbackgroundrunning8-1).
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
@@ -364,7 +377,7 @@ Requests a continuous task from the system. This API uses a promise to return th
**Example**
-```js
+```ts
import particleAbility from '@ohos.ability.particleAbility';
particleAbility.cancelBackgroundRunning().then(() => {
@@ -375,12 +388,17 @@ particleAbility.cancelBackgroundRunning().then(() => {
```
-
## particleAbility.connectAbility
connectAbility(request: Want, options:ConnectOptions): number
-Connects this ability to a specific Service ability. This API uses a callback to return the result.
+Connects this ability to a specific ServiceAbility.
+
+Observe the following when using this API:
+ - To connect to a ServiceAbility of another application, the target application must be configured with associated startup (**AssociateWakeUp** set to **true**)..
+ - If an application running in the background needs to call this API to connect to a ServiceAbility, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+ - For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
@@ -388,60 +406,53 @@ Connects this ability to a specific Service ability. This API uses a callback to
| Name | Type | Mandatory| Description |
| ------- | -------------- | ---- | ---------------------------- |
-| request | [Want](js-apis-application-Want.md) | Yes | Service ability to connect.|
-| options | ConnectOptions | Yes | Callback used to return the result. |
+| request | [Want](js-apis-application-want.md) | Yes | ServiceAbility to connect.|
+| options | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | Yes | Connection options. |
-ConnectOptions
+**Example**
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+```ts
+import particleAbility from '@ohos.ability.particleAbility'
+import rpc from '@ohos.rpc'
-| Name | Readable/Writable| Type | Mandatory | Description |
-| ------------ | ---- | -------- | ---- | ------------------------- |
-| onConnect | Read only | function | Yes | Callback invoked when the connection is successful. |
-| onDisconnect | Read only | function | Yes | Callback invoked when the connection fails. |
-| onFailed | Read only | function | Yes | Callback invoked when **connectAbility** fails to be called.|
+function onConnectCallback(element, remote) {
+ console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
+}
-**Example**
+function onDisconnectCallback(element) {
+ console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
+}
-```js
- import rpc from '@ohos.rpc'
- function onConnectCallback(element, remote){
- console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
- }
- function onDisconnectCallback(element){
- console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
- }
- function onFailedCallback(code){
- console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
- }
- var connId = particleAbility.connectAbility(
- {
- bundleName: "com.ix.ServiceAbility",
- abilityName: "ServiceAbilityA",
- },
- {
- onConnect: onConnectCallback,
- onDisconnect: onDisconnectCallback,
- onFailed: onFailedCallback,
- },
- );
-
- particleAbility.disconnectAbility(connId).then((data)=>{
- console.log( " data: " + data);
- }).catch((error)=>{
- console.log('particleAbilityTest result errCode : ' + error.code )
- });
-
+function onFailedCallback(code) {
+ console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
+}
-```
+var connId = particleAbility.connectAbility(
+ {
+ bundleName: "com.ix.ServiceAbility",
+ abilityName: "ServiceAbilityA",
+ },
+ {
+ onConnect: onConnectCallback,
+ onDisconnect: onDisconnectCallback,
+ onFailed: onFailedCallback,
+ },
+);
+particleAbility.disconnectAbility(connId).then((data) => {
+ console.log(" data: " + data);
+}).catch((error) => {
+ console.log('particleAbilityTest result errCode : ' + error.code)
+});
+
+```
## particleAbility.disconnectAbility
disconnectAbility(connection: number, callback:AsyncCallback\): void;
-Disconnects this ability from the Service ability. This API uses a callback to return the result.
+Disconnects this ability from a specific ServiceAbility. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
@@ -453,34 +464,38 @@ Disconnects this ability from the Service ability. This API uses a callback to r
**Example**
-```js
-import rpc from '@ohos.rpc'
- function onConnectCallback(element, remote){
- console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
- }
- function onDisconnectCallback(element){
- console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
- }
- function onFailedCallback(code){
- console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
- }
- var connId = particleAbility.connectAbility(
- {
- bundleName: "com.ix.ServiceAbility",
- abilityName: "ServiceAbilityA",
- },
- {
- onConnect: onConnectCallback,
- onDisconnect: onDisconnectCallback,
- onFailed: onFailedCallback,
- },
- );
- var result = particleAbility.disconnectAbility(connId).then((data)=>{
- console.log( " data: " + data);
- }).catch((error)=>{
- console.log('particleAbilityTest result errCode : ' + error.code )
- });
+```ts
+import particleAbility from '@ohos.ability.particleAbility';
+import rpc from '@ohos.rpc';
+function onConnectCallback(element, remote) {
+ console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
+}
+
+function onDisconnectCallback(element) {
+ console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
+}
+
+function onFailedCallback(code) {
+ console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
+}
+
+var connId = particleAbility.connectAbility(
+ {
+ bundleName: "com.ix.ServiceAbility",
+ abilityName: "ServiceAbilityA",
+ },
+ {
+ onConnect: onConnectCallback,
+ onDisconnect: onDisconnectCallback,
+ onFailed: onFailedCallback,
+ },
+);
+var result = particleAbility.disconnectAbility(connId).then((data) => {
+ console.log(" data: " + data);
+}).catch((error) => {
+ console.log('particleAbilityTest result errCode : ' + error.code)
+});
```
@@ -488,7 +503,7 @@ import rpc from '@ohos.rpc'
disconnectAbility(connection: number): Promise\;
-Disconnects this ability from the Service ability. This API uses a promise to return the result.
+Disconnects this ability from a specific ServiceAbility. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
@@ -500,40 +515,45 @@ Disconnects this ability from the Service ability. This API uses a promise to re
**Example**
-```js
-import rpc from '@ohos.rpc'
-function onConnectCallback(element, remote){
- console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
- }
- function onDisconnectCallback(element){
- console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
- }
- function onFailedCallback(code){
- console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
- }
- var connId = particleAbility.connectAbility(
- {
- bundleName: "com.ix.ServiceAbility",
- abilityName: "ServiceAbilityA",
- },
- {
- onConnect: onConnectCallback,
- onDisconnect: onDisconnectCallback,
- onFailed: onFailedCallback,
- },
- );
-
- particleAbility.disconnectAbility(connId).then((data)=>{
- console.log( " data: " + data);
- }).catch((error)=>{
- console.log('particleAbilityTest result errCode : ' + error.code )
- });
+```ts
+import particleAbility from '@ohos.ability.particleAbility';
+import rpc from '@ohos.rpc';
+
+function onConnectCallback(element, remote) {
+ console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
+}
+
+function onDisconnectCallback(element) {
+ console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
+}
+
+function onFailedCallback(code) {
+ console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
+}
+
+var connId = particleAbility.connectAbility(
+ {
+ bundleName: "com.ix.ServiceAbility",
+ abilityName: "ServiceAbilityA",
+ },
+ {
+ onConnect: onConnectCallback,
+ onDisconnect: onDisconnectCallback,
+ onFailed: onFailedCallback,
+ },
+);
+
+particleAbility.disconnectAbility(connId).then((data) => {
+ console.log(" data: " + data);
+}).catch((error) => {
+ console.log('particleAbilityTest result errCode : ' + error.code)
+});
```
## ErrorCode
-Enumerates error codes.
+Enumerates the error codes.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
diff --git a/en/application-dev/reference/apis/js-apis-ability-wantConstant.md b/en/application-dev/reference/apis/js-apis-ability-wantConstant.md
index 4b1a66f071f464d6662d8429606c48aa025e8ef6..87b52688c5bec0a80bc44d9c8dcba63fe00283f2 100644
--- a/en/application-dev/reference/apis/js-apis-ability-wantConstant.md
+++ b/en/application-dev/reference/apis/js-apis-ability-wantConstant.md
@@ -1,20 +1,20 @@
-# wantConstant
+# @ohos.ability.wantConstant (wantConstant)
The **wantConstant** module provides the actions, entities, and flags used in **Want** objects.
> **NOTE**
>
-> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module are supported since API version 6 and deprecated since API version 9. You are advised to use [@ohos.app.ability.wantConstant](js-apis-app-ability-wantConstant.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
-```js
+```ts
import wantConstant from '@ohos.ability.wantConstant';
```
## wantConstant.Action
-Enumerates the action constants of the **Want** object.
+Enumerates the action constants of the **Want** object. **action** specifies the operation to execute.
**System capability**: SystemCapability.Ability.AbilityBase
@@ -46,6 +46,7 @@ Enumerates the action constants of the **Want** object.
| ACTION_FILE_SELECT7+ | ohos.action.fileSelect | Action of selecting a file. |
| PARAMS_STREAM7+ | ability.params.stream | URI of the data stream associated with the target when the data is sent. |
| ACTION_APP_ACCOUNT_OAUTH 8+ | ohos.account.appAccount.action.oauth | Action of providing the OAuth service. |
+| ACTION_APP_ACCOUNT_AUTH 9+ | account.appAccount.action.auth | Action of providing the authentication service. |
| ACTION_MARKET_DOWNLOAD 9+ | ohos.want.action.marketDownload | Action of downloading an application from the application market.
**System API**: This is a system API and cannot be called by third-party applications. |
| ACTION_MARKET_CROWDTEST 9+ | ohos.want.action.marketCrowdTest | Action of crowdtesting an application from the application market.
**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_SANDBOX9+ |ohos.dlp.params.sandbox | Action of obtaining the sandbox flag.
**System API**: This is a system API and cannot be called by third-party applications. |
@@ -56,7 +57,7 @@ Enumerates the action constants of the **Want** object.
## wantConstant.Entity
-Enumerates the entity constants of the **Want** object.
+Enumerates the entity constants of the **Want** object. **entity** specifies additional information of the target ability.
**System capability**: SystemCapability.Ability.AbilityBase
@@ -71,25 +72,25 @@ Enumerates the entity constants of the **Want** object.
## wantConstant.Flags
-Describes flags.
+Enumerates the flags that specify how the Want will be handled.
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Value | Description |
| ------------------------------------ | ---------- | ------------------------------------------------------------ |
-| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. |
-| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write data to the URI. |
+| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Grants the permission to read the URI. |
+| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Grants the permission to write data to the URI. |
| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability. |
| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be continued on a remote device. |
| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS. |
| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates that an ability is enabled. |
-| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.
**System API**: This is a system API and cannot be called by third-party applications. |
-| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.
**System API**: This is a system API and cannot be called by third-party applications.|
-| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler. |
-| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started. |
+| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Grants the permission to make the URI persistent.
**System API**: This is a system API and cannot be called by third-party applications. |
+| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Grants the permission to verify URIs by prefix matching.
**System API**: This is a system API and cannot be called by third-party applications.|
+| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Indicates the support for cross-device startup in the distributed scheduler. |
+| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the ServiceAbility is started regardless of whether the host application has been started. |
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that ability continuation is reversible.
**System API**: This is a system API and cannot be called by third-party applications. |
| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. |
| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. |
| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object in the **startAbility** API passed to [ohos.app.Context](js-apis-ability-context.md) and must be used together with **flag_ABILITY_NEW_MISSION**.|
-| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Indicates the operation of creating a mission on the history mission stack. |
-| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.|
+| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the history mission stack. |
+| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Reuses an ability instance if it is on the top of an existing mission stack; creates an ability instance otherwise.|
diff --git a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md
index d593cf5a61697773be5837287f0e63d33cff3ce8..88ffbc6255e15705d88259e65392fa9e4f6a3193 100644
--- a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md
+++ b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md
@@ -1,4 +1,4 @@
-# Ability Access Control
+# @ohos.abilityAccessCtrl (Application Access Control)
The **AbilityAccessCtrl** module provides APIs for application permission management, including authentication, authorization, and revocation.
@@ -40,7 +40,7 @@ Implements ability access control.
checkAccessToken(tokenID: number, permissionName: Permissions): Promise<GrantStatus>
-Checks whether an application has the specified permission. This API uses a promise to return the result.
+Checks whether a permission is granted to an application. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.AccessToken
@@ -48,8 +48,8 @@ Checks whether an application has the specified permission. This API uses a prom
| Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | ------------------------------------------ |
-| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundle-ApplicationInfo.md). |
-| permissionName | Permissions | Yes | Permission to check.|
+| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundleManager-applicationInfo.md). |
+| permissionName | Permissions | Yes | Permission to check. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
**Return value**
@@ -71,7 +71,7 @@ For details about the error codes, see [Ability Access Control Error Codes](../e
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
-let tokenID = 0; // You can use getApplicationInfo to obtain the access token ID.
+let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
try {
atManager.checkAccessToken(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS").then((data) => {
console.log(`checkAccessToken success, data->${JSON.stringify(data)}`);
@@ -87,7 +87,7 @@ try {
verifyAccessTokenSync(tokenID: number, permissionName: Permissions): GrantStatus
-Verifies whether an application has the specified permission. This API returns the result synchronously.
+Verifies whether a permission is granted to an application. This API returns the result synchronously.
**System capability**: SystemCapability.Security.AccessToken
@@ -95,8 +95,8 @@ Verifies whether an application has the specified permission. This API returns t
| Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | ------------------------------------------ |
-| tokenID | number | Yes | Token ID of the application. |
-| permissionName | Permissions | Yes | Name of the permission to verify.|
+| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundleManager-applicationInfo.md). |
+| permissionName | Permissions | Yes | Permission to verify. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
**Return value**
@@ -116,7 +116,7 @@ For details about the error codes, see [Ability Access Control Error Codes](../e
```js
let atManager = abilityAccessCtrl.createAtManager();
-let tokenID = 0;
+let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let data = atManager.verifyAccessTokenSync(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
console.log(`data->${JSON.stringify(data)}`);
```
@@ -137,8 +137,8 @@ Grants a user_grant permission to an application. This API uses a promise to ret
| Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
-| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundle-ApplicationInfo.md). |
-| permissionName | Permissions | Yes | Name of the permission to grant.|
+| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundleManager-applicationInfo.md). |
+| permissionName | Permissions | Yes | Permission to grant. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
| permissionFlag | number | Yes | Permission flag. The value **1** means that the permission request dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
**Return value**
@@ -165,7 +165,7 @@ For details about the error codes, see [Ability Access Control Error Codes](../e
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
-let tokenID = 0; // You can use getApplicationInfo to obtain the access token ID.
+let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let permissionFlag = 1;
try {
atManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlag).then(() => {
@@ -194,10 +194,10 @@ Grants a user_grant permission to an application. This API uses an asynchronous
| Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
-| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundle-ApplicationInfo.md).|
-| permissionName | Permissions | Yes | Name of the permission to grant.|
+| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundleManager-applicationInfo.md).|
+| permissionName | Permissions | Yes | Permission to grant. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
| permissionFlag | number | Yes | Permission flag. The value **1** means that the permission request dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
-| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the permission is granted successfully, **err** is **undefine**. Otherwise, **err** is an error object.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the permission is granted successfully, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
@@ -208,7 +208,8 @@ For details about the error codes, see [Ability Access Control Error Codes](../e
| 12100001 | The parameter is invalid. The tokenID is 0 |
| 12100002 | TokenId does not exist. |
| 12100003 | Permission does not exist. |
-| 12100006 | The specified application does not support the permissions granted or ungranted as specified. |
+| 12100006 | The application specified by the tokenID is not allowed to be granted with the specified permission. Either the application is a sandbox or the tokenID is from a remote device. |
+| 12100007 | Service is abnormal. |
**Example**
@@ -216,7 +217,7 @@ For details about the error codes, see [Ability Access Control Error Codes](../e
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
-let tokenID = 0; // You can use getApplicationInfo to obtain the access token ID.
+let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let permissionFlag = 1;
try {
atManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlag, (err, data) => {
@@ -247,8 +248,8 @@ Revokes a user_grant permission from an application. This API uses a promise to
| Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
-| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundle-ApplicationInfo.md). |
-| permissionName | Permissions | Yes | Name of the permission to revoke.|
+| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundleManager-applicationInfo.md). |
+| permissionName | Permissions | Yes | Permission to revoke. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
| permissionFlag | number | Yes | Permission flag. The value **1** means that the permission request dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
**Return value**
@@ -275,7 +276,7 @@ For details about the error codes, see [Ability Access Control Error Codes](../e
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
-let tokenID = 0; // You can use getApplicationInfo to obtain the access token ID.
+let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let permissionFlag = 1;
try {
atManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlag).then(() => {
@@ -304,10 +305,10 @@ Revokes a user_grant permission from an application. This API uses an asynchrono
| Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
-| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundle-ApplicationInfo.md). |
-| permissionName | Permissions | Yes | Name of the permission to revoke.|
+| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundleManager-applicationInfo.md). |
+| permissionName | Permissions | Yes | Permission to revoke. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
| permissionFlag | number | Yes | Permission flag. The value **1** means that the permission request dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
-| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the permission is revoked successfully, **err** is **undefine**. Otherwise, **err** is an error object.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the permission is revoked successfully, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
@@ -318,7 +319,8 @@ For details about the error codes, see [Ability Access Control Error Codes](../e
| 12100001 | The parameter is invalid. The tokenID is 0 |
| 12100002 | TokenId does not exist. |
| 12100003 | Permission does not exist. |
-| 12100006 | The specified application does not support the permissions granted or ungranted as specified. |
+| 12100006 | The application specified by the tokenID is not allowed to be revoked with the specified permission. Either the application is a sandbox or the tokenID is from a remote device. |
+| 12100007 | Service is abnormal. |
**Example**
@@ -326,7 +328,7 @@ For details about the error codes, see [Ability Access Control Error Codes](../e
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
-let tokenID = 0; // You can use getApplicationInfo to obtain the access token ID.
+let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let permissionFlag = 1;
try {
atManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlag, (err, data) => {
@@ -357,8 +359,8 @@ Obtains the flags of the specified permission of an application. This API uses a
| Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
-| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundle-ApplicationInfo.md). |
-| permissionName | Permissions | Yes | Name of the permission to query.|
+| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundleManager-applicationInfo.md). |
+| permissionName | Permissions | Yes | Target permission. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
**Return value**
@@ -375,7 +377,7 @@ For details about the error codes, see [Ability Access Control Error Codes](../e
| 12100001 | The parameter is invalid. The tokenID is 0 |
| 12100002 | The specified tokenID does not exist. |
| 12100003 | The specified permission does not exist. |
-| 12100006 | The operation is not allowd. Either the application is a sandbox or the tokenID is from a remote device. |
+| 12100006 | The operation is not allowed. Either the application is a sandbox or the tokenID is from a remote device. |
| 12100007 | Service is abnormal. |
**Example**
@@ -384,7 +386,7 @@ For details about the error codes, see [Ability Access Control Error Codes](../e
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
-let tokenID = 0; // You can use getApplicationInfo to obtain the access token ID.
+let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
try {
atManager.getPermissionFlags(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS").then((data) => {
console.log(`getPermissionFlags success, data->${JSON.stringify(data)}`);
@@ -525,7 +527,7 @@ try {
verifyAccessToken(tokenID: number, permissionName: Permissions): Promise<GrantStatus>
-Verifies whether an application has the specified permission. This API uses a promise to return the result.
+Verifies whether a permission is granted to an application. This API uses a promise to return the result.
> **NOTE**
You are advised to use [checkAccessToken](#checkaccesstoken9).
@@ -535,8 +537,8 @@ Verifies whether an application has the specified permission. This API uses a pr
| Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | ------------------------------------------ |
-| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundle-ApplicationInfo.md). |
-| permissionName | Permissions | Yes | Name of the permission to verify. Only valid permission names are supported.|
+| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundleManager-applicationInfo.md). |
+| permissionName | Permissions | Yes | Permission to verify. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
**Return value**
@@ -550,18 +552,107 @@ Verifies whether an application has the specified permission. This API uses a pr
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
-let tokenID = 0; // You can use getApplicationInfo to obtain the access token ID.
+let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let promise = atManager.verifyAccessToken(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
promise.then(data => {
console.log(`promise: data->${JSON.stringify(data)}`);
});
```
+### requestPermissionsFromUser9+
+
+requestPermissionsFromUser(context: Context, permissions: Array<Permissions>, requestCallback: AsyncCallback<PermissionRequestResult>) : void;
+
+Requests user authorization in a dialog box. This API uses an asynchronous callback to return the result.
+
+**Model restriction**: This API can be used only in the stage model.
+
+**System capability**: SystemCapability.Security.AccessToken
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| context | Context | Yes| Ability context of the application that requests the permission.|
+| permissions | Array<Permissions> | Yes| Permissions requested. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
+| callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Yes| Callback invoked to return the result.|
+
+**Error codes**
+
+For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
+| ID| Error Message|
+| -------- | -------- |
+| 12100001 | Parameter invalid. |
+
+**Example**
+
+ ```js
+import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
+let atManager = abilityAccessCtrl.createAtManager();
+try {
+ atManager.requestPermissionsFromUser(this.context, ["ohos.permission.CAMERA"], (err, data)=>{
+ console.info("data:" + JSON.stringify(data));
+ console.info("data permissions:" + data.permissions);
+ console.info("data authResults:" + data.authResults);
+ });
+} catch(err) {
+ console.log(`catch err->${JSON.stringify(err)}`);
+}
+ ```
+
+### requestPermissionsFromUser9+
+
+requestPermissionsFromUser(context: Context, permissions: Array<Permissions>) : Promise<PermissionRequestResult>;
+
+Requests user authorization in a dialog box. This API uses a promise to return the result.
+
+**Model restriction**: This API can be used only in the stage model.
+
+**System capability**: SystemCapability.Security.AccessToken
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| context | Context | Yes| Ability context of the application that requests the permission.|
+| permissions | Array<Permissions> | Yes| Permissions requested. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Promise used to return the result.|
+
+**Error codes**
+
+For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
+| ID| Error Message|
+| -------- | -------- |
+| 12100001 | Parameter invalid. |
+
+**Example**
+
+ ```js
+import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
+let atManager = abilityAccessCtrl.createAtManager();
+try {
+ atManager.requestPermissionsFromUser(this.context, ["ohos.permission.CAMERA"]).then((data) => {
+ console.info("data:" + JSON.stringify(data));
+ console.info("data permissions:" + data.permissions);
+ console.info("data authResults:" + data.authResults);
+ }).catch((err) => {
+ console.info("data:" + JSON.stringify(err));
+ })
+} catch(err) {
+ console.log(`catch err->${JSON.stringify(err)}`);
+}
+ ```
+
### verifyAccessToken(deprecated)
verifyAccessToken(tokenID: number, permissionName: string): Promise<GrantStatus>
-Verifies whether an application has the specified permission. This API uses a promise to return the result.
+Verifies whether a permission is granted to an application. This API uses a promise to return the result.
> NOTE
This API is deprecated since API version 9. You are advised to use [checkAccessToken](#checkaccesstoken9).
@@ -571,8 +662,8 @@ Verifies whether an application has the specified permission. This API uses a pr
| Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | ------------------------------------------ |
-| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundle-ApplicationInfo.md). |
-| permissionName | string | Yes | Name of the permission to verify.|
+| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundleManager-applicationInfo.md). |
+| permissionName | string | Yes | Permission to check.|
**Return value**
@@ -586,7 +677,7 @@ Verifies whether an application has the specified permission. This API uses a pr
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
-let tokenID = 0; // You can use getApplicationInfo to obtain the access token ID.
+let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let promise = atManager.verifyAccessToken(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
promise.then(data => {
console.log(`promise: data->${JSON.stringify(data)}`);
@@ -629,4 +720,4 @@ Defines the detailed permission grant state change information.
| -------------- | ------------------------- | ---- | ---- | ------------------ |
| change | [PermissionStateChangeType](#permissionstatechangetype9) | Yes | No | Operation that triggers the permission grant state change. |
| tokenID | number | Yes | No | Token ID of the application whose permission grant state changes are subscribed.|
-| permissionName | Permissions | Yes | No | Name of the permission whose grant state is changed.|
+| permissionName | Permissions | Yes | No | permission whose grant state is changed. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
diff --git a/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md b/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md
deleted file mode 100644
index 098f4ebba840a13d1f37d6e14256fcc9695f2a8d..0000000000000000000000000000000000000000
--- a/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md
+++ /dev/null
@@ -1,33 +0,0 @@
-# AbilityRunningInfo
-
-The **AbilityRunningInfo** module implements ability running information and ability states.
-
-> **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.
-
-## Usage
-
-The ability running information is obtained by using the **getAbilityRunningInfos** API in **abilityManager**.
-
-```js
-import abilitymanager from '@ohos.application.abilityManager';
-abilitymanager.getAbilityRunningInfos((err,data) => {
- console.log("getAbilityRunningInfos err: " + err + " data: " + JSON.stringify(data));
-});
-```
-
-## Attributes
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-| Name| Type| Readable| Writable| Description|
-| -------- | -------- | -------- | -------- | -------- |
-| ability | ElementName | Yes| No| Information that matches an ability. |
-| pid | number | Yes| No| Process ID.|
-| uid | number | Yes| No| User ID. |
-| processName | string | Yes| No| Process name. |
-| startTime | number | Yes| No| Ability start time. |
-| abilityState | [abilityManager.AbilityState](js-apis-application-abilityManager.md#abilitystate) | Yes| No| Ability state. |
diff --git a/en/application-dev/reference/apis/js-apis-accessibility-GesturePath.md b/en/application-dev/reference/apis/js-apis-accessibility-GesturePath.md
new file mode 100644
index 0000000000000000000000000000000000000000..34d4df8dd99bb528ae79d8d13de74f491f75f3db
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-accessibility-GesturePath.md
@@ -0,0 +1,46 @@
+# @ohos.accessibility.GesturePath
+
+ The **GesturePath** module provides APIs for creating gesture path information required for an accessibility application to inject gestures.
+
+> **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.
+
+## Modules to Import
+
+```ts
+import GesturePath from '@ohos.accessibility.GesturePath';
+```
+
+## GesturePath
+
+Defines a gesture path.
+
+**System capability**: SystemCapability.BarrierFree.Accessibility.Core
+
+### Attributes
+
+| Name | Type | Readable | Writable | Description |
+| ------------ | ---------------------------------------- | ---- | ---- | ------ |
+| points | Array<[GesturePoint](js-apis-accessibility-GesturePoint.md#gesturepoint)> | Yes | Yes | Gesture touch point. |
+| durationTime | number | Yes | Yes | Total gesture duration, in milliseconds.|
+
+### constructor
+
+constructor(durationTime: number);
+
+Constructor used to create a **GesturePath** object.
+
+**System capability**: SystemCapability.BarrierFree.Accessibility.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| durationTime | number | Yes| Total gesture duration, in milliseconds.|
+
+**Example**
+
+```ts
+let gesturePath = new GesturePath.GesturePath(20);
+```
diff --git a/en/application-dev/reference/apis/js-apis-accessibility-GesturePoint.md b/en/application-dev/reference/apis/js-apis-accessibility-GesturePoint.md
new file mode 100644
index 0000000000000000000000000000000000000000..5792c44cd9fc89cf495e943a4e40463ce89281c4
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-accessibility-GesturePoint.md
@@ -0,0 +1,47 @@
+# @ohos.accessibility.GesturePoint
+
+ The **GesturePoint** module provides APIs for creating gesture touch point information required for an accessibility application to inject gestures.
+
+> **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.
+
+## Modules to Import
+
+```ts
+import GesturePoint from '@ohos.accessibility.GesturePoint';
+```
+
+## GesturePoint
+
+Defines a gesture touch point.
+
+**System capability**: SystemCapability.BarrierFree.Accessibility.Core
+
+### Attributes
+
+| Name | Type | Readable | Writable | Description |
+| --------- | ------ | ---- | ---- | ------- |
+| positionX | number | Yes | Yes | X coordinate of the touch point.|
+| positionY | number | Yes | Yes | Y coordinate of the touch point.|
+
+### constructor
+
+constructor(positionX: number, positionY: number);
+
+Constructor used to create a **GesturePoint** object.
+
+**System capability**: SystemCapability.BarrierFree.Accessibility.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| positionX | number | Yes| X coordinate of the touch point.|
+| positionY | number | Yes | Y coordinate of the touch point.|
+
+**Example**
+
+```ts
+let gesturePoint = new GesturePoint.GesturePoint(1, 2);
+```
diff --git a/en/application-dev/reference/apis/js-apis-accessibility-config.md b/en/application-dev/reference/apis/js-apis-accessibility-config.md
index c33230f7181ce92a50cee6c1417eb5d71a124f68..33b6f586279309125be085e8a28d5423b271fae3 100644
--- a/en/application-dev/reference/apis/js-apis-accessibility-config.md
+++ b/en/application-dev/reference/apis/js-apis-accessibility-config.md
@@ -1,17 +1,16 @@
-# System Accessibility Configuration
+# @ohos.accessibility.config
-The **config** module allows you to configure system accessibility features, including accessibility extension, high-contrast text, mouse buttons, and captions.
+The System Accessibility Configuration module allows you to configure system accessibility features, including accessibility extension, high-contrast text, mouse buttons, and captions.
> **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
-```typescript
-import config from "@ohos.accessibility.config";
+```ts
+import config from '@ohos.accessibility.config';
```
## Attributes
@@ -22,20 +21,20 @@ import config from "@ohos.accessibility.config";
| -------- | -------- | -------- | -------- | -------- |
| highContrastText | [Config](#config)\| Yes| Yes| Whether to enable high-contrast text.|
| invertColor | [Config](#config)\| Yes| Yes| Whether to enable color inversion.|
-| daltonizationColorFilter | [Config](#config)\<[DaltonizationColorFilter](#daltonizationcolorfilter)>| Yes| Yes| Daltonization filter. |
+| daltonizationColorFilter | [Config](#config)<[DaltonizationColorFilter](#daltonizationcolorfilter)>| Yes| Yes| Configuration of the daltonization filter.|
| contentTimeout | [Config](#config)\| Yes| Yes| Recommended duration for content display. The value ranges from 0 to 5000, in milliseconds.|
-| animationOff | [Config](#config)\| Yes| Yes| Whether to enable animation.|
+| animationOff | [Config](#config)\| Yes| Yes| Whether to disable animation.|
| brightnessDiscount | [Config](#config)\| Yes| Yes| Brightness discount. The value ranges from 0 to 1.0.|
| mouseKey | [Config](#config)\| Yes| Yes| Whether to enable the mouse button feature.|
-| mouseAutoClick | [Config](#config)\| Yes| Yes| Interval for the automatic mouse clicks. The value ranges from 0 to 5000, in milliseconds.|
+| mouseAutoClick | [Config](#config)\| Yes| Yes| Interval for automatic mouse clicks. The value ranges from 0 to 5000, in milliseconds.|
| shortkey | [Config](#config)\| Yes| Yes| Whether to enable the accessibility extension shortcut key.|
-| shortkeyTarget | [Config](#config)\| Yes| Yes| Target application for the accessibility extension shortcut key. The value format is bundleName/abilityName.|
+| shortkeyTarget | [Config](#config)\| Yes| Yes| Target application for the accessibility extension shortcut key. The value format is 'bundleName/abilityName'.|
| captions | [Config](#config)\| Yes| Yes| Whether to enable captions.|
-| captionsStyle | [Config](#config)\<[accessibility.CaptionsStyle](./js-apis-accessibility.md#captionsstyle8)>| Yes| Yes| Captions style.|
+| captionsStyle | [Config](#config)\<[accessibility.CaptionsStyle](js-apis-accessibility.md#captionsstyle8)>| Yes| Yes| Captions style.|
## enableAbility
-enableAbility(name: string, capability: Array<[accessibility.Capability](./js-apis-accessibility.md#capability)>): Promise<void>;
+enableAbility(name: string, capability: Array<accessibility.Capability>): Promise<void>;
Enables an accessibility extension ability. This API uses a promise to return the result.
@@ -45,29 +44,44 @@ Enables an accessibility extension ability. This API uses a promise to return th
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| name | string | Yes| Name of the accessibility extension ability. The format is bundleName/abilityName.|
-| capability | Array<[accessibility.Capability](./js-apis-accessibility.md#capability)>) | Yes| Capability of the accessibility extension ability.|
+| name | string | Yes| Name of the accessibility extension ability. The format is 'bundleName/abilityName'.|
+| capability | Array<[accessibility.Capability](js-apis-accessibility.md#capability)> | Yes| Capability of the accessibility extension ability.|
**Return value**
| Type| Description|
| -------- | -------- |
-| Promise<void> | Promise used to return the execution result.|
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+For details about the error codes, see [Accessibility Error Codes](../errorcodes/errorcode-accessibility.md).
+
+| ID| Error Message|
+| ------- | -------------------------------- |
+| 9300001 | Invalid bundle name or ability name. |
+| 9300002 | Target ability already enabled. |
**Example**
- ```typescript
- config.enableAbility("com.ohos.example/axExtension", ['retrieve'])
- .then(() => {
- console.info('enable succeed');
- }).catch((error) => {
- console.error('enable failed');
- });
- ```
+```ts
+import accessibility from '@ohos.accessibility';
+let name = 'com.ohos.example/axExtension';
+let capability : accessibility.Capability[] = ['retrieve'];
+try {
+ config.enableAbility(name, capability).then(() => {
+ console.info('enable ability succeed');
+ }).catch((err) => {
+ console.error('failed to enable ability, because ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('failed to enable ability, because ' + JSON.stringify(exception));
+};
+```
## enableAbility
-enableAbility(name: string, capability: Array<[accessibility.Capability](./js-apis-accessibility.md#capability)>, callback: AsyncCallback<void>): void;
+enableAbility(name: string, capability: Array<accessibility.Capability>, callback: AsyncCallback<void>): void;
Enables an accessibility extension ability. This API uses an asynchronous callback to return the result.
@@ -77,21 +91,37 @@ Enables an accessibility extension ability. This API uses an asynchronous callba
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| name | string | Yes| Name of the accessibility extension ability. The format is bundleName/abilityName.|
-| capability | Array<[accessibility.Capability](./js-apis-accessibility.md#capability)> | Yes| Capability of the accessibility extension ability.|
-| callback | AsyncCallback<void> | Yes| Callback used to return the execution result.|
+| name | string | Yes| Name of the accessibility extension ability. The format is 'bundleName/abilityName'.|
+| capability | Array<[accessibility.Capability](js-apis-accessibility.md#capability)> | Yes| Capability of the accessibility extension ability.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+
+**Error codes**
+
+For details about the error codes, see [Accessibility Error Codes](../errorcodes/errorcode-accessibility.md).
+
+| ID| Error Message|
+| ------- | -------------------------------- |
+| 9300001 | Invalid bundle name or ability name. |
+| 9300002 | Target ability already enabled. |
**Example**
- ```typescript
- config.enableAbility("com.ohos.example/axExtension", ['retrieve'], (err, data) => {
- if (err) {
- console.error('enable failed');
- return;
- }
- console.info('enable succeed');
- })
- ```
+```ts
+import accessibility from '@ohos.accessibility';
+let name = 'com.ohos.example/axExtension';
+let capability : accessibility.Capability[] = ['retrieve'];
+try {
+ config.enableAbility(name, capability, (err) => {
+ if (err) {
+ console.error('failed to enable ability, because ' + JSON.stringify(err));
+ return;
+ }
+ console.info('enable ability succeed');
+ });
+} catch (exception) {
+ console.error('failed to enable ability, because ' + JSON.stringify(exception));
+};
+```
## disableAbility
@@ -105,24 +135,36 @@ Disables an accessibility extension ability. This API uses a promise to return t
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| name | string | Yes| Name of the accessibility extension ability. The format is bundleName/abilityName.|
+| name | string | Yes| Name of the accessibility extension ability. The format is 'bundleName/abilityName'.|
**Return value**
| Type| Description|
| -------- | -------- |
-| Promise<void> | Promise used to return the execution result.|
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+For details about the error codes, see [Accessibility Error Codes](../errorcodes/errorcode-accessibility.md).
+
+| ID| Error Message|
+| ------- | -------------------------------- |
+| 9300001 | Invalid bundle name or ability name. |
**Example**
- ```typescript
- config.disableAbility("com.ohos.example/axExtension")
- .then(() => {
- console.info('disable succeed');
- }).catch((error) => {
- console.error('disable failed');
- });
- ```
+```ts
+let name = 'com.ohos.example/axExtension';
+try {
+ config.disableAbility(name).then(() => {
+ console.info('disable ability succeed');
+ }).catch((err) => {
+ console.error('failed to disable ability, because ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('failed to disable ability, because ' + JSON.stringify(exception));
+};
+```
## disableAbility
@@ -136,26 +178,39 @@ Disables an accessibility extension ability. This API uses an asynchronous callb
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| name | string | Yes| Name of the accessibility extension ability. The format is bundleName/abilityName.|
-| callback | AsyncCallback<void> | Yes| Callback used to return the execution result.|
+| name | string | Yes| Name of the accessibility extension ability. The format is 'bundleName/abilityName'.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+
+**Error codes**
+
+For details about the error codes, see [Accessibility Error Codes](../errorcodes/errorcode-accessibility.md).
+
+| ID| Error Message|
+| ------- | -------------------------------- |
+| 9300001 | Invalid bundle name or ability name. |
**Example**
- ```typescript
- config.disableAbility("com.ohos.example/axExtension", (err, data) => {
- if (err) {
- console.error('disable failed');
- return;
- }
- console.info('disable succeed');
- })
- ```
+```ts
+let name = 'com.ohos.example/axExtension';
+try {
+ config.disableAbility(name, (err, data) => {
+ if (err) {
+ console.error('failed to enable ability, because ' + JSON.stringify(err));
+ return;
+ }
+ console.info('disable succeed');
+ });
+} catch (exception) {
+ console.error('failed to enable ability, because ' + JSON.stringify(exception));
+};
+```
-## on('enableAbilityListsStateChanged')
+## on('enabledAccessibilityExtensionListChange')
-on(type: 'enableAbilityListsStateChanged', callback: Callback<void>): void;
+on(type: 'enabledAccessibilityExtensionListChange', callback: Callback<void>): void;
-Adds a listener for changes in the list of enabled accessibility extension abilities.
+Adds a listener for changes in the list of enabled accessibility extension abilities. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
@@ -163,22 +218,27 @@ Adds a listener for changes in the list of enabled accessibility extension abili
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes| Listening type. The value is fixed at **'enableAbilityListsStateChanged'**, indicating the changes in the list of enabled accessibility extension abilities. |
+| type | string | Yes| Listening type. The value is fixed at **'enabledAccessibilityExtensionListChange'**, indicating listening for changes in the list of enabled accessibility extension abilities.|
| callback | Callback<void> | Yes| Callback invoked when the list of enabled accessibility extension abilities changes.|
**Example**
- ```typescript
- config.on('enableAbilityListsStateChanged',() => {
- console.info('ax extension ability enable list changed');
- });
- ```
+```ts
+try {
+ config.on('enabledAccessibilityExtensionListChange', () => {
+ console.info('subscribe enabled accessibility extension list change state success');
+ });
+} catch (exception) {
+ console.error('failed to subscribe enabled accessibility extension list change state, because ' +
+ JSON.stringify(exception));
+};
+```
-## off('enableAbilityListsStateChanged')
+## off('enabledAccessibilityExtensionListChange')
-off(type: 'enableAbilityListsStateChanged', callback?: Callback<void>): void;
+off(type: 'enabledAccessibilityExtensionListChange', callback?: Callback<void>): void;
-Cancels the listener for changes in the list of enabled accessibility extension abilities.
+Cancels the listener for changes in the list of enabled accessibility extension abilities. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
@@ -186,14 +246,21 @@ Cancels the listener for changes in the list of enabled accessibility extension
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | No| Listening type. The value is fixed at **'enableAbilityListsStateChanged'**, indicating the changes in the list of enabled accessibility extension abilities. |
+| type | string | Yes| Listening type. The value is fixed at **'enabledAccessibilityExtensionListChange'**, indicating listening for changes in the list of enabled accessibility extension abilities.|
| callback | Callback<void> | No| Callback invoked when the list of enabled accessibility extension abilities changes.|
**Example**
- ```typescript
- config.off('enableAbilityListsStateChanged');
- ```
+```ts
+try {
+ config.off('enabledAccessibilityExtensionListChange', () => {
+ console.info('Unsubscribe enabled accessibility extension list change state success');
+ });
+} catch (exception) {
+ console.error('failed to Unsubscribe enabled accessibility extension list change state, because ' +
+ JSON.stringify(exception));
+};
+```
## Config
@@ -203,7 +270,7 @@ Implements configuration, acquisition, and listening for attributes.
set(value: T): Promise<void>;
-Sets this attribute. This API uses a promise to return the result.
+Sets the attribute value. This API uses a promise to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
@@ -217,24 +284,28 @@ Sets this attribute. This API uses a promise to return the result.
| Type| Description|
| -------- | -------- |
-| Promise<void> | Promise used to return the execution result.|
+| Promise<void> | Promise that returns no value.|
**Example**
- ```typescript
- config.highContrastText.set(true)
- .then(() => {
- console.info('highContrastText set succeed');
- }).catch((error) => {
- console.error('highContrastText set failed');
- });
- ```
+```ts
+let value = true;
+try {
+ config.highContrastText.set(value).then(() => {
+ console.info('set highContrastText succeed');
+ }).catch((err) => {
+ console.error('failed to set highContrastText, because ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('failed to set config, because ' + JSON.stringify(exception));
+};
+```
### set
set(value: T, callback: AsyncCallback<void>): void;
-Sets this attribute. This API uses an asynchronous callback to return the result.
+Sets the attribute value. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
@@ -243,25 +314,30 @@ Sets this attribute. This API uses an asynchronous callback to return the result
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | T | Yes| Attribute value to set.|
-| callback | AsyncCallback<void> | Yes| Callback used to return the execution result.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
- ```typescript
- config.highContrastText.set(true, (err, data) => {
- if (err) {
- console.error('highContrastText set failed');
- return;
- }
- console.info('highContrastText set succeed');
- })
- ```
+```ts
+let value = true;
+try {
+ config.highContrastText.set(value, (err, data) => {
+ if (err) {
+ console.error('failed to set highContrastText, because ' + JSON.stringify(err));
+ return;
+ }
+ console.info('set highContrastText succeed');
+ });
+} catch (exception) {
+ console.error('failed to set config, because ' + JSON.stringify(exception));
+};
+```
### get
get(): Promise<T>;
-Obtains the value of this attribute. This API uses a promise to return the result.
+Obtains the attribute value. This API uses a promise to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
@@ -269,24 +345,25 @@ Obtains the value of this attribute. This API uses a promise to return the resul
| Type| Description|
| -------- | -------- |
-| Promise<T> | Promise used to return the attribute value.|
+| Promise<T> | Promise used to return the value obtained.|
**Example**
- ```typescript
- config.highContrastText.get()
- .then((value) => {
- console.info('highContrastText get succeed');
- }).catch((error) => {
- console.error('highContrastText get failed');
- });
- ```
+```ts
+let value;
+config.highContrastText.get().then((data) => {
+ value = data;
+ console.info('get highContrastText success');
+}).catch((err) => {
+ console.error('failed to get highContrastText, because ' + JSON.stringify(err));
+});
+```
### get
get(callback: AsyncCallback<T>): void;
-Obtains the value of this attribute. This API uses an asynchronous callback to return the result.
+Obtains the attribute value. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
@@ -294,25 +371,27 @@ Obtains the value of this attribute. This API uses an asynchronous callback to r
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callback | AsyncCallback<void> | Yes| Callback used to return the attribute value.|
+| callback | AsyncCallback<T> | Yes| Callback used to return the attribute value.|
**Example**
- ```typescript
- config.highContrastText.get((err, data) => {
- if (err) {
- console.error('highContrastText get failed');
- return;
- }
- console.info('highContrastText get succeed');
- })
- ```
+```ts
+let value;
+config.highContrastText.get((err, data) => {
+ if (err) {
+ console.error('failed to get highContrastText, because ' + JSON.stringify(err));
+ return;
+ }
+ value = data;
+ console.info('get highContrastText success');
+});
+```
### on
on(callback: Callback<T>): void;
-Adds a listener for attribute changes.
+Adds a listener for attribute changes. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
@@ -324,17 +403,21 @@ Adds a listener for attribute changes.
**Example**
- ```typescript
- config.highContrastText.on(() => {
- console.info('highContrastText changed');
- });
- ```
+```ts
+try {
+ config.highContrastText.on((data) => {
+ console.info('subscribe highContrastText success, result: ' + JSON.stringify(data));
+ });
+} catch (exception) {
+ console.error('failed subscribe highContrastText, because ' + JSON.stringify(exception));
+}
+```
### off
off(callback?: Callback<T>): void;
-Cancels the listener for attribute changes.
+Cancels the listener for attribute changes. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
@@ -342,13 +425,15 @@ Cancels the listener for attribute changes.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callback | Callback<T> | No| Callback invoked when the attribute changes.|
+| callback | Callback<T> | No| Callback invoked when the list of enabled accessibility extension abilities changes.|
**Example**
- ```typescript
- config.highContrastText.off();
- ```
+```ts
+config.highContrastText.off((data) => {
+ console.info('Unsubscribe highContrastText success, result: ' + JSON.stringify(data));
+});
+```
## DaltonizationColorFilter
diff --git a/en/application-dev/reference/apis/js-apis-accessibility-extension-context.md b/en/application-dev/reference/apis/js-apis-accessibility-extension-context.md
deleted file mode 100644
index 9fee7500eae2ec8435f0c3bdc2b48c986b14686a..0000000000000000000000000000000000000000
--- a/en/application-dev/reference/apis/js-apis-accessibility-extension-context.md
+++ /dev/null
@@ -1,379 +0,0 @@
-# AccessibilityExtensionContext
-
-The **AccessibilityExtensionContext** module, inherited from **ExtensionContext**, provides context for **Accessibility Extension** abilities.
-
-You can use the APIs of this module to configure the concerned information, obtain root information, and inject gestures.
-
-> **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 can be used only in the stage model.
-
-## Usage
-
-Before using the **AccessibilityExtensionContext** module, you must define a child class that inherits from **AccessibilityExtensionAbility**.
-
-```js
-import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility'
-class MainAbility extends AccessibilityExtensionAbility {
- onConnect(): void {
- console.log("AxExtensionAbility onConnect");
- let axContext = this.context;
- }
-}
-```
-
-## FocusDirection
-
-Enumerates the focus directions.
-
-**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-
-| Name | Description |
-| -------- | ------- |
-| up | Search for the next focusable item above the current item in focus.|
-| down | Search for the next focusable item below the current item in focus.|
-| left | Search for the next focusable item on the left of the current item in focus.|
-| right | Search for the next focusable item on the right of the current item in focus.|
-| forward | Search for the next focusable item before the current item in focus.|
-| backward | Search for the next focusable item after the current item in focus.|
-
-## FocusType
-
-Enumerates the focus types.
-
-**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-
-| Name | Description |
-| ------------- | ----------- |
-| accessibility | Accessibility focus.|
-| normal | Normal focus. |
-
-## Rect
-
-Defines a rectangle.
-
-**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-
-| Name | Type | Readable | Writable | Description |
-| ------ | ------ | ---- | ---- | --------- |
-| left | number | Yes | No | Left boundary of the rectangle.|
-| top | number | Yes | No | Top boundary of the rectangle.|
-| width | number | Yes | No | Width of the rectangle. |
-| height | number | Yes | No | Height of the rectangle. |
-
-## WindowType
-
-Enumerates the window types.
-
-**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-
-| Name | Description |
-| ----------- | --------- |
-| application | Application window.|
-| system | System window.|
-
-## AccessibilityExtensionContext.setTargetBundleName
-
-setTargetBundleName(targetNames: Array\): Promise\;
-
-Sets the concerned target bundle.
-
-**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| ----------- | ------------------- | ---- | -------- |
-| targetNames | Array<string> | Yes | Name of the target bundle.|
-
-**Return value**
-
-| Type | Description |
-| ---------------------- | --------------------- |
-| Promise<boolean> | Promise used to return the result.|
-
-**Example**
-
-```ts
-this.context.setTargetBundleName(['com.ohos.mms']);
-```
-
-## AccessibilityExtensionContext.getFocusElement
-
-getFocusElement(isAccessibilityFocus?: boolean): Promise\;
-
-Obtains the focus element.
-
-**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| -------------------- | ------- | ---- | ------------------- |
-| isAccessibilityFocus | boolean | No | Whether the obtained focus element is an accessibility focus. The default value is **false**.|
-
-**Return value**
-
-| Type | Description |
-| ----------------------------------- | ---------------------- |
-| Promise<AccessibilityElement> | Promise used to return the current focus element.|
-
-**Example**
-
-```ts
-this.context.getFocusElement().then(focusElement => {
- console.log("AxExtensionAbility getFocusElement success");
-})
-```
-
-## AccessibilityExtensionContext.getWindowRootElement
-
-getWindowRootElement(windowId?: number): Promise\;
-
-Obtains the root element of a window.
-
-**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| -------- | ------ | ---- | --------------------------- |
-| windowId | number | No | Window for which you want to obtain the root element. If this parameter is not specified, it indicates the current active window.|
-
-**Return value**
-
-| Type | Description |
-| ----------------------------------- | ----------------------- |
-| Promise<AccessibilityElement> | Promise used to return the root element.|
-
-**Example**
-
-```ts
-this.context.getWindowRootElement().then(rootElement => {
- console.log("AxExtensionAbility getWindowRootElement success");
-})
-```
-
-## AccessibilityExtensionContext.getWindows
-
-getWindows(displayId?: number): Promise>;
-
-Obtains the list of windows visible to users.
-
-**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| --------- | ------ | ---- | ------------------------- |
-| displayId | number | No | Screen from which the window information is obtained. If this parameter is not specified, it indicates the default home screen.|
-
-**Return value**
-
-| Type | Description |
-| ---------------------------------------- | ------------------------ |
-| Promise<Array<AccessibilityElement>> | Promise used to return the window list. |
-
-**Example**
-
-```ts
-this.context.getWindows().then(windows => {
- console.log("AxExtensionAbility getWindows success");
-})
-```
-
-## AccessibilityExtensionContext.injectGesture
-
-injectGesture(gesturePath: GesturePath, callback: AsyncCallback\): void
-
-Injects a gesture.
-
-**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| ----------- | ---------------------------------------- | ---- | -------------- |
-| gesturePath | [GesturePath](js-apis-application-AccessibilityExtensionAbility.md#GesturePath) | Yes | Path of the gesture to inject. |
-| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
-
-**Example**
-
-```ts
-let gesturePath = new GesturePath(100);
-for (let i = 0; i < 10; i++) {
- let gesturePoint = new GesturePosition(100, i * 200);
- gesturePath.positions.push(gesturePoint);
-}
-this.context.gestureInject(gesturePath, (result) => {
- console.info('gestureInject result: ' + result);
-})
-```
-## AccessibilityElement.attributeNames
-
-attributeNames\(): Promise\>;
-
-Obtains all attribute names of this element.
-
-**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-
-**Return value**
-
-| Type | Description |
-| ---------------------------------------- | ------------------------ |
-| Promise<Array<T>> | Promise used to return all attribute names of the element.|
-
-**Example**
-
-```ts
-let accessibilityElement;
-try {
- accessibilityElement.attributeNames().then((values) => {
- console.log("get attribute names success");
- }).catch((err) => {
- console.log("get attribute names err: " + JSON.stringify(err));
- });
-} catch (e) {
- console.log("An unexpected error occurred. Error:" + e);
-}
-```
-
-## AccessibilityElement.attributeValue
-
-attributeValue\(attributeName: T): Promise\;
-
-Obtains the attribute value based on an attribute name.
-
-**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| ----------- | ---------------------------------------- | ---- | -------------- |
-| attributeName | T | Yes | Attribute name. |
-
-**Return value**
-
-| Type | Description |
-| ---------------------------------------- | ------------------------ |
-| Promise<Array<ElementAttributeValues[T]>> | Promise used to return the attribute value.|
-
-**Example**
-
-```ts
-let accessibilityElement;
-try {
- let attributeName = 'name';
- accessibilityElement.attributeValue(attributeName).then((value) => {
- console.log("get attribute value by name success");
- }).catch((err) => {
- console.log("get attribute value by name err: " + JSON.stringify(err));
- });
-} catch (e) {
- console.log("An unexpected error occurred. Error:" + e);
-}
-```
-
-## AccessibilityElement.actionNames
-
-actionNames(): Promise\>;
-
-Obtains the names of all actions supported by this element.
-
-**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-
-**Return value**
-
-| Type | Description |
-| ---------------------------------------- | ------------------------ |
-| Promise<Array<string>> | Promise used to return the names of all actions supported by the element.|
-
-**Example**
-
-```ts
-let accessibilityElement;
-try {
- accessibilityElement.actionNames().then((values) => {
- console.log("get action names success");
- }).catch((err) => {
- console.log("get action names err: " + JSON.stringify(err));
- });
-} catch (e) {
- console.log("An unexpected error occurred. Error:" + e);
-}
-```
-
-## AccessibilityElement.performAction
-
-performAction(actionName: string, parameters?: object): Promise\;
-
-Performs an action based on the specified action name.
-
-**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| ----------- | ---------------------------------------- | ---- | -------------- |
-| actionName | string | Yes | Action name. |
-| parameters | object | No | Parameter required for performing the target action. |
-
-**Return value**
-
-| Type | Description |
-| ---------------------------------------- | ------------------------ |
-| Promise<Array<boolean>> | Promise used to return the result.|
-
-**Example**
-
-```ts
-let accessibilityElement;
-try {
-
- accessibilityElement.performAction('action').then((result) => {
- console.info('perform action result: ' + result);
- }).catch((err) => {
- console.log("perform action err: " + JSON.stringify(err));
- });
-} catch (e) {
- console.log("An unexpected error occurred. Error:" + e);
-}
-```
-
-## AccessibilityElement.findElement
-
-findElement(type: 'content', condition: string): Promise\>;
-
-Queries the information about this element based on the specified information type and condition.
-
-**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| ----------- | ---------------------------------------- | ---- | -------------- |
-| type | string | Yes | Information type. The value is fixed at **'content'**. |
-| condition | string | Yes | Search criteria. |
-
-**Return value**
-
-| Type | Description |
-| ---------------------------------------- | ------------------------ |
-| Promise<Array<T>> | Promise used to return the result.|
-
-**Example**
-
-```ts
-let accessibilityElement;
-try {
- let condition = 'keyword';
- accessibilityElement.findElement('content', condition).then((values) => {
- console.log("find element success");
- }).catch((err) => {
- console.log("find element err: " + JSON.stringify(err));
- });
-} catch (e) {
- console.log("An unexpected error occurred. Error:" + e);
-}
-```
diff --git a/en/application-dev/reference/apis/js-apis-accessibility.md b/en/application-dev/reference/apis/js-apis-accessibility.md
index 6d318b4ade570aea27b58ca93d37ef0a3992d3bc..cf4443c60f4b58a17986bdb7ae5160fd6a95347c 100644
--- a/en/application-dev/reference/apis/js-apis-accessibility.md
+++ b/en/application-dev/reference/apis/js-apis-accessibility.md
@@ -1,4 +1,4 @@
-# Accessibility
+# @ohos.accessibility
The **Accessibility** module implements the accessibility functions, including obtaining the accessibility application list, accessibility application enabled status, and captions configuration.
@@ -8,7 +8,7 @@ The **Accessibility** module implements the accessibility functions, including o
## Modules to Import
-```typescript
+```ts
import accessibility from '@ohos.accessibility';
```
@@ -49,7 +49,7 @@ Provides information about an accessibility application.
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| id | number | Yes| No| Ability ID.|
+| id | string | Yes| No| Ability ID.|
| name | string | Yes| No| Ability name.|
| bundleName | string | Yes| No| Bundle name.|
| targetBundleNames9+ | Array<string> | Yes| No| Name of the target bundle.|
@@ -85,7 +85,7 @@ Describes the target action supported by an accessibility application.
## Capability
-Enumerates the capabilities of an auxiliary application.
+Enumerates the capabilities of an accessibility application.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
@@ -145,7 +145,7 @@ Describes the style of captions.
## CaptionsManager8+
-Implements configuration management for captions.
+Implements configuration management for captions. Before calling any API of **CaptionsManager**, you must use the [accessibility.getCaptionsManager()](#accessibilitygetcaptionsmanager8) API to obtain a **CaptionsManager** instance.
**System capability**: SystemCapability.BarrierFree.Accessibility.Hearing
@@ -156,87 +156,113 @@ Implements configuration management for captions.
| enabled | boolean | Yes| No| Whether to enable captions configuration.|
| style | [CaptionsStyle](#captionsstyle8) | Yes| No| Style of captions.|
-In the following API examples, you must first use the [accessibility.getCaptionsManager()](#accessibilitygetcaptionsmanager8) API to obtain a **captionsManager** instance, and then call the methods using the obtained instance.
-
### on('enableChange')
on(type: 'enableChange', callback: Callback<boolean>): void;
-Enables listening for the enabled status changes of captions configuration.
+Enables listening for the enabled status changes of captions configuration. This API uses an asynchronous callback to return the result.
-- **Parameters**
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | type | string | Yes| Type of the event to listen for, which is set to **enableChange** in this API.|
- | callback | Callback<boolean> | Yes| Callback invoked when the enabled status of captions configuration changes.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Type of the event to listen for, which is set to **'enableChange'** in this API.|
+| callback | Callback<boolean> | Yes| Callback invoked when the enabled status of captions configuration changes.|
-- **Example**
+**Example**
- ```typescript
- captionsManager.on('enableChange',(data) => {
- console.info('success data:subscribeStateObserver : ' + JSON.stringify(data))
- })
- ```
+```ts
+let captionsManager = accessibility.getCaptionsManager();
+try {
+ captionsManager.on('enableChange', (data) => {
+ console.info('subscribe caption manager enable state change, result: ' + JSON.stringify(data));
+ });
+} catch (exception) {
+ console.error('failed to subscribe caption manager enable state change, because ' + JSON.stringify(exception));
+}
+```
### on('styleChange')
on(type: 'styleChange', callback: Callback<CaptionsStyle>): void;
-Enables listening for captions style changes.
+Enables listening for captions style changes. This API uses an asynchronous callback to return the result.
-- **Parameters**
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | type | string | Yes| Type of the event to listen for, which is set to **styleChange** in this API.|
- | callback | Callback<[CaptionsStyle](#captionsstyle8)> | Yes| Callback invoked when the style of captions changes.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Type of the event to listen for, which is set to **'styleChange'** in this API.|
+| callback | Callback<[CaptionsStyle](#captionsstyle8)> | Yes| Callback invoked when the style of captions changes.|
-- **Example**
+**Example**
+
+```ts
+let captionStyle;
+let captionsManager = accessibility.getCaptionsManager();
+try {
+ captionsManager.on('styleChange', (data) => {
+ captionStyle = data;
+ console.info('subscribe caption manager style state change, result: ' + JSON.stringify(data));
+ });
+} catch (exception) {
+ console.error('failed to subscribe caption manager style state change, because ' + JSON.stringify(exception));
+}
+```
- ```typescript
- captionsManager.on('styleChange',(data) => {
- console.info('success data:subscribeStateObserver : ' + JSON.stringify(data))
- })
- ```
-
### off('enableChange')
off(type: 'enableChange', callback?: Callback<boolean>): void;
-Disables listening for the enabled status changes of captions configuration.
+Disables listening for the enabled status changes of captions configuration. This API uses an asynchronous callback to return the result.
-- **Parameters**
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | type | string | Yes| Type of the event to listen for, which is set to **enableChange** in this API.|
- | callback | Callback<boolean> | No| Callback invoked when the enabled status of captions configuration changes.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Type of the event to listen for, which is set to **'enableChange'** in this API.|
+| callback | Callback<boolean> | No| Callback invoked when the enabled status of captions configuration changes.|
-- **Example**
+**Example**
- ```typescript
- captionsManager.off('enableChange')
- ```
+```ts
+let captionsManager = accessibility.getCaptionsManager();
+try {
+ captionsManager.off('enableChange', (data) => {
+ console.info('Unsubscribe caption manager enable state change, result: ' + JSON.stringify(data));
+ });
+} catch (exception) {
+ console.error('failed to Unsubscribe caption manager enable state change, because ' + JSON.stringify(exception));
+}
+```
### off('styleChange')
off(type: 'styleChange', callback?: Callback<CaptionsStyle>): void;
-Disables listening for captions style changes.
+Disables listening for captions style changes. This API uses an asynchronous callback to return the result.
-- **Parameters**
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | type | string | Yes| Type of the event to listen for, which is set to **styleChange** in this API.|
- | callback | Callback<[CaptionsStyle](#captionsstyle8)> | No| Callback invoked when the style of captions changes.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Type of the event to listen for, which is set to **'styleChange'** in this API.|
+| callback | Callback<[CaptionsStyle](#captionsstyle8)> | No| Callback invoked when the style of captions changes.|
-- **Example**
+**Example**
- ```typescript
- captionsManager.off('styleChange')
- ```
+```ts
+let captionStyle;
+let captionsManager = accessibility.getCaptionsManager();
+try {
+ captionsManager.off('styleChange', (data) => {
+ captionStyle = data;
+ console.info('Unsubscribe caption manager style state change, result: ' + JSON.stringify(data));
+ });
+} catch (exception) {
+ console.error('failed to Unsubscribe caption manager style state change, because ' + JSON.stringify(exception));
+}
+```
## EventInfo
@@ -271,16 +297,20 @@ Implements a constructor.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-- **Parameters**
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | jsonObject | string | Yes| JSON string required for creating an object.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| jsonObject | string | Yes| JSON string required for creating an object.|
-- **Example**
+**Example**
- ```typescript
- let eventInfo = new accessibility.EventInfo({"type":"click","bundleName":"com.example.MyApplication","triggerAction":"click"})
+ ```ts
+ let eventInfo = new accessibility.EventInfo({
+ 'type':'click',
+ 'bundleName':'com.example.MyApplication',
+ 'triggerAction':'click'
+ });
```
## EventType
@@ -331,153 +361,319 @@ Enumerates window update types.
| active | Window activity change.|
| focus | Window focus change.|
-## accessibility.getAbilityLists
+## accessibility.getAbilityLists(deprecated)
getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise<Array<AccessibilityAbilityInfo>>
Obtains the accessibility application list. 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[getAccessibilityExtensionList()](#accessibilitygetaccessibilityextensionlist9).
+
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-- **Parameters**
-
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | abilityType | [AbilityType](#abilitytype) | Yes| Accessibility application type.|
- | stateType | [AbilityState](#abilitystate) | Yes| Accessibility application status.|
-
-- **Return value**
-
- | Type| Description|
- | -------- | -------- |
- | Promise<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Promise used to return the accessibility application list.|
-
-- **Example**
-
- ```typescript
- accessibility.getAbilityLists("spoken", "enable")
- .then((data) => {
- console.info('success data:getAbilityList1 : ' + JSON.stringify(data));
- for (let item of data) {
- console.info(item.id);
- console.info(item.name);
- console.info(item.description);
- console.info(item.abilityTypes);
- console.info(item.eventTypes);
- console.info(item.capabilities);
- console.info(item.packageName);
- console.info(item.filterBundleNames);
- console.info(item.bundleName);
- }
- }).catch((error) => {
- console.error('failed to getAbilityList1 because ' + JSON.stringify(error));
- })
- ```
+**Parameters**
-## accessibility.getAbilityLists
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| abilityType | [AbilityType](#abilitytype) | Yes| Accessibility application type.|
+| stateType | [AbilityState](#abilitystate) | Yes| Accessibility application status.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Promise used to return the accessibility application list.|
+
+**Example**
+
+```ts
+let abilityType = 'spoken';
+let abilityState = 'enable';
+let abilityList: accessibility.AccessibilityInfo[];
+try {
+ accessibility.getAbilityLists(abilityType, abilityState).then((data) => {
+ for (let item of data) {
+ console.info(item.id);
+ console.info(item.name);
+ console.info(item.description);
+ console.info(item.bundleName);
+ extensionList.push(item);
+ }
+ console.info('get accessibility extension list success');
+ }).catch((err) => {
+ console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('failed to get accessibility extension list because ' + JSON.stringify(exception));
+}
+```
+
+## accessibility.getAbilityLists(deprecated)
getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: AsyncCallback<Array<AccessibilityAbilityInfo>>): void
Obtains the accessibility application list. 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 [getAccessibilityExtensionList()](#accessibilitygetaccessibilityextensionlist9-1).
+
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-- **Parameters**
-
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | abilityType | [AbilityType](#abilitytype) | Yes| Accessibility application type.|
- | stateType | [AbilityState](#abilitystate) | Yes| Accessibility application status.|
- | callback | AsyncCallback<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Yes| Callback used to return the accessibility application list.|
-
-- **Example**
-
- ```typescript
- accessibility.getAbilityLists("visual", "enable", (err, data) => {
- if (err) {
- console.error('failed to getAbilityList2 because ' + JSON.stringify(err));
- return;
- }
- console.info('success data:getAbilityList2 : ' + JSON.stringify(data));
- for (let item of data) {
- console.info(item.id);
- console.info(item.name);
- console.info(item.description);
- console.info(item.abilityTypes);
- console.info(item.eventTypes);
- console.info(item.capabilities);
- console.info(item.packageName);
- console.info(item.filterBundleNames);
- console.info(item.bundleName);
- }
- })
- ```
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| abilityType | [AbilityType](#abilitytype) | Yes| Accessibility application type.|
+| stateType | [AbilityState](#abilitystate) | Yes| Accessibility application status.|
+| callback | AsyncCallback<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Yes| Callback used to return the accessibility application list.|
+
+**Example**
+
+```ts
+let abilityType = 'spoken';
+let abilityState = 'enable';
+let abilityList: accessibility.AccessibilityInfo[];
+try {
+ accessibility.getAbilityLists(abilityType, abilityState, (err, data) => {
+ if (err) {
+ console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
+ return;
+ }
+ for (let item of data) {
+ console.info(item.id);
+ console.info(item.name);
+ console.info(item.description);
+ console.info(item.bundleName);
+ abilityList.push(item);
+ }
+ console.info('get accessibility extension list success');
+ }).catch((err) => {
+ console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('failed to get accessibility extension list because ' + JSON.stringify(exception));
+}
+```
+
+## accessibility.getAccessibilityExtensionList9+
+
+getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState): Promise<Array<AccessibilityAbilityInfo>>
+
+Obtains the accessibility application list. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.BarrierFree.Accessibility.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| abilityType | [AbilityType](#abilitytype) | Yes| Accessibility application type.|
+| stateType | [AbilityState](#abilitystate) | Yes| Accessibility application status.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Promise used to return the accessibility application list.|
+
+**Example**
+
+```ts
+let abilityType : accessibility.AbilityType = 'spoken';
+let abilityState : accessibility.AbilityState = 'enable';
+let extensionList: accessibility.AccessibilityAbilityInfo[] = [];
+try {
+ accessibility.getAccessibilityExtensionList(abilityType, abilityState).then((data) => {
+ for (let item of data) {
+ console.info(item.id);
+ console.info(item.name);
+ console.info(item.description);
+ console.info(item.bundleName);
+ extensionList.push(item);
+ }
+ console.info('get accessibility extension list success');
+ }).catch((err) => {
+ console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('failed to get accessibility extension list because ' + JSON.stringify(exception));
+}
+```
+
+## accessibility.getAccessibilityExtensionList9+
+
+getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState, callback: AsyncCallback<Array<AccessibilityAbilityInfo>>): void
+
+Obtains the accessibility application list. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.BarrierFree.Accessibility.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| abilityType | [AbilityType](#abilitytype) | Yes| Accessibility application type.|
+| stateType | [AbilityState](#abilitystate) | Yes| Accessibility application status.|
+| callback | AsyncCallback<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Yes| Callback used to return the accessibility application list.|
+
+**Example**
+
+```ts
+let abilityType : accessibility.AbilityType = 'spoken';
+let abilityState : accessibility.AbilityState = 'enable';
+let extensionList: accessibility.AccessibilityAbilityInfo[] = [];
+try {
+ accessibility.getAccessibilityExtensionList(abilityType, abilityState, (err, data) => {
+ if (err) {
+ console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
+ return;
+ }
+ for (let item of data) {
+ console.info(item.id);
+ console.info(item.name);
+ console.info(item.description);
+ console.info(item.bundleName);
+ extensionList.push(item);
+ }
+ console.info('get accessibility extension list success');
+ });
+} catch (exception) {
+ console.error('failed to get accessibility extension list because ' + JSON.stringify(exception));
+}
+```
## accessibility.getCaptionsManager8+
getCaptionsManager(): CaptionsManager
-Obtains the captions configuration.
+Obtains a **CaptionsManager** instance.
**System capability**: SystemCapability.BarrierFree.Accessibility.Hearing
-- **Return value**
+**Return value**
- | Type| Description|
- | -------- | -------- |
- | [CaptionsManager](#captionsmanager8) | Captions configuration.|
+| Type| Description|
+| -------- | -------- |
+| [CaptionsManager](#captionsmanager8) | Captions configuration.|
-- **Example**
+**Example**
- ```typescript
- captionsManager = accessibility.getCaptionsManager()
- ```
+```ts
+let captionsManager = accessibility.getCaptionsManager();
+```
-## accessibility.on('accessibilityStateChange' | 'touchGuideStateChange')
+## accessibility.on('accessibilityStateChange')
-on(type: 'accessibilityStateChange' | 'touchGuideStateChange', callback: Callback<boolean>): void
+on(type: 'accessibilityStateChange', callback: Callback<boolean>): void
-Enables listening for the enabled status changes of the accessibility application or touch guide mode.
+Enables listening for the enabled status changes of the accessibility application. This API uses an asynchronous callback to return the result.
-- **Parameters**
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | type | string | Yes| Type of the event to listen for.
- **'accessibilityStateChange'** means to listen for the enabled status changes of the accessibility application.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
- **'touchGuideStateChange'** means to listen for the enabled status changes of the touch guide mode.
**System capability**: SystemCapability.BarrierFree.Accessibility.Vision|
- | callback | Callback\ | Yes| Callback invoked when the enabled status of captions configuration changes.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Type of the event to listen for, which is set to **'accessibilityStateChange'** in this API.|
+| callback | Callback<boolean> | Yes| Callback used to return the result.|
-- **Example**
+**Example**
- ```typescript
- accessibility.on('accessibilityStateChange',(data) => {
- console.info('success data:subscribeStateObserver : ' + JSON.stringify(data))
- })
- ```
+```ts
+try {
+ accessibility.on('accessibilityStateChange', (data) => {
+ console.info('subscribe accessibility state change, result: ' + JSON.stringify(data));
+ });
+} catch (exception) {
+ console.error('failed to subscribe accessibility state change, because ' + JSON.stringify(exception));
+}
+```
-## accessibility.off('accessibilityStateChange' | 'touchGuideStateChange')
+## accessibility.on('touchGuideStateChange')
-off(type: 'accessibilityStateChange ' | 'touchGuideStateChange', callback?: Callback<boolean>): void
+on(type: 'touchGuideStateChange', callback: Callback<boolean>): void
-Disables listening for the enabled status changes of the accessibility application or touch guide mode.
+Enables listening for the enabled status changes of the touch guide mode. This API uses an asynchronous callback to return the result.
-- **Parameters**
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | type | string | No| Type of the event to listen for.
- **'accessibilityStateChange'** means to listen for the enabled status changes of the accessibility application.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
- **'touchGuideStateChange'** means to listen for the enabled status changes of the touch guide mode.
**System capability**: SystemCapability.BarrierFree.Accessibility.Vision|
- | callback | Callback<boolean> | No| Callback invoked when the enabled status changes.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Type of the event to listen for, which is set to **'touchGuideStateChange'** in this API.|
+| callback | Callback<boolean> | Yes| Callback used to return the result.|
-- **Example**
+**Example**
- ```typescript
- accessibility.off('accessibilityStateChange',(data) => {
- console.info('success data:unSubscribeStateObserver : ' + JSON.stringify(data))
- })
- ```
+```ts
+try {
+ accessibility.on('touchGuideStateChange', (data) => {
+ console.info('subscribe touch guide state change, result: ' + JSON.stringify(data));
+ });
+} catch (exception) {
+ console.error('failed to subscribe touch guide state change, because ' + JSON.stringify(exception));
+}
+```
+
+## accessibility.off('accessibilityStateChange')
+
+off(type: 'accessibilityStateChange', callback?: Callback<boolean>): void
+
+Disables listening for the enabled status changes of the accessibility application. This API uses an asynchronous callback to return the result.
+
+
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | No| Type of the event to listen for, which is set to **'accessibilityStateChange'** in this API.|
+| callback | Callback<boolean> | No| Callback used to return the result.|
+
+**Example**
+
+```ts
+try {
+ accessibility.off('accessibilityStateChange', (data) => {
+ console.info('Unsubscribe accessibility state change, result: ' + JSON.stringify(data));
+ });
+} catch (exception) {
+ console.error('failed to Unsubscribe accessibility state change, because ' + JSON.stringify(exception));
+}
+```
+
+## accessibility.off('touchGuideStateChange')
+
+off(type: 'touchGuideStateChange', callback?: Callback<boolean>): void
+
+Disables listening for the enabled status changes of the touch guide mode. This API uses an asynchronous callback to return the result.
+
+
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | No| Type of the event to listen for, which is set to **'touchGuideStateChange'** in this API.|
+| callback | Callback<boolean> | No| Callback used to return the result.|
+
+**Example**
+
+```ts
+try {
+ accessibility.off('touchGuideStateChange', (data) => {
+ console.info('Unsubscribe touch guide state change, result: ' + JSON.stringify(data));
+ });
+} catch (exception) {
+ console.error('failed to Unsubscribe touch guide state change, because ' + JSON.stringify(exception));
+}
+```
## accessibility.isOpenAccessibility
@@ -487,22 +683,21 @@ Checks whether accessibility is enabled. This API uses a promise to return the r
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-- **Return value**
+**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise<boolean> | Returns **true** if accessibility is enabled; returns **false** otherwise.|
+| Type| Description|
+| -------- | -------- |
+| Promise<boolean> | Promise used to return the result. Returns **true** if accessibility is enabled; returns **false** otherwise.|
-- **Example**
+**Example**
- ```typescript
- accessibility.isOpenAccessibility()
- .then((data) => {
- console.info('success data:isOpenAccessibility : ' + JSON.stringify(data))
- }).catch((error) => {
- console.error('failed to isOpenAccessibility because ' + JSON.stringify(error));
- })
- ```
+```ts
+accessibility.isOpenAccessibility().then((data) => {
+ console.info('success data:isOpenAccessibility : ' + JSON.stringify(data))
+}).catch((err) => {
+ console.error('failed to isOpenAccessibility because ' + JSON.stringify(err));
+});
+```
## accessibility.isOpenAccessibility
@@ -512,23 +707,23 @@ Checks whether accessibility is enabled. This API uses an asynchronous callback
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-- **Parameters**
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<boolean> | Yes| Callback used to return the result. Returns **true** if accessibility is enabled; returns **false** otherwise.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<boolean> | Yes| Callback used to return the result. Returns **true** if accessibility is enabled; returns **false** otherwise.|
-- **Example**
+**Example**
- ```typescript
- accessibility.isOpenAccessibility((err, data) => {
- if (err) {
- console.error('failed to isOpenAccessibility because ' + JSON.stringify(err));
- return;
- }
- console.info('success data:isOpenAccessibility : ' + JSON.stringify(data))
- })
- ```
+```ts
+accessibility.isOpenAccessibility((err, data) => {
+ if (err) {
+ console.error('failed to isOpenAccessibility because ' + JSON.stringify(err));
+ return;
+ }
+ console.info('success data:isOpenAccessibility : ' + JSON.stringify(data))
+});
+```
## accessibility.isOpenTouchGuide
@@ -538,22 +733,21 @@ Checks whether touch guide mode is enabled. This API uses a promise to return th
**System capability**: SystemCapability.BarrierFree.Accessibility.Vision
-- **Return value**
+**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise<boolean> | Returns **true** if touch guide mode is enabled; returns **false** otherwise.|
+| Type| Description|
+| -------- | -------- |
+| Promise<boolean> | Promise used to return the result. Returns **true** if touch guide mode is enabled; returns **false** otherwise.|
-- **Example**
+**Example**
- ```typescript
- accessibility.isOpenTouchGuide()
- .then((data) => {
- console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data))
- }).catch((error) => {
- console.error('failed to isOpenTouchGuide because ' + JSON.stringify(error));
- })
- ```
+```ts
+accessibility.isOpenTouchGuide().then((data) => {
+ console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data))
+}).catch((err) => {
+ console.error('failed to isOpenTouchGuide because ' + JSON.stringify(err));
+});
+```
## accessibility.isOpenTouchGuide
@@ -563,78 +757,172 @@ Checks whether touch guide mode is enabled. This API uses an asynchronous callba
**System capability**: SystemCapability.BarrierFree.Accessibility.Vision
-- **Parameters**
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<boolean> | Yes| Callback used to return the result. Returns **true** if touch guide mode is enabled; returns **false** otherwise.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<boolean> | Yes| Callback used to return the result. Returns **true** if touch guide mode is enabled; returns **false** otherwise.|
-- **Example**
+**Example**
- ```typescript
- accessibility.isOpenTouchGuide((err, data) => {
- if (err) {
- console.error('failed to isOpenTouchGuide because ' + JSON.stringify(err));
- return;
- }
- console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data))
- })
- ```
+```ts
+accessibility.isOpenTouchGuide((err, data) => {
+ if (err) {
+ console.error('failed to isOpenTouchGuide because ' + JSON.stringify(err));
+ return;
+ }
+ console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data))
+});
+```
-## accessibility.sendEvent
+## accessibility.sendEvent(deprecated)
sendEvent(event: EventInfo): Promise<void>
Sends an accessibility event. This API uses a promise to return the result.
-**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-
-- **Parameters**
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9.
+> You are advised to use **[sendAccessibilityEvent()](#accessibilitysendaccessibilityevent9)**.
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | event | [EventInfo](#eventinfo) | Yes| Accessibility event.|
+**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-- **Return value**
+**Parameters**
- | Type| Description|
- | -------- | -------- |
- | Promise<void> | Promise used to return the result. Returns data if the accessibility event is sent successfully; returns an error otherwise.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| event | [EventInfo](#eventinfo) | Yes| Accessibility event.|
-- **Example**
+**Return value**
- ```typescript
- accessibility.sendEvent(this.eventInfo)
- .then((data) => {
- console.info('success data:sendEvent : ' + JSON.stringify(data))
- }).catch((error) => {
- console.error('failed to sendEvent because ' + JSON.stringify(error));
- })
- ```
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise that returns no value.|
+
+**Example**
+
+```ts
+let eventInfo = new accessibility.EventInfo({
+ 'type':'click',
+ 'bundleName':'com.example.MyApplication',
+ 'triggerAction':'click'
+});
+accessibility.sendEvent(eventInfo).then(() => {
+ console.info('send event success');
+}).catch((err) => {
+ console.error('failed to sendEvent because ' + JSON.stringify(err));
+});
+```
-## accessibility.sendEvent
+## accessibility.sendEvent(deprecated)
sendEvent(event: EventInfo, callback: AsyncCallback<void>): void
Sends an accessibility 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 **[sendAccessibilityEvent()](#accessibilitysendaccessibilityevent9-1)**.
+
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-- **Parameters**
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| event | [EventInfo](#eventinfo) | Yes| Accessibility event.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation fails, **error** that contains data is returned. |
+
+**Example**
+
+```ts
+let eventInfo = new accessibility.EventInfo({
+ 'type':'click',
+ 'bundleName':'com.example.MyApplication',
+ 'triggerAction':'click'
+});
+accessibility.sendEvent(eventInfo, (err, data) => {
+ if (err) {
+ console.error('failed to sendEvent because ' + JSON.stringify(err));
+ return;
+ }
+ console.info('sendEvent success');
+});
+```
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | event | [EventInfo](#eventinfo) | Yes| Accessibility event.|
- | callback | AsyncCallback<void> | Yes| Callback used to return the result. Returns data if the accessibility event is sent successfully; returns an error otherwise.|
+## accessibility.sendAccessibilityEvent9+
-- **Example**
+sendAccessibilityEvent(event: EventInfo): Promise<void>
- ```typescript
- accessibility.sendEvent(this.eventInfo,(err, data) => {
- if (err) {
- console.error('failed to sendEvent because ' + JSON.stringify(err));
- return;
- }
- console.info('success data:sendEvent : ' + JSON.stringify(data))
- })
- ```
+Sends an accessibility event. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.BarrierFree.Accessibility.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| event | [EventInfo](#eventinfo) | Yes| Accessibility event.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise that returns no value.|
+
+**Example**
+
+```ts
+let eventInfo = new accessibility.EventInfo({
+ 'type':'click',
+ 'bundleName':'com.example.MyApplication',
+ 'triggerAction':'click'
+});
+try {
+ accessibility.sendAccessibilityEvent(eventInfo).then(() => {
+ console.info('send event success');
+ }).catch((err) => {
+ console.error('failed to send event because ' + JSON.stringify(err));
+ });
+} catch (exception) {
+ console.error('failed to send event because ' + JSON.stringify(exception));
+}
+```
+
+## accessibility.sendAccessibilityEvent9+
+
+sendAccessibilityEvent(event: EventInfo, callback: AsyncCallback<void>): void
+
+Sends an accessibility event. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.BarrierFree.Accessibility.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| event | [EventInfo](#eventinfo) | Yes| Accessibility event.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation fails, **error** that contains data is returned. |
+
+**Example**
+
+```ts
+let eventInfo = new accessibility.EventInfo({
+ 'type':'click',
+ 'bundleName':'com.example.MyApplication',
+ 'triggerAction':'click'
+});
+try {
+ accessibility.sendEvent(eventInfo, (err, data) => {
+ if (err) {
+ console.error('failed to send event because ' + JSON.stringify(err));
+ return;
+ }
+ console.info('send event success');
+ });
+} catch (exception) {
+ console.error('failed to send event because ' + JSON.stringify(exception));
+}
+```
diff --git a/en/application-dev/reference/apis/js-apis-animator.md b/en/application-dev/reference/apis/js-apis-animator.md
index 9c1088af3a0fa0c7d15b56f51cdcfa49a9addde9..da7ec7d145779eb5044427fdee758a34f6b33fdc 100644
--- a/en/application-dev/reference/apis/js-apis-animator.md
+++ b/en/application-dev/reference/apis/js-apis-animator.md
@@ -1,4 +1,6 @@
-# Animator
+# @ohos.animator
+
+The **animator** module provides APIs for applying animation effects, including defining animations, starting animations, and playing animations in reverse order.
> **NOTE**
>
@@ -7,98 +9,90 @@
## Modules to Import
-```
+```js
import animator from '@ohos.animator';
```
+## create9+
-
-## createAnimator
-
-createAnimator(options: AnimatorOptions): AnimatorResult
+create(options: AnimatorOptions): AnimatorResult
Creates an **Animator** object.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| options | [AnimatorOptions](#animatoroptions) | Yes| Animator options.|
+
+| Name | Type | Mandatory | Description |
+| ------- | ----------------------------------- | ---- | ------- |
+| options | [AnimatorOptions](#animatoroptions) | Yes | Animator options.|
**Return value**
-| Type| Description|
-| -------- | -------- |
+
+| Type | Description |
+| --------------------------------- | ------------- |
| [AnimatorResult](#animatorresult) | Animator result.|
**Example**
- ```
-
-
- ```
-
- ```
- // js
- export default {
- data : {
- divWidth: 200,
- divHeight: 200,
- animator: null
- },
- onInit() {
- var options = {
- duration: 1500,
- easing: 'friction',
- fill: 'forwards',
- iterations: 2,
- begin: 200.0,
- end: 400.0
- };
- this.animator = animator.createAnimator(options);
- },
- Show() {
- var options1 = {
- duration: 2000,
- easing: 'friction',
- fill: 'forwards',
- iterations: 1,
- begin: 200.0,
- end: 400.0
- };
- this.animator.update(options1);
- var _this = this;
- this.animator.onframe = function(value) {
- _this.divWidth = value;
- _this.divHeight = value;
- };
- this.animator.play();
- }
- }
+ ```js
+ let options = {
+ duration: 1500,
+ easing: 'friction',
+ delay: 0,
+ fill: 'forwards',
+ direction: 'normal',
+ iterations: 3,
+ begin: 200.0,
+ end: 400.0
+ };
+ animator.create(options);
```
## AnimatorResult
Defines the animator result.
-### update
+### reset9+
-update(options: AnimatorOptions): void
+reset(options: AnimatorOptions): void
Updates this animator.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| options | [AnimatorOptions](#animatoroptions) | Yes| Animator options.|
+
+| Name | Type | Mandatory | Description |
+| ------- | ----------------------------------- | ---- | ------- |
+| options | [AnimatorOptions](#animatoroptions) | Yes | Animator options.|
+
+**Error codes**
+
+For details about the error codes, see [Animator Error Codes](../errorcodes/errorcode-animator.md).
+
+| ID | Error Message|
+| --------- | ------- |
+| 100001 | If no page is found for pageId or fail to get object property list. |
+
**Example**
-```
-animator.update(options);
+
+```js
+let options = {
+ duration: 1500,
+ easing: 'friction',
+ delay: 0,
+ fill: 'forwards',
+ direction: 'normal',
+ iterations: 3,
+ begin: 200.0,
+ end: 400.0
+};
+try {
+ animator.reset(options);
+} catch(error) {
+ console.error(`Animator reset failed, error code: ${error.code}, message: ${error.message}.`);
+}
```
### play
@@ -110,7 +104,8 @@ Plays this animation.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Example**
-```
+
+```js
animator.play();
```
@@ -123,7 +118,8 @@ Ends this animation.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Example**
-```
+
+```js
animator.finish();
```
@@ -136,7 +132,8 @@ Pauses this animation.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Example**
-```
+
+```js
animator.pause();
```
@@ -149,7 +146,8 @@ Cancels this animation.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Example**
-```
+
+```js
animator.cancel();
```
@@ -162,7 +160,8 @@ Plays this animation in reverse order.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Example**
-```
+
+```js
animator.reverse();
```
@@ -175,13 +174,18 @@ Called when a frame is received.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| progress | number | Yes| Current progress of the animation.|
+
+| Name | Type | Mandatory | Description |
+| -------- | ------ | ---- | -------- |
+| progress | number | Yes | Current progress of the animation.|
**Example**
-```
-animator.onframe();
+
+```js
+let animatorResult = animator.create(options)
+animatorResult.onframe = function(value) {
+ console.info("onframe callback")
+}
```
### onfinish
@@ -193,8 +197,12 @@ Called when this animation is finished.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Example**
-```
-animator.onfinish();
+
+```js
+let animatorResult = animator.create(options)
+animatorResult.onfinish = function() {
+ console.info("onfinish callback")
+}
```
### oncancel
@@ -206,8 +214,12 @@ Called when this animation is canceled.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Example**
-```
-animator.oncancel();
+
+```js
+let animatorResult = animator.create(options)
+animatorResult.oncancel = function() {
+ console.info("oncancel callback")
+}
```
### onrepeat
@@ -219,9 +231,15 @@ Called when this animation repeats.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Example**
+
+```js
+let animatorResult = animator.create(options)
+animatorResult.onrepeat = function() {
+ console.info("onrepeat callback")
+}
```
-animator.onrepeat();
-```
+
+
## AnimatorOptions
@@ -229,13 +247,279 @@ Defines animator options.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| duration | number | Yes| Duration for playing the animation, in milliseconds. The default value is **0**.|
-| easing | string | Yes| Animation interpolation curve. The default value is **'ease'**.|
-| delay | number | Yes| Animation delay duration, in milliseconds. The default value is **0**, indicating that there is no delay.|
-| fill | "none" \| "forwards" \| "backwards" \| "both" | Yes| State of the animated target after the animation is executed. The default value is **none**, which means that the target will retain its end state (defined by the last keyframe) after the animation is executed. |
-| direction | "normal" \| "reverse" \| "alternate" \| "alternate-reverse" | Yes| Animation playback mode. The default value is **normal**.|
-| iterations | number | Yes| Number of times that the animation is played. The default value is **1**. The value **0** means not to play the animation, and **-1** means to play the animation for an unlimited number of times.|
-| begin | number | Yes| Start point of the animation interpolation. If this parameter is not set, the default value **0** is used.|
-| end | number | Yes| End point of the animation interpolation. If this parameter is not set, the default value **1** is used.|
+| Name | Type | Mandatory | Description |
+| ---------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| duration | number | Yes | Duration for playing the animation, in milliseconds. The default value is **0**. |
+| easing | string | Yes | Animation interpolation curve. The default value is **ease**. |
+| delay | number | Yes | Animation delay duration, in milliseconds. The default value is **0**, indicating that there is no delay. |
+| fill | "none" \| "forwards" \| "backwards" \| "both" | Yes | State of the animated target after the animation is executed. The default value is **none**, which means that the target will retain its end state (defined by the last keyframe) after the animation is executed.|
+| direction | "normal" \| "reverse" \| "alternate" \| "alternate-reverse" | Yes | Animation playback mode. The default value is **normal**. |
+| iterations | number | Yes | Number of times that the animation is played. The default value is **1**. The value **0** means not to play the animation, and **-1** means to play the animation for an unlimited number of times. |
+| begin | number | Yes | Start point of the animation interpolation. The default value is 0. |
+| end | number | Yes | End point of animation interpolation. The default value is 1. |
+
+
+## Example
+### JavaScript-compatible Web-like Development Paradigm
+
+```html
+
+
+```
+
+```js
+export default {
+ data: {
+ divWidth: 200,
+ divHeight: 200,
+ animator: null
+ },
+ onInit() {
+ let options = {
+ duration: 1500,
+ easing: 'friction',
+ delay: 0,
+ fill: 'forwards',
+ direction: 'normal',
+ iterations: 2,
+ begin: 200.0,
+ end: 400.0
+ };
+ this.animator = animator.create(options);
+ },
+ Show() {
+ let options1 = {
+ duration: 1500,
+ easing: 'friction',
+ delay: 0,
+ fill: 'forwards',
+ direction: "normal",
+ iterations: 2,
+ begin: 0,
+ end: 400.0,
+ };
+ try {
+ this.animator.reset(options1);
+ } catch(error) {
+ console.error(`Animator reset failed, error code: ${error.code}, message: ${error.message}.`);
+ }
+ let _this = this;
+ this.animator.onframe = function(value) {
+ _this.divWidth = value;
+ _this.divHeight = value;
+ };
+ this.animator.play();
+ }
+}
+```
+
+ ![en-us_image_00007](figures/en-us_image_00007.gif)
+
+### ArkTS-based Declarative Development Paradigm
+
+```ts
+import animator from '@ohos.animator';
+
+@Entry
+@Component
+struct AnimatorTest {
+ private TAG: string = '[AnimatorTest]'
+ private backAnimator: any = undefined
+ private flag: boolean = false
+ @State wid: number = 100
+ @State hei: number = 100
+
+ create() {
+ let _this = this
+ this.backAnimator = animator.create({
+ duration: 2000,
+ easing: 'ease',
+ delay: 0,
+ fill: 'none',
+ direction: 'normal',
+ iterations: 1,
+ begin: 100,
+ end: 200
+ })
+ this.backAnimator.onfinish = function () {
+ _this.flag = true
+ console.info(_this.TAG, 'backAnimator onfinish')
+ }
+ this.backAnimator.onrepeat = function () {
+ console.info(_this.TAG, 'backAnimator repeat')
+ }
+ this.backAnimator.oncancel = function () {
+ console.info(_this.TAG, 'backAnimator cancel')
+ }
+ this.backAnimator.onframe = function (value) {
+ _this.wid = value
+ _this.hei = value
+ }
+ }
+
+ build() {
+ Column() {
+ Column() {
+ Column()
+ .width(this.wid)
+ .height(this.hei)
+ .backgroundColor(Color.Red)
+ }
+ .width('100%')
+ .height(300)
+
+ Column() {
+ Row() {
+ Button('create')
+ .fontSize(30)
+ .fontColor(Color.Black)
+ .onClick(() => {
+ this.create()
+ })
+ }
+ .padding(10)
+
+ Row() {
+ Button('play')
+ .fontSize(30)
+ .fontColor(Color.Black)
+ .onClick(() => {
+ this.flag = false
+ this.backAnimator.play()
+ })
+ }
+ .padding(10)
+
+ Row() {
+ Button('pause')
+ .fontSize(30)
+ .fontColor(Color.Black)
+ .onClick(() => {
+ this.backAnimator.pause()
+ })
+ }
+ .padding(10)
+
+ Row() {
+ Button('finish')
+ .fontSize(30)
+ .fontColor(Color.Black)
+ .onClick(() => {
+ this.flag = true
+ this.backAnimator.finish()
+ })
+ }
+ .padding(10)
+
+ Row() {
+ Button('reverse')
+ .fontSize(30)
+ .fontColor(Color.Black)
+ .onClick(() => {
+ this.flag = false
+ this.backAnimator.reverse()
+ })
+ }
+ .padding(10)
+
+ Row() {
+ Button('cancel')
+ .fontSize(30)
+ .fontColor(Color.Black)
+ .onClick(() => {
+ this.backAnimator.cancel()
+ })
+ }
+ .padding(10)
+
+ Row() {
+ Button('reset')
+ .fontSize(30)
+ .fontColor(Color.Black)
+ .onClick(() => {
+ if (this.flag) {
+ this.flag = false
+ this.backAnimator.reset({
+ duration: 5000,
+ easing: 'ease-in',
+ delay: 0,
+ fill: 'none',
+ direction: 'normal',
+ iterations: 4,
+ begin: 100,
+ end: 300
+ })
+ } else {
+ console.info(this.TAG, 'Animation not ended')
+ }
+ })
+ }
+ .padding(10)
+ }
+ }
+ }
+}
+```
+
+## update(deprecated)
+
+update(options: AnimatorOptions): void
+
+Updates this animator.
+
+This API is deprecated since API version 9. You are advised to use [reset9+](#reset9) instead.
+
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------- | ----------------------------------- | ---- | ------- |
+| options | [AnimatorOptions](#animatoroptions) | Yes | Animator options.|
+
+**Example**
+
+```js
+animator.update(options);
+```
+
+## createAnimator(deprecated)
+
+createAnimator(options: AnimatorOptions): AnimatorResult
+
+Creates an **Animator** object.
+
+This API is deprecated since API version 9. You are advised to use [create9+](#create9) instead.
+
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------- | ----------------------------------- | ---- | ------- |
+| options | [AnimatorOptions](#animatoroptions) | Yes | Animator options.|
+
+**Return value**
+
+| Type | Description |
+| --------------------------------- | ------------- |
+| [AnimatorResult](#animatorresult) | Animator result.|
+
+**Example**
+
+```js
+let options = {
+ duration: 1500,
+ easing: 'friction',
+ delay: 0,
+ fill: 'forwards',
+ direction: 'normal',
+ iterations: 3,
+ begin: 200.0,
+ end: 400.0,
+};
+this.animator = animator.createAnimator(options);
+```
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-ability.md b/en/application-dev/reference/apis/js-apis-app-ability-ability.md
new file mode 100644
index 0000000000000000000000000000000000000000..cfa11ddc30560c1ffa6a03eb8efccb8ea60b6d5b
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-ability.md
@@ -0,0 +1,61 @@
+# @ohos.app.ability.Ability (Ability Base Class)
+
+This is the base class of [UIAbility](js-apis-app-ability-uiAbility.md) and [ExtensionAbility](js-apis-app-ability-extensionAbility.md). It provides the callbacks for system configuration updates and memory level updates. You cannot inherit from this base class.
+
+> **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 can be used only in the stage model.
+
+## Ability.onConfigurationUpdate
+
+onConfigurationUpdate(newConfig: Configuration): void;
+
+Called when the configuration of the environment where the ability is running is updated.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| newConfig | [Configuration](js-apis-app-ability-configuration.md) | Yes| New configuration.|
+
+**Example**
+ ```ts
+// You are not allowed to inherit from the top-level base class Ability. Therefore, the derived class UIAbility is used as an example.
+import UIAbility from '@ohos.app.ability.UIAbility';
+
+class MyUIAbility extends UIAbility {
+ onConfigurationUpdate(config) {
+ console.log('onConfigurationUpdate, config:' + JSON.stringify(config));
+ }
+}
+ ```
+
+## Ability.onMemoryLevel
+
+onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
+
+Called when the system adjusts the memory level.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| level | [AbilityConstant.MemoryLevel](js-apis-app-ability-abilityConstant.md#abilityconstantmemorylevel) | Yes| New memory level.|
+
+**Example**
+
+ ```ts
+// You are not allowed to inherit from the top-level base class Ability. Therefore, the derived class UIAbility is used as an example.
+import UIAbility from '@ohos.app.ability.UIAbility';
+
+class MyUIAbility extends UIAbility {
+ onMemoryLevel(level) {
+ console.log('onMemoryLevel, level:' + JSON.stringify(level));
+ }
+}
+ ```
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md b/en/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md
new file mode 100644
index 0000000000000000000000000000000000000000..766636a7c7d4cda38cb2b71395fd3f2575e2f784
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md
@@ -0,0 +1,217 @@
+# @ohos.app.ability.AbilityConstant (AbilityConstant)
+
+The **AbilityConstant** module defines the ability-related enums, including the initial launch reasons, reasons for the last exit, ability continuation results, and window modes.
+
+> **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 can be used only in the stage model.
+
+## Modules to Import
+
+```ts
+import AbilityConstant from '@ohos.app.ability.AbilityConstant';
+```
+
+## Attributes
+
+## AbilityConstant.LaunchParam
+
+Defines the parameters for starting an ability.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name| Type| Readable| Writable| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| launchReason | [LaunchReason](#abilityconstantlaunchreason)| Yes| Yes| Ability launch reason, which is an enumerated type.|
+| lastExitReason | [LastExitReason](#abilityconstantlastexitreason) | Yes| Yes| Reason for the last exit, which is an enumerated type.|
+
+## AbilityConstant.LaunchReason
+
+Enumerates the initial ability launch reasons. You can use it together with [onCreate(want, launchParam)](js-apis-app-ability-uiAbility.md#uiabilityoncreate) of [Ability](js-apis-app-ability-uiAbility.md) to complete different operations.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name | Value | Description |
+| ----------------------------- | ---- | ------------------------------------------------------------ |
+| UNKNOWN | 0 | Unknown reason.|
+| START_ABILITY | 1 | The ability is started by calling [startAbility](js-apis-ability-context.md#abilitycontextstartability).|
+| CALL | 2 | The ability is started by calling [startAbilityByCall](js-apis-ability-context.md#abilitycontextstartabilitybycall).|
+| CONTINUATION | 3 | The ability is started by means of cross-device migration.|
+| APP_RECOVERY | 4 | The ability is automatically started when the application is restored from a fault.|
+
+**Example**
+
+```ts
+import UIAbility from '@ohos.app.ability.UIAbility';
+
+class MyAbility extends UIAbility {
+ onCreate(want, launchParam) {
+ if (launchParam.launchReason === AbilityConstant.LaunchReason.START_ABILITY) {
+ console.log("The ability has been started by the way of startAbility.");
+ }
+ }
+}
+```
+
+## AbilityConstant.LastExitReason
+
+Enumerates the reasons for the last exit. You can use it together with [onCreate(want, launchParam)](js-apis-app-ability-uiAbility.md#uiabilityoncreate) of [Ability](js-apis-app-ability-uiAbility.md) to complete different operations.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name | Value | Description |
+| ----------------------------- | ---- | ------------------------------------------------------------ |
+| UNKNOWN | 0 | Unknown reason.|
+| ABILITY_NOT_RESPONDING | 1 | The ability does not respond.|
+| NORMAL | 2 | The ability exits normally.|
+
+**Example**
+
+```ts
+import UIAbility from '@ohos.app.ability.UIAbility';
+
+class MyAbility extends UIAbility {
+ onCreate(want, launchParam) {
+ if (launchParam.lastExitReason === AbilityConstant.LastExitReason.ABILITY_NOT_RESPONDING) {
+ console.log("The ability has exit last because the ability was not responding.");
+ }
+ }
+}
+```
+
+## AbilityConstant.OnContinueResult
+
+Enumerates the ability continuation results. You can use it together with [onContinue(wantParam)](js-apis-app-ability-uiAbility.md#uiabilityoncontinue) of [Ability](js-apis-app-ability-uiAbility.md) to complete different operations.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name | Value | Description |
+| ----------------------------- | ---- | ------------------------------------------------------------ |
+| AGREE | 0 | Continuation agreed.|
+| REJECT | 1 | Continuation denied.|
+| MISMATCH | 2 | Mismatch.|
+
+**Example**
+
+```ts
+import UIAbility from '@ohos.app.ability.UIAbility';
+
+class MyAbility extends UIAbility {
+ onContinue(wantParam) {
+ return AbilityConstant.OnConinueResult.AGREE;
+ }
+}
+```
+
+## AbilityConstant.WindowMode
+
+Enumerates the window modes in which an ability can be displayed at startup. It can be used in **startAbility()** to specify the window mode when the ability is started.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name | Value| Description |
+| --- | --- | --- |
+| WINDOW_MODE_UNDEFINED | 0 | Undefined window mode. |
+| WINDOW_MODE_FULLSCREEN | 1 | The ability is displayed in full screen. |
+| WINDOW_MODE_SPLIT_PRIMARY | 100 | The ability is displayed in the primary window in split-screen mode. |
+| WINDOW_MODE_SPLIT_SECONDARY | 101 | The ability is displayed in the secondary window in split-screen mode. |
+| WINDOW_MODE_FLOATING | 102 | The ability is displayed in a floating window.|
+
+**Example**
+
+```ts
+let want = {
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
+};
+let option = {
+ windowMode: AbilityConstant.WindowMode.WINDOW_MODE_FULLSCREEN
+};
+
+// Ensure that the context is obtained.
+this.context.startAbility(want, option).then(()={
+ console.log("Succeed to start ability.");
+}).catch((error)=>{
+ console.log("Failed to start ability with error: " + JSON.stringify(error));
+});
+```
+
+## AbilityConstant.MemoryLevel
+
+Enumerates the memory levels. You can use it in [onMemoryLevel(level)](js-apis-app-ability-ability.md#abilityonmemorylevel) of [Ability](js-apis-app-ability-ability.md) to complete different operations.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name | Value| Description |
+| --- | --- | --- |
+| MEMORY_LEVEL_MODERATE | 0 | Moderate memory usage.|
+| MEMORY_LEVEL_LOW | 1 | Low memory usage. |
+| MEMORY_LEVEL_CRITICAL | 2 | High memory usage. |
+
+**Example**
+
+```ts
+import UIAbility from '@ohos.app.ability.UIAbility';
+
+class MyAbility extends UIAbility {
+ onMemoryLevel(level) {
+ if (level === AbilityConstant.MemoryLevel.MEMORY_LEVEL_CRITICAL) {
+ console.log("The memory of device is critical, please release some memory.");
+ }
+ }
+}
+```
+
+## AbilityConstant.OnSaveResult
+
+Enumerates the result types for the operation of saving application data. You can use it in [onSaveState(reason, wantParam)](js-apis-app-ability-uiAbility.md#uiabilityonsavestate) of [Ability](js-apis-app-ability-uiAbility.md) to complete different operations.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name | Value | Description |
+| ----------------------------- | ---- | ------------------------------------------------------------ |
+| ALL_AGREE | 0 | Always agreed to save the status.|
+| CONTINUATION_REJECT | 1 | Rejected to save the status in continuation.|
+| CONTINUATION_MISMATCH | 2 | Continuation mismatch.|
+| RECOVERY_AGREE | 3 | Agreed to restore the saved status.|
+| RECOVERY_REJECT | 4 | Rejected to restore the saved state.|
+| ALL_REJECT | 5 | Always rejected to save the status.|
+
+**Example**
+
+```ts
+import UIAbility from '@ohos.app.ability.UIAbility';
+
+class MyAbility extends UIAbility {
+ onSaveState(reason, wantParam) {
+ return AbilityConstant.OnSaveResult.ALL_AGREE;
+ }
+}
+```
+
+## AbilityConstant.StateType
+
+Enumerates the scenarios for saving application data. You can use it in [onSaveState(reason, wantParam)](js-apis-app-ability-uiAbility.md#uiabilityonsavestate) of [Ability](js-apis-app-ability-uiAbility.md) to complete different operations.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name | Value | Description |
+| ----------------------------- | ---- | ------------------------------------------------------------ |
+| CONTINUATION | 0 | Saving the status in continuation.|
+| APP_RECOVERY | 1 | Saving the status in application recovery.|
+
+**Example**
+
+```ts
+import UIAbility from '@ohos.app.ability.UIAbility';
+
+class MyAbility extends UIAbility {
+ onSaveState(reason, wantParam) {
+ if (reason === AbilityConstant.StateType.CONTINUATION) {
+ console.log("Save the ability data when the ability continuation.");
+ }
+ return AbilityConstant.OnSaveResult.ALL_AGREE;
+ }
+}
+```
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-abilityDelegatorRegistry.md b/en/application-dev/reference/apis/js-apis-app-ability-abilityDelegatorRegistry.md
new file mode 100644
index 0000000000000000000000000000000000000000..5cfa437047868a9183ae4bb4f41ff42eec47f5d7
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-abilityDelegatorRegistry.md
@@ -0,0 +1,88 @@
+# @ohos.app.ability.abilityDelegatorRegistry (AbilityDelegatorRegistry)
+
+**AbilityDelegatorRegistry**, a module of the [Test Framework](../../ability-deprecated/ability-delegator.md), is used to obtain [AbilityDelegator](js-apis-inner-application-abilityDelegator.md) and [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md) objects. **AbilityDelegator** provides APIs for creating **AbilityMonitor** objects, which can be used to listen for ability lifecycle changes. **AbilityDelegatorArgs** provides APIs for obtaining test parameters.
+
+> **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 can be used only in the test framework.
+
+## Modules to Import
+
+```ts
+import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
+```
+
+## AbilityLifecycleState
+
+Enumerates the ability lifecycle states. It can be used in [getAbilityState(ability)](js-apis-inner-application-abilityDelegator.md#getabilitystate9) of [AbilityDelegator](js-apis-inner-application-abilityDelegator.md) to return different ability lifecycle states.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name | Value | Description |
+| ------------- | ---- | --------------------------- |
+| UNINITIALIZED | 0 | The ability is in an invalid state. |
+| CREATE | 1 | The ability is created.|
+| FOREGROUND | 2 | The ability is running in the foreground. |
+| BACKGROUND | 3 | The ability is running in the background. |
+| DESTROY | 4 | The ability is destroyed.|
+
+## AbilityDelegatorRegistry.getAbilityDelegator
+
+getAbilityDelegator(): AbilityDelegator
+
+Obtains an [AbilityDelegator](js-apis-inner-application-abilityDelegator.md) object.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
+
+| Type | Description |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| [AbilityDelegator](js-apis-inner-application-abilityDelegator.md#AbilityDelegator) | [AbilityDelegator](js-apis-inner-application-abilityDelegator.md#AbilityDelegator) object, which can be used to schedule the functionalities of the test framework.|
+
+**Example**
+
+```ts
+import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
+
+let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
+
+let want = {
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility"
+};
+abilityDelegator.startAbility(want, (err) => {
+ if (err.code !== 0) {
+ console.log("Success start ability.");
+ } else {
+ console.log("Failed start ability, error: " + JSON.stringify(err));
+ }
+})
+```
+
+## AbilityDelegatorRegistry.getArguments
+
+getArguments(): AbilityDelegatorArgs
+
+Obtains an [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md) object.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
+
+| Type | Description |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md) | [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md) object, which can be used to obtain test parameters.|
+
+**Example**
+
+```ts
+import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
+
+let args = AbilityDelegatorRegistry.getArguments();
+console.info("getArguments bundleName:" + args.bundleName);
+console.info("getArguments parameters:" + JSON.stringify(args.parameters));
+console.info("getArguments testCaseNames:" + args.testCaseNames);
+console.info("getArguments testRunnerClassName:" + args.testRunnerClassName);
+```
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md b/en/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md
new file mode 100644
index 0000000000000000000000000000000000000000..84be19350707fee37328ff8040b2986588afd2f8
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md
@@ -0,0 +1,303 @@
+# @ohos.app.ability.abilityLifecycleCallback (AbilityLifecycleCallback)
+
+The **AbilityLifecycleCallback** module defines the callbacks to receive lifecycle changes of [ApplicationContext](js-apis-inner-application-applicationContext.md). The callbacks include [onAbilityCreate](#abilitylifecyclecallbackonabilitycreate), [onWindowStageCreate](#abilitylifecyclecallbackonwindowstagecreate), [onWindowStageActive](#abilitylifecyclecallbackonwindowstageactive), [onWindowStageInactive](#abilitylifecyclecallbackonwindowstageinactive), [onWindowStageDestroy](#abilitylifecyclecallbackonwindowstagedestroy), [onAbilityDestroy](#abilitylifecyclecallbackonabilitydestroy), [onAbilityForeground](#abilitylifecyclecallbackonabilityforeground), [onAbilityBackground](#abilitylifecyclecallbackonabilitybackground), and [onAbilityContinue](#abilitylifecyclecallbackonabilitycontinue).
+
+> **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 can be used only in the stage model.
+
+
+## Modules to Import
+
+```ts
+import AbilityLifecycleCallback from "@ohos.app.ability.AbilityLifecycleCallback";
+```
+
+
+## AbilityLifecycleCallback.onAbilityCreate
+
+onAbilityCreate(ability: UIAbility): void;
+
+Called when an ability is created.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
+
+**Example**
+```ts
+let abilityLifecycleCallback = {
+ onAbilityCreate(ability){
+ console.log("AbilityLifecycleCallback onAbilityCreate.");
+ }
+};
+```
+
+## AbilityLifecycleCallback.onWindowStageCreate
+
+onWindowStageCreate(ability: UIAbility, windowStage: window.WindowStage): void;
+
+Called when the window stage of an ability is created.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
+| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
+
+**Example**
+```ts
+let abilityLifecycleCallback = {
+ onWindowStageCreate(ability, windowStage){
+ console.log("AbilityLifecycleCallback onWindowStageCreate.");
+ }
+};
+```
+
+## AbilityLifecycleCallback.onWindowStageActive
+
+onWindowStageActive(ability: UIAbility, windowStage: window.WindowStage): void;
+
+Called when the window stage of an ability gains focus.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
+| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
+
+**Example**
+```ts
+let abilityLifecycleCallback = {
+ onWindowStageActive(ability, windowStage){
+ console.log("AbilityLifecycleCallback onWindowStageActive.");
+ }
+};
+```
+
+## AbilityLifecycleCallback.onWindowStageInactive
+
+onWindowStageInactive(ability: UIAbility, windowStage: window.WindowStage): void;
+
+Called when the window stage of an ability loses focus.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
+| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
+
+**Example**
+```ts
+let abilityLifecycleCallback = {
+ onWindowStageInactive(ability, windowStage){
+ console.log("AbilityLifecycleCallback onWindowStageInactive.");
+ }
+};
+```
+
+## AbilityLifecycleCallback.onWindowStageDestroy
+
+onWindowStageDestroy(ability: UIAbility, windowStage: window.WindowStage): void;
+
+Called when the window stage of an ability is destroyed.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
+| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
+
+**Example**
+```ts
+let abilityLifecycleCallback = {
+ onWindowStageDestroy(ability, windowStage){
+ console.log("AbilityLifecycleCallback onWindowStageDestroy.");
+ }
+};
+```
+
+## AbilityLifecycleCallback.onAbilityDestroy
+
+onAbilityDestroy(ability: UIAbility): void;
+
+Called when an ability is destroyed.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
+
+**Example**
+```ts
+let abilityLifecycleCallback = {
+ onAbilityDestroy(ability){
+ console.log("AbilityLifecycleCallback onAbilityDestroy.");
+ }
+};
+```
+
+## AbilityLifecycleCallback.onAbilityForeground
+
+onAbilityForeground(ability: UIAbility): void;
+
+Called when an ability is switched from the background to the foreground.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
+
+**Example**
+```ts
+let abilityLifecycleCallback = {
+ onAbilityForeground(ability){
+ console.log("AbilityLifecycleCallback onAbilityForeground.");
+ }
+};
+```
+
+## AbilityLifecycleCallback.onAbilityBackground
+
+onAbilityBackground(ability: UIAbility): void;
+
+Called when an ability is switched from the foreground to the background.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
+
+**Example**
+```ts
+let abilityLifecycleCallback = {
+ onAbilityBackground(ability){
+ console.log("AbilityLifecycleCallback onAbilityBackground.");
+ }
+};
+```
+
+## AbilityLifecycleCallback.onAbilityContinue
+
+onAbilityContinue(ability: UIAbility): void;
+
+Called when an ability is continued on another device.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
+
+**Example**
+```ts
+let abilityLifecycleCallback = {
+ onAbilityContinue(ability){
+ console.log("AbilityLifecycleCallback onAbilityContinue.");
+ }
+};
+```
+
+## Usage of AbilityLifecycleCallback
+
+**Example**
+
+MyFirstAbility.ts
+```ts
+import AbilityLifecycleCallback from "@ohos.app.ability.AbilityLifecycleCallback";
+import AbilityStage from "@ohos.app.ability.AbilityStage";
+import UIAbility from '@ohos.app.ability.UIAbility';
+
+// Declare the ability lifecycle callbacks. A listener can be registered in applicationContext only after all the callbacks are configured.
+let abilityLifecycleCallback = {
+ onAbilityCreate(ability){
+ console.log("AbilityLifecycleCallback onAbilityCreate.");
+ },
+ onWindowStageCreate(ability, windowStage){
+ console.log("AbilityLifecycleCallback onWindowStageCreate.");
+ },
+ onWindowStageActive(ability, windowStage){
+ console.log("AbilityLifecycleCallback onWindowStageActive.");
+ },
+ onWindowStageInactive(ability, windowStage){
+ console.log("AbilityLifecycleCallback onWindowStageInactive.");
+ },
+ onWindowStageDestroy(ability, windowStage){
+ console.log("AbilityLifecycleCallback onWindowStageDestroy.");
+ },
+ onAbilityDestroy(ability){
+ console.log("AbilityLifecycleCallback onAbilityDestroy.");
+ },
+ onAbilityForeground(ability){
+ console.log("AbilityLifecycleCallback onAbilityForeground.");
+ },
+ onAbilityBackground(ability){
+ console.log("AbilityLifecycleCallback onAbilityBackground.");
+ },
+ onAbilityContinue(ability){
+ console.log("AbilityLifecycleCallback onAbilityContinue.");
+ }
+};
+
+export default class MyFirstAbility extends UIAbility {
+ onCreate() {
+ console.log("MyAbilityStage onCreate");
+ // 1. Obtain applicationContext through the context attribute.
+ let applicationContext = this.context.getApplicationContext();
+ // 2. Register the listener for the ability lifecycle changes through the applicationContext object.
+ try {
+ globalThis.lifecycleId = applicationContext.on("abilityLifecycle", abilityLifecycleCallback);
+ console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleId));
+ } catch (paramError) {
+ console.log("error: " + paramError.code + " ," + paramError.message);
+ }
+ }
+}
+```
+
+MySecondAbility.ts
+```ts
+import UIAbility from "ohos.app.ability.UIAbility";
+
+export default class MySecondAbility extends UIAbility {
+ onDestroy() {
+ let applicationContext = this.context.getApplicationContext();
+ // 3. Deregister the listener for the environment changes through the applicationContext object.
+ applicationContext.off("abilityLifecycle", globalThis.lifecycleId, (error) => {
+ if (error.code != 0) {
+ console.log("unregisterAbilityLifecycleCallback failed, error: " + JSON.stringify(error));
+ } else {
+ console.log("unregisterAbilityLifecycleCallback success.");
+ }
+ });
+ }
+}
+```
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md b/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md
new file mode 100644
index 0000000000000000000000000000000000000000..f7f9c49a4cdf1c9e8c92ad8b7c8bd977df525477
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md
@@ -0,0 +1,388 @@
+# @ohos.app.ability.abilityManager (AbilityManager)
+
+The **AbilityManager** module provides APIs for obtaining, adding, and updating ability running information and state information.
+
+> **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 are system APIs and cannot be called by third-party applications.
+
+## Modules to Import
+
+```ts
+import abilityManager from '@ohos.app.ability.abilityManager';
+```
+
+## AbilityState
+
+Enumerates the ability states. This enum can be used together with [AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo.md) to return the ability state.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This enum is an internal definition of a system API and cannot be called by third-party applications.
+
+| Name| Value| Description|
+| -------- | -------- | -------- |
+| INITIAL | 0 | The ability is in the initial state.|
+| FOREGROUND | 9 | The ability is in the foreground state. |
+| BACKGROUND | 10 | The ability is in the background state. |
+| FOREGROUNDING | 11 | The ability is in the state of being switched to the foreground. |
+| BACKGROUNDING | 12 | The ability is in the state of being switched to the background. |
+
+## updateConfiguration
+
+updateConfiguration(config: Configuration, callback: AsyncCallback\): void
+
+Updates the configuration. This API uses an asynchronous callback to return the result.
+
+**Permission required**: ohos.permission.UPDATE_CONFIGURATION
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| --------- | ---------------------------------------- | ---- | -------------- |
+| config | [Configuration](js-apis-app-ability-configuration.md) | Yes | New configuration. You only need to configure the items to be updated.|
+| callback | AsyncCallback\ | Yes | Callback used to return the API call result. You can perform error handling or custom processing in this callback. |
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import abilityManager from '@ohos.app.ability.abilityManager';
+
+const config = {
+ language: 'Zh-Hans', // Simplified Chinese.
+ colorMode: COLOR_MODE_LIGHT, // Light theme.
+ direction: DIRECTION_VERTICAL, // Vertical direction.
+ screenDensity: SCREEN_DENSITY_SDPI, // The screen resolution is SDPI.
+ displayId: 1, // The application is displayed on the display with ID 1.
+ hasPointerDevice: true, // A pointer device is connected.
+};
+
+try {
+ abilityManager.updateConfiguration(config, (err) => {
+ if (err.code !== 0) {
+ console.log("updateConfiguration fail, err: " + JSON.stringify(err));
+ } else {
+ console.log("updateConfiguration success.");
+ }
+ })
+} catch (paramError) {
+ console.log('error.code: ' + JSON.stringify(paramError.code)
+ + ' error.message: ' + JSON.stringify(paramError.message));
+}
+```
+
+## updateConfiguration
+
+updateConfiguration(config: Configuration): Promise\
+
+Updates the configuration. This API uses a promise to return the result.
+
+**Permission required**: ohos.permission.UPDATE_CONFIGURATION
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| --------- | ---------------------------------------- | ---- | -------------- |
+| config | [Configuration](js-apis-app-ability-configuration.md) | Yes | New configuration. You only need to configure the items to be updated.|
+
+**Return value**
+
+| Type | Description |
+| ---------------------------------------- | ------- |
+| Promise\ | Promise used to return the API call result. You can perform error handling or custom processing in this callback.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import abilityManager from '@ohos.app.ability.abilityManager';
+
+const config = {
+ language: 'Zh-Hans', // Simplified Chinese.
+ colorMode: COLOR_MODE_LIGHT, // Light theme.
+ direction: DIRECTION_VERTICAL, // Vertical direction.
+ screenDensity: SCREEN_DENSITY_SDPI, // The screen resolution is SDPI.
+ displayId: 1, // The application is displayed on the display with ID 1.
+ hasPointerDevice: true, // A pointer device is connected.
+};
+
+try {
+ abilityManager.updateConfiguration(config).then(() => {
+ console.log('updateConfiguration success.');
+ }).catch((err) => {
+ console.log('updateConfiguration fail, err: ' + JSON.stringify(err));
+ })
+} catch (paramError) {
+ console.log('error.code: ' + JSON.stringify(paramError.code)
+ + ' error.message: ' + JSON.stringify(paramError.message));
+}
+```
+
+## getAbilityRunningInfos
+
+getAbilityRunningInfos(callback: AsyncCallback\>): void
+
+Obtains the ability running information. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.GET_RUNNING_INFO
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| --------- | ---------------------------------------- | ---- | -------------- |
+| callback | AsyncCallback\> | Yes | Callback used to return the API call result and the ability running information. You can perform error handling or custom processing in this callback. |
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import abilityManager from '@ohos.app.ability.abilityManager';
+
+try {
+ abilityManager.getAbilityRunningInfos((err, data) => {
+ if (err.code !== 0) {
+ console.log("getAbilityRunningInfos fail, error: " + JSON.stringify(err));
+ } else {
+ console.log("getAbilityRunningInfos success, data: " + JSON.stringify(data));
+ }
+ });
+} catch (paramError) {
+ console.log('error.code: ' + JSON.stringify(paramError.code)
+ + ' error.message: ' + JSON.stringify(paramError.message));
+}
+```
+
+## getAbilityRunningInfos
+
+getAbilityRunningInfos(): Promise\>
+
+Obtains the ability running information. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.GET_RUNNING_INFO
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
+
+| Type | Description |
+| ---------------------------------------- | ------- |
+| Promise\> | Callback used to return the API call result and the ability running information. You can perform error handling or custom processing in this callback.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import abilityManager from '@ohos.app.ability.abilityManager';
+
+try {
+ abilityManager.getAbilityRunningInfos().then((data) => {
+ console.log("getAbilityRunningInfos success, data: " + JSON.stringify(data))
+ }).catch((err) => {
+ console.log("getAbilityRunningInfos fail, err: " + JSON.stringify(err));
+ });
+} catch (paramError) {
+ console.log('error.code: ' + JSON.stringify(paramError.code)
+ + ' error.message: ' + JSON.stringify(paramError.message));
+}
+```
+
+## getExtensionRunningInfos
+
+getExtensionRunningInfos(upperLimit: number, callback: AsyncCallback\>): void
+
+Obtains the ExtensionAbility running information. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.GET_RUNNING_INFO
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| --------- | ---------------------------------------- | ---- | -------------- |
+| upperLimit | number | Yes| Maximum number of messages that can be obtained. The maximum value is 231-1.|
+| callback | AsyncCallback\> | Yes | Callback used to return the API call result and the ExtensionAbility running information. You can perform error handling or custom processing in this callback. |
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import abilityManager from '@ohos.app.ability.abilityManager';
+
+let upperLimit = 10;
+
+try {
+ abilityManager.getExtensionRunningInfos(upperLimit, (err, data) => {
+ if (err.code !== 0) {
+ console.log("getExtensionRunningInfos fail, err: " + JSON.stringify(err));
+ } else {
+ console.log("getExtensionRunningInfos success, data: " + JSON.stringify(data));
+ }
+ });
+} catch (paramError) {
+ console.log('error.code: ' + JSON.stringify(paramError.code)
+ + ' error.message: ' + JSON.stringify(paramError.message));
+}
+```
+
+## getExtensionRunningInfos
+
+getExtensionRunningInfos(upperLimit: number): Promise\>
+
+Obtains the ExtensionAbility running information. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.GET_RUNNING_INFO
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| --------- | ---------------------------------------- | ---- | -------------- |
+| upperLimit | number | Yes| Maximum number of messages that can be obtained. The maximum value is 231-1.|
+
+**Return value**
+
+| Type | Description |
+| ---------------------------------------- | ------- |
+| Promise\> | Promise used to return the API call result and the ExtensionAbility running information. You can perform error handling or custom processing in this callback.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import abilityManager from '@ohos.app.ability.abilityManager';
+
+let upperLimit = 10;
+
+try {
+ abilityManager.getExtensionRunningInfos(upperLimit).then((data) => {
+ console.log("getExtensionRunningInfos success, data: " + JSON.stringify(data));
+ }).catch((err) => {
+ console.log("getExtensionRunningInfos fail, err: " + JSON.stringify(err));
+ })
+} catch (paramError) {
+ console.log('error.code: ' + JSON.stringify(paramError.code)
+ + ' error.message: ' + JSON.stringify(paramError.message));
+}
+```
+
+## getTopAbility9+
+
+getTopAbility(callback: AsyncCallback\): void;
+
+Obtains the top ability, which is the ability that has the window focus. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| --------- | ---------------------------------------- | ---- | -------------- |
+| callback | AsyncCallback\<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | Callback used to return the API call result and the element name of the top ability. You can perform error handling or custom processing in this callback. |
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import abilityManager from '@ohos.app.ability.abilityManager';
+
+abilityManager.getTopAbility((err, data) => {
+ if (err.code !== 0) {
+ console.log("getTopAbility fail, err: " + JSON.stringify(err));
+ } else {
+ console.log("getTopAbility success, data: " + JSON.stringify(data));
+ }
+});
+```
+
+## getTopAbility
+
+getTopAbility(): Promise\;
+
+Obtains the top ability, which is the ability that has the window focus. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
+
+| Type | Description |
+| ---------------------------------------- | ------- |
+| Promise\<[ElementName](js-apis-bundleManager-elementName.md)>| Promise used to return the API call result and the element name of the top ability. You can perform error handling or custom processing in this callback.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import abilityManager from '@ohos.app.ability.abilityManager';
+
+abilityManager.getTopAbility().then((data) => {
+ console.log("getTopAbility success, data: " + JSON.stringify(data));
+}).catch((err) => {
+ console.log("getTopAbility fail, err: " + JSON.stringify(err));
+})
+```
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-abilityStage.md b/en/application-dev/reference/apis/js-apis-app-ability-abilityStage.md
new file mode 100644
index 0000000000000000000000000000000000000000..50feb82791f8992894641a296d6cb831fdc86680
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-abilityStage.md
@@ -0,0 +1,135 @@
+# @ohos.app.ability.AbilityStage (AbilityStage)
+
+**AbilityStage** is a runtime class for HAP files.
+
+**AbilityStage** notifies you of when you can perform HAP initialization such as resource pre-loading and thread creation during the HAP loading.
+
+> **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 can be used only in the stage model.
+
+## Modules to Import
+
+```ts
+import AbilityStage from '@ohos.app.ability.AbilityStage';
+```
+
+## AbilityStage.onCreate
+
+onCreate(): void
+
+Called when the application is created.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Example**
+
+```ts
+import AbilityStage from '@ohos.app.ability.AbilityStage';
+
+class MyAbilityStage extends AbilityStage {
+ onCreate() {
+ console.log("MyAbilityStage.onCreate is called");
+ }
+}
+```
+
+
+## AbilityStage.onAcceptWant
+
+onAcceptWant(want: Want): string;
+
+Called when a specified ability is started.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| want | [Want](js-apis-app-ability-want.md) | Yes| Want information about the target ability, such as the ability name and bundle name.|
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | string | Returns an ability ID. If this ability has been started, no new instance is created and the ability is placed at the top of the stack. Otherwise, a new instance is created and started.|
+
+**Example**
+
+```ts
+import AbilityStage from '@ohos.app.ability.AbilityStage';
+
+class MyAbilityStage extends AbilityStage {
+ onAcceptWant(want) {
+ console.log("MyAbilityStage.onAcceptWant called");
+ return "com.example.test";
+ }
+}
+```
+
+
+## AbilityStage.onConfigurationUpdate
+
+onConfigurationUpdate(newConfig: Configuration): void;
+
+Called when the global configuration is updated.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | newConfig | [Configuration](js-apis-app-ability-configuration.md) | Yes| Callback invoked when the global configuration is updated. The global configuration indicates the configuration of the environment where the application is running and includes the language and color mode.|
+
+**Example**
+
+```ts
+import AbilityStage from '@ohos.app.ability.AbilityStage';
+
+class MyAbilityStage extends AbilityStage {
+ onConfigurationUpdate(config) {
+ console.log('onConfigurationUpdate, language:' + config.language);
+ }
+}
+```
+
+## AbilityStage.onMemoryLevel
+
+onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
+
+Called when the system has decided to adjust the memory level. For example, this API can be used when there is not enough memory to run as many background processes as possible.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | level | [AbilityConstant.MemoryLevel](js-apis-app-ability-abilityConstant.md#abilityconstantmemorylevel) | Yes| Memory level that indicates the memory usage status. When the specified memory level is reached, a callback will be invoked and the system will start adjustment.|
+
+**Example**
+
+```ts
+import AbilityStage from '@ohos.app.ability.AbilityStage';
+
+class MyAbilityStage extends AbilityStage {
+ onMemoryLevel(level) {
+ console.log('onMemoryLevel, level:' + JSON.stringify(level));
+ }
+}
+```
+
+## AbilityStage.context
+
+context: AbilityStageContext;
+
+Defines the context of **AbilityStage**.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name | Type | Description |
+| ----------- | --------------------------- | ------------------------------------------------------------ |
+| context | [AbilityStageContext](js-apis-inner-application-abilityStageContext.md) | The context is obtained in the callback invoked when initialization is performed during ability startup.|
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-appManager.md b/en/application-dev/reference/apis/js-apis-app-ability-appManager.md
new file mode 100644
index 0000000000000000000000000000000000000000..840a395eac9e17558918dd7466aa9e0b178b1c4d
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-appManager.md
@@ -0,0 +1,983 @@
+# @ohos.app.ability.appManager (appManager)
+
+The **appManager** module implements application management. You can use the APIs of this module to query whether the application is undergoing a stability test, whether the application is running on a RAM constrained device, the memory size of the application, and information about the running process.
+
+> **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.
+
+## Modules to Import
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+```
+
+## appManager.isRunningInStabilityTest
+
+static isRunningInStabilityTest(callback: AsyncCallback<boolean>): void
+
+Checks whether this application is undergoing a stability test. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+ | Type| Description|
+ | -------- | -------- |
+ |AsyncCallback<boolean> |Callback used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is undergoing a stability test, and **false** means the opposite.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+
+appManager.isRunningInStabilityTest((err, flag) => {
+ if (err.code !== 0) {
+ console.log("isRunningInStabilityTest faile, err: " + JSON.stringify(err));
+ } else {
+ console.log("The result of isRunningInStabilityTest is:" + JSON.stringify(flag));
+ }
+})
+```
+
+
+## appManager.isRunningInStabilityTest
+
+static isRunningInStabilityTest(): Promise<boolean>
+
+Checks whether this application is undergoing a stability test. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<boolean> | Promise used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is undergoing a stability test, and **false** means the opposite.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+
+appManager.isRunningInStabilityTest().then((flag) => {
+ console.log("The result of isRunningInStabilityTest is:" + JSON.stringify(flag));
+}).catch((error) => {
+ console.log("error:" + JSON.stringify(error));
+});
+```
+
+
+## appManager.isRamConstrainedDevice
+
+isRamConstrainedDevice(): Promise\;
+
+Checks whether this application is running on a RAM constrained device. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<boolean> | Promise used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is running on a RAM constrained device, and **false** means the opposite.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+
+appManager.isRamConstrainedDevice().then((data) => {
+ console.log("The result of isRamConstrainedDevice is:" + JSON.stringify(data));
+}).catch((error) => {
+ console.log("error:" + JSON.stringify(error));
+});
+```
+
+## appManager.isRamConstrainedDevice
+
+isRamConstrainedDevice(callback: AsyncCallback\): void;
+
+Checks whether this application is running on a RAM constrained device. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+ | Type| Description|
+ | -------- | -------- |
+ | AsyncCallback<boolean> |Callback used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is running on a RAM constrained device, and **false** means the opposite.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+
+appManager.isRamConstrainedDevice((err, data) => {
+ if (err.code !== 0) {
+ console.log("isRamConstrainedDevice faile, err: " + JSON.stringify(err));
+ } else {
+ console.log("The result of isRamConstrainedDevice is:" + JSON.stringify(data));
+ }
+})
+```
+
+## appManager.getAppMemorySize
+
+getAppMemorySize(): Promise\;
+
+Obtains the memory size of this application. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<number> | Promise used to return the API call result and the memory size. You can perform error handling or custom processing in this callback.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+
+appManager.getAppMemorySize().then((data) => {
+ console.log("The size of app memory is:" + JSON.stringify(data));
+}).catch((error) => {
+ console.log("error:" + JSON.stringify(error));
+});
+```
+
+## appManager.getAppMemorySize
+
+getAppMemorySize(callback: AsyncCallback\): void;
+
+Obtains the memory size of this application. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+ | Type| Description|
+ | -------- | -------- |
+ |AsyncCallback<number> |Callback used to return the API call result and the memory size. You can perform error handling or custom processing in this callback.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+
+appManager.getAppMemorySize((err, data) => {
+ if (err.code !== 0) {
+ console.log("getAppMemorySize faile, err: " + JSON.stringify(err));
+ } else {
+ console.log("The size of app memory is:" + JSON.stringify(data));
+ }
+})
+```
+
+## appManager.getProcessRunningInformation
+
+getProcessRunningInformation(): Promise\>;
+
+Obtains information about the running processes. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.GET_RUNNING_INFO
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise\> | Promise used to return the API call result and the process running information. You can perform error handling or custom processing in this callback.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+
+appManager.getProcessRunningInformation().then((data) => {
+ console.log("The process running information is:" + JSON.stringify(data));
+}).catch((error) => {
+ console.log("error:" + JSON.stringify(error));
+});
+```
+
+## appManager.getProcessRunningInformation9+
+
+getProcessRunningInformation(callback: AsyncCallback\>): void;
+
+Obtains information about the running processes. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.GET_RUNNING_INFO
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Type| Description|
+| -------- | -------- |
+|AsyncCallback\> | Callback used to return the API call result and the process running information. You can perform error handling or custom processing in this callback.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+
+appManager.getProcessRunningInformation((err, data) => {
+ if (err.code !== 0) {
+ console.log("getProcessRunningInformation faile, err: " + JSON.stringify(err));
+ } else {
+ console.log("The process running information is:" + JSON.stringify(data));
+ }
+})
+```
+
+## appManager.on
+
+on(type: "applicationState", observer: ApplicationStateObserver): number;
+
+Registers an observer to listen for the state changes of all applications.
+
+**Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Type of the API to call. It is fixed at **"applicationState"**.|
+| observer | [ApplicationStateObserver](./js-apis-inner-application-applicationStateObserver.md) | Yes| Application state observer, which is used to observe the lifecycle change of an application.|
+
+**Return value**
+
+| Type| Description|
+| --- | --- |
+| number | Digital code of the observer, which will be used in **off()** to deregister the observer.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+
+let applicationStateObserver = {
+ onForegroundApplicationChanged(appStateData) {
+ console.log(`[appManager] onForegroundApplicationChanged: ${JSON.stringify(appStateData)}`);
+ },
+ onAbilityStateChanged(abilityStateData) {
+ console.log(`[appManager] onAbilityStateChanged: ${JSON.stringify(abilityStateData)}`);
+ },
+ onProcessCreated(processData) {
+ console.log(`[appManager] onProcessCreated: ${JSON.stringify(processData)}`);
+ },
+ onProcessDied(processData) {
+ console.log(`[appManager] onProcessDied: ${JSON.stringify(processData)}`);
+ },
+ onProcessStateChanged(processData) {
+ console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
+ }
+}
+try {
+ const observerId = appManager.on('applicationState', applicationStateObserver);
+ console.log(`[appManager] observerCode: ${observerId}`);
+} catch (paramError) {
+ console.log(`[appManager] error: ${paramError.code}, ${paramError.message} `);
+}
+```
+
+## appManager.on
+
+on(type: "applicationState", observer: ApplicationStateObserver, bundleNameList: Array\): number;
+
+Registers an observer to listen for the state changes of a specified application.
+
+**Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Type of the API to call. It is fixed at **"applicationState"**.|
+| observer | [ApplicationStateObserver](./js-apis-inner-application-applicationStateObserver.md) | Yes| Application state observer, which is used to observe the lifecycle change of an application.|
+| bundleNameList | `Array` | Yes| **bundleName** array of the application. A maximum of 128 bundle names can be passed.|
+
+**Return value**
+
+| Type| Description|
+| --- | --- |
+| number | Digital code of the observer, which will be used in **off()** to deregister the observer.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+
+let applicationStateObserver = {
+ onForegroundApplicationChanged(appStateData) {
+ console.log(`[appManager] onForegroundApplicationChanged: ${JSON.stringify(appStateData)}`);
+ },
+ onAbilityStateChanged(abilityStateData) {
+ console.log(`[appManager] onAbilityStateChanged: ${JSON.stringify(abilityStateData)}`);
+ },
+ onProcessCreated(processData) {
+ console.log(`[appManager] onProcessCreated: ${JSON.stringify(processData)}`);
+ },
+ onProcessDied(processData) {
+ console.log(`[appManager] onProcessDied: ${JSON.stringify(processData)}`);
+ },
+ onProcessStateChanged(processData) {
+ console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
+ }
+}
+let bundleNameList = ['bundleName1', 'bundleName2'];
+try {
+ const observerId = appManager.on("applicationState", applicationStateObserver, bundleNameList);
+ console.log(`[appManager] observerCode: ${observerId}`);
+} catch (paramError) {
+ console.log(`[appManager] error: ${paramError.code}, ${paramError.message} `);
+}
+```
+
+## appManager.off
+
+off(type: "applicationState", observerId: number, callback: AsyncCallback\): void;
+
+Deregisters the application state observer. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Type of the API to call. It is fixed at **"applicationState"**.|
+| observerId | number | Yes| Digital code of the observer.|
+| callback | AsyncCallback\ | Yes| Callback used to return the API call result. You can perform error handling or custom processing in this callback.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+
+let observeId = 0;
+
+// 1. Register an application state observer.
+let applicationStateObserver = {
+ onForegroundApplicationChanged(appStateData) {
+ console.log(`[appManager] onForegroundApplicationChanged: ${JSON.stringify(appStateData)}`);
+ },
+ onAbilityStateChanged(abilityStateData) {
+ console.log(`[appManager] onAbilityStateChanged: ${JSON.stringify(abilityStateData)}`);
+ },
+ onProcessCreated(processData) {
+ console.log(`[appManager] onProcessCreated: ${JSON.stringify(processData)}`);
+ },
+ onProcessDied(processData) {
+ console.log(`[appManager] onProcessDied: ${JSON.stringify(processData)}`);
+ },
+ onProcessStateChanged(processData) {
+ console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
+ }
+}
+let bundleNameList = ['bundleName1', 'bundleName2'];
+try {
+ observerId = appManager.on("applicationState", applicationStateObserver, bundleNameList);
+ console.log(`[appManager] observerCode: ${observerId}`);
+} catch (paramError) {
+ console.log(`[appManager] error: ${paramError.code}, ${paramError.message} `);
+}
+
+// 2. Deregister the application state observer.
+function unregisterApplicationStateObserverCallback(err) {
+ if (err.code !== 0) {
+ console.log("unregisterApplicationStateObserverCallback faile, err: " + JSON.stringify(err));
+ } else {
+ console.log("unregisterApplicationStateObserverCallback success.");
+ }
+}
+try {
+ appManager.off("applicationState", observerId, unregisterApplicationStateObserverCallback);
+} catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+}
+```
+
+## appManager.off
+
+off(type: "applicationState", observerId: number): Promise\;
+
+Deregisters the application state observer. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Type of the API to call. It is fixed at **"applicationState"**.|
+| observerId | number | Yes| Digital code of the observer.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise\ | Promise used to return the API call result. You can perform error handling or custom processing in this callback.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+
+let observeId = 0;
+
+// 1. Register an application state observer.
+let applicationStateObserver = {
+ onForegroundApplicationChanged(appStateData) {
+ console.log(`[appManager] onForegroundApplicationChanged: ${JSON.stringify(appStateData)}`);
+ },
+ onAbilityStateChanged(abilityStateData) {
+ console.log(`[appManager] onAbilityStateChanged: ${JSON.stringify(abilityStateData)}`);
+ },
+ onProcessCreated(processData) {
+ console.log(`[appManager] onProcessCreated: ${JSON.stringify(processData)}`);
+ },
+ onProcessDied(processData) {
+ console.log(`[appManager] onProcessDied: ${JSON.stringify(processData)}`);
+ },
+ onProcessStateChanged(processData) {
+ console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
+ }
+}
+let bundleNameList = ['bundleName1', 'bundleName2'];
+try {
+ observerId = appManager.on("applicationState", applicationStateObserver, bundleNameList);
+ console.log(`[appManager] observerCode: ${observerId}`);
+} catch (paramError) {
+ console.log(`[appManager] error: ${paramError.code}, ${paramError.message} `);
+}
+
+// 2. Deregister the application state observer.
+try {
+ appManager.off("applicationState", observerId).then((data) => {
+ console.log("unregisterApplicationStateObserver success, data: " + JSON.stringify(data));
+ }).catch((err) => {
+ console.log("unregisterApplicationStateObserver faile, err: " + JSON.stringify(err));
+ })
+} catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+}
+```
+
+## appManager.getForegroundApplications
+
+getForegroundApplications(callback: AsyncCallback\>): void;
+
+Obtains applications that are running in the foreground. This API uses an asynchronous callback to return the result. The application information is defined by [AppStateData](js-apis-inner-application-appStateData.md).
+
+**Required permissions**: ohos.permission.GET_RUNNING_INFO
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback\> | Yes| Callback used to return the API call result and an array holding the application state data. You can perform error handling or custom processing in this callback.|
+
+**Example**
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+
+function getForegroundApplicationsCallback(err, data) {
+ if (err.code !== 0) {
+ console.log("getForegroundApplicationsCallback fail, err: " + JSON.stringify(err));
+ } else {
+ console.log("getForegroundApplicationsCallback success, data: " + JSON.stringify(data));
+ }
+}
+try {
+ appManager.getForegroundApplications(getForegroundApplicationsCallback);
+} catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+}
+```
+
+## appManager.getForegroundApplications
+
+getForegroundApplications(): Promise\>;
+
+Obtains applications that are running in the foreground. This API uses a promise to return the result. The application information is defined by [AppStateData](js-apis-inner-application-appStateData.md).
+
+**Required permissions**: ohos.permission.GET_RUNNING_INFO
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise\> | Promise used to return an array holding the application state data|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+
+appManager.getForegroundApplications().then((data) => {
+ console.log("getForegroundApplications success, data: " + JSON.stringify(data));
+}).catch((err) => {
+ console.log("getForegroundApplications fail, err: " + JSON.stringify(err));
+})
+```
+
+## appManager.killProcessWithAccount
+
+killProcessWithAccount(bundleName: string, accountId: number): Promise\
+
+Kills a process by bundle name and account ID. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user) and ohos.permission.CLEAN_BACKGROUND_PROCESSES
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| bundleName | string | Yes| Bundle name.|
+| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+
+let bundleName = 'bundleName';
+let accountId = 0;
+try {
+ appManager.killProcessWithAccount(bundleName, accountId).then(() => {
+ console.log("killProcessWithAccount success");
+ }).catch((err) => {
+ console.log("killProcessWithAccount fail, err: " + JSON.stringify(err));
+ })
+} catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+}
+```
+
+
+## appManager.killProcessWithAccount
+
+killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCallback\): void
+
+Kills a process by bundle name and account ID. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user) and ohos.permission.CLEAN_BACKGROUND_PROCESSES
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | bundleName | string | Yes| Bundle name.|
+ | accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
+ | callback | AsyncCallback\ | Yes| Callback used to return the API call result. You can perform error handling or custom processing in this callback.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+
+let bundleName = 'bundleName';
+let accountId = 0;
+function killProcessWithAccountCallback(err, data) {
+ if (err.code !== 0) {
+ console.log("killProcessWithAccountCallback fail, err: " + JSON.stringify(err));
+ } else {
+ console.log("killProcessWithAccountCallback success.");
+ }
+}
+appManager.killProcessWithAccount(bundleName, accountId, killProcessWithAccountCallback);
+```
+
+## appManager.killProcessesByBundleName
+
+killProcessesByBundleName(bundleName: string, callback: AsyncCallback\);
+
+Kills a process by bundle name. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.CLEAN_BACKGROUND_PROCESSES
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| bundleName | string | Yes| Bundle name.|
+| callback | AsyncCallback\ | Yes| Callback used to return the API call result. You can perform error handling or custom processing in this callback.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+
+let bundleName = 'bundleName';
+function killProcessesByBundleNameCallback(err, data) {
+ if (err.code !== 0) {
+ console.log("killProcessesByBundleNameCallback fail, err: " + JSON.stringify(err));
+ } else {
+ console.log("killProcessesByBundleNameCallback success.");
+ }
+}
+try {
+ appManager.killProcessesByBundleName(bundleName, killProcessesByBundleNameCallback);
+} catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+}
+```
+
+## appManager.killProcessesByBundleName
+
+killProcessesByBundleName(bundleName: string): Promise\;
+
+Kills a process by bundle name. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.CLEAN_BACKGROUND_PROCESSES
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| bundleName | string | Yes| Bundle name.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise\ | Promise used to return the result.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+
+let bundleName = 'bundleName';
+try {
+ appManager.killProcessesByBundleName(bundleName).then((data) => {
+ console.log("killProcessesByBundleName success.");
+ }).catch((err) => {
+ console.log("killProcessesByBundleName fail, err: " + JSON.stringify(err));
+ })
+} catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+}
+```
+
+## appManager.clearUpApplicationData
+
+clearUpApplicationData(bundleName: string, callback: AsyncCallback\);
+
+Clears application data by bundle name. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.CLEAN_APPLICATION_DATA
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| bundleName | string | Yes| Bundle name.|
+| callback | AsyncCallback\ | Yes| Callback used to return the API call result. You can perform error handling or custom processing in this callback.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+
+let bundleName = 'bundleName';
+function clearUpApplicationDataCallback(err, data) {
+ if (err) {
+ console.log("clearUpApplicationDataCallback fail, err: " + JSON.stringify(err));
+ } else {
+ console.log("clearUpApplicationDataCallback success.");
+ }
+}
+try {
+ appManager.clearUpApplicationData(bundleName, clearUpApplicationDataCallback);
+} catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+}
+```
+
+## appManager.clearUpApplicationData
+
+clearUpApplicationData(bundleName: string): Promise\;
+
+Clears application data by bundle name. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.CLEAN_APPLICATION_DATA
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| bundleName | string | Yes| Bundle name.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise\ | Promise used to return the API call result. You can perform error handling or custom processing in this callback.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------- |
+| 16000050 | Internal error. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+```ts
+import appManager from '@ohos.app.ability.appManager';
+
+let bundleName = 'bundleName';
+try {
+ appManager.clearUpApplicationData(bundleName).then((data) => {
+ console.log("clearUpApplicationData success.");
+ }).catch((err) => {
+ console.log("clearUpApplicationData fail, err: " + JSON.stringify(err));
+ })
+} catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+}
+```
+
+## ApplicationState
+
+Enumerates the application states. This enum can be used together with [AbilityStateData](js-apis-inner-application-appStateData.md) to return the application state.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+| Name | Value | Description |
+| -------------------- | --- | --------------------------------- |
+| STATE_CREATE | 1 | State indicating that the application is being created. |
+| STATE_FOREGROUND | 2 | State indicating that the application is running in the foreground. |
+| STATE_ACTIVE | 3 | State indicating that the application is active. |
+| STATE_BACKGROUND | 4 | State indicating that the application is running in the background. |
+| STATE_DESTROY | 5 | State indicating that the application is destroyed. |
+
+## ProcessState
+
+Enumerates the process states. This enum can be used together with [ProcessData](js-apis-inner-application-processData.md) to return the process state.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+| Name | Value | Description |
+| -------------------- | --- | --------------------------------- |
+| STATE_CREATE | 1 | State indicating that the process is being created. |
+| STATE_FOREGROUND | 2 | State indicating that the process is running in the foreground. |
+| STATE_ACTIVE | 3 | State indicating that the process is active. |
+| STATE_BACKGROUND | 4 | State indicating that the process is running in the background. |
+| STATE_DESTROY | 5 | State indicating that the process is destroyed. |
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-appRecovery.md b/en/application-dev/reference/apis/js-apis-app-ability-appRecovery.md
new file mode 100644
index 0000000000000000000000000000000000000000..e066ac119344842ffce617fd7934efa3712d895f
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-appRecovery.md
@@ -0,0 +1,146 @@
+# @ohos.app.ability.appRecovery (appRecovery)
+
+The **appRecovery** module provides APIs for recovering faulty applications.
+
+> **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. In the current version, only applications with a single ability in a single process can be recovered.
+
+## Modules to Import
+```ts
+import appRecovery from '@ohos.app.ability.appRecovery';
+```
+
+
+## appRecovery.RestartFlag
+
+Enumerates the application restart flags. This enum is used as an input parameter of [enableAppRecovery](#apprecoveryenableapprecovery).
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name | Value | Description |
+| ----------------------------- | ---- | ------------------------------------------------------------ |
+| ALWAYS_RESTART | 0 | The application is restarted in all cases.|
+| CPP_CRASH_NO_RESTART | 0x0001 | The application is not restarted in the case of CPP_CRASH.|
+| JS_CRASH_NO_RESTART | 0x0002 | The application is not restarted in the case of JS_CRASH.|
+| APP_FREEZE_NO_RESTART | 0x0004 | The application is not restarted in the case of APP_FREEZE.|
+| NO_RESTART | 0xFFFF | The application is not restarted in any case.|
+
+## appRecovery.SaveOccasionFlag
+
+Enumerates the scenarios for saving the application state. This enum is used as an input parameter of [enableAppRecovery](#apprecoveryenableapprecovery).
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name | Value | Description |
+| ----------------------------- | ---- | ------------------------------------------------------------ |
+| SAVE_WHEN_ERROR | 0x0001 | Saving the application state when an application fault occurs.|
+| SAVE_WHEN_BACKGROUND | 0x0002 | Saving the application state when the application is switched to the background.|
+
+## appRecovery.SaveModeFlag
+
+Enumerates the application state saving modes. This enum is used as an input parameter of [enableAppRecovery](#apprecoveryenableapprecovery).
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name | Value | Description |
+| ----------------------------- | ---- | ------------------------------------------------------------ |
+| SAVE_WITH_FILE | 0x0001 | The application state is saved and written to the local file cache.|
+| SAVE_WITH_SHARED_MEMORY | 0x0002 | The application state is saved in the memory. When the application exits due to a fault, it is written to the local file cache.|
+
+## appRecovery.enableAppRecovery
+
+enableAppRecovery(restart?: [RestartFlag](#apprecoveryrestartflag), saveOccasion?: [SaveOccasionFlag](#apprecoverysaveoccasionflag), saveMode?: [SaveModeFlag](#apprecoverysavemodeflag)) : void;
+
+Enables application recovery.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| restart | [RestartFlag](#apprecoveryrestartflag) | No| Whether the application is restarted upon a fault. By default, the application is not restarted.|
+| saveOccasion | [SaveOccasionFlag](#apprecoverysaveoccasionflag) | No| Scenario for saving the application state. By default, the state is saved when a fault occurs.|
+| saveMode | [SaveModeFlag](#apprecoverysavemodeflag) | No| Application state saving mode. By default, the application state is written to the local file cache.|
+
+**Example**
+
+```ts
+import appRecovery from '@ohos.app.ability.appRecovery';
+import AbilityStage from '@ohos.app.ability.AbilityStage';
+import UIAbility from '@ohos.app.ability.UIAbility';
+
+export default class MyAbility extends UIAbility {
+ onCreate() {
+ appRecovery.enableAppRecovery(
+ appRecovery.RestartFlag::ALWAYS_RESTART,
+ appRecovery.SaveOccasionFlag::SAVE_WHEN_ERROR,
+ appRecovery.SaveModeFlag::SAVE_WITH_FILE
+ );
+ }
+}
+```
+
+## appRecovery.restartApp
+
+restartApp(): void;
+
+Restarts the application. This API can be used together with APIs of [errorManager](js-apis-app-ability-errorManager.md).
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+
+**Example**
+
+```ts
+import appRecovery from '@ohos.app.ability.appRecovery';
+import errorManager from '@ohos.app.ability.errorManager';
+
+let observer = {
+ onUnhandledException(errorMsg) {
+ console.log('onUnhandledException, errorMsg: ', errorMsg)
+ appRecovery.restartApp();
+ }
+};
+
+try {
+ errorManager.on("error", observer);
+} catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+}
+```
+
+## appRecovery.saveAppState
+
+saveAppState(): boolean;
+
+Saves the application state. This API can be used together with APIs of [errorManager](js-apis-app-ability-errorManager.md).
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| boolean | Whether the application state is saved. The value **true** is returned if the application state is saved, and **false** is returned otherwise.|
+
+**Example**
+
+```ts
+import appRecovery from '@ohos.app.ability.appRecovery';
+import errorManager from '@ohos.app.ability.errorManager';
+
+let observer = {
+ onUnhandledException(errorMsg) {
+ console.log('onUnhandledException, errorMsg: ', errorMsg)
+ appRecovery.saveAppState();
+ }
+};
+
+try {
+ errorManager.on("error", observer);
+} catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+}
+```
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-common.md b/en/application-dev/reference/apis/js-apis-app-ability-common.md
new file mode 100644
index 0000000000000000000000000000000000000000..5cc9b61b90fb3072aacf530fdaee0ae2633f7ac0
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-common.md
@@ -0,0 +1,62 @@
+# @ohos.app.ability.common (Context)
+
+The **Common** module provides all level-2 module APIs for developers to export.
+
+> **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 can be used only in the stage model.
+
+## Modules to Import
+
+```ts
+import common from '@ohos.app.ability.common'
+```
+
+**System capability**: SystemCapability.Ability.AbilityBase
+
+| Name | Type | Description |
+| ----------- | -------------------- | ------------------------------------------------------------ |
+| UIAbilityContext | [UIAbilityContext](js-apis-inner-application-uiAbilityContext.md) | Level-2 module **UIAbilityContext**. |
+| AbilityStageContext | [AbilityStageContext](js-apis-inner-application-abilityStageContext.md) | Level-2 module **AbilityStageContext**.|
+| ApplicationContext | [ApplicationContext](js-apis-inner-application-applicationContext.md) | Level-2 module **ApplicationContext**.|
+| BaseContext | [BaseContext](js-apis-inner-application-baseContext.md) | Level-2 module **BaseContext**.|
+| Context | [Context](js-apis-inner-application-context.md) | Level-2 module **Context**.|
+| ExtensionContext | [ExtensionContext](js-apis-inner-application-extensionContext.md) | Level-2 module **ExtensionContext**.|
+| FormExtensionContext | [FormExtensionContext](js-apis-inner-application-formExtensionContext.md) | Level-2 module **FormExtensionContext**.|
+| AreaMode | [AreaMode](#areamode) | Enumerated values of **AreaMode**.|
+| EventHub | [EventHub](js-apis-inner-application-eventHub.md) | Level-2 module **EventHub**.|
+| PermissionRequestResult | [PermissionRequestResult](js-apis-inner-application-permissionRequestResult.md) | Level-2 module **PermissionRequestResult**.|
+| PacMap | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#PacMap) | Level-2 module **PacMap**.|
+| AbilityResult | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Level-2 module **AbilityResult**.|
+| ConnectOptions | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | Level-2 module **ConnectOptions**.|
+
+**Example**
+```ts
+import common from '@ohos.app.ability.common'
+
+let uiAbilityContext: common.UIAbilityContext;
+let abilityStageContext: common.AbilityStageContext;
+let applicationContext: common.ApplicationContext;
+let baseContext: common.BaseContext;
+let context: common.Context;
+let extensionContext: common.ExtensionContext;
+let formExtensionContext: common.FormExtensionContext;
+let areaMode: common.AreaMode;
+let eventHub: common.EventHub;
+let permissionRequestResult: common.PermissionRequestResult;
+let pacMap: common.PacMap;
+let abilityResult: common.AbilityResult;
+let connectOptions: common.ConnectOptions;
+```
+
+## AreaMode
+
+Enumerates the data encryption levels.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name | Value | Description |
+| --------------- | ---- | --------------- |
+| EL1 | 0 | Device-level encryption area, which is accessible after the device is powered on. |
+| EL2 | 1 | User-level encryption area, which is accessible only after the device is powered on and the password is entered (for the first time).|
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-configuration.md b/en/application-dev/reference/apis/js-apis-app-ability-configuration.md
new file mode 100644
index 0000000000000000000000000000000000000000..88aab2d4026afac5edaf8c3c7ff58033976e3e66
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-configuration.md
@@ -0,0 +1,55 @@
+# @ohos.app.ability.Configuration (Configuration)
+
+The **Configuration** module defines environment change information.
+
+> **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.
+
+## Modules to Import
+
+```ts
+import Configuration from '@ohos.app.ability.Configuration'
+```
+
+**System capability**: SystemCapability.Ability.AbilityBase
+
+ | Name| Type| Readable| Writable| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| language | string | Yes| Yes| Language of the application, for example, **zh**.|
+| colorMode | [ColorMode](js-apis-app-ability-configurationConstant.md#configurationconstantcolormode) | Yes| Yes| Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.|
+| direction | [Direction](js-apis-app-ability-configurationConstant.md#configurationconstantdirection) | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**.|
+| screenDensity | [ScreenDensity](js-apis-app-ability-configurationConstant.md#configurationconstantscreendensity) | Yes| No| Screen resolution, which can be **SCREEN_DENSITY_SDPI** (120), **SCREEN_DENSITY_MDPI** (160), **SCREEN_DENSITY_LDPI** (240), **SCREEN_DENSITY_XLDPI** (320), **SCREEN_DENSITY_XXLDPI** (480), or **SCREEN_DENSITY_XXXLDPI** (640).|
+| displayId | number | Yes| No| ID of the display where the application is located.|
+| hasPointerDevice | boolean | Yes| No| Whether a pointer device, such as a keyboard, mouse, or touchpad, is connected.|
+
+For details about the fields, see the **ohos.app.ability.Configuration.d.ts** file.
+
+**Example**
+
+ ```ts
+ import UIAbility from '@ohos.app.ability.UIAbility';
+
+ export default class EntryAbility extends UIAbility {
+ onCreate(want, launchParam) {
+ let envCallback = {
+ onConfigurationUpdated(config) {
+ console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`)
+ let language = config.language;
+ let colorMode = config.colorMode;
+ let direction = config.direction;
+ let screenDensity = config.screenDensity;
+ let displayId = config.displayId;
+ let hasPointerDevice = config.hasPointerDevice;
+ }
+ };
+ try {
+ let applicationContext = this.context.getApplicationContext();
+ let callbackId = applicationContext.on("environment", envCallback);
+ console.log("callbackId: " + callbackId);
+ } catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+ }
+ }
+ }
+ ```
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-configurationConstant.md b/en/application-dev/reference/apis/js-apis-app-ability-configurationConstant.md
new file mode 100644
index 0000000000000000000000000000000000000000..bd56e256603930f874c9ba2c064462c8fad594a8
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-configurationConstant.md
@@ -0,0 +1,55 @@
+# @ohos.app.ability.ConfigurationConstant (ConfigurationConstant)
+
+The **ConfigurationConstant** module provides the enumerated values of the environment configuration information.
+
+> **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.
+
+## Modules to Import
+
+```ts
+import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
+```
+
+## ConfigurationConstant.ColorMode
+
+You can obtain the value of this constant by calling the **ConfigurationConstant.ColorMode** API.
+
+**System capability**: SystemCapability.Ability.AbilityBase
+
+| Name| Value| Description|
+| -------- | -------- | -------- |
+| COLOR_MODE_NOT_SET | -1 | Unspecified color mode.|
+| COLOR_MODE_DARK | 0 | Dark mode.|
+| COLOR_MODE_LIGHT | 1 | Light mode.|
+
+
+## ConfigurationConstant.Direction
+
+You can obtain the value of this constant by calling the **ConfigurationConstant.Direction** API.
+
+**System capability**: SystemCapability.Ability.AbilityBase
+
+| Name| Value| Description|
+| -------- | -------- | -------- |
+| DIRECTION_NOT_SET | -1 | Unspecified direction.|
+| DIRECTION_VERTICAL | 0 | Vertical direction.|
+| DIRECTION_HORIZONTAL | 1 | Horizontal direction.|
+
+
+## ConfigurationConstant.ScreenDensity
+
+You can obtain the value of this constant by calling the **ConfigurationConstant.ScreenDensity** API.
+
+**System capability**: SystemCapability.Ability.AbilityBase
+
+| Name| Value| Description|
+| -------- | -------- | -------- |
+| SCREEN_DENSITY_NOT_SET | 0 | Unspecified screen resolution.|
+| SCREEN_DENSITY_SDPI | 120 | The screen resolution is sdpi.|
+| SCREEN_DENSITY_MDPI | 160 | The screen resolution is mdpi.|
+| SCREEN_DENSITY_LDPI | 240 | The screen resolution is ldpi.|
+| SCREEN_DENSITY_XLDPI | 320 | The screen resolution is xldpi.|
+| SCREEN_DENSITY_XXLDPI | 480 | The screen resolution is xxldpi.|
+| SCREEN_DENSITY_XXXLDPI | 640 | The screen resolution is xxxldpi.|
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-contextConstant.md b/en/application-dev/reference/apis/js-apis-app-ability-contextConstant.md
new file mode 100644
index 0000000000000000000000000000000000000000..0c39c8fa01fe62a537614287f3d27645c8b0f354
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-contextConstant.md
@@ -0,0 +1,25 @@
+# @ohos.app.ability.contextConstant (ContextConstant)
+
+The **ContextConstant** module defines context-related enums. Currently, it defines only the enum of data encryption levels.
+
+> **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 can be used only in the stage model.
+
+## Modules to Import
+
+```ts
+import contextConstant from '@ohos.app.ability.contextConstant';
+```
+
+## ContextConstant.AreaMode
+
+You can obtain the value of this constant by calling the **ContextConstant.AreaMode** API.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name| Value| Description|
+| -------- | -------- | -------- |
+| EL1 | 0 | Device-level encryption area, which is accessible after the device is powered on.|
+| EL2 | 1 | User-level encryption area, which is accessible only after the device is powered on and the password is entered (for the first time).|
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md b/en/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md
new file mode 100644
index 0000000000000000000000000000000000000000..0cb95a9abfd6b90f1efacc431070ef6b3397e1e6
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md
@@ -0,0 +1,62 @@
+# @ohos.app.ability.EnvironmentCallback (EnvironmentCallback)
+
+The **EnvironmentCallback** module provides the **onConfigurationUpdated** API for the application context to listen for system environment changes.
+
+> **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 can be used only in the stage model.
+
+
+## Modules to Import
+
+```ts
+import EnvironmentCallback from "@ohos.app.ability.EnvironmentCallback";
+```
+
+
+## EnvironmentCallback.onConfigurationUpdated
+
+onConfigurationUpdated(config: Configuration): void;
+
+Called when the system environment changes.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | config | [Configuration](js-apis-app-ability-configuration.md) | Yes| **Configuration** object after the change.|
+
+**Example**
+
+
+ ```ts
+import UIAbility from "@ohos.app.ability.Ability";
+
+var callbackId;
+
+export default class MyAbility extends UIAbility {
+ onCreate() {
+ console.log("MyAbility onCreate")
+ globalThis.applicationContext = this.context.getApplicationContext();
+ let EnvironmentCallback = {
+ onConfigurationUpdated(config){
+ console.log("onConfigurationUpdated config:" + JSON.stringify(config));
+ }
+ }
+ // 1. Obtain an applicationContext object.
+ let applicationContext = globalThis.applicationContext;
+ // 2. Register a listener for the environment changes through the applicationContext object.
+ callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback);
+ console.log("registerEnvironmentCallback number: " + JSON.stringify(callbackId));
+ }
+ onDestroy() {
+ let applicationContext = globalThis.applicationContext;
+ applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => {
+ console.log("unregisterEnvironmentCallback success, err: " + JSON.stringify(error));
+ });
+ }
+}
+ ```
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-errorManager.md b/en/application-dev/reference/apis/js-apis-app-ability-errorManager.md
new file mode 100644
index 0000000000000000000000000000000000000000..e543a93e9ceb5af52f3cdb939a0cfd5d24145968
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-errorManager.md
@@ -0,0 +1,121 @@
+# @ohos.app.ability.errorManager (ErrorManager)
+
+The **ErrorManager** module provides APIs for registering and deregistering error observers. For example, you can use the APIs to register an observer when your application wants to capture JS crashes.
+
+> **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.
+
+## Modules to Import
+```ts
+import errorManager from '@ohos.app.ability.errorManager'
+```
+
+## ErrorManager.on
+
+on(type: "error", observer: ErrorObserver): number;
+
+Registers an error observer.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Type of the API to call. It is fixed at **"error"**.|
+| observer | [ErrorObserver](./js-apis-inner-application-errorObserver.md) | Yes| Digital code of the observer.|
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | number | Index of the observer.|
+
+**Example**
+
+```ts
+var observer = {
+ onUnhandledException(errorMsg) {
+ console.log('onUnhandledException, errorMsg: ', errorMsg)
+ }
+}
+var observerId = -1;
+try {
+ observerId = errorManager.on("error", observer);
+} catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+}
+```
+
+## ErrorManager.off
+
+off(type: "error", observerId: number, callback: AsyncCallback\): void;
+
+Deregisters an error observer. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Type of the API to call. It is fixed at **"error"**.|
+| observerId | number | Yes| Index of the observer returned by **on()**.|
+| callback | AsyncCallback\ | Yes| Callback used to return the result.|
+
+**Example**
+
+```ts
+var observerId = 100;
+
+function unregisterErrorObserverCallback(err) {
+ if (err) {
+ console.log('------------ unregisterErrorObserverCallback ------------', err);
+ }
+}
+try {
+ errorManager.off("error", observerId, unregisterErrorObserverCallback);
+} catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+}
+```
+
+## ErrorManager.off
+
+off(type: "error", observerId: number): Promise\;
+
+Deregisters an error observer. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Type of the API to call. It is fixed at **"error"**.|
+| observerId | number | Yes| Index of the observer returned by **on()**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise\ | Promise used to return the result.|
+
+**Example**
+
+```ts
+var observerId = 100;
+try {
+ errorManager.off("error", observerId)
+ .then((data) => {
+ console.log('----------- unregisterErrorObserver success ----------', data);
+ })
+ .catch((err) => {
+ console.log('----------- unregisterErrorObserver fail ----------', err);
+ })
+} catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+}
+
+```
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-extensionAbility.md b/en/application-dev/reference/apis/js-apis-app-ability-extensionAbility.md
new file mode 100644
index 0000000000000000000000000000000000000000..d532723b43a1c31f2b01b35799747ec689df5099
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-extensionAbility.md
@@ -0,0 +1,10 @@
+# @ohos.app.ability.ExtensionAbility (ExtensionAbility Base Class)
+
+**ExtensionAbility** is the base class for scenario-specific ExtensionAbilities. It is inherited from [Ability](js-apis-app-ability-ability.md), with no attribute or method added. You cannot inherit from this base class.
+
+> **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 can be used only in the stage model.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-missionManager.md b/en/application-dev/reference/apis/js-apis-app-ability-missionManager.md
new file mode 100644
index 0000000000000000000000000000000000000000..434fb19383e072a36352012300c2a755769d6c1f
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-missionManager.md
@@ -0,0 +1,1027 @@
+# @ohos.app.ability.missionManager (missionManager)
+
+The **missionManager** module provides APIs to lock, unlock, and clear missions, and switch a mission to the foreground.
+
+> **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.
+
+## Modules to Import
+
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+```
+
+## Required Permissions
+
+ohos.permission.MANAGE_MISSIONS
+
+## missionManager.on
+
+on(type:"mission", listener: MissionListener): number;
+
+Registers a listener to observe the mission status.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | listener | [MissionListener](js-apis-inner-application-missionListener.md) | Yes| Mission status listener to register.|
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | number | Index of the mission status listener, which is created by the system and allocated when the listener is registered.|
+
+**Example**
+
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+import UIAbility from '@ohos.app.ability.UIAbility';
+
+var listener = {
+ onMissionCreated: function (mission) {console.log("--------onMissionCreated-------")},
+ onMissionDestroyed: function (mission) {console.log("--------onMissionDestroyed-------")},
+ onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")},
+ onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")},
+ onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")},
+ onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")},
+ onMissionLabelUpdated: function (mission) {console.log("--------onMissionLabelUpdated-------")}
+};
+
+var listenerId = -1;
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want, launchParam) {
+ console.log("[Demo] EntryAbility onCreate");
+ globalThis.abilityWant = want;
+ globalThis.context = this.context;
+ }
+
+ onDestroy() {
+ try {
+ if (listenerId != -1) {
+ missionManager.off("mission", listenerId).catch(function (err) {
+ console.log(err);
+ });
+ }
+ } catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+ }
+ console.log("[Demo] EntryAbility onDestroy")
+ }
+
+ onWindowStageCreate(windowStage) {
+ // The main window is created. Set a main page for this ability.
+ console.log("[Demo] EntryAbility onWindowStageCreate")
+ try {
+ listenerId = missionManager.on("mission", listener);
+ } catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+ }
+
+ windowStage.loadContent("pages/index", (err, data) => {
+ if (err.code) {
+ console.error('Failed to load the content. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
+ });
+
+ if (globalThis.flag) {
+ return;
+ }
+ }
+};
+```
+
+
+## missionManager.off
+
+off(type: "mission", listenerId: number, callback: AsyncCallback<void>): void;
+
+Deregisters a mission status listener.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | listenerId | number | Yes| Index of the mission status listener to deregister. It is returned by **on()**.|
+ | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+
+**Example**
+
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+import UIAbility from '@ohos.app.ability.UIAbility';
+
+var listener = {
+ onMissionCreated: function (mission) {console.log("--------onMissionCreated-------")},
+ onMissionDestroyed: function (mission) {console.log("--------onMissionDestroyed-------")},
+ onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")},
+ onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")},
+ onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")},
+ onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")},
+ onMissionLabelUpdated: function (mission) {console.log("--------onMissionLabelUpdated-------")}
+};
+
+var listenerId = -1;
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want, launchParam) {
+ console.log("[Demo] EntryAbility onCreate")
+ globalThis.abilityWant = want;
+ globalThis.context = this.context;
+ }
+
+ onDestroy() {
+ try {
+ if (listenerId != -1) {
+ missionManager.off("mission", listenerId, (err) => {
+ console.log(err);
+ });
+ }
+ } catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+ }
+ console.log("[Demo] EntryAbility onDestroy")
+ }
+
+ onWindowStageCreate(windowStage) {
+ // The main window is created. Set a main page for this ability.
+ console.log("[Demo] EntryAbility onWindowStageCreate")
+ try {
+ listenerId = missionManager.on("mission", listener);
+ } catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+ }
+
+ windowStage.loadContent("pages/index", (err, data) => {
+ if (err.code) {
+ console.error('Failed to load the content. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
+ });
+
+ if (globalThis.flag) {
+ return;
+ }
+ }
+};
+```
+
+
+## missionManager.off
+
+off(type: "mission", listenerId: number): Promise<void>;
+
+Deregisters a mission status listener. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | listenerId | number | Yes| Index of the mission status listener to deregister. It is returned by **on()**.|
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<void> | Promise used to return the result.|
+
+**Example**
+
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+import UIAbility from '@ohos.app.ability.UIAbility';
+
+var listener = {
+ onMissionCreated: function (mission) {console.log("--------onMissionCreated-------")},
+ onMissionDestroyed: function (mission) {console.log("--------onMissionDestroyed-------")},
+ onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")},
+ onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")},
+ onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")},
+ onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")},
+ onMissionLabelUpdated: function (mission) {console.log("--------onMissionLabelUpdated-------")}
+};
+
+var listenerId = -1;
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want, launchParam) {
+ console.log("[Demo] EntryAbility onCreate")
+ globalThis.abilityWant = want;
+ globalThis.context = this.context;
+ }
+
+ onDestroy() {
+ try {
+ if (listenerId != -1) {
+ missionManager.off("mission", listenerId).catch(function (err) {
+ console.log(err);
+ });
+ }
+ } catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+ }
+ console.log("[Demo] EntryAbility onDestroy")
+ }
+
+ onWindowStageCreate(windowStage) {
+ // The main window is created. Set a main page for this ability.
+ console.log("[Demo] EntryAbility onWindowStageCreate")
+ try {
+ listenerId = missionManager.on("mission", listener);
+ } catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+ }
+
+ windowStage.loadContent("pages/index", (err, data) => {
+ if (err.code) {
+ console.error('Failed to load the content. Cause:' + JSON.stringify(err));
+ return;
+ }
+ console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
+ });
+
+ if (globalThis.flag) {
+ return;
+ }
+ }
+};
+```
+
+
+## missionManager.getMissionInfo
+
+getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<MissionInfo>): void;
+
+Obtains the information about a given mission. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
+ | missionId | number | Yes| Mission ID.|
+ | callback | AsyncCallback<[MissionInfo](./js-apis-inner-application-missionInfo.md))> | Yes| Callback used to return the mission information obtained.|
+
+**Example**
+
+ ```ts
+ import missionManager from '@ohos.app.ability.missionManager';
+
+ let testMissionId = 1;
+ try {
+ var allMissions=await missionManager.getMissionInfos("",10).catch(function(err){console.log(err);});
+ if (allMissions && allMissions.length > 0) {
+ testMissionId = allMissions[0].missionId;
+ }
+
+ missionManager.getMissionInfo("", testMissionId, (error, mission) => {
+ if (error) {
+ console.log("getMissionInfo failed, error.code:" + JSON.stringify(error.code) +
+ "error.message:" + JSON.stringify(error.message));
+ } else {
+ console.log("mission.missionId = " + mission.missionId);
+ console.log("mission.runningState = " + mission.runningState);
+ console.log("mission.lockedState = " + mission.lockedState);
+ console.log("mission.timestamp = " + mission.timestamp);
+ console.log("mission.label = " + mission.label);
+ console.log("mission.iconPath = " + mission.iconPath);
+ }
+ });
+ } catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+ }
+ ```
+
+
+## missionManager.getMissionInfo
+
+getMissionInfo(deviceId: string, missionId: number): Promise<MissionInfo>;
+
+Obtains the information about a given mission. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
+ | missionId | number | Yes| Mission ID.|
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<[MissionInfo](./js-apis-inner-application-missionInfo.md)> | Promise used to return the mission information obtained.|
+
+**Example**
+
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+
+let testMissionId = 1;
+try {
+ missionManager.getMissionInfo("", testMissionId).then((data) => {
+ console.info('getMissionInfo successfully. Data: ' + JSON.stringify(data));
+ }).catch(error => {
+ console.error('getMissionInfo failed. Cause: ' + error.message);
+ });
+} catch (error) {
+ console.error('getMissionInfo failed. Cause: ' + error.message);
+}
+```
+
+## missionManager.getMissionInfos
+
+getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback<Array<MissionInfo>>): void;
+
+Obtains information about all missions. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
+ | numMax | number | Yes| Maximum number of missions whose information can be obtained.|
+ | callback | AsyncCallback<Array<[MissionInfo](./js-apis-inner-application-missionInfo.md)>> | Yes| Callback used to return the array of mission information obtained.|
+
+**Example**
+
+ ```ts
+ import missionManager from '@ohos.app.ability.missionManager';
+
+ try {
+ missionManager.getMissionInfos("", 10, (error, missions) => {
+ if (error) {
+ console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
+ "error.message:" + JSON.stringify(error.message));
+ } else {
+ console.log("size = " + missions.length);
+ console.log("missions = " + JSON.stringify(missions));
+ }
+ })
+ } catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+ }
+ ```
+
+
+## missionManager.getMissionInfos
+
+getMissionInfos(deviceId: string, numMax: number): Promise<Array<MissionInfo>>;
+
+Obtains information about all missions. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
+ | numMax | number | Yes| Maximum number of missions whose information can be obtained.|
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<Array<[MissionInfo](./js-apis-inner-application-missionInfo.md)>> | Promise used to return the array of mission information obtained.|
+
+**Example**
+
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+
+try {
+ missionManager.getMissionInfos("", 10).then((data) => {
+ console.info('getMissionInfos successfully. Data: ' + JSON.stringify(data));
+ }).catch(error => {
+ console.error('getMissionInfos failed. Cause: ' + error.message);
+ });
+} catch (error) {
+ console.error('getMissionInfos failed. Cause: ' + error.message);
+}
+```
+
+## missionManager.getMissionSnapShot
+
+getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback<MissionSnapshot>): void;
+
+Obtains the snapshot of a given mission. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
+ | missionId | number | Yes| Mission ID.|
+ | callback | AsyncCallback<[MissionSnapshot](js-apis-inner-application-missionSnapshot.md)> | Yes| Callback used to return the snapshot information obtained.|
+
+**Example**
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+
+let testMissionId = 2;
+try {
+ missionManager.getMissionSnapShot("", testMissionId, (err, data) => {
+ if (err) {
+ console.error('getMissionSnapShot failed:' + err.message);
+ } else {
+ console.info('getMissionSnapShot successfully:' + JSON.stringify(data));
+ }
+ });
+} catch (err) {
+ console.error('getMissionSnapShot failed:' + err.message);
+}
+```
+
+## missionManager.getMissionSnapShot
+
+getMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnapshot>;
+
+Obtains the snapshot of a given mission. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
+ | missionId | number | Yes| Mission ID.|
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<[MissionSnapshot](js-apis-inner-application-missionSnapshot.md)> | Promise used to return the snapshot information obtained.|
+
+**Example**
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+
+let testMissionId = 2;
+try {
+ missionManager.getMissionSnapShot("", testMissionId).then((data) => {
+ console.info('getMissionSnapShot successfully. Data: ' + JSON.stringify(data));
+ }).catch(error => {
+ console.error('getMissionSnapShot failed. Cause: ' + error.message);
+ });
+} catch (error) {
+ console.error('getMissionSnapShot failed. Cause: ' + error.message);
+}
+```
+
+## missionManager.getLowResolutionMissionSnapShot
+
+getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback\): void;
+
+Obtains the low-resolution snapshot of a given mission. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
+ | missionId | number | Yes| Mission ID.|
+ | callback | AsyncCallback<[MissionSnapshot](js-apis-inner-application-missionSnapshot.md)> | Yes| Callback used to return the snapshot information obtained.|
+
+**Example**
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+
+let testMissionId = 2;
+try {
+ missionManager.getLowResolutionMissionSnapShot("", testMissionId, (err, data) => {
+ if (err) {
+ console.error('getLowResolutionMissionSnapShot failed:' + err.message);
+ } else {
+ console.info('getLowResolutionMissionSnapShot successfully:' + JSON.stringify(data));
+ }
+ });
+} catch (err) {
+ console.error('getLowResolutionMissionSnapShot failed:' + err.message);
+}
+```
+
+## missionManager.getLowResolutionMissionSnapShot
+
+getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise\;
+
+Obtains the low-resolution snapshot of a given mission. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
+ | missionId | number | Yes| Mission ID.|
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<[MissionSnapshot](js-apis-inner-application-missionSnapshot.md)> | Promise used to return the snapshot information obtained.|
+
+**Example**
+
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+
+let testMissionId = 2;
+try {
+ missionManager.getLowResolutionMissionSnapShot("", testMissionId).then((data) => {
+ console.info('getLowResolutionMissionSnapShot successfully. Data: ' + JSON.stringify(data));
+ }).catch(error => {
+ console.error('getLowResolutionMissionSnapShot failed. Cause: ' + error.message);
+ });
+} catch (error) {
+ console.error('getLowResolutionMissionSnapShot failed. Cause: ' + error.message);
+}
+```
+
+
+## missionManager.lockMission
+
+lockMission(missionId: number, callback: AsyncCallback<void>): void;
+
+Locks a given mission. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | missionId | number | Yes| Mission ID.|
+ | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+
+**Example**
+
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+
+let testMissionId = 2;
+try {
+ missionManager.lockMission(testMissionId, (err, data) => {
+ if (err) {
+ console.error('lockMission failed:' + err.message);
+ } else {
+ console.info('lockMission successfully:' + JSON.stringify(data));
+ }
+ });
+} catch (err) {
+ console.error('lockMission failed:' + err.message);
+}
+```
+
+## missionManager.lockMission
+
+lockMission(missionId: number): Promise<void>;
+
+Locks a given mission. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | missionId | number | Yes| Mission ID.|
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<void> | Promise used to return the result.|
+
+**Example**
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+
+let testMissionId = 2;
+try {
+ missionManager.lockMission(testMissionId).then((data) => {
+ console.info('lockMission successfully. Data: ' + JSON.stringify(data));
+ }).catch(error => {
+ console.error('lockMission failed. Cause: ' + error.message);
+ });
+} catch (error) {
+ console.error('lockMission failed. Cause: ' + error.message);
+}
+```
+
+## missionManager.unlockMission
+
+unlockMission(missionId: number, callback: AsyncCallback<void>): void;
+
+Unlocks a given mission. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| missionId | number | Yes| Mission ID.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+
+**Example**
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+
+let testMissionId = 2;
+try {
+ missionManager.unlockMission(testMissionId, (err, data) => {
+ if (err) {
+ console.error('unlockMission failed:' + err.message);
+ } else {
+ console.info('unlockMission successfully:' + JSON.stringify(data));
+ }
+ });
+} catch (err) {
+ console.error('unlockMission failed:' + err.message);
+}
+```
+
+## missionManager.unlockMission
+
+unlockMission(missionId: number): Promise<void>;
+
+Unlocks a given mission. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | missionId | number | Yes| Mission ID.|
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<void> | Promise used to return the result.|
+
+**Example**
+
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+
+let testMissionId = 2;
+try {
+ missionManager.unlockMission(testMissionId).then((data) => {
+ console.info('unlockMission successfully. Data: ' + JSON.stringify(data));
+ }).catch(error => {
+ console.error('unlockMission failed. Cause: ' + error.message);
+ });
+} catch (error) {
+ console.error('unlockMission failed. Cause: ' + error.message);
+}
+```
+
+## missionManager.clearMission
+
+clearMission(missionId: number, callback: AsyncCallback<void>): void;
+
+Clears a given mission, regardless of whether it is locked. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | missionId | number | Yes| Mission ID.|
+ | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+
+**Example**
+
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+
+let testMissionId = 2;
+try {
+ missionManager.clearMission(testMissionId, (err, data) => {
+ if (err) {
+ console.error('clearMission failed:' + err.message);
+ } else {
+ console.info('clearMission successfully:' + JSON.stringify(data));
+ }
+ });
+} catch (err) {
+ console.error('clearMission failed:' + err.message);
+}
+```
+
+
+## missionManager.clearMission
+
+clearMission(missionId: number): Promise<void>;
+
+Clears a given mission, regardless of whether it is locked. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | missionId | number | Yes| Mission ID.|
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<void> | Promise used to return the result.|
+
+**Example**
+
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+
+let testMissionId = 2;
+try {
+ missionManager.clearMission(testMissionId).then((data) => {
+ console.info('clearMission successfully. Data: ' + JSON.stringify(data));
+ }).catch(error => {
+ console.error('clearMission failed. Cause: ' + error.message);
+ });
+} catch (error) {
+ console.error('clearMission failed. Cause: ' + error.message);
+}
+```
+
+## missionManager.clearAllMissions
+
+clearAllMissions(callback: AsyncCallback<void>): void;
+
+Clears all unlocked missions. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Example**
+
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+
+try {
+ missionManager.clearAllMissions(err => {
+ if (err) {
+ console.error('clearAllMissions failed:' + err.message);
+ } else {
+ console.info('clearAllMissions successfully.');
+ }
+ });
+} catch (err) {
+ console.error('clearAllMissions failed:' + err.message);
+}
+```
+
+## missionManager.clearAllMissions
+
+clearAllMissions(): Promise<void>;
+
+Clears all unlocked missions. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<void> | Promise used to return the result.|
+
+**Example**
+
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+
+try {
+ missionManager.clearAllMissions(bundleName).then(() => {
+ console.info('clearAllMissions successfully.');
+ }).catch(err => {
+ console.error('clearAllMissions failed:' + err.message);
+ });
+} catch (err) {
+ console.error('clearAllMissions failed:' + err.message);
+}
+```
+
+## missionManager.moveMissionToFront
+
+moveMissionToFront(missionId: number, callback: AsyncCallback<void>): void;
+
+Switches a given mission to the foreground. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | missionId | number | Yes| Mission ID.|
+ | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+
+**Example**
+
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+
+let testMissionId = 2;
+try {
+ missionManager.moveMissionToFront(testMissionId, (err, data) => {
+ if (err) {
+ console.error('moveMissionToFront failed:' + err.message);
+ } else {
+ console.info('moveMissionToFront successfully:' + JSON.stringify(data));
+ }
+ });
+} catch (err) {
+ console.error('moveMissionToFront failed:' + err.message);
+}
+```
+
+## missionManager.moveMissionToFront
+
+moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCallback<void>): void;
+
+Switches a given mission to the foreground, with the startup parameters for the switching specified. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | missionId | number | Yes| Mission ID.|
+ | options | [StartOptions](js-apis-app-ability-startOptions.md) | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
+ | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+
+**Example**
+
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+
+let testMissionId = 2;
+try {
+ missionManager.moveMissionToFront(testMissionId, {windowMode : 101}, (err, data) => {
+ if (err) {
+ console.error('moveMissionToFront failed:' + err.message);
+ } else {
+ console.info('moveMissionToFront successfully:' + JSON.stringify(data));
+ }
+ });
+} catch (err) {
+ console.error('moveMissionToFront failed:' + err.message);
+}
+```
+
+## missionManager.moveMissionToFront
+
+moveMissionToFront(missionId: number, options?: StartOptions): Promise<void>;
+
+Switches a given mission to the foreground, with the startup parameters for the switching specified. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MISSIONS
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | missionId | number | Yes| Mission ID.|
+ | options | [StartOptions](js-apis-app-ability-startOptions.md) | No| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<void> | Promise used to return the result.|
+
+**Example**
+
+```ts
+import missionManager from '@ohos.app.ability.missionManager';
+
+let testMissionId = 2;
+try {
+ missionManager.moveMissionToFront(testMissionId).then((data) => {
+ console.info('moveMissionToFront successfully. Data: ' + JSON.stringify(data));
+ }).catch(error => {
+ console.error('moveMissionToFront failed. Cause: ' + error.message);
+ });
+} catch (error) {
+ console.error('moveMissionToFront failed. Cause: ' + error.message);
+}
+```
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-quickFixManager.md b/en/application-dev/reference/apis/js-apis-app-ability-quickFixManager.md
new file mode 100644
index 0000000000000000000000000000000000000000..a2090ed00e60cac1b5452bf6357f47cfb3c7be2e
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-quickFixManager.md
@@ -0,0 +1,194 @@
+# @ohos.app.ability.quickFixManager (quickFixManager)
+
+The **quickFixManager** module provides APIs for quick fix. With quick fix, you can fix bugs in your application by applying patches, which is more efficient than by updating the entire application.
+
+> **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.
+
+## Modules to Import
+
+```ts
+import quickFixManager from '@ohos.app.ability.quickFixManager';
+```
+
+## HapModuleQuickFixInfo
+
+Defines the quick fix information at the HAP file level.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+| Name | Type | Mandatory| Description |
+| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
+| moduleName | string | Yes | Name of the HAP file. |
+| originHapHash | string | Yes | Hash value of the HAP file. |
+| quickFixFilePath | string | Yes | Installation path of the quick fix file. |
+
+## ApplicationQuickFixInfo
+
+Defines the quick fix information at the application level.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+| Name | Type | Mandatory| Description |
+| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
+| bundleName | string | Yes | Bundle name. |
+| bundleVersionCode | number | Yes | Internal version number of the application. |
+| bundleVersionName | string | Yes | Version number of the application that is shown to users. |
+| quickFixVersionCode | number | Yes | Version code of the quick fix patch package. |
+| quickFixVersionName | string | Yes | Text description of the version number of the quick fix patch package. |
+| hapModuleQuickFixInfo | Array\<[HapModuleQuickFixInfo](#hapmodulequickfixinfo)> | Yes | Quick fix information at the HAP file level. |
+
+## quickFixManager.applyQuickFix
+
+applyQuickFix(hapModuleQuickFixFiles: Array\, callback: AsyncCallback\): void;
+
+Applies a quick fix patch. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.INSTALL_BUNDLE
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Parameter| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | hapModuleQuickFixFiles | Array\ | Yes| Quick fix files, each of which must contain a valid file path.|
+ | callback | AsyncCallback\ | Yes| Callback used to return the result.|
+
+**Example**
+
+```ts
+ try {
+ let hapModuleQuickFixFiles = ["/data/storage/el2/base/entry.hqf"]
+ quickFixManager.applyQuickFix(hapModuleQuickFixFiles, (error) => {
+ if (error) {
+ console.info( `applyQuickFix failed with error + ${error}`)
+ } else {
+ console.info( 'applyQuickFix success')
+ }
+ })
+ } catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+ }
+```
+
+## quickFixManager.applyQuickFix
+
+applyQuickFix(hapModuleQuickFixFiles: Array\): Promise\;
+
+Applies a quick fix patch. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.INSTALL_BUNDLE
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+ | Parameter| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | hapModuleQuickFixFiles | Array\ | Yes| Quick fix files, each of which must contain a valid file path.|
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise\ | Promise used to return the result.|
+
+**Example**
+
+```ts
+ let hapModuleQuickFixFiles = ["/data/storage/el2/base/entry.hqf"]
+ try {
+ quickFixManager.applyQuickFix(hapModuleQuickFixFiles).then(() => {
+ console.info('applyQuickFix success')
+ }).catch((error) => {
+ console.info(`applyQuickFix err: + ${error}`)
+ })
+ } catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+ }
+```
+
+## quickFixManager.getApplicationQuickFixInfo
+
+getApplicationQuickFixInfo(bundleName: string, callback: AsyncCallback\): void;
+
+Obtains the quick fix information of the application. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Parameter| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| bundleName | string | Yes|Bundle name. |
+| callback | AsyncCallback\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Yes| Callback used to return the quick fix information.|
+
+**Example**
+
+```ts
+ try {
+ let bundleName = "bundleName"
+ quickFixManager.getApplicationQuickFixInfo(bundleName, (error, data) => {
+ if (error) {
+ console.info(`getApplicationQuickFixInfo error: + ${error}`)
+ } else {
+ console.info(`getApplicationQuickFixInfo success: + ${data}`)
+ }
+ })
+ } catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+ }
+```
+
+## quickFixManager.getApplicationQuickFixInfo
+
+getApplicationQuickFixInfo(bundleName: string): Promise\;
+
+Obtains the quick fix information of the application. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Parameter| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| bundleName | string | Yes| Bundle name.|
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Promise\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Promise used to return the quick fix information.|
+
+**Example**
+
+ ```ts
+ try {
+ let bundleName = "bundleName"
+ quickFixManager.getApplicationQuickFixInfo(bundleName).then((data) => {
+ console.info(`getApplicationQuickFixInfo success: + ${data}`)
+ }).catch((error) => {
+ console.info(`getApplicationQuickFixInfo err: + ${error}`)
+ })
+ } catch (paramError) {
+ console.log("error: " + paramError.code + ", " + paramError.message);
+ }
+ ```
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md b/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md
new file mode 100644
index 0000000000000000000000000000000000000000..0efdb59d5eaed4c2b70e5ff666b0c9d63b11212f
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md
@@ -0,0 +1,252 @@
+# @ohos.app.ability.ServiceExtensionAbility (ServiceExtensionAbility)
+
+The **ServiceExtensionAbility** module provides lifecycle callbacks when a ServiceExtensionAbility (background service) is created, destroyed, connected, or disconnected.
+
+> **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 can be used only in the stage model.
+
+## Modules to Import
+
+```ts
+import ServiceExtension from '@ohos.app.ability.ServiceExtensionAbility';
+```
+
+## Required Permissions
+
+None.
+
+## Attributes
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+| Name| Type| Readable| Writable| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| context | [ServiceExtensionContext](js-apis-inner-application-serviceExtensionContext.md) | Yes| No| ServiceExtensionContext, which is inherited from **ExtensionContext**.|
+
+
+## ServiceExtensionAbility.onCreate
+
+onCreate(want: Want): void;
+
+Called when a ServiceExtensionAbility is created to initialize the service logic.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| want | [Want](js-apis-app-ability-want.md) | Yes| Want information related to this ServiceExtensionAbility, including the ability name and bundle name.|
+
+**Example**
+
+ ```ts
+ class ServiceExt extends ServiceExtension {
+ onCreate(want) {
+ console.log('onCreate, want:' + want.abilityName);
+ }
+ }
+ ```
+
+
+## ServiceExtensionAbility.onDestroy
+
+onDestroy(): void;
+
+Called when this ServiceExtensionAbility is destroyed to clear resources.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Example**
+
+ ```ts
+ class ServiceExt extends ServiceExtension {
+ onDestroy() {
+ console.log('onDestroy');
+ }
+ }
+ ```
+
+
+## ServiceExtensionAbility.onRequest
+
+onRequest(want: Want, startId: number): void;
+
+Called following **onCreate()** when a ServiceExtensionAbility is started by calling **startAbility()**. The value of **startId** is incremented for each ability that is started.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| want | [Want](js-apis-app-ability-want.md) | Yes| Want information related to this ServiceExtensionAbility, including the ability name and bundle name.|
+| startId | number | Yes| Number of ability start times. The initial value is **1**, and the value is automatically incremented for each ability started.|
+
+**Example**
+
+ ```ts
+ class ServiceExt extends ServiceExtension {
+ onRequest(want, startId) {
+ console.log('onRequest, want:' + want.abilityName);
+ }
+ }
+ ```
+
+
+## ServiceExtensionAbility.onConnect
+
+onConnect(want: Want): rpc.RemoteObject;
+
+Called following **onCreate()** when a ServiceExtensionAbility is started by calling **connectAbility()**. A **RemoteObject** object is returned for communication between the server and client.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| want | [Want](js-apis-app-ability-want.md)| Yes| Want information related to this ServiceExtensionAbility, including the ability name and bundle name.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| rpc.RemoteObject | A **RemoteObject** object used for communication between the server and client.|
+
+**Example**
+
+ ```ts
+ import rpc from '@ohos.rpc'
+ class StubTest extends rpc.RemoteObject{
+ constructor(des) {
+ super(des);
+ }
+ onConnect(code, data, reply, option) {
+ }
+ }
+ class ServiceExt extends ServiceExtension {
+ onConnect(want) {
+ console.log('onConnect , want:' + want.abilityName);
+ return new StubTest("test");
+ }
+ }
+ ```
+
+
+## ServiceExtensionAbility.onDisconnect
+
+onDisconnect(want: Want): void;
+
+Called when a client is disconnected from this ServiceExtensionAbility.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| want |[Want](js-apis-app-ability-want.md)| Yes| Want information related to this ServiceExtensionAbility, including the ability name and bundle name.|
+
+**Example**
+
+ ```ts
+ class ServiceExt extends ServiceExtension {
+ onDisconnect(want) {
+ console.log('onDisconnect, want:' + want.abilityName);
+ }
+ }
+ ```
+
+## ServiceExtensionAbility.onReconnect
+
+onReconnect(want: Want): void;
+
+Called when a new client attempts to connect to this ServiceExtensionAbility after all previous clients are disconnected. This capability is reserved.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| want |[Want](js-apis-app-ability-want.md)| Yes| Want information related to this ServiceExtensionAbility, including the ability name and bundle name.|
+
+**Example**
+
+ ```ts
+ class ServiceExt extends ServiceExtension {
+ onReconnect(want) {
+ console.log('onReconnect, want:' + want.abilityName);
+ }
+ }
+ ```
+
+## ServiceExtensionAbility.onConfigurationUpdate
+
+onConfigurationUpdate(newConfig: Configuration): void;
+
+Called when the configuration of this ServiceExtensionAbility is updated.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| newConfig | [Configuration](js-apis-app-ability-configuration.md) | Yes| New configuration.|
+
+**Example**
+
+ ```ts
+ class ServiceExt extends ServiceExtension {
+ onConfigurationUpdate(config) {
+ console.log('onConfigurationUpdate, config:' + JSON.stringify(config));
+ }
+ }
+ ```
+
+## ServiceExtensionAbility.onDump
+
+onDump(params: Array\): Array\;
+
+Dumps the client information.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| params | Array\ | Yes| Parameters in the form of a command.|
+
+**Example**
+
+ ```ts
+ class ServiceExt extends ServiceExtension {
+ onDump(params) {
+ console.log('dump, params:' + JSON.stringify(params));
+ return ["params"]
+ }
+ }
+ ```
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-startOptions.md b/en/application-dev/reference/apis/js-apis-app-ability-startOptions.md
new file mode 100644
index 0000000000000000000000000000000000000000..3e95fbf541e7ed79834673c2ca97b1398bc73989
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-startOptions.md
@@ -0,0 +1,24 @@
+# @ohos.app.ability.StartOptions (StartOptions)
+
+**StartOptions** is used as an input parameter of [startAbility()](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability-1) to specify the window mode of an ability.
+
+> **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 can be used only in the stage model.
+
+## Modules to Import
+
+```ts
+import StartOptions from '@ohos.app.ability.StartOptions';
+```
+
+## Attributes
+
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| [windowMode](js-apis-application-abilityConstant.md#abilityconstantwindowmode) | number | No| Window mode.|
+| displayId | number | No| Display ID. The default value is **0**, indicating the current display.|
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md b/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md
new file mode 100644
index 0000000000000000000000000000000000000000..38d9f5428c37873ae9f786ed0f391142f30a011b
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md
@@ -0,0 +1,739 @@
+# @ohos.app.ability.UIAbility (UIAbility)
+
+UIAbility is an application component that has the UI. The **UIAbility** module provides lifecycle callback such as component creation, destruction, and foreground/background switching. It also provides the following capabilities related to component collaboration:
+
+- [Caller](#caller): an object returned by [startAbilityByCall](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartabilitybycall). The CallerAbility (caller) uses this object to communicate with the CalleeAbility (callee).
+- [Callee](#callee): an internal object of UIAbility. The CalleeAbility (callee) uses this object to communicate with the CallerAbility (caller).
+
+> **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 can be used only in the stage model.
+
+## Modules to Import
+
+```ts
+import UIAbility from '@ohos.app.ability.UIAbility';
+```
+
+## Attributes
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+| Name| Type| Readable| Writable| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| context | [UIAbilityContext](js-apis-inner-application-uiAbilityContext.md) | Yes| No| Context of the UIAbility.|
+| launchWant | [Want](js-apis-app-ability-want.md) | Yes| No| Parameters for starting the UIAbility.|
+| lastRequestWant | [Want](js-apis-app-ability-want.md) | Yes| No| Parameters used when the UIAbility was started last time.|
+| callee | [Callee](#callee) | Yes| No| Object that invokes the stub service.|
+
+## UIAbility.onCreate
+
+onCreate(want: Want, param: AbilityConstant.LaunchParam): void;
+
+Called to initialize the service logic when a UIAbility is created.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| want | [Want](js-apis-app-ability-want.md) | Yes| Information related to this UIAbility, including the ability name and bundle name.|
+| param | [AbilityConstant.LaunchParam](js-apis-app-ability-abilityConstant.md#abilityconstantlaunchparam) | Yes| Parameters for starting the UIAbility, and the reason for the last abnormal exit.|
+
+**Example**
+
+ ```ts
+ class MyUIAbility extends UIAbility {
+ onCreate(want, param) {
+ console.log('onCreate, want:' + want.abilityName);
+ }
+ }
+ ```
+
+
+## UIAbility.onWindowStageCreate
+
+onWindowStageCreate(windowStage: window.WindowStage): void
+
+Called when a **WindowStage** is created for this UIAbility.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** information.|
+
+**Example**
+
+ ```ts
+ class MyUIAbility extends UIAbility {
+ onWindowStageCreate(windowStage) {
+ console.log('onWindowStageCreate');
+ }
+ }
+ ```
+
+
+## UIAbility.onWindowStageDestroy
+
+onWindowStageDestroy(): void
+
+Called when the **WindowStage** is destroyed for this UIAbility.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Example**
+
+ ```ts
+ class MyUIAbility extends UIAbility {
+ onWindowStageDestroy() {
+ console.log('onWindowStageDestroy');
+ }
+ }
+ ```
+
+
+## UIAbility.onWindowStageRestore
+
+onWindowStageRestore(windowStage: window.WindowStage): void
+
+Called when the **WindowStage** is restored during the migration of this UIAbility, which is a multi-instance ability.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** information.|
+
+**Example**
+
+ ```ts
+ class MyUIAbility extends UIAbility {
+ onWindowStageRestore(windowStage) {
+ console.log('onWindowStageRestore');
+ }
+ }
+ ```
+
+
+## UIAbility.onDestroy
+
+onDestroy(): void;
+
+Called when this UIAbility is destroyed to clear resources.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Example**
+
+ ```ts
+ class MyUIAbility extends UIAbility {
+ onDestroy() {
+ console.log('onDestroy');
+ }
+ }
+ ```
+
+
+## UIAbility.onForeground
+
+onForeground(): void;
+
+Called when this UIAbility is switched from the background to the foreground.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Example**
+
+ ```ts
+ class MyUIAbility extends UIAbility {
+ onForeground() {
+ console.log('onForeground');
+ }
+ }
+ ```
+
+
+## UIAbility.onBackground
+
+onBackground(): void;
+
+Called when this UIAbility is switched from the foreground to the background.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Example**
+
+ ```ts
+ class MyUIAbility extends UIAbility {
+ onBackground() {
+ console.log('onBackground');
+ }
+ }
+ ```
+
+
+## UIAbility.onContinue
+
+onContinue(wantParam : {[key: string]: any}): AbilityConstant.OnContinueResult;
+
+Called to save data during the ability migration preparation process.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| wantParam | {[key: string]: any} | Yes| **want** parameter.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| [AbilityConstant.OnContinueResult](js-apis-app-ability-abilityConstant.md#abilityconstantoncontinueresult) | Continuation result.|
+
+**Example**
+
+ ```ts
+ import AbilityConstant from "@ohos.app.ability.AbilityConstant"
+ class MyUIAbility extends UIAbility {
+ onContinue(wantParams) {
+ console.log('onContinue');
+ wantParams["myData"] = "my1234567";
+ return AbilityConstant.OnContinueResult.AGREE;
+ }
+ }
+ ```
+
+
+## UIAbility.onNewWant
+
+onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void;
+
+Called when a new Want is passed in and this UIAbility is started again.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| want | [Want](js-apis-app-ability-want.md) | Yes| Want information, such as the ability name and bundle name.|
+| launchParams | [AbilityConstant.LaunchParam](js-apis-app-ability-abilityConstant.md#abilityconstantlaunchparam) | Yes| Reason for the UIAbility startup and the last abnormal exit.|
+
+**Example**
+
+ ```ts
+ class MyUIAbility extends UIAbility {
+ onNewWant(want, launchParams) {
+ console.log('onNewWant, want:' + want.abilityName);
+ console.log('onNewWant, launchParams:' + JSON.stringify(launchParams));
+ }
+ }
+ ```
+
+## UIAbility.onDump
+
+onDump(params: Array\): Array\;
+
+Dumps client information.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| params | Array\ | Yes| Parameters in the form of a command.|
+
+**Example**
+
+ ```ts
+ class MyUIAbility extends UIAbility {
+ onDump(params) {
+ console.log('dump, params:' + JSON.stringify(params));
+ return ["params"]
+ }
+ }
+ ```
+
+
+## UIAbility.onSaveState
+
+onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: any}): AbilityConstant.OnSaveResult;
+
+Called when the framework automatically saves the UIAbility state in the case of an application fault. This API is used together with [appRecovery](js-apis-app-ability-appRecovery.md). If automatic state saving is enabled, **onSaveState** is called to save the state of this UIAbility.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| reason | [AbilityConstant.StateType](js-apis-app-ability-abilityConstant.md#abilityconstantstatetype) | Yes| Reason for triggering the callback to save the UIAbility state.|
+| wantParam | {[key: string]: any} | Yes| **want** parameter.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| [AbilityConstant.OnSaveResult](js-apis-app-ability-abilityConstant.md#abilityconstantonsaveresult) | Whether the UIAbility state is saved.|
+
+**Example**
+
+ ```ts
+import AbilityConstant from '@ohos.app.ability.AbilityConstant'
+
+class MyUIAbility extends UIAbility {
+ onSaveState(reason, wantParam) {
+ console.log('onSaveState');
+ wantParam["myData"] = "my1234567";
+ return AbilityConstant.OnSaveResult.RECOVERY_AGREE;
+ }
+}
+ ```
+
+
+
+## Caller
+
+Implements sending of sequenceable data to the target ability when the CallerAbility invokes the target ability (CalleeAbility).
+
+## Caller.call
+
+call(method: string, data: rpc.Sequenceable): Promise<void>;
+
+Sends sequenceable data to the target ability.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
+| data | [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) | Yes| Sequenceable data. You need to customize the data.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise used to return a response.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------------------------------- |
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+ ```ts
+ class MyMessageAble{ // Custom sequenceable data structure.
+ name:""
+ str:""
+ num: 1
+ constructor(name, str) {
+ this.name = name;
+ this.str = str;
+ }
+ marshalling(messageParcel) {
+ messageParcel.writeInt(this.num);
+ messageParcel.writeString(this.str);
+ console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
+ return true;
+ }
+ unmarshalling(messageParcel) {
+ this.num = messageParcel.readInt();
+ this.str = messageParcel.readString();
+ console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
+ return true;
+ }
+ };
+ var method = 'call_Function'; // Notification message string negotiated by the two abilities.
+ var caller;
+ export default class MainUIAbility extends UIAbility {
+ onWindowStageCreate(windowStage) {
+ this.context.startUIAbilityByCall({
+ bundleName: "com.example.myservice",
+ abilityName: "MainUIAbility",
+ deviceId: ""
+ }).then((obj) => {
+ caller = obj;
+ let msg = new MyMessageAble("msg", "world"); // See the definition of Sequenceable.
+ caller.call(method, msg)
+ .then(() => {
+ console.log('Caller call() called');
+ })
+ .catch((callErr) => {
+ console.log('Caller.call catch error, error.code: ' + JSON.stringify(callErr.code) +
+ ' error.message: ' + JSON.stringify(callErr.message));
+ });
+ }).catch((err) => {
+ console.log('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) +
+ ' error.message: ' + JSON.stringify(err.message));
+ });
+ }
+ }
+ ```
+
+
+## Caller.callWithResult
+
+callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessageParcel>;
+
+Sends sequenceable data to the target ability and obtains the sequenceable data returned by the target ability.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
+| data | [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) | Yes| Sequenceable data. You need to customize the data.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<[rpc.MessageParcel](js-apis-rpc.md#sequenceabledeprecated)> | Promise used to return the sequenceable data from the target ability.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------------------------------- |
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+ ```ts
+ class MyMessageAble{
+ name:""
+ str:""
+ num: 1
+ constructor(name, str) {
+ this.name = name;
+ this.str = str;
+ }
+ marshalling(messageParcel) {
+ messageParcel.writeInt(this.num);
+ messageParcel.writeString(this.str);
+ console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
+ return true;
+ }
+ unmarshalling(messageParcel) {
+ this.num = messageParcel.readInt();
+ this.str = messageParcel.readString();
+ console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
+ return true;
+ }
+ };
+ var method = 'call_Function';
+ var caller;
+ export default class MainUIAbility extends UIAbility {
+ onWindowStageCreate(windowStage) {
+ this.context.startUIAbilityByCall({
+ bundleName: "com.example.myservice",
+ abilityName: "MainUIAbility",
+ deviceId: ""
+ }).then((obj) => {
+ caller = obj;
+ let msg = new MyMessageAble(1, "world");
+ caller.callWithResult(method, msg)
+ .then((data) => {
+ console.log('Caller callWithResult() called');
+ let retmsg = new MyMessageAble(0, "");
+ data.readSequenceable(retmsg);
+ })
+ .catch((callErr) => {
+ console.log('Caller.callWithResult catch error, error.code: ' + JSON.stringify(callErr.code) +
+ ' error.message: ' + JSON.stringify(callErr.message));
+ });
+ }).catch((err) => {
+ console.log('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) +
+ ' error.message: ' + JSON.stringify(err.message));
+ });
+ }
+ }
+ ```
+
+
+## Caller.release
+
+release(): void;
+
+Releases the caller interface of the target ability.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------------------------------- |
+| 401 | Invalid input parameter. |
+| 16200001 | Caller released. The caller has been released. |
+| 16200002 | Callee invalid. The callee does not exist. |
+| 16000050 | Internal Error. |
+
+**Example**
+
+ ```ts
+ var caller;
+ export default class MainUIAbility extends UIAbility {
+ onWindowStageCreate(windowStage) {
+ this.context.startUIAbilityByCall({
+ bundleName: "com.example.myservice",
+ abilityName: "MainUIAbility",
+ deviceId: ""
+ }).then((obj) => {
+ caller = obj;
+ try {
+ caller.release();
+ } catch (releaseErr) {
+ console.log('Caller.release catch error, error.code: ' + JSON.stringify(releaseErr.code) +
+ ' error.message: ' + JSON.stringify(releaseErr.message));
+ }
+ }).catch((err) => {
+ console.log('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) +
+ ' error.message: ' + JSON.stringify(err.message));
+ });
+ }
+ }
+ ```
+
+## Caller.onRelease
+
+ onRelease(callback: OnReleaseCallBack): void;
+
+Registers a callback that is invoked when the stub on the target ability is disconnected.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used for the **onRelease** API.|
+
+**Example**
+
+ ```ts
+ var caller;
+ export default class MainUIAbility extends UIAbility {
+ onWindowStageCreate(windowStage) {
+ this.context.startUIAbilityByCall({
+ bundleName: "com.example.myservice",
+ abilityName: "MainUIAbility",
+ deviceId: ""
+ }).then((obj) => {
+ caller = obj;
+ try {
+ caller.onRelease((str) => {
+ console.log(' Caller OnRelease CallBack is called ' + str);
+ });
+ } catch (error) {
+ console.log('Caller.on catch error, error.code: ' + JSON.stringify(error.code) +
+ ' error.message: ' + JSON.stringify(error.message));
+ }
+ }).catch((err) => {
+ console.log('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) +
+ ' error.message: ' + JSON.stringify(err.message));
+ });
+ }
+ }
+ ```
+
+## Caller.on
+
+ on(type: "release", callback: OnReleaseCallback): void;
+
+Registers a callback that is invoked when the stub on the target ability is disconnected.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Event type. The value is fixed at **release**.|
+| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used for the **onRelease** API.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------------------------------- |
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+ ```ts
+ var caller;
+ export default class MainUIAbility extends UIAbility {
+ onWindowStageCreate(windowStage) {
+ this.context.startUIAbilityByCall({
+ bundleName: "com.example.myservice",
+ abilityName: "MainUIAbility",
+ deviceId: ""
+ }).then((obj) => {
+ caller = obj;
+ try {
+ caller.on("release", (str) => {
+ console.log(' Caller OnRelease CallBack is called ' + str);
+ });
+ } catch (error) {
+ console.log('Caller.on catch error, error.code: ' + JSON.stringify(error.code) +
+ ' error.message: ' + JSON.stringify(error.message));
+ }
+ }).catch((err) => {
+ console.log('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) +
+ ' error.message: ' + JSON.stringify(err.message));
+ });
+ }
+ }
+ ```
+
+
+## Callee
+
+Implements callbacks for caller notification registration and deregistration.
+
+## Callee.on
+
+on(method: string, callback: CalleeCallback): void;
+
+Registers a caller notification callback, which is invoked when the target ability registers a function.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| method | string | Yes| Notification message string negotiated between the two abilities.|
+| callback | [CalleeCallback](#calleecallback) | Yes| JS notification synchronization callback of the [rpc.MessageParcel](js-apis-rpc.md#messageparceldeprecated) type. The callback must return at least one empty [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) object. Otherwise, the function execution fails.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------------------------------- |
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+ ```ts
+ class MyMessageAble{
+ name:""
+ str:""
+ num: 1
+ constructor(name, str) {
+ this.name = name;
+ this.str = str;
+ }
+ marshalling(messageParcel) {
+ messageParcel.writeInt(this.num);
+ messageParcel.writeString(this.str);
+ console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
+ return true;
+ }
+ unmarshalling(messageParcel) {
+ this.num = messageParcel.readInt();
+ this.str = messageParcel.readString();
+ console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
+ return true;
+ }
+ };
+ var method = 'call_Function';
+ function funcCallBack(pdata) {
+ console.log('Callee funcCallBack is called ' + pdata);
+ let msg = new MyMessageAble("test", "");
+ pdata.readSequenceable(msg);
+ return new MyMessageAble("test1", "Callee test");
+ }
+ export default class MainUIAbility extends UIAbility {
+ onCreate(want, launchParam) {
+ console.log('Callee onCreate is called');
+ try {
+ this.callee.on(method, funcCallBack);
+ } catch (error) {
+ console.log('Callee.on catch error, error.code: ' + JSON.stringify(error.code) +
+ ' error.message: ' + JSON.stringify(error.message));
+ }
+ }
+ }
+ ```
+
+## Callee.off
+
+off(method: string): void;
+
+Deregisters a caller notification callback, which is invoked when the target ability registers a function.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| method | string | Yes| Registered notification message string.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------------------------------- |
+| 401 | If the input parameter is not valid parameter. |
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+
+**Example**
+
+ ```ts
+ var method = 'call_Function';
+ export default class MainUIAbility extends UIAbility {
+ onCreate(want, launchParam) {
+ console.log('Callee onCreate is called');
+ try {
+ this.callee.off(method);
+ } catch (error) {
+ console.log('Callee.off catch error, error.code: ' + JSON.stringify(error.code) +
+ ' error.message: ' + JSON.stringify(error.message));
+ }
+ }
+ }
+ ```
+
+## OnReleaseCallback
+
+(msg: string): void;
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+| Name| Readable| Writable| Type| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| (msg: string) | Yes| No| function | Prototype of the listener function registered by the caller.|
+
+## CalleeCallback
+
+(indata: rpc.MessageParcel): rpc.Sequenceable;
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+| Name| Readable| Writable| Type| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| (indata: [rpc.MessageParcel](js-apis-rpc.md#messageparceldeprecated)) | Yes| No| [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) | Prototype of the listener function registered by the callee.|
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-want.md b/en/application-dev/reference/apis/js-apis-app-ability-want.md
new file mode 100644
index 0000000000000000000000000000000000000000..c96e29d90f3a10a563df41bc8a545cb42dfdeba4
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-want.md
@@ -0,0 +1,136 @@
+# @ohos.app.ability.Want (Want)
+
+Want is a carrier for information transfer between objects (application components). Want can be used as a parameter of **startAbility** to specify a startup target and information that needs to be carried during startup, for example, **bundleName** and **abilityName**, which respectively indicate the bundle name of the target ability and the ability name in the bundle. When UIAbility A needs to start UIAbility B and transfer some data to UIAbility B, it can use Want a carrier to transfer the data.
+
+> **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.
+
+## Modules to Import
+
+```ts
+import Want from '@ohos.app.ability.Want';
+```
+
+## Attributes
+
+**System capability**: SystemCapability.Ability.AbilityBase
+
+| Name | Type | Mandatory| Description |
+| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
+| deviceId | string | No | ID of the device running the ability. If this field is unspecified, the local device is used. |
+| bundleName | string | No | Bundle name of the ability.|
+| moduleName | string | No| Name of the module to which the ability belongs.|
+| abilityName | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.|
+| [action](js-apis-app-ability-wantConstant.md#wantconstantaction) | string | No | Action to take, such as viewing and sharing application details. In implicit Want, you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data. For details about the definition and matching rules of implicit Want, see [Matching Rules of Explicit Want and Implicit Want](../../application-models/explicit-implicit-want-mappings.md). |
+| [entities](js-apis-app-ability-wantConstant.md#wantconstantentity) | Array\ | No| Additional category information (such as browser and video player) of the ability. It is a supplement to the **action** field for implicit Want. and is used to filter ability types.|
+| uri | string | No| Data carried. This field is used together with **type** to specify the data type. If **uri** is specified in a Want, the Want will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
+| type | string | No| MIME type, that is, the type of the file to open, for example, **text/xml** and **image/***. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com.|
+| parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:
- **ohos.aafwk.callerPid**: PID of the caller.
- **ohos.aafwk.param.callerToken**: token of the caller.
- **ohos.aafwk.param.callerUid**: UID in [BundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information. |
+| [flags](js-apis-ability-wantConstant.md#wantconstantflags) | number | No| How the **Want** object will be handled. By default, a number is passed in.
For example, **wantConstant.Flags.FLAG_ABILITY_CONTINUATION** specifies whether to start the ability in cross-device migration scenarios.|
+
+**Example**
+
+- Basic usage (called in a UIAbility object, where context in the example is the context object of the UIAbility).
+
+ ```ts
+ let want = {
+ "deviceId": "", // An empty deviceId indicates the local device.
+ "bundleName": "com.example.myapplication",
+ "abilityName": "FuncAbility",
+ "moduleName": "entry" // moduleName is optional.
+ };
+ this.context.startAbility(want, (error) => {
+ // Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
+ console.log("error.code = " + error.code)
+ })
+ ```
+
+- Data is transferred through user-defined fields. The following data types are supported (called in a UIAbility object, where context in the example is the context object of the UIAbility):
+
+ * String
+ ```ts
+ let want = {
+ bundleName: "com.example.myapplication",
+ abilityName: "FuncAbility",
+ parameters: {
+ keyForString: "str",
+ },
+ }
+ ```
+ * Number
+ ```ts
+ let want = {
+ bundleName: "com.example.myapplication",
+ abilityName: "FuncAbility",
+ parameters: {
+ keyForInt: 100,
+ keyForDouble: 99.99,
+ },
+ }
+ ```
+ * Boolean
+ ```ts
+ let want = {
+ bundleName: "com.example.myapplication",
+ abilityName: "FuncAbility",
+ parameters: {
+ keyForBool: true,
+ },
+ }
+ ```
+ * Object
+ ```ts
+ let want = {
+ bundleName: "com.example.myapplication",
+ abilityName: "FuncAbility",
+ parameters: {
+ keyForObject: {
+ keyForObjectString: "str",
+ keyForObjectInt: -200,
+ keyForObjectDouble: 35.5,
+ keyForObjectBool: false,
+ },
+ },
+ }
+ ```
+ * Array
+ ```ts
+ let want = {
+ bundleName: "com.example.myapplication",
+ abilityName: "FuncAbility",
+ parameters: {
+ keyForArrayString: ["str1", "str2", "str3"],
+ keyForArrayInt: [100, 200, 300, 400],
+ keyForArrayDouble: [0.1, 0.2],
+ keyForArrayObject: [{obj1: "aaa"}, {obj2: 100}],
+ },
+ }
+ ```
+ * File descriptor (FD)
+ ```ts
+ import fileio from '@ohos.fileio';
+ let fd;
+ try {
+ fd = fileio.openSync("/data/storage/el2/base/haps/pic.png");
+ } catch(e) {
+ console.log("openSync fail:" + JSON.stringify(e));
+ }
+ let want = {
+ "deviceId": "", // An empty deviceId indicates the local device.
+ "bundleName": "com.example.myapplication",
+ "abilityName": "FuncAbility",
+ "moduleName": "entry", // moduleName is optional.
+ "parameters": {
+ "keyFd":{"type":"FD", "value":fd}
+ }
+ };
+ this.context.startAbility(want, (error) => {
+ // Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
+ console.log("error.code = " + error.code)
+ })
+ ```
+
+- For more details and examples, see [Want](../../application-models/want-overview.md).
+
+
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-wantAgent.md b/en/application-dev/reference/apis/js-apis-app-ability-wantAgent.md
new file mode 100644
index 0000000000000000000000000000000000000000..43b95743b25c34bdae9457c1e1ed1cf01f8e986e
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-wantAgent.md
@@ -0,0 +1,1619 @@
+# @ohos.app.ability.wantAgent (WantAgent)
+
+The **app.ability.WantAgent** module provides APIs for creating and comparing **WantAgent** objects, and obtaining the user ID and bundle name of a **WantAgent** object. You are advised to use this module, since it will replace the [@ohos.wantAgent](js-apis-wantAgent.md) module in the near future.
+
+> **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.
+
+## Modules to Import
+
+```ts
+import WantAgent from '@ohos.app.ability.wantAgent';
+```
+
+## WantAgent.getWantAgent
+
+getWantAgent(info: WantAgentInfo, callback: AsyncCallback\): void
+
+Obtains a **WantAgent** object. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------- | ---- | ----------------------- |
+| info | [WantAgentInfo](js-apis-inner-wantAgent-wantAgentInfo.md) | Yes | Information about the **WantAgent** object to obtain. |
+| callback | AsyncCallback\ | Yes | Callback used to return the **WantAgent** object.|
+
+**Error codes**
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+| ID | Error Message |
+|-----------|--------------------|
+| 16000001 | Input error. The specified ability name does not exist. |
+| 16000002 | Ability type error. The specified ability type is wrong.|
+| 16000003 | Input error. The specified id does not exist.|
+| 16000004 | Visibility verification failed.|
+| 16000006 | Can not cross user operations.|
+| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
+| 16000008 | Crowdtest App Expiration.|
+| 16000009 | Can not start ability in wukong mode.|
+| 16000010 | Can not operation with continue flag.|
+| 16000011 | Context does not exist.|
+| 16000050 | Internal Error.|
+| 16000051 | Network error. The network is abnormal.|
+| 16000052 | Free install not support. The application does not support free install.|
+| 16000053 | Not top ability. The application is not top ability.|
+| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
+| 16000055 | Free install timeout.|
+| 16000056 | Can not free install other ability.|
+| 16000057 | Not support cross device free install.|
+| 16000101 | execute shell command failed.|
+| 16000151 | Invalid wantagent object.|
+| 16000152 | wantAgent object not found.|
+| 16000153 | wangAgent object canceled.|
+
+**Example**
+
+```ts
+// WantAgent object
+let wantAgent;
+// WantAgentInfo object
+let wantAgentInfo = {
+ wants: [
+ {
+ deviceId: 'deviceId',
+ bundleName: 'com.example.myapplication',
+ abilityName: 'EntryAbility',
+ action: 'action1',
+ entities: ['entity1'],
+ type: 'MIMETYPE',
+ uri: 'key={true,true,false}',
+ parameters:
+ {
+ mykey0: 2222,
+ mykey1: [1, 2, 3],
+ mykey2: '[1, 2, 3]',
+ mykey3: 'ssssssssssssssssssssssssss',
+ mykey4: [false, true, false],
+ mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
+ mykey6: true,
+ }
+ }
+ ],
+ operationType: WantAgent.OperationType.START_ABILITIES,
+ requestCode: 0,
+ wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
+}
+
+// getWantAgent callback
+function getWantAgentCallback(err, data) {
+ if (err === undefined) {
+ wantAgent = data;
+ } else {
+ console.info('getWantAgent failed' + JSON.stringify(err));
+ }
+}
+try {
+ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
+} catch(err) {
+ console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+}
+```
+
+
+
+## WantAgent.getWantAgent
+
+getWantAgent(info: WantAgentInfo): Promise\
+
+Obtains a **WantAgent** object. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ---- | ------------- | ---- | ------------- |
+| info | [WantAgentInfo](js-apis-inner-wantAgent-wantAgentInfo.md) | Yes | Information about the **WantAgent** object to obtain.|
+
+**Return value**
+
+| Type | Description |
+| ----------------------------------------------------------- | ------------------------------------------------------------ |
+| Promise\ | Promise used to return the **WantAgent** object.|
+
+**Error codes**
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+| ID | Error Message |
+|-----------|--------------------|
+| 16000001 | Input error. The specified ability name does not exist. |
+| 16000002 | Ability type error. The specified ability type is wrong.|
+| 16000003 | Input error. The specified id does not exist.|
+| 16000004 | Visibility verification failed.|
+| 16000006 | Can not cross user operations.|
+| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
+| 16000008 | Crowdtest App Expiration.|
+| 16000009 | Can not start ability in wukong mode.|
+| 16000010 | Can not operation with continue flag.|
+| 16000011 | Context does not exist.|
+| 16000050 | Internal Error.|
+| 16000051 | Network error. The network is abnormal.|
+| 16000052 | Free install not support. The application does not support free install.|
+| 16000053 | Not top ability. The application is not top ability.|
+| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
+| 16000055 | Free install timeout.|
+| 16000056 | Can not free install other ability.|
+| 16000057 | Not support cross device free install.|
+| 16000101 | execute shell command failed.|
+| 16000151 | Invalid wantagent object.|
+| 16000152 | wantAgent object not found.|
+| 16000153 | wangAgent object canceled.|
+
+**Example**
+
+```ts
+// WantAgentInfo object
+let wantAgentInfo = {
+ wants: [
+ {
+ deviceId: 'deviceId',
+ bundleName: 'com.example.myapplication',
+ abilityName: 'EntryAbility',
+ action: 'action1',
+ entities: ['entity1'],
+ type: 'MIMETYPE',
+ uri: 'key={true,true,false}',
+ parameters:
+ {
+ mykey0: 2222,
+ mykey1: [1, 2, 3],
+ mykey2: '[1, 2, 3]',
+ mykey3: 'ssssssssssssssssssssssssss',
+ mykey4: [false, true, false],
+ mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
+ mykey6: true,
+ }
+ }
+ ],
+ operationType: WantAgent.OperationType.START_ABILITIES,
+ requestCode: 0,
+ wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
+}
+
+try {
+ WantAgent.getWantAgent(wantAgentInfo).then((data) => {
+ wantAgent = data;
+}).catch((err) => {
+ console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+});
+} catch (err) {
+ console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+}
+```
+
+
+
+## WantAgent.getBundleName
+
+getBundleName(agent: WantAgent, callback: AsyncCallback\): void
+
+Obtains the bundle name of a **WantAgent** object. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------- | ---- | --------------------------------- |
+| agent | WantAgent | Yes | Target **WantAgent** object. |
+| callback | AsyncCallback\ | Yes | Callback used to return the bundle name.|
+
+**Error codes**
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+| ID | Error Message |
+|-----------|--------------------|
+| 16000001 | Input error. The specified ability name does not exist. |
+| 16000002 | Ability type error. The specified ability type is wrong.|
+| 16000003 | Input error. The specified id does not exist.|
+| 16000004 | Visibility verification failed.|
+| 16000006 | Can not cross user operations.|
+| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
+| 16000008 | Crowdtest App Expiration.|
+| 16000009 | Can not start ability in wukong mode.|
+| 16000010 | Can not operation with continue flag.|
+| 16000011 | Context does not exist.|
+| 16000050 | Internal Error.|
+| 16000051 | Network error. The network is abnormal.|
+| 16000052 | Free install not support. The application does not support free install.|
+| 16000053 | Not top ability. The application is not top ability.|
+| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
+| 16000055 | Free install timeout.|
+| 16000056 | Can not free install other ability.|
+| 16000057 | Not support cross device free install.|
+| 16000101 | execute shell command failed.|
+| 16000151 | Invalid wantagent object.|
+| 16000152 | wantAgent object not found.|
+| 16000153 | wangAgent object canceled.|
+
+**Example**
+
+```ts
+// WantAgent object
+let wantAgent;
+// WantAgentInfo object
+let wantAgentInfo = {
+ wants: [
+ {
+ deviceId: 'deviceId',
+ bundleName: 'com.example.myapplication',
+ abilityName: 'EntryAbility',
+ action: 'action1',
+ entities: ['entity1'],
+ type: 'MIMETYPE',
+ uri: 'key={true,true,false}',
+ parameters:
+ {
+ mykey0: 2222,
+ mykey1: [1, 2, 3],
+ mykey2: '[1, 2, 3]',
+ mykey3: 'ssssssssssssssssssssssssss',
+ mykey4: [false, true, false],
+ mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
+ mykey6: true,
+ }
+ }
+ ],
+ operationType: WantAgent.OperationType.START_ABILITIES,
+ requestCode: 0,
+ wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
+}
+
+// getWantAgent callback
+function getWantAgentCallback(err, data) {
+ if (err === undefined) {
+ wantAgent = data;
+ } else {
+ console.info('getWantAgent failed' + JSON.stringify(wantAgent));
+ }
+ // getBundleName callback
+ function getBundleNameCallback(err, data) {
+ if(err) {
+ console.info('getBundleName failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ } else {
+ console.info('getBundleName ok!' + JSON.stringify(data));
+ }
+ }
+ try {
+ WantAgent.getBundleName(wantAgent, getBundleNameCallback);
+ } catch(err) {
+ console.info('getBundleName failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ }
+}
+try {
+ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
+} catch(err) {
+ console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+}
+```
+
+
+
+## WantAgent.getBundleName
+
+getBundleName(agent: WantAgent): Promise\
+
+Obtains the bundle name of a **WantAgent** object. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----- | --------- | ---- | ------------- |
+| agent | WantAgent | Yes | Target **WantAgent** object.|
+
+**Return value**
+
+| Type | Description |
+| ----------------------------------------------------------- | ------------------------------------------------------------ |
+| Promise\ | Promise used to return the bundle name.|
+
+**Error codes**
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+| ID | Error Message |
+|-----------|--------------------|
+| 16000001 | Input error. The specified ability name does not exist. |
+| 16000002 | Ability type error. The specified ability type is wrong.|
+| 16000003 | Input error. The specified id does not exist.|
+| 16000004 | Visibility verification failed.|
+| 16000006 | Can not cross user operations.|
+| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
+| 16000008 | Crowdtest App Expiration.|
+| 16000009 | Can not start ability in wukong mode.|
+| 16000010 | Can not operation with continue flag.|
+| 16000011 | Context does not exist.|
+| 16000050 | Internal Error.|
+| 16000051 | Network error. The network is abnormal.|
+| 16000052 | Free install not support. The application does not support free install.|
+| 16000053 | Not top ability. The application is not top ability.|
+| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
+| 16000055 | Free install timeout.|
+| 16000056 | Can not free install other ability.|
+| 16000057 | Not support cross device free install.|
+| 16000101 | execute shell command failed.|
+| 16000151 | Invalid wantagent object.|
+| 16000152 | wantAgent object not found.|
+| 16000153 | wangAgent object canceled.|
+
+**Example**
+
+```ts
+ // WantAgent object
+let wantAgent;
+// WantAgentInfo object
+let wantAgentInfo = {
+ wants: [
+ {
+ deviceId: 'deviceId',
+ bundleName: 'com.example.myapplication',
+ abilityName: 'EntryAbility',
+ action: 'action1',
+ entities: ['entity1'],
+ type: 'MIMETYPE',
+ uri: 'key={true,true,false}',
+ parameters:
+ {
+ mykey0: 2222,
+ mykey1: [1, 2, 3],
+ mykey2: '[1, 2, 3]',
+ mykey3: 'ssssssssssssssssssssssssss',
+ mykey4: [false, true, false],
+ mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
+ mykey6: true,
+ }
+ }
+ ],
+ operationType: WantAgent.OperationType.START_ABILITIES,
+ requestCode: 0,
+ wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
+}
+
+// getWantAgent callback
+function getWantAgentCallback(err, data) {
+ if (err === undefined) {
+ wantAgent = data;
+ } else {
+ console.info('getWantAgent failed!' + JSON.stringify(wantAgent));
+ }
+ try {
+ WantAgent.getBundleName(wantAgent).then((data)=>{
+ console.info('getBundleName ok!' + JSON.stringify(data));
+ }).catch((err)=>{
+ console.info('getBundleName failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ })
+ } catch(err){
+ console.info('getBundleName failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ }
+}
+try {
+ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
+} catch(err) {
+ console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+}
+```
+
+
+
+## WantAgent.getUid
+
+getUid(agent: WantAgent, callback: AsyncCallback\): void
+
+Obtains the user ID of a **WantAgent** object. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------- | ---- | ----------------------------------- |
+| agent | WantAgent | Yes | Target **WantAgent** object. |
+| callback | AsyncCallback\ | Yes | Callback used to return the user ID.|
+
+**Error codes**
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+| ID | Error Message |
+|-----------|--------------------|
+| 16000001 | Input error. The specified ability name does not exist. |
+| 16000002 | Ability type error. The specified ability type is wrong.|
+| 16000003 | Input error. The specified id does not exist.|
+| 16000004 | Visibility verification failed.|
+| 16000006 | Can not cross user operations.|
+| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
+| 16000008 | Crowdtest App Expiration.|
+| 16000009 | Can not start ability in wukong mode.|
+| 16000010 | Can not operation with continue flag.|
+| 16000011 | Context does not exist.|
+| 16000050 | Internal Error.|
+| 16000051 | Network error. The network is abnormal.|
+| 16000052 | Free install not support. The application does not support free install.|
+| 16000053 | Not top ability. The application is not top ability.|
+| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
+| 16000055 | Free install timeout.|
+| 16000056 | Can not free install other ability.|
+| 16000057 | Not support cross device free install.|
+| 16000101 | execute shell command failed.|
+| 16000151 | Invalid wantagent object.|
+| 16000152 | wantAgent object not found.|
+| 16000153 | wangAgent object canceled.|
+
+**Example**
+
+```ts
+import WantAgent from '@ohos.app.ability.wantAgent';
+// WantAgent object
+let wantAgent;
+// WantAgentInfo object
+let wantAgentInfo = {
+ wants: [
+ {
+ deviceId: 'deviceId',
+ bundleName: 'com.example.myapplication',
+ abilityName: 'EntryAbility',
+ action: 'action1',
+ entities: ['entity1'],
+ type: 'MIMETYPE',
+ uri: 'key={true,true,false}',
+ parameters:
+ {
+ mykey0: 2222,
+ mykey1: [1, 2, 3],
+ mykey2: '[1, 2, 3]',
+ mykey3: 'ssssssssssssssssssssssssss',
+ mykey4: [false, true, false],
+ mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
+ mykey6: true,
+ }
+ }
+ ],
+ operationType: WantAgent.OperationType.START_ABILITIES,
+ requestCode: 0,
+ wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
+}
+
+// getWantAgent callback
+function getWantAgentCallback(err, data) {
+ if (err === undefined) {
+ wantAgent = data;
+ } else {
+ console.info('getWantAgent failed' + JSON.stringify(err));
+ }
+ // getUid callback
+ function getUidCallback(err, data) {
+ if(err) {
+ console.info('getUid failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ } else {
+ console.info('getUid ok!' + JSON.stringify(data));
+ }
+ }
+ try {
+ WantAgent.getUid(wantAgent, getUidCallback);
+ } catch(err) {
+ console.info('getUid failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ }
+}
+try {
+ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
+} catch(err) {
+ console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+}
+```
+
+
+
+## WantAgent.getUid
+
+getUid(agent: WantAgent): Promise\
+
+Obtains the user ID of a **WantAgent** object. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----- | --------- | ---- | ------------- |
+| agent | WantAgent | Yes | Target **WantAgent** object.|
+
+**Return value**
+
+| Type | Description |
+| ----------------------------------------------------------- | ------------------------------------------------------------ |
+| Promise\ | Promise used to return the user ID.|
+
+**Error codes**
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+| ID | Error Message |
+|-----------|--------------------|
+| 16000001 | Input error. The specified ability name does not exist. |
+| 16000002 | Ability type error. The specified ability type is wrong.|
+| 16000003 | Input error. The specified id does not exist.|
+| 16000004 | Visibility verification failed.|
+| 16000006 | Can not cross user operations.|
+| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
+| 16000008 | Crowdtest App Expiration.|
+| 16000009 | Can not start ability in wukong mode.|
+| 16000010 | Can not operation with continue flag.|
+| 16000011 | Context does not exist.|
+| 16000050 | Internal Error.|
+| 16000051 | Network error. The network is abnormal.|
+| 16000052 | Free install not support. The application does not support free install.|
+| 16000053 | Not top ability. The application is not top ability.|
+| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
+| 16000055 | Free install timeout.|
+| 16000056 | Can not free install other ability.|
+| 16000057 | Not support cross device free install.|
+| 16000101 | execute shell command failed.|
+| 16000151 | Invalid wantagent object.|
+| 16000152 | wantAgent object not found.|
+| 16000153 | wangAgent object canceled.|
+
+**Example**
+
+```ts
+// WantAgent object
+let wantAgent;
+// WantAgentInfo object
+let wantAgentInfo = {
+ wants: [
+ {
+ deviceId: 'deviceId',
+ bundleName: 'com.example.myapplication',
+ abilityName: 'EntryAbility',
+ action: 'action1',
+ entities: ['entity1'],
+ type: 'MIMETYPE',
+ uri: 'key={true,true,false}',
+ parameters:
+ {
+ mykey0: 2222,
+ mykey1: [1, 2, 3],
+ mykey2: '[1, 2, 3]',
+ mykey3: 'ssssssssssssssssssssssssss',
+ mykey4: [false, true, false],
+ mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
+ mykey6: true,
+ }
+ }
+ ],
+ operationType: WantAgent.OperationType.START_ABILITIES,
+ requestCode: 0,
+ wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
+}
+
+// getWantAgent callback
+function getWantAgentCallback(err, data) {
+ if (err === undefined) {
+ wantAgent = data;
+ } else {
+ console.info('getWantAgent failed!' + JSON.stringify(wantAgent));
+ }
+ try {
+ WantAgent.getUid(wantAgent).then((data)=>{
+ console.info('getUid ok!' + JSON.stringify(data));
+ }).catch((err)=>{
+ console.info('getUid failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ })
+ } catch(err){
+ console.info('getUid failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ }
+}
+try {
+ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
+} catch(err) {
+ console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+}
+```
+
+
+## WantAgent.getWant
+
+getWant(agent: WantAgent, callback: AsyncCallback\): void
+
+Obtains the want in a **WantAgent** object. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | --------------------- | ---- | ------------------------------- |
+| agent | WantAgent | Yes | Target **WantAgent** object. |
+| callback | AsyncCallback\<[Want](js-apis-app-ability-want.md)\> | Yes | Callback used to return the want.|
+
+**Error codes**
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+| ID | Error Message |
+|-----------|--------------------|
+| 16000001 | Input error. The specified ability name does not exist. |
+| 16000002 | Ability type error. The specified ability type is wrong.|
+| 16000003 | Input error. The specified id does not exist.|
+| 16000004 | Visibility verification failed.|
+| 16000006 | Can not cross user operations.|
+| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
+| 16000008 | Crowdtest App Expiration.|
+| 16000009 | Can not start ability in wukong mode.|
+| 16000010 | Can not operation with continue flag.|
+| 16000011 | Context does not exist.|
+| 16000050 | Internal Error.|
+| 16000051 | Network error. The network is abnormal.|
+| 16000052 | Free install not support. The application does not support free install.|
+| 16000053 | Not top ability. The application is not top ability.|
+| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
+| 16000055 | Free install timeout.|
+| 16000056 | Can not free install other ability.|
+| 16000057 | Not support cross device free install.|
+| 16000101 | execute shell command failed.|
+| 16000151 | Invalid wantagent object.|
+| 16000152 | wantAgent object not found.|
+| 16000153 | wangAgent object canceled.|
+
+**Example**
+
+```ts
+// WantAgent object
+let wantAgent;
+// WantAgentInfo object
+let wantAgentInfo = {
+ wants: [
+ {
+ deviceId: 'deviceId',
+ bundleName: 'com.example.myapplication',
+ abilityName: 'EntryAbility',
+ action: 'action1',
+ entities: ['entity1'],
+ type: 'MIMETYPE',
+ uri: 'key={true,true,false}',
+ parameters:
+ {
+ mykey0: 2222,
+ mykey1: [1, 2, 3],
+ mykey2: '[1, 2, 3]',
+ mykey3: 'ssssssssssssssssssssssssss',
+ mykey4: [false, true, false],
+ mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
+ mykey6: true,
+ }
+ }
+ ],
+ operationType: WantAgent.OperationType.START_ABILITIES,
+ requestCode: 0,
+ wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
+}
+
+// getWantAgent callback
+function getWantAgentCallback(err, data) {
+ if (err === undefined) {
+ wantAgent = data;
+ } else {
+ console.info('getWantAgent failed' + JSON.stringify(wantAgent));
+ }
+ // getUid callback
+ function getWantCallback(err, data) {
+ if(err) {
+ console.info('getWant failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ } else {
+ console.info('getWant ok!' + JSON.stringify(data));
+ }
+ }
+ try {
+ WantAgent.getWant(wantAgent, getBundleNameCallback);
+ } catch(err) {
+ console.info('getWant failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ }
+}
+try {
+ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
+} catch(err) {
+ console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+}
+```
+
+
+
+## WantAgent.getWant
+
+getWant(agent: WantAgent): Promise\
+
+Obtains the want in a **WantAgent** object. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----- | --------- | ---- | ------------- |
+| agent | WantAgent | Yes | Target **WantAgent** object.|
+
+**Return value**
+
+| Type | Description |
+| ----------------------------------------------------------- | ------------------------------------------------------------ |
+| Promise\ | Promise used to return the want.|
+
+**Error codes**
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+| ID | Error Message |
+|-----------|--------------------|
+| 16000001 | Input error. The specified ability name does not exist. |
+| 16000002 | Ability type error. The specified ability type is wrong.|
+| 16000003 | Input error. The specified id does not exist.|
+| 16000004 | Visibility verification failed.|
+| 16000006 | Can not cross user operations.|
+| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
+| 16000008 | Crowdtest App Expiration.|
+| 16000009 | Can not start ability in wukong mode.|
+| 16000010 | Can not operation with continue flag.|
+| 16000011 | Context does not exist.|
+| 16000050 | Internal Error.|
+| 16000051 | Network error. The network is abnormal.|
+| 16000052 | Free install not support. The application does not support free install.|
+| 16000053 | Not top ability. The application is not top ability.|
+| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
+| 16000055 | Free install timeout.|
+| 16000056 | Can not free install other ability.|
+| 16000057 | Not support cross device free install.|
+| 16000101 | execute shell command failed.|
+| 16000151 | Invalid wantagent object.|
+| 16000152 | wantAgent object not found.|
+| 16000153 | wangAgent object canceled.|
+
+**Example**
+
+```ts
+// WantAgent object
+let wantAgent;
+// WantAgentInfo object
+let wantAgentInfo = {
+ wants: [
+ {
+ deviceId: 'deviceId',
+ bundleName: 'com.example.myapplication',
+ abilityName: 'EntryAbility',
+ action: 'action1',
+ entities: ['entity1'],
+ type: 'MIMETYPE',
+ uri: 'key={true,true,false}',
+ parameters:
+ {
+ mykey0: 2222,
+ mykey1: [1, 2, 3],
+ mykey2: '[1, 2, 3]',
+ mykey3: 'ssssssssssssssssssssssssss',
+ mykey4: [false, true, false],
+ mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
+ mykey6: true,
+ }
+ }
+ ],
+ operationType: WantAgent.OperationType.START_ABILITIES,
+ requestCode: 0,
+ wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
+}
+
+// getWantAgent callback
+function getWantAgentCallback(err, data) {
+ if (err === undefined) {
+ wantAgent = data;
+ } else {
+ console.info('getWantAgent failed!' + JSON.stringify(wantAgent));
+ }
+ try {
+ WantAgent.getUid(wantAgent).then((data)=>{
+ console.info('getUid ok!' + JSON.stringify(data));
+ }).catch((err)=>{
+ console.info('getUid failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ })
+ } catch(err){
+ console.info('getUid failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ }
+}
+try {
+ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
+} catch(err) {
+ console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+}
+```
+
+
+
+## WantAgent.cancel
+
+cancel(agent: WantAgent, callback: AsyncCallback\): void
+
+Cancels a **WantAgent** object. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | --------------------- | ---- | --------------------------- |
+| agent | WantAgent | Yes | Target **WantAgent** object. |
+| callback | AsyncCallback\ | Yes | Callback used to return the result.|
+
+**Error codes**
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+| ID | Error Message |
+|-----------|--------------------|
+| 16000001 | Input error. The specified ability name does not exist. |
+| 16000002 | Ability type error. The specified ability type is wrong.|
+| 16000003 | Input error. The specified id does not exist.|
+| 16000004 | Visibility verification failed.|
+| 16000006 | Can not cross user operations.|
+| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
+| 16000008 | Crowdtest App Expiration.|
+| 16000009 | Can not start ability in wukong mode.|
+| 16000010 | Can not operation with continue flag.|
+| 16000011 | Context does not exist.|
+| 16000050 | Internal Error.|
+| 16000051 | Network error. The network is abnormal.|
+| 16000052 | Free install not support. The application does not support free install.|
+| 16000053 | Not top ability. The application is not top ability.|
+| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
+| 16000055 | Free install timeout.|
+| 16000056 | Can not free install other ability.|
+| 16000057 | Not support cross device free install.|
+| 16000101 | execute shell command failed.|
+| 16000151 | Invalid wantagent object.|
+| 16000152 | wantAgent object not found.|
+| 16000153 | wangAgent object canceled.|
+
+**Example**
+
+```ts
+// WantAgent object
+let wantAgent;
+// WantAgentInfo object
+let wantAgentInfo = {
+ wants: [
+ {
+ deviceId: 'deviceId',
+ bundleName: 'com.example.myapplication',
+ abilityName: 'EntryAbility',
+ action: 'action1',
+ entities: ['entity1'],
+ type: 'MIMETYPE',
+ uri: 'key={true,true,false}',
+ parameters:
+ {
+ mykey0: 2222,
+ mykey1: [1, 2, 3],
+ mykey2: '[1, 2, 3]',
+ mykey3: 'ssssssssssssssssssssssssss',
+ mykey4: [false, true, false],
+ mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
+ mykey6: true,
+ }
+ }
+ ],
+ operationType: WantAgent.OperationType.START_ABILITIES,
+ requestCode: 0,
+ wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
+}
+
+// getWantAgent callback
+function getWantAgentCallback(err, data) {
+ if (err === undefined) {
+ wantAgent = data;
+ } else {
+ console.info('getWantAgent failed' + JSON.stringify(wantAgent));
+ }
+ // getUid callback
+ function cancelCallback(err, data) {
+ if(err) {
+ console.info('cancel failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ } else {
+ console.info('cancel ok!');
+ }
+ }
+ try {
+ WantAgent.cancel(wantAgent, getBundleNameCallback);
+ } catch(err) {
+ console.info('cancel failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ }
+}
+try {
+ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
+} catch(err) {
+ console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+}
+```
+
+
+
+## WantAgent.cancel
+
+cancel(agent: WantAgent): Promise\
+
+Cancels a **WantAgent** object. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----- | --------- | ---- | ------------- |
+| agent | WantAgent | Yes | Target **WantAgent** object.|
+
+**Return value**
+
+| Type | Description |
+| --------------- | ------------------------------- |
+| Promise\ | Promise used to return the result.|
+
+**Error codes**
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+| ID | Error Message |
+|-----------|--------------------|
+| 16000001 | Input error. The specified ability name does not exist. |
+| 16000002 | Ability type error. The specified ability type is wrong.|
+| 16000003 | Input error. The specified id does not exist.|
+| 16000004 | Visibility verification failed.|
+| 16000006 | Can not cross user operations.|
+| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
+| 16000008 | Crowdtest App Expiration.|
+| 16000009 | Can not start ability in wukong mode.|
+| 16000010 | Can not operation with continue flag.|
+| 16000011 | Context does not exist.|
+| 16000050 | Internal Error.|
+| 16000051 | Network error. The network is abnormal.|
+| 16000052 | Free install not support. The application does not support free install.|
+| 16000053 | Not top ability. The application is not top ability.|
+| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
+| 16000055 | Free install timeout.|
+| 16000056 | Can not free install other ability.|
+| 16000057 | Not support cross device free install.|
+| 16000101 | execute shell command failed.|
+| 16000151 | Invalid wantagent object.|
+| 16000152 | wantAgent object not found.|
+| 16000153 | wangAgent object canceled.|
+
+**Example**
+
+```ts
+// WantAgent object
+let wantAgent;
+// WantAgentInfo object
+let wantAgentInfo = {
+ wants: [
+ {
+ deviceId: 'deviceId',
+ bundleName: 'com.example.myapplication',
+ abilityName: 'EntryAbility',
+ action: 'action1',
+ entities: ['entity1'],
+ type: 'MIMETYPE',
+ uri: 'key={true,true,false}',
+ parameters:
+ {
+ mykey0: 2222,
+ mykey1: [1, 2, 3],
+ mykey2: '[1, 2, 3]',
+ mykey3: 'ssssssssssssssssssssssssss',
+ mykey4: [false, true, false],
+ mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
+ mykey6: true,
+ }
+ }
+ ],
+ operationType: WantAgent.OperationType.START_ABILITIES,
+ requestCode: 0,
+ wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
+}
+
+// getWantAgent callback
+function getWantAgentCallback(err, data) {
+ if (err === undefined) {
+ wantAgent = data;
+ } else {
+ console.info('getWantAgent failed!' + JSON.stringify(wantAgent));
+ }
+ try {
+ WantAgent.cancel(wantAgent).then((data)=>{
+ console.info('cancel ok!');
+ }).catch((err)=>{
+ console.info('cancel failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ })
+ } catch(err){
+ console.info('cancel failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ }
+}
+try {
+ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
+} catch(err) {
+ console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+}
+```
+
+## WantAgent.trigger
+
+trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback\): void
+
+Triggers a **WantAgent** object. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ----------------------------- | ---- | ------------------------------- |
+| agent | WantAgent | Yes | Target **WantAgent** object. |
+| triggerInfo | [TriggerInfo](js-apis-inner-wantAgent-triggerInfo.md) | Yes | **TriggerInfo** object. |
+| callback | AsyncCallback\<[CompleteData](#completedata)\> | No | Callback used to return the result.|
+
+**Error codes**
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+| ID | Error Message |
+|-----------|--------------------|
+| 16000001 | Input error. The specified ability name does not exist. |
+| 16000002 | Ability type error. The specified ability type is wrong.|
+| 16000003 | Input error. The specified id does not exist.|
+| 16000004 | Visibility verification failed.|
+| 16000006 | Can not cross user operations.|
+| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
+| 16000008 | Crowdtest App Expiration.|
+| 16000009 | Can not start ability in wukong mode.|
+| 16000010 | Can not operation with continue flag.|
+| 16000011 | Context does not exist.|
+| 16000050 | Internal Error.|
+| 16000051 | Network error. The network is abnormal.|
+| 16000052 | Free install not support. The application does not support free install.|
+| 16000053 | Not top ability. The application is not top ability.|
+| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
+| 16000055 | Free install timeout.|
+| 16000056 | Can not free install other ability.|
+| 16000057 | Not support cross device free install.|
+| 16000101 | execute shell command failed.|
+| 16000151 | Invalid wantagent object.|
+| 16000152 | wantAgent object not found.|
+| 16000153 | wangAgent object canceled.|
+
+**Example**
+
+```ts
+// WantAgent object
+let wantAgent;
+// triggerInfo
+let triggerInfo = {
+ code: 0 // Custom result code.
+ }
+// WantAgentInfo object
+let wantAgentInfo = {
+ wants: [
+ {
+ deviceId: 'deviceId',
+ bundleName: 'com.example.myapplication',
+ abilityName: 'EntryAbility',
+ action: 'action1',
+ entities: ['entity1'],
+ type: 'MIMETYPE',
+ uri: 'key={true,true,false}',
+ parameters:
+ {
+ mykey0: 2222,
+ mykey1: [1, 2, 3],
+ mykey2: '[1, 2, 3]',
+ mykey3: 'ssssssssssssssssssssssssss',
+ mykey4: [false, true, false],
+ mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
+ mykey6: true,
+ }
+ }
+ ],
+ operationType: WantAgent.OperationType.START_ABILITIES,
+ requestCode: 0,
+ wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
+}
+
+// getWantAgent callback
+function getWantAgentCallback(err, data) {
+ if (err === undefined) {
+ wantAgent = data;
+ } else {
+ console.info('getWantAgent failed' + JSON.stringify(wantAgent));
+ }
+ // getUid callback
+ function triggerCallback(err, data) {
+ if(err) {
+ console.info('getUid failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ } else {
+ console.info('getUid ok!' + JSON.stringify(data));
+ }
+ }
+ try {
+ WantAgent.trigger(wantAgent, triggerInfo, triggerCallback);
+ } catch(err) {
+ console.info('getUid failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ }
+}
+try {
+ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
+} catch(err) {
+ console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+}
+```
+
+
+
+## WantAgent.equal
+
+equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback\): void
+
+Checks whether two **WantAgent** objects are equal to determine whether the same operation is from the same application. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ---------- | ------------------------ | ---- | --------------------------------------- |
+| agent | WantAgent | Yes | The first **WantAgent** object. |
+| otherAgent | WantAgent | Yes | The second **WantAgent** object. |
+| callback | AsyncCallback\ | Yes | Callback used to return the result.|
+
+**Error codes**
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+| ID | Error Message |
+|-----------|--------------------|
+| 16000001 | Input error. The specified ability name does not exist. |
+| 16000002 | Ability type error. The specified ability type is wrong.|
+| 16000003 | Input error. The specified id does not exist.|
+| 16000004 | Visibility verification failed.|
+| 16000006 | Can not cross user operations.|
+| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
+| 16000008 | Crowdtest App Expiration.|
+| 16000009 | Can not start ability in wukong mode.|
+| 16000010 | Can not operation with continue flag.|
+| 16000011 | Context does not exist.|
+| 16000050 | Internal Error.|
+| 16000051 | Network error. The network is abnormal.|
+| 16000052 | Free install not support. The application does not support free install.|
+| 16000053 | Not top ability. The application is not top ability.|
+| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
+| 16000055 | Free install timeout.|
+| 16000056 | Can not free install other ability.|
+| 16000057 | Not support cross device free install.|
+| 16000101 | execute shell command failed.|
+| 16000151 | Invalid wantagent object.|
+| 16000152 | wantAgent object not found.|
+| 16000153 | wangAgent object canceled.|
+
+**Example**
+
+```ts
+// WantAgent object
+let wantAgent1;
+let wantAgent2;
+// WantAgentInfo object
+let wantAgentInfo = {
+ wants: [
+ {
+ deviceId: 'deviceId',
+ bundleName: 'com.example.myapplication',
+ abilityName: 'EntryAbility',
+ action: 'action1',
+ entities: ['entity1'],
+ type: 'MIMETYPE',
+ uri: 'key={true,true,false}',
+ parameters:
+ {
+ mykey0: 2222,
+ mykey1: [1, 2, 3],
+ mykey2: '[1, 2, 3]',
+ mykey3: 'ssssssssssssssssssssssssss',
+ mykey4: [false, true, false],
+ mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
+ mykey6: true,
+ }
+ }
+ ],
+ operationType: WantAgent.OperationType.START_ABILITIES,
+ requestCode: 0,
+ wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
+}
+
+// getWantAgent callback
+function getWantAgentCallback(err, data) {
+ if (err === undefined) {
+ wantAgent1 = data;
+ wantAgent2 = data;
+ } else {
+ console.info('getWantAgent failed' + JSON.stringify(wantAgent));
+ }
+ // getUid callback
+ function equalCallback(err, data) {
+ if(err) {
+ console.info('equal failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ } else {
+ console.info('equal ok!' + JSON.stringify(data));
+ }
+ }
+ try {
+ WantAgent.equal(wantAgent1,wantAgent2,equalCallback);
+ } catch(err) {
+ console.info('equal failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ }
+}
+try {
+ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
+} catch(err) {
+ console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+}
+```
+
+
+
+## WantAgent.equal
+
+equal(agent: WantAgent, otherAgent: WantAgent): Promise\
+
+Checks whether two **WantAgent** objects are equal to determine whether the same operation is from the same application. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ---------- | --------- | ---- | ------------- |
+| agent | WantAgent | Yes | The first **WantAgent** object.|
+| otherAgent | WantAgent | Yes | The second **WantAgent** object.|
+
+**Return value**
+
+| Type | Description |
+| ----------------------------------------------------------- | ------------------------------------------------------------ |
+| Promise\ | Promise used to return the result.|
+
+**Error codes**
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+| ID | Error Message |
+|-----------|--------------------|
+| 16000001 | Input error. The specified ability name does not exist. |
+| 16000002 | Ability type error. The specified ability type is wrong.|
+| 16000003 | Input error. The specified id does not exist.|
+| 16000004 | Visibility verification failed.|
+| 16000006 | Can not cross user operations.|
+| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
+| 16000008 | Crowdtest App Expiration.|
+| 16000009 | Can not start ability in wukong mode.|
+| 16000010 | Can not operation with continue flag.|
+| 16000011 | Context does not exist.|
+| 16000050 | Internal Error.|
+| 16000051 | Network error. The network is abnormal.|
+| 16000052 | Free install not support. The application does not support free install.|
+| 16000053 | Not top ability. The application is not top ability.|
+| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
+| 16000055 | Free install timeout.|
+| 16000056 | Can not free install other ability.|
+| 16000057 | Not support cross device free install.|
+| 16000101 | execute shell command failed.|
+| 16000151 | Invalid wantagent object.|
+| 16000152 | wantAgent object not found.|
+| 16000153 | wangAgent object canceled.|
+
+**Example**
+
+```ts
+// WantAgent object
+let wantAgent1;
+let wantAgent2;
+// WantAgentInfo object
+let wantAgentInfo = {
+ wants: [
+ {
+ deviceId: 'deviceId',
+ bundleName: 'com.example.myapplication',
+ abilityName: 'EntryAbility',
+ action: 'action1',
+ entities: ['entity1'],
+ type: 'MIMETYPE',
+ uri: 'key={true,true,false}',
+ parameters:
+ {
+ mykey0: 2222,
+ mykey1: [1, 2, 3],
+ mykey2: '[1, 2, 3]',
+ mykey3: 'ssssssssssssssssssssssssss',
+ mykey4: [false, true, false],
+ mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
+ mykey6: true,
+ }
+ }
+ ],
+ operationType: WantAgent.OperationType.START_ABILITIES,
+ requestCode: 0,
+ wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
+}
+
+// getWantAgent callback
+function getWantAgentCallback(err, data) {
+ if (err === undefined) {
+ wantAgent1 = data;
+ wantAgent2 = data;
+ } else {
+ console.info('getWantAgent failed!' + JSON.stringify(wantAgent));
+ }
+ try {
+ WantAgent.equal(wantAgent1,wantAgent2).then((data)=>{
+ console.info('equal ok!' + JSON.stringify(data));
+ }).catch((err)=>{
+ console.info('equal failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ })
+ } catch(err){
+ console.info('equal failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ }
+}
+try {
+ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
+} catch(err) {
+ console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+}
+```
+
+## WantAgent.getOperationType
+
+getOperationType(agent: WantAgent, callback: AsyncCallback\): void;
+
+Obtains the operation type of a **WantAgent** object. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ---------- | ------------------------ | ---- | --------------------------------------- |
+| agent | WantAgent | Yes | Target **WantAgent** object. |
+| callback | AsyncCallback\ | Yes | Callback used to return the operation type.|
+
+**Error codes**
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+| ID | Error Message |
+|-----------|--------------------|
+| 16000001 | Input error. The specified ability name does not exist. |
+| 16000002 | Ability type error. The specified ability type is wrong.|
+| 16000003 | Input error. The specified id does not exist.|
+| 16000004 | Visibility verification failed.|
+| 16000006 | Can not cross user operations.|
+| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
+| 16000008 | Crowdtest App Expiration.|
+| 16000009 | Can not start ability in wukong mode.|
+| 16000010 | Can not operation with continue flag.|
+| 16000011 | Context does not exist.|
+| 16000050 | Internal Error.|
+| 16000051 | Network error. The network is abnormal.|
+| 16000052 | Free install not support. The application does not support free install.|
+| 16000053 | Not top ability. The application is not top ability.|
+| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
+| 16000055 | Free install timeout.|
+| 16000056 | Can not free install other ability.|
+| 16000057 | Not support cross device free install.|
+| 16000101 | execute shell command failed.|
+| 16000151 | Invalid wantagent object.|
+| 16000152 | wantAgent object not found.|
+| 16000153 | wangAgent object canceled.|
+
+**Example**
+
+```ts
+// WantAgent object
+let wantAgent;
+// WantAgentInfo object
+let wantAgentInfo = {
+ wants: [
+ {
+ deviceId: 'deviceId',
+ bundleName: 'com.example.myapplication',
+ abilityName: 'EntryAbility',
+ action: 'action1',
+ entities: ['entity1'],
+ type: 'MIMETYPE',
+ uri: 'key={true,true,false}',
+ parameters:
+ {
+ mykey0: 2222,
+ mykey1: [1, 2, 3],
+ mykey2: '[1, 2, 3]',
+ mykey3: 'ssssssssssssssssssssssssss',
+ mykey4: [false, true, false],
+ mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
+ mykey6: true,
+ }
+ }
+ ],
+ operationType: WantAgent.OperationType.START_ABILITIES,
+ requestCode: 0,
+ wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
+}
+
+// getWantAgent callback
+function getWantAgentCallback(err, data) {
+ if (err === undefined) {
+ wantAgent = data;
+ } else {
+ console.info('getWantAgent failed' + JSON.stringify(wantAgent));
+ }
+ // getUid callback
+ function getOperationTypeCallback(err, data) {
+ if(err) {
+ console.info('getOperationType failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ } else {
+ console.info('getOperationType ok!' + JSON.stringify(data));
+ }
+ }
+ try {
+ WantAgent.getOperationTypeCallback(wantAgent, getBundleNameCallback);
+ } catch(err) {
+ console.info('getOperationTypeCallback failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ }
+}
+try {
+ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
+} catch(err) {
+ console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+}
+```
+
+## WantAgent.getOperationType
+
+getOperationType(agent: WantAgent): Promise\;
+
+Obtains the operation type of a **WantAgent** object. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ---------- | --------- | ---- | ------------- |
+| agent | WantAgent | Yes | Target **WantAgent** object.|
+
+**Return value**
+
+| Type | Description |
+| ----------------------------------------------------------- | ------------------------------------------------------------ |
+| Promise\ | Promise used to return the operation type.|
+
+**Error codes**
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+| ID | Error Message |
+|-----------|--------------------|
+| 16000001 | Input error. The specified ability name does not exist. |
+| 16000002 | Ability type error. The specified ability type is wrong.|
+| 16000003 | Input error. The specified id does not exist.|
+| 16000004 | Visibility verification failed.|
+| 16000006 | Can not cross user operations.|
+| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
+| 16000008 | Crowdtest App Expiration.|
+| 16000009 | Can not start ability in wukong mode.|
+| 16000010 | Can not operation with continue flag.|
+| 16000011 | Context does not exist.|
+| 16000050 | Internal Error.|
+| 16000051 | Network error. The network is abnormal.|
+| 16000052 | Free install not support. The application does not support free install.|
+| 16000053 | Not top ability. The application is not top ability.|
+| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
+| 16000055 | Free install timeout.|
+| 16000056 | Can not free install other ability.|
+| 16000057 | Not support cross device free install.|
+| 16000101 | execute shell command failed.|
+| 16000151 | Invalid wantagent object.|
+| 16000152 | wantAgent object not found.|
+| 16000153 | wangAgent object canceled.|
+
+**Example**
+
+```ts
+// WantAgent object
+let wantAgent;
+// WantAgentInfo object
+let wantAgentInfo = {
+ wants: [
+ {
+ deviceId: 'deviceId',
+ bundleName: 'com.example.myapplication',
+ abilityName: 'EntryAbility',
+ action: 'action1',
+ entities: ['entity1'],
+ type: 'MIMETYPE',
+ uri: 'key={true,true,false}',
+ parameters:
+ {
+ mykey0: 2222,
+ mykey1: [1, 2, 3],
+ mykey2: '[1, 2, 3]',
+ mykey3: 'ssssssssssssssssssssssssss',
+ mykey4: [false, true, false],
+ mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
+ mykey6: true,
+ }
+ }
+ ],
+ operationType: WantAgent.OperationType.START_ABILITIES,
+ requestCode: 0,
+ wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
+}
+
+// getWantAgent callback
+function getWantAgentCallback(err, data) {
+ if (err === undefined) {
+ wantAgent = data;
+ } else {
+ console.info('getWantAgent failed!' + JSON.stringify(wantAgent));
+ }
+ try {
+ WantAgent.getOperationType(wantAgent).then((data)=>{
+ console.info('getOperationType ok!' + JSON.stringify(data));
+ }).catch((err)=>{
+ console.info('getOperationType failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ })
+ } catch(err){
+ console.info('getOperationType failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ }
+}
+try {
+ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
+} catch(err) {
+ console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+}
+```
+
+## WantAgentFlags
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name | Value | Description |
+| ------------------- | -------------- | ------------------------------------------------------------ |
+| ONE_TIME_FLAG | 0 | The **WantAgent** object can be used only once. |
+| NO_BUILD_FLAG | 1 | The **WantAgent** object does not exist and hence it is not created. In this case, **null** is returned. |
+| CANCEL_PRESENT_FLAG | 2 | The existing **WantAgent** object should be canceled before a new object is generated.|
+| UPDATE_PRESENT_FLAG | 3 | Extra information of the existing **WantAgent** object is replaced with that of the new object.|
+| CONSTANT_FLAG | 4 | The **WantAgent** object is immutable. |
+| REPLACE_ELEMENT | 5 | The **element** attribute of the current **Want** can be replaced by the **element** attribute of the **Want** in **WantAgent.trigger()**.|
+| REPLACE_ACTION | 6 | The **action** attribute of the current **Want** can be replaced by the **action** attribute of the **Want** in **WantAgent.trigger()**.|
+| REPLACE_URI | 7 | The **uri** attribute of the current **Want** can be replaced by the **uri** attribute of the **Want** in **WantAgent.trigger()**.|
+| REPLACE_ENTITIES | 8 | The **entities** attribute of the current **Want** can be replaced by the **entities** attribute of the **Want** in **WantAgent.trigger()**.|
+| REPLACE_BUNDLE | 9 | The **bundleName** attribute of the current **Want** can be replaced by the **bundleName** attribute of **Want** in **WantAgent.trigger()**.|
+
+
+
+## OperationType
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name | Value | Description |
+| ----------------- | ------------- | ------------------------- |
+| UNKNOWN_TYPE | 0 | Unknown operation type. |
+| START_ABILITY | 1 | Starts an ability with a UI.|
+| START_ABILITIES | 2 | Starts multiple abilities with a UI.|
+| START_SERVICE | 3 | Starts an ability without a UI.|
+| SEND_COMMON_EVENT | 4 | Sends a common event. |
+
+
+
+## CompleteData
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name | Type | Mandatory| Description |
+| -------------- | ------------------------------ | ---- | ---------------------- |
+| info | WantAgent | Yes | A triggered **WantAgent** object. |
+| want | Want | Yes | An existing triggered **want**. |
+| finalCode | number | Yes | Request code that triggers the **WantAgent** object.|
+| finalData | string | No | Final data collected by the common event. |
+| extraInfo | {[key: string]: any} | No | Extra information. |
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-wantConstant.md b/en/application-dev/reference/apis/js-apis-app-ability-wantConstant.md
new file mode 100644
index 0000000000000000000000000000000000000000..4d7a483eab8a55c91d4dbb89287fa611f980ef34
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-ability-wantConstant.md
@@ -0,0 +1,82 @@
+# @ohos.app.ability.wantConstant (wantConstant)
+
+The **wantConstant** module provides the actions, entities, and flags used in **Want** objects.
+
+> **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.
+
+## Modules to Import
+
+```js
+import wantConstant from '@ohos.app.ability.wantConstant';
+```
+
+## wantConstant.Action
+
+Enumerates the action constants of the **Want** object. **action** specifies the operation to execute.
+
+**System capability**: SystemCapability.Ability.AbilityBase
+
+| Name | Value | Description |
+| ------------ | ------------------ | ---------------------- |
+| ACTION_HOME | ohos.want.action.home | Action of returning to the home page. |
+| ACTION_DIAL | ohos.want.action.dial | Action of launching the numeric keypad. |
+| ACTION_SEARCH | ohos.want.action.search | Action of launching the search function. |
+| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | Action of launching the UI that provides wireless network settings, for example, Wi-Fi options. |
+| ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | Action of launching the UI for managing installed applications. |
+| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | Action of launching the UI that displays the details of an application. |
+| ACTION_SET_ALARM | ohos.want.action.setAlarm | Action of launching the UI for setting the alarm clock. |
+| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | Action of launching the UI that displays all alarms. |
+| ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | Action of launching the UI for snoozing an alarm. |
+| ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | Action of launching the UI for deleting an alarm. |
+| ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | Action of launching the UI for dismissing a timer. |
+| ACTION_SEND_SMS | ohos.want.action.sendSms | Action of launching the UI for sending an SMS message. |
+| ACTION_CHOOSE | ohos.want.action.choose | Action of launching the UI for opening a contact or picture. |
+| ACTION_IMAGE_CAPTURE | ohos.want.action.imageCapture | Action of launching the UI for photographing. |
+| ACTION_VIDEO_CAPTURE | ohos.want.action.videoCapture | Action of launching the UI for shooting a video. |
+| ACTION_SELECT | ohos.want.action.select | Action of launching the UI for application selection. |
+| ACTION_SEND_DATA | ohos.want.action.sendData | Action of launching the UI for sending a single data record. |
+| ACTION_SEND_MULTIPLE_DATA | ohos.want.action.sendMultipleData | Action of launching the UI for sending multiple data records. |
+| ACTION_SCAN_MEDIA_FILE | ohos.want.action.scanMediaFile | Action of requesting a media scanner to scan a file and add the file to the media library. |
+| ACTION_VIEW_DATA | ohos.want.action.viewData | Action of viewing data. |
+| ACTION_EDIT_DATA | ohos.want.action.editData | Action of editing data. |
+| INTENT_PARAMS_INTENT | ability.want.params.INTENT | Action of displaying selection options with an action selector. |
+| INTENT_PARAMS_TITLE | ability.want.params.TITLE | Title of the character sequence dialog box used with the action selector. |
+| ACTION_FILE_SELECT | ohos.action.fileSelect | Action of selecting a file. |
+| PARAMS_STREAM | ability.params.stream | URI of the data stream associated with the target when the data is sent. |
+| ACTION_APP_ACCOUNT_AUTH | account.appAccount.action.auth | Action of providing the authentication service. |
+| ACTION_MARKET_DOWNLOAD | ohos.want.action.marketDownload | Action of downloading an application from the application market.
**System API**: This is a system API and cannot be called by third-party applications. |
+| ACTION_MARKET_CROWDTEST | ohos.want.action.marketCrowdTest | Action of crowdtesting an application from the application market.
**System API**: This is a system API and cannot be called by third-party applications. |
+| DLP_PARAMS_SANDBOX |ohos.dlp.params.sandbox | Action of obtaining the sandbox flag.
**System API**: This is a system API and cannot be called by third-party applications. |
+| DLP_PARAMS_BUNDLE_NAME |ohos.dlp.params.bundleName |Action of obtaining the DLP bundle name.
**System API**: This is a system API and cannot be called by third-party applications. |
+| DLP_PARAMS_MODULE_NAME |ohos.dlp.params.moduleName |Action of obtaining the DLP module name.
**System API**: This is a system API and cannot be called by third-party applications. |
+| DLP_PARAMS_ABILITY_NAME |ohos.dlp.params.abilityName |Action of obtaining the DLP ability name.
**System API**: This is a system API and cannot be called by third-party applications. |
+| DLP_PARAMS_INDEX |ohos.dlp.params.index |Action of obtaining the DLP index.
**System API**: This is a system API and cannot be called by third-party applications. |
+
+## wantConstant.Entity
+
+Enumerates the entity constants of the **Want** object. **entity** specifies additional information of the target ability.
+
+**System capability**: SystemCapability.Ability.AbilityBase
+
+| Name | Value | Description |
+| ------------ | ------------------ | ---------------------- |
+| ENTITY_DEFAULT | entity.system.default | Default entity. The default entity is used if no entity is specified. |
+| ENTITY_HOME | entity.system.home | Home screen entity. |
+| ENTITY_VOICE | entity.system.voice | Voice interaction entity. |
+| ENTITY_BROWSABLE | entity.system.browsable | Browser type entity. |
+| ENTITY_VIDEO | entity.system.video | Video type entity. |
+
+
+## wantConstant.Flags
+
+ Enumerates the flags that specify how the Want will be handled.
+
+**System capability**: SystemCapability.Ability.AbilityBase
+
+| Name | Value | Description |
+| ------------------------------------ | ---------- | ------------------------------------------------------------ |
+| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. |
+| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write data to the URI. |
+| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. |
diff --git a/en/application-dev/reference/apis/js-apis-app-form-formBindingData.md b/en/application-dev/reference/apis/js-apis-app-form-formBindingData.md
new file mode 100644
index 0000000000000000000000000000000000000000..51637975d72ea807f428f235aec90310f69b197f
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-form-formBindingData.md
@@ -0,0 +1,64 @@
+# @ohos.application.formBindingData (formBindingData)
+
+The **FormBindingData** module provides APIs for widget data binding. You can use the APIs to create a **FormBindingData** object and obtain related information.
+
+> **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.
+
+## Modules to Import
+
+```ts
+import formBindingData from '@ohos.app.form.formBindingData';
+```
+
+## FormBindingData
+
+Describes a **FormBindingData** object.
+
+**System capability**: SystemCapability.Ability.Form
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| data | Object | Yes| Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format.|
+
+
+## createFormBindingData
+
+createFormBindingData(obj?: Object | string): FormBindingData
+
+Creates a **FormBindingData** object.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | -------------- | ---- | ------------------------------------------------------------ |
+| obj | Object\|string | No | Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by "formImages", and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {"formImages": {"key1": fd1, "key2": fd2}}.|
+
+
+**Return value**
+
+| Type | Description |
+| ----------------------------------- | --------------------------------------- |
+| [FormBindingData](#formbindingdata) | **FormBindingData** object created based on the passed data.|
+
+
+**Example**
+
+```ts
+import fs from '@ohos.file.fs';
+import formBindingData from '@ohos.app.form.formBindingData';
+
+try {
+ let fd = fs.openSync('/path/to/form.png')
+ let obj = {
+ "temperature": "21°",
+ "formImages": { "image": fd }
+ };
+ formBindingData.createFormBindingData(obj);
+} catch (error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
diff --git a/en/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md b/en/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md
new file mode 100644
index 0000000000000000000000000000000000000000..ef4e93e215b868013f025722737472735a1016f7
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md
@@ -0,0 +1,311 @@
+# @ohos.app.form.FormExtensionAbility (FormExtensionAbility)
+
+The **FormExtensionAbility** module provides lifecycle callbacks invoked when a widget is created, destroyed, or updated.
+
+> **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 can be used only in the stage model.
+
+## Modules to Import
+
+```ts
+import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
+```
+
+## Attributes
+
+**System capability**: SystemCapability.Ability.Form
+
+| Name | Type | Readable| Writable| Description |
+| ------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ |
+| context | [FormExtensionContext](js-apis-inner-application-formExtensionContext.md) | Yes | No | Context of the FormExtensionAbility. This context is inherited from [ExtensionContext](js-apis-inner-application-extensionContext.md).|
+
+## onAddForm
+
+onAddForm(want: Want): formBindingData.FormBindingData
+
+Called to notify the widget provider that a **Form** instance (widget) has been created.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | -------------------------------------- | ---- | ------------------------------------------------------------ |
+| want | [Want](js-apis-application-want.md) | Yes | Want information related to the FormExtensionAbility, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------------------------------------------ | ----------------------------------------------------------- |
+| [formBindingData.FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | A **formBindingData.FormBindingData** object containing the data to be displayed on the widget.|
+
+**Example**
+
+```ts
+import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
+import formBindingData from '@ohos.app.form.formBindingData';
+
+export default class MyFormExtensionAbility extends FormExtensionAbility {
+ onAddForm(want) {
+ console.log('FormExtensionAbility onAddForm, want:' + want.abilityName);
+ let dataObj1 = {
+ temperature: "11c",
+ "time": "11:00"
+ };
+ let obj1 = formBindingData.createFormBindingData(dataObj1);
+ return obj1;
+ }
+};
+```
+
+## onCastToNormalForm
+
+onCastToNormalForm(formId: string): void
+
+Called to notify the widget provider that a temporary widget has been converted to a normal one.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------------------------ |
+| formId | string | Yes | ID of the widget that requests to be converted to a normal one.|
+
+**Example**
+
+```ts
+import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
+
+export default class MyFormExtensionAbility extends FormExtensionAbility {
+ onCastToNormalForm(formId) {
+ console.log('FormExtensionAbility onCastToNormalForm, formId:' + formId);
+ }
+};
+```
+
+## onUpdateForm
+
+onUpdateForm(formId: string): void
+
+Called to notify the widget provider that a widget has been updated. After obtaining the latest data, your application should call [updateForm](js-apis-app-form-formProvider.md#updateform) of **formProvider** to update the widget data.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------------------ |
+| formId | string | Yes | ID of the widget that requests to be updated.|
+
+**Example**
+
+```ts
+import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
+import formBindingData from '@ohos.app.form.formBindingData';
+import formProvider from '@ohos.app.form.formProvider';
+
+export default class MyFormExtensionAbility extends FormExtensionAbility {
+ onUpdateForm(formId) {
+ console.log('FormExtensionAbility onUpdateForm, formId:' + formId);
+ let obj2 = formBindingData.createFormBindingData({
+ temperature: "22c",
+ time: "22:00"
+ });
+ formProvider.updateForm(formId, obj2).then((data) => {
+ console.log('FormExtensionAbility context updateForm, data:' + data);
+ }).catch((error) => {
+ console.error('Operation updateForm failed. Cause: ' + error);
+ });
+ }
+};
+```
+
+## onChangeFormVisibility
+
+onChangeFormVisibility(newStatus: { [key: string]: number }): void
+
+Called to notify the widget provider of the change of visibility.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| --------- | ------------------------- | ---- | ---------------------------- |
+| newStatus | { [key: string]: number } | Yes | ID and visibility status of the widget to be changed.|
+
+**Example**
+
+```ts
+import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
+import formBindingData from '@ohos.app.form.formBindingData'
+import formProvider from '@ohos.app.form.formProvider';
+
+export default class MyFormExtensionAbility extends FormExtensionAbility {
+ onChangeFormVisibility(newStatus) {
+ console.log('FormExtensionAbility onChangeFormVisibility, newStatus:' + newStatus);
+ let obj2 = formBindingData.createFormBindingData({
+ temperature: "22c",
+ time: "22:00"
+ });
+
+ for (let key in newStatus) {
+ console.log('FormExtensionAbility onChangeFormVisibility, key:' + key + ", value=" + newStatus[key]);
+ formProvider.updateForm(key, obj2).then((data) => {
+ console.log('FormExtensionAbility context updateForm, data:' + data);
+ }).catch((error) => {
+ console.error('Operation updateForm failed. Cause: ' + error);
+ });
+ }
+ }
+};
+```
+
+## onFormEvent
+
+onFormEvent(formId: string, message: string): void
+
+Called to instruct the widget provider to receive and process the widget event.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------- | ------ | ---- | ---------------------- |
+| formId | string | Yes | ID of the widget that requests the event.|
+| message | string | Yes | Event message. |
+
+**Example**
+
+```ts
+import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
+
+export default class MyFormExtensionAbility extends FormExtensionAbility {
+ onFormEvent(formId, message) {
+ console.log('FormExtensionAbility onFormEvent, formId:' + formId + ", message:" + message);
+ }
+};
+```
+
+## onRemoveForm
+
+onRemoveForm(formId: string): void
+
+Called to notify the widget provider that a **Form** instance (widget) has been destroyed.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------------------ |
+| formId | string | Yes | ID of the widget to be destroyed.|
+
+**Example**
+
+```ts
+import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
+
+export default class MyFormExtensionAbility extends FormExtensionAbility {
+ onRemoveForm(formId) {
+ console.log('FormExtensionAbility onRemoveForm, formId:' + formId);
+ }
+};
+```
+
+## onConfigurationUpdate
+
+onConfigurationUpdate(newConfig: Configuration): void;
+
+Called when the configuration of the environment where the ability is running is updated.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| newConfig | [Configuration](js-apis-application-configuration.md) | Yes| New configuration.|
+
+**Example**
+
+```ts
+import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
+
+export default class MyFormExtensionAbility extends FormExtensionAbility {
+ onConfigurationUpdate(config) {
+ console.log('onConfigurationUpdate, config:' + JSON.stringify(config));
+ }
+};
+```
+
+## onAcquireFormState
+
+onAcquireFormState?(want: Want): formInfo.FormState;
+
+Called when the widget provider receives the status query result of a widget. By default, the initial state is returned.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| want | [Want](js-apis-application-want.md) | Yes| Description of the widget state, including the bundle name, ability name, module name, widget name, and widget dimension.|
+
+**Example**
+
+```ts
+import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
+import formInfo from '@ohos.app.form.formInfo';
+
+export default class MyFormExtensionAbility extends FormExtensionAbility {
+ onAcquireFormState(want) {
+ console.log('FormExtensionAbility onAcquireFormState, want:' + want);
+ return formInfo.FormState.UNKNOWN;
+ }
+};
+```
+
+## onShareForm
+
+onShareForm?(formId: string): { [key: string]: any }
+
+Called by the widget provider to receive shared widget data.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| formId | string | Yes | Widget ID.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------------------------------------------ | ----------------------------------------------------------- |
+| {[key: string]: any} | Data to be shared by the widget, in the form of key-value pairs.|
+
+**Example**
+
+```ts
+import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
+
+export default class MyFormExtensionAbility extends FormExtensionAbility {
+ onShareForm(formId) {
+ console.log('FormExtensionAbility onShareForm, formId:' + formId);
+ let wantParams = {
+ "temperature": "20",
+ "time": "2022-8-8 09:59",
+ };
+ return wantParams;
+ }
+};
+```
diff --git a/en/application-dev/reference/apis/js-apis-app-form-formHost.md b/en/application-dev/reference/apis/js-apis-app-form-formHost.md
new file mode 100644
index 0000000000000000000000000000000000000000..e78cf3647a1298ed77b4993d811393ede4e2e5b6
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-form-formHost.md
@@ -0,0 +1,1603 @@
+# @ohos.app.form.formHost (formHost)
+
+The **formHost** module provides APIs related to the widget host, which is an application that displays the widget content and controls the position where the widget is displayed. You can use the APIs to delete, release, and update widgets installed by the same user, and obtain widget information and status.
+
+> **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.
+
+## Modules to Import
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+```
+
+## deleteForm
+
+deleteForm(formId: string, callback: AsyncCallback<void>): void
+
+Deletes a widget. After this API is called, the application can no longer use the widget, and the Widget Manager will not retain the widget information. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formId | string | Yes | Widget ID.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the widget is deleted, **error** is undefined; otherwise, **error** is an error object.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ let formId = "12400633174999288";
+ formHost.deleteForm(formId, (error) => {
+ if (error) {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ } else {
+ console.log('formHost deleteForm success');
+ }
+ });
+} catch (error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## deleteForm
+
+deleteForm(formId: string): Promise<void>
+
+Deletes a widget. After this API is called, the application can no longer use the widget, and the Widget Manager will not retain the widget information. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formId | string | Yes | Widget ID.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise that returns no value.|
+
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Parameters**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ let formId = "12400633174999288";
+ formHost.deleteForm(formId).then(() => {
+ console.log('formHost deleteForm success');
+ }).catch((error) => {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## releaseForm
+
+releaseForm(formId: string, callback: AsyncCallback<void>): void
+
+Releases a widget. After this API is called, the application can no longer use the widget, but the Widget Manager still retains the widget cache and storage information. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formId | string | Yes | Widget ID.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the widget is released, **error** is undefined; otherwise, **error** is an error object.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ let formId = "12400633174999288";
+ formHost.releaseForm(formId, (error) => {
+ if (error) {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ }
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## releaseForm
+
+releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<void>): void
+
+Releases a widget. After this API is called, the application can no longer use the widget, but the Widget Manager retains the storage information about the widget and retains or releases the cache information based on the setting. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------------- | ------ | ---- | ----------- |
+| formId | string | Yes | Widget ID. |
+| isReleaseCache | boolean | Yes | Whether to release the cache.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the widget is released, **error** is undefined; otherwise, **error** is an error object.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ let formId = "12400633174999288";
+ formHost.releaseForm(formId, true, (error) => {
+ if (error) {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ }
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## releaseForm
+
+releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>
+
+Releases a widget. After this API is called, the application can no longer use the widget, but the Widget Manager retains the storage information about the widget and retains or releases the cache information based on the setting. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------------- | ------ | ---- | ----------- |
+| formId | string | Yes | Widget ID. |
+| isReleaseCache | boolean | No | Whether to release the cache.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ let formId = "12400633174999288";
+ formHost.releaseForm(formId, true).then(() => {
+ console.log('formHost releaseForm success');
+ }).catch((error) => {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## requestForm
+
+requestForm(formId: string, callback: AsyncCallback<void>): void
+
+Requests a widget update. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formId | string | Yes | Widget ID.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the widget is updated, **error** is undefined; otherwise, **error** is an error object.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ let formId = "12400633174999288";
+ formHost.requestForm(formId, (error) => {
+ if (error) {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ }
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## requestForm
+
+requestForm(formId: string): Promise<void>
+
+Requests a widget update. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formId | string | Yes | Widget ID.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ let formId = "12400633174999288";
+ formHost.requestForm(formId).then(() => {
+ console.log('formHost requestForm success');
+ }).catch((error) => {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+
+```
+
+## castToNormalForm
+
+castToNormalForm(formId: string, callback: AsyncCallback<void>): void
+
+Converts a temporary widget to a normal one. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formId | string | Yes | Widget ID.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the widget is converted to a normal one, **error** is undefined; otherwise, **error** is an error object.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ let formId = "12400633174999288";
+ formHost.castToNormalForm(formId, (error) => {
+ if (error) {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ }
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## castToNormalForm
+
+castToNormalForm(formId: string): Promise<void>
+
+Converts a temporary widget to a normal one. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formId | string | Yes | Widget ID.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ let formId = "12400633174999288";
+ formHost.castToNormalForm(formId).then(() => {
+ console.log('formHost castTempForm success');
+ }).catch((error) => {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## notifyVisibleForms
+
+notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void
+
+Instructs the widget framework to make a widget visible. After this API is called, **onVisibilityChange** is invoked to notify the widget provider. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formIds | Array<string> | Yes | List of widget IDs. |
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. If a notification is sent to the widget framework to make the widget visible, **error** is undefined; otherwise, **error** is an error object.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ let formId = ["12400633174999288"];
+ formHost.notifyVisibleForms(formId, (error) => {
+ if (error) {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ }
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## notifyVisibleForms
+
+notifyVisibleForms(formIds: Array<string>): Promise<void>
+
+Instructs the widget framework to make a widget visible. After this API is called, **onVisibilityChange** is invoked to notify the widget provider. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formIds | Array<string> | Yes | List of widget IDs.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ let formId = ["12400633174999288"];
+ formHost.notifyVisibleForms(formId).then(() => {
+ console.log('formHost notifyVisibleForms success');
+ }).catch((error) => {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## notifyInvisibleForms
+
+notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<void>): void
+
+Instructs the widget framework to make a widget invisible. After this API is called, **onVisibilityChange** is invoked to notify the widget provider. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formIds | Array<string> | Yes | List of widget IDs.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. If a notification is sent to the widget framework to make the widget invisible, **error** is undefined; otherwise, **error** is an error object.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ let formId = ["12400633174999288"];
+ formHost.notifyInvisibleForms(formId, (error) => {
+ if (error) {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ }
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## notifyInvisibleForms
+
+notifyInvisibleForms(formIds: Array<string>): Promise<void>
+
+Instructs the widget framework to make a widget invisible. After this API is called, **onVisibilityChange** is invoked to notify the widget provider. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formIds | Array<string> | Yes | List of widget IDs.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ let formId = ["12400633174999288"];
+ formHost.notifyInvisibleForms(formId).then(() => {
+ console.log('formHost notifyInvisibleForms success');
+ }).catch((error) => {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## enableFormsUpdate
+
+enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void
+
+Instructs the widget framework to make a widget updatable. After this API is called, the widget is in the enabled state and can receive updates from the widget provider. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formIds | Array<string> | Yes | List of widget IDs. |
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. If a notification is sent to the widget framework to make the widget updatable, **error** is undefined; otherwise, **error** is an error object.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ let formId = ["12400633174999288"];
+ formHost.enableFormsUpdate(formId, (error) => {
+ if (error) {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ }
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## enableFormsUpdate
+
+enableFormsUpdate(formIds: Array<string>): Promise<void>
+
+Instructs the widget framework to make a widget updatable. After this API is called, the widget is in the enabled state and can receive updates from the widget provider. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formIds | Array<string> | Yes | List of widget IDs.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ let formId = ["12400633174999288"];
+ formHost.enableFormsUpdate(formId).then(() => {
+ console.log('formHost enableFormsUpdate success');
+ }).catch((error) => {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## disableFormsUpdate
+
+disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void>): void
+
+Instructs the widget framework to make a widget not updatable. After this API is called, the widget cannot receive updates from the widget provider. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formIds | Array<string> | Yes | List of widget IDs. |
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. If a notification is sent to the widget framework to make the widget not updatable, **error** is undefined; otherwise, **error** is an error object.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ let formId = ["12400633174999288"];
+ formHost.disableFormsUpdate(formId, (error) => {
+ if (error) {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ }
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## disableFormsUpdate
+
+disableFormsUpdate(formIds: Array<string>): Promise<void>
+
+Instructs the widget framework to make a widget not updatable. After this API is called, the widget cannot receive updates from the widget provider. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formIds | Array<string> | Yes | List of widget IDs.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ let formId = ["12400633174999288"];
+ formHost.disableFormsUpdate(formId).then(() => {
+ console.log('formHost disableFormsUpdate success');
+ }).catch((error) => {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## isSystemReady
+
+isSystemReady(callback: AsyncCallback<void>): void
+
+Checks whether the system is ready. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the check is successful, **error** is undefined; otherwise, **error** is an error object.|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ formHost.isSystemReady((error, data) => {
+ if (error) {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ }
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## isSystemReady
+
+isSystemReady(): Promise<void>
+
+Checks whether the system is ready. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise that returns no value.|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ formHost.isSystemReady().then(() => {
+ console.log('formHost isSystemReady success');
+ }).catch((error) => {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## getAllFormsInfo
+
+getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void
+
+Obtains the widget information provided by all applications on the device. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ formHost.getAllFormsInfo((error, data) => {
+ if (error) {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ } else {
+ console.log('formHost getAllFormsInfo, data:' + JSON.stringify(data));
+ }
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## getAllFormsInfo
+
+getAllFormsInfo(): Promise<Array<formInfo.FormInfo>>
+
+Obtains the widget information provided by all applications on the device. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**: SystemCapability.Ability.Form
+
+**Return value**
+
+| Type | Description |
+| :----------------------------------------------------------- | :---------------------------------- |
+| Promise<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Promise used to return the information obtained.|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ formHost.getAllFormsInfo().then((data) => {
+ console.log('formHost getAllFormsInfo data:' + JSON.stringify(data));
+ }).catch((error) => {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## getFormsInfo
+
+getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void
+
+Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| bundleName | string | Yes| Bundle name of the application.|
+| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ formHost.getFormsInfo("com.example.ohos.formjsdemo", (error, data) => {
+ if (error) {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ } else {
+ console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
+ }
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## getFormsInfo
+
+getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void
+
+Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| bundleName | string | Yes| Bundle name of the application.|
+| moduleName | string | Yes| Module name.|
+| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry", (error, data) => {
+ if (error) {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ } else {
+ console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
+ }
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## getFormsInfo
+
+getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formInfo.FormInfo>>
+
+Obtains the widget information provided by a given application on the device. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| bundleName | string | Yes| Bundle name of the application.|
+| moduleName | string | No| Module name.|
+
+**Return value**
+
+| Type | Description |
+| :----------------------------------------------------------- | :---------------------------------- |
+| Promise<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Promise used to return the information obtained.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry").then((data) => {
+ console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
+ }).catch((error) => {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## deleteInvalidForms
+
+deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<number>): void
+
+Deletes invalid widgets from the list. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formIds | Array<string> | Yes | List of valid widget IDs.|
+| callback | AsyncCallback<number> | Yes| Callback used to return the result. If the invalid widgets are deleted, **error** is undefined and **data** is the number of widgets deleted; otherwise, **error** is an error object.|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ let formIds = new Array("12400633174999288", "12400633174999289");
+ formHost.deleteInvalidForms(formIds, (error, data) => {
+ if (error) {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ } else {
+ console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data));
+ }
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## deleteInvalidForms
+
+deleteInvalidForms(formIds: Array<string>): Promise<number>
+
+Deletes invalid widgets from the list. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formIds | Array<string> | Yes | List of valid widget IDs.|
+
+**Return value**
+
+| Type | Description |
+| :------------ | :---------------------------------- |
+| Promise<number> | Promise used to return the number of widgets deleted.|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+try {
+ let formIds = new Array("12400633174999288", "12400633174999289");
+ formHost.deleteInvalidForms(formIds).then((data) => {
+ console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data));
+ }).catch((error) => {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## acquireFormState
+
+acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo>): void
+
+Obtains the widget state. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| want | [Want](js-apis-application-want.md) | Yes | **Want** information carried to query the widget state. The information must contain the bundle name, ability name, module name, widget name, and widget dimensions.|
+| callback | AsyncCallback<[formInfo.FormStateInfo](js-apis-app-form-formInfo.md#formstateinfo)> | Yes| Callback used to return the result. If the widget state is obtained, **error** is undefined and **data** is the widget state obtained; otherwise, **error** is an error object.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+let want = {
+ "deviceId": "",
+ "bundleName": "ohos.samples.FormApplication",
+ "abilityName": "FormAbility",
+ "parameters": {
+ "ohos.extra.param.key.module_name": "entry",
+ "ohos.extra.param.key.form_name": "widget",
+ "ohos.extra.param.key.form_dimension": 2
+ }
+};
+try {
+ formHost.acquireFormState(want, (error, data) => {
+ if (error) {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ } else {
+ console.log('formHost acquireFormState, data:' + JSON.stringify(data));
+ }
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## acquireFormState
+
+acquireFormState(want: Want): Promise<formInfo.FormStateInfo>
+
+Obtains the widget state. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| want | [Want](js-apis-application-want.md) | Yes | **Want** information carried to query the widget state. The information must contain the bundle name, ability name, module name, widget name, and widget dimensions.|
+
+**Return value**
+
+| Type | Description |
+| :------------ | :---------------------------------- |
+| Promise<[formInfo.FormStateInfo](js-apis-app-form-formInfo.md#formstateinfo)> | Promise used to return the widget state obtained.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+let want = {
+ "deviceId": "",
+ "bundleName": "ohos.samples.FormApplication",
+ "abilityName": "FormAbility",
+ "parameters": {
+ "ohos.extra.param.key.module_name": "entry",
+ "ohos.extra.param.key.form_name": "widget",
+ "ohos.extra.param.key.form_dimension": 2
+ }
+};
+try {
+ formHost.acquireFormState(want).then((data) => {
+ console.log('formHost acquireFormState, data:' + JSON.stringify(data));
+ }).catch((error) => {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## on("formUninstall")
+
+on(type: "formUninstall", callback: Callback<string>): void
+
+Subscribes to widget uninstall events. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| type | string | Yes | Event type. The value **formUninstall** indicates a widget uninstallation event.|
+| callback | Callback<string> | Yes| Callback used to return the widget ID.|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+let callback = function(formId) {
+ console.log('formHost on formUninstall, formId:' + formId);
+}
+formHost.on("formUninstall", callback);
+```
+
+## off("formUninstall")
+
+off(type: "formUninstall", callback?: Callback<string>): void
+
+Unsubscribes from widget uninstall events. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| type | string | Yes | Event type. The value **formUninstall** indicates a widget uninstallation event.|
+| callback | Callback<string> | No| Callback used to return the widget ID. If it is left unspecified, it indicates the callback for all the events that have been subscribed.
The value must be the same as that in **on("formUninstall")**.|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+let callback = function(formId) {
+ console.log('formHost on formUninstall, formId:' + formId);
+}
+formHost.off("formUninstall", callback);
+```
+
+## notifyFormsVisible
+
+notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: AsyncCallback<void>): void
+
+Instructs the widgets to make themselves visible. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formIds | Array<string> | Yes | List of widget IDs.|
+| isVisible | boolean | Yes | Whether to make the widgets visible.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the notification is sent, **error** is undefined; otherwise, **error** is an error object.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+let formIds = new Array("12400633174999288", "12400633174999289");
+try {
+ formHost.notifyFormsVisible(formIds, true, (error) => {
+ if (error) {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ }
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## notifyFormsVisible
+
+notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise<void>
+
+Instructs the widgets to make themselves visible. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formIds | Array<string> | Yes | List of widget IDs.|
+| isVisible | boolean | Yes | Whether to make the widgets visible.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+let formIds = new Array("12400633174999288", "12400633174999289");
+try {
+ formHost.notifyFormsVisible(formIds, true).then(() => {
+ console.log('formHost notifyFormsVisible success');
+ }).catch((error) => {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## notifyFormsEnableUpdate
+
+notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, callback: AsyncCallback<void>): void
+
+Instructs the widgets to enable or disable updates. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formIds | Array<string> | Yes | List of widget IDs.|
+| isEnableUpdate | boolean | Yes | Whether to make the widgets updatable.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the notification is sent, **error** is undefined; otherwise, **error** is an error object.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+let formIds = new Array("12400633174999288", "12400633174999289");
+try {
+ formHost.notifyFormsEnableUpdate(formIds, true, (error) => {
+ if (error) {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ }
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## notifyFormsEnableUpdate
+
+notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean): Promise<void>
+
+Instructs the widgets to enable or disable updates. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formIds | Array<string> | Yes | List of widget IDs.|
+| isEnableUpdate | boolean | Yes | Whether to make the widgets updatable.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+let formIds = new Array("12400633174999288", "12400633174999289");
+try {
+ formHost.notifyFormsEnableUpdate(formIds, true).then(() => {
+ console.log('formHost notifyFormsEnableUpdate success');
+ }).catch((error) => {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+## shareForm
+
+shareForm(formId: string, deviceId: string, callback: AsyncCallback<void>): void
+
+Shares a specified widget with a remote device. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM and ohos.permission.DISTRIBUTED_DATASYNC
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formId | string | Yes | Widget ID.|
+| deviceId | string | Yes | Remote device ID.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the widget is shared, **error** is undefined; otherwise, **error** is an error object.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+let formId = "12400633174999288";
+let deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2";
+try {
+ formHost.shareForm(formId, deviceId, (error) => {
+ if (error) {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ }
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## shareForm
+
+shareForm(formId: string, deviceId: string): Promise<void>
+
+Shares a specified widget with a remote device. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM and ohos.permission.DISTRIBUTED_DATASYNC
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formId | string | Yes | Widget ID.|
+| deviceId | string | Yes | Remote device ID.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+let formId = "12400633174999288";
+let deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2";
+try {
+ formHost.shareForm(formId, deviceId).then(() => {
+ console.log('formHost shareForm success');
+ }).catch((error) => {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## notifyFormsPrivacyProtected
+
+notifyFormsPrivacyProtected(formIds: Array\, isProtected: boolean, callback: AsyncCallback\): void
+
+Notifies that the privacy protection status of the specified widgets changes. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| formIds | Array\ | Yes | ID of the widgets.|
+| isProtected | boolean | Yes | Whether privacy protection is enabled.|
+| callback | AsyncCallback\ | Yes| Callback used to return the result. If privacy protection is set successfully, **error** is undefined; otherwise, **error** is an error object.|
+
+**Error codes**
+
+| Error Code ID | Error Message |
+| ------------------------------------------------------------ | ------------------ |
+| 401 | Incorrect input parameter.|
+| For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).| |
+
+**Example**
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+let formIds = new Array("12400633174999288", "12400633174999289");
+try {
+ formHost.notifyFormsPrivacyProtected(formIds, true, (error) => {
+ if (error) {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ }
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
+
+## notifyFormsPrivacyProtected
+
+function notifyFormsPrivacyProtected(formIds: Array\, isProtected: boolean): Promise\;
+
+Notifies that the privacy protection status of the specified widgets changes. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.REQUIRE_FORM
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | --------------- | ---- | -------------------------------- |
+| formIds | Array\ | Yes | ID of the widgets.|
+| isProtected | boolean | Yes | Whether privacy protection is enabled. |
+
+**Return value**
+
+| Type | Description |
+| ------------------- | ------------------------- |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| Error Code ID | Error Message |
+| ------------------------------------------------------------ | ------------------ |
+| 401 | Incorrect input parameter.|
+| For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).| |
+
+```ts
+import formHost from '@ohos.app.form.formHost';
+
+let formIds = new Array("12400633174999288", "12400633174999289");
+try {
+ formHost.notifyFormsPrivacyProtected(formIds, true).then(() => {
+ console.log('formHost notifyFormsPrivacyProtected success');
+ }).catch((error) => {
+ console.log(`error, code: ${error.code}, message: ${error.message}`);
+ });
+} catch(error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+}
+```
diff --git a/en/application-dev/reference/apis/js-apis-app-form-formInfo.md b/en/application-dev/reference/apis/js-apis-app-form-formInfo.md
new file mode 100644
index 0000000000000000000000000000000000000000..84b40a57a56038b89ddf7ee06caef5f492e252f0
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-form-formInfo.md
@@ -0,0 +1,141 @@
+# @ohos.app.form.formInfo (formInfo)
+
+The **formInfo** module provides types and enums related to the widget information and state.
+
+> **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.
+
+## Modules to Import
+
+```ts
+import formInfo from '@ohos.app.form.formInfo';
+```
+
+## FormInfo
+
+Describes widget information.
+
+**System capability**: SystemCapability.Ability.Form
+
+| Name | Type | Readable | Writable | Description |
+| ----------- | -------- | -------- | -------------------- | ------------------------------------------------------------ |
+| bundleName | string | Yes | No | Name of the bundle to which the widget belongs. |
+| moduleName | string | Yes | No | Name of the module to which the widget belongs. |
+| abilityName | string | Yes | No | Name of the ability to which the widget belongs. |
+| name | string | Yes | No | Widget name. |
+| description | string | Yes | No | Description of the widget. |
+| type | [FormType](#formtype) | Yes | No | Type of the widget. Currently, only JS widgets are supported.|
+| jsComponentName | string | Yes | No | Name of the component used in the JS widget. |
+| colorMode | [ColorMode](#colormode) | Yes | No | Color mode of the widget. |
+| isDefault | boolean | Yes | No | Whether the widget is the default one. |
+| updateEnabled | boolean | Yes | No | Whether the widget is updatable. |
+| formVisibleNotify | boolean | Yes | No | Whether to send a notification when the widget is visible. |
+| relatedBundleName | string | Yes | No | Name of the associated bundle to which the widget belongs. |
+| scheduledUpdateTime | string | Yes | No | Time when the widget was updated. |
+| formConfigAbility | string | Yes | No | Configuration ability of the widget, that is, the ability corresponding to the option in the selection box displayed when the widget is long pressed. |
+| updateDuration | number | Yes | No | Update period of the widget.|
+| defaultDimension | number | Yes | No | Default dimension of the widget. |
+| supportDimensions | Array<number> | Yes | No | Dimensions supported by the widget. For details, see [FormDimension](#formdimension). |
+| customizeData | {[key: string]: [value: string]} | Yes | No | Custom data of the widget. |
+
+## FormType
+
+Enumerates the widget types.
+
+**System capability**: SystemCapability.Ability.Form
+
+| Name | Value | Description |
+| ----------- | ---- | ------------ |
+| JS | 1 | JS widget. |
+| eTS | 2 | eTS widget.|
+
+## ColorMode
+
+Enumerates the color modes supported by the widget.
+
+**System capability**: SystemCapability.Ability.Form
+
+| Name | Value | Description |
+| ----------- | ---- | ------------ |
+| MODE_AUTO | -1 | Auto mode. |
+| MODE_DARK | 0 | Dark mode. |
+| MODE_LIGHT | 1 | Light mode. |
+
+## FormStateInfo
+
+Describes the widget state information.
+
+**System capability**: SystemCapability.Ability.Form
+
+| Name | Type | Readable | Writable | Description |
+| ----------- | -------- | -------- | -------------------- | ------------------------------------------------------------ |
+| formState | [FormState](#formstate) | Yes | No | Widget state. |
+| want | Want | Yes | No | Want text. |
+
+## FormState
+
+Enumerates the widget states.
+
+**System capability**: SystemCapability.Ability.Form
+
+| Name | Value | Description |
+| ----------- | ---- | ------------ |
+| UNKNOWN | -1 | Unknown state. |
+| DEFAULT | 0 | Default state. |
+| READY | 1 | Ready state. |
+
+## FormParam
+
+Enumerates the widget parameters.
+
+**System capability**: SystemCapability.Ability.Form
+
+| Name | Value | Description |
+| ----------- | ---- | ------------ |
+| IDENTITY_KEY | "ohos.extra.param.key.form_identity" | Widget ID. |
+| DIMENSION_KEY | "ohos.extra.param.key.form_dimension" | Widget dimension. |
+| NAME_KEY | "ohos.extra.param.key.form_name" | Widget name. |
+| MODULE_NAME_KEY | "ohos.extra.param.key.module_name" | Name of the module to which the widget belongs. |
+| WIDTH_KEY | "ohos.extra.param.key.form_width" | Widget width. |
+| HEIGHT_KEY | "ohos.extra.param.key.form_height" | Widget height. |
+| TEMPORARY_KEY | "ohos.extra.param.key.form_temporary" | Temporary widget. |
+| ABILITY_NAME_KEY | "ohos.extra.param.key.ability_name" | Ability name. |
+| DEVICE_ID_KEY | "ohos.extra.param.key.device_id" | Device ID. |
+| BUNDLE_NAME_KEY | "ohos.extra.param.key.bundle_name" | Key that specifies the target bundle name.|
+
+## FormDimension
+
+Enumerates the widget dimensions.
+
+**System capability**: SystemCapability.Ability.Form
+
+| Name | Value | Description |
+| ----------- | ---- | ------------ |
+| Dimension_1_2 | 1 | 1 x 2. |
+| Dimension_2_2 | 2 | 2 x 2. |
+| Dimension_2_4 | 3 | 2 x 4. |
+| Dimension_4_4 | 4 | 4 x 4. |
+| Dimension_2_1 | 5 | 2 x 1. |
+
+
+## FormInfoFilter
+
+Defines the widget information filter. Only the widget information that meets the filter is returned.
+
+**System capability**: SystemCapability.Ability.Form
+
+| Name | Type | Description |
+| ----------- | ---- | ------------ |
+| moduleName | string | Optional. Only the information about the widget whose **moduleName** is the same as the provided value is returned.
If this parameter is not set, **moduleName** is not used for filtering. |
+
+## VisibilityType
+
+Enumerates the visibility types of the widget.
+
+**System capability**: SystemCapability.Ability.Form
+
+| Name | Value | Description |
+| ----------- | ---- | ------------ |
+| FORM_VISIBLE | 1 | The widget is visible.|
+| FORM_INVISIBLE | 2 | The widget is invisible.|
diff --git a/en/application-dev/reference/apis/js-apis-app-form-formProvider.md b/en/application-dev/reference/apis/js-apis-app-form-formProvider.md
new file mode 100644
index 0000000000000000000000000000000000000000..d61484f86b36bafd74ded1860272ac1a4b86089a
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-app-form-formProvider.md
@@ -0,0 +1,583 @@
+# @ohos.app.form.formProvider (formProvider)
+
+The **FormProvider** module provides APIs related to the widget provider. You can use the APIs to update a widget, set the next refresh time for a widget, obtain widget information, and request a widget release.
+
+> **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.
+
+## Modules to Import
+
+```ts
+import formProvider from '@ohos.app.form.formProvider';
+```
+
+## setFormNextRefreshTime
+
+setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback<void>): void
+
+Sets the next refresh time for a widget. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------------------------------------- |
+| formId | string | Yes | Widget ID. |
+| minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. |
+| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formProvider from '@ohos.app.form.formProvider';
+
+let formId = "12400633174999288";
+try {
+ formProvider.setFormNextRefreshTime(formId, 5, (error, data) => {
+ if (error) {
+ console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ } else {
+ console.log(`formProvider setFormNextRefreshTime success`);
+ }
+ });
+} catch (error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+}
+```
+
+## setFormNextRefreshTime
+
+setFormNextRefreshTime(formId: string, minute: number): Promise<void>
+
+Sets the next refresh time for a widget. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------------------------------------- |
+| formId | string | Yes | Widget ID. |
+| minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. |
+
+**Return value**
+
+| Type | Description |
+| ------------- | ---------------------------------- |
+| Promise\ | Promise that returns no value. |
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formProvider from '@ohos.app.form.formProvider';
+
+let formId = "12400633174999288";
+try {
+ formProvider.setFormNextRefreshTime(formId, 5).then(() => {
+ console.log(`formProvider setFormNextRefreshTime success`);
+ }).catch((error) => {
+ console.log(`promise error, code: ${error.code}, message: ${error.message})`);
+ });
+} catch (error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+}
+```
+
+## updateForm
+
+updateForm(formId: string, formBindingData: formBindingData.FormBindingData,callback: AsyncCallback<void>): void
+
+Updates a widget. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
+| formId | string | Yes | ID of the widget to update.|
+| formBindingData.FormBindingData | [FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | Yes | Data to be used for the update. |
+| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formBindingData from '@ohos.application.formBindingData';
+import formProvider from '@ohos.app.form.formProvider';
+
+let formId = "12400633174999288";
+try {
+ let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
+ formProvider.updateForm(formId, obj, (error, data) => {
+ if (error) {
+ console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ } else {
+ console.log(`formProvider updateForm success`);
+ }
+ });
+} catch (error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+}
+```
+
+## updateForm
+
+updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise<void>
+
+Updates a widget. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
+| formId | string | Yes | ID of the widget to update.|
+| formBindingData.FormBindingData | [FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | Yes | Data to be used for the update. |
+
+**Return value**
+
+| Type | Description |
+| -------------- | ----------------------------------- |
+| Promise\ | Promise that returns no value.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formBindingData from '@ohos.application.formBindingData';
+import formProvider from '@ohos.app.form.formProvider';
+
+let formId = "12400633174999288";
+let obj = formBindingData.createFormBindingData({ temperature: "22c", time: "22:00" });
+try {
+ formProvider.updateForm(formId, obj).then(() => {
+ console.log(`formProvider updateForm success`);
+ }).catch((error) => {
+ console.log(`promise error, code: ${error.code}, message: ${error.message})`);
+ });
+} catch (error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+}
+```
+
+## getFormsInfo
+
+getFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void
+
+Obtains the application's widget information on the device. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the information obtained.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+
+**Example**
+
+```ts
+import formProvider from '@ohos.app.form.formProvider';
+
+try {
+ formProvider.getFormsInfo((error, data) => {
+ if (error) {
+ console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ } else {
+ console.log('formProvider getFormsInfo, data: ' + JSON.stringify(data));
+ }
+ });
+} catch (error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+}
+```
+## getFormsInfo
+
+getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback<Array<formInfo.FormInfo>>): void
+
+Obtains the application's widget information that meets a filter criterion on the device. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| filter | [formInfo.FormInfoFilter](js-apis-app-form-formInfo.md#forminfofilter) | Yes| Filter criterion.|
+| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the information obtained.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formInfo from '@ohos.app.form.formInfo';
+import formProvider from '@ohos.app.form.formProvider';
+
+const filter: formInfo.FormInfoFilter = {
+ // get info of forms belong to module entry.
+ moduleName: "entry"
+};
+try {
+ formProvider.getFormsInfo(filter, (error, data) => {
+ if (error) {
+ console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ } else {
+ console.log('formProvider getFormsInfo, data: ' + JSON.stringify(data));
+ }
+ });
+} catch (error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+}
+```
+
+## getFormsInfo
+
+getFormsInfo(filter?: formInfo.FormInfoFilter): Promise<Array<formInfo.FormInfo>>
+
+Obtains the application's widget information on the device. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| filter | [formInfo.FormInfoFilter](js-apis-app-form-formInfo.md#forminfofilter) | No| Filter criterion.|
+
+**Return value**
+
+| Type | Description |
+| :------------ | :---------------------------------- |
+| Promise<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Promise used to return the information obtained.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formInfo from '@ohos.app.form.formInfo';
+import formProvider from '@ohos.app.form.formProvider';
+
+const filter: formInfo.FormInfoFilter = {
+ // get info of forms belong to module entry.
+ moduleName: "entry"
+};
+try {
+ formProvider.getFormsInfo(filter).then((data) => {
+ console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
+ }).catch((error) => {
+ console.log(`promise error, code: ${error.code}, message: ${error.message})`);
+ });
+} catch (error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+}
+```
+
+## requestPublishForm
+
+requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\): void
+
+Requests to publish a widget carrying data to the widget host. This API uses an asynchronous callback to return the result. This API is usually called by the home screen.
+
+**System capability**: SystemCapability.Ability.Form
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
+| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:
Information about the target widget.
**abilityName**: ability of the target widget.
**parameters**:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" |
+| formBindingData | [formBindingData.FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.|
+| callback | AsyncCallback<string> | Yes| Callback used to return the widget ID.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formBindingData from '@ohos.application.formBindingData';
+import formProvider from '@ohos.app.form.formProvider';
+
+let want = {
+ abilityName: "FormAbility",
+ parameters: {
+ "ohos.extra.param.key.form_dimension": 2,
+ "ohos.extra.param.key.form_name": "widget",
+ "ohos.extra.param.key.module_name": "entry"
+ }
+};
+try {
+ let obj = formBindingData.createFormBindingData({ temperature: "22c", time: "22:00" });
+ formProvider.requestPublishForm(want, obj, (error, data) => {
+ if (error) {
+ console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ } else {
+ console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
+ }
+ });
+} catch (error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+}
+```
+
+## requestPublishForm
+
+requestPublishForm(want: Want, callback: AsyncCallback<string>): void
+
+Requests to publish a widget to the widget host. This API uses an asynchronous callback to return the result. This API is usually called by the home screen.
+
+**System capability**: SystemCapability.Ability.Form
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------------------- | ---- | ------------------------------------------------------------ |
+| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:
Information about the target widget.
**abilityName**: ability of the target widget.
**parameters**:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" |
+| callback | AsyncCallback<string> | Yes | Callback used to return the widget ID.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formProvider from '@ohos.app.form.formProvider';
+
+let want = {
+ abilityName: "FormAbility",
+ parameters: {
+ "ohos.extra.param.key.form_dimension": 2,
+ "ohos.extra.param.key.form_name": "widget",
+ "ohos.extra.param.key.module_name": "entry"
+ }
+};
+try {
+ formProvider.requestPublishForm(want, (error, data) => {
+ if (error) {
+ console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ } else {
+ console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
+ }
+ });
+} catch (error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+}
+```
+
+## requestPublishForm
+
+requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData): Promise<string>
+
+Requests to publish a widget to the widget host. This API uses a promise to return the result. This API is usually called by the home screen.
+
+**System capability**: SystemCapability.Ability.Form
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
+| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:
Information about the target widget.
**abilityName**: ability of the target widget.
**parameters**:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" |
+| formBindingData | [formBindingData.FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | No | Data used for creating the widget. |
+
+**Return value**
+
+| Type | Description |
+| :------------ | :---------------------------------- |
+| Promise<string> | Promise used to return the widget ID.|
+
+**Error codes**
+
+| Error Code ID| Error Message|
+| -------- | -------- |
+| 401 | Incorrect input parameter.|
+|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
+**Example**
+
+```ts
+import formProvider from '@ohos.app.form.formProvider';
+
+let want = {
+ abilityName: "FormAbility",
+ parameters: {
+ "ohos.extra.param.key.form_dimension": 2,
+ "ohos.extra.param.key.form_name": "widget",
+ "ohos.extra.param.key.module_name": "entry"
+ }
+};
+try {
+ formProvider.requestPublishForm(want).then((data) => {
+ console.log('formProvider requestPublishForm success, form ID is :' + JSON.stringify(data));
+ }).catch((error) => {
+ console.log(`promise error, code: ${error.code}, message: ${error.message})`);
+ });
+} catch (error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+}
+```
+
+## isRequestPublishFormSupported
+
+isRequestPublishFormSupported(callback: AsyncCallback<boolean>): void
+
+Checks whether a widget can be published to the widget host. This API uses an asynchronous callback to return the result.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| callback | AsyncCallback<boolean> | Yes| Callback used to return whether the widget can be published to the widget host.|
+
+**Example**
+
+```ts
+import formProvider from '@ohos.app.form.formProvider';
+
+try {
+ formProvider.isRequestPublishFormSupported((error, isSupported) => {
+ if (error) {
+ console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ } else {
+ if (isSupported) {
+ var want = {
+ abilityName: "FormAbility",
+ parameters: {
+ "ohos.extra.param.key.form_dimension": 2,
+ "ohos.extra.param.key.form_name": "widget",
+ "ohos.extra.param.key.module_name": "entry"
+ }
+ };
+ try {
+ formProvider.requestPublishForm(want, (error, data) => {
+ if (error) {
+ console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ } else {
+ console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
+ }
+ });
+ } catch (error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ }
+ }
+ }
+ });
+} catch (error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+}
+```
+
+## isRequestPublishFormSupported
+
+isRequestPublishFormSupported(): Promise<boolean>
+
+Checks whether a widget can be published to the widget host. This API uses a promise to return the result.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Return value**
+
+| Type | Description |
+| :------------ | :---------------------------------- |
+| Promise<boolean> | Promise used to return whether the widget can be published to the widget host.|
+
+**Example**
+
+```ts
+import formProvider from '@ohos.app.form.formProvider';
+
+try {
+ formProvider.isRequestPublishFormSupported().then((isSupported) => {
+ if (isSupported) {
+ var want = {
+ abilityName: "FormAbility",
+ parameters: {
+ "ohos.extra.param.key.form_dimension": 2,
+ "ohos.extra.param.key.form_name": "widget",
+ "ohos.extra.param.key.module_name": "entry"
+ }
+ };
+ try {
+ formProvider.requestPublishForm(want).then((data) => {
+ console.log('formProvider requestPublishForm success, form ID is :' + JSON.stringify(data));
+ }).catch((error) => {
+ console.log(`promise error, code: ${error.code}, message: ${error.message})`);
+ });
+ } catch (error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ }
+ }
+ }).catch((error) => {
+ console.log(`promise error, code: ${error.code}, message: ${error.message})`);
+ });
+} catch (error) {
+ console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+}
+```
diff --git a/en/application-dev/reference/apis/js-apis-appAccount.md b/en/application-dev/reference/apis/js-apis-appAccount.md
index c98d603c0092e8f2fd9e1f9a2ce0d33ecd9cc1a7..0d2aef3e25aa21eb724c8f74f977d901ea12b290 100644
--- a/en/application-dev/reference/apis/js-apis-appAccount.md
+++ b/en/application-dev/reference/apis/js-apis-appAccount.md
@@ -1,8 +1,9 @@
-# App Account Management
+# @ohos.account.appAccount
-The **appAccount** module provides APIs for app account management. You can use the APIs to add, delete, query, modify, and authorize app accounts, write data to disks, and synchronize data.
+The **appAccount** module provides APIs for adding, deleting, modifying, and querying app account information, and supports inter-app authentication and distributed data synchronization.
-> **NOTE**
+> **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.
@@ -17,7 +18,7 @@ import account_appAccount from '@ohos.account.appAccount';
createAppAccountManager(): AppAccountManager
-Creates an **AppAccountManager** instance.
+Creates an **AppAccountManager** object.
**System capability**: SystemCapability.Account.AppAccount
@@ -25,46 +26,59 @@ Creates an **AppAccountManager** instance.
| Type | Description |
| ----------------- | ------------ |
-| AppAccountManager | **AppAccountManager** instance created.|
+| AppAccountManager | **AppAccountManager** object created.|
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
+ let appAccountManager = account_appAccount.createAppAccountManager();
```
## AppAccountManager
-Provides methods to manage app accounts.
+Implements app account management.
-### addAccount
+### createAccount9+
-addAccount(name: string, callback: AsyncCallback<void>): void
+createAccount(name: string, callback: AsyncCallback<void>): void;
-Adds an app account to the **AppAccountManager** service. This API uses an asynchronous callback to return the result.
+Creates an app account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ------------------------- | ---- | -------------------- |
-| name | string | Yes | Name of the app account to add. |
-| callback | AsyncCallback<void> | Yes | Callback invoked when the app account is added.|
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | ----- | -------------------- |
+| name | string | Yes | Name of the app account to create. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid name. |
+| 12300004 | Account already exists. |
+| 12300007 | The number of accounts reaches the upper limit. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.addAccount("WangWu", (err) => {
- console.log("addAccount err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.createAccount("WangWu", (err) => {
+ console.log("createAccount err: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("createAccount err: " + JSON.stringify(err));
+ }
```
-### addAccount
+### createAccount9+
-addAccount(name: string, extraInfo: string, callback: AsyncCallback<void>): void
+createAccount(name: string, options: CreateAccountOptions, callback: AsyncCallback<void>): void
-Adds an app account name and additional information (information that can be converted into the string type, such as token) to the **AppAccountManager** service. This API uses an asynchronous callback to return the result.
+Creates an app account with custom data. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -72,26 +86,46 @@ Adds an app account name and additional information (information that can be con
| Name | Type | Mandatory | Description |
| --------- | ------------------------- | ---- | ---------------------------------------- |
-| name | string | Yes | Name of the app account to add. |
-| extraInfo | string | Yes | Additional information to add. The additional information cannot contain sensitive information, such as the app account password.|
-| callback | AsyncCallback<void> | Yes | Callback invoked when the app account name and additional information are added. |
+| name | string | Yes | Name of the app account to create. |
+| options | [CreateAccountOptions](#createaccountoptions9) | Yes | Options for creating the app account. You can customize data based on service requirements, but do not add sensitive data (such as passwords and tokens).|
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. |
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or options. |
+| 12300004 | Account already exists. |
+| 12300007 | The number of accounts reaches the upper limit. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.addAccount("LiSi", "token101", (err) => {
- console.log("addAccount err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ let options = {
+ customData: {
+ "age": "10"
+ }
+ }
+ try {
+ appAccountManager.createAccount("LiSi", options, (err) => {
+ if (err) {
+ console.log("createAccount failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("createAccount successfully");
+ }
+ });
+ } catch(err) {
+ console.log("createAccount exception: " + JSON.stringify(err));
+ }
```
+### createAccount9+
+createAccount(name: string, options?: CreateAccountOptions): Promise<void>
-### addAccount
-
-addAccount(name: string, extraInfo?: string): Promise<void>
-
-Adds an app account name and additional information (information that can be converted into the string type, such as token) to the **AppAccountManager** service. This API uses a promise to return the result.
+Creates an app account with custom data. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -99,31 +133,104 @@ Adds an app account name and additional information (information that can be con
| Name | Type | Mandatory | Description |
| --------- | ------ | ---- | ---------------------------------------- |
-| name | string | Yes | Name of the app account to add. |
-| extraInfo | string | No | Additional information to add. The additional information cannot contain sensitive information, such as the app account password.|
+| name | string | Yes | Name of the app account to create. |
+| options | [CreateAccountOptions](#createaccountoptions9) | No | Options for creating the app account. You can customize data based on service requirements, but do not add sensitive data (such as passwords and tokens). This parameter can be left empty.|
**Return value**
| Type | Description |
| ------------------- | --------------------- |
-| Promise<void> | Promise used to return the result.|
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or options. |
+| 12300004 | Account already exists. |
+| 12300007 | The number of accounts reaches the upper limit. |
+| 12400003 | The number of custom data reaches the upper limit. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.addAccount("LiSi", "token101").then(()=> {
- console.log('addAccount Success');
- }).catch((err) => {
- console.log("addAccount err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ let options = {
+ customData: {
+ "age": "10"
+ }
+ }
+ try {
+ appAccountManager.createAccount("LiSi", options).then(() => {
+ console.log("createAccount successfully");
+ }).catch((err) => {
+ console.log("createAccount failed, error: " + JSON.stringify(err));
+ });
+ } catch(err) {
+ console.log("createAccount exception: " + JSON.stringify(err));
+ }
```
-### addAccountImplicitly8+
+### createAccountImplicitly9+
-addAccountImplicitly(owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
+createAccountImplicitly(owner: string, callback: AuthCallback): void
+
+Creates an app account implicitly based on the specified account owner. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | --------------------- | ---- | ----------------------- |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
+| callback | [AuthCallback](#authcallback9) | Yes | Authenticator callback used to return the result.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid owner. |
+| 12300007 | The number of accounts reaches the upper limit. |
+| 12300010 | Account service busy. |
+| 12300113 | Authenticator service not found. |
+| 12300114 | Authenticator service exception. |
+
+**Example**
+
+ ```js
+ import featureAbility from '@ohos.ability.featureAbility';
-Implicitly adds an app account based on the specified account owner, authentication type, and options. This API uses an asynchronous callback to return the result.
+ function onResultCallback(code, result) {
+ console.log("resultCode: " + code);
+ console.log("result: " + JSON.stringify(result));
+ }
+
+ function onRequestRedirectedCallback(request) {
+ let abilityStartSetting = {want: request};
+ featureAbility.startAbility(abilityStartSetting, (err) => {
+ console.log("startAbility err: " + JSON.stringify(err));
+ });
+ }
+
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.createAccountImplicitly("com.example.accountjsdemo", {
+ onResult: onResultCallback,
+ onRequestRedirected: onRequestRedirectedCallback
+ });
+ } catch (err) {
+ console.log("createAccountImplicitly exception: " + JSON.stringify(err));
+ }
+ ```
+
+### createAccountImplicitly9+
+
+createAccountImplicitly(owner: string, options: CreateAccountImplicitlyOptions, callback: AuthCallback): void
+
+Creates an app account implicitly based on the specified account owner and options. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -131,10 +238,20 @@ Implicitly adds an app account based on the specified account owner, authenticat
| Name | Type | Mandatory | Description |
| -------- | --------------------- | ---- | ----------------------- |
-| owner | string | Yes | Owner of the app account to add. The value is the bundle name of the app. |
-| authType | string | Yes | Authentication type of the app account to add. The authentication type is customized. |
-| options | {[key: string]: any} | Yes | Authentication options, which can be set as required.|
-| callback | [AuthenticatorCallback](#authenticatorcallback8) | Yes | Authenticator callback invoked to return the authentication result. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
+| options | [CreateAccountImplicitlyOptions](#createaccountimplicitlyoptions9) | Yes | Options for implicitly creating the account. |
+| callback | [AuthCallback](#authcallback9) | Yes | Authenticator callback used to return the result. |
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or options. |
+| 12300007 | The number of accounts reaches the upper limit. |
+| 12300010 | Account service busy. |
+| 12300113 | Authenticator service not found. |
+| 12300114 | Authenticator service exception. |
**Example**
@@ -142,29 +259,37 @@ Implicitly adds an app account based on the specified account owner, authenticat
import featureAbility from '@ohos.ability.featureAbility';
function onResultCallback(code, result) {
- console.log("resultCode: " + code);
- console.log("result: " + JSON.stringify(result));
+ console.log("resultCode: " + code);
+ console.log("result: " + JSON.stringify(result));
}
function onRequestRedirectedCallback(request) {
- let abilityStartSetting = {want: request};
- featureAbility.startAbility(abilityStartSetting, (err)=>{
- console.log("startAbility err: " + JSON.stringify(err));
- });
+ let abilityStartSetting = {want: request};
+ featureAbility.startAbility(abilityStartSetting, (err) => {
+ console.log("startAbility err: " + JSON.stringify(err));
+ });
}
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.addAccountImplicitly("com.example.ohos.accountjsdemo", "getSocialData", {}, {
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ let options = {
+ authType: "getSocialData",
+ requiredLabels: [ "student" ]
+ };
+ try {
+ appAccountManager.createAccountImplicitly("com.example.accountjsdemo", options, {
onResult: onResultCallback,
onRequestRedirected: onRequestRedirectedCallback
- });
+ });
+ } catch (err) {
+ console.log("createAccountImplicitly exception: " + JSON.stringify(err));
+ }
```
-### deleteAccount
+### removeAccount9+
-deleteAccount(name: string, callback: AsyncCallback<void>): void
+removeAccount(name: string, callback: AsyncCallback<void>): void
-Deletes an app account from the **AppAccountManager** service. This API uses an asynchronous callback to return the result.
+Removes an app account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -172,23 +297,39 @@ Deletes an app account from the **AppAccountManager** service. This API uses an
| Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ---------------- |
-| name | string | Yes | Name of the app account to delete. |
-| callback | AsyncCallback<void> | Yes | Callback invoked when the app account is deleted.|
+| name | string | Yes | Name of the app account to remove. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid name. |
+| 12300003 | Account not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.deleteAccount("ZhaoLiu", (err) => {
- console.log("deleteAccount err: " + JSON.stringify(err));
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.removeAccount("ZhaoLiu", (err) => {
+ if (err) {
+ console.log("removeAccount failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("removeAccount successfully");
+ }
});
+ } catch(err) {
+ console.log("removeAccount exception: " + JSON.stringify(err));
+ }
```
-### deleteAccount
+### removeAccount9+
-deleteAccount(name: string): Promise<void>
+removeAccount(name: string): Promise<void>
-Deletes an app account from the **AppAccountManager** service. This API uses a promise to return the result.
+Removes an app account. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -196,87 +337,131 @@ Deletes an app account from the **AppAccountManager** service. This API uses a p
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----------- |
-| name | string | Yes | Name of the app account to delete.|
+| name | string | Yes | Name of the app account to remove.|
**Return value**
| Type | Description |
| :------------------ | :-------------------- |
-| Promise<void> | Promise used to return the result.|
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid name. |
+| 12300003 | Account not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.deleteAccount("ZhaoLiu").then(() => {
- console.log('deleteAccount Success');
- }).catch((err) => {
- console.log("deleteAccount err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.removeAccount("Lisi").then(() => {
+ console.log("removeAccount successfully");
+ }).catch((err) => {
+ console.log("removeAccount failed, error: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("removeAccount exception: " + JSON.stringify(err));
+ }
```
-### disableAppAccess
+### setAppAccess9+
-disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void
+setAppAccess(name: string, bundleName: string, isAccessible: boolean, callback: AsyncCallback<void>): void
-Disables an app account from accessing an app with the given bundle name. This API uses an asynchronous callback to return the result.
+Sets the access to the data of an account for an app. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ------------------------- | ---- | --------------------------------- |
-| name | string | Yes | Name of the target app account. |
-| bundleName | string | Yes | Bundle name of the app. |
-| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+| Name | Type | Mandatory | Description |
+| ------------ | ------------------------- | ---- | --------------------------------- |
+| name | string | Yes | Name of the target app account. |
+| bundleName | string | Yes | Bundle name of the app. |
+| isAccessible | boolean | Yes | Whether the access is allowed. The value **true** means to allow the access; the value **false** means the opposite.|
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or bundleName. |
+| 12300003 | Account not found. |
+| 12400001 | Application not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => {
- console.log("disableAppAccess err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.setAppAccess("ZhangSan", "com.example.accountjsdemo", true, (err) => {
+ if (err) {
+ console.log("setAppAccess failed: " + JSON.stringify(err));
+ } else {
+ console.log("setAppAccess successfully");
+ }
+ });
+ } catch (err) {
+ console.log("setAppAccess exception: " + JSON.stringify(err));
+ }
```
-### disableAppAccess
+### setAppAccess9+
-disableAppAccess(name: string, bundleName: string): Promise<void>
+setAppAccess(name: string, bundleName: string, isAccessible: boolean): Promise<void>
-Disables an app account from accessing an app with the given bundle name. This API uses a promise to return the result.
+Sets the access to the data of an account for an app. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ------ | ---- | ---------------- |
-| name | string | Yes | Name of the target app account.|
-| bundleName | string | Yes | Bundle name of the app. |
+| Name | Type | Mandatory | Description |
+| ---------- | ------ | ---- | --------- |
+| name | string | Yes | Name of the target app account. |
+| bundleName | string | Yes | Bundle name of the app.|
+| isAccessible | boolean | Yes | Whether the access is allowed. The value **true** means to allow the access; the value **false** means the opposite.|
**Return value**
| Type | Description |
| :------------------ | :-------------------- |
-| Promise<void> | Promise used to return the result.|
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or bundleName. |
+| 12300003 | Account not found. |
+| 12400001 | Application not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => {
- console.log('disableAppAccess Success');
- }).catch((err) => {
- console.log("disableAppAccess err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.setAppAccess("ZhangSan", "com.example.accountjsdemo", true).then(() => {
+ console.log("setAppAccess successfully");
+ }).catch((err) => {
+ console.log("setAppAccess failed: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("setAppAccess exception: " + JSON.stringify(err));
+ }
```
-### enableAppAccess
+### checkAppAccess9+
-enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void
+checkAppAccess(name: string, bundleName: string, callback: AsyncCallback<boolean>): void
-Enables an app account to access an app with the given bundle name. This API uses an asynchronous callback to return the result.
+Checks whether an app can access the data of an account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -286,22 +471,39 @@ Enables an app account to access an app with the given bundle name. This API use
| ---------- | ------------------------- | ---- | --------------------------------- |
| name | string | Yes | Name of the target app account. |
| bundleName | string | Yes | Bundle name of the app. |
-| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. The value **true** means the app can access the account data; the value **false** means the opposite.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or bundleName. |
+| 12300003 | Account not found. |
+| 12400001 | Application not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => {
- console.log("enableAppAccess: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.checkAppAccess("ZhangSan", "com.example.accountjsdemo", (err, isAccessible) => {
+ if (err) {
+ console.log("checkAppAccess failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("checkAppAccess successfully");
+ }
+ });
+ } catch (err) {
+ console.log("checkAppAccess exception: " + JSON.stringify(err));
+ }
```
-### enableAppAccess
+### checkAppAccess9+
-enableAppAccess(name: string, bundleName: string): Promise<void>
+checkAppAccess(name: string, bundleName: string): Promise<boolean>
-Enables an app account to access an app with the given bundle name. This API uses a promise to return the result.
+Checks whether an app can access the data of an account. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -314,26 +516,124 @@ Enables an app account to access an app with the given bundle name. This API use
**Return value**
+| Type | Description |
+| ------------------- | --------------------- |
+| Promise<boolean> | Promise used to return the result. The value **true** means the app can access the account data; the value **false** means the opposite.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or bundleName. |
+| 12300003 | Account not found. |
+| 12400001 | Application not found. |
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.checkAppAccess("ZhangSan", "com.example.accountjsdemo").then((isAccessible) => {
+ console.log("checkAppAccess successfully, isAccessible: " + isAccessible);
+ }).catch((err) => {
+ console.log("checkAppAccess failed, error: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("checkAppAccess exception: " + JSON.stringify(err));
+ }
+ ```
+
+### setDataSyncEnabled9+
+
+setDataSyncEnabled(name: string, isEnabled: boolean, callback: AsyncCallback<void>): void
+
+Sets data synchronization for an app account. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | ---- | ------------------------- |
+| name | string | Yes | Name of the target app account. |
+| isEnabled | boolean | Yes | Whether to enable data synchronization. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name. |
+| 12300003 | Account not found. |
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.setDataSyncEnabled("ZhangSan", true, (err) => {
+ console.log("setDataSyncEnabled err: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("setDataSyncEnabled err: " + JSON.stringify(err));
+ }
+ ```
+
+### setDataSyncEnabled9+
+
+setDataSyncEnabled(name: string, isEnabled: boolean): Promise<void>
+
+Sets data synchronization for an app account. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ------- | ---- | ----------- |
+| name | string | Yes | Name of the target app account. |
+| isEnabled | boolean | Yes | Whether to enable data synchronization.|
+
+**Return value**
+
| Type | Description |
| :------------------ | :-------------------- |
-| Promise<void> | Promise used to return the result.|
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid name. |
+| 12300003 | Account not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => {
- console.log('enableAppAccess Success');
- }).catch((err) => {
- console.log("enableAppAccess err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager .setDataSyncEnabled("ZhangSan", true).then(() => {
+ console.log('setDataSyncEnabled Success');
+ }).catch((err) => {
+ console.log("setDataSyncEnabled err: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("setDataSyncEnabled err: " + JSON.stringify(err));
+ }
```
-### checkAppAccountSyncEnable
+### checkDataSyncEnabled9+
-checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>): void
+checkDataSyncEnabled(name: string, callback: AsyncCallback<boolean>): void
-Checks whether an app account allows app data synchronization. This API uses an asynchronous callback to return the result.
+Checks whether data synchronization is enabled for an app account. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
@@ -344,23 +644,38 @@ Checks whether an app account allows app data synchronization. This API uses an
| Name | Type | Mandatory | Description |
| -------- | ---------------------------- | ---- | --------------------- |
| name | string | Yes | Name of the target app account. |
-| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.|
+| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. The value **true** means data synchronization is enabled for the app account; the value **false** means the opposite.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid name. |
+| 12300003 | Account not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.checkAppAccountSyncEnable("ZhangSan", (err, result) => {
- console.log("checkAppAccountSyncEnable err: " + JSON.stringify(err));
- console.log('checkAppAccountSyncEnable result: ' + result);
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.checkDataSyncEnabled("ZhangSan", (err, isEnabled) => {
+ if (err) {
+ console.log("checkDataSyncEnabled failed, err: " + JSON.stringify(err));
+ } else {
+ console.log('checkDataSyncEnabled successfully, isEnabled: ' + isEnabled);
+ }
+ });
+ } catch (err) {
+ console.log("checkDataSyncEnabled err: " + JSON.stringify(err));
+ }
```
-### checkAppAccountSyncEnable
+### checkDataSyncEnabled9+
-checkAppAccountSyncEnable(name: string): Promise<boolean>
+checkDataSyncEnabled(name: string): Promise<boolean>
-Checks whether an app account allows app data synchronization. This API uses a promise to return the result.
+Checks whether data synchronization is enabled for an app account. This API uses a promise to return the result.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
@@ -376,22 +691,34 @@ Checks whether an app account allows app data synchronization. This API uses a p
| Type | Description |
| :--------------------- | :-------------------- |
-| Promise<boolean> | Promise used to return the result.|
+| Promise<boolean> | Promise used to return the result. The value **true** means data synchronization is enabled for the app account; the value **false** means the opposite.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name. |
+| 12300003 | Account not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.checkAppAccountSyncEnable("ZhangSan").then((data) => {
- console.log('checkAppAccountSyncEnable, result: ' + data);
- }).catch((err) => {
- console.log("checkAppAccountSyncEnable err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.checkDataSyncEnabled("ZhangSan").then((isEnabled) => {
+ console.log("checkDataSyncEnabled successfully, isEnabled: " + isEnabled);
+ }).catch((err) => {
+ console.log("checkDataSyncEnabled failed, err: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("checkDataSyncEnabled err: " + JSON.stringify(err));
+ }
```
-### setAccountCredential
+### setCredential9+
-setAccountCredential(name: string, credentialType: string, credential: string,callback: AsyncCallback<void>): void
+setCredential(name: string, credentialType: string, credential: string,callback: AsyncCallback<void>): void
Sets a credential for an app account. This API uses an asynchronous callback to return the result.
@@ -403,21 +730,37 @@ Sets a credential for an app account. This API uses an asynchronous callback to
| -------------- | ------------------------- | ---- | ------------- |
| name | string | Yes | Name of the target app account. |
| credentialType | string | Yes | Type of the credential to set. |
-| credential | string | Yes | Credential to set. |
-| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+| credential | string | Yes | Credential value. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the credential is set successfully, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or credentialType or credential. |
+| 12300003 | Account not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001", (err) => {
- console.log("setAccountCredential err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.setCredential("ZhangSan", "PIN_SIX", "xxxxxx", (err) => {
+ if (err) {
+ console.log("setCredential failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("setCredential successfully");
+ }
+ });
+ } catch (err) {
+ console.log("setCredential exception: " + JSON.stringify(err));
+ }
```
-### setAccountCredential
+### setCredential9+
-setAccountCredential(name: string, credentialType: string, credential: string): Promise<void>
+setCredential(name: string, credentialType: string, credential: string): Promise<void>
Sets a credential for an app account. This API uses a promise to return the result.
@@ -429,587 +772,648 @@ Sets a credential for an app account. This API uses a promise to return the resu
| -------------- | ------ | ---- | ---------- |
| name | string | Yes | Name of the target app account. |
| credentialType | string | Yes | Type of the credential to set.|
-| credential | string | Yes | Credential to set. |
+| credential | string | Yes | Credential value. |
**Return value**
-| Type | Description |
+| Type | Description |
| :------------------ | :-------------------- |
-| Promise<void> | Promise used to return the result.|
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or credentialType or credential. |
+| 12300003 | Account not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001").then(() => {
- console.log('setAccountCredential Success');
- }).catch((err) => {
- console.log("setAccountCredential err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.setCredential("ZhangSan", "PIN_SIX", "xxxxxx").then(() => {
+ console.log("setCredential successfully");
+ }).catch((err) => {
+ console.log("setCredential failed, error: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("setCredential exception: " + JSON.stringify(err));
+ }
```
-### setAccountExtraInfo
+### getCredential9+
-setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback<void>): void
+getCredential(name: string, credentialType: string, callback: AsyncCallback<string>): void
-Sets additional information for an app account. This API uses an asynchronous callback to return the result.
+Obtains the credential of an app account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| --------- | ------------------------- | ---- | --------------- |
-| name | string | Yes | Name of the target app account. |
-| extraInfo | string | Yes | Additional information to set. |
-| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+| Name | Type | Mandatory | Description |
+| -------------- | --------------------------- | ---- | -------------- |
+| name | string | Yes | Name of the target app account. |
+| credentialType | string | Yes | Type of the credential to obtain.|
+| callback | AsyncCallback<string> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the credential obtained. Otherwise, **err** is an error object.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or credentialType. |
+| 12300003 | Account not found. |
+| 12300102 | Credential not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002", (err) => {
- console.log("setAccountExtraInfo err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.getCredential("ZhangSan", "PIN_SIX", (err, result) => {
+ if (err) {
+ console.log("getCredential failed, error: " + JSON.stringify(err));
+ } else {
+ console.log('getCredential successfully, result: ' + result);
+ }
+ });
+ } catch (err) {
+ console.log("getCredential err: " + JSON.stringify(err));
+ }
```
-### setAccountExtraInfo
+### getCredential9+
-setAccountExtraInfo(name: string, extraInfo: string): Promise<void>
+getCredential(name: string, credentialType: string): Promise<string>
-Sets additional information for an app account. This API uses a promise to return the result.
+Obtains the credential of an app account. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| --------- | ------ | ---- | --------- |
-| name | string | Yes | Name of the target app account. |
-| extraInfo | string | Yes | Additional information to set.|
+| Name | Type | Mandatory | Description |
+| -------------- | ------ | ---- | ---------- |
+| name | string | Yes | Name of the target app account.|
+| credentialType | string | Yes | Type of the credential to obtain.|
**Return value**
-| Type | Description |
-| :------------------ | :-------------------- |
-| Promise<void> | Promise used to return the result.|
+| Type | Description |
+| :-------------------- | :-------------------- |
+| Promise<string> | Promise used to return the credential obtained.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or credentialType. |
+| 12300003 | Account not found. |
+| 12300102 | Credential not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002").then(() => {
- console.log('setAccountExtraInfo Success');
- }).catch((err) => {
- console.log("setAccountExtraInfo err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.getCredential("ZhangSan", "PIN_SIX").then((credential) => {
+ console.log("getCredential successfully, credential: " + credential);
+ }).catch((err) => {
+ console.log("getCredential failed, error: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("getCredential exception: " + JSON.stringify(err));
+ }
```
-### setAppAccountSyncEnable
-
-setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback<void>): void
+### setCustomData9+
-Sets whether to enable app data synchronization for an app account. This API uses an asynchronous callback to return the result.
+setCustomData(name: string, key: string, value: string, callback: AsyncCallback<void>): void
-**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
+Sets custom data for an app account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ------------------------- | ---- | ------------------------- |
-| name | string | Yes | Name of the target app account. |
-| isEnable | boolean | Yes | Whether to enable app data synchronization. |
-| callback | AsyncCallback<void> | Yes | Callback invoked when app data synchronization is enabled or disabled for the app account.|
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | ---- | ----------------- |
+| name | string | Yes | Name of the target app account.|
+| key | string | Yes | Key of the custom data to set.|
+| value | string | Yes | Value of the custom data to set.|
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or key or value. |
+| 12300003 | Account not found. |
+| 12400003 | The number of custom data reaches the upper limit. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.setAppAccountSyncEnable("ZhangSan", true, (err) => {
- console.log("setAppAccountSyncEnable err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.setCustomData("ZhangSan", "age", "12", (err) => {
+ if (err) {
+ console.log("setCustomData failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("setCustomData successfully");
+ }
+ });
+ } catch (err) {
+ console.log("setCustomData exception: " + JSON.stringify(err));
+ }
```
-### setAppAccountSyncEnable
-
-setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void>
+### setCustomData9+
-Sets whether to enable app data synchronization for an app account. This API uses a promise to return the result.
+setCustomData(name: string, key: string, value: string): Promise<void>
-**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
+Sets custom data for an app account. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ------- | ---- | ----------- |
-| name | string | Yes | Name of the target app account. |
-| isEnable | boolean | Yes | Whether to enable app data synchronization.|
+| Name | Type| Mandatory | Description |
+| ----- | ------ | ---- | ----------------- |
+| name | string | Yes | Name of the target app account. |
+| key | string | Yes | Key of the custom data to set.|
+| value | string | Yes | Value of the custom data to set.|
**Return value**
| Type | Description |
| :------------------ | :-------------------- |
-| Promise<void> | Promise used to return the result.|
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or key or value. |
+| 12300003 | Account not found. |
+| 12400003 | The number of custom data reaches the upper limit. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager .setAppAccountSyncEnable("ZhangSan", true).then(() => {
- console.log('setAppAccountSyncEnable Success');
- }).catch((err) => {
- console.log("setAppAccountSyncEnable err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.setCustomData("ZhangSan", "age", "12").then(() => {
+ console.log("setCustomData successfully");
+ }).catch((err) => {
+ console.log("setCustomData failed, error: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("setCustomData exception: " + JSON.stringify(err));
+ }
```
-### setAssociatedData
+### getCustomData9+
-setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback<void>): void
+getCustomData(name: string, key: string, callback: AsyncCallback<string>): void
-Sets data to be associated with an app account. This API uses an asynchronous callback to return the result.
+Obtains the custom data of an app account based on the specified key. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ------------------------- | ---- | ----------------- |
-| name | string | Yes | Name of the target app account. |
-| key | string | Yes | Key of the data to set. The private key can be customized.|
-| value | string | Yes | Value of the data to be set. |
-| callback | AsyncCallback<void> | Yes | Callback invoked when the data associated with the specified app account is set.|
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------- | ----- | ------------------------ |
+| name | string | Yes | Name of the target app account. |
+| key | string | Yes | Key of the custom data to obtain. |
+| callback | AsyncCallback<string> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the custom data value obtained. Otherwise, **err** is an error object.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or key. |
+| 12300003 | Account not found. |
+| 12400002 | Custom data not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.setAssociatedData("ZhangSan", "k001", "v001", (err) => {
- console.log("setAssociatedData err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.getCustomData("ZhangSan", "age", (err, data) => {
+ if (err) {
+ console.log('getCustomData failed, error: ' + err);
+ } else {
+ console.log("getCustomData successfully, data: " + data);
+ }
+ });
+ } catch (err) {
+ console.log("getCustomData exception: " + JSON.stringify(err));
+ }
```
-### setAssociatedData
+### getCustomData9+
-setAssociatedData(name: string, key: string, value: string): Promise<void>
+getCustomData(name: string, key: string): Promise<string>
-Sets data to be associated with an app account. This API uses a promise to return the result.
+Obtains the custom data of an app account based on the specified key. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| ----- | ------ | ---- | ----------------- |
-| name | string | Yes | Name of the target app account. |
-| key | string | Yes | Key of the data to set. The private key can be customized.|
-| value | string | Yes | Value of the data to be set. |
+| Name | Type | Mandatory | Description |
+| ---- | ------ | ---- | --------- |
+| name | string | Yes | Name of the target app account. |
+| key | string | Yes | Key of the custom data to obtain.|
**Return value**
-| Type | Description |
-| :------------------ | :-------------------- |
-| Promise<void> | Promise used to return the result.|
+| Type | Description |
+| --------------------- | --------------------- |
+| Promise<string> | Promise used to return the custom data value obtained.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or key. |
+| 12300003 | Account not found. |
+| 12400002 | Custom data not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.setAssociatedData("ZhangSan", "k001", "v001").then(() => {
- console.log('setAssociatedData Success');
- }).catch((err) => {
- console.log("setAssociatedData err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.getCustomData("ZhangSan", "age").then((data) => {
+ console.log("getCustomData successfully, data: " + data);
+ }).catch((err) => {
+ console.log("getCustomData failed, error: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("getCustomData exception: " + JSON.stringify(err));
+ }
```
-### getAccountCredential
+### getCustomDataSync9+
-getAccountCredential(name: string, credentialType: string, callback: AsyncCallback<string>): void
+getCustomDataSync(name: string, key: string): string;
-Obtains the credentials (such as the digital password, face image, and PIN) of an app account. This API uses an asynchronous callback to return the result.
+Obtains the custom data of an app account based on the specified key. The API returns the result synchronously.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------------- | --------------------------- | ---- | -------------- |
-| name | string | Yes | Name of the target app account. |
-| credentialType | string | Yes | Type of the credential to obtain.|
-| callback | AsyncCallback<string> | Yes | Callback invoked to return the credential obtained.|
+| Name | Type | Mandatory | Description |
+| ---- | ------ | ---- | --------- |
+| name | string | Yes | Name of the target app account. |
+| key | string | Yes | Key of the custom data to obtain.|
+
+**Return value**
+
+| Type | Description |
+| --------------------- | --------------------- |
+| string | Value of the custom data obtained.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or key. |
+| 12300003 | Account not found. |
+| 12400002 | Custom data not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.getAccountCredential("ZhangSan", "credentialType001", (err, result) => {
- console.log("getAccountCredential err: " + JSON.stringify(err));
- console.log('getAccountCredential result: ' + result);
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ let value = appAccountManager.getCustomDataSync("ZhangSan", "age");
+ console.info("getCustomDataSync successfully, vaue:" + value);
+ } catch (err) {
+ console.error("getCustomDataSync failed, error: " + JSON.stringify(err));
+ }
```
-### getAccountCredential
+### getAllAccounts9+
-getAccountCredential(name: string, credentialType: string): Promise<string>
+getAllAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void
-Obtains the credential of an app account. This API uses a promise to return the result.
+Obtains information about all accessible app accounts. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------------- | ------ | ---- | ---------- |
-| name | string | Yes | Name of the target app account. |
-| credentialType | string | Yes | Type of the credential to obtain.|
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | --------- |
+| callback | AsyncCallback<Array<[AppAccountInfo](#appaccountinfo)>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is a list of accessible app accounts. Otherwise, **err** is an error object.|
-**Return value**
+**Error codes**
-| Type | Description |
-| :-------------------- | :-------------------- |
-| Promise<string> | Promise used to return the result.|
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.getAccountCredential("ZhangSan", "credentialType001").then((data) => {
- console.log('getAccountCredential, result: ' + data);
- }).catch((err) => {
- console.log("getAccountCredential err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.getAllAccounts((err, data) => {
+ if (err) {
+ console.debug("getAllAccounts failed, error:" + JSON.stringify(err));
+ } else {
+ console.debug("getAllAccounts successfully");
+ }
+ });
+ } catch (err) {
+ console.debug("getAllAccounts exception: " + JSON.stringify(err));
+ }
```
-### getAccountExtraInfo
+### getAllAccounts9+
-getAccountExtraInfo(name: string, callback: AsyncCallback<string>): void
+getAllAccounts(): Promise<Array<AppAccountInfo>>
+
+Obtains information about all accessible app accounts. This API uses a promise to return the result.
-Obtains additional information (information that can be converted into the string type) about an app account. This API uses an asynchronous callback to return the result.
+**Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS
**System capability**: SystemCapability.Account.AppAccount
-**Parameters**
+**Return value**
-| Name | Type | Mandatory | Description |
-| -------- | --------------------------- | ---- | --------------- |
-| name | string | Yes | Name of the target app account. |
-| callback | AsyncCallback<string> | Yes | Callback invoked to return the additional information of the specified app account.|
+| Type | Description |
+| ---------------------------------------- | --------------------- |
+| Promise<Array<[AppAccountInfo](#appaccountinfo)>> | Promise used to return information about all accessible accounts.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.getAccountExtraInfo("ZhangSan", (err, result) => {
- console.log("getAccountExtraInfo err: " + JSON.stringify(err));
- console.log('getAccountExtraInfo result: ' + result);
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.getAllAccounts().then((data) => {
+ console.debug("getAllAccounts successfully");
+ }).catch((err) => {
+ console.debug("getAllAccounts failed, error:" + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.debug("getAllAccounts exception: " + JSON.stringify(err));
+ }
```
-### getAccountExtraInfo
+### getAccountsByOwner9+
-getAccountExtraInfo(name: string): Promise<string>
+getAccountsByOwner(owner: string, callback: AsyncCallback<Array<AppAccountInfo>>): void
+
+Obtains the app accounts that can be accessed by the invoker based on the app account owner. This API uses an asynchronous callback to return the result.
-Obtains additional information of an app account. This API uses a promise to return the result.
+**Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| ---- | ------ | ---- | ------- |
-| name | string | Yes | Name of the target app account.|
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | --------- |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
+| callback | AsyncCallback<Array<[AppAccountInfo](#appaccountinfo)>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is null and **data** is the app account information obtained. Otherwise, **err** is an error object.|
-**Return value**
+**Error codes**
-| Type | Description |
-| :-------------------- | :-------------------- |
-| Promise<string> | Promise used to return the result.|
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid owner. |
+| 12400001 | Application not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.getAccountExtraInfo("ZhangSan").then((data) => {
- console.log('getAccountExtraInfo, result: ' + data);
- }).catch((err) => {
- console.log("getAccountExtraInfo err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.getAccountsByOwner("com.example.accountjsdemo2", (err, data) => {
+ if (err) {
+ console.debug("getAccountsByOwner failed, error:" + JSON.stringify(err));
+ } else {
+ console.debug("getAccountsByOwner successfully, data:" + JSON.stringify(data));
+ }
+ });
+ } catch (err) {
+ console.debug("getAccountsByOwner exception:" + JSON.stringify(err));
+ }
```
-### getAssociatedData
+### getAccountsByOwner9+
-getAssociatedData(name: string, key: string, callback: AsyncCallback<string>): void
+getAccountsByOwner(owner: string): Promise<Array<AppAccountInfo>>
-Obtains data associated with an app account. This API uses an asynchronous callback to return the result.
+Obtains the app accounts that can be accessed by the invoker based on the app account owner. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | --------------------------- | ---- | ----------------- |
-| name | string | Yes | Name of the target app account. |
-| key | string | Yes | Key of the data to obtain. |
-| callback | AsyncCallback<string> | Yes | Callback invoked to return the data associated with the specified app account.|
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ------ |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
+
+**Return value**
+
+| Type | Description |
+| ---------------------------------------- | --------------------- |
+| Promise<Array<[AppAccountInfo](#appaccountinfo)>> | Promise used to return the app account information obtained.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid owner. |
+| 12400001 | Application not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.getAssociatedData("ZhangSan", "k001", (err, result) => {
- console.log("getAssociatedData err: " + JSON.stringify(err));
- console.log('getAssociatedData result: ' + result);
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.getAccountsByOwner("com.example.accountjsdemo2").then((data) => {
+ console.debug("getAccountsByOwner successfully, data:" + JSON.stringify(data));
+ }).catch((err) => {
+ console.debug("getAccountsByOwner failed, error:" + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.debug("getAccountsByOwner exception:" + JSON.stringify(err));
+ }
```
-### getAssociatedData
+### on('accountChange')9+
-getAssociatedData(name: string, key: string): Promise<string>
+on(type: 'accountChange', owners: Array<string>, callback: Callback<Array<AppAccountInfo>>): void
-Obtains data associated with an app account. This API uses a promise to return the result.
+Subscribes to account information changes of apps.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| ---- | ------ | ---- | --------- |
-| name | string | Yes | Name of the target app account. |
-| key | string | Yes | Key of the data to obtain.|
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ------------------------------ |
+| type | 'accountChange' | Yes | Event type to subscribe to. The value is **'accountChange'**. An event will be reported when the account information of the target app changes.|
+| owners | Array<string> | Yes | App bundle names of the account. |
+| callback | Callback<Array<[AppAccountInfo](#appaccountinfo)>> | Yes | Callback invoked to return a list of app accounts whose information is changed. |
-**Return value**
+**Error codes**
-| Type | Description |
-| :-------------------- | :-------------------- |
-| Promise<string> | Promise used to return the result.|
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid type or owners. |
+| 12300011 | Callback has been registered. |
+| 12400001 | Application not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.getAssociatedData("ZhangSan", "k001").then((data) => {
- console.log('getAssociatedData: ' + data);
- }).catch((err) => {
- console.log("getAssociatedData err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ function changeOnCallback(data){
+ console.log("receive change data:" + JSON.stringify(data));
+ }
+ try{
+ appAccountManager.on("accountChange", ["com.example.actsaccounttest"], changeOnCallback);
+ } catch(err) {
+ console.error("on accountChange failed, error:" + JSON.stringify(err));
+ }
```
-### getAssociatedDataSync9+
+### off('accountChange')9+
-getAssociatedDataSync(name: string, key: string): string;
+off(type: 'accountChange', callback?: Callback>): void
-Obtains the data associated with this app account. This API returns the result synchronously.
+Unsubscribes from account information changes.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| ---- | ------ | ---- | --------- |
-| name | string | Yes | Name of the target app account. |
-| key | string | Yes | Key of the data to obtain.|
+| Name | Type | Mandatory | Description |
+| -------- | -------------------------------- | ---- | ------------ |
+| type | 'accountChange' | Yes | Event type to unsubscribe from. The value is **'accountChange'**. |
+| callback | Callback> | No | Callback to unregister.|
-**Return value**
+**Error codes**
-| Type | Description |
-| :-------------------- | :-------------------- |
-| string | Data obtained.|
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid type. |
+| 12300012 | Callback has not been registered. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- var backData = appAccountManager.getAssociatedDataSync("ZhangSan", "k001");
- console.info("getAssociatedDataSync backData:" + JSON.stringify(backData));
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ function changeOnCallback(data){
+ console.log("receive change data:" + JSON.stringify(data));
+ }
+ try{
+ appAccountManager.on("accountChange", ["com.example.actsaccounttest"], changeOnCallback);
+ } catch(err) {
+ console.error("on accountChange failed, error:" + JSON.stringify(err));
+ }
+ try{
+ appAccountManager.off('accountChange', changeOnCallback);
+ }
+ catch(err){
+ console.error("off accountChange failed, error:" + JSON.stringify(err));
+ }
```
-### getAllAccessibleAccounts
-
-getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void
+### auth9+
-Obtains information about all accessible app accounts. This API uses an asynchronous callback to return the result.
+auth(name: string, owner: string, authType: string, callback: AuthCallback): void
-**Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS (available only to system applications)
+Authenticates an app account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ---------------------------------------- | ---- | --------- |
-| callback | AsyncCallback<Array<[AppAccountInfo](#appaccountinfo)>> | Yes | Callback invoked to return information about all accessible app accounts.|
+| Name | Type | Mandatory | Description |
+| -------- | --------------------- | ---- | --------------- |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
+| authType | string | Yes | Authentication type. |
+| callback | [AuthCallback](#authcallback9) | Yes | Callback invoked to return the authentication result.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or owner or authType. |
+| 12300003 | Account not found. |
+| 12300010 | Account service busy. |
+| 12300113 | Authenticator service not found. |
+| 12300114 | Authenticator service exception. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.getAllAccessibleAccounts((err, data)=>{
- console.debug("getAllAccessibleAccounts err:" + JSON.stringify(err));
- console.debug("getAllAccessibleAccounts data:" + JSON.stringify(data));
- });
- ```
+ import featureAbility from '@ohos.ability.featureAbility';
-### getAllAccessibleAccounts
+ function onResultCallback(code, authResult) {
+ console.log("resultCode: " + code);
+ console.log("authResult: " + JSON.stringify(authResult));
+ }
-getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>>
+ function onRequestRedirectedCallback(request) {
+ let abilityStartSetting = {want: request};
+ featureAbility.startAbility(abilityStartSetting, (err) => {
+ console.log("startAbility err: " + JSON.stringify(err));
+ });
+ }
-Obtains information about all accessible app accounts. This API uses a promise to return the result.
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.auth("LiSi", "com.example.accountjsdemo", "getSocialData", {
+ onResult: onResultCallback,
+ onRequestRedirected: onRequestRedirectedCallback
+ });
+ } catch (err) {
+ console.log("auth exception: " + JSON.stringify(err));
+ }
+ ```
-**Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS (available only to system applications)
+### auth9+
-**System capability**: SystemCapability.Account.AppAccount
+auth(name: string, owner: string, authType: string, options: {[key: string]: Object}, callback: AuthCallback): void
-**Parameters**
-
-| Type | Description |
-| ---------------------------------------- | --------------------- |
-| Promise<Array<[AppAccountInfo](#appaccountinfo)>> | Promise used to return the result.|
-
-**Example**
-
- ```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.getAllAccessibleAccounts().then((data) => {
- console.log('getAllAccessibleAccounts: ' + data);
- }).catch((err) => {
- console.log("getAllAccessibleAccounts err: " + JSON.stringify(err));
- });
- ```
-
-### getAllAccounts
-
-getAllAccounts(owner: string, callback: AsyncCallback<Array<AppAccountInfo>>): void
-
-Obtains information about all app accounts of the specified app. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS (available only to system applications)
-
-**System capability**: SystemCapability.Account.AppAccount
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| -------- | ---------------------------------------- | ---- | --------- |
-| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
-| callback | AsyncCallback<Array<[AppAccountInfo](#appaccountinfo)>> | Yes | Callback invoked to return information about all accessible app accounts.|
-
-**Example**
-
- ```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- const selfBundle = "com.example.actsgetallaaccounts";
- appAccountManager.getAllAccounts(selfBundle, (err, data)=>{
- console.debug("getAllAccounts err:" + JSON.stringify(err));
- console.debug("getAllAccounts data:" + JSON.stringify(data));
- });
- ```
-
-### getAllAccounts
-
-getAllAccounts(owner: string): Promise<Array<AppAccountInfo>>
-
-Obtains information about all app accounts of the specified app. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS (available only to system applications)
-
-**System capability**: SystemCapability.Account.AppAccount
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| ----- | ------ | ---- | ------ |
-| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
-
-**Parameters**
-
-| Type | Description |
-| ---------------------------------------- | --------------------- |
-| Promise<Array<[AppAccountInfo](#appaccountinfo)>> | Promise used to return the result.|
-
-**Example**
-
- ```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- const selfBundle = "com.example.actsgetallaaccounts";
- appAccountManager.getAllAccounts(selfBundle).then((data) => {
- console.log('getAllAccounts: ' + data);
- }).catch((err) => {
- console.log("getAllAccounts err: " + JSON.stringify(err));
- });
- ```
-
-### on('change')
-
-on(type: 'change', owners: Array<string>, callback: Callback<Array<AppAccountInfo>>): void
-
-Subscribes to the account change events of the specified account owners. This API uses an asynchronous callback to return the result.
-
-**System capability**: SystemCapability.Account.AppAccount
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| -------- | ---------------------------------------- | ---- | ------------------------------ |
-| type | 'change' | Yes | Account change events to subscribe to. The subscriber will receive a notification when the account owners update their accounts.|
-| owners | Array<string> | Yes | Account owners. |
-| callback | Callback<Array<[AppAccountInfo](#appaccountinfo)>> | Yes | Callback invoked to return the account changes. |
-
-**Example**
-
- ```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- function changeOnCallback(data){
- console.debug("receive change data:" + JSON.stringify(data));
- }
- try{
- appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback);
- }
- catch(err){
- console.error("on accountOnOffDemo err:" + JSON.stringify(err));
- }
- ```
-
-### off('change')
-
-off(type: 'change', callback?: Callback>): void
-
-Unsubscribes from the account change events. This API uses an asynchronous callback to return the result.
-
-**System capability**: SystemCapability.Account.AppAccount
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| -------- | -------------------------------- | ---- | ------------ |
-| type | 'change' | Yes | Account change events to unsubscribe from. |
-| callback | Callback> | No | Callback used to report the account changes.|
-
-**Example**
-
- ```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- function changeOnCallback(data){
- console.debug("receive change data:" + JSON.stringify(data));
- appAccountManager.off('change', function(){
- console.debug("off finish");
- })
- }
- try{
- appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback);
- }
- catch(err){
- console.error("on accountOnOffDemo err:" + JSON.stringify(err));
- }
- ```
-
-### authenticate8+
-
-authenticate(name: string, owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
-
-Authenticates an app account to obtain an Open Authorization (OAuth) token. This API uses an asynchronous callback to return the result.
+Authenticates an app account with customized options. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -1020,38 +1424,56 @@ Authenticates an app account to obtain an Open Authorization (OAuth) token. This
| name | string | Yes | Name of the target app account. |
| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
| authType | string | Yes | Authentication type. |
-| options | {[key: string]: any} | Yes | Options for the authentication. |
-| callback | [AuthenticatorCallback](#authenticatorcallback8) | Yes | Authenticator callback invoked to return the authentication result.|
+| options | {[key: string]: Object} | Yes | Options for the authentication. |
+| callback | [AuthCallback](#authcallback9) | Yes | Callback invoked to return the authentication result.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or owner or authType. |
+| 12300003 | Account not exist. |
+| 12300010 | Account service busy. |
+| 12300113 | Authenticator service not found. |
+| 12300114 | Authenticator service exception. |
**Example**
```js
import featureAbility from '@ohos.ability.featureAbility';
- function onResultCallback(code, result) {
- console.log("resultCode: " + code);
- console.log("result: " + JSON.stringify(result));
+ function onResultCallback(code, authResult) {
+ console.log("resultCode: " + code);
+ console.log("authResult: " + JSON.stringify(authResult));
}
function onRequestRedirectedCallback(request) {
- let abilityStartSetting = {want: request};
- featureAbility.startAbility(abilityStartSetting, (err)=>{
- console.log("startAbility err: " + JSON.stringify(err));
- });
+ let abilityStartSetting = {want: request};
+ featureAbility.startAbility(abilityStartSetting, (err) => {
+ console.log("startAbility err: " + JSON.stringify(err));
+ });
}
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.authenticate("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", {}, {
- onResult: onResultCallback,
- onRequestRedirected: onRequestRedirectedCallback
- });
+ let options = {
+ "password": "xxxx",
+ };
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.auth("LiSi", "com.example.accountjsdemo", "getSocialData", options, {
+ onResult: onResultCallback,
+ onRequestRedirected: onRequestRedirectedCallback
+ });
+ } catch (err) {
+ console.log("auth exception: " + JSON.stringify(err));
+ }
```
-### getOAuthToken8+
+### getAuthToken9+
-getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback<string>): void
+getAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback<string>): void
-Obtains the OAuth token of an app account based on the specified authentication type. This API uses an asynchronous callback to return the result.
+Obtains the authorization token of the specified authentication type for an app account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -1062,23 +1484,39 @@ Obtains the OAuth token of an app account based on the specified authentication
| name | string | Yes | Name of the target app account. |
| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
| authType | string | Yes | Authentication type. |
-| callback | AsyncCallback<string> | Yes | Callback invoked to return the result. |
+| callback | AsyncCallback<string> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the authorization token value obtained. Otherwise, **err** is an error object. |
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name, owner or authType. |
+| 12300003 | Account not found. |
+| 12300107 | AuthType not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", (err, data) => {
- console.log('getOAuthToken err: ' + JSON.stringify(err));
- console.log('getOAuthToken token: ' + data);
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.getAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData", (err, token) => {
+ if (err) {
+ console.log("getAuthToken failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("getAuthToken successfully, token: " + token);
+ }
+ });
+ } catch (err) {
+ console.log("getAuthToken exception: " + JSON.stringify(err));
+ }
```
-### getOAuthToken8+
+### getAuthToken9+
-getOAuthToken(name: string, owner: string, authType: string): Promise<string>
+getAuthToken(name: string, owner: string, authType: string): Promise<string>
-Obtains the OAuth token of an app account based on the specified authentication type. This API uses a promise to return the result.
+Obtains the authorization token of the specified authentication type for an app account. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -1090,28 +1528,41 @@ Obtains the OAuth token of an app account based on the specified authentication
| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
| authType | string | Yes | Authentication type. |
-**Parameters**
+**Return value**
-| Type | Description |
+| Type | Description |
| --------------------- | --------------------- |
-| Promise<string> | Promise used to return the result.|
+| Promise<string> | Promise used to return the authorization token obtained.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or owner or authType. |
+| 12300003 | Account not found. |
+| 12300107 | AuthType not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "getSocialData").then((data) => {
- console.log('getOAuthToken token: ' + data);
- }).catch((err) => {
- console.log("getOAuthToken err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.getAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData").then((token) => {
+ console.log("getAuthToken successfully, token: " + token);
+ }).catch((err) => {
+ console.log("getAuthToken failed, error: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("getAuthToken exception: " + JSON.stringify(err));
+ }
```
-### setOAuthToken8+
+### setAuthToken9+
-setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback<void>): void
+setAuthToken(name: string, authType: string, token: string, callback: AsyncCallback<void>): void
-Sets an OAuth token for an app account. This API uses an asynchronous callback to return the result.
+Sets an authorization token of the specific authentication type for an app account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -1121,23 +1572,40 @@ Sets an OAuth token for an app account. This API uses an asynchronous callback t
| -------- | ------------------------- | ---- | -------- |
| name | string | Yes | Name of the target app account.|
| authType | string | Yes | Authentication type. |
-| token | string | Yes | OAuth token to set.|
-| callback | AsyncCallback<void> | Yes | Callback invoked to return the result.|
+| token | string | Yes | Token to set.|
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or authType or token. |
+| 12300003 | Account not found. |
+| 12400004 | The number of token reaches the upper limit. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.setOAuthToken("LiSi", "getSocialData", "xxxx", (err) => {
- console.log('setOAuthToken err: ' + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.setAuthToken("LiSi", "getSocialData", "xxxx", (err) => {
+ if (err) {
+ console.log("setAuthToken failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("setAuthToken successfully");
+ }
+ });
+ } catch (err) {
+ console.log('setAuthToken exception: ' + JSON.stringify(err));
+ }
```
-### setOAuthToken8+
+### setAuthToken9+
-setOAuthToken(name: string, authType: string, token: string): Promise<void>
+setAuthToken(name: string, authType: string, token: string): Promise<void>
-Sets an OAuth token for an app account. This API uses a promise to return the result.
+Sets an authorization token of the specific authentication type for an app account. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -1147,30 +1615,43 @@ Sets an OAuth token for an app account. This API uses a promise to return the re
| -------- | ------ | ---- | -------- |
| name | string | Yes | Name of the target app account.|
| authType | string | Yes | Authentication type. |
-| token | string | Yes | OAuth token to set.|
+| token | string | Yes | Token to set.|
-**Parameters**
+**Return value**
| Type | Description |
| ------------------- | --------------------- |
-| Promise<void> | Promise used to return the result.|
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or authType or token. |
+| 12300003 | Account not found. |
+| 12400004 | The number of token reaches the upper limit. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.setOAuthToken("LiSi", "getSocialData", "xxxx").then(() => {
- console.log('setOAuthToken successfully');
- }).catch((err) => {
- console.log('setOAuthToken err: ' + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.setAuthToken("LiSi", "getSocialData", "xxxx").then(() => {
+ console.log("setAuthToken successfully");
+ }).catch((err) => {
+ console.log("setAuthToken failed, error: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("setAuthToken exception: " + JSON.stringify(err));
+ }
```
-### deleteOAuthToken8+
+### deleteAuthToken9+
-deleteOAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback<void>): void
+deleteAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback<void>): void
-Deletes the specified OAuth token for an app account. This API uses an asynchronous callback to return the result.
+Deletes the authorization token of the specified authentication type for an app account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -1181,23 +1662,40 @@ Deletes the specified OAuth token for an app account. This API uses an asynchron
| name | string | Yes | Name of the target app account. |
| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
| authType | string | Yes | Authentication type. |
-| token | string | Yes | OAuth token to delete.|
-| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
+| token | string | Yes | Token to delete.|
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. |
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or owner or authType or token. |
+| 12300003 | Account not found. |
+| 12300107 | AuthType not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", "xxxxx", (err) => {
- console.log('deleteOAuthToken err: ' + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.deleteAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData", "xxxxx", (err) => {
+ if (err) {
+ console.log('deleteAuthToken failed, error: ' + JSON.stringify(err));
+ } else {
+ console.log("deleteAuthToken successfully");
+ }
+ });
+ } catch (err) {
+ console.log('deleteAuthToken exception: ' + JSON.stringify(err));
+ }
```
-### deleteOAuthToken8+
+### deleteAuthToken9+
-deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise<void>
+deleteAuthToken(name: string, owner: string, authType: string, token: string): Promise<void>
-Deletes the specified OAuth token for an app account. This API uses a promise to return the result.
+Deletes the authorization token of the specified authentication type for an app account. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -1208,30 +1706,43 @@ Deletes the specified OAuth token for an app account. This API uses a promise to
| name | string | Yes | Name of the target app account. |
| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
| authType | string | Yes | Authentication type. |
-| token | string | Yes | OAuth token to delete.|
+| token | string | Yes | Token to delete.|
-**Parameters**
+**Return value**
| Type | Description |
| ------------------- | --------------------- |
-| Promise<void> | Promise used to return the result.|
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or owner or authType or token. |
+| 12300003 | Account not found. |
+| 12300107 | AuthType not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", "xxxxx").then(() => {
- console.log('deleteOAuthToken successfully');
- }).catch((err) => {
- console.log("deleteOAuthToken err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.deleteAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData", "xxxxx").then(() => {
+ console.log("deleteAuthToken successfully");
+ }).catch((err) => {
+ console.log('deleteAuthToken failed, error: ' + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log('deleteAuthToken exception: ' + JSON.stringify(err));
+ }
```
-### setOAuthTokenVisibility8+
+### setAuthTokenVisibility9+
-setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback<void>): void
+setAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback<void>): void
-Sets the visibility of an OAuth token to an app. This API uses an asynchronous callback to return the result.
+Sets the visibility of an authorization token to an app. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -1242,57 +1753,91 @@ Sets the visibility of an OAuth token to an app. This API uses an asynchronous c
| name | string | Yes | Name of the target app account. |
| authType | string | Yes | Authentication type. |
| bundleName | string | Yes | Bundle name of the app. |
-| isVisible | boolean | Yes | Whether the OAuth token is visible to the app. The value **true** means visible, and the value **false** means the opposite.|
-| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
+| isVisible | boolean | Yes | Whether the authorization token is visible to the app. The value **true** means the authorization token is visible to the app; the value **false** means the opposite.|
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or authType or bundleName. |
+| 12300003 | Account not found. |
+| 12300107 | AuthType not found. |
+| 12400001 | Application not found. |
+| 12400005 | The size of authorization list reaches the upper limit. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.setOAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo", true, (err) => {
- console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.setAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo", true, (err) => {
+ if (err) {
+ console.log("setAuthTokenVisibility failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("setAuthTokenVisibility successfully");
+ }
+ });
+ } catch (err) {
+ console.log("setAuthTokenVisibility exception: " + JSON.stringify(err));
+ }
```
-### setOAuthTokenVisibility8+
+### setAuthTokenVisibility9+
-setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise<void>
+setAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise<void>
-Sets the visibility of an OAuth token to an app. This API uses a promise to return the result.
+Sets the visibility of an authorization token to an app. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ------- | ---- | ------------ |
-| name | string | Yes | Name of the target app account. |
-| authType | string | Yes | Authentication type. |
-| bundleName | string | Yes | Bundle name of the app.|
-| isVisible | boolean | Yes | Whether the OAuth token is visible to the app. |
+| Name | Type | Mandatory | Description |
+| ---------- | ------------------------- | ---- | ------------------------- |
+| name | string | Yes | Name of the target app account. |
+| authType | string | Yes | Authentication type. |
+| bundleName | string | Yes | Bundle name of the app. |
+| isVisible | boolean | Yes | Whether the authorization token is visible to the app. The value **true** means the authorization token is visible to the app; the value **false** means the opposite.|
-**Parameters**
+**Return value**
| Type | Description |
| ------------------- | --------------------- |
-| Promise<void> | Promise used to return the result.|
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or authType or bundleName. |
+| 12300003 | Account not found. |
+| 12300107 | AuthType not found. |
+| 12400001 | Application not found. |
+| 12400005 | The size of authorization list reaches the upper limit. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.setOAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo", true).then(() => {
- console.log('setOAuthTokenVisibility successfully');
- }).catch((err) => {
- console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.setAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo", true).then(() => {
+ console.log("setAuthTokenVisibility successfully");
+ }).catch((err) => {
+ console.log("setAuthTokenVisibility failed, error: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("setAuthTokenVisibility exception: " + JSON.stringify(err));
+ }
```
-### checkOAuthTokenVisibility8+
+### checkAuthTokenVisibility9+
-checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback<boolean>): void
+checkAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback<boolean>): void
-Checks whether an OAuth token is visible to an app. This API uses an asynchronous callback to return the result.
+Checks the visibility of an authorization token of the specified authentication type to an app. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -1303,23 +1848,40 @@ Checks whether an OAuth token is visible to an app. This API uses an asynchronou
| name | string | Yes | Name of the target app account. |
| authType | string | Yes | Authentication type. |
| bundleName | string | Yes | Bundle name of the app.|
-| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. |
+| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** can be **true** (the authorization token is visible to the app) or **false** (the authorization token is not visible to the app). If the operation fails, **err** is an error object. |
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or authType or bundleName. |
+| 12300003 | Account not found. |
+| 12300107 | AuthType not found. |
+| 12400001 | Application not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.checkOAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo", (err, data) => {
- console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err));
- console.log('checkOAuthTokenVisibility isVisible: ' + data);
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.checkAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo", (err, isVisible) => {
+ if (err) {
+ console.log("checkAuthTokenVisibility failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("checkAuthTokenVisibility successfully, isVisible: " + isVisible);
+ }
+ });
+ } catch (err) {
+ console.log("checkAuthTokenVisibility exception: " + JSON.stringify(err));
+ }
```
-### checkOAuthTokenVisibility8+
+### checkAuthTokenVisibility9+
-checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise<boolean>
+checkAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise<boolean>
-Checks whether an OAuth token is visible to an app. This API uses a promise to return the result.
+Checks the visibility of an authorization token of the specified authentication type to an app. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -1331,28 +1893,42 @@ Checks whether an OAuth token is visible to an app. This API uses a promise to r
| authType | string | Yes | Authentication type. |
| bundleName | string | Yes | Bundle name of the app.|
-**Parameters**
+**Return value**
| Type | Description |
| ---------------------- | --------------------- |
-| Promise<boolean> | Promise used to return the result.|
+| Promise<boolean> | Promise used to return the result. The value **true** means the authorization token is visible to the app; the value **false** means the opposite.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or authType or bundleName. |
+| 12300003 | Account not found. |
+| 12300107 | AuthType not found. |
+| 12400001 | Application not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.checkOAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo").then((data) => {
- console.log('checkOAuthTokenVisibility isVisible: ' + data);
- }).catch((err) => {
- console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.checkAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo").then((isVisible) => {
+ console.log("checkAuthTokenVisibility successfully, isVisible: " + isVisible);
+ }).catch((err) => {
+ console.log("checkAuthTokenVisibility failed, error: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("checkAuthTokenVisibility exception: " + JSON.stringify(err));
+ }
```
-### getAllOAuthTokens8+
+### getAllAuthTokens9+
-getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array<OAuthTokenInfo>>): void
+getAllAuthTokens(name: string, owner: string, callback: AsyncCallback<Array<AuthTokenInfo>>): void
-Obtains all OAuth tokens visible to the caller for an app account. This API uses an asynchronous callback to return the result.
+Obtains all tokens visible to the invoker for an app account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -1362,23 +1938,38 @@ Obtains all OAuth tokens visible to the caller for an app account. This API uses
| -------- | ---------------------------------------- | ---- | ----------- |
| name | string | Yes | Name of the target app account. |
| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
-| callback | AsyncCallback<Array< [OAuthTokenInfo](#oauthtokeninfo8)>> | Yes | Callback invoked to return the result. |
+| callback | AsyncCallback<Array<[AuthTokenInfo](#authtokeninfo9)>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is a list of all tokens visible to the invoker. Otherwise, **err** is an error object. |
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or owner. |
+| 12300003 | Account not found. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo", (err, data) => {
- console.log("getAllOAuthTokens err: " + JSON.stringify(err));
- console.log('getAllOAuthTokens data: ' + JSON.stringify(data));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.getAllAuthTokens("LiSi", "com.example.accountjsdemo", (err, tokenArr) => {
+ if (err) {
+ console.log("getAllAuthTokens failed, error: " + JSON.stringify(err));
+ } else {
+ console.log('getAllAuthTokens successfully, tokenArr: ' + tokenArr);
+ }
+ });
+ } catch (err) {
+ console.log("getAllAuthTokens exception: " + JSON.stringify(err));
+ }
```
-### getAllOAuthTokens8+
+### getAllAuthTokens9+
-getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenInfo>>
+getAllAuthTokens(name: string, owner: string): Promise<Array<AuthTokenInfo>>
-Obtains all OAuth tokens visible to the caller for an app account. This API uses a promise to return the result.
+Obtains all tokens visible to the invoker for an app account. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -1389,584 +1980,2519 @@ Obtains all OAuth tokens visible to the caller for an app account. This API uses
| name | string | Yes | Name of the target app account. |
| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
-**Parameters**
+**Return value**
| Type | Description |
| ---------------------------------------- | --------------------- |
-| Promise<Array< [OAuthTokenInfo](#oauthtokeninfo8)>> | Promise used to return the result.|
+| Promise<Array<[AuthTokenInfo](#authtokeninfo9)>> | Promise used to return the tokens obtained.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or owner. |
+| 12300003 | Account not found. |
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.getAllAuthTokens("LiSi", "com.example.accountjsdemo").then((tokenArr) => {
+ console.log('getAllAuthTokens successfully, tokenArr: ' + JSON.stringify(tokenArr));
+ }).catch((err) => {
+ console.log("getAllAuthTokens failed, error: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("getAllAuthTokens exception: " + JSON.stringify(err));
+ }
+ ```
+
+### getAuthList9+
+
+getAuthList(name: string, authType: string, callback: AsyncCallback<Array<string>>): void
+
+Obtains the authorization list of the specified authentication type for an app account. The authorization list contains all authorized bundles. The token authorization list is set by [setAuthTokenVisibility](#setauthtokenvisibility9). This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ----------------------- |
+| name | string | Yes | Name of the target app account. |
+| authType | string | Yes | Authentication type.|
+| callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is a list of authorized bundles obtained. Otherwise, **err** is an error object.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or authType. |
+| 12300003 | Account not found. |
+| 12300107 | AuthType not found. |
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.getAuthList("com.example.accountjsdemo", "getSocialData", (err, authList) => {
+ if (err) {
+ console.log("getAuthList failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("getAuthList successfully, authList: " + authList);
+ }
+ });
+ } catch (err) {
+ console.log('getAuthList exception: ' + JSON.stringify(err));
+ }
+ ```
+
+### getAuthList9+
+
+getAuthList(name: string, authType: string): Promise<Array<string>>
+
+Obtains the authorization list of the specified authentication type for an app account. The authorization list contains all authorized bundles. The token authorization list is set by [setAuthTokenVisibility](#setauthtokenvisibility9). This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ------ | ---- | ------------------------------ |
+| name | string | Yes | Name of the target app account. |
+| authType | string | Yes | Authentication type.|
+
+**Return value**
+
+| Type | Description |
+| ---------------------------------- | --------------------- |
+| Promise<Array<string>> | Promise used to return a list of authorized bundles.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or authType. |
+| 12300003 | Account not found. |
+| 12300107 | AuthType not found. |
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.getAuthList("com.example.accountjsdemo", "getSocialData").then((authList) => {
+ console.log("getAuthList successfully, authList: " + authList);
+ }).catch((err) => {
+ console.log("getAuthList failed, error: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("getAuthList exception: " + JSON.stringify(err));
+ }
+ ```
+
+### getAuthCallback9+
+
+getAuthCallback(sessionId: string, callback: AsyncCallback<AuthCallback>): void
+
+Obtains the authenticator callback for the authentication session. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| --------- | ---------------------------------------- | ---- | -------- |
+| sessionId | string | Yes | ID of the authentication session.|
+| callback | AsyncCallback<[AuthCallback](#authcallback9)> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the authenticator callback object obtained. Otherwise, **err** is an error object.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid sessionId. |
+| 12300108 | Session not found. |
+
+**Example**
+
+ ```js
+ import featureAbility from '@ohos.ability.featureAbility';
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ featureAbility.getWant((err, want) => {
+ var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
+ try {
+ appAccountManager.getAuthCallback(sessionId, (err, callback) => {
+ if (err.code != account_appAccount.ResultCode.SUCCESS) {
+ console.log("getAuthCallback err: " + JSON.stringify(err));
+ return;
+ }
+ var result = {
+ accountInfo: {
+ name: "Lisi",
+ owner: "com.example.accountjsdemo",
+ },
+ tokenInfo: {
+ token: "xxxxxx",
+ authType: "getSocialData"
+ }
+ };
+ callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
+ });
+ } catch (err) {
+ console.log("getAuthCallback exception: " + JSON.stringify(err));
+ }
+ });
+ ```
+
+### getAuthCallback9+
+
+getAuthCallback(sessionId: string): Promise<AuthCallback>
+
+Obtains the authenticator callback for the authentication session. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| --------- | ------ | ---- | -------- |
+| sessionId | string | Yes | ID of the authentication session.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------------------ | --------------------- |
+| Promise<[AuthCallback](#authcallback9)> | Promise used to return the authenticator callback obtained.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid sessionId. |
+| 12300108 | Session not found. |
+
+**Example**
+
+ ```js
+ import featureAbility from '@ohos.ability.featureAbility';
+
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ featureAbility.getWant().then((want) => {
+ var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
+ try {
+ appAccountManager.getAuthCallback(sessionId).then((callback) => {
+ var result = {
+ accountInfo: {
+ name: "Lisi",
+ owner: "com.example.accountjsdemo",
+ },
+ tokenInfo: {
+ token: "xxxxxx",
+ authType: "getSocialData"
+ }
+ };
+ callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
+ }).catch((err) => {
+ console.log("getAuthCallback err: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("getAuthCallback exception: " + JSON.stringify(err));
+ }
+ }).catch((err) => {
+ console.log("getWant err: " + JSON.stringify(err));
+ });
+ ```
+
+### queryAuthenticatorInfo9+
+
+queryAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo>): void
+
+Obtains the authenticator information of an app. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | -------------------------------------- | ---- | ----------- |
+| owner | string | Yes | Bundle name of the app.|
+| callback | AsyncCallback<[AuthenticatorInfo](#authenticatorinfo8)> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the authenticator information obtained. Otherwise, **err** is an error object. |
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid owner. |
+| 12300113 | Authenticator service not found. |
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.queryAuthenticatorInfo("com.example.accountjsdemo", (err, info) => {
+ if (err) {
+ console.log("queryAuthenticatorInfo failed, error: " + JSON.stringify(err));
+ } else {
+ console.log('queryAuthenticatorInfo successfully, info: ' + JSON.stringify(info));
+ }
+ });
+ } catch (err) {
+ console.log("queryAuthenticatorInfo exception: " + JSON.stringify(err));
+ }
+ ```
+
+### queryAuthenticatorInfo9+
+
+queryAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo>
+
+Obtains the authenticator information of an app. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ----------- |
+| owner | string | Yes | Bundle name of the app.|
+
+**Return value**
+
+| Type | Description |
+| -------------------------------- | --------------------- |
+| Promise<[AuthenticatorInfo](#authenticatorinfo8)> | Promise used to return the authenticator information obtained.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid owner. |
+| 12300113 | Authenticator service not found. |
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.queryAuthenticatorInfo("com.example.accountjsdemo").then((info) => {
+ console.log("queryAuthenticatorInfo successfully, info: " + JSON.stringify(info));
+ }).catch((err) => {
+ console.log("queryAuthenticatorInfo failed, error: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("queryAuthenticatorInfo exception: " + JSON.stringify(err));
+ }
+ ```
+
+### checkAccountLabels9+
+
+checkAccountLabels(name: string, owner: string, labels: Array<string>, callback: AsyncCallback<boolean>): void;
+
+Checks whether an app account has specific labels. This API uses an asynchronous callback to return the result. The labels are checked by the authenticator of the target app.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | ------------------------- | ----- | --------------- |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
+| labels | Array<string> | Yes | Labels to check. |
+| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** can be **true** or **false**. The value **true** means the app account has the labels; the value **false** means the opposite. If the operation fails, **err** is an error object. |
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or owner or labels. |
+| 12300003 | Account not found. |
+| 12300010 | Account service busy. |
+| 12300113 | Authenticator service not found. |
+| 12300114 | Authenticator service exception. |
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ let labels = ["student"];
+ try {
+ appAccountManager.checkAccountLabels("zhangsan", "com.example.accountjsdemo", labels, (err, hasAllLabels) => {
+ if (err) {
+ console.log("checkAccountLabels failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("checkAccountLabels successfully, hasAllLabels: " + hasAllLabels);
+ }
+ });
+ } catch (err) {
+ console.log("checkAccountLabels exception: " + JSON.stringify(err));
+ }
+ ```
+
+### checkAccountLabels9+
+
+checkAccountLabels(name: string, owner: string, labels: Array<string>): Promise<boolean>
+
+Checks whether an app account has specific labels. This API uses a promise to return the result. The labels are checked by the authenticator of the target app.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | ------------------------- | ----- | --------------- |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
+| labels | Array<string> | Yes | Labels to check. |
+
+**Return value**
+
+| Type | Description |
+| ------------------- | -------------------------------- |
+| Promise<boolean> | Promise used to return the result. The value **true** means the app account has the labels; the value **false** means the opposite.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or owner or labels. |
+| 12300003 | Account not found. |
+| 12300010 | Account service busy. |
+| 12300113 | Authenticator service not found. |
+| 12300114 | Authenticator service exception. |
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ let labels = ["student"];
+ try {
+ appAccountManager.checkAccountLabels("zhangsan", "com.example.accountjsdemo", labels).then((hasAllLabels) => {
+ console.log('checkAccountLabels successfully: ' + hasAllLabels);
+ }).catch((err) => {
+ console.log("checkAccountLabels failed, error: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("checkAccountLabels exception: " + JSON.stringify(err));
+ }
+ ```
+
+### deleteCredential9+
+
+deleteCredential(name: string, credentialType: string, callback: AsyncCallback<void>): void
+
+Deletes the credential of the specified type from an app account. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | ------------------------- | ----- | -------------- |
+| name | string | Yes | Name of the target app account.|
+| credentialType | string | Yes | Type of the credential to delete. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or credentialType. |
+| 12300003 | Account not found. |
+| 12300102 | Credential not found. |
**Example**
- ```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo").then((data) => {
- console.log('getAllOAuthTokens data: ' + JSON.stringify(data));
- }).catch((err) => {
- console.log("getAllOAuthTokens err: " + JSON.stringify(err));
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.deleteCredential("zhangsan", "PIN_SIX", (err) => {
+ if (err) {
+ console.log("deleteCredential failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("deleteCredential successfully");
+ }
+ });
+ } catch (err) {
+ console.log("deleteCredential exception: " + JSON.stringify(err));
+ }
+ ```
+
+### deleteCredential9+
+
+deleteCredential(name: string, credentialType: string): Promise<void>
+
+Deletes the credential of the specified type from an app account. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | ------ | ----- | --------------- |
+| name | string | Yes | Name of the target app account.|
+| credentialType | string | Yes | Type of the credential to delete. |
+
+**Return value**
+
+| Type | Description |
+| ------------------- | -------------------------------- |
+| Promise<void> | Promise that returns no value.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or credentialType. |
+| 12300003 | Account not found. |
+| 12300102 | Credential not found. |
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.deleteCredential("zhangsan", "PIN_SIX").then(() => {
+ console.log("deleteCredential successfully");
+ }).catch((err) => {
+ console.log("deleteCredential failed, error: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("deleteCredential exception: " + JSON.stringify(err));
+ }
+ ```
+
+### selectAccountsByOptions9+
+
+selectAccountsByOptions(options: SelectAccountsOptions, callback: AsyncCallback<Array<AppAccountInfo>>): void
+
+Selects the accounts that can be accessed by the invoker based on the options. This API uses an asynchronous callback to return the result. If the options contain label constraints, the authenticator of the target app provides the capability of checking the labels.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | ----------------------------------- | ----- | --------------- |
+| options | SelectAccountsOptions | Yes | Options for selecting accounts. |
+| callback | AsyncCallback<Array<[AppAccountInfo](#appaccountinfo)>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is a list of accounts selected. Otherwise, **err** is an error object. |
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid options. |
+| 12300010 | Account service busy. |
+| 12300114 | Authenticator service exception. |
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ let options = {
+ allowedOwners: [ "com.example.accountjsdemo" ],
+ requiredLabels: [ "student" ]
+ };
+ try {
+ appAccountManager.selectAccountsByOptions(options, (err, accountArr) => {
+ if (err) {
+ console.log("selectAccountsByOptions failed, error: " + JSON.stringify(err));
+ } else {
+ console.log("selectAccountsByOptions successfully, accountArr: " + JSON.stringify(accountArr));
+ }
+ });
+ } catch (err) {
+ console.log("selectAccountsByOptions exception: " + JSON.stringify(err));
+ }
+ ```
+
+### selectAccountsByOptions9+
+
+selectAccountsByOptions(options: SelectAccountsOptions): Promise<Array<AppAccountInfo>>
+
+Selects the accounts that can be accessed by the invoker based on the options. This API uses a promise to return the result. If the options contain label constraints, the authenticator of the target app provides the capability of checking the labels.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | ------------------------- | ----- | --------------- |
+| options | [SelectAccountsOptions](#selectaccountsoptions9) | Yes | Options for selecting accounts. |
+
+**Return value**
+
+| Type | Description |
+| ------------------- | -------------------------------- |
+| Promise<[AppAccountInfo](#appaccountinfo)> | Promise used to return the accounts selected.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid options. |
+| 12300010 | Account service busy. |
+| 12300114 | Authenticator service exception. |
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ let options = {
+ allowedOwners: ["com.example.accountjsdemo"]
+ };
+ try {
+ appAccountManager.selectAccountsByOptions(options).then((accountArr) => {
+ console.log("selectAccountsByOptions successfully, accountArr: " + JSON.stringify(accountArr));
+ }).catch((err) => {
+ console.log("selectAccountsByOptions failed, error: " + JSON.stringify(err));
+ });
+ } catch (err) {
+ console.log("selectAccountsByOptions exception: " + JSON.stringify(err));
+ }
+ ```
+
+### verifyCredential9+
+
+verifyCredential(name: string, owner: string, callback: AuthCallback): void;
+
+Verifies the credential of an app account. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | --------------------- | ----- | ----------------------- |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
+| callback | [AuthCallback](#authcallback9) | Yes | Callback invoked to return the result.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or owner. |
+| 12300003 | Account not found. |
+| 12300010 | Account service busy. |
+| 12300113 | Authenticator service not found. |
+| 12300114 | Authenticator service exception. |
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.verifyCredential("zhangsan", "com.example.accountjsdemo", {
+ onResult: (resultCode, result) => {
+ console.log("verifyCredential onResult, resultCode:" + JSON.stringify(resultCode));
+ console.log("verifyCredential onResult, result:" + JSON.stringify(result));
+ },
+ onRequestRedirected: (request) => {
+ console.log("verifyCredential onRequestRedirected, request:" + JSON.stringify(request));
+ }
+ });
+ } catch (err) {
+ console.log("verifyCredential err: " + JSON.stringify(err));
+ }
+ ```
+
+### verifyCredential9+
+
+verifyCredential(name: string, owner: string, options: VerifyCredentialOptions, callback: AuthCallback): void;
+
+Verifies the user credential. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ----------------------- | ----- | ----------------------- |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
+| options | [VerifyCredentialOptions](#verifycredentialoptions9) | Yes | Options for verifying the user credential. |
+| callback | [AuthCallback](#authcallback9) | Yes | Callback invoked to return the result.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------|
+| 12300001 | System service exception. |
+| 12300002 | Invalid name or owner or options. |
+| 12300003 | Account not found. |
+| 12300010 | Account service busy. |
+| 12300113 | Authenticator service not found. |
+| 12300114 | Authenticator service exception. |
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ let options = {
+ credentialType: "pin",
+ credential: "123456"
+ };
+ try {
+ appAccountManager.verifyCredential("zhangsan", "com.example.accountjsdemo", options, {
+ onResult: (resultCode, result) => {
+ console.log("verifyCredential onResult, resultCode:" + JSON.stringify(resultCode));
+ console.log("verifyCredential onResult, result:" + JSON.stringify(result));
+ },
+ onRequestRedirected: (request) => {
+ console.log("verifyCredential onRequestRedirected, request:" + JSON.stringify(request));
+ }
+ });
+ } catch (err) {
+ console.log("verifyCredential err: " + JSON.stringify(err));
+ }
+ ```
+
+### setAuthenticatorProperties9+
+
+setAuthenticatorProperties(owner: string, callback: AuthCallback): void;
+
+Sets the authenticator attributes of an app. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | --------------------- | ----- | ----------------------- |
+| owner | string | Yes | Owner of the authenticator. |
+| callback | [AuthCallback](#authcallback9) | Yes | Callback invoked to return the result.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid owner. |
+| 12300010 | Account service busy. |
+| 12300113 | Authenticator service not found. |
+| 12300114 | Authenticator service exception. |
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ try {
+ appAccountManager.setAuthenticatorProperties("com.example.accountjsdemo", {
+ onResult: (resultCode, result) => {
+ console.log("setAuthenticatorProperties onResult, resultCode:" + JSON.stringify(resultCode));
+ console.log("setAuthenticatorProperties onResult, result:" + JSON.stringify(result));
+ },
+ onRequestRedirected: (request) => {
+ console.log("setAuthenticatorProperties onRequestRedirected, request:" + JSON.stringify(request));
+ }
+ });
+ } catch (err) {
+ console.log("setAuthenticatorProperties err: " + JSON.stringify(err));
+ }
+ ```
+
+### setAuthenticatorProperties9+
+
+setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callback: AuthCallback): void;
+
+Set authenticator properties. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | --------------------- | ----- | ----------------------- |
+| owner | string | Yes | Owner of the authenticator. |
+| options | [SetPropertiesOptions](#setpropertiesoptions9) | Yes | Authenticator properties to set. |
+| callback | [AuthCallback](#authcallback9) | Yes | Authenticator callback invoked to return the result.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | ------- |
+| 12300001 | System service exception. |
+| 12300002 | Invalid owner or options. |
+| 12300010 | Account service busy. |
+| 12300113 | Authenticator service not found. |
+| 12300114 | Authenticator service exception. |
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ let options = {
+ properties: {"prop1": "value1"}
+ };
+ try {
+ appAccountManager.setAuthenticatorProperties("com.example.accountjsdemo", options, {
+ onResult: (resultCode, result) => {
+ console.log("setAuthenticatorProperties onResult, resultCode:" + JSON.stringify(resultCode));
+ console.log("setAuthenticatorProperties onResult, result:" + JSON.stringify(result));
+ },
+ onRequestRedirected: (request) => {
+ console.log("setAuthenticatorProperties onRequestRedirected, request:" + JSON.stringify(request));
+ }
+ });
+ } catch (err) {
+ console.log("setAuthenticatorProperties err: " + JSON.stringify(err));
+ }
+
+ ```
+
+### addAccount(deprecated)
+
+addAccount(name: string, callback: AsyncCallback<void>): void
+
+Adds an app account. 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 [createAccount](#createaccount9).
+
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | ---- | -------------------- |
+| name | string | Yes | Name of the target app account. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.addAccount("WangWu", (err) => {
+ console.log("addAccount err: " + JSON.stringify(err));
+ });
+ ```
+
+### addAccount(deprecated)
+
+addAccount(name: string, extraInfo: string, callback: AsyncCallback<void>): void
+
+Adds an app account name and additional information. 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 [createAccount](#createaccount9-1).
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| --------- | ------------------------- | ---- | ---------------------------------------- |
+| name | string | Yes | Name of the target app account. |
+| extraInfo | string | Yes | Additional information (information that can be converted to the string type). It cannot contain sensitive information, such as the app account password and token.|
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. |
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.addAccount("LiSi", "token101", (err) => {
+ console.log("addAccount err: " + JSON.stringify(err));
+ });
+ ```
+
+### addAccount(deprecated)
+
+addAccount(name: string, extraInfo?: string): Promise<void>
+
+Adds an app account name and additional information. This API uses an asynchronous callback to return the result. 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 [createAccount](#createaccount9-2).
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| --------- | ------ | ---- | ---------------------------------------- |
+| name | string | Yes | Name of the target app account. |
+| extraInfo | string | No | Additional information (information that can be converted to the string type). It cannot contain sensitive information, such as the app account password and token.|
+
+**Return value**
+
+| Type | Description |
+| ------------------- | --------------------- |
+| Promise<void> | Promise that returns no value.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.addAccount("LiSi", "token101").then(()=> {
+ console.log('addAccount Success');
+ }).catch((err) => {
+ console.log("addAccount err: " + JSON.stringify(err));
+ });
+ ```
+
+### addAccountImplicitly(deprecated)
+
+addAccountImplicitly(owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
+
+Adds an app account implicitly based on the specified owner. 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 [createAccountImplicitly](#createaccountimplicitly9).
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | --------------------- | ---- | ----------------------- |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
+| authType | string | Yes | Authentication type. The authentication type is customized. |
+| options | {[key: string]: any} | Yes | Authentication options, which can be set as required.|
+| callback | [AuthenticatorCallback](#authenticatorcallbackdeprecated) | Yes | Authenticator callback invoked to return the result. |
+
+**Example**
+
+ ```js
+ import featureAbility from '@ohos.ability.featureAbility';
+
+ function onResultCallback(code, result) {
+ console.log("resultCode: " + code);
+ console.log("result: " + JSON.stringify(result));
+ }
+
+ function onRequestRedirectedCallback(request) {
+ let abilityStartSetting = {want: request};
+ featureAbility.startAbility(abilityStartSetting, (err)=>{
+ console.log("startAbility err: " + JSON.stringify(err));
+ });
+ }
+
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.addAccountImplicitly("com.example.accountjsdemo", "getSocialData", {}, {
+ onResult: onResultCallback,
+ onRequestRedirected: onRequestRedirectedCallback
+ });
+ ```
+
+### deleteAccount(deprecated)
+
+deleteAccount(name: string, callback: AsyncCallback<void>): void
+
+Deletes an app account. 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 [removeAccount](#removeaccount9).
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | ---- | ---------------- |
+| name | string | Yes | Name of the target app account. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.deleteAccount("ZhaoLiu", (err) => {
+ console.log("deleteAccount err: " + JSON.stringify(err));
+ });
+ ```
+
+### deleteAccount(deprecated)
+
+deleteAccount(name: string): Promise<void>
+
+Deletes an app account. 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 [removeAccount](#removeaccount9).
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---- | ------ | ---- | ----------- |
+| name | string | Yes | Name of the target app account.|
+
+**Return value**
+
+| Type | Description |
+| :------------------ | :-------------------- |
+| Promise<void> | Promise that returns no value.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.deleteAccount("ZhaoLiu").then(() => {
+ console.log('deleteAccount Success');
+ }).catch((err) => {
+ console.log("deleteAccount err: " + JSON.stringify(err));
+ });
+ ```
+### disableAppAccess(deprecated)
+
+disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void
+
+Disables an app account from accessing an app. 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 [setAppAccess](#setappaccess9).
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---------- | ------------------------- | ---- | --------------------------------- |
+| name | string | Yes | Name of the target app account. |
+| bundleName | string | Yes | Bundle name of the app. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.disableAppAccess("ZhangSan", "com.example.accountjsdemo", (err) => {
+ console.log("disableAppAccess err: " + JSON.stringify(err));
+ });
+ ```
+
+### disableAppAccess(deprecated)
+
+disableAppAccess(name: string, bundleName: string): Promise<void>
+
+Disables an app account from accessing an app. 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 [setAppAccess](#setappaccess9-1).
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---------- | ------ | ---- | ---------------- |
+| name | string | Yes | Name of the target app account.|
+| bundleName | string | Yes | Bundle name of the app. |
+
+**Return value**
+
+| Type | Description |
+| :------------------ | :-------------------- |
+| Promise<void> | Promise that returns no value.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.disableAppAccess("ZhangSan", "com.example.accountjsdemo").then(() => {
+ console.log('disableAppAccess Success');
+ }).catch((err) => {
+ console.log("disableAppAccess err: " + JSON.stringify(err));
+ });
+ ```
+
+### enableAppAccess(deprecated)
+
+enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void
+
+Enables an app account to access an app. 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 [setAppAccess](#setappaccess9).
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---------- | ------------------------- | ---- | --------------------------------- |
+| name | string | Yes | Name of the target app account. |
+| bundleName | string | Yes | Bundle name of the app. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.enableAppAccess("ZhangSan", "com.example.accountjsdemo", (err) => {
+ console.log("enableAppAccess: " + JSON.stringify(err));
+ });
+ ```
+
+### enableAppAccess(deprecated)
+
+enableAppAccess(name: string, bundleName: string): Promise<void>
+
+Enables an app account to access an app. 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 [setAppAccess](#setappaccess9-1).
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---------- | ------ | ---- | --------- |
+| name | string | Yes | Name of the target app account. |
+| bundleName | string | Yes | Bundle name of the app.|
+
+**Return value**
+
+| Type | Description |
+| :------------------ | :-------------------- |
+| Promise<void> | Promise that returns no value.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.enableAppAccess("ZhangSan", "com.example.accountjsdemo").then(() => {
+ console.log('enableAppAccess Success');
+ }).catch((err) => {
+ console.log("enableAppAccess err: " + JSON.stringify(err));
+ });
+ ```
+
+### checkAppAccountSyncEnable(deprecated)
+
+checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>): void
+
+Checks whether data synchronization is enabled for an app account. 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 [checkDataSyncEnabled](#checkdatasyncenabled9).
+
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------- | ---- | --------------------- |
+| name | string | Yes | Name of the target app account. |
+| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. The value **true** means data synchronization is enabled for the app account; the value **false** means the opposite.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.checkAppAccountSyncEnable("ZhangSan", (err, result) => {
+ console.log("checkAppAccountSyncEnable err: " + JSON.stringify(err));
+ console.log('checkAppAccountSyncEnable result: ' + result);
+ });
+ ```
+
+### checkAppAccountSyncEnable(deprecated)
+
+checkAppAccountSyncEnable(name: string): Promise<boolean>
+
+Checks whether data synchronization is enabled for an app account. 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 [checkDataSyncEnabled](#checkdatasyncenabled9-1).
+
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---- | ------ | ---- | ------- |
+| name | string | Yes | Name of the target app account.|
+
+**Return value**
+
+| Type | Description |
+| ---------------------- | --------------------- |
+| Promise<boolean> | Promise used to return the result. The value **true** means data synchronization is enabled for the app account; the value **false** means the opposite.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.checkAppAccountSyncEnable("ZhangSan").then((data) => {
+ console.log('checkAppAccountSyncEnable, result: ' + data);
+ }).catch((err) => {
+ console.log("checkAppAccountSyncEnable err: " + JSON.stringify(err));
+ });
+ ```
+
+### setAccountCredential(deprecated)
+
+setAccountCredential(name: string, credentialType: string, credential: string,callback: AsyncCallback<void>): void
+
+Set credentials for an app account. 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 [setCredential](#setcredential9).
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | ------------------------- | ---- | ------------- |
+| name | string | Yes | Name of the target app account. |
+| credentialType | string | Yes | Type of the credential to set. |
+| credential | string | Yes | Credential value. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001", (err) => {
+ console.log("setAccountCredential err: " + JSON.stringify(err));
+ });
+ ```
+
+### setAccountCredential(deprecated)
+
+setAccountCredential(name: string, credentialType: string, credential: string): Promise<void>
+
+Set credentials for an app account. 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 [setCredential](#setcredential9-1).
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | ------ | ---- | ---------- |
+| name | string | Yes | Name of the target app account. |
+| credentialType | string | Yes | Type of the credential to set.|
+| credential | string | Yes | Credential value.|
+
+**Return value**
+
+| Type | Description |
+| :------------------ | :-------------------- |
+| Promise<void> | Promise that returns no value.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001").then(() => {
+ console.log('setAccountCredential Success');
+ }).catch((err) => {
+ console.log("setAccountCredential err: " + JSON.stringify(err));
+ });
+ ```
+
+### setAccountExtraInfo(deprecated)
+
+setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback<void>): void
+
+Sets additional information for an app account. 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 [setCustomData](#setcustomdata9).
+
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| --------- | ------------------------- | ---- | --------------- |
+| name | string | Yes | Name of the target app account. |
+| extraInfo | string | Yes | Additional information (information that can be converted to the string type). It cannot contain sensitive information, such as the app account password and token. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002", (err) => {
+ console.log("setAccountExtraInfo err: " + JSON.stringify(err));
+ });
+ ```
+
+### setAccountExtraInfo(deprecated)
+
+setAccountExtraInfo(name: string, extraInfo: string): Promise<void>
+
+Sets additional information for an app account. 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 [setCustomData](#setcustomdata9-1).
+
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| --------- | ------ | ---- | --------- |
+| name | string | Yes | Name of the target app account. |
+| extraInfo | string | Yes | Additional information (information that can be converted to the string type). It cannot contain sensitive information, such as the app account password and token.|
+
+**Return value**
+
+| Type | Description |
+| :------------------ | :-------------------- |
+| Promise<void> | Promise that returns no value.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002").then(() => {
+ console.log('setAccountExtraInfo Success');
+ }).catch((err) => {
+ console.log("setAccountExtraInfo err: " + JSON.stringify(err));
+ });
+ ```
+
+### setAppAccountSyncEnable(deprecated)
+
+setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback<void>): void
+
+Sets data synchronization for an app account. 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 [setDataSyncEnabled](#setdatasyncenabled9).
+
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | ---- | ------------------------- |
+| name | string | Yes | Name of the target app account. |
+| isEnable | boolean | Yes | Whether to enable data synchronization. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.setAppAccountSyncEnable("ZhangSan", true, (err) => {
+ console.log("setAppAccountSyncEnable err: " + JSON.stringify(err));
+ });
+ ```
+
+### setAppAccountSyncEnable(deprecated)
+
+setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void>
+
+Sets data synchronization for an app account. 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 [setDataSyncEnabled](#setdatasyncenabled9-1).
+
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ------- | ---- | ----------- |
+| name | string | Yes | Name of the target app account. |
+| isEnable | boolean | Yes | Whether to enable data synchronization.|
+
+**Return value**
+
+| Type | Description |
+| :------------------ | :-------------------- |
+| Promise<void> | Promise that returns no value.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager .setAppAccountSyncEnable("ZhangSan", true).then(() => {
+ console.log('setAppAccountSyncEnable Success');
+ }).catch((err) => {
+ console.log("setAppAccountSyncEnable err: " + JSON.stringify(err));
+ });
+ ```
+
+### setAssociatedData(deprecated)
+
+setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback<void>): void
+
+Sets data to be associated with an app account. 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 [setCustomData](#setcustomdata9).
+
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | ---- | ----------------- |
+| name | string | Yes | Name of the target app account. |
+| key | string | Yes | Key of the data to set.|
+| value | string | Yes | Value of the data to set. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.setAssociatedData("ZhangSan", "k001", "v001", (err) => {
+ console.log("setAssociatedData err: " + JSON.stringify(err));
+ });
+ ```
+
+### setAssociatedData(deprecated)
+
+setAssociatedData(name: string, key: string, value: string): Promise<void>
+
+Sets data to be associated with an app account. 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 [setCustomData](#setcustomdata9-1).
+
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ----------------- |
+| name | string | Yes | Name of the target app account. |
+| key | string | Yes | Key of the data to set.|
+| value | string | Yes | Value of the data to set.|
+
+**Return value**
+
+| Type | Description |
+| :------------------ | :-------------------- |
+| Promise<void> | Promise that returns no value.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.setAssociatedData("ZhangSan", "k001", "v001").then(() => {
+ console.log('setAssociatedData Success');
+ }).catch((err) => {
+ console.log("setAssociatedData err: " + JSON.stringify(err));
+ });
+ ```
+
+### getAllAccessibleAccounts(deprecated)
+
+getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void
+
+Obtains information about all accessible app accounts. 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 [getAllAccounts](#getallaccounts9).
+
+**Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | --------- |
+| callback | AsyncCallback<Array<[AppAccountInfo](#appaccountinfo)>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is a list of accessible app accounts. Otherwise, **err** is an error object.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getAllAccessibleAccounts((err, data)=>{
+ console.debug("getAllAccessibleAccounts err:" + JSON.stringify(err));
+ console.debug("getAllAccessibleAccounts data:" + JSON.stringify(data));
+ });
+ ```
+
+### getAllAccessibleAccounts(deprecated)
+
+getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>>
+
+Obtains information about all accessible app accounts. 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 [getAllAccounts](#getallaccounts9-1).
+
+**Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Return value**
+
+| Type | Description |
+| ---------------------------------------- | --------------------- |
+| Promise<Array<[AppAccountInfo](#appaccountinfo)>> | Promise used to return the accessible app accounts.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getAllAccessibleAccounts().then((data) => {
+ console.log('getAllAccessibleAccounts: ' + data);
+ }).catch((err) => {
+ console.log("getAllAccessibleAccounts err: " + JSON.stringify(err));
+ });
+ ```
+
+### getAllAccounts(deprecated)
+
+getAllAccounts(owner: string, callback: AsyncCallback<Array<AppAccountInfo>>): void
+
+Obtains the app accounts that can be accessed by the invoker based on the app account owner. 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 [getAccountsByOwner](#getaccountsbyowner9).
+
+**Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | --------- |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
+| callback | AsyncCallback<Array<[AppAccountInfo](#appaccountinfo)>> | Yes | Callback invoked to return information about all accessible app accounts.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ const selfBundle = "com.example.actsgetallaaccounts";
+ appAccountManager.getAllAccounts(selfBundle, (err, data)=>{
+ console.debug("getAllAccounts err:" + JSON.stringify(err));
+ console.debug("getAllAccounts data:" + JSON.stringify(data));
+ });
+ ```
+
+### getAllAccounts(deprecated)
+
+getAllAccounts(owner: string): Promise<Array<AppAccountInfo>>
+
+Obtains the app accounts that can be accessed by the invoker based on the app account owner. 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 [getAccountsByOwner](#getaccountsbyowner9-1).
+
+**Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS (available only to system applications)
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ------ |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
+
+**Return value**
+
+| Type | Description |
+| ---------------------------------------- | --------------------- |
+| Promise<Array<[AppAccountInfo](#appaccountinfo)>> | Promise use to return the app accounts that can be accessed by the invoker.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ const selfBundle = "com.example.actsgetallaaccounts";
+ appAccountManager.getAllAccounts(selfBundle).then((data) => {
+ console.log('getAllAccounts: ' + data);
+ }).catch((err) => {
+ console.log("getAllAccounts err: " + JSON.stringify(err));
+ });
+ ```
+
+### getAccountCredential(deprecated)
+
+getAccountCredential(name: string, credentialType: string, callback: AsyncCallback<string>): void
+
+Obtains the credential of an app account. 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 [getCredential](#getcredential9).
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | --------------------------- | ---- | -------------- |
+| name | string | Yes | Name of the target app account. |
+| credentialType | string | Yes | Type of the credential to obtain.|
+| callback | AsyncCallback<string> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the credential obtained. Otherwise, **err** is an error object.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getAccountCredential("ZhangSan", "credentialType001", (err, result) => {
+ console.log("getAccountCredential err: " + JSON.stringify(err));
+ console.log('getAccountCredential result: ' + result);
+ });
+ ```
+
+### getAccountCredential(deprecated)
+
+getAccountCredential(name: string, credentialType: string): Promise<string>
+
+Obtains the credential of an app account. 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 [getCredential](#getcredential9-1).
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | ------ | ---- | ---------- |
+| name | string | Yes | Name of the target app account. |
+| credentialType | string | Yes | Type of the credential to obtain.|
+
+**Return value**
+
+| Type | Description |
+| :-------------------- | :-------------------- |
+| Promise<string> | Promise used to return the credential obtained.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getAccountCredential("ZhangSan", "credentialType001").then((data) => {
+ console.log('getAccountCredential, result: ' + data);
+ }).catch((err) => {
+ console.log("getAccountCredential err: " + JSON.stringify(err));
+ });
+ ```
+
+### getAccountExtraInfo(deprecated)
+
+getAccountExtraInfo(name: string, callback: AsyncCallback<string>): void
+
+Obtains additional information of an app account. Additional information refers to other information that can be converted to the string type. It cannot contain sensitive information, such as the app account password and token. 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 [getCustomData](#getcustomdata9).
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------- | ---- | --------------- |
+| name | string | Yes | Name of the target app account. |
+| callback | AsyncCallback<string> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the additional information obtained. Otherwise, **err** is an error object.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getAccountExtraInfo("ZhangSan", (err, result) => {
+ console.log("getAccountExtraInfo err: " + JSON.stringify(err));
+ console.log('getAccountExtraInfo result: ' + result);
+ });
+ ```
+
+### getAccountExtraInfo(deprecated)
+
+getAccountExtraInfo(name: string): Promise<string>
+
+Obtains additional information of an app account. Additional information refers to other information that can be converted to the string type. It cannot contain sensitive information, such as the app account password and token. 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 [getCustomData](#getcustomdata9-1).
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---- | ------ | ---- | ------- |
+| name | string | Yes | Name of the target app account.|
+
+**Return value**
+
+| Type | Description |
+| :-------------------- | :-------------------- |
+| Promise<string> | Promise used to return the additional information obtained.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getAccountExtraInfo("ZhangSan").then((data) => {
+ console.log('getAccountExtraInfo, result: ' + data);
+ }).catch((err) => {
+ console.log("getAccountExtraInfo err: " + JSON.stringify(err));
+ });
+ ```
+
+### getAssociatedData(deprecated)
+
+getAssociatedData(name: string, key: string, callback: AsyncCallback<string>): void
+
+Obtains data associated with an app account. 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 [getCustomData](#getcustomdata9).
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------- | ---- | ----------------- |
+| name | string | Yes | Name of the target app account. |
+| key | string | Yes | Key of the data to obtain. |
+| callback | AsyncCallback<string> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the data obtained. Otherwise, **err** is an error object.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getAssociatedData("ZhangSan", "k001", (err, result) => {
+ console.log("getAssociatedData err: " + JSON.stringify(err));
+ console.log('getAssociatedData result: ' + result);
+ });
+ ```
+
+### getAssociatedData(deprecated)
+
+getAssociatedData(name: string, key: string): Promise<string>
+
+Obtains data associated with an app account. 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 [getCustomData](#getcustomdata9-1).
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---- | ------ | ---- | --------- |
+| name | string | Yes | Name of the target app account. |
+| key | string | Yes | Key of the data to obtain.|
+
+**Return value**
+
+| Type | Description |
+| :-------------------- | :-------------------- |
+| Promise<string> | Promise used to return the data obtained.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getAssociatedData("ZhangSan", "k001").then((data) => {
+ console.log('getAssociatedData: ' + data);
+ }).catch((err) => {
+ console.log("getAssociatedData err: " + JSON.stringify(err));
+ });
+ ```
+
+### on('change')(deprecated)
+
+on(type: 'change', owners: Array<string>, callback: Callback<Array<AppAccountInfo>>): void
+
+Subscribes to account information changes of apps.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [on('accountChange')](#onaccountchange9).
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ------------------------------ |
+| type | 'change' | Yes | Event type to subscribe to. The value is **'change'**. An event will be reported when the account information changes.|
+| owners | Array<string> | Yes | App bundle names of the account. |
+| callback | Callback<Array<[AppAccountInfo](#appaccountinfo)>> | Yes | Callback invoked to return the account changes. |
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ function changeOnCallback(data){
+ console.debug("receive change data:" + JSON.stringify(data));
+ }
+ try{
+ appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback);
+ }
+ catch(err){
+ console.error("on accountOnOffDemo err:" + JSON.stringify(err));
+ }
+ ```
+
+### off('change')(deprecated)
+
+off(type: 'change', callback?: Callback>): void
+
+Unsubscribes from account information changes.
+
+> **NOTE**
+>
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [off('accountChange')](#offaccountchange9).
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | -------------------------------- | ---- | ------------ |
+| type | 'change' | Yes | Event type to unsubscribe from. The value is **'change'**, which indicates the account change event. |
+| callback | Callback> | No | Callback to unregister.|
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ function changeOnCallback(data){
+ console.debug("receive change data:" + JSON.stringify(data));
+ appAccountManager.off('change', function(){
+ console.debug("off finish");
+ })
+ }
+ try{
+ appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback);
+ }
+ catch(err){
+ console.error("on accountOnOffDemo err:" + JSON.stringify(err));
+ }
+ ```
+
+### authenticate(deprecated)
+
+authenticate(name: string, owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
+
+Authenticates an app account with customized options. 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 [auth](#auth9).
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | --------------------- | ---- | --------------- |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
+| authType | string | Yes | Authentication type. |
+| options | {[key: string]: any} | Yes | Options for the authentication. |
+| callback | [AuthenticatorCallback](#authenticatorcallbackdeprecated) | Yes | Callback invoked to return the result.|
+
+**Example**
+
+ ```js
+ import featureAbility from '@ohos.ability.featureAbility';
+
+ function onResultCallback(code, result) {
+ console.log("resultCode: " + code);
+ console.log("result: " + JSON.stringify(result));
+ }
+
+ function onRequestRedirectedCallback(request) {
+ let abilityStartSetting = {want: request};
+ featureAbility.startAbility(abilityStartSetting, (err)=>{
+ console.log("startAbility err: " + JSON.stringify(err));
+ });
+ }
+
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.authenticate("LiSi", "com.example.accountjsdemo", "getSocialData", {}, {
+ onResult: onResultCallback,
+ onRequestRedirected: onRequestRedirectedCallback
});
```
-### getOAuthList8+
+### getOAuthToken(deprecated)
-getOAuthList(name: string, authType: string, callback: AsyncCallback<Array<string>>): void
+getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback<string>): void
-Obtains a list of authorized OAuth tokens of an app account. This API uses an asynchronous callback to return the result.
+Obtains the authorization token of the specified authentication type for an app account. 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 [getAuthToken](#getauthtoken9).
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ---------------------------------------- | ---- | ----------------------- |
-| name | string | Yes | Name of the target app account. |
-| authType | string | Yes | Authorization type.|
-| callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------- | ---- | ----------- |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
+| authType | string | Yes | Authentication type. |
+| callback | AsyncCallback<string> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the authorization token value obtained. Otherwise, **err** is an error object. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "getSocialData", (err, data) => {
- console.log('getOAuthList err: ' + JSON.stringify(err));
- console.log('getOAuthList data: ' + JSON.stringify(data));
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getOAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData", (err, data) => {
+ console.log('getOAuthToken err: ' + JSON.stringify(err));
+ console.log('getOAuthToken token: ' + data);
});
```
-### getOAuthList8+
+### getOAuthToken(deprecated)
-getOAuthList(name: string, authType: string): Promise<Array<string>>
+getOAuthToken(name: string, owner: string, authType: string): Promise<string>
-Obtains a list of authorized OAuth tokens of an app account. This API uses a promise to return the result.
+Obtains the authorization token of the specified authentication type for an app account. This API uses a promise to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getAuthToken](#getauthtoken9-1).
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ------ | ---- | ----------------------- |
-| name | string | Yes | Name of the target app account. |
-| authType | string | Yes | Authorization type.|
+| Name | Type | Mandatory | Description |
+| -------- | ------ | ---- | ----------- |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
+| authType | string | Yes | Authentication type. |
-**Parameters**
+**Return value**
-| Type | Description |
-| ---------------------------------- | --------------------- |
-| Promise<Array<string>> | Promise used to return the result.|
+| Type | Description |
+| --------------------- | --------------------- |
+| Promise<string> | Promise used to return the result.|
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "getSocialData").then((data) => {
- console.log('getOAuthList data: ' + JSON.stringify(data));
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getOAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData").then((data) => {
+ console.log('getOAuthToken token: ' + data);
}).catch((err) => {
- console.log("getOAuthList err: " + JSON.stringify(err));
+ console.log("getOAuthToken err: " + JSON.stringify(err));
});
```
-### getAuthenticatorCallback8+
+### setOAuthToken(deprecated)
-getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<AuthenticatorCallback>): void
+setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback<void>): void
-Obtains the authenticator callback for an authentication session. This API uses an asynchronous callback to return the result.
+Sets an authorization token of the specific authentication type for an app account. 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 [setAuthToken](#setauthtoken9).
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| --------- | ---------------------------------------- | ---- | -------- |
-| sessionId | string | Yes | ID of the authentication session.|
-| callback | AsyncCallback<[AuthenticatorCallback](#authenticatorcallback8)> | Yes | Callback invoked to return the result.|
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | ---- | -------- |
+| name | string | Yes | Name of the target app account.|
+| authType | string | Yes | Authentication type. |
+| token | string | Yes | Token to set.|
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
**Example**
```js
- import featureAbility from '@ohos.ability.featureAbility';
- const appAccountManager = account_appAccount.createAppAccountManager();
- featureAbility.getWant((err, want) => {
- var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
- appAccountManager.getAuthenticatorCallback(sessionId, (err, callback) => {
- if (err.code != account_appAccount.ResultCode.SUCCESS) {
- console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
- return;
- }
- var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
- [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
- [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData",
- [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
- callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.setOAuthToken("LiSi", "getSocialData", "xxxx", (err) => {
+ console.log('setOAuthToken err: ' + JSON.stringify(err));
});
```
-### getAuthenticatorCallback8+
+### setOAuthToken(deprecated)
-getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback>
+setOAuthToken(name: string, authType: string, token: string): Promise<void>
-Obtains the authenticator callback for an authentication session. This API uses a promise to return the result.
+Sets an authorization token of the specific authentication type for an app account. This API uses a promise to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [setAuthToken](#setauthtoken9-1).
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| --------- | ------ | ---- | -------- |
-| sessionId | string | Yes | ID of the authentication session.|
+| Name | Type | Mandatory | Description |
+| -------- | ------ | ---- | -------- |
+| name | string | Yes | Name of the target app account.|
+| authType | string | Yes | Authentication type. |
+| token | string | Yes | Authorization token to set.|
-**Parameters**
+**Return value**
-| Type | Description |
-| ------------------------------------ | --------------------- |
-| Promise<[AuthenticatorCallback](#authenticatorcallback8)> | Promise used to return the result.|
+| Type | Description |
+| ------------------- | --------------------- |
+| Promise<void> | Promise that returns no value.|
**Example**
```js
- import featureAbility from '@ohos.ability.featureAbility';
-
- const appAccountManager = account_appAccount.createAppAccountManager();
- featureAbility.getWant().then((want) => {
- var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
- appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
- var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
- [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
- [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData",
- [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
- callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
- }).catch((err) => {
- console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
- });
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.setOAuthToken("LiSi", "getSocialData", "xxxx").then(() => {
+ console.log('setOAuthToken successfully');
}).catch((err) => {
- console.log("getWant err: " + JSON.stringify(err));
+ console.log('setOAuthToken err: ' + JSON.stringify(err));
});
```
-### getAuthenticatorInfo8+
+### deleteOAuthToken(deprecated)
-getAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo>): void
+deleteOAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback<void>): void
+
+Deletes the authorization token of the specified authentication type for an app account. This API uses an asynchronous callback to return the result.
-Obtains authenticator information of an app account. 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 [deleteAuthToken](#deleteauthtoken9).
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | -------------------------------------- | ---- | ----------- |
-| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
-| callback | AsyncCallback<[AuthenticatorInfo](#authenticatorinfo8)> | Yes | Callback invoked to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | ---- | ------------ |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
+| authType | string | Yes | Authentication type. |
+| token | string | Yes | Authorization token to delete.|
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo", (err, data) => {
- console.log("getAuthenticatorInfo err: " + JSON.stringify(err));
- console.log('getAuthenticatorInfo data: ' + JSON.stringify(data));
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.deleteOAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData", "xxxxx", (err) => {
+ console.log('deleteOAuthToken err: ' + JSON.stringify(err));
});
```
-### getAuthenticatorInfo8+
+### deleteOAuthToken(deprecated)
-getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo>
+deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise<void>
+
+Deletes the authorization token of the specified authentication type for an app account. This API uses a promise to return the result.
-Obtains authenticator information of an app account. This API uses a promise to return the result.
+> **NOTE**
+>
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [deleteAuthToken](#deleteauthtoken9-1).
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| ----- | ------ | ---- | ----------- |
-| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
+| Name | Type | Mandatory | Description |
+| -------- | ------ | ---- | ------------ |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
+| authType | string | Yes | Authentication type. |
+| token | string | Yes | Authorization token to delete.|
-**Parameters**
+**Return value**
-| Type | Description |
-| -------------------------------- | --------------------- |
-| Promise<[AuthenticatorInfo](#authenticatorinfo8)> | Promise used to return the result.|
+| Type | Description |
+| ------------------- | --------------------- |
+| Promise<void> | Promise that returns no value.|
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo").then((data) => {
- console.log('getAuthenticatorInfo: ' + JSON.stringify(data));
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.deleteOAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData", "xxxxx").then(() => {
+ console.log('deleteOAuthToken successfully');
}).catch((err) => {
- console.log("getAuthenticatorInfo err: " + JSON.stringify(err));
+ console.log("deleteOAuthToken err: " + JSON.stringify(err));
});
```
-### checkAppAccess9+
+### setOAuthTokenVisibility(deprecated)
-checkAppAccess(name: string, bundleName: string, callback: AsyncCallback<boolean>): void
+setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback<void>): void
+
+Sets the visibility of an authorization token to an app. This API uses an asynchronous callback to return the result.
-Checks whether an app account is authorized to access an app. 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 [setAuthTokenVisibility](#setauthtokenvisibility9).
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ---------------------------- | ----- | ---------------- |
-| name | string | Yes | Name of the target app account. |
-| bundleName | string | Yes | Bundle name of the app to access. |
-| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. |
+| Name | Type | Mandatory | Description |
+| ---------- | ------------------------- | ---- | ------------------------- |
+| name | string | Yes | Name of the target app account. |
+| authType | string | Yes | Authentication type. |
+| bundleName | string | Yes | Bundle name of the app. |
+| isVisible | boolean | Yes | Whether the authorization token is visible to the app. The value **true** means the authorization token is visible to the app; the value **false** means the opposite.|
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.checkAppAccess("zhangsan", "com.example.ohos.accountjsdemo", (err, data) => {
- console.log('checkAppAccess: ' + JSON.stringify(data));
- console.log("checkAppAccess err: " + JSON.stringify(err));
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.setOAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo", true, (err) => {
+ console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err));
});
```
-### checkAppAccess9+
+### setOAuthTokenVisibility(deprecated)
-checkAppAccess(name: string, bundleName: string): Promise<boolean>
+setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise<void>
+
+Sets the visibility of an authorization token to an app. This API uses a promise to return the result.
-Checks whether an app account is authorized to access an app. This API uses a promise to return the result.
+> **NOTE**
+>
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [setAuthTokenVisibility](#setauthtokenvisibility9-1).
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| ---------- | ------ | ----- | ---------------- |
-| name | string | Yes | Name of the target app account. |
-| bundleName | string | Yes | Bundle name of the app to access. |
+| Name | Type | Mandatory | Description |
+| ---------- | ------- | ---- | ------------ |
+| name | string | Yes | Name of the target app account. |
+| authType | string | Yes | Authentication type. |
+| bundleName | string | Yes | Bundle name of the app.|
+| isVisible | boolean | Yes | Whether the authorization token is visible to the app. The value **true** means the authorization token is visible to the app; the value **false** means the opposite. |
-**Parameters**
+**Return value**
-| Type | Description |
-| ---------------------- | --------------------------------- |
-| Promise<boolean> | Promise used to return the result.|
+| Type | Description |
+| ------------------- | --------------------- |
+| Promise<void> | Promise that returns no value.|
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.checkAppAccess("zhangsan", "com.example.ohos.accountjsdemo").then((data) => {
- console.log('checkAppAccess: ' + JSON.stringify(data));
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.setOAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo", true).then(() => {
+ console.log('setOAuthTokenVisibility successfully');
}).catch((err) => {
- console.log("checkAppAccess err: " + JSON.stringify(err));
+ console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err));
});
```
-### deleteAccountCredential9+
+### checkOAuthTokenVisibility(deprecated)
-deleteAccountCredential(name: string, credentialType: string, callback: AsyncCallback<void>): void
+checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback<boolean>): void
+
+Checks the visibility of an authorization token of the specified authentication type to an app. This API uses an asynchronous callback to return the result.
-Deletes the credential of an app account. 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 [checkAuthTokenVisibility](#checkauthtokenvisibility9).
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------------- | ------------------------- | ----- | -------------- |
-| name | string | Yes | Name of the target app account.|
-| credentialType | string | Yes | Type of the credential to delete. |
-| callback | AsyncCallback<void> | Yes | Callback invoked to return the result.|
+| Name | Type | Mandatory | Description |
+| ---------- | ---------------------------- | ---- | ----------- |
+| name | string | Yes | Name of the target app account. |
+| authType | string | Yes | Authentication type. |
+| bundleName | string | Yes | Bundle name of the app.|
+| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** can be **true** (the authorization token is visible to the app) or **false** (the authorization token is not visible to the app). If the operation fails, **err** is an error object. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.deleteAccountCredential("zhangsan", "pin", (err, data) => {
- console.log('deleteAccountCredential: ' + JSON.stringify(data));
- console.log("deleteAccountCredential err: " + JSON.stringify(err));
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.checkOAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo", (err, data) => {
+ console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err));
+ console.log('checkOAuthTokenVisibility isVisible: ' + data);
});
```
-### deleteAccountCredential9+
+### checkOAuthTokenVisibility(deprecated)
+
+checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise<boolean>
-deleteAccountCredential(name: string, credentialType: string): Promise<void>
+Checks the visibility of an authorization token of the specified authentication type to an app. This API uses a promise to return the result.
-Deletes the credential of an app account. This API uses a promise to return the result.
+> **NOTE**
+>
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [checkAuthTokenVisibility](#checkauthtokenvisibility9-1).
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------------- | ------ | ----- | --------------- |
-| name | string | Yes | Name of the target app account.|
-| credentialType | string | Yes | Type of the credential to delete. |
+| Name | Type | Mandatory | Description |
+| ---------- | ------ | ---- | ------------- |
+| name | string | Yes | Name of the target app account. |
+| authType | string | Yes | Authentication type. |
+| bundleName | string | Yes | Bundle name of the app.|
-**Parameters**
+**Return value**
-| Type | Description |
-| ------------------- | -------------------------------- |
-| Promise<void> | Promise used to return the result.|
+| Type | Description |
+| ---------------------- | --------------------- |
+| Promise<boolean> | Promise used to return the result. The value **true** means the authorization token is visible to the app; the value **false** means the opposite.|
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.deleteAccountCredential("zhangsan", "pin").then((data) => {
- console.log('deleteAccountCredential: ' + JSON.stringify(data));
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.checkOAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo").then((data) => {
+ console.log('checkOAuthTokenVisibility isVisible: ' + data);
}).catch((err) => {
- console.log("deleteAccountCredential err: " + JSON.stringify(err));
+ console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err));
});
```
-### checkAccountLabels9+
+### getAllOAuthTokens(deprecated)
-checkAccountLabels(name: string, owner: string, labels: Array<string>, callback: AsyncCallback<boolean>): void;
+getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array<OAuthTokenInfo>>): void
+
+Obtains all tokens visible to the invoker for an app account. This API uses an asynchronous callback to return the result.
-Checks whether an app account has specific labels. 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 [getAllAuthTokens](#getallauthtokens9).
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------------- | ------------------------- | ----- | --------------- |
-| name | string | Yes | Name of the target app account. |
-| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
-| labels | Array<string> | Yes | Labels to check. |
-| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ----------- |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
+| callback | AsyncCallback<Array<[OAuthTokenInfo](#oauthtokeninfodeprecated)>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is a list of all tokens visible to the invoker. Otherwise, **err** is an error object. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- var labels = ["student"];
- appAccountManager.checkAccountLabels("zhangsan", "com.example.ohos.accountjsdemo", labels, (err, data) => {
- console.log('checkAccountLabels: ' + JSON.stringify(data));
- console.log("checkAccountLabels err: " + JSON.stringify(err));
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getAllOAuthTokens("LiSi", "com.example.accountjsdemo", (err, data) => {
+ console.log("getAllOAuthTokens err: " + JSON.stringify(err));
+ console.log('getAllOAuthTokens data: ' + JSON.stringify(data));
});
```
-### checkAccountLabels9+
+### getAllOAuthTokens(deprecated)
-checkAccountLabels(name: string, owner: string, labels: Array<string>): Promise<boolean>
+getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenInfo>>
-Checks whether an app account has specific labels. This API uses a promise to return the result.
+Obtains all tokens visible to the invoker for an app account. This API uses a promise to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getAllAuthTokens](#getallauthtokens9-1).
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------------- | ------------------------- | ----- | --------------- |
-| name | string | Yes | Name of the target app account. |
-| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
-| labels | Array<string> | Yes | Labels to check. |
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ----------- |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
-**Parameters**
+**Return value**
-| Type | Description |
-| ------------------- | -------------------------------- |
-| Promise<boolean> | Promise used to return the result.|
+| Type | Description |
+| ---------------------------------------- | --------------------- |
+| Promise<Array< [OAuthTokenInfo](#oauthtokeninfodeprecated)>> | Promise used to return the tokens obtained.|
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- var labels = ["student"];
- appAccountManager.checkAccountLabels("zhangsan", "com.example.ohos.accountjsdemo", labels).then((data) => {
- console.log('checkAccountLabels: ' + JSON.stringify(data));
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getAllOAuthTokens("LiSi", "com.example.accountjsdemo").then((data) => {
+ console.log('getAllOAuthTokens data: ' + JSON.stringify(data));
}).catch((err) => {
- console.log("checkAccountLabels err: " + JSON.stringify(err));
+ console.log("getAllOAuthTokens err: " + JSON.stringify(err));
});
```
-### selectAccountsByOptions9+
+### getOAuthList(deprecated)
+
+getOAuthList(name: string, authType: string, callback: AsyncCallback<Array<string>>): void
-selectAccountsByOptions(options: SelectAccountsOptions, callback: AsyncCallback<Array<AppAccountInfo>>);
+Obtains the authorization list of the specified authentication type for an app account. The authorization list contains all authorized bundles. The token authorization list is set by setOAuthTokenVisibility(#setoauthtokenvisibilitydeprecated). This API uses an asynchronous callback to return the result.
-Selects the accounts accessible to the requester based on the options. 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 [getAuthList](#getauthlist9).
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------------- | ----------------------------------- | ----- | --------------- |
-| options | SelectAccountsOptions | Yes | Options for selecting accounts. |
-| callback | AsyncCallback<[AppAccountInfo](#appaccountinfo)> | Yes | Callback invoked to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ----------------------- |
+| name | string | Yes | Name of the target app account. |
+| authType | string | Yes | Authentication type.|
+| callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is a list of authorized bundles obtained. Otherwise, **err** is an error object. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- var options = {
- allowedOwners: ["com.example.ohos.accountjsdemo"]
- };
- appAccountManager.selectAccountsByOptions(options, (err, data) => {
- console.log('selectAccountsByOptions: ' + JSON.stringify(data));
- console.log("selectAccountsByOptions err: " + JSON.stringify(err));
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getOAuthList("com.example.accountjsdemo", "getSocialData", (err, data) => {
+ console.log('getOAuthList err: ' + JSON.stringify(err));
+ console.log('getOAuthList data: ' + JSON.stringify(data));
});
```
-### selectAccountsByOptions9+
+### getOAuthList(deprecated)
-selectAccountsByOptions(options: SelectAccountsOptions): Promise<Array<AppAccountInfo>>
+getOAuthList(name: string, authType: string): Promise<Array<string>>
-Selects the accounts accessible to the requester based on the options. This API uses a promise to return the result.
+Obtains the authorization list of the specified authentication type for an app account. The authorization list contains all authorized bundles. The token authorization list is set by setOAuthTokenVisibility(#setoauthtokenvisibilitydeprecated). This API uses a promise to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getAuthList](#getauthlist9-1).
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------------- | ------------------------- | ----- | --------------- |
-| options | [SelectAccountsOptions](#selectaccountsoptions9) | Yes | Options for selecting accounts. |
+| Name | Type | Mandatory | Description |
+| -------- | ------ | ---- | ----------------------- |
+| name | string | Yes | Name of the target app account. |
+| authType | string | Yes | Authentication type.|
-**Parameters**
+**Return value**
-| Type | Description |
-| ------------------- | -------------------------------- |
-| Promise<[AppAccountInfo](#appaccountinfo)> | Promise used to return the result.|
+| Type | Description |
+| ---------------------------------- | --------------------- |
+| Promise<Array<string>> | Promise used to return a list of authorized bundles.|
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- var options = {
- allowedOwners: ["com.example.ohos.accountjsdemo"]
- };
- appAccountManager.selectAccountsByOptions(options).then((data) => {
- console.log('selectAccountsByOptions: ' + JSON.stringify(data));
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getOAuthList("com.example.accountjsdemo", "getSocialData").then((data) => {
+ console.log('getOAuthList data: ' + JSON.stringify(data));
}).catch((err) => {
- console.log("selectAccountsByOptions err: " + JSON.stringify(err));
+ console.log("getOAuthList err: " + JSON.stringify(err));
});
```
-### verifyCredential9+
+### getAuthenticatorCallback(deprecated)
-verifyCredential(name: string, owner: string, callback: AuthenticatorCallback): void;
+getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<AuthenticatorCallback>): void
-Verifies the user credential. This API uses an asynchronous callback to return the result.
+Obtains the authenticator callback for an authentication session. 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 [getAuthCallback](#getauthcallback9).
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | --------------------- | ----- | ----------------------- |
-| name | string | Yes | Name of the target app account. |
-| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
-| callback | [AuthenticatorCallback](#authenticatorcallback8) | Yes | Authenticator callback invoked to return the verification result.|
+| Name | Type | Mandatory | Description |
+| --------- | ---------------------------------------- | ---- | -------- |
+| sessionId | string | Yes | ID of the authentication session.|
+| callback | AsyncCallback<[AuthenticatorCallback](#authenticatorcallbackdeprecated)> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the authenticator callback obtained. Otherwise, **err** is an error object.|
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.verifyCredential("zhangsan", "com.example.ohos.accountjsdemo", {
- onResult: (resultCode, result) => {
- console.log("verifyCredential onResult, resultCode:" + JSON.stringify(resultCode));
- console.log("verifyCredential onResult, result:" + JSON.stringify(result));
- },
- onRequestRedirected: (request) => {
- console.log("verifyCredential onRequestRedirected, request:" + JSON.stringify(request));
- }
+ import featureAbility from '@ohos.ability.featureAbility';
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ featureAbility.getWant((err, want) => {
+ var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
+ appAccountManager.getAuthenticatorCallback(sessionId, (err, callback) => {
+ if (err.code != account_appAccount.ResultCode.SUCCESS) {
+ console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
+ return;
+ }
+ var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
+ [account_appAccount.Constants.KEY_OWNER]: "com.example.accountjsdemo",
+ [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData",
+ [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
+ callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
+ });
});
```
-### verifyCredential9+
+### getAuthenticatorCallback(deprecated)
-verifyCredential(name: string, owner: string, options: VerifyCredentialOptions, callback: AuthenticatorCallback): void;
+getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback>
-Verifies the user credential. This API uses an asynchronous callback to return the result.
+Obtains the authenticator callback for an authentication session. This API uses a promise to return the result.
+
+> **NOTE**
+>
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getAuthCallback](#getauthcallback9-1).
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ----------------------- | ----- | ----------------------- |
-| name | string | Yes | Name of the target app account. |
-| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
-| options | [VerifyCredentialOptions](#verifycredentialoptions9) | Yes | Options for verifying the user credential. |
-| callback | [AuthenticatorCallback](#authenticatorcallback8) | Yes | Authenticator callback invoked to return the verification result.|
+| Name | Type | Mandatory | Description |
+| --------- | ------ | ---- | -------- |
+| sessionId | string | Yes | ID of the authentication session.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------------------ | --------------------- |
+| Promise<[AuthenticatorCallback](#authenticatorcallbackdeprecated)> | Promise used to return the authenticator callback obtained.|
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- var options = {
- credentialType: "pin",
- credential: "123456"
- };
- appAccountManager.verifyCredential("zhangsan", "com.example.ohos.accountjsdemo", options, {
- onResult: (resultCode, result) => {
- console.log("verifyCredential onResult, resultCode:" + JSON.stringify(resultCode));
- console.log("verifyCredential onResult, result:" + JSON.stringify(result));
- },
- onRequestRedirected: (request) => {
- console.log("verifyCredential onRequestRedirected, request:" + JSON.stringify(request));
- }
+ import featureAbility from '@ohos.ability.featureAbility';
+
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ featureAbility.getWant().then((want) => {
+ var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
+ appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
+ var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
+ [account_appAccount.Constants.KEY_OWNER]: "com.example.accountjsdemo",
+ [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData",
+ [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
+ callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
+ }).catch((err) => {
+ console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
+ });
+ }).catch((err) => {
+ console.log("getWant err: " + JSON.stringify(err));
});
```
-### setAuthenticatorProperties9+
+### getAuthenticatorInfo(deprecated)
+
+getAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo>): void
-setAuthenticatorProperties(owner: string, callback: AuthenticatorCallback): void;
+Obtains the authenticator information of an app. This API uses an asynchronous callback to return the result.
-Sets authenticator properties. 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 [queryAuthenticatorInfo](#queryauthenticatorinfo9).
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | --------------------- | ----- | ----------------------- |
-| owner | string | Yes | Owner of the authenticator. |
-| options | [SetPropertiesOptions](#setpropertiesoptions9) | Yes | Authenticator properties to set. |
-| callback | [AuthenticatorCallback](#authenticatorcallback8) | Yes | Authenticator callback invoked to return the result.|
+| Name | Type | Mandatory | Description |
+| -------- | -------------------------------------- | ---- | ----------- |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
+| callback | AsyncCallback<[AuthenticatorInfo](#authenticatorinfo8)> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the authenticator information obtained. Otherwise, **err** is an error object. |
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.setAuthenticatorProperties("com.example.ohos.accountjsdemo", {
- onResult: (resultCode, result) => {
- console.log("setAuthenticatorProperties onResult, resultCode:" + JSON.stringify(resultCode));
- console.log("setAuthenticatorProperties onResult, result:" + JSON.stringify(result));
- },
- onRequestRedirected: (request) => {
- console.log("setAuthenticatorProperties onRequestRedirected, request:" + JSON.stringify(request));
- }
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getAuthenticatorInfo("com.example.accountjsdemo", (err, data) => {
+ console.log("getAuthenticatorInfo err: " + JSON.stringify(err));
+ console.log('getAuthenticatorInfo data: ' + JSON.stringify(data));
});
```
-### setAuthenticatorProperties9+
+### getAuthenticatorInfo(deprecated)
+
+getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo>
-setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callback: AuthenticatorCallback): void;
+Obtains the authenticator information of an app. This API uses a promise to return the result.
-Sets authenticator properties. 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 [queryAuthenticatorInfo](#queryauthenticatorinfo9-1).
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | --------------------- | ----- | ----------------------- |
-| owner | string | Yes | Owner of the authenticator. |
-| options | [SetPropertiesOptions](#setpropertiesoptions9) | Yes | Authenticator properties to set. |
-| callback | [AuthenticatorCallback](#authenticatorcallback8) | Yes | Authenticator callback invoked to return the result.|
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ----------- |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
+
+**Return value**
+
+| Type | Description |
+| -------------------------------- | --------------------- |
+| Promise<[AuthenticatorInfo](#authenticatorinfo8)> | Promise used to return the authenticator information obtained.|
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
- var options = {
- properties: {"prop1": "value1"}
- };
- appAccountManager.setAuthenticatorProperties("com.example.ohos.accountjsdemo", options, {
- onResult: (resultCode, result) => {
- console.log("setAuthenticatorProperties onResult, resultCode:" + JSON.stringify(resultCode));
- console.log("setAuthenticatorProperties onResult, result:" + JSON.stringify(result));
- },
- onRequestRedirected: (request) => {
- console.log("setAuthenticatorProperties onRequestRedirected, request:" + JSON.stringify(request));
- }
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getAuthenticatorInfo("com.example.accountjsdemo").then((data) => {
+ console.log('getAuthenticatorInfo: ' + JSON.stringify(data));
+ }).catch((err) => {
+ console.log("getAuthenticatorInfo err: " + JSON.stringify(err));
});
```
@@ -1979,19 +4505,35 @@ Defines app account information.
| Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ----------- |
| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
-| name | string | Yes | Name of the app account. |
+| name | string | Yes | Name of the target app account. |
+
+## AuthTokenInfo9+
+
+Defines authorization token information.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+| Name | Type | Mandatory | Description |
+| -------------------- | -------------- | ----- | ---------------- |
+| authType9+ | string | Yes | Authentication type. |
+| token9+ | string | Yes | Value of the authorization token. |
+| account9+ | [AppAccountInfo](#appaccountinfo) | No | Account information of the authorization token.|
+
+## OAuthTokenInfo(deprecated)
-## OAuthTokenInfo8+
+Defines authorization token information.
-Defines OAuth token information.
+> **NOTE**
+>
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [AuthTokenInfo](#authtokeninfo9).
**System capability**: SystemCapability.Account.AppAccount
| Name | Type | Mandatory | Description |
| -------------------- | -------------- | ----- | ---------------- |
| authType | string | Yes | Authentication type. |
-| token | string | Yes | Value of the token. |
-| account9+ | AppAccountInfo | No | Account information of the token.|
+| token | string | Yes | Value of the authorization token. |
+| account9+ | [AppAccountInfo](#appaccountinfo) | No | Account information of the authorization token.|
## AuthenticatorInfo8+
@@ -2005,9 +4547,41 @@ Defines OAuth authenticator information.
| iconId | number | Yes | ID of the authenticator icon. |
| labelId | number | Yes | ID of the authenticator label. |
+## AuthResult9+
+
+Defines the authentication result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+| Name | Type | Mandatory | Description |
+| ------- | ------ | ---- | ---------- |
+| account | [AppAccountInfo](#appaccountinfo) | No | Account information of the authorization token.|
+| tokenInfo | [AuthTokenInfo](#authtokeninfo9) | No | Token information. |
+
+## CreateAccountOptions9+
+
+Defines the options for creating an app account.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+| Name | Type | Mandatory | Description |
+| ------- | ------ | ---- | ---------- |
+| customData | {[key: string]: string} | No | Custom data.|
+
+## CreateAccountImplicitlyOptions9+
+
+Defines the options for implicitly creating an app account.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+| Name | Type | Mandatory | Description |
+| ------- | ------ | ---- | ---------- |
+| requiredLabels | Array<string> | No | Labels required.|
+| authType | string | No | Authentication type.|
+| parameters | {[key: string]: Object} | No | Customized parameters.|
## SelectAccountsOptions9+
-Represents the options for selecting accounts.
+Defines the options for selecting accounts.
**System capability**: SystemCapability.Account.AppAccount
@@ -2027,7 +4601,7 @@ Represents the options for verifying the user credential.
| -------------- | ---------------------- | ----- | -------------- |
| credentialType | string | No | Type of the credential to verify. |
| credential | string | No | Credential value. |
-| parameters | {[key:string]: Object} | No | Customized parameters.|
+| parameters | {[key: string]: Object} | No | Customized parameters.|
## SetPropertiesOptions9+
@@ -2038,8 +4612,8 @@ Represents the options for setting authenticator properties.
| Name | Type | Mandatory | Description |
| ---------- | ---------------------- | ----- | -------------- |
-| properties | {[key:string]: Object} | No | Authenticator properties. |
-| parameters | {[key:string]: Object} | No | Customized parameters.|
+| properties | {[key: string]: Object} | No | Authenticator properties. |
+| parameters | {[key: string]: Object} | No | Customized parameters.|
## Constants8+
@@ -2047,12 +4621,16 @@ Enumerates the constants.
**System capability**: SystemCapability.Account.AppAccount
-| Name | Default Value | Description |
+| Name | Value | Description |
| -------------------------------- | ---------------------- | ----------------------- |
-| ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | Operation of adding an account implicitly. |
-| ACTION_AUTHENTICATE | "authenticate" | Authentication operation. |
-| KEY_NAME | "name" | App account name. |
-| KEY_OWNER | "owner" | Owner of an app account.|
+| ACTION_ADD_ACCOUNT_IMPLICITLY(deprecated) | "addAccountImplicitly" | Operation of adding an account implicitly. |
+| ACTION_AUTHENTICATE(deprecated) | "authenticate" | Authentication operation. |
+| ACTION_CREATE_ACCOUNT_IMPLICITLY9+ | "createAccountImplicitly" | Operation of creating an account implicitly. |
+| ACTION_AUTH9+ | "auth" | Authentication operation. |
+| ACTION_VERIFY_CREDENTIAL9+ | "verifyCredential" | Operation of verifying credentials. |
+| ACTION_SET_AUTHENTICATOR_PROPERTIES9+ | "setAuthenticatorProperties" | Operation of setting authenticator properties. |
+| KEY_NAME | "name" | Name of the app account. |
+| KEY_OWNER | "owner" | Owner of the app account.|
| KEY_TOKEN | "token" | Token. |
| KEY_ACTION | "action" | Operation. |
| KEY_AUTH_TYPE | "authType" | Authentication type. |
@@ -2069,7 +4647,7 @@ Enumerates the result codes.
**System capability**: SystemCapability.Account.AppAccount
-| Name | Default Value | Description |
+| Name | Value | Description |
| ----------------------------------- | ----- | ------------ |
| SUCCESS | 0 | The operation is successful. |
| ERROR_ACCOUNT_NOT_EXIST | 10001 | The app account does not exist. |
@@ -2085,16 +4663,122 @@ Enumerates the result codes.
| ERROR_OAUTH_SERVICE_EXCEPTION | 10011 | The OAuth service is abnormal. |
| ERROR_OAUTH_SESSION_NOT_EXIST | 10012 | The session to be authenticated does not exist. |
| ERROR_OAUTH_TIMEOUT | 10013 | The authentication timed out. |
-| ERROR_OAUTH_TOKEN_NOT_EXIST | 10014 | The OAuth token does not exist.|
+| ERROR_OAUTH_TOKEN_NOT_EXIST | 10014 | The authorization token does not exist.|
| ERROR_OAUTH_TOKEN_TOO_MANY | 10015 | The number of OAuth tokens reaches the limit. |
| ERROR_OAUTH_UNSUPPORT_ACTION | 10016 | The authentication operation is not supported. |
| ERROR_OAUTH_UNSUPPORT_AUTH_TYPE | 10017 | The authentication type is not supported. |
| ERROR_PERMISSION_DENIED | 10018 | The required permission is missing. |
-## AuthenticatorCallback8+
+## AuthCallback9+
+
+Implements authenticator callbacks.
+
+### onResult9+
+
+onResult: (code: number, result?: AuthResult) => void
+
+Called to return the result of an authentication request.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------ | -------------------- | ---- | ------ |
+| code | number | Yes | Authentication result code.|
+| result | [AuthResult](#authresult9) | No | Authentication result. |
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ var sessionId = "1234";
+ appAccountManager.getAuthCallback(sessionId).then((callback) => {
+ var result = {
+ accountInfo: {
+ name: "Lisi",
+ owner: "com.example.accountjsdemo",
+ },
+ tokenInfo: {
+ token: "xxxxxx",
+ authType: "getSocialData"
+ }
+ };
+ callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
+ }).catch((err) => {
+ console.log("getAuthCallback err: " + JSON.stringify(err));
+ });
+ ```
+
+### onRequestRedirected9+
+
+onRequestRedirected: (request: Want) => void
+
+Called to redirect a request.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------- | ---- | ---- | ---------- |
+| request | Want | Yes | Request to be redirected.|
+
+**Example**
+
+ ```js
+ class MyAuthenticator extends account_appAccount.Authenticator {
+ createAccountImplicitly(options, callback) {
+ callback.onRequestRedirected({
+ bundleName: "com.example.accountjsdemo",
+ abilityName: "com.example.accountjsdemo.LoginAbility",
+ });
+ }
+
+ auth(name, authType, options, callback) {
+ var result = {
+ accountInfo: {
+ name: "Lisi",
+ owner: "com.example.accountjsdemo",
+ },
+ tokenInfo: {
+ token: "xxxxxx",
+ authType: "getSocialData"
+ }
+ };
+ callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
+ }
+ }
+ ```
+
+### onRequestContinued9+
+
+onRequestContinued?: () => void
+
+Called to continue to process the request.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Example**
+
+ ```js
+ let appAccountManager = account_appAccount.createAppAccountManager();
+ var sessionId = "1234";
+ appAccountManager.getAuthCallback(sessionId).then((callback) => {
+ callback.onRequestContinued();
+ }).catch((err) => {
+ console.log("getAuthCallback err: " + JSON.stringify(err));
+ });
+ ```
+
+## AuthenticatorCallback(deprecated)
Provides OAuth authenticator callbacks.
+> **NOTE**
+>
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [AuthCallback](#authcallback9).
+
### onResult8+
onResult: (code: number, result: {[key: string]: any}) => void
@@ -2113,11 +4797,11 @@ Called to return the result of an authentication request.
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
+ let appAccountManager = account_appAccount.createAppAccountManager();
var sessionId = "1234";
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
- [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
+ [account_appAccount.Constants.KEY_OWNER]: "com.example.accountjsdemo",
[account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData",
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
@@ -2146,8 +4830,8 @@ Called to redirect a request.
class MyAuthenticator extends account_appAccount.Authenticator {
addAccountImplicitly(authType, callerBundleName, options, callback) {
callback.onRequestRedirected({
- bundleName: "com.example.ohos.accountjsdemo",
- abilityName: "com.example.ohos.accountjsdemo.LoginAbility",
+ bundleName: "com.example.accountjsdemo",
+ abilityName: "com.example.accountjsdemo.LoginAbility",
});
}
@@ -2171,7 +4855,7 @@ Called to continue to process the request.
**Example**
```js
- const appAccountManager = account_appAccount.createAppAccountManager();
+ let appAccountManager = account_appAccount.createAppAccountManager();
var sessionId = "1234";
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
callback.onRequestContinued();
@@ -2184,11 +4868,30 @@ Called to continue to process the request.
Provides APIs to operate the authenticator.
-### addAccountImplicitly8+
+### createAccountImplicitly9+
+
+createAccountImplicitly(options: CreateAccountImplicitlyOptions, callback: AuthCallback): void
+
+Creates an app account implicitly based on the specified account owner. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---------------- | --------------------- | ---- | --------------- |
+| options | [CreateAccountImplicitlyOptions](#createaccountimplicitlyoptions9) | Yes | Options for implicitly creating the account. |
+| callback | [AuthCallback](#authcallback9) | Yes | Authenticator callback invoked to return the result.|
+
+### addAccountImplicitlydeprecated
addAccountImplicitly(authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
-Implicitly adds an app account based on the specified authentication type and options. This API uses an asynchronous callback to return the result.
+Adds an app account implicitly based on the specified authentication type and options. 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 [createAccountImplicitly](#createaccountimplicitly9-2).
**System capability**: SystemCapability.Account.AppAccount
@@ -2199,13 +4902,35 @@ Implicitly adds an app account based on the specified authentication type and op
| authType | string | Yes | Authentication type. |
| callerBundleName | string | Yes | Bundle name of the authentication requester. |
| options | {[key: string]: any} | Yes | Options for the authentication. |
-| callback | [AuthenticatorCallback](#authenticatorcallback8) | Yes | Authenticator callback invoked to return the authentication result.|
+| callback | [AuthenticatorCallback](#authenticatorcallbackdeprecated) | Yes | Authenticator callback invoked to return the authentication result.|
+
+### auth9+
+
+auth(name: string, authType: string, options: {[key:string]: Object}, callback: AuthCallback): void
+
+Authenticates an app account to obtain the authorization token. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---------------- | --------------------- | ---- | --------------- |
+| name | string | Yes | Name of the target app account. |
+| authType | string | Yes | Authentication type. |
+| callerBundleName | string | Yes | Authentication type. |
+| options | {[key: string]: Object} | Yes | Options for the authentication. |
+| callback | [AuthCallback](#authcallback9) | Yes | Callback invoked to return the result.|
-### authenticate8+
+### authenticatedeprecated
authenticate(name: string, authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
-Authenticates an app account to obtain the OAuth token. This API uses an asynchronous callback to return the result.
+Authenticates an app account to obtain the authorization token. 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 [auth](#auth9-2).
**System capability**: SystemCapability.Account.AppAccount
@@ -2217,11 +4942,11 @@ Authenticates an app account to obtain the OAuth token. This API uses an asynchr
| authType | string | Yes | Authentication type. |
| callerBundleName | string | Yes | Bundle name of the authentication requester. |
| options | {[key: string]: any} | Yes | Options for the authentication. |
-| callback | [AuthenticatorCallback](#authenticatorcallback8) | Yes | Authenticator callback invoked to return the authentication result.|
+| callback | [AuthenticatorCallback](#authenticatorcallbackdeprecated) | Yes | Authenticator callback invoked to return the authentication result.|
### verifyCredential9+
-verifyCredential(name: string, options: VerifyCredentialOptions, callback: AuthenticatorCallback): void;
+verifyCredential(name: string, options: VerifyCredentialOptions, callback: AuthCallback): void;
Verifies the credential of an app account. This API uses an asynchronous callback to return the result.
@@ -2233,13 +4958,13 @@ Verifies the credential of an app account. This API uses an asynchronous callbac
| ---------------- | --------------------- | ---- | --------------- |
| name | string | Yes | Name of the target app account. |
| options | [VerifyCredentialOptions](#verifycredentialoptions9) | Yes | Options for credential verification. |
-| callback | [AuthenticatorCallback](#authenticatorcallback8) | Yes | Authenticator callback invoked to return the verification result.|
+| callback | [AuthCallback](#authcallback9) | Yes | Authenticator callback invoked to return the verification result.|
### setProperties9+
-setProperties(options: SetPropertiesOptions, callback: AuthenticatorCallback): void;
+setProperties(options: SetPropertiesOptions, callback: AuthCallback): void;
-Sets authenticator properties. This API uses an asynchronous callback to return the result.
+Sets the authenticator properties. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -2248,11 +4973,11 @@ Sets authenticator properties. This API uses an asynchronous callback to return
| Name | Type | Mandatory | Description |
| ---------------- | --------------------- | ---- | --------------- |
| options | [SetPropertiesOptions](#setpropertiesoptions9) | Yes | Authenticator properties to set. |
-| callback | [AuthenticatorCallback](#authenticatorcallback8) | Yes | Authenticator callback invoked to return the result.|
+| callback | [AuthCallback](#authcallback9) | Yes | Authenticator callback invoked to return the result.|
### checkAccountLabels9+
-checkAccountLabels(name: string, labels: Array<string>, callback: AuthenticatorCallback): void;
+checkAccountLabels(name: string, labels: Array<string>, callback: AuthCallback): void;
Checks the account labels. This API uses an asynchronous callback to return the result.
@@ -2264,11 +4989,11 @@ Checks the account labels. This API uses an asynchronous callback to return the
| ---------------- | --------------------- | ---- | --------------- |
| name | string | Yes | Name of the target app account. |
| labels | Array<string> | Yes | Labels to check. |
-| callback | [AuthenticatorCallback](#authenticatorcallback8) | Yes | Authenticator callback invoked to return the check result.|
+| callback | [AuthCallback](#authcallback9) | Yes | Authenticator callback invoked to return the check result.|
### isAccountRemovable9+
-isAccountRemovable(name: string, callback: AuthenticatorCallback): void;
+isAccountRemovable(name: string, callback: AuthCallback): void;
Checks whether an app account can be deleted. This API uses an asynchronous callback to return the result.
@@ -2279,7 +5004,7 @@ Checks whether an app account can be deleted. This API uses an asynchronous call
| Name | Type | Mandatory | Description |
| ---------------- | --------------------- | ---- | --------------- |
| name | string | Yes | Name of the target app account. |
-| callback | [AuthenticatorCallback](#authenticatorcallback8) | Yes | Authenticator callback invoked to return the result.|
+| callback | [AuthCallback](#authcallback9) | Yes | Authenticator callback invoked to return the result.|
### getRemoteObject9+
@@ -2293,49 +5018,49 @@ Obtains the remote object of an authenticator. This API cannot be overloaded.
```js
class MyAuthenticator extends account_appAccount.Authenticator {
- addAccountImplicitly(authType, callerBundleName, options, callback) {
- callback.onRequestRedirected({
- bundleName: "com.example.ohos.accountjsdemo",
- abilityName: "com.example.ohos.accountjsdemo.LoginAbility",
- });
- }
+ addAccountImplicitly(authType, callerBundleName, options, callback) {
+ callback.onRequestRedirected({
+ bundleName: "com.example.accountjsdemo",
+ abilityName: "com.example.accountjsdemo.LoginAbility",
+ });
+ }
- authenticate(name, authType, callerBundleName, options, callback) {
- var result = {[account_appAccount.Constants.KEY_NAME]: name,
- [account_appAccount.Constants.KEY_AUTH_TYPE]: authType,
- [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
- callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
- }
+ authenticate(name, authType, callerBundleName, options, callback) {
+ var result = {[account_appAccount.Constants.KEY_NAME]: name,
+ [account_appAccount.Constants.KEY_AUTH_TYPE]: authType,
+ [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
+ callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
+ }
- verifyCredential(name, options, callback) {
- callback.onRequestRedirected({
- bundleName: "com.example.ohos.accountjsdemo",
- abilityName: "com.example.ohos.accountjsdemo.VerifyAbility",
- parameters: {
- name: name
- }
- });
- }
+ verifyCredential(name, options, callback) {
+ callback.onRequestRedirected({
+ bundleName: "com.example.accountjsdemo",
+ abilityName: "com.example.accountjsdemo.VerifyAbility",
+ parameters: {
+ name: name
+ }
+ });
+ }
- setProperties(options, callback) {
- callback.onResult(account_appAccount.ResultCode.SUCCESS, {});
- }
+ setProperties(options, callback) {
+ callback.onResult(account_appAccount.ResultCode.SUCCESS, {});
+ }
- checkAccountLabels(name, labels, callback) {
- var result = {[account_appAccount.Constants.KEY_BOOLEAN_RESULT]: false};
- callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
- }
-
- isAccountRemovable(name, callback) {
- var result = {[account_appAccount.Constants.KEY_BOOLEAN_RESULT]: true};
- callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
- }
+ checkAccountLabels(name, labels, callback) {
+ var result = {[account_appAccount.Constants.KEY_BOOLEAN_RESULT]: false};
+ callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
+ }
+
+ isAccountRemovable(name, callback) {
+ var result = {[account_appAccount.Constants.KEY_BOOLEAN_RESULT]: true};
+ callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
+ }
}
var authenticator = null;
export default {
- onConnect(want) {
- authenticator = new MyAuthenticator();
- return authenticator.getRemoteObject();
- }
+ onConnect(want) {
+ authenticator = new MyAuthenticator();
+ return authenticator.getRemoteObject();
+ }
}
```
diff --git a/en/application-dev/reference/apis/js-apis-appControl.md b/en/application-dev/reference/apis/js-apis-appControl.md
index 50d8a59fdcbc6b3138afa2679c8ec10700e6ccb1..06b334d58cad8e7dd26a45c0344cfa48e1fdf0d6 100644
--- a/en/application-dev/reference/apis/js-apis-appControl.md
+++ b/en/application-dev/reference/apis/js-apis-appControl.md
@@ -1,4 +1,4 @@
-# appControl
+# @ohos.bundle.appControl (appControl)
The **appControl** module provides APIs for setting, obtaining, and deleting the disposed status of an application. An application in the disposed state is forbidden to run. When a user clicks the application icon on the home screen, the corresponding page is displayed based on the disposal intent.
@@ -30,7 +30,7 @@ Sets the disposed status for an application. This API uses a promise to return t
| Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | --------------------------------------- |
-| appId | string | Yes | ID of the target application.
**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). |
+| appId | string | Yes | ID of the target application.
**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). |
| disposedWant | Want | Yes| Disposal intent of the application.|
**Return value**
@@ -45,7 +45,7 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message |
| ------ | -------------------------------------- |
-| 17700005 | The specified appId was not found. |
+| 17700005 | The specified app ID is not found. |
**Example**
@@ -81,7 +81,7 @@ Sets the disposed status for an application. This API uses an asynchronous callb
| Name | Type | Mandatory | Description |
| ----------- | ------------------------------- | ---- | --------------------------------------- |
-| appId | string | Yes | ID of the target application.
**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). |
+| appId | string | Yes | ID of the target application.
**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). |
| disposedWant | Want | Yes| Disposal intent of the application.|
| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
@@ -91,7 +91,7 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message |
| ------ | -------------------------------------- |
-| 17700005 | The specified appId was not found. |
+| 17700005 | The specified app ID is not found. |
**Example**
@@ -128,7 +128,7 @@ Obtains the disposed status of an application. This API uses a promise to return
| Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | --------------------------------------- |
-| appId | string | Yes | ID of the target application.
**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). |
+| appId | string | Yes | ID of the target application.
**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). |
**Return value**
@@ -142,7 +142,7 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message |
| ------ | -------------------------------------- |
-| 17700005 | The specified appId was not found. |
+| 17700005 | The specified app ID is not found. |
**Example**
@@ -177,7 +177,7 @@ Obtains the disposed status of an application. This API uses an asynchronous cal
| Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | --------------------------------------- |
-| appId | string | Yes | ID of the target application.
**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). |
+| appId | string | Yes | ID of the target application.
**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). |
| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the disposed status obtained; otherwise, **err** is an error object. |
**Error codes**
@@ -186,7 +186,7 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message |
| ------ | -------------------------------------- |
-| 17700005 | The specified appId was not found. |
+| 17700005 | The specified app ID is not found. |
**Example**
@@ -222,7 +222,7 @@ Deletes the disposed status for an application. This API uses a promise to retur
| Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | --------------------------------------- |
-| appId | string | Yes | ID of the target application.
**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). |
+| appId | string | Yes | ID of the target application.
**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). |
**Return value**
@@ -236,7 +236,7 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message |
| ------ | -------------------------------------- |
-| 17700005 | The specified appId was not found. |
+| 17700005 | The specified app ID is not found. |
**Example**
@@ -271,7 +271,7 @@ Deletes the disposed status for an application. This API uses an asynchronous ca
| Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | --------------------------------------- |
-| appId | string | Yes | ID of the target application.
**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). |
+| appId | string | Yes | ID of the target application.
**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. For details about how to obtain **appId**, see [Obtaining appId of an Application](#obtaining-appid-of-an-application). |
| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. |
**Error codes**
@@ -280,7 +280,7 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message |
| ------ | -------------------------------------- |
-| 17700005 | The specified appId was not found. |
+| 17700005 | The specified app ID is not found. |
**Example**
diff --git a/en/application-dev/reference/apis/js-apis-application-AccessibilityExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-AccessibilityExtensionAbility.md
index a78f8cc320a4d081f356145d8ed4c51907a025ba..a47e3e8908f69f5515beab95cea6f74351719a77 100644
--- a/en/application-dev/reference/apis/js-apis-application-AccessibilityExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-application-AccessibilityExtensionAbility.md
@@ -1,12 +1,10 @@
-# Accessibility Extension Ability
+# @ohos.application.AccessibilityExtensionAbility
-The **AccessibilityExtensionAbility** module is based on the ExtensionAbility framework and provides the **AccessibilityExtensionAbility**.
+The **AccessibilityExtensionAbility** module provides accessibility extension capabilities based on the ExtensionAbility framework.
->**NOTE**
+> **NOTE**
>
->The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
->
->The APIs of this module can be used only in the stage model.
+> 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
@@ -18,9 +16,9 @@ import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtens
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-| Name | Type | Readable | Writable | Description |
+| Name | Type| Readable| Writable| Description |
| --------- | -------- | ---- | ---- | ------------------------- |
-| context | [AccessibilityExtensionContext](js-apis-accessibility-extension-context.md) | Yes | No | Context of the accessibility extension ability. |
+| context | [AccessibilityExtensionContext](js-apis-inner-application-accessibilityExtensionContext.md) | Yes| No| Context of the accessibility extension ability.|
## AccessibilityEvent
@@ -32,36 +30,10 @@ Defines an accessibility event.
| Name | Type | Readable | Writable | Description |
| --------- | ---------------------------------------- | ---- | ---- | ---------- |
-| eventType | [EventType](js-apis-accessibility.md#eventtype) \| [WindowUpdateType](js-apis-accessibility.md#windowupdatetype) \| [TouchGuideType](#touchguidetype) \| [GestureType](#gesturetype) \| [PageUpdateType](#pageupdatetype) | Yes | No | Event type. |
+| eventType | [accessibility.EventType](js-apis-accessibility.md#EventType) \| [accessibility.WindowUpdateType](js-apis-accessibility.md#WindowUpdateType) \| [TouchGuideType](#touchguidetype) \| [GestureType](#gesturetype) \| [PageUpdateType](#pageupdatetype) | Yes | No | Event type. |
| target | AccessibilityElement | Yes | No | Target component where the event occurs.|
| timeStamp | number | Yes | No | Timestamp of the event. |
-## GesturePath
-
-Defines a gesture path.
-
-**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-
-### Attributes
-
-| Name | Type | Readable | Writable | Description |
-| ------------ | ---------------------------------------- | ---- | ---- | ------ |
-| points | Array<[GesturePoint](gesturepoint)> | Yes | Yes | An array of gesture touch points. |
-| durationTime | number | Yes | Yes | Total time consumed by the gesture.|
-
-## GesturePoint
-
-Defines a gesture touch point.
-
-**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-
-### Attributes
-
-| Name | Type | Readable | Writable | Description |
-| --------- | ------ | ---- | ---- | ------- |
-| positionX | number | Yes | Yes | X-coordinate of the touch point.|
-| positionY | number | Yes | Yes | Y-coordinate of the touch point.|
-
## GestureType
Enumerates gesture types.
@@ -89,7 +61,7 @@ Enumerates gesture types.
## PageUpdateType
-Enumerates the page refresh types.
+Enumerates the page update types.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
@@ -106,27 +78,25 @@ Enumerates the touch guide event types.
| Name | Description |
| ---------- | ------------ |
-| touchBegin | A touch starts in touch guide mode.|
-| touchEnd | A touch ends in touch guide mode.|
+| touchBegin | Start of touch in touch guide mode. |
+| touchEnd | End of touch in touch guide mode. |
## AccessibilityExtensionAbility.onConnect
onConnect(): void;
-Called when the **AccessibilityExtensionAbility** is enabled and connected to the system service. In this API, you can initialize service logic. This API can be overridden as required.
+Called when the **AccessibilityExtensionAbility** is enabled and connected to the system service. In this API, you can have the service logic initialized. This API can be overridden as required.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-**Parameters**
-
-None
-
**Example**
```ts
-onConnect(): void {
- console.log("AxExtensionAbility onConnect");
-}
+class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
+ onConnect() {
+ console.log('AxExtensionAbility onConnect');
+ }
+};
```
## AccessibilityExtensionAbility.onDisconnect
@@ -137,16 +107,14 @@ Called when the **AccessibilityExtensionAbility** is disabled and disconnected f
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
-**Parameters**
-
-None
-
**Example**
```ts
-onDisconnect(): void {
- console.log("AxExtensionAbility onDisconnect");
-}
+class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
+ onDisconnect() {
+ console.log('AxExtensionAbility onDisconnect');
+ }
+};
```
## AccessibilityExtensionAbility.onAccessibilityEvent
@@ -166,19 +134,21 @@ Called when an event that matches the specified bundle and event type occurs. In
**Example**
```ts
-onAccessibilityEvent(event: AccessibilityEvent): void {
- console.log("AxExtensionAbility onAccessibilityEvent");
- if (event.eventType == 'click') {
- console.log("AxExtensionAbility onAccessibilityEvent: click");
+class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
+ onAccessibilityEvent(event) {
+ console.log('AxExtensionAbility onAccessibilityEvent');
+ if (event.eventType == 'click') {
+ console.log('AxExtensionAbility onAccessibilityEvent: click');
+ }
}
-}
+};
```
## AccessibilityExtensionAbility.onKeyEvent
-onKeyEvent(keyEvent: inputEventClient.KeyEvent): boolean;
+onKeyEvent(keyEvent: KeyEvent): boolean;
-Called when a physical key is pressed. In this API, you can determine whether to intercept the key event based on the service.
+Called when a physical key is pressed. In this API, you can determine whether to intercept an event based on the service.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
@@ -191,12 +161,14 @@ Called when a physical key is pressed. In this API, you can determine whether to
**Example**
```ts
-onKeyEvent(keyEvent: inputEventClient.KeyEvent): boolean {
- console.log("AxExtensionAbility onKeyEvent");
- if (keyEvent.keyCode == 22) {
- console.log("AxExtensionAbility onKeyEvent: intercept 22");
- return true;
+class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
+ onKeyEvent(keyEvent) {
+ console.log('AxExtensionAbility onKeyEvent');
+ if (keyEvent.keyCode == 22) {
+ console.log('AxExtensionAbility onKeyEvent: intercept 22');
+ return true;
+ }
+ return false;
}
- return false;
-}
+};
```
diff --git a/en/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md
index 7798cdee3d2f71f54e7cc6937816cbb4c253a833..9ecffc326e125b6e7dbe0ecd3cf03bfc3d2fa7dd 100644
--- a/en/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md
@@ -1,6 +1,6 @@
-# Data Share Extension Ability
+# @ohos.application.DataShareExtensionAbility
-The **DataShareExtensionAbility** module provides Extension abilities for data share services.
+The **DataShareExtensionAbility** module provides data share services based on the Extension ability.
>**NOTE**
>
@@ -17,13 +17,34 @@ The **DataShareExtensionAbility** module provides Extension abilities for data s
import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility'
```
+## URI Naming Rule
+
+The URIs are in the following format:
+
+**Scheme://authority/path**
+
+- *Scheme*: scheme name, which has a fixed value of **datashare** for the **DataShare** module.
+- *authority*: [userinfo@]host[:port]
+ - *userinfo*: login information, which can be left unspecified.
+ - *host*: server address. It is the target device ID for cross-device access and empty for local device access.
+ - *port*: port number of the server, which can be left unspecified.
+- *path*: **DataShare** identifier and the resource path. The **DataShare** identifier is mandatory, and the resource path is optional.
+
+Example:
+
+- URI without the resource path:
**datashare:///com.samples.datasharetest.DataShare**
+
+- URI with the resource path:
**datashare:///com.samples.datasharetest.DataShare/DB00/TBL00**
+
+**com.samples.datasharetest.DataShare** is the data share identifier, and **DB00/TBL00** is the resource path.
+
## Attributes
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
-| Name| Type| Readable| Writable| Description|
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| context | [ExtensionContext](js-apis-extension-context.md) | Yes| No|Context of the DataShare Extension ability.|
+| context | [ExtensionContext](js-apis-inner-application-extensionContext.md) | Yes| No|Context of the DataShare Extension ability.|
## onCreate
@@ -37,13 +58,13 @@ Called by the server to initialize service logic when the DataShare client conne
| Name| Type| Mandatory| Description|
| ----- | ------ | ------ | ------ |
-| want | [Want](js-apis-application-Want.md#want) | Yes | **Want** information, including the ability name and bundle name.|
+| want | [Want](js-apis-application-want.md#want) | Yes | **Want** information, including the ability name and bundle name.|
| callback | AsyncCallback<void> | Yes| Callback that returns no value.|
**Example**
```ts
-import rdb from '@ohos.data.rdb';
+import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
@@ -56,7 +77,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility {
onCreate(want, callback) {
rdb.getRdbStore(this.context, {
name: DB_NAME
- }, 1, function (err, data) {
+ }, function (err, data) {
console.log('getRdbStore done, data : ' + data);
rdbStore = data;
rdbStore.executeSql(DDL_TBL_CREATE, [], function (err) {
@@ -83,13 +104,13 @@ Inserts data into the database. This API can be overridden as required.
| Name| Type| Mandatory| Description|
| ----- | ------ | ------ | ------ |
| uri |string | Yes | URI of the data to insert.|
-| valueBucket |[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | Yes| Data to insert.|
+| valueBucket |[ValuesBucket](js-apis-data-valuesBucket.md#valuesbucket) | Yes| Data to insert.|
| callback |AsyncCallback<number> | Yes| Callback invoked to return the index of the data inserted.|
**Example**
```ts
-import rdb from '@ohos.data.rdb';
+import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
@@ -127,14 +148,14 @@ Updates data in the database. This API can be overridden as required.
| Name| Type| Mandatory| Description|
| ----- | ------ | ------ | ------ |
| uri | string | Yes | URI of the data to update.|
-| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Filter criteria for updating data.|
-| valueBucket | [ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | Yes| New data.|
+| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Filter criteria for updating data.|
+| valueBucket | [ValuesBucket](js-apis-data-valuesBucket.md#valuesbucket) | Yes| New data.|
| callback | AsyncCallback<number> | Yes| Callback invoked to return the number of updated data records.|
**Example**
```ts
-import rdb from '@ohos.data.rdb';
+import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
@@ -170,13 +191,13 @@ Deletes data from the database. This API can be overridden as required.
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------------------------------ | ---- | ---------------------------------- |
| uri | string | Yes | URI of the data to delete. |
-| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Filter criteria for deleting data. |
+| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Filter criteria for deleting data. |
| callback | AsyncCallback<number> | Yes | Callback invoked to return the number of data records deleted.|
**Example**
```ts
-import rdb from '@ohos.data.rdb';
+import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
@@ -212,14 +233,14 @@ Queries data from the database. This API can be overridden as required.
| Name| Type| Mandatory| Description|
| ----- | ------ | ------ | ------ |
| uri | string | Yes | URI of the data to query.|
-| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Filter criteria for querying data.|
+| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Filter criteria for querying data.|
| columns | Array<string> | Yes| Columns to query. If this parameter is empty, all columns will be queried.|
| callback | AsyncCallback<Object> | Yes| Callback invoked to return the result set.|
**Example**
```ts
-import rdb from '@ohos.data.rdb';
+import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
@@ -255,16 +276,16 @@ Batch inserts data into the database. This API is called by the server and can b
**Parameters**
-| Name | Type | Mandatory| Description |
+| Name | Type | Mandatory| Description |
| ------------ | ------------------------------------------------------------ | ---- | -------------------------------- |
| uri | string | Yes | URI of the data to insert. |
-| valueBuckets | Array<[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket)> | Yes | Data to insert. |
+| valueBuckets | Array<[ValuesBucket](js-apis-data-valuesBucket.md#valuesbucket)> | Yes | Data to insert. |
| callback | AsyncCallback<number> | Yes | Callback invoked to return the number of inserted data records.|
**Example**
```ts
-import rdb from '@ohos.data.rdb';
+import rdb from '@ohos.data.relationalStore';
let DB_NAME = "DB00.db";
let TBL_NAME = "TBL00";
diff --git a/en/application-dev/reference/apis/js-apis-application-EnvironmentCallback.md b/en/application-dev/reference/apis/js-apis-application-EnvironmentCallback.md
index f0d75fc57deed25160bbb080ef1565a45a94679d..d4c25269235da3b95e4f230c084d92c1df047269 100644
--- a/en/application-dev/reference/apis/js-apis-application-EnvironmentCallback.md
+++ b/en/application-dev/reference/apis/js-apis-application-EnvironmentCallback.md
@@ -1,16 +1,16 @@
-# EnvironmentCallback
+# @ohos.application.EnvironmentCallback (EnvironmentCallback)
-The **EnvironmentCallback** module provides the **onConfigurationUpdated** API for the application context to listen for system environment changes.
+The **EnvironmentCallback** module provides APIs, such as **onConfigurationUpdated** and **onMemoryLevel**, for the application context to listen for system environment changes.
> **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 are supported since API version 9 and are deprecated in versions later than API version 9. You are advised to use [@ohos.app.ability.EnvironmentCallback](js-apis-app-ability-environmentCallback.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module can be used only in the stage model.
## Modules to Import
-```js
+```ts
import EnvironmentCallback from "@ohos.application.EnvironmentCallback";
```
@@ -27,24 +27,40 @@ Called when the system environment changes.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | config | [Configuration](js-apis-configuration.md) | Yes| **Configuration** object after the change.|
+ | config | [Configuration](js-apis-application-configuration.md) | Yes| **Configuration** object after the change.|
+
+## EnvironmentCallback.onMemoryLevel
+
+onMemoryLevel(level: number): void;
+
+Called when the system memory level changes.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | level | [MemoryLevel](js-apis-application-abilityConstant.md#abilityconstantmemorylevel) | Yes| New memory level.|
**Example**
-
- ```js
-import AbilityStage from "@ohos.application.AbilityStage";
+ ```ts
+import UIAbility from '@ohos.app.ability.UIAbility';
var callbackId;
-export default class MyAbilityStage extends AbilityStage {
+export default class EntryAbility extends UIAbility {
onCreate() {
- console.log("MyAbilityStage onCreate")
+ console.log("MyAbility onCreate")
globalThis.applicationContext = this.context.getApplicationContext();
let EnvironmentCallback = {
onConfigurationUpdated(config){
console.log("onConfigurationUpdated config:" + JSON.stringify(config));
},
+ onMemoryLevel(level){
+ console.log("onMemoryLevel level:" + level);
+ }
}
// 1. Obtain an applicationContext object.
let applicationContext = globalThis.applicationContext;
diff --git a/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md b/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md
deleted file mode 100644
index 45024751e4460258a696e7f7e883e84fb93d73c2..0000000000000000000000000000000000000000
--- a/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md
+++ /dev/null
@@ -1,40 +0,0 @@
-# MissionSnapshot
-
-The **MissionSnapshot** module provides the mission snapshot information of an ability.
-
-> **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.
-
-## Usage
-
-The mission snapshot information can be obtained by using **getMissionSnapShot** in **missionManager**.
-
-```js
-import ElementName from '@ohos.bundle';
-import image from '@ohos.multimedia.image';
-import missionManager from '@ohos.application.missionManager';
-
-missionManager.getMissionInfos("", 10, (error, missions) => {
- console.log("getMissionInfos is called, error.code = " + error.code);
- console.log("size = " + missions.length);
- console.log("missions = " + JSON.stringify(missions));
- var id = missions[0].missionId;
-
- missionManager.getMissionSnapShot("", id, (error, snapshot) => {
- console.log("getMissionSnapShot is called, error.code = " + error.code);
- console.log("bundleName = " + snapshot.ability.bundleName);
- })
-})
-```
-## MissionSnapshot
-
-Describes the mission snapshot.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
-
-| Name| Type| Readable| Writable| Description|
-| -------- | -------- | -------- | -------- | -------- |
-| ability | ElementName | Yes| Yes| Information that matches an ability.|
-| snapshot | [image.PixelMap](js-apis-image.md) | Yes| Yes| Snapshot of the mission.|
diff --git a/en/application-dev/reference/apis/js-apis-application-StartOptions.md b/en/application-dev/reference/apis/js-apis-application-StartOptions.md
index 39f44f65437b6b91ce457228fa12153d10aed3e6..7634b276495d98e18bc7ec966f3483e526dd3ba3 100644
--- a/en/application-dev/reference/apis/js-apis-application-StartOptions.md
+++ b/en/application-dev/reference/apis/js-apis-application-StartOptions.md
@@ -1,15 +1,15 @@
-# StartOptions
+# @ohos.application.StartOptions (StartOptions)
The **StartOptions** module implements ability startup options.
> **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 are supported since API version 9 and are deprecated in versions later than API version 9. You are advised to use [@ohos.app.ability.StartOptions](js-apis-app-ability-startOptions.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module can be used only in the stage model.
## Modules to Import
-```
+```ts
import StartOptions from '@ohos.application.StartOptions';
```
@@ -17,7 +17,7 @@ import StartOptions from '@ohos.application.StartOptions';
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-| Name| Readable| Writable| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- | -------- | -------- |
-| [windowMode](js-apis-application-abilityConstant.md#abilityconstantwindowmode) | Yes| No| number | No| Window mode.|
-| displayId | Yes| No| number | No| Display ID.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| [windowMode](js-apis-application-abilityConstant.md#abilityconstantwindowmode) | number | No| Window mode.|
+| displayId | number | No| Display ID.|
diff --git a/en/application-dev/reference/apis/js-apis-application-Want.md b/en/application-dev/reference/apis/js-apis-application-Want.md
index 9275473cd14727d8a3e8f16327d2020a1adefb4d..44cc01a00c5057488b45a5a6a38cc02adbf1cbc2 100644
--- a/en/application-dev/reference/apis/js-apis-application-Want.md
+++ b/en/application-dev/reference/apis/js-apis-application-Want.md
@@ -1,14 +1,14 @@
-# Want
+# @ohos.application.Want (Want)
-The **Want** module provides the basic communication component of the system.
+Want is a carrier for information transfer between objects (application components). Want can be used as a parameter of **startAbility()** to specify a startup target and information that needs to be carried during startup, for example, **bundleName** and **abilityName**, which respectively indicate the bundle name of the target ability and the ability name in the bundle. When ability A needs to start ability B and transfer some data to ability B, it can use Want a carrier to transfer the data.
> **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 supported since API version 8 and deprecated since API version 9. You are advised to use [Want](js-apis-app-ability-want.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
-```
+```ts
import Want from '@ohos.application.Want';
```
@@ -16,28 +16,28 @@ import Want from '@ohos.application.Want';
**System capability**: SystemCapability.Ability.AbilityBase
-| Name | Readable/Writable| Type | Mandatory| Description |
-| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
-| deviceId | Read only | string | No | ID of the device running the ability. |
-| bundleName | Read only | string | No | Bundle name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability.|
-| abilityName | Read only | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.|
-| uri | Read only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
-| type | Read only | string | No | MIME type, that is, the type of the file to open, for example, **text/xml** and **image/***. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com. |
-| flags | Read only | number | No | How the **Want** object will be handled. For details, see [flags](js-apis-featureAbility.md#flags).|
-| action | Read only | string | No | Action to take, such as viewing and sharing application details. In implicit **Want**, you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data. |
-| parameters | Read only | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:
**ohos.aafwk.callerPid**: PID of the caller.
**ohos.aafwk.param.callerToken**: token of the caller.
**ohos.aafwk.param.callerUid**: UID in [bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information. |
-| entities | Read only | Array\ | No | Additional category information (such as browser and video player) of the target ability. It is a supplement to **action** in implicit **Want** and is used to filter ability types. |
-| moduleName9+ | Read only | string | No | Module to which the ability belongs.|
+| Name | Type | Mandatory| Description |
+| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
+| deviceId | string | No | ID of the device running the ability. If this field is unspecified, the local device is used. |
+| bundleName | string | No | Bundle name.|
+| abilityName | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.|
+| uri | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
+| type | string | No | MIME type, that is, the type of the file to open, for example, **text/xml** and **image/***. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com. |
+| flags | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-ability-wantConstant.md#wantConstant.Flags).|
+| action | string | No | Action to take, such as viewing and sharing application details. In implicit **Want**, you can define this attribute and use it together with **uri** or **parameters** to specify the operation to be performed on the data. For details, see [action](js-apis-app-ability-wantConstant.md#wantConstant.Action). For details about the definition and matching rules of implicit Want, see [Matching Rules of Explicit Want and Implicit Want](application-models/explicit-implicit-want-mappings.md). |
+| parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:
**ohos.aafwk.callerPid**: PID of the caller.
**ohos.aafwk.param.callerToken**: token of the caller.
**ohos.aafwk.param.callerUid**: UID in [bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information. |
+| entities | Array\ | No | Additional category information (such as browser and video player) of the ability. It is a supplement to the **action** field for implicit Want. and is used to filter ability types. For details, see [entity](js-apis-app-ability-wantConstant.md#wantConstant.Entity). |
+| moduleName9+ | string | No | Module to which the ability belongs.|
**Example**
-- Basic usage
+- Basic usage (called in a UIAbility object, where context in the example is the context object of the UIAbility).
- ``` js
- var want = {
+ ```ts
+ let want = {
"deviceId": "", // An empty deviceId indicates the local device.
- "bundleName": "com.extreme.test",
- "abilityName": "MainAbility",
+ "bundleName": "com.example.myapplication",
+ "abilityName": "EntryAbility",
"moduleName": "entry" // moduleName is optional.
};
this.context.startAbility(want, (error) => {
@@ -46,13 +46,13 @@ import Want from '@ohos.application.Want';
})
```
-- Data is transferred through user-defined fields. The following data types are supported:
+- Data is transferred through user-defined fields. The following data types are supported (called in a UIAbility object, where context in the example is the context object of the UIAbility):
* String
```ts
let want = {
- bundleName: "com.example.demo",
- abilityName: "com.example.demo.MainAbility",
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility",
parameters: {
keyForString: "str",
},
@@ -61,8 +61,8 @@ import Want from '@ohos.application.Want';
* Number
```ts
let want = {
- bundleName: "com.example.demo",
- abilityName: "com.example.demo.MainAbility",
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility",
parameters: {
keyForInt: 100,
keyForDouble: 99.99,
@@ -72,8 +72,8 @@ import Want from '@ohos.application.Want';
* Boolean
```ts
let want = {
- bundleName: "com.example.demo",
- abilityName: "com.example.demo.MainAbility",
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility",
parameters: {
keyForBool: true,
},
@@ -82,8 +82,8 @@ import Want from '@ohos.application.Want';
* Object
```ts
let want = {
- bundleName: "com.example.demo",
- abilityName: "com.example.demo.MainAbility",
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility",
parameters: {
keyForObject: {
keyForObjectString: "str",
@@ -97,8 +97,8 @@ import Want from '@ohos.application.Want';
* Array
```ts
let want = {
- bundleName: "com.example.demo",
- abilityName: "com.example.demo.MainAbility",
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility",
parameters: {
keyForArrayString: ["str1", "str2", "str3"],
keyForArrayInt: [100, 200, 300, 400],
@@ -110,16 +110,16 @@ import Want from '@ohos.application.Want';
* File descriptor (FD)
```ts
import fileio from '@ohos.fileio';
- var fd;
+ let fd;
try {
fd = fileio.openSync("/data/storage/el2/base/haps/pic.png");
} catch(e) {
console.log("openSync fail:" + JSON.stringify(e));
}
- var want = {
+ let want = {
"deviceId": "", // An empty deviceId indicates the local device.
- "bundleName": "com.extreme.test",
- "abilityName": "MainAbility",
+ "bundleName": "com.example.myapplication",
+ "abilityName": "EntryAbility",
"moduleName": "entry", // moduleName is optional.
"parameters": {
"keyFd":{"type":"FD", "value":fd}
@@ -131,4 +131,6 @@ import Want from '@ohos.application.Want';
})
```
+- For more details and examples, see [Want](../../application-models/want-overview.md).
+
diff --git a/en/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md
index 1fa16906d34877c7e7dce4638b472b0c539b8921..bd6d74bbcbbdb4b0d29ccad209b012a11f44c9af 100644
--- a/en/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md
@@ -1,4 +1,5 @@
-# Window Extension Ability
+# @ohos.application.WindowExtensionAbility (WindowExtensionAbility)
+
**WindowExtensionAbility** inherits from **ExtensionAbility**. The content in a **WindowExtensionAbility** object can be displayed as an ability component in other application windows.
> **NOTE**
@@ -21,7 +22,7 @@ import WindowExtensionAbility from '@ohos.application.WindowExtensionAbility';
| Name | Type| Readable| Writable| Description |
| --------- | -------- | ---- | ---- | ------------------------- |
-| context | [ExtensionContext](js-apis-extension-context.md) | Yes | No | Context of an Extension ability. |
+| context | [ExtensionContext](js-apis-inner-application-extensionContext.md) | Yes | No | Context of an Extension ability. |
## WindowExtensionAbility.onConnect
@@ -35,7 +36,7 @@ Called when this Window Extension ability is connected to an ability for the fir
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name.|
+| want | [Want](js-apis-application-want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name.|
**Example**
@@ -61,7 +62,7 @@ Called when this Window Extension ability is disconnected from all connected abi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name.|
+| want | [Want](js-apis-application-want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name.|
**Example**
diff --git a/en/application-dev/reference/apis/js-apis-application-ability.md b/en/application-dev/reference/apis/js-apis-application-ability.md
index 7ba7d62c053ea5eb7f03e6264f959c5770e196ee..efba928564b2c9aa34e35b2af7485674ea99274d 100644
--- a/en/application-dev/reference/apis/js-apis-application-ability.md
+++ b/en/application-dev/reference/apis/js-apis-application-ability.md
@@ -1,4 +1,4 @@
-# Ability
+# @ohos.application.Ability (Ability)
The **Ability** module manages the ability lifecycle and context, such as creating and destroying an ability, and dumping client information.
@@ -14,8 +14,8 @@ This module provides the following common ability-related functions:
## Modules to Import
-```
-import Ability from '@ohos.application.Ability';
+```ts
+import UIAbility from '@ohos.app.ability.UIAbility';
```
## Attributes
@@ -24,9 +24,9 @@ import Ability from '@ohos.application.Ability';
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| context | [AbilityContext](js-apis-ability-context.md) | Yes| No| Context of an ability.|
-| launchWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters for starting the ability.|
-| lastRequestWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters used when the ability was started last time.|
+| context | [UIAbilityContext](js-apis-inner-application-uiAbilityContext.md) | Yes| No| Context of an ability.|
+| launchWant | [Want](js-apis-app-ability-want.md) | Yes| No| Parameters for starting the ability.|
+| lastRequestWant | [Want](js-apis-app-ability-want.md) | Yes| No| Parameters used when the ability was started last time.|
| callee | [Callee](#callee) | Yes| No| Object that invokes the stub service.|
## Ability.onCreate
@@ -41,13 +41,13 @@ Called to initialize the service logic when an ability is created.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | want | [Want](js-apis-application-Want.md) | Yes| Information related to this ability, including the ability name and bundle name.|
+ | want | [Want](js-apis-app-ability-want.md) | Yes| Information related to this ability, including the ability name and bundle name.|
| param | AbilityConstant.LaunchParam | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.|
**Example**
```ts
- class myAbility extends Ability {
+ export default class EntryAbility extends UIAbility {
onCreate(want, param) {
console.log('onCreate, want:' + want.abilityName);
}
@@ -67,7 +67,7 @@ Called when a **WindowStage** is created for this ability.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | windowStage | window.WindowStage | Yes| **WindowStage** information.|
+ | windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** information.|
**Example**
@@ -111,7 +111,7 @@ Called when the **WindowStage** is restored during the migration of this ability
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | windowStage | window.WindowStage | Yes| **WindowStage** information.|
+ | windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** information.|
**Example**
@@ -219,48 +219,48 @@ Called to save data during the ability migration preparation process.
onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void;
-Called when the ability startup mode is set to singleton.
+Called when a new Want is passed in and this UIAbility is started again.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | want | [Want](js-apis-application-Want.md) | Yes| Want parameters, such as the ability name and bundle name.|
- | launchParams | AbilityConstant.LaunchParam | Yes| Reason for the ability startup and the last abnormal exit.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| want | [Want](js-apis-application-want.md) | Yes| Want information, such as the ability name and bundle name.|
+| launchParams | AbilityConstant.LaunchParam | Yes| Reason for the ability startup and the last abnormal exit.|
**Example**
```ts
class myAbility extends Ability {
- onNewWant(want) {
+ onNewWant(want, launchParams) {
console.log('onNewWant, want:' + want.abilityName);
+ console.log('onNewWant, launchParams:' + JSON.stringify(launchParams));
}
}
```
-
## Ability.onConfigurationUpdated
onConfigurationUpdated(config: Configuration): void;
-Called when the configuration of the environment where the ability is running is updated.
+Called when the global configuration is updated.
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | config | [Configuration](js-apis-configuration.md) | Yes| New configuration.|
+ | config | [Configuration](js-apis-application-configuration.md) | Yes| Callback invoked when the global configuration is updated. The global configuration indicates the configuration of the environment where the application is running and includes the language and color mode.|
**Example**
```ts
class myAbility extends Ability {
onConfigurationUpdated(config) {
- console.log('onConfigurationUpdated, config:' + JSON.stringify(config));
+ console.log('onConfigurationUpdated, language:' + config.language);
}
}
```
@@ -314,12 +314,11 @@ Called when the system has decided to adjust the memory level. For example, this
}
```
-
## Ability.onSaveState
onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: any}): AbilityConstant.OnSaveResult;
-Called when the framework saves the ability state in the case of an application fault if automatic saving is enabled. This API is used together with [appRecovery](js-apis-app-ability-appRecovery.md).
+Called when the framework automatically saves the ability state in the case of an application fault. This API is used together with [appRecovery](js-apis-app-ability-appRecovery.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
@@ -338,7 +337,7 @@ Called when the framework saves the ability state in the case of an application
**Example**
- ```js
+ ```ts
import AbilityConstant from '@ohos.application.AbilityConstant'
class myAbility extends Ability {
@@ -390,8 +389,9 @@ Sends sequenceable data to the target ability.
**Example**
```ts
- import Ability from '@ohos.app.ability.UIAbility';
- class MyMessageAble{ // Custom sequenceable data structure
+ import UIAbility from '@ohos.app.ability.UIAbility';
+
+ class MyMessageAble{ // Custom sequenceable data structure.
name:""
str:""
num: 1
@@ -414,11 +414,11 @@ Sends sequenceable data to the target ability.
};
var method = 'call_Function'; // Notification message string negotiated by the two abilities
var caller;
- export default class MainAbility extends Ability {
+ export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: "com.example.myservice",
- abilityName: "MainAbility",
+ abilityName: "EntryAbility",
deviceId: ""
}).then((obj) => {
caller = obj;
@@ -474,7 +474,8 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
**Example**
```ts
- import Ability from '@ohos.app.ability.UIAbility';
+ import UIAbility from '@ohos.app.ability.UIAbility';
+
class MyMessageAble{
name:""
str:""
@@ -498,11 +499,11 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
};
var method = 'call_Function';
var caller;
- export default class MainAbility extends Ability {
+ export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: "com.example.myservice",
- abilityName: "MainAbility",
+ abilityName: "EntryAbility",
deviceId: ""
}).then((obj) => {
caller = obj;
@@ -545,14 +546,17 @@ Releases the caller interface of the target ability.
**Example**
+
```ts
- import Ability from '@ohos.app.ability.UIAbility';
+ import UIAbility from '@ohos.app.ability.UIAbility';
+
var caller;
- export default class MainAbility extends Ability {
+
+ export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: "com.example.myservice",
- abilityName: "MainAbility",
+ abilityName: "EntryAbility",
deviceId: ""
}).then((obj) => {
caller = obj;
@@ -570,10 +574,9 @@ Releases the caller interface of the target ability.
}
```
+## Caller.onRelease
-## Caller.on
-
- on(type: "release", callback: OnReleaseCallback): void;
+ onRelease(callback: OnReleaseCallBack): void;
Registers a callback that is invoked when the stub on the target ability is disconnected.
@@ -583,32 +586,25 @@ Registers a callback that is invoked when the stub on the target ability is disc
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | type | string | Yes| Event type. The value is fixed at **release**.|
| callback | OnReleaseCallBack | Yes| Callback used for the **onRelease** API.|
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| 16200001 | Caller released. The caller has been released. |
-| 16000050 | Internal Error. |
-
**Example**
```ts
- import Ability from '@ohos.app.ability.UIAbility';
+ import UIAbility from '@ohos.app.ability.UIAbility';
+
var caller;
- export default class MainAbility extends Ability {
+
+ export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: "com.example.myservice",
- abilityName: "MainAbility",
+ abilityName: "EntryAbility",
deviceId: ""
}).then((obj) => {
caller = obj;
try {
- caller.on("release", (str) => {
+ caller.onRelease((str) => {
console.log(' Caller OnRelease CallBack is called ' + str);
});
} catch (error) {
@@ -654,7 +650,7 @@ Registers a caller notification callback, which is invoked when the target abili
**Example**
```ts
- import Ability from '@ohos.app.ability.UIAbility';
+ import UIAbility from '@ohos.app.ability.UIAbility';
class MyMessageAble{
name:""
str:""
@@ -679,11 +675,11 @@ Registers a caller notification callback, which is invoked when the target abili
var method = 'call_Function';
function funcCallBack(pdata) {
console.log('Callee funcCallBack is called ' + pdata);
- let msg = new MyMessageAble(0, "");
+ let msg = new MyMessageAble("test", "");
pdata.readSequenceable(msg);
- return new MyMessageAble(10, "Callee test");
+ return new MyMessageAble("test1", "Callee test");
}
- export default class MainAbility extends Ability {
+ export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
console.log('Callee onCreate is called');
try {
@@ -722,9 +718,11 @@ Deregisters a caller notification callback, which is invoked when the target abi
**Example**
```ts
- import Ability from '@ohos.app.ability.UIAbility';
+ import UIAbility from '@ohos.app.ability.UIAbility';
+
var method = 'call_Function';
- export default class MainAbility extends Ability {
+
+ export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
console.log('Callee onCreate is called');
try {
@@ -737,7 +735,7 @@ Deregisters a caller notification callback, which is invoked when the target abi
}
```
-## OnReleaseCallback
+## OnReleaseCallBack
(msg: string): void;
@@ -747,7 +745,7 @@ Deregisters a caller notification callback, which is invoked when the target abi
| -------- | -------- | -------- | -------- | -------- |
| (msg: string) | function | Yes| No| Prototype of the listener function registered by the caller.|
-## CalleeCallback
+## CalleeCallBack
(indata: rpc.MessageParcel): rpc.Sequenceable;
@@ -756,5 +754,3 @@ Deregisters a caller notification callback, which is invoked when the target abi
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes| No| Prototype of the listener function registered by the callee.|
-
-
\ No newline at end of file
diff --git a/en/application-dev/reference/apis/js-apis-application-abilityConstant.md b/en/application-dev/reference/apis/js-apis-application-abilityConstant.md
index 50e65757431e7df6b9bc784c6169da902a04bf5d..70d679e5f44e1089e91ff7377b687ded761e29e6 100644
--- a/en/application-dev/reference/apis/js-apis-application-abilityConstant.md
+++ b/en/application-dev/reference/apis/js-apis-application-abilityConstant.md
@@ -1,17 +1,15 @@
-# AbilityConstant
+# @ohos.application.AbilityConstant (AbilityConstant)
-The **AbilityConstant** module provides ability launch parameters.
-
-The parameters include the initial launch reasons, reasons for the last exit, and ability continuation results.
+The **AbilityConstant** module defines the ability-related enums, including the initial launch reasons, reasons for the last exit, ability continuation results, and window modes.
> **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 are supported since API version 9 and are deprecated in versions later than API version 9. You are advised to use [@ohos.app.ability.AbilityConstant](js-apis-app-ability-abilityConstant.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module can be used only in the stage model.
## Modules to Import
-```js
+```ts
import AbilityConstant from '@ohos.application.AbilityConstant';
```
@@ -19,14 +17,14 @@ import AbilityConstant from '@ohos.application.AbilityConstant';
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-| Name| Type| Readable| Writable| Description|
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| launchReason | LaunchReason| Yes| Yes| Ability launch reason.|
-| lastExitReason | LastExitReason | Yes| Yes| Reason for the last exit.|
+| launchReason | [LaunchReason](#abilityconstantlaunchreason)| Yes| Yes| Ability launch reason.|
+| lastExitReason | [LastExitReason](#abilityconstantlastexitreason) | Yes| Yes| Reason for the last exit.|
## AbilityConstant.LaunchReason
-Enumerates ability launch reasons.
+Enumerates the initial ability launch reasons.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -36,11 +34,12 @@ Enumerates ability launch reasons.
| START_ABILITY | 1 | Ability startup.|
| CALL | 2 | Call.|
| CONTINUATION | 3 | Ability continuation.|
+| APP_RECOVERY | 4 | Application recovery.|
## AbilityConstant.LastExitReason
-Enumerates reasons for the last exit.
+Enumerates the reasons for the last exit.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -53,7 +52,7 @@ Enumerates reasons for the last exit.
## AbilityConstant.OnContinueResult
-Enumerates ability continuation results.
+Enumerates the ability continuation results.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -88,3 +87,29 @@ Enumerates the memory levels.
| MEMORY_LEVEL_MODERATE | 0 | Moderate memory usage. |
| MEMORY_LEVEL_LOW | 1 | Low memory usage. |
| MEMORY_LEVEL_CRITICAL | 2 | High memory usage. |
+
+## AbilityConstant.OnSaveResult
+
+Enumerates the result types for the operation of saving application data.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name | Value | Description |
+| ----------------------------- | ---- | ------------------------------------------------------------ |
+| ALL_AGREE | 0 | Agreed to save the status.|
+| CONTINUATION_REJECT | 1 | Rejected to save the status in continuation.|
+| CONTINUATION_MISMATCH | 2 | Continuation mismatch.|
+| RECOVERY_AGREE | 3 | Agreed to restore the saved status.|
+| RECOVERY_REJECT | 4 | Rejected to restore the saved state.|
+| ALL_REJECT | 5 | Rejected to save the status.|
+
+## AbilityConstant.StateType
+
+Enumerates the scenarios for saving application data.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+| Name | Value | Description |
+| ----------------------------- | ---- | ------------------------------------------------------------ |
+| CONTINUATION | 0 | Saving the status in continuation.|
+| APP_RECOVERY | 1 | Saving the status in application recovery.|
diff --git a/en/application-dev/reference/apis/js-apis-abilityDelegatorRegistry.md b/en/application-dev/reference/apis/js-apis-application-abilityDelegatorRegistry.md
similarity index 72%
rename from en/application-dev/reference/apis/js-apis-abilityDelegatorRegistry.md
rename to en/application-dev/reference/apis/js-apis-application-abilityDelegatorRegistry.md
index d30dce2a75e700019c9f44ce1c918a9574f3cea7..ae72afeca2e3214d00a785c0639793e8df47d715 100644
--- a/en/application-dev/reference/apis/js-apis-abilityDelegatorRegistry.md
+++ b/en/application-dev/reference/apis/js-apis-application-abilityDelegatorRegistry.md
@@ -1,14 +1,14 @@
-# AbilityDelegatorRegistry
+# @ohos.application.abilityDelegatorRegistry (AbilityDelegatorRegistry)
The **AbilityDelegatorRegistry** module provides APIs for storing the global registers of the registered **AbilityDelegator** and **AbilityDelegatorArgs** objects. You can use the APIs to obtain the **AbilityDelegator** and **AbilityDelegatorArgs** objects of an application.
> **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 supported since API version 8 and deprecated since API version 9. You are advised to use [@ohos.app.ability.abilityDelegatorRegistry](js-apis-app-ability-abilityDelegatorRegistry.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
-```js
+```ts
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
```
@@ -38,18 +38,16 @@ Obtains the **AbilityDelegator** object of the application.
| Type | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
-| [AbilityDelegator](js-apis-application-abilityDelegator.md#AbilityDelegator) | [AbilityDelegator](js-apis-application-abilityDelegator.md#AbilityDelegator) object, which can be used to schedule functions related to the test framework.|
+| [AbilityDelegator](js-apis-inner-application-abilityDelegator.md#AbilityDelegator) | [AbilityDelegator](js-apis-inner-application-abilityDelegator.md#AbilityDelegator) object, which can be used to schedule functions related to the test framework.|
**Example**
-```js
+```ts
var abilityDelegator;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
```
-
-
## AbilityDelegatorRegistry.getArguments
getArguments(): AbilityDelegatorArgs
@@ -62,11 +60,11 @@ Obtains the **AbilityDelegatorArgs** object of the application.
| Type | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
-| [AbilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md#AbilityDelegatorArgs) | [AbilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md#AbilityDelegatorArgs) object, which can be used to obtain test parameters.|
+| [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md#AbilityDelegatorArgs) | [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md#AbilityDelegatorArgs) object, which can be used to obtain test parameters.|
**Example**
-```js
+```ts
var args = AbilityDelegatorRegistry.getArguments();
console.info("getArguments bundleName:" + args.bundleName);
console.info("getArguments testCaseNames:" + args.testCaseNames);
diff --git a/en/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md b/en/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md
index 54264312fcc88ad0177473a7e4d256f566e6c2d2..040448220bb9da59779f0d449c43a59d8ab920bd 100644
--- a/en/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md
+++ b/en/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md
@@ -1,16 +1,16 @@
-# AbilityLifecycleCallback
+# @ohos.application.AbilityLifecycleCallback (AbilityLifecycleCallback)
-The **AbilityLifecycleCallback** module provides callbacks, such as **onAbilityCreate**, **onWindowStageCreate**, and **onWindowStageDestroy**, to receive lifecycle state changes in the application context.
+The **AbilityLifecycleCallback** module provides callbacks, such as **onAbilityCreate**, **onWindowStageCreate**, and **onWindowStageDestroy**, to receive lifecycle state changes in the application context. These callbacks can be used as an input parameter of [registerAbilityLifecycleCallback](js-apis-inner-application-applicationContext.md#applicationcontextregisterabilitylifecyclecallback).
> **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 are supported since API version 9 and are deprecated in versions later than API version 9. You are advised to use [@ohos.app.ability.AbilityLifecycleCallback](js-apis-app-ability-abilityLifecycleCallback.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module can be used only in the stage model.
## Modules to Import
-```js
+```ts
import AbilityLifecycleCallback from "@ohos.application.AbilityLifecycleCallback";
```
@@ -25,9 +25,9 @@ Called when an ability is created.
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
## AbilityLifecycleCallback.onWindowStageCreate
@@ -40,10 +40,10 @@ Called when the window stage of an ability is created.
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
- | windowStage | [WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
+| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
## AbilityLifecycleCallback.onWindowStageActive
@@ -56,10 +56,10 @@ Called when the window stage of an ability gains focus.
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
- | windowStage | [WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
+| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
## AbilityLifecycleCallback.onWindowStageInactive
@@ -72,10 +72,10 @@ Called when the window stage of an ability loses focus.
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
- | windowStage | [WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
+| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
## AbilityLifecycleCallback.onWindowStageDestroy
@@ -88,10 +88,10 @@ Called when the window stage of an ability is destroyed.
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
- | windowStage | [WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
+| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
## AbilityLifecycleCallback.onAbilityDestroy
@@ -104,9 +104,9 @@ Called when an ability is destroyed.
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
## AbilityLifecycleCallback.onAbilityForeground
@@ -119,9 +119,9 @@ Called when an ability is switched from the background to the foreground.
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
## AbilityLifecycleCallback.onAbilityBackground
@@ -134,9 +134,9 @@ Called when an ability is switched from the foreground to the background.
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
## AbilityLifecycleCallback.onAbilityContinue
@@ -149,57 +149,65 @@ Called when an ability is continued on another device.
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
**Example**
-
-
- ```js
- import AbilityStage from "@ohos.application.AbilityStage";
-
- export default class MyAbilityStage extends AbilityStage {
- onCreate() {
- console.log("MyAbilityStage onCreate")
- let AbilityLifecycleCallback = {
- onAbilityCreate(ability){
- console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability));
- },
- onWindowStageCreate(ability, windowStage){
- console.log("AbilityLifecycleCallback onWindowStageCreate ability:" + JSON.stringify(ability));
- console.log("AbilityLifecycleCallback onWindowStageCreate windowStage:" + JSON.stringify(windowStage));
+
+```ts
+import AbilityStage from "@ohos.application.AbilityStage";
+
+var lifecycleId;
+
+export default class MyAbilityStage extends AbilityStage {
+ onCreate() {
+ console.log("MyAbilityStage onCreate")
+ let AbilityLifecycleCallback = {
+ onAbilityCreate(ability) {
+ console.log("onAbilityCreate ability:" + JSON.stringify(ability));
+ },
+ onWindowStageCreate(ability, windowStage) {
+ console.log("onWindowStageCreate ability:" + JSON.stringify(ability));
+ console.log("onWindowStageCreate windowStage:" + JSON.stringify(windowStage));
},
- onWindowStageActive(ability, windowStage){
- console.log("AbilityLifecycleCallback onWindowStageActive ability:" + JSON.stringify(ability));
- console.log("AbilityLifecycleCallback onWindowStageActive windowStage:" + JSON.stringify(windowStage));
+ onWindowStageActive(ability, windowStage) {
+ console.log("onWindowStageActive ability:" + JSON.stringify(ability));
+ console.log("onWindowStageActive windowStage:" + JSON.stringify(windowStage));
},
- onWindowStageInactive(ability, windowStage){
- console.log("AbilityLifecycleCallback onWindowStageInactive ability:" + JSON.stringify(ability));
- console.log("AbilityLifecycleCallback onWindowStageInactive windowStage:" + JSON.stringify(windowStage));
+ onWindowStageInactive(ability, windowStage) {
+ console.log("onWindowStageInactive ability:" + JSON.stringify(ability));
+ console.log("onWindowStageInactive windowStage:" + JSON.stringify(windowStage));
},
- onWindowStageDestroy(ability, windowStage){
- console.log("AbilityLifecycleCallback onWindowStageDestroy ability:" + JSON.stringify(ability));
- console.log("AbilityLifecycleCallback onWindowStageDestroy windowStage:" + JSON.stringify(windowStage));
+ onWindowStageDestroy(ability, windowStage) {
+ console.log("onWindowStageDestroy ability:" + JSON.stringify(ability));
+ console.log("onWindowStageDestroy windowStage:" + JSON.stringify(windowStage));
},
- onAbilityDestroy(ability){
- console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + JSON.stringify(ability));
- },
- onAbilityForeground(ability){
- console.log("AbilityLifecycleCallback onAbilityForeground ability:" + JSON.stringify(ability));
- },
- onAbilityBackground(ability){
- console.log("AbilityLifecycleCallback onAbilityBackground ability:" + JSON.stringify(ability));
- },
- onAbilityContinue(ability){
- console.log("AbilityLifecycleCallback onAbilityContinue ability:" + JSON.stringify(ability));
- }
- }
- // 1. Obtain applicationContext through the context attribute.
- let applicationContext = this.context.getApplicationContext();
- // 2. Use applicationContext to register a listener for the ability lifecycle in the application.
- let lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback);
- console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid));
- }
- }
- ```
+ onAbilityDestroy(ability) {
+ console.log("onAbilityDestroy ability:" + JSON.stringify(ability));
+ },
+ onAbilityForeground(ability) {
+ console.log("onAbilityForeground ability:" + JSON.stringify(ability));
+ },
+ onAbilityBackground(ability) {
+ console.log("onAbilityBackground ability:" + JSON.stringify(ability));
+ },
+ onAbilityContinue(ability) {
+ console.log("onAbilityContinue ability:" + JSON.stringify(ability));
+ }
+ }
+ // 1. Obtain applicationContext through the context attribute.
+ let applicationContext = this.context.getApplicationContext();
+ // 2. Use applicationContext to register a listener for the ability lifecycle in the application.
+ lifecycleId = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback);
+ console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleId));
+ }
+
+ onDestroy() {
+ let applicationContext = this.context.getApplicationContext();
+ applicationContext.unregisterAbilityLifecycleCallback(lifecycleId, (error, data) => {
+ console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error));
+ });
+ }
+}
+```
diff --git a/en/application-dev/reference/apis/js-apis-application-abilityManager.md b/en/application-dev/reference/apis/js-apis-application-abilityManager.md
index e1bf96bae511de4e1fb83d92df6ee05bdddbf990..e509a1b5d13a2d0d20b8d6dee4efee9487c5ee92 100644
--- a/en/application-dev/reference/apis/js-apis-application-abilityManager.md
+++ b/en/application-dev/reference/apis/js-apis-application-abilityManager.md
@@ -1,16 +1,16 @@
-# AbilityManager
+# @ohos.application.abilityManager (AbilityManager)
The **AbilityManager** module provides APIs for obtaining, adding, and modifying ability running information and state information.
> **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 supported since API version 8 and deprecated since API version 9. You are advised to use [@ohos.app.ability.abilityManager](js-apis-app-ability-abilityManager.md) instead. 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.
## Modules to Import
-```js
-import AbilityManager from '@ohos.application.abilityManager'
+```ts
+import abilityManager from '@ohos.application.abilityManager'
```
## AbilityState
@@ -26,8 +26,8 @@ Enumerates the ability states.
| INITIAL | 0 | The ability is in the initial state.|
| FOREGROUND | 9 | The ability is in the foreground state. |
| BACKGROUND | 10 | The ability is in the background state. |
-| FOREGROUNDING | 11 | The ability is in the foregrounding state. |
-| BACKGROUNDING | 12 | The ability is in the backgrounding state. |
+| FOREGROUNDING | 11 | The ability is in the state of being switched to the foreground. |
+| BACKGROUNDING | 12 | The ability is in the state of being switched to the background. |
## updateConfiguration
@@ -43,19 +43,17 @@ Updates the configuration. This API uses an asynchronous callback to return the
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
-| config | Configuration | Yes | New configuration.|
+| config | [Configuration](js-apis-application-configuration.md) | Yes | New configuration.|
| callback | AsyncCallback\ | Yes | Callback used to return the result. |
**Example**
-```js
-import abilitymanager from '@ohos.application.abilityManager';
-
+```ts
var config = {
language: 'chinese'
}
-abilitymanager.updateConfiguration(config, () => {
+abilityManager.updateConfiguration(config, () => {
console.log('------------ updateConfiguration -----------');
})
```
@@ -74,7 +72,7 @@ Updates the configuration. This API uses a promise to return the result.
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
-| config | Configuration | Yes | New configuration.|
+| config | [Configuration](js-apis-application-configuration.md) | Yes | New configuration.|
**Return value**
@@ -84,14 +82,12 @@ Updates the configuration. This API uses a promise to return the result.
**Example**
-```js
-import abilitymanager from '@ohos.application.abilityManager';
-
+```ts
var config = {
language: 'chinese'
}
-abilitymanager.updateConfiguration(config).then(() => {
+abilityManager.updateConfiguration(config).then(() => {
console.log('updateConfiguration success');
}).catch((err) => {
console.log('updateConfiguration fail');
@@ -112,14 +108,12 @@ Obtains the ability running information. This API uses an asynchronous callback
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
-| callback | AsyncCallback\> | Yes | Callback used to return the result. |
+| callback | AsyncCallback\> | Yes | Callback used to return the result. |
**Example**
-```js
-import abilitymanager from '@ohos.application.abilityManager';
-
-abilitymanager.getAbilityRunningInfos((err,data) => {
+```ts
+abilityManager.getAbilityRunningInfos((err,data) => {
console.log("getAbilityRunningInfos err: " + err + " data: " + JSON.stringify(data));
});
```
@@ -138,14 +132,12 @@ Obtains the ability running information. This API uses a promise to return the r
| Type | Description |
| ---------------------------------------- | ------- |
-| Promise\> | Promise used to return the result.|
+| Promise\