From 34ed2be94db24711bf58c2982837bbdaf30a63fd Mon Sep 17 00:00:00 2001 From: Gloria Date: Thu, 1 Dec 2022 11:01:59 +0800 Subject: [PATCH] Update docs against 11278+11480+11618+11384+11654+11518+10458+11718+11642+11687+11639 Signed-off-by: wusongqing --- .../reference/apis/Readme-EN.md | 43 +- .../js-apis-Bundle-BundleStatusCallback.md | 14 +- .../apis/js-apis-Bundle-InnerBundleManager.md | 73 +- .../reference/apis/js-apis-Bundle.md | 1509 ++------- .../reference/apis/js-apis-appControl.md | 324 ++ .../apis/js-apis-bundle-AbilityInfo.md | 19 +- .../apis/js-apis-bundle-ApplicationInfo.md | 17 +- .../apis/js-apis-bundle-BundleInfo.md | 16 +- .../apis/js-apis-bundle-BundleInstaller.md | 60 +- .../apis/js-apis-bundle-CustomizeData.md | 10 +- .../apis/js-apis-bundle-ElementName.md | 7 +- .../js-apis-bundle-ExtensionAbilityInfo.md | 28 - .../apis/js-apis-bundle-HapModuleInfo.md | 10 +- .../js-apis-bundle-LauncherAbilityInfo.md | 4 +- .../reference/apis/js-apis-bundle-Metadata.md | 18 - .../apis/js-apis-bundle-ModuleInfo.md | 11 +- .../apis/js-apis-bundle-PermissionDef.md | 4 +- .../apis/js-apis-bundleManager-abilityInfo.md | 53 + .../js-apis-bundleManager-applicationInfo.md | 34 + .../apis/js-apis-bundleManager-bundleInfo.md | 65 + .../js-apis-bundleManager-dispatchInfo.md | 18 + .../apis/js-apis-bundleManager-elementName.md | 3 +- ...apis-bundleManager-extensionAbilityInfo.md | 28 + .../js-apis-bundleManager-hapModuleInfo.md | 27 + ...-apis-bundleManager-launcherAbilityInfo.md | 18 + .../apis/js-apis-bundleManager-metadata.md | 15 + ...o.md => js-apis-bundleManager-packInfo.md} | 118 +- .../js-apis-bundleManager-permissionDef.md | 20 + .../reference/apis/js-apis-bundleManager.md | 2905 +++++++++++++++++ .../reference/apis/js-apis-bundleMonitor.md | 104 + .../reference/apis/js-apis-cert.md | 2419 -------------- ...nfig-policy.md => js-apis-configPolicy.md} | 0 ...anager.md => js-apis-defaultAppManager.md} | 245 +- .../reference/apis/js-apis-dispatchInfo.md | 18 - .../apis/js-apis-distributedBundle.md | 150 +- .../apis/js-apis-enterprise-device-manager.md | 975 ------ ...riseDeviceManager-DeviceSettingsManager.md | 123 - .../reference/apis/js-apis-freeInstall.md | 422 +++ .../reference/apis/js-apis-installer.md | 300 ++ .../apis/js-apis-launcherBundleManager.md | 304 ++ .../reference/apis/js-apis-net-policy.md | 1120 ------- .../reference/apis/js-apis-net-statistics.md | 409 --- .../reference/apis/js-apis-tlsSocket.md | 486 --- ...cessToken.md => errorcode-Access-token.md} | 0 ...le.md => errorcode-DistributedSchedule.md} | 0 ...{errcode-bundle.md => errorcode-bundle.md} | 122 +- ...linput.md => errorcode-multimodalinput.md} | 0 .../reference/errorcodes/errorcode-sensors.md | 40 - 48 files changed, 5425 insertions(+), 7283 deletions(-) create mode 100644 en/application-dev/reference/apis/js-apis-appControl.md delete mode 100644 en/application-dev/reference/apis/js-apis-bundle-ExtensionAbilityInfo.md delete mode 100644 en/application-dev/reference/apis/js-apis-bundle-Metadata.md create mode 100644 en/application-dev/reference/apis/js-apis-bundleManager-abilityInfo.md create mode 100644 en/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md create mode 100644 en/application-dev/reference/apis/js-apis-bundleManager-bundleInfo.md create mode 100644 en/application-dev/reference/apis/js-apis-bundleManager-dispatchInfo.md create mode 100644 en/application-dev/reference/apis/js-apis-bundleManager-extensionAbilityInfo.md create mode 100644 en/application-dev/reference/apis/js-apis-bundleManager-hapModuleInfo.md create mode 100644 en/application-dev/reference/apis/js-apis-bundleManager-launcherAbilityInfo.md create mode 100644 en/application-dev/reference/apis/js-apis-bundleManager-metadata.md rename en/application-dev/reference/apis/{js-apis-bundle-PackInfo.md => js-apis-bundleManager-packInfo.md} (59%) create mode 100644 en/application-dev/reference/apis/js-apis-bundleManager-permissionDef.md create mode 100644 en/application-dev/reference/apis/js-apis-bundleManager.md create mode 100644 en/application-dev/reference/apis/js-apis-bundleMonitor.md delete mode 100644 en/application-dev/reference/apis/js-apis-cert.md rename en/application-dev/reference/apis/{js-apis-config-policy.md => js-apis-configPolicy.md} (100%) rename en/application-dev/reference/apis/{js-apis-bundle-defaultAppManager.md => js-apis-defaultAppManager.md} (68%) delete mode 100644 en/application-dev/reference/apis/js-apis-dispatchInfo.md delete mode 100644 en/application-dev/reference/apis/js-apis-enterprise-device-manager.md delete mode 100644 en/application-dev/reference/apis/js-apis-enterpriseDeviceManager-DeviceSettingsManager.md create mode 100644 en/application-dev/reference/apis/js-apis-freeInstall.md create mode 100644 en/application-dev/reference/apis/js-apis-installer.md create mode 100644 en/application-dev/reference/apis/js-apis-launcherBundleManager.md delete mode 100644 en/application-dev/reference/apis/js-apis-net-policy.md delete mode 100644 en/application-dev/reference/apis/js-apis-net-statistics.md delete mode 100644 en/application-dev/reference/apis/js-apis-tlsSocket.md rename en/application-dev/reference/errorcodes/{errorcode-AccessToken.md => errorcode-Access-token.md} (100%) rename en/application-dev/reference/errorcodes/{errcode-DistributedSchedule.md => errorcode-DistributedSchedule.md} (100%) rename en/application-dev/reference/errorcodes/{errcode-bundle.md => errorcode-bundle.md} (59%) rename en/application-dev/reference/errorcodes/{errorcodes-multimodalinput.md => errorcode-multimodalinput.md} (100%) delete mode 100644 en/application-dev/reference/errorcodes/errorcode-sensors.md diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 8c3b7c6998..32c2d5b1d1 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -6,7 +6,7 @@ - [@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) + - app/[context](js-apis-Context.md) - Stage Model - [@ohos.application.Ability](js-apis-application-ability.md) - [@ohos.application.AbilityConstant](js-apis-application-abilityConstant.md) @@ -60,13 +60,34 @@ - [@ohos.notification](js-apis-notification.md) - application/[EventHub](js-apis-eventhub.md) - Bundle Management + - [@ohos.bundle.appControl](js-apis-appControl.md) + - [@ohos.bundle.bundleManager](js-apis-bundleManager.md) + - [@ohos.bundle.bundleMonitor](js-apis-bundleMonitor.md) + - [@ohos.bundle.defaultAppManager](js-apis-defaultAppManager.md) + - [@ohos.bundle.distributedBundle](js-apis-distributedBundle.md) + - [@ohos.bundle.freeInstall](js-apis-freeInstall.md) + - [@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) - UI Page - [@ohos.animator](js-apis-animator.md) - [@ohos.mediaquery](js-apis-mediaquery.md) - [@ohos.promptAction](js-apis-promptAction.md) - [@ohos.router](js-apis-router.md) - - Graphics +- Graphics - [@ohos.animation.windowAnimationManager](js-apis-windowAnimationManager.md) - [@ohos.display ](js-apis-display.md) - [@ohos.effectKit](js-apis-effectKit.md) @@ -85,8 +106,7 @@ - [@ohos.i18n](js-apis-i18n.md) - [@ohos.intl](js-apis-intl.md) - [@ohos.resourceManager](js-apis-resource-manager.md) -- Resource Scheduling - - [@ohos.backgroundTaskManager](js-apis-backgroundTaskManager.md) +- Resource Scheduling - [@ohos.distributedMissionManager](js-apis-distributedMissionManager.md) - [@ohos.reminderAgentManager](js-apis-reminderAgentManager.md) - [@ohos.resourceschedule.backgroundTaskManager](js-apis-resourceschedule-backgroundTaskManager.md) @@ -96,8 +116,7 @@ - Security - [@ohos.abilityAccessCtrl](js-apis-abilityAccessCtrl.md) - [@ohos.privacyManager](js-apis-privacyManager.md) - - [@ohos.security.cert](js-apis-cert.md) - - [@ohos.security.cryptoFramework]js-apis-cryptoFramework.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) @@ -136,11 +155,8 @@ - [@ohos.net.connection](js-apis-net-connection.md) - [@ohos.net.ethernet](js-apis-net-ethernet.md) - [@ohos.net.http](js-apis-http.md) - - [@ohos.net.policy](js-apis-net-policy.md) - [@ohos.net.sharing](js-apis-net-sharing.md) - [@ohos.net.socket](js-apis-socket.md) - - [@ohos.net.statistics](js-apis-net-statistics.md) - - [@ohos.net.tlsSocket](js-apis-tlsSocket.md) - [@ohos.net.webSocket](js-apis-webSocket.md) - [@ohos.request](js-apis-request.md) - Connectivity @@ -197,19 +213,18 @@ - [@ohos.runningLock](js-apis-runninglock.md) - [@ohos.sensor](js-apis-sensor.md) - [@ohos.settings](js-apis-settings.md) + - [@ohos.systemParameterV9](js-apis-system-parameterV9.md) - [@ohos.thermal](js-apis-thermal.md) - [@ohos.update](js-apis-update.md) - [@ohos.usb](js-apis-usb.md) - [@ohos.vibrator](js-apis-vibrator.md) -- Account Management +- Account Management - [@ohos.account.appAccount](js-apis-appAccount.md) - [@ohos.account.distributedAccount](js-apis-distributed-account.md) - [@ohos.account.osAccount](js-apis-osAccount.md) - Custom Management - - [@ohos.configPolicy](js-apis-config-policy.md) + - [@ohos.configPolicy](js-apis-configPolicy.md) - [@ohos.EnterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md) - - [@ohos.enterpriseDeviceManager](js-apis-enterprise-device-manager.md) - - enterpriseDeviceManager/[DeviceSettingsManager](js-apis-enterpriseDeviceManager-DeviceSettingsManager.md) - Language Base Class Library - [@ohos.buffer](js-apis-buffer.md) - [@ohos.convertxml](js-apis-convertxml.md) @@ -252,6 +267,7 @@ - [@ohos.prompt](js-apis-prompt.md) - [@ohos.reminderAgent](js-apis-reminderAgent.md) - [@ohos.systemParameter](js-apis-system-parameter.md) + - [@ohos.workScheduler](js-apis-workScheduler.md) - [@system.app](js-apis-system-app.md) - [@system.battery](js-apis-system-battery.md) - [@system.bluetooth](js-apis-system-bluetooth.md) @@ -277,6 +293,7 @@ - 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) diff --git a/en/application-dev/reference/apis/js-apis-Bundle-BundleStatusCallback.md b/en/application-dev/reference/apis/js-apis-Bundle-BundleStatusCallback.md index 2f601b1407..b3476c86cc 100644 --- a/en/application-dev/reference/apis/js-apis-Bundle-BundleStatusCallback.md +++ b/en/application-dev/reference/apis/js-apis-Bundle-BundleStatusCallback.md @@ -4,16 +4,18 @@ The **BundleStatusCallback** module provides bundle callback information, which > **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. +> This module is deprecated since API version 9. You are advised to use [bundleMonitor](js-apis-bundleMonitor.md) instead. -## BundleStatusCallback + +## BundleStatusCallback(deprecated) +> This API is deprecated since API version 9. You are advised to use [bundleMonitor](js-apis-bundleMonitor.md) instead. **System API**: This is a system API and cannot be called by third-party applications. **System capability**: SystemCapability.BundleManager.BundleFramework -| Name | Type | Description | +| Type | Callback | Description | | ------ | --------------------------------------------- | -------------------------------------- | -| add | (bundleName : string, userId: number) => void | Callback invoked when a **launcherStatusCallback** is added.| -| update | (bundleName : string, userId: number) => void | Callback invoked when a **launcherStatusCallback** is updated.| -| remove | (bundleName : string, userId: number) => void | Callback invoked when a **launcherStatusCallback** is removed.| +| add | (bundleName : string, userId: number) => void | Used to obtain information when a bundle is installed.| +| update | (bundleName : string, userId: number) => void | Used to obtain information when a bundle is updated.| +| remove | (bundleName : string, userId: number) => void | Used to obtain information when a bundle is uninstalled.| 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 8beab3711f..9d023410ff 100644 --- a/en/application-dev/reference/apis/js-apis-Bundle-InnerBundleManager.md +++ b/en/application-dev/reference/apis/js-apis-Bundle-InnerBundleManager.md @@ -1,14 +1,14 @@ -# innerBundleManager +# innerBundleManager(deprecated) -The **innerBundleManager** module manages internal bundles. +The **innerBundleManager** module provides APIs for the **Home Screen** 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. +> 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. ## Modules to Import -``` +```typescript import innerBundleManager from '@ohos.bundle.innerBundleManager'; ``` @@ -16,20 +16,13 @@ import innerBundleManager from '@ohos.bundle.innerBundleManager'; SystemCapability.BundleManager.BundleFramework -## Required Permissions - -| Permission | Permission Level | Description | -| ------------------------------------------ | ------------ | ---------------------------- | -| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | Permission to query information about all applications. | -| ohos.permission.LISTEN_BUNDLE_CHANGE | system_grant | Permission to listen for application changes.| - -For details, see [Permission Levels](../../security/accesstoken-overview.md#permission-levels). -## innerBundleManager.getLauncherAbilityInfos +## innerBundleManager.getLauncherAbilityInfos(deprecated) getLauncherAbilityInfos(bundleName: string, userId: number, callback: AsyncCallback<Array<LauncherAbilityInfo>>) : void; Obtains the launcher ability information based on a given bundle name. This API uses an asynchronous callback to return the result. +> This API is deprecated since API version 9. You are advised to use [launcherBundleManager#getLauncherAbilityInfo](js-apis-launcherBundleManager.md) instead. **Required permissions** @@ -45,19 +38,19 @@ This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory| Description | +| 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.| | callback | AsyncCallback\> | Yes | Callback used to return an array of the launcher ability information. | - -## innerBundleManager.getLauncherAbilityInfos +## innerBundleManager.getLauncherAbilityInfos(deprecated) getLauncherAbilityInfos(bundleName: string, userId: number) : Promise<Array<LauncherAbilityInfo>> Obtains the launcher ability information based on a given bundle name. This API uses a promise to return the result. +> This API is deprecated since API version 9. You are advised to use [launcherBundleManager#getLauncherAbilityInfo](js-apis-launcherBundleManager.md) instead. **Required permissions** @@ -73,7 +66,7 @@ This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory| Description | +| 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.| @@ -84,11 +77,12 @@ This is a system API and cannot be called by third-party applications. | ------------------------------------------------------------ | ------------------------- | | Promise\> | Promise used to return an array of the launcher ability information.| -## innerBundleManager.on +## innerBundleManager.on(deprecated) on(type:"BundleStatusChange", bundleStatusCallback : BundleStatusCallback, callback: AsyncCallback<string>) : void; Registers a callback to receive bundle status changes. This API uses an asynchronous callback to return the result. +> This API is deprecated since API version 9. You are advised to use [bundleMonitor#on](js-apis-bundleMonitor.md) instead. **Required permissions** @@ -104,17 +98,18 @@ This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | -------------------- | --------------------- | ---- | ---------------------------------------------------- | | type | string | Yes | Event type. Only **BundleStatusChange** is supported. | | bundleStatusCallback | [BundleStatusCallback](js-apis-Bundle-BundleStatusCallback.md) | Yes | Callback to register. | | callback | AsyncCallback\ | Yes | Callback used to return a successful result or error information.| -## innerBundleManager.on +## innerBundleManager.on(deprecated) -on(type:"BundleStatusChange", bundleStatusCallback : BundleStatusCallback): Promise<string> +on(type:"BundleStatusChange", bundleStatusCallback : BundleStatusCallback) : Promise<string> Registers a callback to receive bundle status changes. This API uses a promise to return the result. +> This API is deprecated since API version 9. You are advised to use [bundleMonitor#on](js-apis-bundleMonitor.md) instead. **Required permissions** @@ -130,7 +125,7 @@ This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | -------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------ | | type | string | Yes | Event type. Only **BundleStatusChange** is supported.| | bundleStatusCallback | [BundleStatusCallback](js-apis-Bundle-BundleStatusCallback.md) | Yes | Callback to register. | @@ -141,11 +136,12 @@ This is a system API and cannot be called by third-party applications. | --------------- | ----------------------------------- | | Promise\ | Promise used to return a successful result or error information.| -## innerBundleManager.off +## innerBundleManager.off(deprecated) off(type:"BundleStatusChange", callback: AsyncCallback<string>) : void; Deregisters the callback that receives bundle status changes. This API uses an asynchronous callback to return the result. +> This API is deprecated since API version 9. You are advised to use [bundleMonitor#off](js-apis-bundleMonitor.md) instead. **Required permissions** @@ -161,16 +157,17 @@ This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ---------------------------------------------------- | | type | string | Yes | Event type. Only **BundleStatusChange** is supported. | | callback | AsyncCallback\ | Yes | Callback used to return a successful result or error information.| -## innerBundleManager.off +## innerBundleManager.off(deprecated) -off(type:"BundleStatusChange"): Promise<string> +off(type:"BundleStatusChange") : Promise<string> Deregisters the callback that receives bundle status changes. This API uses a promise to return the result. +> This API is deprecated since API version 9. You are advised to use [bundleMonitor#off](js-apis-bundleMonitor.md) instead. **Required permissions** @@ -187,8 +184,8 @@ This is a system API and cannot be called by third-party applications. **Parameters** | Name| Type | Mandatory| Description | -| ---- | ------ | ---- | ------------------------------------------ | -| type | string | Yes | Event type. Only **BundleStatusChange** is supported.| +| ------ | ------ | ---- | ------------------------------------------ | +| type | string | Yes | Event type. Only **BundleStatusChange** is supported.| **Return value** @@ -196,11 +193,12 @@ This is a system API and cannot be called by third-party applications. | --------------- | ----------------------------------- | | Promise\ | Promise used to return a successful result or error information.| -## innerBundleManager.getAllLauncherAbilityInfos +## innerBundleManager.getAllLauncherAbilityInfos(deprecated) getAllLauncherAbilityInfos(userId: number, callback: AsyncCallback<Array<LauncherAbilityInfo>>) : void; Obtains the information about all launcher abilities. This API uses an asynchronous callback to return the result. +> This API is deprecated since API version 9. You are advised to use [launcherBundleManager#getAllLauncherAbilityInfo](js-apis-launcherBundleManager.md) instead. **Required permissions** @@ -216,16 +214,17 @@ This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory| Description | +| 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.| | callback | AsyncCallback\> | Yes | Callback used to return an array of the launcher ability information. | -## innerBundleManager.getAllLauncherAbilityInfos +## innerBundleManager.getAllLauncherAbilityInfos(deprecated) getAllLauncherAbilityInfos(userId: number) : Promise<Array<LauncherAbilityInfo>> Obtains the information about all launcher abilities. This API uses a promise to return the result. +> This API is deprecated since API version 9. You are advised to use [launcherBundleManager#getAllLauncherAbilityInfo](js-apis-launcherBundleManager.md) instead. **Required permissions** @@ -241,7 +240,7 @@ This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory| Description | +| 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.| @@ -251,11 +250,12 @@ This is a system API and cannot be called by third-party applications. | ------------------------------------------------------------ | ------------------------- | | Promise\> | Promise used to return an array of the launcher ability information.| -## innerBundleManager.getShortcutInfos +## innerBundleManager.getShortcutInfos(deprecated) getShortcutInfos(bundleName :string, callback: AsyncCallback<Array<ShortcutInfo>>) : void; Obtains the shortcut information based on a given bundle name. This API uses an asynchronous callback to return the result. +> This API is deprecated since API version 9. You are advised to use [launcherBundleManager#getShortcutInfo](js-apis-launcherBundleManager.md) instead. **Required permissions** @@ -271,16 +271,17 @@ This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | ---------- | ------------------------------------------------------------ | ---- | ---------------------------------------------- | | bundleName | string | Yes | Bundle name of an application. | | callback | AsyncCallback\> | Yes | Callback used to return an array of the shortcut information.| -## innerBundleManager.getShortcutInfos +## innerBundleManager.getShortcutInfos(deprecated) getShortcutInfos(bundleName : string) : Promise<Array<ShortcutInfo>> Obtains the shortcut information based on a given bundle name. This API uses a promise to return the result. +> This API is deprecated since API version 9. You are advised to use [launcherBundleManager#getShortcutInfo](js-apis-launcherBundleManager.md) instead. **Required permissions** @@ -296,7 +297,7 @@ This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | ---------- | ------ | ---- | ------------------------ | | bundleName | string | Yes | Bundle name of an application.| diff --git a/en/application-dev/reference/apis/js-apis-Bundle.md b/en/application-dev/reference/apis/js-apis-Bundle.md index ca3b0873ab..52a10b74d2 100644 --- a/en/application-dev/reference/apis/js-apis-Bundle.md +++ b/en/application-dev/reference/apis/js-apis-Bundle.md @@ -3,9 +3,8 @@ The **Bundle** module provides APIs for querying the information about bundles, applications, abilities, Extension abilities, and application states. > **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. -> API version 9 is a canary version for trial use. The APIs of this version may be unstable. ## Modules to Import ```js @@ -21,9 +20,11 @@ import bundle from '@ohos.bundle'; | 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. | -For details, see "Permission Levels" in [Access Control Overview](../../security/accesstoken-overview.md). +For details, see [Permission Levels](../../security/accesstoken-overview.md#permission-levels). -## bundle.getApplicationInfo +## bundle.getApplicationInfodeprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo) instead. getApplicationInfo(bundleName: string, bundleFlags: number, userId?: number): Promise\ @@ -39,7 +40,7 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory| Description | +| 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).| @@ -65,7 +66,9 @@ bundle.getApplicationInfo(bundleName, bundleFlags, userId) }) ``` -## bundle.getApplicationInfo +## bundle.getApplicationInfodeprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo) instead. getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback\): void @@ -81,7 +84,7 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory| Description | +| 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).| @@ -103,7 +106,10 @@ bundle.getApplicationInfo(bundleName, bundleFlags, userId, (err, data) => { }) ``` -## bundle.getApplicationInfo +## bundle.getApplicationInfodeprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo) instead. + getApplicationInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\): void @@ -119,7 +125,7 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory| Description | +| 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).| @@ -139,81 +145,10 @@ bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => { }) ``` -## bundle.getApplicationInfoSync9+ - -getApplicationInfoSync(bundleName: string, bundleFlags: number, userId: number): ApplicationInfo; - -Obtains the application information of the specified user based on a given bundle name. This API returns the result synchronously. - -**Required permissions** - -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO - -**System capability** - -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 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. | - -**Return value** - -| Type | Description | -| ---------------------------------------------------- | ------------------- | -| [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | **ApplicationInfo** object.| - -**Example** - -```js -let bundleName = "com.example.myapplication"; -let bundleFlags = 0; -let userId = 100; -var applicationInfo = bundle.getApplicationInfoSync(bundleName, bundleFlags, userId); -console.info('Operation successful. Name:' + applicationInfo.name); -``` - -## bundle.getApplicationInfoSync9+ -getApplicationInfoSync(bundleName: string, bundleFlags: number) : ApplicationInfo; +## bundle.getAllBundleInfodeprecated -Obtains the application information based on a given bundle name. This API returns the result synchronously. - -**Required permissions** - -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO - -**System capability** - -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 application information flags in [BundleFlag](#bundleflag).| - -**Return value** - -| Type | Description | -| ---------------------------------------------------- | ------------------- | -| [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | **ApplicationInfo** object.| - -**Example** - -```js -let bundleName = "com.example.myapplication"; -let bundleFlags = 0; -var applicationInfo = bundle.getApplicationInfoSync(bundleName, bundleFlags); -console.info('Operation successful. Name:' + applicationInfo.name); -``` - -## bundle.getAllBundleInfo +> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllBundleInfo](js-apis-bundleManager.md#bundlemanagergetallbundleinfo) instead. getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise> @@ -229,7 +164,7 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory| Description | +| 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 | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | @@ -253,7 +188,10 @@ bundle.getAllBundleInfo(bundleFlag, userId) }) ``` -## bundle.getAllBundleInfo +## bundle.getAllBundleInfodeprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllBundleInfo](js-apis-bundleManager.md#bundlemanagergetallbundleinfo) instead. + getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback>): void @@ -269,7 +207,7 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory| Description | +| 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. | @@ -287,7 +225,10 @@ bundle.getAllBundleInfo(bundleFlag, (err, data) => { }) ``` -## bundle.getAllBundleInfo +## bundle.getAllBundleInfodeprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllBundleInfo](js-apis-bundleManager.md#bundlemanagergetallbundleinfo) instead. + getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback>): void @@ -303,7 +244,7 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory| Description | +| 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. | @@ -323,7 +264,10 @@ bundle.getAllBundleInfo(bundleFlag, userId, (err, data) => { }) ``` -## bundle.getBundleInfo +## bundle.getBundleInfodeprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo) instead. + getBundleInfo(bundleName: string, bundleFlags: number, options?: BundleOptions): Promise\ @@ -339,7 +283,7 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | +| 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).| @@ -367,7 +311,9 @@ bundle.getBundleInfo(bundleName, bundleFlags, options) }) ``` -## bundle.getBundleInfo +## bundle.getBundleInfodeprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo) instead. getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\): void @@ -383,7 +329,7 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory| Description | +| 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).| @@ -404,7 +350,9 @@ bundle.getBundleInfo(bundleName, bundleFlags, (err, data) => { ``` -## bundle.getBundleInfo +## bundle.getBundleInfodeprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo) instead. getBundleInfo(bundleName: string, bundleFlags: number, options: BundleOptions, callback: AsyncCallback\): void @@ -420,7 +368,7 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory| Description | +| 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).| @@ -444,83 +392,11 @@ bundle.getBundleInfo(bundleName, bundleFlags, options, (err, data) => { }) ``` -## bundle.getBundleInfoSync9+ -getBundleInfoSync(bundleName: string, bundleFlags: number, options: BundleOptions): BundleInfo; -Obtains the bundle information based on a given bundle name and bundle options. This API returns the result synchronously. +## bundle.getBundleInstallerdeprecated -**Required permissions** - -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO - -**System capability** - -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) | Yes | Options of the bundle. | - -**Return value** - -| Type | Description | -| ------------------------------------------ | -------------- | -| [BundleInfo](js-apis-bundle-BundleInfo.md) | **BundleInfo** object.| - -**Example** - -```js -let bundleName = "com.example.myapplication"; -let bundleFlags = 1; -let options = { - "userId" : 100 -}; -var bundleInfo = bundle.getBundleInfoSync(bundleName, bundleFlags, options); -console.info('Operation successful. Name:' + bundleInfo.name); -``` - -## bundle.getBundleInfoSync9+ - -getBundleInfoSync(bundleName: string, bundleFlags: number): BundleInfo; - -Obtains the bundle information based on a given bundle name. This API returns the result synchronously. - -**Required permissions** - -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO - -**System capability** - -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).| - -**Return value** - -| Type | Description | -| ------------------------------------------ | -------------- | -| [BundleInfo](js-apis-bundle-BundleInfo.md) | **BundleInfo** object.| - -**Example** - -```js -let bundleName = "com.example.myapplication"; -let bundleFlags = 1; -var bundleInfo = bundle.getBundleInfoSync(bundleName, bundleFlags); -console.info('Operation successful. Name:' + bundleInfo.name); -``` - -## bundle.getBundleInstaller +> This API is deprecated since API version 9. You are advised to use [installer.getBundleInstaller](js-apis-installer.md#bundleinstallergetbundleinstaller) instead. getBundleInstaller(): Promise<BundleInstaller>; @@ -544,7 +420,9 @@ This is a system API and cannot be called by third-party applications. | ------------------------------------------------------------ | -------------------------------------------- | | Promise<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | Promise used to return the installation package information.| -## bundle.getBundleInstaller +## bundle.getBundleInstallerdeprecated + +> This API is deprecated since API version 9. You are advised to use [installer.getBundleInstaller](js-apis-installer.md#bundleinstallergetbundleinstaller) instead. getBundleInstaller(callback: AsyncCallback<BundleInstaller>): void; @@ -564,11 +442,13 @@ This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ---------------- | | callback | AsyncCallback<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | Yes | Callback used to return the installation package information.| -## bundle.cleanBundleCacheFiles8+ +## bundle.cleanBundleCacheFiles8+ deprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.cleanBundleCacheFiles](js-apis-bundleManager.md#bundlemanagercleanbundlecachefiles) instead. cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback<void>): void; @@ -588,12 +468,14 @@ This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | ---------- | ------------------- | ---- | ------------------------------------- | | bundleName | string | Yes | Bundle name of an application.| | callback | AsyncCallback\ | Yes | Callback used to return the result. | -## bundle.cleanBundleCacheFiles8+ +## bundle.cleanBundleCacheFiles8+ deprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.cleanBundleCacheFiles](js-apis-bundleManager.md#bundlemanagercleanbundlecachefiles) instead. cleanBundleCacheFiles(bundleName: string): Promise<void> @@ -613,7 +495,7 @@ This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | ---------- | ------ | ---- | ------------------------------------- | | bundleName | string | Yes | Bundle name of an application.| @@ -623,7 +505,9 @@ This is a system API and cannot be called by third-party applications. | ------------- | ------------------------------------ | | Promise\ | Promise that returns no value.| -## bundle.setApplicationEnabled8+ +## bundle.setApplicationEnabled8+ deprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.setApplicationEnabled](js-apis-bundleManager.md#bundlemanagersetapplicationenabled) instead. setApplicationEnabled(bundleName: string, isEnable: boolean, callback: AsyncCallback<void>): void; @@ -643,13 +527,15 @@ This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | ---------- | ------------------- | ---- | ----------------------------------------------- | | bundleName | string | Yes | Bundle name of an 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. | -## bundle.setApplicationEnabled8+ +## bundle.setApplicationEnabled8+ deprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.setApplicationEnabled](js-apis-bundleManager.md#bundlemanagersetapplicationenabled) instead. setApplicationEnabled(bundleName: string, isEnable: boolean): Promise<void> @@ -669,7 +555,7 @@ This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | ---------- | ------- | ---- | ----------------------------------------------- | | bundleName | string | Yes | Bundle name of an application. | | isEnable | boolean | Yes | Whether to enable the application. The value **true** means to enable the application, and **false** means the opposite.| @@ -680,7 +566,9 @@ This is a system API and cannot be called by third-party applications. | ------------- | ------------------------------------ | | Promise\ | Promise that returns no value.| -## bundle.setAbilityEnabled8+ +## bundle.setAbilityEnabled8+ deprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.setAbilityEnabled](js-apis-bundleManager.md#bundlemanagersetabilityenabled) instead. setAbilityEnabled(info: AbilityInfo, isEnable: boolean, callback: AsyncCallback<void>): void; @@ -700,13 +588,15 @@ This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | -------- | -------------------------------------------- | ---- | ----------------------------------------------- | | info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes | Ability information. | -| isEnable | boolean | Yes | Whether to enable the ability. The value **true** means to enable the ability, and **false** means the opposite.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. | +| 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. | + +## bundle.setAbilityEnabled8+ deprecated -## bundle.setAbilityEnabled8+ +> This API is deprecated since API version 9. You are advised to use [bundleManager.setAbilityEnabled](js-apis-bundleManager.md#bundlemanagersetabilityenabled) instead. setAbilityEnabled(info: AbilityInfo, isEnable: boolean): Promise<void> @@ -726,10 +616,10 @@ This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | -------- | -------------------------------------------- | ---- | ----------------------------------------------- | | info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes | Ability information. | -| isEnable | boolean | Yes | Whether to enable the ability. The value **true** means to enable the ability, and **false** means the opposite.| +| isEnable | boolean | Yes | Whether to enable the application. The value **true** means to enable the application, and **false** means the opposite.| **Return value** @@ -737,7 +627,9 @@ This is a system API and cannot be called by third-party applications. | ------------- | ------------------------------------ | | Promise\ | Promise that returns no value.| -## bundle.getPermissionDef8+ +## bundle.getPermissionDef8+ deprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.getPermissionDef](js-apis-bundleManager.md#bundlemanagergetpermissiondef) instead. getPermissionDef(permissionName: string, callback: AsyncCallback<PermissionDef>): void; @@ -757,12 +649,14 @@ This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------ | | permissionName | string | Yes | Name of the permission. | | callback | AsyncCallback<[PermissionDef](js-apis-bundle-PermissionDef)> | Yes | Callback used to return the permission details.| -## bundle.getPermissionDef8+ +## bundle.getPermissionDef8+ deprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.getPermissionDef](js-apis-bundleManager.md#bundlemanagergetpermissiondef) instead. getPermissionDef(permissionName: string): Promise<PermissionDef> @@ -782,7 +676,7 @@ This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | -------------- | ------ | ---- | ---------------- | | permissionName | string | Yes | Name of the permission.| @@ -792,196 +686,10 @@ 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.| -## bundle.setModuleUpgradeFlag9+ - -setModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag, callback: AsyncCallback<void>):void; - -Sets whether the module needs an upgrade. This API uses an asynchronous callback to return the result. - -**System capability** - -SystemCapability.BundleManager.BundleFramework - -**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 of an application. | -| moduleName | string | Yes | Module name of the application. | -| upgradeFlag | [UpgradeFlag](#upgradeflag) | Yes | Upgrade flag, which is used only by the internal system. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -## bundle.setModuleUpgradeFlag9+ - -setModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag): Promise<void> - -Sets whether the module needs an upgrade. This API uses a promise to return the result. - -**System capability** - -SystemCapability.BundleManager.BundleFramework - -**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 of an application. | -| moduleName | string | Yes | Module name of the application. | -| upgradeFlag | [UpgradeFlag](#upgradeflag) | Yes | Upgrade flag, which is for internal use only.| - -**Return value** - -| Type | Description | -| ------------- | ------------------------------------ | -| Promise\ | Promise that returns no value.| - -## bundle.isModuleRemovable9+ - -isModuleRemovable(bundleName: string, moduleName: string, callback: AsyncCallback<boolean>): void; - -Checks whether a module is removable. This API uses an asynchronous callback to return the result. - -**System capability** - -SystemCapability.BundleManager.BundleFramework - -**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 of an application. | -| moduleName | string | Yes | Module name of the application. | -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the module is removable, **true** is returned. Otherwise, **false** is returned.| - -## bundle.isModuleRemovable9+ - -isModuleRemovable(bundleName: string, moduleName: string): Promise<boolean> - -Checks whether a module is removable. This API uses a promise to return the result. - -**System capability** - -SystemCapability.BundleManager.BundleFramework - -**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 of an application. | -| moduleName | string | Yes | Module name of the application.| - -**Return value** - -| Type | Description | -| ---------------- | ---------------------------- | -| Promise\ | Promise used to return the result. If the module is removable, **true** is returned. Otherwise, **false** is returned.| - -## bundle.getBundlePackInfo9+ - -getBundlePackInfo(bundleName: string, bundlePackFlag : pack.BundlePackFlag, callback: AsyncCallback<pack.BundlePackInfo>): void; - -Obtains the bundle package information based on a given bundle name and bundle flags. This API uses an asynchronous callback to return the result. - -**System capability** - -SystemCapability.BundleManager.BundleFramework - -**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 of an application. | -| bundlePackFlag | pack.BundlePackFlag | Yes | Flags of the bundle package. | -| callback | AsyncCallback | Yes | Callback used to return the bundle package information.| - -## bundle.getBundlePackInfo9+ - -getBundlePackInfo(bundleName: string, bundlePackFlag : pack.BundlePackFlag): Promise<pack.BundlePackInfo>; - -Obtains the bundle package information based on a given bundle name and bundle flags. This API uses a promise to return the result. - -**System capability** - -SystemCapability.BundleManager.BundleFramework - -**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 of an application. | -| bundlePackFlag | pack.BundlePackFlag | Yes | Flags of the bundle package.| - -**Return value** - -| Type | Description | -| ---------------------------- | ------------------------------------------------------ | -| Promise | Promise used to return the bundle package information. | - -## bundle.getDispatcherVersion9+ - -getDispatcherVersion(callback: AsyncCallback<DispatchInfo>): void; - -Obtains the dispatcher version. This API uses an asynchronous callback to return the result. - -**System capability** - -SystemCapability.BundleManager.BundleFramework -**System API** - -This is a system API and cannot be called by third-party applications. - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| callback | AsyncCallback<[DispatchInfo](js-apis-dispatchInfo.md)> | Yes | Callback used to return the [DispatchInfo](js-apis-dispatchInfo.md).| - -## bundle.getDispatcherVersion9+ - -getDispatcherVersion(): Promise<DispatchInfo>; - -Obtains the dispatcher version. This API uses a promise to return the result. - -**System capability** - -SystemCapability.BundleManager.BundleFramework - -**System API** - -This is a system API and cannot be called by third-party applications. - -**Return value** - -| Type | Description | -| ------------------------------------------------ | ------------------------------------------------------------ | -| Promise<[DispatchInfo](js-apis-dispatchInfo.md)> | Promise used to return the [DispatchInfo](js-apis-dispatchInfo.md).| +## bundle.getAllApplicationInfodeprecated -## bundle.getAllApplicationInfo +> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllApplicationInfo](js-apis-bundleManager.md#bundlemanagergetallapplicationinfo) instead. getAllApplicationInfo(bundleFlags: number, userId?: number): Promise> @@ -997,10 +705,10 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory| Description | +| 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 | No | 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 default value is the user ID of the caller. The value must be greater than or equal to 0. | **Return value** @@ -1021,9 +729,9 @@ bundle.getAllApplicationInfo(bundleFlags, userId) }) ``` +## bundle.getAllApplicationInfodeprecated - -## bundle.getAllApplicationInfo +> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllApplicationInfo](js-apis-bundleManager.md#bundlemanagergetallapplicationinfo) instead. getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback>): void @@ -1039,10 +747,10 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory| Description | +| 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 | No | 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 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** @@ -1060,7 +768,9 @@ bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => { ``` -## bundle.getAllApplicationInfo +## bundle.getAllApplicationInfodeprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllApplicationInfo](js-apis-bundleManager.md#bundlemanagergetallapplicationinfo) instead. getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback>) : void; @@ -1076,7 +786,7 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory| Description | +| 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).| | callback | AsyncCallback> | Yes | Callback used to return the application information. | @@ -1094,7 +804,9 @@ bundle.getAllApplicationInfo(bundleFlags, (err, data) => { }) ``` -## bundle.getBundleArchiveInfo +## bundle.getBundleArchiveInfodeprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.getBundleArchiveInfo](js-apis-bundleManager.md#bundlemanagergetbundlearchiveinfo) instead. getBundleArchiveInfo(hapFilePath: string, bundleFlags: number) : Promise\ @@ -1106,7 +818,7 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | +| 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).| @@ -1129,7 +841,9 @@ bundle.getBundleArchiveInfo(hapFilePath, bundleFlags) }) ``` -## bundle.getBundleArchiveInfo +## bundle.getBundleArchiveInfodeprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.getBundleArchiveInfo](js-apis-bundleManager.md#bundlemanagergetbundlearchiveinfo) instead. getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback\) : void @@ -1141,7 +855,7 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | +| 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).| @@ -1162,7 +876,9 @@ bundle.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => { ``` -## bundle.getAbilityInfo +## bundle.getAbilityInfodeprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo) instead. getAbilityInfo(bundleName: string, abilityName: string): Promise\ @@ -1178,7 +894,7 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | ----------- | ------ | ---- | ---------------- | | bundleName | string | Yes | Bundle name of an application. | | abilityName | string | Yes | Ability name.| @@ -1202,7 +918,9 @@ bundle.getAbilityInfo(bundleName, abilityName) }) ``` -## bundle.getAbilityInfo +## bundle.getAbilityInfodeprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo) instead. getAbilityInfo(bundleName: string, abilityName: string, callback: AsyncCallback\): void; @@ -1218,7 +936,7 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | ----------- | ------------ | ---- | ---------------- | | bundleName | string | Yes | Bundle name of an application. | | abilityName | string | Yes | Ability name.| @@ -1237,89 +955,12 @@ bundle.getAbilityInfo(bundleName, abilityName, (err, data) => { console.info('Operation successful. Data:' + JSON.stringify(data)); }) ``` -## bundle.getAbilityInfo9+ -getAbilityInfo(bundleName: string, moduleName: string, abilityName: string): Promise\ +## bundle.getAbilityLabel8+ deprecated -Obtains the ability information based on a given bundle name, module name, and ability name. This API uses a promise to return the result. +> This API is deprecated since API version 9. You are advised to use [bundleManager.getAbilityLabel](js-apis-bundleManager.md#bundlemanagergetabilitylabel) instead. -**Required permissions** - -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO - -**System capability** - -SystemCapability.BundleManager.BundleFramework - -**Parameters** - -| Name | Type | Mandatory | Description | -| ----------- | ------ | ---- | ---------------- | -| bundleName | string | Yes | Bundle name of an application. | -| moduleName | string | Yes | Module name of the application. | -| abilityName | string | Yes | Ability name.| - -**Return value** - -| Type | Description | -| --------------------- | --------------------- | -| Promise\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Promise used to return the ability information.| - -**Example** - -```js -let bundleName = "com.example.myapplication"; -let moduleName = "entry"; -let abilityName = "com.example.myapplication.MainAbility"; -bundle.getAbilityInfo(bundleName, moduleName, abilityName) -.then((data) => { - console.info('Operation successful. Data: ' + JSON.stringify(data)); -}).catch((error) => { - console.error('Operation failed. Cause: ' + JSON.stringify(error)); -}) -``` - -## bundle.getAbilityInfo9+ - -getAbilityInfo(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback\): void; - -Obtains the ability information based on a given bundle name, module name, and ability name. This API uses an asynchronous callback to return the result. - -**Required permissions** - -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO - -**System capability** - -SystemCapability.BundleManager.BundleFramework - -**Parameters** - -| Name | Type | Mandatory | Description | -| ----------- | ------------ | ---- | ---------------- | -| bundleName | string | Yes | Bundle name of an application. | -| moduleName | string | Yes | Module 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 -let bundleName = "com.example.myapplication"; -let moduleName = "entry"; -let abilityName = "com.example.myapplication.MainAbility"; -bundle.getAbilityInfo(bundleName, moduleName, abilityName, (err, data) => { - if (err) { - console.error('Operation failed. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Operation successful. Data:' + JSON.stringify(data)); -}) -``` - -## bundle.getAbilityLabel8+ - -getAbilityLabel(bundleName: string, abilityName: string): Promise\ +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. @@ -1333,7 +974,7 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | ----------- | ------ | ---- | ---------------- | | bundleName | string | Yes | Bundle name of an application. | | abilityName | string | Yes | Ability name.| @@ -1357,7 +998,9 @@ bundle.getAbilityLabel(bundleName, abilityName) }) ``` -## bundle.getAbilityLabel8+ +## bundle.getAbilityLabel8+ deprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.getAbilityLabel](js-apis-bundleManager.md#bundlemanagergetabilitylabel) instead. getAbilityLabel(bundleName: string, abilityName: string, callback : AsyncCallback\): void @@ -1373,7 +1016,7 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | ----------- | ---------------------- | ---- | ---------------- | | bundleName | string | Yes | Bundle name of an application. | | abilityName | string | Yes | Ability name.| @@ -1392,87 +1035,10 @@ bundle.getAbilityLabel(bundleName, abilityName, (err, data) => { console.info('Operation successful. Data:' + JSON.stringify(data)); }) ``` -## bundle.getAbilityLabel9+ - -getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Promise\ - -Obtains the application name based on a given bundle name, module name, and ability name. This API uses a promise to return the result. - -**Required permissions** - -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO - -**System capability** - -SystemCapability.BundleManager.BundleFramework - -**Parameters** -| Name | Type | Mandatory | Description | -| ----------- | ------ | ---- | ---------------- | -| bundleName | string | Yes | Bundle name of an application. | -| moduleName | string | Yes | Module name of the application. | -| abilityName | string | Yes | Ability name.| +## bundle.isAbilityEnabled8+ deprecated -**Return value** - -| Type | Description | -| ---------------- | ------------------ | -| Promise\ | Promise used to return the application name.| - -**Example** - -```js -let bundleName = "com.example.myapplication"; -let moduleName = "entry"; -let abilityName = "com.example.myapplication.MainAbility"; -bundle.getAbilityLabel(bundleName, moduleName, abilityName) -.then((data) => { - console.info('Operation successful. Data: ' + JSON.stringify(data)); -}).catch((error) => { - console.error('Operation failed. Cause: ' + JSON.stringify(error)); -}) -``` - -## bundle.getAbilityLabel9+ - -getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, callback : AsyncCallback\): void - -Obtains the application name based on a given bundle name, module name, and ability name. This API uses an asynchronous callback to return the result. - -**Required permissions** - -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO - -**System capability** - -SystemCapability.BundleManager.BundleFramework - -**Parameters** - -| Name | Type | Mandatory | Description | -| ----------- | ---------------------- | ---- | ---------------- | -| bundleName | string | Yes | Bundle name of an application. | -| moduleName | string | Yes | Module name of the application. | -| abilityName | string | Yes | Ability name.| -| callback | AsyncCallback\ | Yes | Callback used to return the application name. | - -**Example** - -```js -let bundleName = "com.example.myapplication"; -let moduleName = "entry"; -let abilityName = "com.example.myapplication.MainAbility"; -bundle.getAbilityLabel(bundleName, moduleName, abilityName, (err, data) => { - if (err) { - console.error('Operation failed. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Operation successful. Data:' + JSON.stringify(data)); -}) -``` - -## bundle.isAbilityEnabled8+ +> This API is deprecated since API version 9. You are advised to use [bundleManager.isAbilityEnabled](js-apis-bundleManager.md#bundlemanagerisabilityenabled) instead. isAbilityEnabled(info: AbilityInfo): Promise\ @@ -1484,9 +1050,9 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ----------- | ---- | ------------ | -| info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes | Ability information.| +| Name| Type | Mandatory| Description | +| ------ | -------------------------------------------- | ---- | ----------------- | +| info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes | Ability information.| **Return value** @@ -1508,7 +1074,9 @@ bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{ }) ``` -## bundle.isAbilityEnabled8+ +## bundle.isAbilityEnabled8+ deprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.isAbilityEnabled](js-apis-bundleManager.md#bundlemanagerisabilityenabled) instead. isAbilityEnabled(info : AbilityInfo, callback : AsyncCallback\): void @@ -1520,10 +1088,10 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ----------------------- | ---- | --------------- | -| info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes | Ability information. | -| 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.| +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------------- | ---- | ----------------------- | +| info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes | Ability information. | +| 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.| **Example** @@ -1541,7 +1109,9 @@ bundle.getAbilityInfo(bundleName, abilityName).then((abilityInfo)=>{ }) ``` -## bundle.isApplicationEnabled8+ +## bundle.isApplicationEnabled8+ deprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.isApplicationEnabled](js-apis-bundleManager.md#bundlemanagerisapplicationenabled) instead. isApplicationEnabled(bundleName: string): Promise\ @@ -1553,9 +1123,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 an application.| **Return value** @@ -1575,7 +1145,9 @@ bundle.isApplicationEnabled(bundleName) }) ``` -## bundle.isApplicationEnabled8+ +## bundle.isApplicationEnabled8+ deprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.isApplicationEnabled](js-apis-bundleManager.md#bundlemanagerisapplicationenabled) instead. isApplicationEnabled(bundleName: string, callback : AsyncCallback\): void @@ -1587,10 +1159,10 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| 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.| +| 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. | **Example** @@ -1605,7 +1177,9 @@ bundle.isApplicationEnabled(bundleName, (err, data) => { }) ``` -## bundle.queryAbilityByWant +## bundle.queryAbilityByWantdeprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo) instead. queryAbilityByWant(want: Want, bundleFlags: number, userId?: number): Promise> @@ -1621,7 +1195,7 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | +| 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. The default value is **0**. For details on the available enumerated values, see the ability information flags in [BundleFlag](#bundleflag).| @@ -1652,7 +1226,9 @@ bundle.queryAbilityByWant(want, bundleFlags, userId) -## bundle.queryAbilityByWant +## bundle.queryAbilityByWantdeprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo) instead. queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback>): void @@ -1668,7 +1244,7 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory| Description | +| 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. The default value is **0**. For details on the available enumerated values, see the ability information flags in [BundleFlag](#bundleflag).| @@ -1693,7 +1269,9 @@ bundle.queryAbilityByWant(want, bundleFlags, userId, (err, data) => { }) ``` -## bundle.queryAbilityByWant +## bundle.queryAbilityByWantdeprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo) instead. queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback>): void; @@ -1709,7 +1287,7 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory| Description | +| 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. The default value is **0**. For details on the available enumerated values, see the ability information flags in [BundleFlag](#bundleflag).| @@ -1734,7 +1312,9 @@ bundle.queryAbilityByWant(want, bundleFlags, (err, data) => { -## bundle.getLaunchWantForBundle +## bundle.getLaunchWantForBundledeprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.getLaunchWantForBundle](js-apis-bundleManager.md#bundlemanagergetlaunchwantforbundle) instead. getLaunchWantForBundle(bundleName: string): Promise\ @@ -1750,9 +1330,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 an application.| **Return value** | Type | Description | @@ -1771,7 +1351,9 @@ bundle.getLaunchWantForBundle(bundleName) }) ``` -## bundle.getLaunchWantForBundle +## bundle.getLaunchWantForBundledeprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.getLaunchWantForBundle](js-apis-bundleManager.md#bundlemanagergetlaunchwantforbundle) instead. getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\): void; @@ -1787,10 +1369,10 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| 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.| +| 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.| **Example** @@ -1806,7 +1388,9 @@ bundle.getLaunchWantForBundle(bundleName, (err, data) => { ``` -## bundle.getNameForUid8+ +## bundle.getNameForUid8+ deprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.getBundleNameByUid](js-apis-bundleManager.md#bundlemanagergetbundlenamebyuid) instead. getNameForUid(uid: number): Promise\ @@ -1818,9 +1402,9 @@ 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.| **Return value** | Type | Description | @@ -1839,7 +1423,9 @@ bundle.getNameForUid(uid) }) ``` -## bundle.getNameForUid8+ +## bundle.getNameForUid8+ deprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.getBundleNameByUid](js-apis-bundleManager.md#bundlemanagergetbundlenamebyuid) instead. getNameForUid(uid: number, callback: AsyncCallback\) : void @@ -1851,10 +1437,10 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| 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.| +| 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** @@ -1870,7 +1456,9 @@ bundle.getNameForUid(uid, (err, data) => { ``` -## bundle.getAbilityIcon8+ +## bundle.getAbilityIcon8+ deprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.getAbilityIcon](js-apis-bundleManager.md#bundlemanagergetabilityicon) instead. getAbilityIcon(bundleName: string, abilityName: string): Promise\; @@ -1886,10 +1474,10 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | -| ----------- | ---------------------------------------- | ---- | ---------------------------------------- | -| bundleName | string | Yes | Bundle name based on which the pixel map is to obtain. | -| abilityName | string | Yes | Ability name based on which the pixel map is to obtain. | +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | --------------------- | +| bundleName | string | Yes | Bundle name based on which the pixel map is to obtain. | +| abilityName | string | Yes | Ability name based on which the pixel map is to obtain.| **Return value** | Type | Description | @@ -1909,7 +1497,9 @@ bundle.getAbilityIcon(bundleName, abilityName) }) ``` -## bundle.getAbilityIcon8+ +## bundle.getAbilityIcon8+ deprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.getAbilityIcon](js-apis-bundleManager.md#bundlemanagergetabilityicon) instead. getAbilityIcon(bundleName: string, abilityName: string, callback: AsyncCallback\): void; @@ -1925,7 +1515,7 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | ----------- | ---------------------------------------- | ---- | ---------------------------------------- | | bundleName | string | Yes | Bundle name based on which the pixel map is to obtain. | | abilityName | string | Yes | Ability name based on which the pixel map is to obtain. | @@ -1945,686 +1535,145 @@ bundle.getAbilityIcon(bundleName, abilityName, (err, data) => { }) ``` -## bundle.getAbilityIcon9+ - -getAbilityIcon(bundleName: string, moduleName: string, abilityName: string): Promise\; - -Obtains the [pixel map](js-apis-image.md) of the icon corresponding to a given bundle name, module name, and ability name. This API uses a promise to return the result. - -**Required permissions** - -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO - -**System capability** - -SystemCapability.BundleManager.BundleFramework - -**Parameters** - -| Name | Type | Mandatory | Description | -| ----------- | ---------------------------------------- | ---- | ---------------------------------------- | -| bundleName | string | Yes | Bundle name based on which the pixel map is to obtain. | -| moduleName | string | Yes | Module name based on which the pixel map is to obtain. | -| abilityName | string | Yes | Ability name based on which the pixel map is to obtain. | - -**Return value** -| Type | Description | -| --------------------- | ------------------------------------------------------------ | -| Promise\ | Promise used to return the [pixel map](js-apis-image.md).| - -**Example** - -```js -let bundleName = "com.example.myapplication"; -let moduleName = "entry"; -let abilityName = "com.example.myapplication.MainAbility"; -bundle.getAbilityIcon(bundleName, moduleName, abilityName) -.then((data) => { - console.info('Operation successful. Data: ' + JSON.stringify(data)); -}).catch((error) => { - console.error('Operation failed. Cause: ' + JSON.stringify(error)); -}) -``` - -## bundle.getAbilityIcon9+ - -getAbilityIcon(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback\): void; - -Obtains the [pixel map](js-apis-image.md) of the icon corresponding to a given bundle name, module name, and ability name. This API uses an asynchronous callback to return the result. - -**Required permissions** - -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO - -**System capability** - -SystemCapability.BundleManager.BundleFramework - -**Parameters** - -| Name | Type | Mandatory | Description | -| ----------- | ---------------------------------------- | ---- | ---------------------------------------- | -| bundleName | string | Yes | Bundle name based on which the pixel map is to obtain. | -| moduleName | string | Yes | Module name based on which the pixel map is to obtain. | -| abilityName | string | Yes | Ability name based on which the pixel map is to obtain. | -| callback | AsyncCallback\ | Yes | Callback used to return the [pixel map](js-apis-image.md).| - -**Example** - -```js -let bundleName = "com.example.myapplication"; -let moduleName = "entry"; -let abilityName = "com.example.myapplication.MainAbility"; -bundle.getAbilityIcon(bundleName, moduleName, abilityName, (err, data) => { - if (err) { - console.error('Operation failed. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Operation successful. Data:' + JSON.stringify(data)); -}) -``` - -## bundle.queryExtensionAbilityInfos9+ - -queryExtensionAbilityInfos(want: Want, extensionType: number, extensionFlags: number, userId?: number): Promise> - -Obtains the Extension ability information based on a given want. This API uses a promise to return the result. - -**Required permissions** - -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO - -**System capability** - -SystemCapability.BundleManager.BundleFramework - -**Parameters** - -| Name | Type | Mandatory | Description | -| -------------- | ------ | ---- | ---------------------------------------- | -| want | [Want](js-apis-application-Want.md) | Yes | Want that contains the bundle name. | -| extensionType | number | Yes | Type of the Extension ability information to obtain. The default value is **0**. For details on the available enumerated values, see [ExtensionAbilityType](#extensionabilitytype9).| -| extensionFlags | number | Yes | Extension ability information to be returned. The default value is **0**. For details on the available enumerated values, see [ExtensionFlags](#extensionflag9).| -| 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** - -| Type | Description | -| ------------------------------------- | ------------------------------ | -| Promise> | Promise used to return the Extension ability information.| - -**Example** - -```js -let extensionType = 0; -let extensionFlags = 0; -let userId = 100; -let want = { - bundleName : "com.example.myapplication", - abilityName : "com.example.myapplication.MainAbility" -}; -bundle.queryExtensionAbilityInfos(want, extensionType, extensionFlags, userId) -.then((data) => { - console.info('Operation successful. Data: ' + JSON.stringify(data)); -}).catch((error) => { - console.error('Operation failed. Cause: ' + JSON.stringify(error)); -}) -``` - - - -## bundle.queryExtensionAbilityInfos9+ - -queryExtensionAbilityInfos(want: Want, extensionType: number, extensionFlags: number, userId: number, callback: AsyncCallback>): void - -Obtains the Extension ability information of the specified user based on a given want. This API uses an asynchronous callback to return the result. - -**Required permissions** - -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO - -**System capability** - -SystemCapability.BundleManager.BundleFramework - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| want | [Want](js-apis-application-Want.md) | Yes | Want that contains the bundle name. | -| extensionType | number | Yes | Type of the Extension ability information to obtain. The default value is **0**. For details on the available enumerated values, see [ExtensionAbilityType](#extensionabilitytype9).| -| extensionFlags | number | Yes | Extension ability information to be returned. The default value is **0**. For details on the available enumerated values, see [ExtensionFlags](#extensionflag9).| -| 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 Extension ability information. | - -**Example** - -```js -let extensionType = 0; -let extensionFlags = 0; -let userId = 100; -let want = { - bundleName : "com.example.myapplication", - abilityName : "com.example.myapplication.MainAbility" -}; -const receiver = function onReceive(err, data) { - var errValue = JSON.stringify(err) - var dataValue = JSON.stringify(data) - console.error('Operation failed. Cause: ' + errValue); - console.error('Operation failed. Cause: ' + dataValue); -} -bundle.queryExtensionAbilityInfos(want, extensionType, extensionFlags, userId, receiver) -``` - -## bundle.queryExtensionAbilityInfos9+ - -queryExtensionAbilityInfos(want: Want, extensionType: number, extensionFlags: number, callback: AsyncCallback>): void; - -Obtains the Extension ability information based on a given want. This API uses an asynchronous callback to return the result. - -**Required permissions** - -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO - -**System capability** - -SystemCapability.BundleManager.BundleFramework - -**Parameters** - -| Name | Type | Mandatory | Description | -| -------------- | ---------------------------------------- | ---- | ---------------------------------------- | -| want | [Want](js-apis-application-Want.md) | Yes | Want that contains the bundle name. | -| extensionType | number | Yes | Type of the Extension ability information to obtain. The default value is **0**. For details on the available enumerated values, see [ExtensionAbilityType](#extensionabilitytype9).| -| extensionFlags | number | Yes | Extension ability information to be returned. The default value is **0**. For details on the available enumerated values, see [ExtensionFlags](#extensionflag9).| -| callback | AsyncCallback> | Yes | Callback used to return the Extension ability information. | - -**Example** - -```js -let extensionType = 0; -let extensionFlags = 0; -let want = { - bundleName : "com.example.myapplication", - abilityName : "com.example.myapplication.MainAbility" -}; -const receiver = function onReceive(err, data) { - var errValue = JSON.stringify(err) - var dataValue = JSON.stringify(data) - console.error('Operation failed. Cause: ' + errValue); - console.error('Operation failed. Cause: ' + dataValue); -} -bundle.queryExtensionAbilityInfos(want, extensionType, extensionFlags, receiver) -``` - -## bundle.getProfileByAbility9+ - -getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback\>): void; - -Obtains the JSON string array of the current application's configuration file in the [metadata](js-apis-bundle-Metadata.md) based on a given module name, ability name, and metadata name. This API uses an asynchronous callback to return the result. This API cannot be used to obtain the JSON string array of another application. - -**System capability**: SystemCapability.BundleManager.BundleFramework - -**Parameters** - -| Name | Type | Mandatory | Description | -| ---------------- | ---------------------------------- | ---- | ---------------------------------------- | -| moduleName | string | Yes | Module to which the configuration file to be obtained belongs. | -| abilityName | string | Yes | Ability to which the configuration file to be obtained belongs. | -| metadataName | string | Yes | Metadata to which the configuration file to be obtained belongs. | -| callback | AsyncCallback\> | Yes | Callback used to return the JSON string array of the configuration file. | - -**Example** - -```js -let moduleName = 'entry'; -let abilityName = 'MainAbility'; -let metadataName = 'ohos.ability.shortcuts'; -const caller = function callback(err, data) { - console.error('Operation errcode is: ' + err); - console.error('Operation result is: ' + data); -} -bundle.getProfileByAbility(moduleName, abilityName, metadataName, caller) -``` - -## bundle.getProfileByAbility9+ - -getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise\>; - -Obtains the JSON string array of the current application's configuration file in the [metadata](js-apis-bundle-Metadata.md) based on a given module name, ability name, and metadata name. This API uses a promise to return the result. This API cannot be used to obtain the JSON string array of another application. - -**System capability**: SystemCapability.BundleManager.BundleFramework - -**Parameters** - -| Name | Type | Mandatory | Description | -| ---------------- | ---------------------------------- | ---- | ---------------------------------------- | -| moduleName | string | Yes | Module to which the configuration file to be obtained belongs. | -| abilityName | string | Yes | Ability to which the configuration file to be obtained belongs. | -| metadataName | string | No | Metadata to which the configuration file to be obtained belongs. | - -**Return value** - -| Type | Description | -| ------------------------------------- | ------------------------------ | -| Promise\> | Promise used to return the JSON string array of the configuration file.| - -**Example** - -```js -let moduleName = 'entry'; -let abilityName = 'MainAbility'; -let metadataName = 'ohos.ability.shortcuts'; - -bundle.getProfileByAbility(moduleName, abilityName, metadataName).then(data=>{ - console.error('Operation result is: ' + data); -}).catch(err=>{ - console.error('Operation errcode is: ' + err); -}) -``` - -## bundle.getProfileByExtensionAbility9+ - -getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback\>): void; - -Obtains the JSON string array of the current application's configuration file in the [metadata](js-apis-bundle-Metadata.md) based on a given module name, Extension ability name, and metadata name. This API uses an asynchronous callback to return the result. This API cannot be used to obtain the JSON string array of another application. - -**System capability**: SystemCapability.BundleManager.BundleFramework - -**Parameters** - -| Name | Type | Mandatory | Description | -| ---------------- | ---------------------------------- | ---- | ---------------------------------------- | -| moduleName | string | Yes | Module to which the configuration file to be obtained belongs. | -| extensionAbilityName | string | Yes | Extension ability to which the configuration file to be obtained belongs. | -| metadataName | string | Yes | Metadata to which the configuration file to be obtained belongs. | -| callback | AsyncCallback\> | Yes | Callback used to return the JSON string array of the configuration file. | - -**Example** - -```js -let moduleName = 'entry'; -let extensionAbilityName = 'Form'; -let metadataName = 'ohos.extension.form'; -const caller = function callback(err, data) { - console.error('Operation errcode is: ' + err); - console.error('Operation result is: ' + data); -} -bundle.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName, caller) -``` - -## bundle.getProfileByExtensionAbility9+ - -getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise\>; - -Obtains the JSON string array of the current application's configuration file in the [metadata](js-apis-bundle-Metadata.md) based on a given module name, Extension ability name, and metadata name. This API uses a promise to return the result. This API cannot be used to obtain the JSON string array of another application. - -**System capability**: SystemCapability.BundleManager.BundleFramework - -**Parameters** - -| Name | Type | Mandatory | Description | -| ---------------- | ---------------------------------- | ---- | ---------------------------------------- | -| moduleName | string | Yes | Module to which the configuration file to be obtained belongs. | -| extensionAbilityName | string | Yes | Extension ability to which the configuration file to be obtained belongs. | -| metadataName | string | No | Metadata to which the configuration file to be obtained belongs. | - -**Return value** - -| Type | Description | -| ------------------------------------- | ------------------------------ | -| Promise\> | Promise used to return the JSON string array of the configuration file.| - -**Example** - -```js -let moduleName = 'entry'; -let extensionAbilityName = 'Form'; -let metadataName = 'ohos.extension.form'; - -bundle.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName).then(data=>{ - console.error('Operation result is: ' + data); -}).catch(err=>{ - console.error('Operation errcode is: ' + err); -}) -``` - -## bundle.setDisposedStatus9+ - -setDisposedStatus(bundleName: string, status: number, callback: AsyncCallback\): void; - -Sets the disposal status for an application based on a given bundle name. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS - -**System capability**: SystemCapability.BundleManager.BundleFramework - -**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 of an application. | -| status | number | Yes | Disposal status to set. This parameter is reserved for the application market. The default value is **0**, indicating that no disposal is performed. | -| callback | AsyncCallback\ | Yes | Callback that returns no value. | - -**Example** - -```js -let bundleName = 'com.ohos.camera'; -let status = 1; -const caller = function callback(err, data) { - console.error('Operation err is: ' + err); - console.error('Operation result is: ' + data); -} -bundle.setDisposedStatus(bundleName, status, caller) -``` - -## bundle.setDisposedStatus9+ - -setDisposedStatus(bundleName: string, status: number): Promise\; - -Sets the disposal status for an application based on a given bundle name. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS - -**System capability**: SystemCapability.BundleManager.BundleFramework - -**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 of an application. | -| status | number | Yes | Disposal status to set. This parameter is reserved for the application market. The default value is **0**, indicating that no disposal is performed. | - -**Return value** - -| Type | Description | -| ------------------------------------- | ------------------------------ | -| Promise\ | Promise that returns no value.| - -**Example** - -```js -let bundleName = 'com.ohos.camera'; -let status = 1; - -bundle.setDisposedStatus(bundleName, status).then(data=>{ - console.error('Operation result is: ' + data); -}).catch(err=>{ - console.error('Operation err is: ' + err); -}) -``` - -## bundle.getDisposedStatus9+ - -getDisposedStatus(bundleName: string, callback: AsyncCallback\): void; - -Obtains the disposal status of an application based on a given bundle name. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS - -**System capability**: SystemCapability.BundleManager.BundleFramework - -**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 of an application. | -| callback | AsyncCallback\ | Yes | Callback used to return the disposal status. | - -**Example** - -```js -let bundleName = 'com.ohos.camera'; -const caller = function callback(err, data) { - console.error('Operation err is: ' + err); - console.error('Operation result is: ' + data); -} -bundle.getDisposedStatus(bundleName, caller) -``` - -## bundle.getDisposedStatus9+ - -getDisposedStatus(bundleName: string): Promise\; - -Obtains the disposal status of an application based on a given bundle name. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS - -**System capability**: SystemCapability.BundleManager.BundleFramework - -**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 of an application. | - -**Return value** - -| Type | Description | -| ------------------------------------- | ------------------------------ | -| Promise\ | Promise used to return the disposal status.| - -**Example** - -```js -let bundleName = 'com.ohos.camera'; - -bundle.getDisposedStatus(bundleName).then(data=>{ - console.error('Operation result is: ' + data); -}).catch(err=>{ - console.error('Operation err is: ' + err); -}) -``` - -## InstallErrorCode +## InstallErrorCodedeprecated +> This API is deprecated since API version 9. You are not advised to use it anymore. **System capability**: SystemCapability.BundleManager.BundleFramework -| Name | Default Value | Description | -| ---------------------------------------- | ---- | ------------------------- | -| SUCCESS | 0 | Installation succeeded. | -| STATUS_INSTALL_FAILURE | 1 | Installation failed. (The application to be installed is not found.) | -| STATUS_INSTALL_FAILURE_ABORTED | 2 | Installation aborted. | -| STATUS_INSTALL_FAILURE_INVALID | 3 | Invalid installation parameter. | -| STATUS_INSTALL_FAILURE_CONFLICT | 4 | Installation conflict. (The basic information of the application to update is inconsistent with that of the existing application.) | -| STATUS_INSTALL_FAILURE_STORAGE | 5 | Failed to store the bundle information. | -| STATUS_INSTALL_FAILURE_INCOMPATIBLE | 6 | Installation incompatibility. (A downgrade occurs or the signature information is incorrect.) | -| STATUS_UNINSTALL_FAILURE | 7 | Uninstallation failed. (The application to be uninstalled is not found.) | -| STATUS_UNINSTALL_FAILURE_BLOCKED | 8 | Uninstallation aborted. (This error code is not in use.) | -| STATUS_UNINSTALL_FAILURE_ABORTED | 9 | Uninstallation aborted. (Invalid parameters.) | -| STATUS_UNINSTALL_FAILURE_CONFLICT | 10 | Uninstallation conflict. (Failed to uninstall a system application or end the application process.)| -| STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT | 0x0B | Installation failed. (Download timed out.) | -| STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED | 0x0C | Installation failed. (Download failed.) | -| STATUS_RECOVER_FAILURE_INVALID8+ | 0x0D | Failed to restore the pre-installed application. | -| STATUS_ABILITY_NOT_FOUND | 0x40 | Ability not found. | -| STATUS_BMS_SERVICE_ERROR | 0x41 | BMS service error. | -| STATUS_FAILED_NO_SPACE_LEFT8+ | 0x42 | Insufficient device space. | -| STATUS_GRANT_REQUEST_PERMISSIONS_FAILED8+ | 0x43 | Application authorization failed. | -| STATUS_INSTALL_PERMISSION_DENIED8+ | 0x44 | Installation permission denied. | -| STATUS_UNINSTALL_PERMISSION_DENIED8+ | 0x45 | Uninstallation permission denied. | - -## BundleFlag +| Name | Value | Description | +| ---------------------------------------------------- | ---- | ------------------------------------------------ | +| SUCCESS | 0 | Installation succeeded. | +| STATUS_INSTALL_FAILURE | 1 | Installation failed. (The application to be installed is not found.) | +| STATUS_INSTALL_FAILURE_ABORTED | 2 | Installation aborted. | +| STATUS_INSTALL_FAILURE_INVALID | 3 | Invalid installation parameter. | +| STATUS_INSTALL_FAILURE_CONFLICT | 4 | Installation conflict. (The basic information of the application to update is inconsistent with that of the existing application.) | +| STATUS_INSTALL_FAILURE_STORAGE | 5 | Failed to store the bundle information. | +| STATUS_INSTALL_FAILURE_INCOMPATIBLE | 6 | Installation incompatibility. (A downgrade occurs or the signature information is incorrect.)| +| STATUS_UNINSTALL_FAILURE | 7 | Uninstallation failed. (The application to be uninstalled is not found.) | +| STATUS_UNINSTALL_FAILURE_BLOCKED | 8 | Uninstallation aborted. (This error code is not in use.) | +| STATUS_UNINSTALL_FAILURE_ABORTED | 9 | Uninstallation aborted. (Invalid parameters.) | +| STATUS_UNINSTALL_FAILURE_CONFLICT | 10 | Uninstallation conflict. (Failed to uninstall a system application or end the application process.)| +| STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT | 0x0B | Installation failed. (Download timed out.) | +| STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED | 0x0C | Installation failed. (Download failed.) | +| STATUS_RECOVER_FAILURE_INVALID8+ | 0x0D | Failed to restore the pre-installed application. | +| STATUS_ABILITY_NOT_FOUND | 0x40 | Ability not found. | +| STATUS_BMS_SERVICE_ERROR | 0x41 | BMS service error. | +| STATUS_FAILED_NO_SPACE_LEFT8+ | 0x42 | Insufficient device space. | +| STATUS_GRANT_REQUEST_PERMISSIONS_FAILED8+ | 0x43 | Application authorization failed. | +| STATUS_INSTALL_PERMISSION_DENIED8+ | 0x44 | No installation permission. | +| STATUS_UNINSTALL_PERMISSION_DENIED8+ | 0x45 | No uninstallation permission. | + +## BundleFlagdeprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.BundleFlag](js-apis-bundleManager.md#bundleflag) instead. Enumerates bundle flags. **System capability**: SystemCapability.BundleManager.BundleFramework -| Name | Default Value | Description | -| ---------------------------------------- | ---------- | ------------------- | -| GET_BUNDLE_DEFAULT | 0x00000000 | Obtains the default application information. | -| GET_BUNDLE_WITH_ABILITIES | 0x00000001 | Obtains the bundle information with the ability information. | -| GET_ABILITY_INFO_WITH_PERMISSION | 0x00000002 | Obtains the ability information with the permission information. | -| GET_ABILITY_INFO_WITH_APPLICATION | 0x00000004 | Obtains the ability information with the application information. | -| GET_APPLICATION_INFO_WITH_PERMISSION | 0x00000008 | Obtains the application information with the permission information. | -| GET_BUNDLE_WITH_REQUESTED_PERMISSION | 0x00000010 | Obtains the bundle information with the information about the required permissions. | -| GET_ABILITY_INFO_WITH_METADATA8+ | 0x00000020 | Obtains the ability metadata information. | -| GET_BUNDLE_WITH_EXTENSION_ABILITY9+ | 0x00000020 | Obtains the bundle information with the Extension ability information.| -| GET_APPLICATION_INFO_WITH_METADATA8+ | 0x00000040 | Obtains the application metadata information. | -| GET_ABILITY_INFO_SYSTEMAPP_ONLY8+ | 0x00000080 | Obtains the ability information of system applications.| -| GET_ABILITY_INFO_WITH_DISABLE8+ | 0x00000100 | Obtains information about disabled abilities. | -| GET_APPLICATION_INFO_WITH_DISABLE8+ | 0x00000200 | Obtains information about disabled applications. | -| GET_APPLICATION_INFO_WITH_CERTIFICATE_FINGERPRINT 9+ | 0x00000400 | Obtains the signing certificate fingerprint of the application. | -| GET_ALL_APPLICATION_INFO | 0xFFFF0000 | Obtains all application information. | -| GET_BUNDLE_WITH_HASH_VALUE9+ | 0x00000030 | Obtains information about the bundle that contains a hash value. | - -## BundleOptions +| Name | Value | Description | +| ----------------------------------------------- | ---------- | ------------------------------- | +| GET_BUNDLE_DEFAULT | 0x00000000 | Obtains the default application information. | +| GET_BUNDLE_WITH_ABILITIES | 0x00000001 | Obtains the bundle information with the ability information. | +| GET_ABILITY_INFO_WITH_PERMISSION | 0x00000002 | Obtains the ability information with the permission information. | +| GET_ABILITY_INFO_WITH_APPLICATION | 0x00000004 | Obtains the ability information with the application information. | +| GET_APPLICATION_INFO_WITH_PERMISSION | 0x00000008 | Obtains the application information with the permission information. | +| GET_BUNDLE_WITH_REQUESTED_PERMISSION | 0x00000010 | Obtains the bundle information with the information about the required permissions. | +| GET_ABILITY_INFO_WITH_METADATA8+ | 0x00000020 | Obtains the ability metadata information. | +| GET_APPLICATION_INFO_WITH_METADATA8+ | 0x00000040 | Obtains the application metadata information. | +| GET_ABILITY_INFO_SYSTEMAPP_ONLY8+ | 0x00000080 | Obtains the ability information of system applications.| +| GET_ABILITY_INFO_WITH_DISABLE8+ | 0x00000100 | Obtains information about disabled abilities. | +| GET_APPLICATION_INFO_WITH_DISABLE8+ | 0x00000200 | Obtains information about disabled applications. | +| 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. Describes the bundle options. **System capability**: SystemCapability.BundleManager.BundleFramework -| Name | Type | Readable | Writable | Description | -| ------ | ------ | ---- | ---- | ---------------------------- | -| userId | number | Yes | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.| +| Name | Type | Readable| Writable| Description | +| ------ | ------ | ---- | ---- | ----------------------------------------------------- | +| userId | number | Yes | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.| + +## AbilityTypedeprecated -## AbilityType +> This API is deprecated since API version 9. You are advised to use [bundleManager.AbilityType](js-apis-bundleManager.md#abilitytype) instead. Enumerates ability types. **System capability**: SystemCapability.BundleManager.BundleFramework -| Name | Type | Description | -| ------- | ---- | ----------------- | -| UNKNOWN | None | Unknown ability type. | -| PAGE | None | Ability that has a UI. | -| SERVICE | None | Ability that does not have a UI. | -| DATA | None | Ability that is used to provide data access services.| +| Name| Value| Description | +| ------- | ---- | --------------------------- | +| UNKNOWN | None | Unknown ability type. | +| PAGE | None | FA developed using the Page template to provide the capability of interacting with users. | +| SERVICE | None | PA developed using the Service template to provide the capability of running tasks in the background. | +| DATA | None | PA developed using the Data template to provide unified data access for external systems.| + +## DisplayOrientationdeprecated -## DisplayOrientation +> This API is deprecated since API version 9. You are advised to use [bundleManager.DisplayOrientation](js-apis-bundleManager.md#displayorientation) instead. Enumerates display orientations. **System capability**: SystemCapability.BundleManager.BundleFramework -| Name | Type | Description | -| ------------- | ---- | ------------- | -| UNSPECIFIED | None | Unspecified display orientation. | -| LANDSCAPE | None | Landscape orientation. | -| PORTRAIT | None | Portrait orientation. | -| FOLLOW_RECENT | None | Orientation same as that of the nearest ability in the stack.| -| LANDSCAPE_INVERTED9+ |None | Reverse landscape orientation. | -| PORTRAIT_INVERTED9+ |None | Reverse portrait orientation. | -| AUTO_ROTATION9+ |None | Orientation determined by the sensor. | -| AUTO_ROTATION_LANDSCAPE9+ |None | Orientation determined by the sensor in the horizontal direction, including landscape and reverse landscape. | -| AUTO_ROTATION_PORTRAIT9+ |None | Orientation determined by the sensor in the vertical direction, including portrait and reverse portrait. | -| AUTO_ROTATION_RESTRICTED9+ |None | Orientation determined by the sensor when the sensor switch is enabled. | -| AUTO_ROTATION_LANDSCAPE_RESTRICTED9+ |None | Orientation determined by the sensor in the horizontal direction, including landscape and reverse landscape, when the sensor switch is enabled. | -| AUTO_ROTATION_PORTRAIT_RESTRICTED9+ |None | Orientation determined by the sensor in the vertical direction, including portrait and reverse portrait, when the sensor switch is enabled. | -| LOCKED9+ |None | Auto rotate disabled. | -## LaunchMode +| Name | Value | Description | +| ------------- | ---- | ------------------------ | +| UNSPECIFIED | None | Unspecified display orientation. | +| LANDSCAPE | None | Landscape orientation. | +| PORTRAIT | None | Portrait orientation. | +| FOLLOW_RECENT | None | Orientation same as that of the nearest ability in the stack.| +## LaunchModedeprecated + +> This API is deprecated since API version 9. You are advised to use [bundleManager.LaunchType](js-apis-bundleManager.md#launchtype) instead. Enumerates launch modes. **System capability**: SystemCapability.BundleManager.BundleFramework -| Name | Type | Description | -| --------- | ---- | ------------- | +| Name | Value | Description | +| --------- | ---- | ------------------- | | SINGLETON | 0 | The ability has only one instance.| -| STANDARD | 1 | The ability can have multiple instances. | +| STANDARD | 1 | The ability can have multiple instances. | -## AbilitySubType +## AbilitySubTypedeprecated +> This API is deprecated since API version 9. You are not advised to use it anymore. Enumerates ability subtypes. **System capability**: SystemCapability.BundleManager.BundleFramework -| Name | Type | Description | -| ----------- | ---- | -------------------- | -| UNSPECIFIED | 0 | Undefined ability subtype. | +| Name | Value | Description | +| ----------- | ---- | ----------------------------- | +| UNSPECIFIED | 0 | Undefined ability subtype. | | CA | 1 | Ability that has a UI.| -## ExtensionAbilityType9+ - -Enumerates Extension ability types. - - **System capability**: SystemCapability.BundleManager.BundleFramework - -| Name | Type | Description | -| ------------------------------ | ---- | ------------------------- | -| FORM9+ | 0 | Form (widget) included. | -| WORK_SCHEDULER9+ | 1 | Work scheduler included.| -| INPUT_METHOD9+ | 2 | Input method included. | -| SERVICE9+ | 3 | Service included. | -| ACCESSIBILITY9+ | 4 | Accessibility included. | -| DATA_SHARE9+ | 5 | Data sharing included.| -| FILE_SHARE9+ | 6 | File sharing included.| -| STATIC_SUBSCRIBER9+ | 7 | Subscribers included. | -| WALLPAPER9+ | 8 | Wallpaper included. | -| BACKUP9+ | 9 | Data backup and restore included.| -| WINDOW9+ | 10 | Window type extension information included.| -| ENTERPRISE_ADMIN9+ | 11 | Enterprise administrators included. | -| THUMBNAIL9+ | 13 | Thumbnails included.| -| PREVIEW9+ | 14 | Preview included.| -| UNSPECIFIED9+ | 255 | Unspecified type. | - -## ExtensionFlag9+ - -Enumerates Extension flags. - - **System capability**: SystemCapability.BundleManager.BundleFramework - -| Name | Default Value | Description | -| ---------------------------------------- | ---------- | ------------------------------ | -| GET_EXTENSION_INFO_DEFAULT9+ | 0x00000000 | Obtains the default Extension ability information. | -| GET_EXTENSION_INFO_WITH_PERMISSION9+ | 0x00000002 | Obtains the Extension ability information that carries permission information. | -| GET_EXTENSION_INFO_WITH_APPLICATION9+ | 0x00000004 | Obtains the Extension ability information that carries application information. | -| GET_EXTENSION_INFO_WITH_METADATA9+ | 0x00000020 | Obtains the Extension ability information that carries metadata information.| - -## ColorMode +## ColorModedeprecated +> This API is deprecated since API version 9. You are not advised to use it anymore. Enumerates color modes. **System capability**: SystemCapability.BundleManager.BundleFramework -| Name | Type | Description | -| ---------- | ---- | ---- | +| Name | Value | Description | +| ---------- | ---- | -------- | | AUTO_MODE | -1 | Automatic mode.| | DARK_MODE | 0 | Dark mode.| | LIGHT_MODE | 1 | Light mode.| -## GrantStatus +## GrantStatusdeprecated + +> 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. **System capability**: SystemCapability.BundleManager.BundleFramework -| Name | Type | Description | -| ------------------ | ---- | ---- | +| Name | Value | Description | +| ------------------ | ---- | ------------ | | PERMISSION_DENIED | -1 | Permission denied.| -| PERMISSION_GRANTED | 0 | Permission granted. | - -## SupportWindowMode - -Enumerates window modes. - - **System capability**: SystemCapability.BundleManager.BundleFramework - -| Name | Type | Description | -| ------------------ | ---- | ---- | -| FULL_SCREEN9+ | 0 | Full screen.| -| SPLIT9+ | 1 | Split-screen. | -| FLOATING9+ | 2 | Floating. | - -## UpgradeFlag - -Enumerates the upgrade flags, which are for internal use only. - -**System API**: This is a system API and cannot be called by third-party applications. - -**System capability**: SystemCapability.BundleManager.BundleFramework - -| Name | Value | Description | -| ----------------------------- | ---- | ---------------- | -| NOT_UPGRADE9+ | 0 | No module needs an upgrade. | -| SINGLE_UPGRADE9+ | 1 | A single module needs an upgrade.| -| RELATION_UPGRADE9+ | 2 | The module that has a relationship with the current one needs an upgrade.| +| PERMISSION_GRANTED | 0 | Permission granted. | diff --git a/en/application-dev/reference/apis/js-apis-appControl.md b/en/application-dev/reference/apis/js-apis-appControl.md new file mode 100644 index 0000000000..50d8a59fdc --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-appControl.md @@ -0,0 +1,324 @@ +# 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. + +> **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 appControl from '@ohos.bundle.appControl' +``` + +## appControl.setDisposedStatus + +setDisposedStatus(appId: string, disposedWant: Want): Promise\ + +Sets the disposed status for an application. This API uses a promise to return the result. If the operation is successful, **null** is returned. If the operation fails, an error message is returned. + +**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS + +**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| 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). | +| disposedWant | Want | Yes| Disposal intent of the application.| + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\ | Promise that returns no value.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700005 | The specified appId was not found. | + +**Example** + +```ts +var appId = "com.example.myapplication_xxxxx"; +var want = {bundleName: 'com.example.myapplication'}; + +try { + appControl.setDisposedStatus(appId, want) + .then(() => { + console.info('setDisposedStatus success'); + }).catch((error) => { + console.error('setDisposedStatus failed ' + error.message); + }); +} catch (error) { + console.error('setDisposedStatus failed ' + error.message); +} +``` + +## appControl.setDisposedStatus + +setDisposedStatus(appId: string, disposedWant: Want, callback: AsyncCallback\): void; + +Sets the disposed status for an application. This API uses an asynchronous callback to return the result. If the operation is successful, **null** is returned. If the operation fails, an error message is returned. + +**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS + +**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| 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). | +| 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.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700005 | The specified appId was not found. | + +**Example** + +```ts +var appId = "com.example.myapplication_xxxxx"; +var want = {bundleName: 'com.example.myapplication'}; + +try { + appControl.setDisposedStatus(appId, want, (error, data) => { + if (error) { + console.error('setDisposedStatus failed ' + error.message); + return; + } + console.info('setDisposedStatus success'); + }); +} catch (error) { + console.error('setDisposedStatus failed ' + error.message); +} +``` + +## appControl.getDisposedStatus + +getDisposedStatus(appId: string): Promise\; + +Obtains the disposed status of an application. This API uses a promise to return the result. If the operation is successful, the disposed status of the application is returned. If the operation fails, an error message is returned. + +**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS + +**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| 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). | + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\ | Promise used to return the disposed status.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700005 | The specified appId was not found. | + +**Example** + +```ts +var appId = "com.example.myapplication_xxxxx"; + +try { + appControl.getDisposedStatus(appId) + .then((data) => { + console.info('getDisposedStatus success. DisposedStatus: ' + JSON.stringify(data)); + }).catch((error) => { + console.error('getDisposedStatus failed ' + error.message); + }); +} catch (error) { + console.error('getDisposedStatus failed ' + error.message); +} +``` + +## appControl.getDisposedStatus + +getDisposedStatus(appId: string, callback: AsyncCallback\): void; + +Obtains the disposed status of an application. This API uses an asynchronous callback to return the result. If the operation is successful, the disposed status of the application is returned. If the operation fails, an error message is returned. + +**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS + +**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| 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). | +| 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** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700005 | The specified appId was not found. | + +**Example** + +```ts +var appId = "com.example.myapplication_xxxxx"; + +try { + appControl.getDisposedStatus(appId, (error, data) => { + if (error) { + console.error('getDisposedStatus failed ' + error.message); + return; + } + console.info('getDisposedStatus success. DisposedStatus: ' + JSON.stringify(data)); + }); +} catch (error) { + console.error('getDisposedStatus failed ' + error.message); +} +``` + +## appControl.deleteDisposedStatus + +deleteDisposedStatus(appId: string): Promise\ + +Deletes the disposed status for an application. This API uses a promise to return the result. If the operation is successful, **null** is returned. If the operation fails, an error message is returned. + +**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS + +**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| 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). | + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\ | Promise that returns no value.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700005 | The specified appId was not found. | + +**Example** + +```ts +var appId = "com.example.myapplication_xxxxx"; + +try { + appControl.deleteDisposedStatus(appId) + .then(() => { + console.info('deleteDisposedStatus success'); + }).catch((error) => { + console.error('deleteDisposedStatus failed ' + error.message); + }); +} catch (error) { + console.error('deleteDisposedStatus failed ' + error.message); +} +``` + +## appControl.deleteDisposedStatus + +deleteDisposedStatus(appId: string, callback: AsyncCallback\) : void + +Deletes the disposed status for an application. This API uses an asynchronous callback to return the result. If the operation is successful, **null** is returned. If the operation fails, an error message is returned. + +**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS + +**System capability**: SystemCapability.BundleManager.BundleFramework.AppControl + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| 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). | +| 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** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| ------ | -------------------------------------- | +| 17700005 | The specified appId was not found. | + +**Example** + +```ts +var appId = "com.example.myapplication_xxxxx"; +try { + appControl.deleteDisposedStatus(appId, (error, data) => { + if (error) { + console.error('deleteDisposedStatus failed ' + error.message); + return; + } + console.info('deleteDisposedStatus success'); + }); +} catch (error) { + console.error('deleteDisposedStatus failed ' + error.message); +} +``` + +## Obtaining appId of an Application + +**appId** is the unique identifier of an application and is determined by the bundle name and signature information of the application. It can be obtained by calling [getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo). + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager'; + +var bundleName = 'com.example.myapplication'; +var appId; +try { + bundleManager.getBundleInfo(bundleName, bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) + .then((data) => { + appId = data.signatureInfo.appId; + console.info("appId is " + appId); + }).catch((error) => { + console.error("getBundleInfo failed " + error.message); + }); +} catch (error) { + console.error("getBundleInfo failed " + error.message); +} +``` diff --git a/en/application-dev/reference/apis/js-apis-bundle-AbilityInfo.md b/en/application-dev/reference/apis/js-apis-bundle-AbilityInfo.md index 3cb5f27927..7f6d5b0196 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-AbilityInfo.md +++ b/en/application-dev/reference/apis/js-apis-bundle-AbilityInfo.md @@ -3,11 +3,14 @@ Unless otherwise specified, ability information is obtained through **GET_BUNDLE_DEFAULT**. > **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. -## AbilityInfo +## AbilityInfo(deprecated) -**System capability**: SystemCapability.BundleManager.BundleFramework +> This API is deprecated since API version 9. You are advised to use [AbilityInfo](js-apis-bundleManager-abilityInfo.md) instead. + + **System capability**: SystemCapability.BundleManager.BundleFramework | Name | Type | Readable| Writable| Description | | --------------------- | -------------------------------------------------------- | ---- | ---- | ----------------------------------------- | @@ -24,7 +27,7 @@ Unless otherwise specified, ability information is obtained through **GET_BUNDLE | backgroundModes | number | Yes | No | Background service mode of the ability.
This attribute can be used only in the FA model. | | isVisible | boolean | Yes | No | Whether the ability can be called by other applications. | | formEnabled | boolean | Yes | No | Whether the ability provides the service widget capability.
This attribute can be used only in the FA model.| -| type | AbilityType | Yes | No | Ability type.
This attribute can be used only in the FA model. | +| type | AbilityType | Yes | No | Ability type.
This attribute can be used only in the FA model. | | orientation | DisplayOrientation | Yes | No | Ability display orientation. | | launchMode | LaunchMode | Yes | No | Ability launch mode. | | permissions | Array\ | Yes | No | Permissions required for other applications to call the ability.
The value is obtained by passing **GET_ABILITY_INFO_WITH_PERMISSION**.| @@ -36,13 +39,5 @@ Unless otherwise specified, ability information is obtained through **GET_BUNDLE | uri | string | Yes | No | URI of the ability.
This attribute can be used only in the FA model.| | labelId | number | Yes | No | Ability label ID. | | subType | AbilitySubType | Yes | No | Subtype of the template that can be used by the ability.
This attribute can be used only in the FA model.| -| metaData8+ | Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)> | Yes | No | Custom metadata of the ability.
The value is obtained by passing **GET_ABILITY_INFO_WITH_METADATA**.| -| metadata9+ | Array\<[Metadata](js-apis-bundle-Metadata.md)> | Yes | No | Metadata of the ability.
The value is obtained by passing **GET_ABILITY_INFO_WITH_METADATA**.| +| metadata8+ | Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)> | Yes | No | Metadata of the ability.
The value is obtained by passing **GET_ABILITY_INFO_WITH_METADATA**.| | enabled8+ | boolean | Yes | No | Whether the ability is enabled. | -| supportWindowMode9+ | Array\<[SupportWindowMode](js-apis-Bundle.md)> | Yes | No | Window modes supported by the ability. | -| maxWindowRatio9+ | number | Yes | No | Maximum window ratio supported by the ability. | -| minWindowRatio9+ | number | Yes | No | Minimum window ratio supported by ability. | -| maxWindowWidth9+ | number | Yes | No | Maximum window width supported by the ability. | -| minWindowWidth9+ | number | Yes | No | Minimum window width supported by the ability. | -| maxWindowHeight9+ | number | Yes | No | Maximum window height supported by the ability. | -| minWindowHeight9+ | number | Yes | No | Minimum window height supported by the ability. | diff --git a/en/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md b/en/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md index ae94a539b9..fb5aa288ea 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md +++ b/en/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md @@ -6,7 +6,9 @@ The **ApplicationInfo** module provides application information. Unless otherwis > > 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. -## ApplicationInfo +## ApplicationInfo(deprecated) + +> This API is deprecated since API version 9. You are advised to use [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) instead. **System capability**: SystemCapability.BundleManager.BundleFramework @@ -18,11 +20,9 @@ The **ApplicationInfo** module provides application information. Unless otherwis | systemApp | boolean | Yes | No | Whether the application is a system application. The default value is **false**. | | enabled | boolean | Yes | No | Whether the application is enabled. The default value is **true**. | | label | string | Yes | No | Application label. | -| labelId(deprecated) | string | Yes | No | Application label ID.
\- **NOTE**: This attribute is deprecated from API version 9. Use **labelIndex** instead. | -| labelIndex9+ | number | Yes | No | Index of the application label.| +| labelId(deprecated) | string | Yes | No | Application label ID.
\- **NOTE**: This attribute is deprecated from API version 9. Use **labelIndex** instead.| | icon | string | Yes | No | Application icon. | -| iconId(deprecated) | string | Yes | No | Application icon ID.
\- **NOTE**: This attribute is deprecated from API version 9. Use **iconIndex** instead. | -| iconIndex9+ | number | Yes | No | Index of the application icon.| +| iconId(deprecated) | string | Yes | No | Application icon ID.
\- **NOTE**: This attribute is deprecated from API version 9. Use **iconIndex** instead.| | process | string | Yes | No | Process in which the application runs. If this parameter is not set, the bundle name is used. | | supportedModes | number | Yes | No | Running modes supported by the application. | | moduleSourceDirs | Array\ | Yes | No | Relative paths for storing application resources. | @@ -31,14 +31,7 @@ The **ApplicationInfo** module provides application information. Unless otherwis | entryDir | string | Yes | No | Path for storing application files. | | codePath8+ | string | Yes | No | Installation directory of the application. | | metaData8+ | Map\> | Yes | No | Custom metadata of the application.
The value is obtained by passing **GET_APPLICATION_INFO_WITH_METADATA**.| -| metadata9+ | Map\> | Yes | No | Metadata of the application.
The value is obtained by passing **GET_APPLICATION_INFO_WITH_METADATA**.| | removable8+ | boolean | Yes | No | Whether the application is removable. | | accessTokenId8+ | number | Yes | No | Access token ID of the application. | | uid8+ | number | Yes | No | UID of the application. | | entityType8+ | string | Yes | No | Entity type of the application. | -| fingerprint9+ | string | Yes | No | Signing certificate fingerprint of the application, that is, the SHA-256 checksum of the signing certificate that you request for the application.
The value is obtained by passing **GET_APPLICATION_INFO_WITH_CERTIFICATE_FINGERPRINT**.| -| iconResource9+ | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Icon resource of the application.| -| labelResource9+ | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Label resource of the application.| -| descriptionResource9+ | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Description resource of the application.| -| appDistributionType9+ | string | Yes | No | Distribution type of the application signing certificate. The options are **app_gallery**, **enterprise**, **os_integration**, and **crowdtesting**. | -| appProvisionType9+ | string | Yes | No | Type of the application signing certificate file. The options are **debug** and **release**.| diff --git a/en/application-dev/reference/apis/js-apis-bundle-BundleInfo.md b/en/application-dev/reference/apis/js-apis-bundle-BundleInfo.md index d744a5ab3e..f1d0240513 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-BundleInfo.md +++ b/en/application-dev/reference/apis/js-apis-bundle-BundleInfo.md @@ -6,7 +6,11 @@ The **BundleInfo** module provides bundle information. Unless otherwise specifie > > 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. -## BundleInfo + + +## BundleInfo(deprecated) + +> This API is deprecated since API version 9. You are advised to use [BundleInfo](js-apis-bundleManager-bundleInfo.md) instead. **System capability**: SystemCapability.BundleManager.BundleFramework @@ -35,11 +39,12 @@ The **BundleInfo** module provides bundle information. Unless otherwise specifie | minCompatibleVersionCode | number | Yes | No | Earliest version compatible with the bundle in the distributed scenario. | | entryInstallationFree | boolean | Yes | No | Whether installation-free is supported for the entry module. | | reqPermissionStates8+ | Array\ | Yes | No | Permission grant state. | -| extensionAbilityInfo9+ | Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)> | Yes | No | Extension ability information.
The value is obtained by passing **GET_BUNDLE_WITH_EXTENSION_ABILITY**.| -## ReqPermissionDetail +## ReqPermissionDetail(deprecated) + +> This API is deprecated since API version 9. You are advised to use [ReqPermissionDetail](js-apis-bundleManager-bundleInfo.md) instead. Provides the detailed information of the permissions to request from the system. @@ -49,12 +54,13 @@ Provides the detailed information of the permissions to request from the system. | --------------------- | ----------------------- | ---- | ---- | ---------------------- | | name | string | Yes | Yes | Name of the permission to request. | | reason | string | Yes | Yes | Reason for requesting the permission. | -| reasonId9+ | number | Yes | Yes | ID of the reason for requesting the permission.| | usedScene | [UsedScene](#usedscene) | Yes | Yes | Application scenario and timing for using the permission.| -## UsedScene +## UsedScene(deprecated) + +> This API is deprecated since API version 9. You are advised to use [UsedScene](js-apis-bundleManager-bundleInfo.md) instead. Describes the application scenario and timing for using the permission. diff --git a/en/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md b/en/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md index 3dd7cf31bb..9ab7fb823f 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md +++ b/en/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md @@ -1,15 +1,18 @@ # BundleInstaller -The **BundleInstaller** module provides APIs for installing, updating, and deleting bundles on devices. +The **BundleInstaller** module provides APIs for you to install, uninstall, and recover bundles on devices. > **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. -## BundleInstaller.install +## BundleInstaller.install(deprecated) + +> This API is deprecated since API version 9. You are advised to use [install](js-apis-installer.md) instead. install(bundleFilePaths: Array<string>, param: InstallParam, callback: AsyncCallback<InstallStatus>): void; -Installs bundles. This API uses an asynchronous callback to return the result. +Installs a bundle. This API uses an asynchronous callback to return the result. **Required permissions** @@ -23,13 +26,15 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | -| bundleFilePaths | Array<string> | Yes | Paths where the bundles are stored. Each path should point to a relative directory of the current application's data directory.| -| param | [InstallParam](#installparam) | Yes | Parameters required for the installation or uninstall. | +| bundleFilePaths | Array<string> | Yes | Paths where the HAP files of the bundle are stored. Each path should point to a relative directory of the current bundle's data directory.| +| param | [InstallParam](#installparam) | Yes | Parameters required for bundle installation. | | callback | AsyncCallback<[InstallStatus](#installstatus)> | Yes | Callback used to return the installation status. | -## BundleInstaller.uninstall +## BundleInstaller.uninstall(deprecated) + +> This API is deprecated since API version 9. You are advised to use [uninstall](js-apis-installer.md) instead. uninstall(bundleName: string, param: InstallParam, callback: AsyncCallback<InstallStatus>): void; @@ -47,13 +52,15 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | | bundleName | string | Yes | Bundle name. | -| param | [InstallParam](#installparam) | Yes | Parameters required for the installation or uninstall. | +| param | [InstallParam](#installparam) | Yes | Parameters required for bundle uninstall. | | callback | AsyncCallback<[InstallStatus](#installstatus)> | Yes | Callback used to return the installation status.| -## BundleInstaller.recover8+ +## BundleInstaller.recover(deprecated) + +> This API is deprecated since API version 9. You are advised to use [recover](js-apis-installer.md) instead. recover(bundleName: string, param: InstallParam, callback: AsyncCallback<InstallStatus>): void; @@ -71,26 +78,13 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | | bundleName | string | Yes | Bundle name. | -| param | [InstallParam](#installparam) | Yes | Parameters required for the installation or uninstall. | +| param | [InstallParam](#installparam) | Yes | Parameters required for bundle recovering. | | callback | AsyncCallback<[InstallStatus](#installstatus)> | Yes | Callback used to return the installation status.| -## HashParam9+ - -Describes the parameters required for bundle installation or uninstall. - - **System capability**: SystemCapability.BundleManager.BundleFramework - - **System API**: This is a system API and cannot be called by third-party applications. - -| Name | Type | Description | -| ---------- | ------ | ---------------- | -| moduleName | string | Module name of the application.| -| hashValue | string | Hash value. | - -## InstallParam +## InstallParam(deprecated) Describes the parameters required for bundle installation or uninstall. @@ -98,15 +92,13 @@ Describes the parameters required for bundle installation or uninstall. **System API**: This is a system API and cannot be called by third-party applications. -| Name | Type | Description | -| ------------------------------ | ------------------------------ | ------------------ | -| userId | number | User ID. | -| installFlag | number | Installation flag. | -| isKeepData | boolean | Whether data is kept.| -| hashParams9+ | Array<[HashParam](#hashparam)> | Hash parameters. | -| crowdtestDeadline9+ | number | Time when the test package is killed.| +| Name | Type | Readable| Writable| Description | +| ----------- | ------- | ---- | ---- | ------------------ | +| userId | number | Yes | No | User ID. | +| installFlag | number | Yes | No | Installation flag. | +| isKeepData | boolean | Yes | No | Whether data is kept.| -## InstallStatus +## InstallStatus(deprecated) Describes the bundle installation status. diff --git a/en/application-dev/reference/apis/js-apis-bundle-CustomizeData.md b/en/application-dev/reference/apis/js-apis-bundle-CustomizeData.md index 3fc0106cb1..246f1420fb 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-CustomizeData.md +++ b/en/application-dev/reference/apis/js-apis-bundle-CustomizeData.md @@ -1,21 +1,17 @@ # CustomizeData - +The **CustomizeData** module provides custom metadata. > **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. +## CustomizeData(deprecated) - -Provides custom metadata. - -## CustomizeData +> This API is deprecated since API version 9. You are advised to use [Metadata](js-apis-bundleManager-metadata.md) instead. **System capability**: SystemCapability.BundleManager.BundleFramework - - | Name | Type | Readable| Writable| Description | | ------------------ | ------ | ---- | ---- | ---------------- | | name | string | Yes | Yes | Custom metadata name.| diff --git a/en/application-dev/reference/apis/js-apis-bundle-ElementName.md b/en/application-dev/reference/apis/js-apis-bundle-ElementName.md index 4a22bff59f..54f43e7a56 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-ElementName.md +++ b/en/application-dev/reference/apis/js-apis-bundle-ElementName.md @@ -6,11 +6,11 @@ The **ElementName** module provides the element name information, which can be o > > 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. -## ElementName(deprecated) +## ElementName(deprecated) > This API is deprecated since API version 9. You are advised to use [ElementName](js-apis-bundleManager-elementName.md) instead. - **System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFramework | Name | Type | Readable| Writable| Description | | ----------------------- | ---------| ---- | ---- | ------------------------- | @@ -19,6 +19,3 @@ The **ElementName** module provides the element name information, which can be o | abilityName | string | Yes | Yes | Name of the ability. | | uri | string | Yes | Yes | Resource ID. | | shortName | string | Yes | Yes | Short name of the ability. | -| moduleName9+ | string | Yes | Yes | Name of the HAP file to which the ability belongs. | - - \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-bundle-ExtensionAbilityInfo.md b/en/application-dev/reference/apis/js-apis-bundle-ExtensionAbilityInfo.md deleted file mode 100644 index 5457c4e315..0000000000 --- a/en/application-dev/reference/apis/js-apis-bundle-ExtensionAbilityInfo.md +++ /dev/null @@ -1,28 +0,0 @@ -# ExtensionAbilityInfo - -The **ExtensionAbilityInfo** module provides Extension ability information. Unless otherwise specified, all attributes are obtained through [getBundleInfo](js-apis-Bundle.md#bundlegetbundleinfo), and flags are obtained through [GET_BUNDLE_DEFAULT](js-apis-Bundle.md#bundleflag). - -> **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. - -## ExtensionAbilityInfo - -**System capability**: SystemCapability.BundleManager.BundleFramework - -| Name | Type | Readable| Writable| Description | -| -------------------- | ---------------------------------------------------- | ---- | ---- | -------------------------------------------------- | -| bundleName | string | Yes | No | Bundle name of the application. | -| moduleName | string | Yes | No | Name of the HAP file to which the Extension ability belongs. | -| name | string | Yes | No | Name of the Extension ability. | -| labelId | number | Yes | No | Label ID of the Extension ability. | -| descriptionId | number | Yes | No | Description ID of the Extension ability. | -| iconId | number | Yes | No | Icon ID of the Extension ability. | -| isVisible | boolean | Yes | No | Whether the Extension ability can be called by other applications. | -| extensionAbilityType | bundle.ExtensionAbilityType | Yes | No | Type of the Extension ability. | -| permissions | Array\ | Yes | No | Permissions required for other applications to call the Extension ability.| -| applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | Yes | No | Application information of the Extension ability. | -| metadata | Array\<[Metadata](js-apis-bundle-Metadata.md)> | Yes | No | Metadata of the Extension ability. | -| enabled | boolean | Yes | No | Whether the Extension ability is enabled. | -| readPermission | string | Yes | No | Permission required for reading data from the Extension ability. | -| writePermission | string | Yes | No | Permission required for writing data to the Extension ability. | diff --git a/en/application-dev/reference/apis/js-apis-bundle-HapModuleInfo.md b/en/application-dev/reference/apis/js-apis-bundle-HapModuleInfo.md index 5a11609281..0e252cc3fe 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-HapModuleInfo.md +++ b/en/application-dev/reference/apis/js-apis-bundle-HapModuleInfo.md @@ -1,14 +1,14 @@ # HapModuleInfo - +The **HapModuleInfo** module provides module information. Unless otherwise specified, all attributes are obtained through **GET_BUNDLE_DEFAULT**. > **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. -The **HapModuleInfo** module provides module information. Unless otherwise specified, all attributes are obtained through **GET_BUNDLE_DEFAULT**. +## HapModuleInfo(deprecated) -## HapModuleInfo +> This API is deprecated since API version 9. You are advised to use [HapModuleInfo](js-apis-bundleManager-hapModuleInfo.md) instead. **System capability**: SystemCapability.BundleManager.BundleFramework @@ -29,7 +29,3 @@ The **HapModuleInfo** module provides module information. Unless otherwise speci | moduleName | string | Yes | No | Module name. | | mainAbilityName | string | Yes | No | Name of the main ability. | | installationFree | boolean | Yes | No | Whether installation-free is supported. | -| mainElementName9+ | string | Yes | No | Information about the main ability. | -| extensionAbilityInfo9+ | Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)> | Yes | No | Information about the Extension ability.| -| metadata9+ | Array\<[Metadata](js-apis-bundle-Metadata.md)> | Yes | No | Metadata of the ability. | -| hashValue9+ | string | Yes | No | Hash value of the module.
The value is obtained by passing **GET_BUNDLE_WITH_HASH_VALUE**.| diff --git a/en/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md b/en/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md index ef19c14e94..7df2416aa4 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md +++ b/en/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md @@ -6,7 +6,9 @@ The **LauncherAbilityInfo** module provides information about the launcher abili > > 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. -## LauncherAbilityInfo +## LauncherAbilityInfo(deprecated) + +> This API is deprecated since API version 9. You are advised to use [LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md) instead. **System capability**: SystemCapability.BundleManager.BundleFramework diff --git a/en/application-dev/reference/apis/js-apis-bundle-Metadata.md b/en/application-dev/reference/apis/js-apis-bundle-Metadata.md deleted file mode 100644 index 7a0c9f617f..0000000000 --- a/en/application-dev/reference/apis/js-apis-bundle-Metadata.md +++ /dev/null @@ -1,18 +0,0 @@ -# Metadata - -The **Metadata** module provides the metadata 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. - -## Metadata - -**System capability**: SystemCapability.BundleManager.BundleFramework - -| Name | Type | Readable| Writable| Description | -| -------- | ------ | ---- | ---- | ---------- | -| name | string | Yes | Yes | Metadata name.| -| value | string | Yes | Yes | Metadata value. | -| resource | string | Yes | Yes | Metadata resource.| - diff --git a/en/application-dev/reference/apis/js-apis-bundle-ModuleInfo.md b/en/application-dev/reference/apis/js-apis-bundle-ModuleInfo.md index 4dc32a18b0..781b34f89b 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-ModuleInfo.md +++ b/en/application-dev/reference/apis/js-apis-bundle-ModuleInfo.md @@ -1,21 +1,16 @@ # ModuleInfo - +The **ModuleInfo** module provides module information of an application. > **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. - - -Provides the module information of the application. - -## ModuleInfo +## ModuleInfo(deprecated) +> This API is deprecated since API version 9. You are advised to use [HapModuleInfo](js-apis-bundleManager-hapModuleInfo.md) instead. **System capability**: SystemCapability.BundleManager.BundleFramework - - | Name | Type | Readable| Writable| Description | | --------------- | ------ | ---- | ---- | -------- | | moduleName | string | Yes | No | Module name.| diff --git a/en/application-dev/reference/apis/js-apis-bundle-PermissionDef.md b/en/application-dev/reference/apis/js-apis-bundle-PermissionDef.md index d93fcec0ec..aa7b5da045 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-PermissionDef.md +++ b/en/application-dev/reference/apis/js-apis-bundle-PermissionDef.md @@ -6,7 +6,9 @@ The **PermissionDef** module provides permission details defined in the configur > > 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. -## **PermissionDef** +## **PermissionDef**(deprecated) + +> This API is deprecated since API version 9. You are advised to use [PermissionDef](js-apis-bundleManager-permissionDef.md) instead. **System capability**: SystemCapability.BundleManager.BundleFramework diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-abilityInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-abilityInfo.md new file mode 100644 index 0000000000..71f2ee6483 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundleManager-abilityInfo.md @@ -0,0 +1,53 @@ +# AbilityInfo + +The **AbilityInfo** module provides information about an ability. Unless otherwise specified, the information is obtained through [GET_ABILITY_INFO_DEFAULT](js-apis-bundleManager.md). + +> **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. + +## AbilityInfo + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Type | Readable| Writable| Description | +| --------------------- | -------------------------------------------------------- | ---- | ---- | ----------------------------------------- | +| bundleName | string | Yes | No | Bundle name. | +| moduleName | string | Yes | No | Name of the HAP file to which the ability belongs. | +| name | string | Yes | No | Ability name. | +| label | string | Yes | No | Ability name visible to users. | +| labelId | number | Yes | No | ID of the ability label. | +| description | string | Yes | No | Ability description. | +| descriptionId | number | Yes | No | ID of the ability description. | +| icon | string | Yes | No | Index of the ability icon resource file. | +| iconId | number | Yes | No | ID of the ability icon. | +| process | string | Yes | No | Process in which the ability runs. If this parameter is not set, the bundle name is used.| +| isVisible | boolean | Yes | No | Whether the ability can be called by other bundles. | +| type | [AbilityType](js-apis-bundleManager.md#abilitytype) | Yes | No | Ability type.
This attribute can be used only in the FA model. | +| orientation | [DisplayOrientation](js-apis-bundleManager.md#displayorientation) | Yes | No | Ability display orientation. | +| launchType | [LaunchType](js-apis-bundleManager.md#launchtype) | Yes | No | Ability launch mode. | +| permissions | Array\ | Yes | No | Permissions required for other bundles to call the ability. The information is obtained by using **GET_ABILITY_INFO_WITH_PERMISSION**.| +| readPermission | string | Yes | No | Permission required for reading the ability data.
This attribute can be used only in the FA model.| +| writePermission | string | Yes | No | Permission required for writing data to the ability.
This attribute can be used only in the FA model.| +| uri | string | Yes | No | URI of the ability.
This attribute can be used only in the FA model.| +| deviceTypes | Array\ | Yes | No | Device types supported by the ability. | +| applicationInfo | [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | Yes | No | Application information. The information is obtained by using **GET_ABILITY_INFO_WITH_APPLICATION**.| +| metadata | Array\<[Metadata](js-apis-bundleManager-metadata.md)> | Yes | No | Metadata of the ability. The information is obtained by using **GET_ABILITY_INFO_WITH_METADATA**.| +| enabled | boolean | Yes | No | Whether the ability is enabled. | +| supportWindowModes | Array\<[SupportWindowMode](js-apis-bundleManager.md#supportwindowmode)> | Yes | No | Window modes supported by the ability. | +| windowSize|[WindowSize](#windowsize) | Yes | No | Window size.| + +## WindowSize + +Describes the window size. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Type | Readable| Writable| Description | +| -------------------| ------- | ---- | ---- | ---------------------------------- | +| maxWindowRatio | number | Yes | No | Maximum aspect ratio of the window in free window mode. The value ranges from 0 to 1.| +| minWindowRatio | number | Yes | No | Minimum aspect ratio of the window in free window mode. The value ranges from 0 to 1.| +| maxWindowWidth | number | Yes | No | Maximum width of the window in free window mode. The unit is vp.| +| minWindowWidth | number | Yes | No | Minimum width of the window in free window mode. The unit is vp.| +| maxWindowHeight | number | Yes | No | Maximum height of the window in free window mode. The unit is vp.| +| minWindowHeight | number | Yes | No | Maximum height of the window in free window mode. The unit is vp.| diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md new file mode 100644 index 0000000000..d4c0b4f4c2 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md @@ -0,0 +1,34 @@ +# ApplicationInfo + +The **ApplicationInfo** module provides information about an application. Unless otherwise specified, the information is obtained through [GET_APPLICATION_INFO_DEFAULT](js-apis-bundleManager.md). + +> **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. + +## ApplicationInfo + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core +| Name | Type | Readable| Writable| Description | +| -------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ | +| name | string | Yes | No | Application name. | +| description | string | Yes | No | Application description. | +| descriptionId | number | Yes | No | ID of the application description. | +| enabled | boolean | Yes | No | Whether the application is enabled. The default value is **true**. | +| label | string | Yes | No | Application label. | +| labelId | number | Yes | No | ID of the application label. | +| icon | string | Yes | No | Application icon. | +| iconId | number | Yes | No | ID of the application icon. | +| process | string | Yes | No | Process in which the application runs. If this parameter is not set, the bundle name is used. | +| permissions | Array\ | Yes | No | Permissions required for accessing the application. The information is obtained by using **GET_APPLICATION_INFO_WITH_PERMISSION**.| +| entryDir | string | Yes | No | Path for storing application files. | +| codePath | string | Yes | No | Installation directory of the application. | +| metadata | Map\> | Yes | No | Metadata of the application. The information is obtained by using **GET_APPLICATION_INFO_WITH_METADATA**.| +| removable | boolean | Yes | No | Whether the application is removable. | +| accessTokenId | number | Yes | No | Access token ID of the application. | +| uid | number | Yes | No | UID of the application. | +| iconResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Icon resource of the application. | +| labelResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Label resource of the application. | +| descriptionResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Description resource of the application. | +| appDistributionType | string | Yes | No | Distribution type of the application signing certificate. The options are **app_gallery**, **enterprise**, **os_integration**, and **crowdtesting**. | +| appProvisionType | string | Yes | No | Type of the application signing certificate file. The options are **debug** and **release**. | diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-bundleInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-bundleInfo.md new file mode 100644 index 0000000000..0f54e790c3 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundleManager-bundleInfo.md @@ -0,0 +1,65 @@ +# BundleInfo + +The **BundleInfo** module provides information about a bundle. Unless otherwise specified, the information is obtained through [GET_BUNDLE_INFO_DEFAULT](js-apis-bundle-bundleManager). + +> **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. + +## BundleInfo + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Type | Readable| Writable| Description | +| --------------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ | +| name | string | Yes | No | Bundle name. | +| vendor | string | Yes | No | Vendor of the bundle. | +| versionCode | number | Yes | No | Version number of the bundle. | +| versionName | string | Yes | No | Version description of the bundle. | +| minCompatibleVersionCode | number | Yes | No | Earliest version compatible with the bundle in the distributed scenario. | +| targetVersion | number | Yes | No | Target API version required for running the bundle. | +| appInfo | [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | Yes | No | Application information. The information is obtained by using **GET_BUNDLE_INFO_WITH_APPLICATION**. | +| hapModulesInfo | Array\<[HapModuleInfo](js-apis-bundleManager-hapModuleInfo.md)> | Yes | No | Module configuration information. The information is obtained by using **GET_BUNDLE_INFO_WITH_HAP_MODULE**. | +| reqPermissionDetails | Array\<[ReqPermissionDetail](#reqpermissiondetail)> | Yes | No | Detailed information of the permissions to request from the system. The information is obtained by using **GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION**.| +| permissionGrantStates | Array\<[PermissionGrantState](js-apis-bundleManager.md#permissiongrantstate)> | Yes | No | Permission grant state. The information is obtained by using **GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION**. | +| signatureInfo | [SignatureInfo](#signatureinfo) | Yes | No | Signature information of the bundle. The information is obtained by using **GET_BUNDLE_INFO_WITH_SIGNATURE_INFO**. | +| installTime | number | Yes | No | Time when the bundle was installed. | +| updateTime | number | Yes | No | Time when the bundle was updated. | + + +## ReqPermissionDetail + +Provides the detailed information of the permissions to request from the system. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Type | Readable| Writable| Description | +| --------------------- | ----------------------- | ---- | ---- | ---------------------| +| name | string | Yes | Yes | Name of the permission to request. | +| reason | string | Yes | Yes | Reason for requesting the permission. | +| reasonId | number | Yes | Yes | ID of the reason for requesting the permission.| +| usedScene | [UsedScene](#usedscene) | Yes | Yes | Application scenario and timing for using the permission.| + + + +## UsedScene + +Describes the application scenario and timing for using the permission. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Type | Readable| Writable| Description | +| --------- | -------------- | ---- | ---- | --------------------------- | +| abilities | Array\ | Yes | Yes | Abilities that use the permission. | +| when | string | Yes | Yes | Time when the permission is used. | + +## SignatureInfo + +Describes the signature information of the bundle. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Type | Readable| Writable| Description | +| --------- | -------------- | ---- | ---- | --------------------------- | +| appId | string | Yes | No | Application ID. | +|fingerprint| string | Yes | No | Fingerprint information of the bundle. | diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-dispatchInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-dispatchInfo.md new file mode 100644 index 0000000000..daa678528c --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundleManager-dispatchInfo.md @@ -0,0 +1,18 @@ +# DispatchInfo + +The **DispatchInfo** module provides version information about the **dispatchInfo** struct and dispatch API. The information can be obtained through [freeInstall.getDispatchInfo](js-apis-freeInstall.md). + +> **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. + +## DispatchInfo + +**System API**: This is a system API. + +**System capability**: SystemCapability.BundleManager.BundleFramework.FreeInstall + +| Name | Type | Readable| Writable| Description | +| ----------- | ------ | ---- | ---- | ------------------------ | +| version | string | Yes | No | Version of the **dispatchInfo** struct.| +| dispatchAPIVersion | string | Yes | No | Version of the dispatch API. | diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-elementName.md b/en/application-dev/reference/apis/js-apis-bundleManager-elementName.md index 93b932d3c4..6948fac50f 100644 --- a/en/application-dev/reference/apis/js-apis-bundleManager-elementName.md +++ b/en/application-dev/reference/apis/js-apis-bundleManager-elementName.md @@ -1,6 +1,6 @@ # ElementName -The **ElementName** module provides the element name information, which can be obtained through [Context.getElementName](js-apis-Context.md). +The **ElementName** module provides information about an element name. The information can be obtained through [Context.getElementName](js-apis-Context.md). > **NOTE** @@ -19,4 +19,3 @@ The **ElementName** module provides the element name information, which can be o | uri | string | Yes | Yes | Resource ID. | | shortName | string | Yes | Yes | Short name of the ability. | | moduleName | string | Yes | Yes | Module name of the HAP file to which the ability belongs. | - diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-extensionAbilityInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-extensionAbilityInfo.md new file mode 100644 index 0000000000..bc15423253 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundleManager-extensionAbilityInfo.md @@ -0,0 +1,28 @@ +# ExtensionAbilityInfo + +The **ExtensionAbilityInfo** module provides information about an Extension ability. Unless otherwise specified, all attributes are obtained through [getBundleInfo](js-apis-bundleManager.md), and flags are obtained through [GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY](js-apis-bundleManager.md#bundleflag). + +> **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. + +## ExtensionAbilityInfo + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Type | Readable| Writable| Description | +| -------------------- | ----------------------------------------------------------- | ---- | ---- | -------------------------------------------------- | +| bundleName | string | Yes | No | Bundle name. | +| moduleName | string | Yes | No | Name of the HAP file to which the Extension ability belongs. | +| name | string | Yes | No | Name of the Extension ability. | +| labelId | number | Yes | No | Label ID of the Extension ability. | +| descriptionId | number | Yes | No | Description ID of the Extension ability. | +| iconId | number | Yes | No | Icon ID of the Extension ability. | +| isVisible | boolean | Yes | No | Whether the Extension ability can be called by other bundles. | +| extensionAbilityType | [ExtensionAbilityType](js-apis-bundleManager.md#extensionabilitytype) | Yes | No | Type of the Extension ability. | +| permissions | Array\ | Yes | No | Permissions required for other bundles to call the Extension ability.| +| applicationInfo | [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | Yes | No | Application information of the Extension ability. | +| metadata | Array\<[Metadata](js-apis-bundleManager-metadata.md)> | Yes | No | Metadata of the Extension ability. | +| enabled | boolean | Yes | No | Whether the Extension ability is enabled. | +| readPermission | string | Yes | No | Permission required for reading data from the Extension ability. | +| writePermission | string | Yes | No | Permission required for writing data to the Extension ability. | diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-hapModuleInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-hapModuleInfo.md new file mode 100644 index 0000000000..23e9c8c5e5 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundleManager-hapModuleInfo.md @@ -0,0 +1,27 @@ +# HapModuleInfo + +> **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. + +## HapModuleInfo + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Type | Readable| Writable| Description | +| --------------------------------- | ------------------------------------------------------------ | ---- | ---- | -------------------- | +| name | string | Yes | No | Module name. | +| icon | string | Yes | No | Module icon. | +| iconId | number | Yes | No | ID of the module icon. | +| label | string | Yes | No | Module label. | +| labelId | number | Yes | No | ID of the module label. | +| description | string | Yes | No | Module description. | +| descriptionId | number | Yes | No | ID of the module mescription. | +| mainElementName | string | Yes | No | Name of the main ability. | +| abilitiesInfo | Array\<[AbilityInfo](js-apis-bundleManager-abilityInfo.md)> | Yes | No | Ability information. | +| extensionAbilitiesInfo | Array\<[ExtensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)> | Yes | No | Information about the Extension ability.| +| metadata | Array\<[Metadata](js-apis-bundleManager-metadata.md)> | Yes | No | Metadata of the ability. | +| deviceTypes | Array\ | Yes | No | Device types supported by the module. | +| installationFree | boolean | Yes | No | Whether installation-free is supported. | +| hashValue | string | Yes | No | Hash value of the module. | +| moduleSourceDir | string | Yes | No | Module path.| diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-launcherAbilityInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-launcherAbilityInfo.md new file mode 100644 index 0000000000..c1919df283 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundleManager-launcherAbilityInfo.md @@ -0,0 +1,18 @@ +# LauncherAbilityInfo +> **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. +## LauncherAbilityInfo + +**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher + +**System API**: This is a system API and cannot be called by third-party applications. + +| Name | Type | Readable| Writable| Description | +| --------------- | ----------------------------------------------------------- | ---- | ---- | ------------------------------------ | +| applicationInfo | [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | Yes | No | Application information of the launcher ability.| +| elementName | [ElementName](js-apis-bundleManager-elementName.md) | Yes | No | Element name of the launcher ability. | +| labelId | number | Yes | No | Label ID of the launcher ability. | +| iconId | number | Yes | No | Icon ID of the launcher ability. | +| userId | number | Yes | No | User ID of the launcher ability. | +| installTime | number | Yes | No | Time when the launcher ability was installed. | diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-metadata.md b/en/application-dev/reference/apis/js-apis-bundleManager-metadata.md new file mode 100644 index 0000000000..203c5328b6 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundleManager-metadata.md @@ -0,0 +1,15 @@ +# Metadata + +The **metadata** module provides the configuration about the module, ability, and Extension ability. The value is of the array type. The configuration is valid only for the current module, ability, or Extension 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. +## Metadata +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Type | Readable| Writable| Description | +| -------- | ------ | ---- | ---- | ---------- | +| name | string | Yes | Yes | Metadata name.| +| value | string | Yes | Yes | Metadata value. | +| resource | string | Yes | Yes | Metadata resource.| diff --git a/en/application-dev/reference/apis/js-apis-bundle-PackInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-packInfo.md similarity index 59% rename from en/application-dev/reference/apis/js-apis-bundle-PackInfo.md rename to en/application-dev/reference/apis/js-apis-bundleManager-packInfo.md index 323d4d1f94..4a0e43c193 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-PackInfo.md +++ b/en/application-dev/reference/apis/js-apis-bundleManager-packInfo.md @@ -1,157 +1,147 @@ # PackInfo -The **PackInfo** module provides the bundle package information, which can be obtained using [bundle.getBundlePackInfo](js-apis-Bundle.md). +The **PackInfo** module provides information in the **pack.info** file. The information can be obtained using [freeInstall.getBundlePackInfo](js-apis-freeInstall.md). + > **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. -## BundlePackFlag - -**System API**: This is a system API and cannot be called by third-party applications. - -**System capability**: SystemCapability.BundleManager.BundleFramework - -| Name | Value | Description | -| ------------------ | ---------- | ---------------------------------- | -| GET_PACK_INFO_ALL | 0x00000000 | All information about the package. | -| GET_PACKAGES | 0x00000001 | Package information about the package.| -| GET_BUNDLE_SUMMARY | 0x00000002 | Bundle summary of the package. | -| GET_MODULE_SUMMARY | 0x00000004 | Module summary of the package. | - ## BundlePackInfo -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall -| Name | Type | Readable| Writable| Description | -| -------- | --------------------------------------- | ---- | ---- | ----------------------------- | -| packages | Array\<[PackageConfig](#packageconfig)> | Yes | No | Package configuration information. | -| summary | [PackageSummary](#packagesummary) | Yes | No | Package summary.| + +| Name | Type | Readable| Writable| Description | +| -------- | --------------------------------------- | ---- | ---- | ------------------------- | +| packages | Array\<[PackageConfig](#packageconfig)> | Yes | No | Package configuration information in the **pack.info** file. | +| summary | [PackageSummary](#packagesummary) | Yes | No | Package summary information in the **pack.info** file.| ## PackageConfig -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall | Name | Type | Readable| Writable| Description | | ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ | -| deviceType | Array\ | Yes | No | Device types supported. | -| name | string | Yes | No | Package name. | -| moduleType | string | Yes | No | Module type. | -| deliveryWithInstall | boolean | Yes | No | Whether the HAP file will be installed when the user installs the application. The value **true** means that the HAP file will be automatically installed when the user installs the application, and **false** means the opposite.| +| deviceTypes | Array\ | Yes | No | Device types supported by the bundle. | +| name | string | Yes | No | Bundle name. | +| moduleType | string | Yes | No | Module type of the bundle. | +| deliveryWithInstall | boolean | Yes | No | Whether the HAP file will be installed when the user installs the bundle. The value **true** means that the HAP file will be automatically installed when the user installs the bundle, and **false** means the opposite.| -## PackageSummary +## PackageSummary -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall | Name | Type | Readable| Writable| Description | | ------- | --------------------------------------------- | ---- | ---- | -------------------- | | app | [BundleConfigInfo](#bundleconfiginfo) | Yes | No | Bundle configuration information. | -| modules | Array\<[ModuleConfigInfo](#moduleconfiginfo)> | Yes | No | Module configuration information.| +| modules | Array\<[ModuleConfigInfo](#moduleconfiginfo)> | Yes | No | Module configuration information of the bundle.| ## BundleConfigInfo -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall | Name | Type | Readable| Writable| Description | | ---------- | ------------------- | ---- | ---- | ---------------------------------- | -| bundleName | string | Yes | No | Bundle name of an application. It uniquely identifies the application.| +| bundleName | string | Yes | No | Bundle name. It uniquely identifies the application.| | version | [Version](#version) | Yes | No | Bundle version. | ## ModuleConfigInfo -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall | Name | Type | Readable| Writable| Description | | ------------------ | ------------------------------------------------- | ---- | ---- | ---------------------------------- | +| mainAbility | string | Yes| No| Name of the main ability.| | apiVersion | [ApiVersion](#apiversion) | Yes | No | API version of the module. | -| deviceType | Array\ | Yes | No | Device type of the module. | +| deviceType | Array\ | Yes | No | Device types supported by the module. | | distro | [ModuleDistroInfo](#moduledistroinfo) | Yes | No | Distribution information of the module. | | abilities | Array\<[ModuleAbilityInfo](#moduleabilityinfo)> | Yes | No | Ability information of the module. | -| extensionAbilities | Array\<[ExtensionAbilities](#extensionabilities)> | Yes | No | Extension ability information of the module.| +| extensionAbilities | Array\<[ExtensionAbilities](#extensionability)> | Yes | No | Extension ability information of the module.| -## ModuleDistroInfo +## ModuleDistroInfo -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall | Name | Type | Readable| Writable| Description | | ------------------- | ------- | ---- | ---- | ------------------------------------------------------------ | -| mainAbility | string | Yes | No | Name of the main ability. | -| deliveryWithInstall | boolean | Yes | No | Whether the HAP file will be installed when the user installs the application. The value **true** means that the HAP file will be automatically installed when the user installs the application, and **false** means the opposite.| +| deliveryWithInstall | boolean | Yes | No | Whether the HAP file will be installed when the user installs the bundle. The value **true** means that the HAP file will be automatically installed when the user installs the bundle, and **false** means the opposite.| | installationFree | boolean | Yes | No | Whether the HAP file supports the installation-free feature. The value **true** means that the HAP file supports the installation-free feature and meets installation-free constraints, and **false** means the opposite.| | moduleName | string | Yes | No | Module name. | | moduleType | string | Yes | No | Module type. | -## ModuleAbilityInfo +## ModuleAbilityInfo -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall | Name | Type | Readable| Writable| Description | | ------- | ------------------------------------------- | ---- | ---- | ------------------------------------------------------------ | -| name | string | Yes | No | Logical name of the ability. The name must be unique in the application. | +| name | string | Yes | No | Name of the ability. The name must be unique in the bundle. | | label | string | Yes | No | Name of the ability displayed to users. The value is a resource index to names in multiple languages.| -| visible | boolean | Yes | No | Whether the ability can be called by other applications. The value **true** means that the ability can be called by other applications, and **false** means the opposite.| +| visible | boolean | Yes | No | Whether the ability can be called by other bundles. The value **true** means that the ability can be called by other bundles, and **false** means the opposite.| | forms | Array\<[AbilityFormInfo](#abilityforminfo)> | Yes | No | Widget information. | -## ExtensionAbilities +## ExtensionAbility -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall | Name | Type | Readable| Writable| Description | | ----- | ------------------------------------------- | ---- | ---- | ------------------------------------------------------------ | -| forms | Array\<[AbilityFormInfo](#abilityforminfo)> | Yes | No | Specification of the widget. A widget is a brief view of an application that is embedded on the home screen to receive periodical updates.| +| name | string | Yes| No| Name of the Extension ability.| +| forms | Array\<[AbilityFormInfo](#abilityforminfo)> | Yes | No | Widget information.| ## AbilityFormInfo -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall | Name | Type | Readable| Writable| Description | | ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ | | name | string | Yes | No | Widget name. | | type | string | Yes | No | Widget type. | -| updateEnabled | boolean | Yes | No | Whether the widget supports periodical update. The value **true** means that the widget supports periodical update, and **false** means the opposite.| +| updateEnabled | boolean | Yes | No | Whether the widget supports periodic update. The value **true** means that the widget supports periodic update, and **false** means the opposite.| | scheduledUpdateTime | string | Yes | No | Scheduled time to update the widget. The value is in 24-hour format and accurate to the minute. | -| updateDuration | number | Yes | No | Interval to update the widget. The unit is 30 minutes. The value is a multiple of 30. A widget can be updated periodically, either at a specified interval (**updateDuration**) or at the scheduled time (**scheduledUpdateTime**). If both are configured, **updateDuration** takes precedence.| -| supportDimensions | Array\ | Yes | No | Dimensions of the widget. The value can be **1\*2**, **2\*2**, **2\*4**, **4\*4**, or a combination of these options. At least one option must be specified when defining the widget.| -| defaultDimension | number | Yes | No | Default dimensions of the widget. The value must be available in the **supportDimensions** array of the widget.| +| updateDuration | number | Yes | No | Interval to update the widget. The unit is 30 minutes. The value is a multiple of 30. A widget can be updated at a specified interval (**updateDuration**) or at the scheduled time (**scheduledUpdateTime**). If both are configured, **updateDuration** takes precedence.| +| supportDimensions | Array\ | Yes | No | Dimensions of the widget. The value can be **1\*2**, **2\*2**, **2\*4**, **4\*4**, or a combination of these options. At least one option must be specified when defining the widget.| +| defaultDimension | string | Yes | No | Default dimensions of the widget. The value must be available in the **supportDimensions** array of the widget.| ## ApiVersion **System API**: This is a system API and cannot be called by third-party applications. -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall | Name | Type | Readable| Writable| Description | | ----------- | ------ | ---- | ---- | -------------------- | | releaseType | string | Yes | No | Name of the API version. | | compatible | number | Yes | No | Minimum API version.| -| target | numbe | Yes | No | Target API version. | +| target | number | Yes | No | Target API version. | ## Version -**System API**: This is a system API and cannot be called by third-party applications. +**System API**: This is a system API. -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall | Name | Type | Readable| Writable| Description | | ------------------------ | ------ | ---- | ---- | ------------------------------------------------------------ | -| minCompatibleVersionCode | number | Yes | No | Minimum compatible version of the application. It is used to check whether the application is compatible with a version on other devices in the cross-device scenario. The value is a 32-bit non-negative integer.| -| name | string | Yes | No | Application version number visible to users. | -| code | number | Yes | No | Application version number used only for application management. The value is a 32-bit non-negative integer. It is used only to determine whether a version is later than another version. A larger value indicates a later version.| +| minCompatibleVersionCode | number | Yes | No | Minimum compatible version of the bundle. It is used to check whether the bundle is compatible with a version on other devices in the cross-device scenario. The value is a 32-bit non-negative integer.| +| name | string | Yes | No | Version number of the bundle visible to users. | +| code | number | Yes | No | Version number of the bundle used only for bundle management. The value is a 32-bit non-negative integer. It is used only to determine whether a version is later than another version. A larger value indicates a later version.| diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-permissionDef.md b/en/application-dev/reference/apis/js-apis-bundleManager-permissionDef.md new file mode 100644 index 0000000000..aa3d41a76f --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundleManager-permissionDef.md @@ -0,0 +1,20 @@ +# PermissionDef + +The **PermissionDef** module provides permission details defined in the configuration file. The information can be obtained using [bundleManager.getPermissionDef](js-apis-bundleManager.md). + +> **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. + +## **PermissionDef** + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +| Name | Type | Readable| Writable| Description | +| -------------- | ------ | ---- | ---- | -------------- | +| permissionName | string | Yes | No | Name of the permission. | +| grantMode | number | Yes | No | Grant mode of the permission.| +| labelId | number | Yes | No | Label ID of the permission. | +| descriptionId | number | Yes | No | Description ID of the permission. | diff --git a/en/application-dev/reference/apis/js-apis-bundleManager.md b/en/application-dev/reference/apis/js-apis-bundleManager.md new file mode 100644 index 0000000000..9d616bbe15 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundleManager.md @@ -0,0 +1,2905 @@ +# bundleManager + +The **bundleManager** module provides APIs for querying information about bundles, applications, abilities, Extension abilities, and more. + +> **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 bundleManager from '@ohos.bundle.bundleManager' +``` +## Required Permissions + +| 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.REMOVE_CACHE_FILES | system_basic | Permission to clear cache files of a bundle. | +|ohos.permission.CHANGE_ABILITY_ENABLED_STATE| system_basic | Permission to enable or disable an application or ability. | + +For details, see [Permission Levels](../../security/accesstoken-overview.md#permission-levels). + +## Enums + +### BundleFlag + +Enumerates the bundle flags, which indicate the type of bundle information to obtain. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Value | Description | +| ----------------------------------------- | ---------- | ------------------------------------------------------------ | +| GET_BUNDLE_INFO_DEFAULT | 0x00000000 | Used to obtain the default bundle information. The obtained information does not contain information about the signature, application, HAP module, ability, Extension ability, or permission.| +| GET_BUNDLE_INFO_WITH_APPLICATION | 0x00000001 | Used to obtain the bundle information with application information. The obtained information does not contain information about the signature, HAP module, ability, Extension ability, or permission.| +| GET_BUNDLE_INFO_WITH_HAP_MODULE | 0x00000002 | Used to obtain the bundle information with HAP module information. The obtained information does not contain information about the signature, application, ability, Extension ability, or permission.| +| GET_BUNDLE_INFO_WITH_ABILITY | 0x00000004 | Used to obtain the bundle information with ability information. The obtained information does not contain information about the signature, application, Extension ability, or permission. It must be used together with **GET_BUNDLE_INFO_WITH_HAP_MODULE**.| +| GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY | 0x00000008 | Used to obtain the bundle information with Extension ability information. The obtained information does not contain information about the signature, application, ability, or permission. It must be used together with **GET_BUNDLE_INFO_WITH_HAP_MODULE**.| +| GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION | 0x00000010 | Used to obtain the bundle information with permission information. The obtained information does not contain information about the signature, application, HAP module, ability, or Extension ability.| +| GET_BUNDLE_INFO_WITH_METADATA | 0x00000020 | Used to obtain the metadata contained in the application, HAP module, ability, or Extension ability information. It must be used together with **GET_BUNDLE_INFO_WITH_APPLICATION**, **GET_BUNDLE_INFO_WITH_HAP_MODULE**, **GET_BUNDLE_INFO_WITH_ABILITY**, and **GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY**.| +| GET_BUNDLE_INFO_WITH_DISABLE | 0x00000040 | Used to obtain the information about disabled bundles and abilities of a bundle. The obtained bundle information does not contain information about the signature, application, HAP module, ability, Extension ability, or permission.| +| GET_BUNDLE_INFO_WITH_SIGNATURE_INFO | 0x00000080 | Used to obtain the bundle information with signature information. The obtained information does not contain information about the application, HAP module, ability, Extension ability, or permission.| + +### ApplicationFlag + +Enumerates the application flags, which indicate the type of application information to obtain. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + + **System API**: This is a system API and cannot be called by third-party applications. + +| Name | Value | Description | +| ------------------------------------ | ---------- | ------------------------------------------------------------ | +| GET_APPLICATION_INFO_DEFAULT | 0x00000000 | Used to obtain the default application information. The obtained information does not contain the permission information or metadata.| +| GET_APPLICATION_INFO_WITH_PERMISSION | 0x00000001 | Used to obtain the application information with permission information. | +| GET_APPLICATION_INFO_WITH_METADATA | 0x00000002 | Used to obtain the application information with metadata. | +| GET_APPLICATION_INFO_WITH_DISABLE | 0x00000004 | Used to obtain the application information of disabled bundles. | + +### AbilityFlag + +Enumerates the ability flags, which indicate the type of ability information to obtain. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + + **System API**: This is a system API and cannot be called by third-party applications. + +| Name | Value | Description | +| --------------------------------- | ---------- | ------------------------------------------------------------ | +| GET_ABILITY_INFO_DEFAULT | 0x00000000 | Used to obtain the default ability information. The obtained information does not contain the permission, metadata, or disabled ability information.| +| GET_ABILITY_INFO_WITH_PERMISSION | 0x00000001 | Used to obtain the ability information with permission information. | +| GET_ABILITY_INFO_WITH_APPLICATION | 0x00000002 | Used to obtain the ability information with application information. | +| GET_ABILITY_INFO_WITH_METADATA | 0x00000004 | Used to obtain the ability information with metadata. | +| GET_ABILITY_INFO_WITH_DISABLE | 0x00000008 | Used to obtain the ability information of disabled abilities. | +| GET_ABILITY_INFO_ONLY_SYSTEM_APP | 0x00000010 | Used to obtain the ability information of system applications. | + +### ExtensionAbilityFlag + +Enumerates the Extension ability flags, which indicate the type of Extension ability information to obtain. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + + **System API**: This is a system API and cannot be called by third-party applications. + +| Name | Value | Description | +| ------------------------------------------- | ---------- | ------------------------------------------------------------ | +| GET_EXTENSION_ABILITY_INFO_DEFAULT | 0x00000000 | Used to obtain the default Extension ability information. The obtained information does not contain the permission, metadata, or disabled ability information.| +| GET_EXTENSION_ABILITY_INFO_WITH_PERMISSION | 0x00000001 | Used to obtain the Extension ability information with permission information. | +| GET_EXTENSION_ABILITY_INFO_WITH_APPLICATION | 0x00000002 | Used to obtain the Extension ability information with application information. | +| GET_EXTENSION_ABILITY_INFO_WITH_METADATA | 0x00000004 | Used to obtain the Extension ability information with metadata. | + +### ExtensionAbilityType + +Enumerates the types of Extension abilities. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name| Value| Description| +|:----------------:|:---:|-----| +| FORM | 0 | [FormExtensionAbility](../../ability/stage-formextension.md): provides APIs for widget development.| +| WORK_SCHEDULER | 1 | [WorkSchedulerExtensionAbility](../../task-management/work-scheduler-dev-guide.md): enables applications to execute non-real-time tasks when the system is idle.| +| INPUT_METHOD | 2 | [InputMethodExtensionAbility](js-apis-inputmethod-extension-ability.md): provides APIs for developing input method applications.| +| SERVICE | 3 | [ServiceExtensionAbility](../../ability/stage-serviceextension.md): enables applications to run in the background and provide services.| +| ACCESSIBILITY | 4 | [AccessibilityExtensionAbility](js-apis-application-AccessibilityExtensionAbility.md): provides accessibility for access to and operations on the UI.| +| DATA_SHARE | 5 | [DataShareExtensionAbility](../../database/database-datashare-guidelines.md): enables applications to read and write data.| +| FILE_SHARE | 6 | FileShareExtensionAbility: enables file sharing between applications. This ability is reserved.| +| STATIC_SUBSCRIBER| 7 | [StaticSubscriberExtensionAbility](js-apis-application-staticSubscriberExtensionAbility.md): provides APIs for processing static events, such as the startup event.| +| WALLPAPER | 8 | WallpaperExtensionAbility: provides APIs to implement the home screen wallpaper. This ability is reserved.| +| BACKUP | 9 | BackupExtensionAbility: provides APIs for backing up and restoring application data and public data. This ability is reserved.| +| WINDOW | 10 | [WindowExtensionAbility](js-apis-application-WindowExtensionAbility.md): allows system applications to display UIs of other applications.| +| ENTERPRISE_ADMIN | 11 | [EnterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md): provides APIs for processing enterprise management events, such as application installation events on devices and events indicating too many incorrect screen-lock password attempts.| +| THUMBNAIL | 13 | ThumbnailExtensionAbility: provides thumbnails for files. This ability is reserved.| +| PREVIEW | 14 | PreviewExtensionAbility: provides APIs for file preview so that other applications can be embedded and displayed in the current application. This ability is reserved.| +| UNSPECIFIED | 255 | No type is specified. It is used together with **queryExtensionAbilityInfo** to query all types of Extension abilities.| + + +### PermissionGrantState + +Enumerates the permission grant states. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name| Value| Description| +|:----------------:|:---:|:---:| +| PERMISSION_DENIED| -1 | Permission denied.| +| PERMISSION_GRANTED | 0 | Permission granted. | + +### SupportWindowMode + +Enumerates the window modes supported by the ability. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name| Value| Description| +|:----------------:|:---:|:---:| +| FULL_SCREEN | 0 | A window in full-screen mode is supported.| +| SPLIT | 1 | A window in split-screen mode is supported.| +| FLOATING | 2 | A floating window is supported. | + +### LaunchType + +Enumerates the launch types of the ability. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name| Value| Description| +|:----------------:|:---:|:---:| +| SINGLETON | 0 | The ability can have only one instance.| +| STANDARD | 1 | The ability can have multiple instances.| +| SPECIFIED | 2 | The ability can have one or multiple instances, depending on the internal service of the ability.| + +### AbilityType + +Enumerates the types of abilities. + + **Model restriction**: This API can be used only in the FA model. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Value | Description | +| :-----: | ---- | :--------------------------------------------------------: | +| PAGE | 1 | FA developed using the Page template to provide the capability of interacting with users. | +| SERVICE | 2 | PA developed using the Service template to provide the capability of running tasks in the background. | +| DATA | 3 | PA developed using the Data template to provide unified data access for external systems.| + +### DisplayOrientation + +Enumerates the display orientations of the ability. This attribute applies only to the ability using the Page template. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name |Value|Description| +|:----------------------------------|---|---| +| UNSPECIFIED |0 |Unspecified. The orientation is determined by the system.| +| LANDSCAPE |1 |Landscape.| +| PORTRAIT |2 |Portrait.| +| FOLLOW_RECENT |3 |The last display orientation is used.| +| LANDSCAPE_INVERTED |4 |Reverse landscape.| +| PORTRAIT_INVERTED |5 |Reverse portrait.| +| AUTO_ROTATION |6 |Auto rotation.| +| AUTO_ROTATION_LANDSCAPE |7 |Auto rotation in the horizontal direction.| +| AUTO_ROTATION_PORTRAIT |8 |Auto rotation in the vertical direction.| +| AUTO_ROTATION_RESTRICTED |9 |Switched-determined auto rotation.| +| AUTO_ROTATION_LANDSCAPE_RESTRICTED |10|Switched-determined auto rotation in the horizontal direction.| +| AUTO_ROTATION_PORTRAIT_RESTRICTED |11|Switched-determined auto rotation in the vertical direction.| +| LOCKED |12|Locked.| + +## Methods + +### bundleManager.getBundleInfoForSelf + +getBundleInfoForSelf(bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>; + +Obtains the bundle information of this bundle based on the given bundle flags. This API uses a promise to return the result. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | --------------------- | +| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain.| + +**Return value** + +| Type | Description | +| ----------------------------------------------------------- | ------------------------------------- | +| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise used to return the bundle information.| + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; +try { + bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => { + console.info('getBundleInfoForSelf successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('getBundleInfoForSelf failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getBundleInfoForSelf failed:' + error.message); +} +``` + +### bundleManager.getBundleInfoForSelf + +getBundleInfoForSelf(bundleFlags: [number](#bundleflag), callback: AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>): void; + +Obtains the bundle information of this bundle based on the given bundle flags. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | --------------------- | +| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain.| +| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the bundle information obtained. Otherwise, **err** is an error object.| + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; + +try { + bundleManager.getBundleInfoForSelf(bundleFlags, (err, data) => { + if (err) { + console.error('getBundleInfoForSelf failed:' + err.message); + } else { + console.info('getBundleInfoForSelf successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('getBundleInfoForSelf failed:' + err.message); +} +``` + +### bundleManager.getBundleInfo + +getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback\): void; + +Obtains the bundle information based on the given bundle name, bundle flags, and user ID. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | ---------------------------- | +| bundleName | string | Yes | Bundle name. | +| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain.| +| userId | number | Yes | User ID. | +| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the bundle information obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700004 | The specified user ID is not found. | +| 17700026 | The specified bundle is disabled. | + +**Example** + +```ts +// Obtain the bundle information with the ability information. +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; +let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY; +let userId = 100; + +try { + bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { + if (err) { + console.error('getBundleInfo failed:' + err.message); + } else { + console.info('getBundleInfo successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('getBundleInfo failed:' + err.message); +} +``` + +```ts +// Obtain the bundle information with the metadata in the application information. +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; +let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA; +let userId = 100; + +try { + bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { + if (err) { + console.error('getBundleInfo failed:' + err.message); + } else { + console.info('getBundleInfo successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('getBundleInfo failed:' + err.message); +} +``` + +### bundleManager.getBundleInfo + +getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\): void; + +Obtains the bundle information based on the given bundle name and bundle flags. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | ---------------------------- | +| bundleName | string | Yes | Bundle name. | +| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain.| +| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the bundle information obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700004 | The specified user ID is not found. | +| 17700026 | The specified bundle is disabled. | + +**Example** + +```ts +// Obtain the bundle information with the Extension ability information. +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; +let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY; + +try { + bundleManager.getBundleInfo(bundleName, bundleFlags, (err, data) => { + if (err) { + console.error('getBundleInfo failed:' + err.message); + } else { + console.info('getBundleInfo successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('getBundleInfo failed:' + err.message); +} +``` + +### bundleManager.getBundleInfo + +getBundleInfo(bundleName: string, bundleFlags: [number](#bundleflag), userId?: number): Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>; + +Obtains the bundle information based on the given bundle name, bundle flags, and user ID. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | ---------------------------- | +| bundleName | string | Yes | Bundle name.| +| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain. | +| userId | number | No | User ID. | + +**Return value** + +| Type | Description | +| ----------------------------------------------------------- | --------------------------- | +| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise used to return the bundle information obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). +| ID| Error Message | +| -------- | --------------------------------------| +| 17700001 | The specified bundleName is not found. | +| 17700004 | The specified user ID is not found. | +| 17700026 | The specified bundle is disabled. | + +**Example** + +```ts +// Obtain the bundle information with the application and signature information. +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; +let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; +let userId = 100; + +try { + bundleManager.getBundleInfo(bundleName, bundleFlags, userId).then((data) => { + console.info('getBundleInfo successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('getBundleInfo failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getBundleInfo failed. Cause: ' + error.message); +} +``` + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; +let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; + +try { + bundleManager.getBundleInfo(bundleName, bundleFlags).then((data) => { + console.info('getBundleInfo successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('getBundleInfo failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getBundleInfo failed. Cause: ' + error.message); +} + +``` + +### bundleManager.getApplicationInfo + +getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), userId: number, callback: AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>): void; + +Obtains the application information based on the given bundle name, application flags, and user ID. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | ---------------------------- | +| bundleName | string | Yes | Bundle name.| +| appFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. | +| userId | number | Yes | User ID. | +| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the application information obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | --------------------------------------| +| 17700001 | The specified bundleName is not found. | +| 17700004 | The specified user ID is not found. | +| 17700026 | The specified bundle is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; +let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; +let userId = 100; + +try { + bundleManager.getApplicationInfo(bundleName, appFlags, userId, (err, data) => { + if (err) { + console.error('getApplicationInfo failed:' + err.message); + } else { + console.info('getApplicationInfo successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('getApplicationInfo failed:' + err.message); +} +``` + +### bundleManager.getApplicationInfo + +getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), callback: AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>): void; + +Obtains the application information based on the given bundle name and application flags. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | ---------------------------- | +| bundleName | string | Yes | Bundle name.| +| appFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. | +| callback | AsyncCallback\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the application information obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | --------------------------------------| +| 17700001 | The specified bundleName is not found. | +| 17700004 | The specified user ID is not found. | +| 17700026 | The specified bundle is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; +let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION; + +try { + bundleManager.getApplicationInfo(bundleName, appFlags, (err, data) => { + if (err) { + console.error('getApplicationInfo failed:' + err.message); + } else { + console.info('getApplicationInfo successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('getApplicationInfo failed:' + err.message); +} +``` + +### bundleManager.getApplicationInfo + +getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), userId?: number): Promise\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)>; + +Obtains the application information based on the given bundle name, application flags, and user ID. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | ---------------------------- | +| bundleName | string | Yes | Bundle name.| +| appFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. | +| userId | number | No | User ID.| + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | -------------------------------- | +| Promise\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | Promise used to return the application information obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700004 | The specified user ID is not found. | +| 17700026 | The specified bundle is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; +let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION; +let userId = 100; + +try { + bundleManager.getApplicationInfo(bundleName, appFlags, userId).then((data) => { + console.info('getApplicationInfo successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('getApplicationInfo failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getApplicationInfo failed. Cause: ' + error.message); +} +``` + +### bundleManager.getAllBundleInfo + +getAllBundleInfo(bundleFlags: [number](#bundleflag), userId: number, callback: AsyncCallback>): void; + +Obtains an array of bundle information based on the given bundle flags and user ID. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | -------------------------------------------------- | +| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain. | +| userId | number | Yes | User ID. | +| callback | AsyncCallback> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of bundle information obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | --------------------------------- | +| 17700004 | The specified user ID is not found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION; +let userId = 100; + +try { + bundleManager.getAllBundleInfo(bundleFlags, userId, (err, data) => { + if (err) { + console.error('getAllBundleInfo failed:' + err.message); + } else { + console.info('getAllBundleInfo successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('getAllBundleInfo failed:' + err.message); +} +``` + +### bundleManager.getAllBundleInfo + +getAllBundleInfo(bundleFlags: [number](#bundleflag), callback: AsyncCallback>): void; + +Obtains an array of bundle information based on the given bundle flags. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | -------------------------------------------------- | +| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain. | +| callback | AsyncCallback> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of bundle information obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ---------------------------------- | +| 17700004 | The specified user ID is not found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; + +try { + bundleManager.getAllBundleInfo(bundleFlags, (err, data) => { + if (err) { + console.error('getAllBundleInfo failed:' + err.message); + } else { + console.info('getAllBundleInfo successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('getAllBundleInfo failed:' + err.message); +} +``` + +### bundleManager.getAllBundleInfo + +getAllBundleInfo(bundleFlags: [number](#bundleflag), userId?: number): Promise>; + +Obtains an array of bundle information based on the given bundle flags and user ID. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | -------------------------------------------------- | +| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain. | +| userId | number | No | User ID. | + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | ----------------------------------- | +| Promise> | Promise used to return the array of bundle information obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ---------------------------------- | +| 17700004 | The specified user ID is not found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; + +try { + bundleManager.getAllBundleInfo(bundleFlags).then((data) => { + console.info('getAllBundleInfo successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('getAllBundleInfo failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getAllBundleInfo failed. Cause: ' + error.message); +} +``` + +### bundleManager.getAllApplicationInfo + +getAllApplicationInfo(appFlags: [number](#applicationflag), userId: number, callback: AsyncCallback>): void; + +Obtains an array of application information based on the given application flags and user ID. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | ----------------------------------------------------------- | +| appFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. | +| userId | number | Yes | User ID. | +| callback | AsyncCallback> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of application information obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ---------------------------------- | +| 17700004 | The specified user ID is not found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; +let userId = 100; + +try { + bundleManager.getAllApplicationInfo(appFlags, userId, (err, data) => { + if (err) { + console.error('getAllApplicationInfo failed:' + err.message); + } else { + console.info('getAllApplicationInfo successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('getAllApplicationInfo failed:' + err.message); +} +``` + +### bundleManager.getAllApplicationInfo + +getAllApplicationInfo(appFlags: [number](#applicationflag), callback: AsyncCallback>): void; + +Obtains an array of application information based on the given application flags. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | ----------------------------------------------------------- | +| appFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. | +| callback | AsyncCallback> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of application information obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ---------------------------------- | +| 17700004 | The specified user ID is not found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; + +try { + bundleManager.getAllApplicationInfo(appFlags, (err, data) => { + if (err) { + console.error('getAllApplicationInfo failed:' + err.message); + } else { + console.info('getAllApplicationInfo successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('getAllApplicationInfo failed:' + err.message); +} +``` + +### bundleManager.getAllApplicationInfo + +getAllApplicationInfo(appFlags: [number](#applicationflag), userId?: number): Promise>; + +Obtains an array of application information based on the given application flags and user ID. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | ---------------------------------------------------------- | +| appFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. | +| userId | number | No | User ID. | + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | ---------------------------------------- | +| Promise> | Promise used to return the array of application information obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ---------------------------------- | +| 17700004 | The specified user ID is not found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; + +try { + bundleManager.getAllApplicationInfo(appFlags).then((data) => { + console.info('getAllApplicationInfo successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('getAllApplicationInfo failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getAllApplicationInfo failed. Cause: ' + error.message); +} + +``` + +### bundleManager.queryAbilityInfo + +queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId: number, callback: AsyncCallback>): void; + +Obtains an array of ability information based on the given want, ability flags, and user ID. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | ------ | ---- | ------------------------------------------------------- | +| want | Want | Yes | Want containing the bundle name to query. | +| abilityFlags | [number](#abilityflag) | Yes | Type of the ability information to obtain. | +| userId | number | Yes | User ID. | +| callback | AsyncCallback> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of ability information obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700003 | The specified ability is not found. | +| 17700004 | The specified userId is invalid. | +| 17700026 | The specified bundle is disabled. | +| 17700029 | The specified ability is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; +let userId = 100; +let want = { + bundleName : "com.example.myapplication", + abilityName : "com.example.myapplication.MainAbility" +}; + +try { + bundleManager.queryAbilityInfo(want, abilityFlags, userId, (err, data) => { + if (err) { + console.error('queryAbilityInfo failed:' + err.message); + } else { + console.info('queryAbilityInfo successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('queryAbilityInfo failed:' + err.message); +} +``` + +### bundleManager.queryAbilityInfo + +queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), callback: AsyncCallback>): void; + +Obtains an array of ability information based on the given want and ability flags. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | ------ | ---- | -------------------------------------------------------| +| want | Want | Yes | Want containing the bundle name to query. | +| abilityFlags | [number](#abilityflag) | Yes | Type of the ability information to obtain. | +| callback | AsyncCallback> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of ability information obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700003 | The specified ability is not found. | +| 17700004 | The specified userId is invalid. | +| 17700026 | The specified bundle is disabled. | +| 17700029 | The specified ability is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; +let want = { + bundleName : "com.example.myapplication", + abilityName : "com.example.myapplication.MainAbility" +}; + +try { + bundleManager.queryAbilityInfo(want, abilityFlags, (err, data) => { + if (err) { + console.error('queryAbilityInfo failed:' + err.message); + } else { + console.info('queryAbilityInfo successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('queryAbilityInfo failed:' + err.message); +} +``` + +### bundleManager.queryAbilityInfo + +queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId?: number): Promise>; + +Obtains the ability information based on the given want, ability flags, and user ID. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | ------ | ---- | ------------------------------------------------------- | +| want | Want | Yes | Want containing the bundle name to query. | +| abilityFlags | [number](#abilityflag) | Yes | Type of the ability information to obtain.| +| userId | number | No | User ID. | + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | ------------------------------------ | +| Promise> | Promise used to return the array of ability information obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700003 | The specified extensionAbility is not found. | +| 17700004 | The specified userId is invalid. | +| 17700026 | The specified bundle is disabled. | +| 17700029 | The specified ability is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; +let userId = 100; +let want = { + bundleName : "com.example.myapplication", + abilityName : "com.example.myapplication.MainAbility" +}; + +try { + bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((data) => { + console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('queryAbilityInfo failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('queryAbilityInfo failed. Cause: ' + error.message); +} +``` + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; +let want = { + bundleName : "com.example.myapplication", + abilityName : "com.example.myapplication.MainAbility" +}; + +try { + bundleManager.queryAbilityInfo(want, abilityFlags).then((data) => { + console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('queryAbilityInfo failed. Cause: ' + error.message); + }) +} catch (error) { + console.error('queryAbilityInfo failed. Cause: ' + error.message); +} +``` + +### bundleManager.queryExtensionAbilityInfo + +queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityType](#extensionabilitytype), extensionAbilityFlags: [number](#extensionabilityflag), userId: number, callback: AsyncCallback>): void; + +Obtains the Extension ability information based on the given want, Extension ability type, Extension ability flags, and user ID. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| want | Want | Yes | Want containing the bundle name to query. | +| extensionAbilityType | [ExtensionAbilityType](#extensionabilitytype) | Yes | Type of the Extension ability. | +| extensionAbilityFlags | [number](#extensionabilityflag) | Yes | Type of the Extension ability information to obtain. | +| userId | number | Yes | User ID. | +| callback | AsyncCallback> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of Extension ability information obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ------------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700003 | The specified extensionAbility is not found. | +| 17700004 | The specified userId is invalid. | +| 17700026 | The specified bundle is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM; +let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; +let userId = 100; +let want = { + bundleName : "com.example.myapplication", + abilityName : "com.example.myapplication.MainAbility" +}; + +try { + bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId, (err, data) => { + if (err) { + console.error('queryExtensionAbilityInfo failed:' + err.message); + } else { + console.info('queryExtensionAbilityInfo successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('queryExtensionAbilityInfo failed:' + err.message); +} +``` + +### bundleManager.queryExtensionAbilityInfo + +queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityType](#extensionabilitytype), extensionAbilityFlags: [number](#extensionabilityflag), callback: AsyncCallback>): void; + +Obtains the Extension ability information based on the given want, Extension ability type, and Extension ability flags. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| want | Want | Yes | Want containing the bundle name to query. | +| extensionAbilityType | [ExtensionAbilityType](#extensionabilitytype) | Yes | Type of the Extension ability. | +| extensionAbilityFlags | [number](#extensionabilityflag) | Yes | Type of the Extension ability information to obtain. | +| callback | AsyncCallback> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of Extension ability information obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700003 | The specified extensionAbility is not found. | +| 17700004 | The specified userId is invalid. | +| 17700026 | The specified bundle is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM; +let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; +let want = { + bundleName : "com.example.myapplication", + abilityName : "com.example.myapplication.MainAbility" +}; + +try { + bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, (err, data) => { + if (err) { + console.error('queryExtensionAbilityInfo failed:' + err.message); + } else { + console.info('queryExtensionAbilityInfo successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('queryExtensionAbilityInfo failed:' + err.message); +} +``` + +### bundleManager.queryExtensionAbilityInfo + +queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityType](#extensionabilitytype), extensionAbilityFlags: [number](#extensionabilityflag), userId?: number): Promise>; + +Obtains the Extension ability information based on the given want, Extension ability type, Extension ability flags, and user ID. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------------------- | --------------------------------------------- | ---- | ------------------------------------------------------- | +| want | Want | Yes | Want containing the bundle name to query. | +| extensionAbilityType | [ExtensionAbilityType](#extensionabilitytype) | Yes | Type of the Extension ability. | +| extensionAbilityFlags | [number](#extensionabilityflag) | Yes | Type of the Extension ability information to obtain.| +| userId | number | No | User ID. | + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | --------------------------------------------- | +| Promise> | Promise used to return the array of Extension ability information obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | --------------------------------------| +| 17700001 | The specified bundleName is not found. | +| 17700003 | The specified extensionAbility is not found. | +| 17700004 | The specified userId is invalid. | +| 17700026 | The specified bundle is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' + +let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM; +let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; +let userId = 100; +let want = { + bundleName : "com.example.myapplication", + abilityName : "com.example.myapplication.MainAbility" +}; + +try { + bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId).then((data) => { + console.info('queryExtensionAbilityInfo successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('queryExtensionAbilityInfo failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('queryExtensionAbilityInfo failed. Cause: ' + error.message); +} +``` + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let extensionAbilityType = bundleManager.ExtensionAbilityType.FORM; +let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_DEFAULT; +let want = { + bundleName : "com.example.myapplication", + abilityName : "com.example.myapplication.MainAbility" +}; + +try { + bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags).then((data) => { + console.info('queryExtensionAbilityInfo successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('queryExtensionAbilityInfo failed. Cause: ' + error.message); + }) +} catch (error) { + console.error('queryExtensionAbilityInfo failed. Cause: ' + error.message); +} +``` + +### bundleManager.getBundleNameByUid + +getBundleNameByUid(uid: number, callback: AsyncCallback\): void; + +Obtains the bundle name based on the given UID. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| uid | number | Yes | UID of the application. | +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the bundle name obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | --------------------- | +| 17700021 | The uid is not found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let uid = 20010005; +try { + bundleManager.getBundleNameByUid(uid, (err, data) => { + if (err) { + console.error('getBundleNameByUid failed:' + err.message); + } else { + console.info('getBundleNameByUid successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('getBundleNameByUid failed:' + err.message); +} +``` + +### bundleManager.getBundleNameByUid + +getBundleNameByUid(uid: number): Promise\; + +Obtains the bundle name based on the given UID. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ---- | ------ | ---- | ------------------ | +| uid | number | Yes | UID of the application.| + +**Return value** + +| Type | Description | +| ---------------- | --------------------------- | +| Promise\ | Promise used to return the bundle name obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ---------------------| +| 17700021 | The uid is not found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let uid = 20010005; +try { + bundleManager.getBundleNameByUid(uid).then((data) => { + console.info('getBundleNameByUid successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('getBundleNameByUid failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getBundleNameByUid failed. Cause: ' + error.message); +} +``` + +### bundleManager.getBundleArchiveInfo + +getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag), callback: AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>): void; + +Obtains the bundle information based on the given HAP file path and bundle flags. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | ----------------------------------------------------------- | +| hapFilePath | string | Yes | Path where the HAP file is stored. The path must be the relative path of the current bundle's data directory.| +| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain. | +| callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Yes| Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the bundle information obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | --------------------------- | +| 17700022 | The hapFilePath is invalid. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let hapFilePath = "/data/xxx/test.hap"; +let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; + +try { + bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => { + if (err) { + console.error('getBundleArchiveInfo failed:' + err.message); + } else { + console.info('getBundleArchiveInfo successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('getBundleArchiveInfo failed:' + err.message); +} +``` + +### bundleManager.getBundleArchiveInfo + +getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)>; + +Obtains the bundle information based on the given HAP file path and bundle flags. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | ------------------------------------------------------------ | +| hapFilePath | string | Yes | Path where the HAP file is stored. The path must be the relative path of the current bundle's data directory.| +| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain. | + +**Return value** + +| Type | Description | +| ----------------------------------------------------------- | --------------------------- | +| Promise\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | Promise used to return the bundle information obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | -------------------------- | +| 17700022 | The hapFilePath is invalid. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let hapFilePath = "/data/xxx/test.hap"; +let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; + +try { + bundleManager.getBundleArchiveInfo(hapFilePath, bundleFlags).then((data) => { + console.info('getBundleArchiveInfo successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('getBundleArchiveInfo failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getBundleArchiveInfo failed. Cause: ' + error.message); +} +``` + +### bundleManager.cleanBundleCacheFiles + +cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback\): void; + +Clears cache files of a bundle. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.REMOVE_CACHE_FILES + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | -------------------- | ---- | ------------------------------------------------------------ | +| bundleName | string | Yes | Bundle name. | +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ------------------------------------------------------------ | +| 17700001 | The specified bundleName is not found. | +| 17700030 | The specified bundle does not support clearing of cache files. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = "com.ohos.myapplication"; + +try { + bundleManager.cleanBundleCacheFiles(bundleName, err => { + if (err) { + console.error('cleanBundleCacheFiles failed:' + err.message); + } else { + console.info('cleanBundleCacheFiles successfully.'); + } + }); +} catch (err) { + console.error('cleanBundleCacheFiles failed:' + err.message); +} +``` + +### bundleManager.cleanBundleCacheFiles + +cleanBundleCacheFiles(bundleName: string): Promise\; + +Clears cache files of a bundle. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.REMOVE_CACHE_FILES + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | ------------------------------------------ | +| bundleName | string | Yes | Bundle name.| + +**Return value** + +| Type | Description | +| -------------- | ------------------------------------------------------------ | +| Promise\ | Promise used to return the result. If the operation is successful, no value is returned. Otherwise, an error message is returned.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ---------------------------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700030 | The specified bundle does not support cleaning cache files. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = "com.ohos.myapplication"; + +try { + bundleManager.cleanBundleCacheFiles(bundleName).then(()=> { + console.info('cleanBundleCacheFiles successfully.'); + }).catch(err=> { + console.error('cleanBundleCacheFiles failed:' + err.message); + }); +} catch (err) { + console.error('cleanBundleCacheFiles failed:' + err.message); +} +``` + +### bundleManager.setApplicationEnabled + +setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCallback\): void; + +Enables or disables an application. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------- | ---- | ------------------------------------- | +| bundleName | string | Yes | Bundle name. | +| isEnabled | boolean | Yes | Whether to enable the application. The value **true** means to enable the application, and **false** means to disable the application.| +| callback | AsyncCallback\ | Yes| Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = "com.ohos.myapplication"; + +try { + bundleManager.setApplicationEnabled(bundleName, false, err => { + if (err) { + console.error('setApplicationEnabled failed:' + err.message); + } else { + console.info('setApplicationEnabled successfully.'); + } + }); +} catch (err) { + console.error('setApplicationEnabled failed:' + err.message); +} +``` + +### bundleManager.setApplicationEnabled + +setApplicationEnabled(bundleName: string, isEnabled: boolean): Promise\; + +Enables or disables an application. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------- | ---- | ------------------------------------- | +| bundleName | string | Yes | Bundle name. | +| isEnabled | boolean | Yes | Whether to enable the application. The value **true** means to enable the application, and **false** means to disable the application.| + +**Return value** + +| Type | Description | +| -------------- | ------------------------------------ | +| Promise\ | Promise that returns no value.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = "com.ohos.myapplication"; + +try { + bundleManager.setApplicationEnabled(bundleName, false).then(()=> { + console.info('setApplicationEnabled successfully.'); + }).catch(err=> { + console.error('setApplicationEnabled failed:' + err.message); + }); +} catch (err) { + console.error('setApplicationEnabled failed:' + err.message); +} +``` + +### bundleManager.setAbilityEnabled + +setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isEnabled: boolean, callback: AsyncCallback\): void; + +Enables or disables an ability. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------- | ---- | ------------------------------------- | +| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes | Information about the target ability. | +| isEnabled| boolean | Yes | Whether to enable the ability. The value **true** means to enable the ability, and **false** means to disable the ability.| +| callback | AsyncCallback\ | Yes| Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ---------------------------------------| +| 17700001 | The specified bundleName is not found. | +| 17700003 | The specified abilityInfo is not found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; +let userId = 100; +let want = { + bundleName : "com.example.myapplication", + abilityName : "com.example.myapplication.MainAbility" +}; +var info; + +try { + bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => { + console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(abilitiesInfo)); + info = abilitiesInfo[0]; + + bundleManager.setAbilityEnabled(info, false, err => { + if (err) { + console.error('setAbilityEnabled failed:' + err.message); + } else { + console.info('setAbilityEnabled successfully.'); + } + }); + }).catch(error => { + console.error('queryAbilityInfo failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('queryAbilityInfo failed. Cause: ' + error.message); +} +``` + +### bundleManager.setAbilityEnabled + +setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isEnabled: boolean): Promise\; + +Enables or disables an ability. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.CHANGE_ABILITY_ENABLED_STATE + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------- | ---- | ------------------------------------- | +| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes | Information about the target ability. | +| isEnabled| boolean | Yes | Whether to enable the ability. The value **true** means to enable the ability, and **false** means to disable the ability.| + +**Return value** + +| Type | Description | +| -------------- | --------------------------------- | +| Promise\ | Promise that returns no value.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700003 | The specified abilityInfo is not found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; +let userId = 100; +let want = { + bundleName : "com.example.myapplication", + abilityName : "com.example.myapplication.MainAbility" +}; +var info; + +try { + bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => { + console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(abilitiesInfo)); + info = abilitiesInfo[0]; + + bundleManager.setAbilityEnabled(info, false).then(()=> { + console.info('setAbilityEnabled successfully.'); + }).catch(err=> { + console.error('setAbilityEnabled failed:' + err.message); + }); + }).catch(error => { + console.error('queryAbilityInfo failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('queryAbilityInfo failed. Cause: ' + error.message); +} +``` + +### bundleManager.isApplicationEnabled + +isApplicationEnabled(bundleName: string, callback: AsyncCallback\): void; + +Checks whether an application is enabled. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | -------------------------- | +| bundleName | string | Yes | Bundle name.| +| callback | AsyncCallback\ | Yes| Callback used to return the result. The value **true** means that the application is enabled, and **false** means the opposite.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; + +try { + bundleManager.isApplicationEnabled(bundleName, (err, data) => { + if (err) { + console.error('isApplicationEnabled failed:' + err.message); + } else { + console.info('isApplicationEnabled successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('isApplicationEnabled failed:' + err.message); +} +``` + +### bundleManager.isApplicationEnabled + +isApplicationEnabled(bundleName: string): Promise\; + +Checks whether an application is enabled. This API uses a promise to return the result. + +**System API**: This is a system API. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | -------------------------- | +| bundleName | string | Yes | Bundle name. | + +**Return value** + +| Type | Description | +| ----------------- | ------------------------------------------------------------ | +| Promise\ | Promise used to return the result. The value **true** means that the application is enabled, and **false** means the opposite.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; + +try { + bundleManager.isApplicationEnabled(bundleName).then((data) => { + console.info('isApplicationEnabled successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('isApplicationEnabled failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('isApplicationEnabled failed. Cause: ' + error.message); +} +``` + +### bundleManager.isAbilityEnabled + +isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), callback: AsyncCallback\): void; + +Checks whether an ability is enabled. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ---- | ----------- | ---- | --------------------------- | +| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes | Information about the target ability.| +| callback | AsyncCallback\ | Yes| Callback used to return the result. The value **true** means that the ability is enabled, and **false** means the opposite.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | --------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700003 | The specified abilityName is not found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; +let userId = 100; +let want = { + bundleName : "com.example.myapplication", + abilityName : "com.example.myapplication.MainAbility" +}; +var info; + +try { + bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => { + console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(abilitiesInfo)); + info = abilitiesInfo[0]; + + bundleManager.isAbilityEnabled(info, (err, data) => { + if (err) { + console.error('isAbilityEnabled failed:' + err.message); + } else { + console.info('isAbilityEnabled successfully:' + JSON.stringify(data)); + } + }); + }).catch(error => { + console.error('queryAbilityInfo failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('queryAbilityInfo failed. Cause: ' + error.message); +} +``` + +### bundleManager.isAbilityEnabled + +isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md)): Promise\; + +Checks whether an ability is enabled. This API uses a promise to return the result. + +**System API**: This is a system API. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ---- | ----------- | ---- | --------------------------- | +| info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes | Information about the target ability.| + +**Return value** + +| Type | Description | +| ----------------- | ------------------------------------------------------------ | +| Promise\ | Promise used to return the result. The value **true** means that the ability is enabled, and **false** means the opposite.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | --------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700003 | The specified abilityName is not found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let abilityFlags = bundleManager.AbilityFlag.GET_ABILITY_INFO_DEFAULT; +let userId = 100; +let want = { + bundleName : "com.example.myapplication", + abilityName : "com.example.myapplication.MainAbility" +}; +var info; + +try { + bundleManager.queryAbilityInfo(want, abilityFlags, userId).then((abilitiesInfo) => { + console.info('queryAbilityInfo successfully. Data: ' + JSON.stringify(abilitiesInfo)); + info = abilitiesInfo[0]; + + bundleManager.isAbilityEnabled(info).then((data) => { + console.info('isAbilityEnabled successfully. Data: ' + JSON.stringify(data)); + }).catch(err => { + console.error('isAbilityEnabled failed. Cause: ' + err.message); + }); + }).catch(error => { + console.error('queryAbilityInfo failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('queryAbilityInfo failed. Cause: ' + error.message); +} +``` + +### bundleManager.getLaunchWantForBundle + +getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallback\): void; + +Obtains the want used to launch the bundle based on the given bundle name and user ID. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | -------------------- | ---- | ------------------------------------------------------------ | +| bundleName | string | Yes | Bundle name. | +| userId | number | Yes | User ID. | +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the **Want** object obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | --------------------------------------| +| 17700001 | The specified bundleName is not found. | +| 17700004 | The specified user ID is not found | +| 17700026 | The specified bundle is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; +let userId = 100; + +try { + bundleManager.getLaunchWantForBundle(bundleName, userId, (err, data) => { + if (err) { + console.error('getLaunchWantForBundle failed:' + err.message); + } else { + console.info('getLaunchWantForBundle successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('getLaunchWantForBundle failed:' + err.message); +} +``` + +### bundleManager.getLaunchWantForBundle + +getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\): void; + +Obtains the want used to launch the bundle based on the given bundle name. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | -------------------- | ---- | ------------------------------------------------------------ | +| bundleName | string | Yes | Bundle name. | +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the **Want** object obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | --------------------------------------| +| 17700001 | The specified bundleName is not found. | +| 17700004 | The specified user ID is not found | +| 17700026 | The specified bundle is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; + +try { + bundleManager.getLaunchWantForBundle(bundleName, (err, data) => { + if (err) { + console.error('getLaunchWantForBundle failed:' + err.message); + } else { + console.info('getLaunchWantForBundle successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('getLaunchWantForBundle failed:' + err.message); +} +``` + +### bundleManager.getLaunchWantForBundle + +getLaunchWantForBundle(bundleName: string, userId?: number): Promise\; + +Obtains the want used to launch the bundle based on the given bundle name and user ID. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | ------------------------- | +| bundleName | string | Yes | Bundle name.| +| userId | number | No | User ID. | + +**Return value** + +| Type | Description | +| -------------- | ------------------------- | +| Promise\ | Promise used to return the **Want** object obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | --------------------------------------| +| 17700001 | The specified bundleName is not found. | +| 17700004 | The specified user ID is not found. | +| 17700026 | The specified bundle is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; +let userId = 100; + +try { + bundleManager.getLaunchWantForBundle(bundleName, userId).then((data) => { + console.info('getLaunchWantForBundle successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('getLaunchWantForBundle failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getLaunchWantForBundle failed. Cause: ' + error.message); +} +``` + +### bundleManager.getProfileByAbility + +getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback>): void; + +Obtains the JSON strings of the configuration file based on the given module ame, ability name, and metadata name. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ | +| moduleName | string | Yes | Module name. | +| abilityName | string | Yes | Ability name. | +| metadataName | string | Yes | Metadata name. | +| callback | AsyncCallback> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of JSON strings obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ------------------------------------------------------------ | +| 17700002 | The specified moduleName is not existed. | +| 17700003 | The specified abilityName is not existed. | +| 17700024 | Failed to get the profile because there is no profile in the HAP. | +| 17700026 | The specified bundle is disabled. | +| 17700029 | The specified ability is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let moduleName = 'entry'; +let abilityName = 'MainAbility'; +let metadataName = 'com.example.myapplication.metadata'; + +try { + bundleManager.getProfileByAbility(moduleName, abilityName, metadataName, (err, data) => { + if (err) { + console.error('getProfileByAbility failed:' + err.message); + } else { + console.info('getProfileByAbility successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('getProfileByAbility failed:' + err.message); +} +``` + +### bundleManager.getProfileByAbility + +getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise>; + +Obtains the JSON strings of the configuration file based on the given module ame, ability name, and metadata name. This API uses a promise to return the result. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | ------ | ---- | -------------------------- | +| moduleName | string | Yes | Module name. | +| abilityName | string | Yes | Ability name. | +| metadataName | string | No | Metadata name.| + +**Return value** + +| Type | Description | +| ----------------------- | ------------------------------- | +| Promise> | Promise used to return the array of JSON strings obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ------------------------------------------------------------ | +| 17700002 | The specified moduleName is not existed. | +| 17700003 | The specified abilityName is not existed. | +| 17700024 | Failed to get the profile because there is no profile in the HAP. | +| 17700026 | The specified bundle is disabled. | +| 17700029 | The specified ability is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let moduleName = 'entry'; +let abilityName = 'MainAbility'; + +try { + bundleManager.getProfileByAbility(moduleName, abilityName).then((data) => { + console.info('getProfileByAbility successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('getProfileByAbility failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getProfileByAbility failed. Cause: ' + error.message); +} +``` + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let moduleName = 'entry'; +let abilityName = 'MainAbility'; +let metadataName = 'com.example.myapplication.metadata'; +try { + bundleManager.getProfileByAbility(moduleName, abilityName, metadataName).then((data) => { + console.info('getProfileByAbility successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('getProfileByAbility failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getProfileByAbility failed. Cause: ' + error.message); +} +``` + +### bundleManager.getProfileByExtensionAbility + +getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback>): void; + +Obtains the JSON strings of the configuration file based on the given module ame, Extension ability name, and metadata name. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------------- | ----------------------------- | ---- | ------------------------------------------------------------ | +| moduleName | string | Yes | Module name. | +| extensionAbilityName | string | Yes | Extension ability name. | +| metadataName | string | Yes | Metadata name. | +| callback | AsyncCallback> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of JSON strings obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ------------------------------------------------------------ | +| 17700002 | The specified moduleName is not existed. | +| 17700003 | The specified extensionAbilityName is not existed. | +| 17700024 | Failed to get the profile because there is no profile in the HAP. | +| 17700026 | The specified bundle is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let moduleName = 'entry'; +let extensionAbilityName = 'com.example.myapplication.extension'; +let metadataName = 'com.example.myapplication.metadata'; + +try { + bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName, (err, data) => { + if (err) { + console.error('getProfileByExtensionAbility failed:' + err.message); + } else { + console.info('getProfileByExtensionAbility successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('getProfileByExtensionAbility failed:' + err.message); +} +``` + +### bundleManager.getProfileByExtensionAbility + +getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise>; + +Obtains the JSON strings of the configuration file based on the given module ame, Extension ability name, and metadata name. This API uses a promise to return the result. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------------- | ------ | ---- | ---------------------------------- | +| moduleName | string | Yes | Module name. | +| extensionAbilityName | string | Yes | Extension ability name.| +| metadataName | string | No | Metadata name. | + +**Return value** + +| Type | Description | +| ----------------------- | ----------------------------------- | +| Promise> | Promise used to return the array of JSON strings obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ------------------------------------------------------------ | +| 17700002 | The specified moduleName is not existed. | +| 17700003 | The specified extensionAbilityName is not existed. | +| 17700024 | Failed to get the profile because there is no profile in the HAP. | +| 17700026 | The specified bundle is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let moduleName = 'entry'; +let extensionAbilityName = 'com.example.myapplication.extension'; +let metadataName = 'com.example.myapplication.metadata'; + +try { + bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName).then((data) => { + console.info('getProfileByExtensionAbility successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('getProfileByExtensionAbility failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getProfileByExtensionAbility failed. Cause: ' + error.message); +} + +try { + bundleManager.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName).then((data) => { + console.info('getProfileByExtensionAbility successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('getProfileByExtensionAbility failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getProfileByExtensionAbility failed. Cause: ' + error.message); +} +``` + +### bundleManager.getPermissionDef + +getPermissionDef(permissionName: string, callback: AsyncCallback\<[PermissionDef](js-apis-bundleManager-permissionDef.md)>): void; + +Obtains the details of a permission. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| permissionName | string | Yes | Name of the permission. | +| callback | AsyncCallback\<[PermissionDef](js-apis-bundleManager-permissionDef.md)> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of **PermissionDef** objects obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ------------------------------------- | +| 17700006 | The specified permission is not found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let permission = "ohos.permission.GET_BUNDLE_INFO"; +try { + bundleManager.getPermissionDef(permission, (err, data) => { + if (err) { + console.error('getPermissionDef failed:' + err.message); + } else { + console.info('getPermissionDef successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('getPermissionDef failed:' + err.message); +} +``` + +### bundleManager.getPermissionDef + +getPermissionDef(permissionName: string): Promise\<[PermissionDef](js-apis-bundleManager-permissionDef.md)>; + +Obtains the details of a permission. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------- | ------ | ---- | -------------- | +| permissionName | string | Yes | Name of the permission.| + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | ------------------------------------------ | +| Promise\<[PermissionDef](js-apis-bundleManager-permissionDef.md)> | Promise used to return the array of **PermissionDef** objects obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ------------------------------------- | +| 17700006 | The specified permission is not found. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let permissionName = "ohos.permission.GET_BUNDLE_INFO"; +try { + bundleManager.getPermissionDef(permissionName).then((data) => { + console.info('getPermissionDef successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('getPermissionDef failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getPermissionDef failed. Cause: ' + error.message); +} +``` + +### bundleManager.getAbilityLabel + +getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback\): void; + +Obtains the ability label based on the given bundle name, module name, and ability name. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Resource + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ---------------------- | ---- | ------------------------------------------------------------ | +| bundleName | string | Yes | Bundle name. | +| moduleName | string | Yes | Module name. | +| abilityName | string | Yes | Ability name. | +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the label obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700002 | The specified moduleName is not found. | +| 17700003 | The specified abilityName is not found. | +| 17700026 | The specified bundle is disabled. | +| 17700029 | The specified ability is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; +let moduleName = 'entry'; +let abilityName = 'MainAbility'; + +try { + bundleManager.getAbilityLabel(bundleName, moduleName, abilityName, (err, data) => { + if (err) { + console.error('getAbilityLabel failed:' + err.message); + } else { + console.info('getAbilityLabel successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('getAbilityLabel failed:' + err.message); +} +``` + +### bundleManager.getAbilityLabel + +getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Promise\; + +Obtains the ability label based on the given bundle name, module name, and ability name. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Resource + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | ------------------------- | +| bundleName | string | Yes | Bundle name. | +| moduleName | string | Yes | Module name. | +| abilityName | string | Yes | Ability name.| + +**Return value** + +| Type | Description | +| ---------------- | ----------------------------------- | +| Promise\ | Promise used to return the label.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | --------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700002 | The specified moduleName is not found. | +| 17700003 | The specified abilityName is not found. | +| 17700026 | The specified bundle is disabled. | +| 17700029 | The specified ability is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; +let moduleName = 'entry'; +let abilityName = 'MainAbility'; + +try { + bundleManager.getAbilityLabel(bundleName, moduleName, abilityName).then((data) => { + console.info('getAbilityLabel successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('getAbilityLabel failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getAbilityLabel failed. Cause: ' + error.message); +} +``` + +### bundleManager.getAbilityIcon + +getAbilityIcon(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)>): void; + +Obtains the ability icon based on the given bundle name, module name, and ability name. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Resource + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| bundleName | string | Yes | Bundle name. | +| moduleName | string | Yes | Module name. | +| abilityName | string | Yes | Ability name. | +| callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the **PixelMap** object of the icon. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700002 | The specified moduleName is not found. | +| 17700003 | The specified abilityName is not found. | +| 17700026 | The specified bundle is disabled. | +| 17700029 | The specified ability is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; +let moduleName = 'entry'; +let abilityName = 'MainAbility'; + +try { + bundleManager.getAbilityIcon(bundleName, moduleName, abilityName, (err, data) => { + if (err) { + console.error('getAbilityIcon failed:' + err.message); + } else { + console.info('getAbilityIcon successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('getAbilityIcon failed:' + err.message); +} +``` + +### bundleManager.getAbilityIcon + +getAbilityIcon(bundleName: string, moduleName: string, abilityName: string): Promise<[image.PixelMap](js-apis-image.md#pixelmap7)>; + +Obtains the ability icon based on the given bundle name, module name, and ability name. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Resource + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | ------------------------- | +| bundleName | string | Yes | Bundle name. | +| moduleName | string | Yes | Module name. | +| abilityName | string | Yes | Ability name.| + +**Return value** + +| Type | Description | +| ----------------------------------------------------- | ------------------------------------------- | +| Promise<[image.PixelMap](js-apis-image.md#pixelmap7)> | Promise used to return the **PixelMap** object of the icon.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700002 | The specified moduleName is not found. | +| 17700003 | The specified abilityName is not found. | +| 17700026 | The specified bundle is disabled. | +| 17700029 | The specified ability is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; +let moduleName = 'entry'; +let abilityName = 'MainAbility'; + +try { + bundleManager.getAbilityIcon(bundleName, moduleName, abilityName).then((data) => { + console.info('getAbilityIcon successfully. Data: ' + JSON.stringify(data)); + }).catch(error => { + console.error('getAbilityIcon failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getAbilityIcon failed. Cause: ' + error.message); +} +``` + +### bundleManager.getApplicationInfoSync + +getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md); + +Synchronously obtains the application information based on the given bundle name, application flags, and user ID. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | ----------------------------------------------------------| +| bundleName | string | Yes | Bundle name. | +| applicationFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. | +| userId | number | Yes | User ID. | + +**Return value** + +| Type | Description | +| --------------- | ------------------------- | +| [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | Application information obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700004 | The specified userId is not found. | +| 17700026 | The specified bundle is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; +let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; +let userId = 100; + +try { + let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags, userId); + console.info("getApplicationInfoSync successfully:" + JSON.stringify(data)); +} catch (err) { + console.error('getApplicationInfoSync failed:' + err.message); +} +``` + +### bundleManager.getApplicationInfoSync + +getApplicationInfoSync(bundleName: string, applicationFlags: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md); + +Synchronously obtains the application information based on the given bundle name and application flags. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | ----------------------------------------------------------| +| bundleName | string | Yes | Bundle name. | +| applicationFlags | [number](#applicationflag) | Yes | Type of the application information to obtain. | + +**Return value** + +| Type | Description | +| --------------- | ------------------------- | +| [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | Application information obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | -------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700026 | The specified bundle is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; +let applicationFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT; + +try { + let data = bundleManager.getApplicationInfoSync(bundleName, applicationFlags); + console.info("getApplicationInfoSync successfully:" + JSON.stringify(data)); +} catch (err) { + console.error('getApplicationInfoSync failed:' + err.message); +} +``` + +### bundleManager.getBundleInfoSync + +getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId: number): [BundleInfo](js-apis-bundleManager-bundleInfo.md); + +Synchronously obtains the bundle information based on the given bundle name, bundle flags, and user ID. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | -------------------------------------------------------- | +| bundleName | string | Yes | Bundle name. | +| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain.| +| userId | number | Yes | User ID. | + +**Return value** + +| Type | Description | +| ---------- | -------------------- | +| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700004 | The specified user ID is not found. | +| 17700026 | The specified bundle is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; +let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION; +let userId = 100; + +try { + let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags, userId); + console.info("getBundleInfoSync successfully :" + JSON.stringify(data)); +} catch (err) { + console.error('getBundleInfoSync failed:' + err.message); +} +``` + +### bundleManager.getBundleInfoSync + +getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag)): [BundleInfo](js-apis-bundleManager-bundleInfo.md); + +Synchronously obtains the bundle information based on the given bundle name and bundle flags. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------ | ---- | -------------------------------------------------------- | +| bundleName | string | Yes | Bundle name. | +| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain.| + +**Return value** + +| Type | Description | +| ---------- | -------------------- | +| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ------------------------------------- | +| 17700001 | The specified bundleName is not found. | +| 17700004 | The specified user ID is not found. | +| 17700026 | The specified bundle is disabled. | + +**Example** + +```ts +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; +let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION; +try { + let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags); + console.info("getBundleInfoSync successfully :" + JSON.stringify(data)); +} catch (err) { + console.error('getBundleInfoSync failed:' + err.message); +} +``` diff --git a/en/application-dev/reference/apis/js-apis-bundleMonitor.md b/en/application-dev/reference/apis/js-apis-bundleMonitor.md new file mode 100644 index 0000000000..ceef9d8521 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundleMonitor.md @@ -0,0 +1,104 @@ +# Bundle.bundleMonitor + +The **Bundle.bundleMonitor** module provides APIs for listens for bundle installation, uninstall, and updates. + +> **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 bundleMonitor from '@ohos.bundle.bundleMonitor'; +``` + +## Required Permissions + +| Permission | Permission Level | Description | +| ------------------------------------ | ----------- | ------------------------------ | +| ohos.permission.LISTEN_BUNDLE_CHANGE | system_core | Permission to listen for bundle installation, uninstall, and updates.| + +For details, see [Permission Levels](../../security/accesstoken-overview.md#permission-levels). + +## BundleChangeInfo + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +| Name | Template | Readable| Writable| Description | +| ---------- | ------ | ---- | ---- | -------------------------- | +| bundleName | string | Yes | No | Name of the bundle whose status changes.| +| userId | number | Yes | No | ID of the user whose bundle status changes. | + +## bundleMonitor.on + +on(type: BundleChangedEvent, callback: Callback\): void; + +Subscribes to bundle installation, uninstall, and update events. + +**Required permissions**: ohos.permission.LISTEN_BUNDLE_CHANGE + +**System API**: This is a system API and cannot be called by third-party applications. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------------------------- | -------- | ---- | ------------------ | +| BundleChangedEvent | string | Yes | Type of the event to subscribe to.| +| Callback\ | callback | Yes | Callback used for the subscription.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +**Example** + +```ts +import bundleMonitor from '@ohos.bundle.bundleMonitor'; + +try { + bundleMonitor.on('add', (bundleChangeInfo) => { + console.info(`bundleName : ${bundleChangeInfo.bundleName} userId : ${bundleChangeInfo.userId}`); + }) +} catch (errData) { + console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); +} +``` + +## bundleMonitor.off + +off(type: BundleChangedEvent, callback?: Callback\): void; + +Unsubscribes from bundle installation, uninstall, and update events. + +**Required permissions**: ohos.permission.LISTEN_BUNDLE_CHANGE + +**System API**: This is a system API and cannot be called by third-party applications. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------------------------- | -------- | ---- | ---------------------------------------------------------- | +| BundleChangedEvent | string | Yes | Type of the event to unsubscribe from. | +| Callback\ | callback | Yes | Callback used for the unsubscription. If this parameter is left empty, all callbacks of the current event are unsubscribed from.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +**Example** + +```ts +import bundleMonitor from '@ohos.bundle.bundleMonitor'; + +try { + bundleMonitor.off('add'); +} catch (errData) { + console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); +} +``` diff --git a/en/application-dev/reference/apis/js-apis-cert.md b/en/application-dev/reference/apis/js-apis-cert.md deleted file mode 100644 index f6da43b47b..0000000000 --- a/en/application-dev/reference/apis/js-apis-cert.md +++ /dev/null @@ -1,2419 +0,0 @@ -# Certificate - -The **certificate** module provides APIs for performing certificate operations. The APIs of this module depend on the basic algorithm capabilities provided by the cryptography framework. For details about the cryptography framework APIs, see [Cryptography Framework](./js-apis-cryptoFramework.md). - -> **NOTE** -> -> The initial APIs of this module are supported since API version 9. - -## Modules to Import - -```javascript -import cryptoCert from '@ohos.security.cert'; -import cryptoFramework from "@ohos.security.cryptoFramework" -``` - -## CertResult - - Enumerates the error codes. - - **System capability**: SystemCapability.Security.Cert - -| Name | Default Value | Description | -| --------------------------------------| -------- | -----------------------------| -| INVALID_PARAMS | 401 | Invalid parameters. | -| NOT_SUPPORT | 801 | This operation is not supported. | -| ERR_OUT_OF_MEMORY | 19020001 | Memory error. | -| ERR_RUNTIME_ERROR | 19020002 | Runtime error. | -| ERR_CRYPTO_OPERATION | 19030001 | Crypto operation error. | -| ERR_CERT_SIGNATURE_FAILURE | 19030002 | The certificate signature verification failed. | -| ERR_CERT_NOT_YET_VALID | 19030003 | The certificate has not taken effect. | -| ERR_CERT_HAS_EXPIRED | 19030004 | The certificate has expired. | -| ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY | 19030005 | Failed to obtain the certificate issuer. | -| ERR_KEYUSAGE_NO_CERTSIGN | 19030006 | The key cannot be used for signing a certificate. | -| ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE | 19030007 | The key cannot be used for digital signature. | - -## DataBlob -Defines a binary data array. - **System capability**: SystemCapability.Security.Cert -| Name | Type | Readable| Writable| Description | -| -------------- | -------------- | ---- | ---- | ----------------| -| data | Uint8Array | Yes | Yes | Data. | - -## DataArray -Defines a list of data arrays. - **System capability**: SystemCapability.Security.Cert -| Name | Type | Readable| Writable| Description | -| -------------- | -------------- | ---- | ---- | ----------------| -| data | Uint8Array | Yes | Yes | Data list. | - -## EncodingFormat - - Enumerates the certificate encoding formats. - - **System capability**: SystemCapability.Security.Cert - -| Name | Default Value | Description | -| ------------| ---------| -----------| -| FORMAT_DER | 0 | Distinguished Encoding Rules (DER) format. | -| FORMAT_PEM | 1 | Privacy-Enhanced Mail (PEM) format. | - - -## EncodingBlob - -Defines a certificate binary array in encoding format. - -### Attributes - -**System capability**: SystemCapability.Security.Cert - -| Name | Type | Readable| Writable| Description | -| -------------- | -------------- | ---- | ---- | ----------------------------------| -| data | Uint8Array | Yes | Yes | Certificate data. | -| encodingFormat | [EncodingFormat](#encodingformat) | Yes | Yes | Certificate encoding format.| - - -## CertChainData - -Defines the certificate chain data, which is passed in as input parameters during certificate chain verification. - -### Attributes - -**System capability**: SystemCapability.Security.Cert - -| Name | Type | Readable| Writable| Description | -| -------------- | -------------- | ---- | ---- | ------------------------------------------------------------ | -| data | Uint8Array | Yes | Yes | Certificate data, in the *length* (2 bytes) + *data* format. For example, **08ABCDEFGH07ABCDEFG**. The first two bytes indicate the length of the first certificate is eight bytes, and the following eight bytes indicate the certificate data. Then, the next two bytes indicates the length of another certificate is seven bytes, and the seven bytes followed indicate the certificate data. | -| count | number | Yes | Yes | Number of certificates contained in the input data. | -| encodingFormat | [EncodingFormat](#encodingformat) | Yes | Yes | Certificate encoding format.| - - -## cryptoCert.createX509Cert - -createX509Cert(inStream : EncodingBlob, callback : AsyncCallback\) : void - -Creates an **X509Cert** instance. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------- | ---- | ------------------ | -| inStream | [EncodingBlob](#encodingblob) | Yes | X.509 certificate serialization data.| -| callback | AsyncCallback\ | No | Callback invoked to return the **X509Cert** instance created. | - - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { - if (error != null) { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Cert success"); - } -}); -``` - -## cryptoCert.createX509Cert - -createX509Cert(inStream : EncodingBlob) : Promise\ - -Creates an **X509Cert** instance. This API uses a promise to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------ | ---- | ------------------ | -| inStream | [EncodingBlob](#encodingblob) | Yes | X.509 certificate serialization data.| - -**Return value** - -| Type | Description | -| :------- | ---------------- | -| Promise\ |Promise used to return the **X509Cer** instance created.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob).then(x509Cert => { - Console.log("createX509Cert success"); -}, error => { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); -}); -``` - -## X509Cert - -Provides APIs for X.509 certificate operations. - -### verify - -verify(key : cryptoFramework.PubKey, callback : AsyncCallback\) : void - -Verifies the certificate signature. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------- | ---- | ------------------ | -| key | cryptoFramework.PubKey | Yes | Public key used for signature verification.| -| callback | AsyncCallback\) | No | Callback invoked to return the result. If **error** is **null**, the signature verification is successful. If **error** is not **null**, the signature verification fails. | - - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; -import cryptoFramework from "@ohos.security.cryptoFramework" - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { - if (error != null) { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Cert success"); - // Generate a public key by AsyKeyGenerator or obtain the public key by using getPublicKey() of the X509Cert instance. - let pubKey = null; - x509Cert.verify(pubKey, function (error, data) { - if (error != null) { - Console.log("verify failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("verify success"); - } - }); - } -}); -``` - -### verify - -verify(key : cryptoFramework.PubKey) : Promise\ - -Verifies the certificate signature. This API uses a promise to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------ | -| key | cryptoFramework.PubKey | Yes | Public key used for signature verification.| - -**Return value** - -| Type| Description | -| ---- | ------------------------------------------------------------ | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob).then(x509Cert => { - Console.log("createX509Cert success"); - // Generate a public key by AsyKeyGenerator or obtain the public key by using getPublicKey() of the X509Cert instance. - let pubKey = null; - x509Cert.verify(pubKey).then(result => { - Console.log("verify success"); - }, error => { - Console.log("verify failed, errCode: " + error.code + ", errMsg: " + error.message); - }); -}, error => { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); -}); -``` - -### getEncoded - -getEncoded(callback : AsyncCallback\) : void - -Obtains the serialized X.509 certificate data. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------- | ---- | -------- | -| callback | AsyncCallback\<[EncodingBlob](#encodingblob)> | No | Callback invoked to return the serialized X.509 certificate data obtained.| - - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { - if (error != null) { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Cert success"); - x509Cert.getEncoded(function (error, data) { - if (error != null) { - Console.log("getEncoded failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("getEncoded success"); - } - }); - } -}); -``` - -### getEncoded - -getEncoded() : Promise\ - -Obtains the serialized X.509 certificate data. This API uses a promise to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------------ | ---------------------- | -| Promise\<[EncodingBlob](#encodingblob)> | Promise used to return the serialized X.509 certificate data obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob).then(x509Cert => { - Console.log("createX509Cert success"); - x509Cert.getEncoded().then(result => { - Console.log("getEncoded success"); - }, error => { - Console.log("getEncoded failed, errCode: " + error.code + ", errMsg: " + error.message); - }); -}, error => { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); -}); -``` - -### getPublicKey - -getPublicKey(callback : AsyncCallback\) : void - -Obtains the public key of this X.509 certificate. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------- | ---- | -------- | -| callback | AsyncCallback | No | Callback invoked to return the public key obtained.| - - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; -import cryptoFramework from "@ohos.security.cryptoFramework" - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { - if (error != null) { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Cert success"); - x509Cert.getPublicKey(function (error, pubKey) { - if (error != null) { - Console.log("getPublicKey failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("getPublicKey success"); - } - }); - } -}); -``` - -### getPublicKey - -getPublicKey() : Promise\ - -Obtains the public key of this X.509 certificate. This API uses a promise to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------ | ---------------- | -| cryptoFramework.PubKey | X.509 certificate public key obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; -import cryptoFramework from "@ohos.security.cryptoFramework" - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob).then(x509Cert => { - Console.log("createX509Cert success"); - x509Cert.getPublicKey().then(pubKey => { - Console.log("getPublicKey success"); - }, error => { - Console.log("getPublicKey failed, errCode: " + error.code + ", errMsg: " + error.message); - }); -}, error => { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); -}); -``` - -### checkValidityWithDate - -checkValidityWithDate(date: string, callback : AsyncCallback\) : void - -Checks the validity period of this X.509 certificate. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------- | ---- | -------- | -| date | string | Yes | Date of the certificate to check. | -| callback | AsyncCallback\ | No | Callback invoked to return the result. If **error** is **null**, the certificate is valid. If **error** is not **null**, the certificate has expired.| - - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { - if (error != null) { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Cert success"); - let date = "150527000001Z"; - x509Cert.checkValidityWithDate(date, function (error, data) { - if (error != null) { - Console.log("checkValidityWithDate failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("checkValidityWithDate success"); - } - }); - } -}); -``` - -### checkValidityWithDate - -checkValidityWithDate(date: string) : Promise\ - -Checks the validity period of this X.509 certificate. This API uses a promise to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name| Type | Mandatory| Description| -| ------ | ------ | ---- | ---- | -| date | string | Yes | Date of the certificate to check.| - -**Return value** - -| Type| Description | -| ---- | ------------------------------------------------------------ | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob).then(x509Cert => { - Console.log("createX509Cert success"); - let date = "150527000001Z"; - x509Cert.checkValidityWithDate(date).then(result => { - Console.log("checkValidityWithDate success"); - }, error => { - Console.log("checkValidityWithDate failed, errCode: " + error.code + ", errMsg: " + error.message); - }); -}, error => { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); -}); -``` - -### getVersion - -getVersion() : number - -Obtains the X.509 certificate version. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------ | ---------------- | -| number | X.509 certificate version obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { - if (error != null) { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Cert success"); - let version = x509Cert.getVersion(); - } -}); -``` - -### getSerialNumber - -getSerialNumber() : number - -Obtains the X.509 certificate serial number. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------ | ------------------ | -| number | X.509 certificate serial number obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { - if (error != null) { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Cert success"); - let serialNumber = x509Cert.getSerialNumber(); - } -}); -``` - -### getIssuerName - -getIssuerName() : DataBlob - -Obtains the X.509 certificate issuer. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| -------- | ---------------------- | -| [DataBlob](#datablob) | X.509 certificate issuer obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { - if (error != null) { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Cert success"); - let issuerName = x509Cert.getIssuerName(); - } -}); -``` - -### getSubjectName - -getSubjectName() : DataBlob - -Obtains the subject of this X.509 certificate. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| -------- | -------------------- | -| [DataBlob](#datablob) | Subject name obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { - if (error != null) { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Cert success"); - let subjectName = x509Cert.getSubjectName(); - } -}); -``` - -### getNotBeforeTime - -getNotBeforeTime() : string - -Obtains the start time of this X.509 certificate. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------ | -------------------------- | -| string | Start time of the X.509 certificate obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { - if (error != null) { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Cert success"); - let notBefore = x509Cert.getNotBeforeTime(); - } -}); -``` - -### getNotAfterTime - -getNotAfterTime() : string - -Obtains the expiration time of this X.509 certificate. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------ | -------------------------- | -| string | Expiration time of the X.509 certificate obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { - if (error != null) { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Cert success"); - let notAfter = x509Cert.getNotAfterTime(); - } -}); -``` - -### getSignature - -getSignature() : DataBlob - -Obtains the signature data of this X.509 certificate. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| -------- | -------------------- | -| [DataBlob](#datablob) | Signature data obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { - if (error != null) { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Cert success"); - let signature = x509Cert.getSignature(); - } -}); -``` - -### getSignatureAlgName - -getSignatureAlgName() : string - -Obtains the signing algorithm of this X.509 certificate. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------ | ------------------------ | -| string | X.509 certificate signing algorithm obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { - if (error != null) { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Cert success"); - let sigAlgName = x509Cert.getSignatureAlgName(); - } -}); -``` - -### getSignatureAlgOid - -getSignatureAlgOid() : string - -Obtains the object identifier (OID) of the X.509 certificate signing algorithm. OIDs are allocated by the International Organization for Standardization (ISO). - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------ | --------------------------------- | -| string | OID obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { - if (error != null) { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Cert success"); - let sigAlgOid = x509Cert.getSignatureAlgOid(); - } -}); -``` - -### getSignatureAlgParams - -getSignatureAlgParams() : DataBlob - -Obtains the signing algorithm parameters of this X.509 certificate. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| -------- | ------------------------ | -| [DataBlob](#datablob) | X.509 certificate signing algorithm parameters obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { - if (error != null) { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Cert success"); - let sigAlgParams = x509Cert.getSignatureAlgParams(); - } -}); -``` - -### getKeyUsage - -getKeyUsage() : DataBlob - -Obtains the key usage of this X.509 certificate. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| -------- | -------------------- | -| [DataBlob](#datablob) | Key usage of the X.509 certificate obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { - if (error != null) { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Cert success"); - let keyUsage = x509Cert.getKeyUsage(); - } -}); -``` - -### getExtKeyUsage - -getExtKeyUsage() : DataArray - -Obtains the usage of the extended key of this X.509 certificate. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| --------- | ------------------------ | -| [DataArray](#dataarray) | Usage of the extended key obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { - if (error != null) { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Cert success"); - let extKeyUsage = x509Cert.getExtKeyUsage(); - } -}); -``` - -### getBasicConstraints - -getBasicConstraints() : number - -Obtains the basic constraints for obtaining this X.509 certificate. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------ | -------------------- | -| number | Basic constraints obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { - if (error != null) { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Cert success"); - let basicConstraints = x509Cert.getBasicConstraints(); - } -}); -``` - -### getSubjectAltNames - -getSubjectAltNames() : DataArray - -Obtains the Subject Alternative Names (SANs) of this X.509 certificate. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| --------- | ------------------------ | -| [DataArray](#dataarray) | SANs obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { - if (error != null) { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Cert success"); - let subjectAltNames = x509Cert.getSubjectAltNames(); - } -}); -``` - -### getIssuerAltNames - -getIssuerAltNames() : DataArray - -Obtains the Issuer Alternative Names (IANs) of this X.509 certificate. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| --------- | -------------------------- | -| [DataArray](#dataarray) | IANs obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Certificate binary data, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { - if (error != null) { - Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Cert success"); - let issuerAltNames = x509Cert.getIssuerAltNames(); - } -}); -``` - -## cryptoCert.createX509Crl - -createX509Crl(inStream : EncodingBlob, callback : AsyncCallback\) : void - -Creates an **X509Crl** instance. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------- | ---- | -------------------------- | -| inStream | [EncodingBlob](#encodingblob) | Yes | Serialized certificate revocation list (CRL) data.| -| callback | AsyncCallback\ | No | Callback invoked to return the **X509Crl** instance created. | - - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { - if (error != null) { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Crl success"); - } -}); -``` - -## cryptoCert.createX509Crl - -createX509Crl(inStream : EncodingBlob) : Promise\ - -Creates an **X509Crl** instance. This API uses a promise to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------ | ---- | -------------------------- | -| inStream | [EncodingBlob](#encodingblob) | Yes | Serialized CRL data.| - -**Return value** - -| Type | Description | -| ------- | -------------------- | -| Promise\ | Promise used to return the **X509Crl** instance created.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob).then(x509Crl => { - Console.log("createX509Crl success"); -}, error => { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); -}); -``` - -## X509Crl - -Provides APIs for X.509 certificate CRL operations. - -### isRevoked - -isRevoked(cert : X509Cert, callback : AsyncCallback\) : void - -Checks whether an X.509 certificate is revoked. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------- | ---- | -------------------- | -| cert | [X509Cert](#x509cert) | Yes | X.509 certificate to check.| -| callback | AsyncCallback\ | No | Callback invoked to return the result. The value **true** indicates that the certificate is revoked, and **false** indicates the opposite. | - - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { - if (error != null) { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Crl success"); - // Create an X509Cert instance. - let x509Cert = null; - x509Crl.isRevoked(x509Cert, function (error, isRevoked) { - if (error != null) { - Console.log("call isRevoked failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("call isRevoked success"); - } - }); - } -}); -``` - -### isRevoked - -isRevoked(cert : X509Cert) : Promise\ - -Checks whether an X.509 certificate is revoked. This API uses a promise to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | -------- | ---- | -------------------- | -| cert | X509Cert | Yes | X.509 certificate to check.| - -**Return value** - -| Type | Description | -| ------- | ------------------------------------------------- | -| Promise\ | Promise used to return the result. The value **true** indicates the certificate is revoked; the value **false** indicates the opposite.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob).then(x509Crl => { - Console.log("createX509Crl success"); - // Create an X509Cert instance. - let x509Cert = null; - x509Crl.isRevoked(x509Cert).then(isRevoked => { - Console.log("call isRevoked success"); - }, error => { - Console.log("call isRevoked failed, errCode: " + error.code + ", errMsg: " + error.message); - }); -}, error => { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); -}); -``` - -### getType - -getType() : string - -Obtains the CRL type. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------ | -------------------- | -| string | CRL type obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { - if (error != null) { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Crl success"); - let type = x509Crl.getType(); - } -}); -``` - -### getEncoded - -getEncoded(callback : AsyncCallback\) : void - -Obtains the serialized X.509 CRL data. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------- | ---- | -------- | -| callback | AsyncCallback\ | No | Callback invoked to return the serialized X.509 CRL data obtained.| - - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { - if (error != null) { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Crl success"); - x509Crl.getEncoded(function (error, data) { - if (error != null) { - Console.log("getEncoded failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("getEncoded success"); - } - }); - } -}); -``` - -### getEncoded - -getEncoded() : Promise\ - -Obtains the serialized X.509 CRL data. This API uses a promise to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------------ | -------------------------------- | -| Promise\ | Promise used to return the serialized X.509 CRL data obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob).then(x509Crl => { - Console.log("createX509Crl success"); - x509Crl.getEncoded().then(result => { - Console.log("getEncoded success"); - }, error => { - Console.log("getEncoded failed, errCode: " + error.code + ", errMsg: " + error.message); - }); -}, error => { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); -}); -``` - -### verify - -verify(key : cryptoFramework.PubKey, callback : AsyncCallback\) : void - -Verifies the signature of the X.509 CRL. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------- | ---- | ---------------------- | -| key | cryptoFramework.PubKey | Yes | Public key used for signature verification.| -| callback | AsyncCallback\ | No | Callback invoked to return the result. If **error** is **null**, the signature verification is successful. If **error** is not **null**, the signature verification fails. | - - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; -import cryptoFramework from "@ohos.security.cryptoFramework" - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { - if (error != null) { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Crl success"); - // Generate the public key by AsyKeyGenerator. - let pubKey = null; - x509Crl.verify(pubKey, function (error, data) { - if (error != null) { - Console.log("verify failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("verify success"); - } - }); - } -}); -``` - -### verify - -verify(key : cryptoFramework.PubKey) : Promise\ - -Verifies the signature of the X.509 CRL. This API uses a promise to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ---------------------- | -| key | cryptoFramework.PubKey | Yes | Public key used for signature verification.| - -**Return value** - -| Type| Description | -| ---- | ------------------------------------------------------------ | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; -import cryptoFramework from "@ohos.security.cryptoFramework" - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob).then(x509Crl => { - Console.log("createX509Crl success"); - // Generate the public key by AsyKeyGenerator. - let pubKey = null; - x509Crl.verify(pubKey).then(result => { - Console.log("verify success"); - }, error => { - Console.log("verify failed, errCode: " + error.code + ", errMsg: " + error.message); - }); -}, error => { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); -}); -``` - -### getVersion - -getVersion() : number - -Obtains the version of the X.509 CRL. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------ | -------------------------------- | -| number | Version of the X.509 CRL obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { - if (error != null) { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Crl success"); - let version = x509Crl.getVersion(); - } -}); -``` - -### getIssuerName - -getIssuerName() : DataBlob - -Obtains the issuer of the X.509 CRL. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| -------- | ------------------------------ | -| [DataBlob](#datablob) | Issuer of the X.509 CRL obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { - if (error != null) { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Crl success"); - let issuerName = x509Crl.getIssuerName(); - } -}); -``` - -### getLastUpdate - -getLastUpdate() : string - -Obtains the date when the X.509 CRL was last updated. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------ | ------------------------------------ | -| string | Last update date of the X.509 CRL.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { - if (error != null) { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Crl success"); - let lastUpdate = x509Crl.getLastUpdate(); - } -}); -``` - -### getNextUpdate - -getNextUpdate() : string - -Obtains the date when the CRL will be updated the next time. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------ | ------------------------------------ | -| string | Next update date obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { - if (error != null) { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Crl success"); - let nextUpdate = x509Crl.getNextUpdate(); - } -}); -``` - -### getRevokedCert - -getRevokedCert(serialNumber : number, callback : AsyncCallback\) : void - -Obtains the revoked X.509 certificate based on the specified serial number of the certificate. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| ------------ | ------------- | ---- | -------------- | -| serialNumber | number | Yes | Serial number of the certificate.| -| callback | AsyncCallback\ | No | Callback invoked to return the revoked X.509 certificate. | - - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { - if (error != null) { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Crl success"); - // Set the serial number of the corresponding certificate. - let serialNumber = 1000; - x509Crl.getRevokedCert(serialNumber, function (error, entry) { - if (error != null) { - Console.log("getRevokedCert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("getRevokedCert success"); - } - }); - } -}); -``` - -### getRevokedCert - -getRevokedCert(serialNumber : number) : Promise\ - -Obtains the revoked X.509 certificate based on the specified serial number of the certificate. This API uses a promise to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| ------------ | ------ | ---- | -------------- | -| serialNumber | number | Yes | Serial number of the certificate.| - -**Return value** - -| Type | Description | -| ------------ | ---------------------- | -| Promise\ | Promise used to return the revoked X.509 certificate obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob).then(x509Crl => { - Console.log("createX509Crl success"); - // Set the serial number of the corresponding certificate. - let serialNumber = 1000; - x509Crl.getRevokedCert(serialNumber).then(entry => { - Console.log("getRevokedCert success"); - }, error => { - Console.log("getRevokedCert failed, errCode: " + error.code + ", errMsg: " + error.message); - }); -}, error => { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); -}); -``` - -### getRevokedCertWithCert - -getRevokedCertWithCert(cert : X509Cert, callback : AsyncCallback\) : void - -Obtains the revoked X.509 certificate based on the specified certificate. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------- | ---- | ------------ | -| cert | X509Cert | Yes | Certificate based on which the revoked certificate is obtained.| -| callback | AsyncCallback\ | No | Callback invoked to return the revoked X.509 certificate obtained. | - - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { - if (error != null) { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Crl success"); - // Create an X509Cert instance. - let x509Cert = null; - x509Crl.getRevokedCertWithCert(x509Cert, function (error, entry) { - if (error != null) { - Console.log("getRevokedCertWithCert failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("getRevokedCertWithCert success"); - } - }); - } -}); -``` - -### getRevokedCertWithCert - -getRevokedCertWithCert(cert : X509Cert) : Promise\ - -Obtains the revoked X.509 certificate based on the specified certificate. This API uses a promise to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | -------- | ---- | ------------ | -| cert | X509Cert | Yes | Certificate based on which the revoked certificate is obtained.| - -**Return value** - -| Type | Description | -| ------------ | ---------------------- | -| Promise\ | Promise used to return the revoked X.509 certificate obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob).then(x509Crl => { - Console.log("createX509Crl success"); - // Create an X509Cert instance. - let x509Cert = null; - x509Crl.getRevokedCertWithCert(x509Cert).then(entry => { - Console.log("getRevokedCertWithCert success"); - }, error => { - Console.log("getRevokedCertWithCert failed, errCode: " + error.code + ", errMsg: " + error.message); - }); -}, error => { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); -}); -``` - -### getRevokedCerts - -getRevokedCerts(callback : AsyncCallback>) : void - -Obtains all the revoked X.509 certificates. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------- | ---- | -------- | -| callback | AsyncCallback> | No | Callback invoked to return the revoked X.509 certificates obtained.| - - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { - if (error != null) { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Crl success"); - x509Crl.getRevokedCerts(function (error, array) { - if (error != null) { - Console.log("getRevokedCerts failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("getRevokedCerts success"); - } - }); - } -}); -``` - -### getRevokedCerts - -getRevokedCerts() : Promise> - -Obtains all the revoked X.509 certificates. This API uses a promise to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------------------- | ---------------------- | -|Promise> | Promise used to return a list of revoked X.509 certificates.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob).then(x509Crl => { - Console.log("createX509Crl success"); - x509Crl.getRevokedCerts().then(array => { - Console.log("getRevokedCerts success"); - }, error => { - Console.log("getRevokedCerts failed, errCode: " + error.code + ", errMsg: " + error.message); - }); -}, error => { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); -}); -``` - -### getTbsInfo - -getTbsInfo(callback : AsyncCallback\) : void - -Obtains the DER-encoded CRL information, the **tbsCertList** from this CRL. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------- | ---- | -------- | -| callback | AsyncCallback\<[DataBlob](#datablob)> | No | Callback invoked to return the tbsCertList information obtained.| - - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { - if (error != null) { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Crl success"); - x509Crl.getTbsInfo(function (error, tbsInfo) { - if (error != null) { - Console.log("getTbsInfo failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("getTbsInfo success"); - } - }); - } -}); -``` - -### getTbsInfo - -getTbsInfo() : Promise\ - -Obtains the DER-encoded CRL information, the **tbsCertList** from this CRL. This API uses a promise to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| -------- | --------------------------------- | -| Promise\<[DataBlob](#datablob)> | Promise used to return the **tbsCertList** information obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob).then(x509Crl => { - Console.log("createX509Crl success"); - x509Crl.getTbsInfo().then(tbsInfo => { - Console.log("getTbsInfo success"); - }, error => { - Console.log("getTbsInfo failed, errCode: " + error.code + ", errMsg: " + error.message); - }); -}, error => { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); -}); -``` - -### getSignature - -getSignature() : DataBlob - -Obtains the signature data of the X.509 CRL. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| -------- | ------------------------------ | -| [DataBlob](#datablob) | Signature data of the X.509 CRL obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { - if (error != null) { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Crl success"); - let signature = x509Crl.getSignature(); - } -}); -``` - -### getSignatureAlgName - -getSignatureAlgName() : string - -Obtains the signing algorithm of the X.509 CRL. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------ | -------------------------------- | -| string | Signing algorithm obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { - if (error != null) { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Crl success"); - let sigAlgName = x509Crl.getSignatureAlgName(); - } -}); -``` - -### getSignatureAlgOid - -getSignatureAlgOid() : string - -Obtains the OID of the X.509 CRL signing algorithm. OIDs are allocated by the International Organization for Standardization (ISO). - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------ | --------------------------------------------- | -| string | OID of the X.509 CRL signing algorithm obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { - if (error != null) { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Crl success"); - let sigAlgOid = x509Crl.getSignatureAlgOid(); - } -}); -``` - -### getSignatureAlgParams - -getSignatureAlgParams() : DataBlob - -Obtains the parameters of the X.509 CRL signing algorithm. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| -------- | ---------------------------------- | -| [DataBlob](#datablob) | Algorithm parameters obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Binary data of the CRL, which must be set based on the service. -let encodingData = null; -let encodingBlob = { - data: encodingData, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { - if (error != null) { - Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("createX509Crl success"); - let sigAlgParams = x509Crl.getSignatureAlgParams(); - } -}); -``` - -## cryptoCert.createCertChainValidator - -createCertChainValidator(algorithm :string) : CertChainValidator - -Creates a **CertChainValidator** object. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| --------- | ------ | ---- | ------------------------------------------ | -| algorithm | string | Yes | Certificate chain validator algorithm. Currently, only **PKIX** is supported.| - -**Return value** - -| Type | Description | -| ------------------ | -------------------- | -| CertChainValidator | **CertChainValidator** object created.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -let validator = cryptoCert.createCertChainValidator("PKIX"); -``` - -## CertChainValidator - -Provides APIs for certificate chain validator operations. - -### validate - -validate(certChain : CertChainData, callback : AsyncCallback\) : void - -Validates the X.509 certificate chain. This API uses an asynchronous callback to return the result. -The certificate chain validator does not verify the certificate validity period because the system time on the device is untrusted. To check the validity period of a certificate, use the [checkValidityWithDate()](#checkvaliditywithdate) API of the **X509Cert** class. For details, see [Certificate Specifications](./../security/cert-overview.md#certificate-specifications). - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| --------- | ------------- | ---- | ------------------------ | -| certChain | [CertChainData](#certchaindata) | Yes | Serialized X.509 certificate chain data.| -| callback | AsyncCallback\ | No | Callback invoked to return the result. If **error** is **null**, the X.509 certificate chain is valid. If **error** is not **null**, the X.509 certificate chain is not valid. | - - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -let validator = cryptoCert.createCertChainValidator("PKIX"); -// Certificate chain binary data, which must be set based on the service. -let encodingData = null; -// Number of certificates in the certificate chain. It must be set based on the service. -let certCount = 2; -let certChainData = { - data: encodingData, - count: certCount, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -validator.validate(certChainData, function (error, data) { - if (error != null) { - Console.log("validate failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("validate success"); - } -}); -``` - -### validate - -validate(certChain : CertChainData) : Promise\ - -Validates the X.509 certificate chain. This API uses a promise to return the result. -The certificate chain validator does not verify the certificate validity period because the system time on the device is untrusted. To check the validity period of a certificate, use the [checkValidityWithDate()](#checkvaliditywithdate) API of the **X509Cert** class. For details, see [Certificate Specifications](./../security/cert-overview.md#certificate-specifications). - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| --------- | ------------- | ---- | ------------------------ | -| certChain | [CertChainData](#certchaindata) | Yes | Serialized X.509 certificate chain data.| - -**Return value** - -| Type| Description | -| ---- | ------------------------------------------------------------ | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -let validator = cryptoCert.createCertChainValidator("PKIX"); -// Certificate chain binary data, which must be set based on the service. -let encodingData = null; -// Number of certificates in the certificate chain. It must be set based on the service. -let certCount = 2; -let certChainData = { - data: encodingData, - count: certCount, - // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. - encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM -}; -validator.validate(certChainData).then(result => { - Console.log("validate success"); -}, error => { - Console.log("validate failed, errCode: " + error.code + ", errMsg: " + error.message); -}); -``` - -### algorithm - -algorithm : string - -Obtains the algorithm of the X.509 certificate chain validator. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------ | ------------------------ | -| string | Algorithm of the X.509 certificate chain validator obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -let validator = cryptoCert.createCertChainValidator("PKIX"); -let algorithm = validator.algorithm; -``` - -## X509CrlEntry - -Provides APIs for operating the revoked certificates. - -### getEncoded - -getEncoded(callback : AsyncCallback\) : void - -Obtains the serialized data of this revoked certificate. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------- | ---- | -------- | -| callback | AsyncCallback\<[EncodingBlob](#encodingblob)> | No | Callback invoked to return the serialized data of the revoked certificate.| - - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Obtain X509CrlEntry by using getRevokedCert() of X509Crl. -let x509CrlEntry = null; -x509CrlEntry.getEncoded(function (error, data) { - if (error != null) { - Console.log("getEncoded failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("getEncoded success"); - } -}); -``` - -### getEncoded - -getEncoded() : Promise\ - -Obtains the serialized data of this revoked certificate. This API uses a promise to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------------ | -------------------------- | -| Promise\<[EncodingBlob](#encodingblob)> | Promise used to return the serialized data of the revoked certificate obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Obtain X509CrlEntry by using getRevokedCert() of X509Crl. -let x509CrlEntry = null; -x509CrlEntry.getEncoded().then(result => { - Console.log("getEncoded success"); -}, error => { - Console.log("getEncoded failed, errCode: " + error.code + ", errMsg: " + error.message); -}); -``` - -### getSerialNumber - -getSerialNumber() : number - -Obtains the serial number of this revoked certificate. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------ | ---------------------- | -| number | Serial number of the revoked certificate obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Obtain X509CrlEntry by using getRevokedCert() of X509Crl. -let x509CrlEntry = null; -let serialNumber = x509CrlEntry.getSerialNumber(); -``` - -### getCertIssuer - -getCertIssuer(callback : AsyncCallback\) : void - -Obtains the issuer of this revoked certificate. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------- | ---- | -------- | -| callback | AsyncCallback\<[DataBlob](#datablob)> | No | Callback invoked to return the issuer of the revoked certificate obtained.| - - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Obtain X509CrlEntry by using getRevokedCert() of X509Crl. -let x509CrlEntry = null; -x509CrlEntry.getCertIssuer(function (error, issuer) { - if (error != null) { - Console.log("getCertIssuer failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("getCertIssuer success"); - } -}); -``` - -### getCertIssuer - -getCertIssuer() : Promise\ - -Obtains the issuer of this revoked certificate. This API uses a promise to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| -------- | -------------------------- | -| Promise\<[DataBlob](#datablob)> | Promise used to return the issuer of the revoked certificate obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Obtain X509CrlEntry by using getRevokedCert() of X509Crl. -let x509CrlEntry = null; -x509CrlEntry.getCertIssuer().then(issuer => { - Console.log("getCertIssuer success"); -}, error => { - Console.log("getCertIssuer failed, errCode: " + error.code + ", errMsg: " + error.message); -}); -``` - -### getRevocationDate - -getRevocationDate(callback : AsyncCallback\) : void - -Obtains the date when the certificate was revoked. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ------------- | ---- | -------- | -| callback | AsyncCallback\ | No | Callback invoked to return the certificate revocation date obtained.| - - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Obtain X509CrlEntry by using getRevokedCert() of X509Crl. -let x509CrlEntry = null; -x509CrlEntry.getRevocationDate(function (error, date) { - if (error != null) { - Console.log("getRevocationDate failed, errCode: " + error.code + ", errMsg: " + error.message); - } else { - Console.log("getRevocationDate success"); - } -}); -``` - -### getRevocationDate - -getRevocationDate() : Promise\ - -Obtains the date when the certificate was revoked. This API uses a promise to return the result. - -**System capability**: SystemCapability.Security.Cert - -**Return value** - -| Type | Description | -| ------ | -------------------- | -| Promise\ | Promise used to return the certificate revocation date obtained.| - -**Example** - -```js -import cryptoCert from '@ohos.security.cert'; - -// Obtain X509CrlEntry by using getRevokedCert() of X509Crl. -let x509CrlEntry = null; -x509CrlEntry.getRevocationDate().then(date => { - Console.log("getRevocationDate success"); -}, error => { - Console.log("getRevocationDate failed, errCode: " + error.code + ", errMsg: " + error.message); -}); -``` diff --git a/en/application-dev/reference/apis/js-apis-config-policy.md b/en/application-dev/reference/apis/js-apis-configPolicy.md similarity index 100% rename from en/application-dev/reference/apis/js-apis-config-policy.md rename to en/application-dev/reference/apis/js-apis-configPolicy.md diff --git a/en/application-dev/reference/apis/js-apis-bundle-defaultAppManager.md b/en/application-dev/reference/apis/js-apis-defaultAppManager.md similarity index 68% rename from en/application-dev/reference/apis/js-apis-bundle-defaultAppManager.md rename to en/application-dev/reference/apis/js-apis-defaultAppManager.md index e80cf7f78b..28830ea073 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-defaultAppManager.md +++ b/en/application-dev/reference/apis/js-apis-defaultAppManager.md @@ -9,24 +9,34 @@ The **DefaultAppManager** module provides APIs to query whether the current appl ## Modules to Import ``` -import defaultAppMgr from '@ohos.bundle.defaultAppManager' +import defaultAppMgr from '@ohos.bundle.defaultAppManager'; ``` + +## Required Permissions + +| Permission | Permission Level | Description | +| --------------------------------------- | ----------- | ---------------- | +| ohos.permission.GET_DEFAULT_APPLICATION | system_core | Permission related to the default application.| + +For details, see in [Permission Levels](../../security/accesstoken-overview.md#permission-levels). + + ## defaultAppMgr.ApplicationType Enumerates the application types. -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFramework.DefaultApp -| Name | Type | Description | -| -------- | -------- | -------------------------------------- | -| BROWSER | string | Default browser. | -| IMAGE | string | Default image viewer. | -| AUDIO | string | Default audio player. | -| VIDEO | string | Default video player. | -| PDF | string | Default PDF reader. | -| WORD | string | Default Word viewer. | -| EXCEL | string | Default Excel viewer. | -| PPT | string | Default PowerPoint viewer. | +| Name | Type | Value | Description | +| -------- | -------- | -------------------------------------- | -------------------------------------- | +| BROWSER | string | Web Browser | Default browser. | +| IMAGE | string | Image Gallery | Default image viewer. | +| AUDIO | string | Audio Player | Default audio player. | +| VIDEO | string | Video Player | Default video player. | +| PDF | string | PDF Viewer | Default PDF reader. | +| WORD | string | Word Viewer | Default Word viewer. | +| EXCEL | string | Excel Viewer | Default Excel viewer. | +| PPT | string | PPT Viewer | Default PowerPoint viewer. | ## defaultAppMgr.isDefaultApplication @@ -34,11 +44,11 @@ isDefaultApplication(type: string): Promise\ Checks whether this application is the default application of a system-defined application type. This API uses a promise to return the result. -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFramework.DefaultApp **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | ----------- | ------ | ---- | --------------------------------------- | | type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype). | @@ -48,9 +58,15 @@ Checks whether this application is the default application of a system-defined a | ------------------------- | ------------------ | | Promise\ | Promise used to return the result. If the application is the default application, `true` is returned; otherwise, `false` is returned.| +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + + **Example** -```js +```ts +import defaultAppMgr from '@ohos.bundle.defaultAppManager'; defaultAppMgr.isDefaultApplication(defaultAppMgr.ApplicationType.BROWSER) .then((data) => { console.info('Operation successful. IsDefaultApplication ? ' + JSON.stringify(data)); @@ -65,18 +81,23 @@ isDefaultApplication(type: string, callback: AsyncCallback\): void Checks whether this application is the default application of a system-defined application type. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFramework.DefaultApp **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | ----------- | ------------------------------- | ---- | --------------------------------------- | | type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype). | | callback | AsyncCallback\ | Yes | Callback used to return the result. If the application is the default application, `true` is returned; otherwise, `false` is returned.| +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + **Example** ```js +import defaultAppMgr from '@ohos.bundle.defaultAppManager'; defaultAppMgr.isDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, (err, data) => { if (err) { console.error('Operation failed. Cause: ' + JSON.stringify(err)); @@ -94,13 +115,13 @@ Obtains the default application based on a system-defined application type or a **Required permissions**: ohos.permission.GET_DEFAULT_APPLICATION -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFramework.DefaultApp **System API**: This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | ----------- | ------ | ---- | --------------------------------------- | | type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype) or a file type that complies with the media type format. | | userId | number | No | User ID. The default value is the user ID of the caller. | @@ -111,9 +132,20 @@ Obtains the default application based on a system-defined application type or a | ------------------------- | ------------------ | | Promise\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Promise used to return the default application.| +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ----------------------------------------- | +| 17700004 | The specified user ID is not found. | +| 17700023 | The specified default app does not exist. | +| 17700025 | The specified type is invalid. | + **Example** ```js +import defaultAppMgr from '@ohos.bundle.defaultAppManager'; defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER) .then((data) => { console.info('Operation successful. bundleInfo: ' + JSON.stringify(data)); @@ -139,22 +171,34 @@ Obtains the default application of a user based on a system-defined application **Required permissions**: ohos.permission.GET_DEFAULT_APPLICATION -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFramework.DefaultApp **System API**: This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | ----------- | ------ | ---- | --------------------------------------- | | type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype) or a file type that complies with the media type format. | | userId | number | Yes | User ID. | | callback | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes | Callback used to return the default application. | +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ----------------------------------------- | +| 17700004 | The specified user ID is not found. | +| 17700023 | The specified default app does not exist. | +| 17700025 | The specified type is invalid. | + **Example** ```js -defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, 100, (err, data) => { +import defaultAppMgr from '@ohos.bundle.defaultAppManager'; +let userId = 100; +defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, userId, (err, data) => { if (err) { console.error('Operation failed. Cause: ' + JSON.stringify(err)); return; @@ -162,7 +206,7 @@ defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, 100, console.info('Operation successful. bundleInfo:' + JSON.stringify(data)); }); -defaultAppMgr.getDefaultApplication("image/png", 100, (err, data) => { +defaultAppMgr.getDefaultApplication("image/png", userId, (err, data) => { if (err) { console.error('Operation failed. Cause: ' + JSON.stringify(err)); return; @@ -179,20 +223,31 @@ Obtains the default application based on a system-defined application type or a **Required permissions**: ohos.permission.GET_DEFAULT_APPLICATION -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFramework.DefaultApp **System API**: This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | ----------- | ------ | ---- | --------------------------------------- | | type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype) or a file type that complies with the media type format. | | callback | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes | Callback used to return the default application. | +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ----------------------------------------- | +| 17700004 | The specified user ID is not found. | +| 17700023 | The specified default app does not exist. | +| 17700025 | The specified type is invalid. | + **Example** ```js +import defaultAppMgr from '@ohos.bundle.defaultAppManager'; defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, (err, data) => { if (err) { console.error('Operation failed. Cause: ' + JSON.stringify(err)); @@ -200,7 +255,6 @@ defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, (err, } console.info('Operation successful. bundleInfo:' + JSON.stringify(data)); }); - defaultAppMgr.getDefaultApplication("image/png", (err, data) => { if (err) { console.error('Operation failed. Cause: ' + JSON.stringify(err)); @@ -218,30 +272,56 @@ Sets the default application based on a system-defined application type or a fil **Required permissions**: ohos.permission.SET_DEFAULT_APPLICATION -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFramework.DefaultApp **System API**: This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | ----------- | ------ | ---- | --------------------------------------- | | type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype) or a file type that complies with the media type format. | | elementName | [ElementName](js-apis-bundle-ElementName.md) | Yes | Information about the element to be set as the default application. | -| userId | number | No | User ID. The default value is the user ID of the caller. | +| userId | number | No | User ID. The default value is the user ID of the caller. | + +**Return value** + +| Type | Description | +| -------------- | ---------------------------------- | +| Promise\ | Promise that returns no value.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ---------------------------------------------- | +| 17700004 | The specified user ID is not found. | +| 17700025 | The specified type is invalid. | +| 17700028 | The specified ability does not match the type. | **Example** ```js +import defaultAppMgr from '@ohos.bundle.defaultAppManager'; defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, { bundleName: "com.test.app", moduleName: "module01", abilityName: "MainAbility" -}) -.then((data) => { +}).then((data) => { console.info('Operation successful.'); -}) -.catch((error) => { +}).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); +}); + +let userId = 100; +defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, { + bundleName: "com.test.app", + moduleName: "module01", + abilityName: "MainAbility" +}, userId).then((data) => { + console.info('Operation successful.'); +}).catch((error) => { console.error('Operation failed. Cause: ' + JSON.stringify(error)); }); @@ -249,11 +329,9 @@ defaultAppMgr.setDefaultApplication("image/png", { bundleName: "com.test.app", moduleName: "module01", abilityName: "MainAbility" -}) -.then((data) => { +}, userId).then((data) => { console.info('Operation successful.'); -}) -.catch((error) => { +}).catch((error) => { console.error('Operation failed. Cause: ' + JSON.stringify(error)); }); ``` @@ -266,27 +344,39 @@ Sets the default application for a user based on a system-defined application ty **Required permissions**: ohos.permission.SET_DEFAULT_APPLICATION -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFramework.DefaultApp **System API**: This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | ----------- | ------ | ---- | --------------------------------------- | | type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype) or a file type that complies with the media type format. | | elementName | [ElementName](js-apis-bundle-ElementName.md) | Yes | Information about the element to be set as the default application. | | userId | number | Yes | User ID. | | callback | AsyncCallback\ | Yes | Callback used to return the result. | +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ---------------------------------------------- | +| 17700004 | The specified user ID is not found. | +| 17700025 | The specified type is invalid. | +| 17700028 | The specified ability does not match the type. | + **Example** ```js +import defaultAppMgr from '@ohos.bundle.defaultAppManager'; +let userId = 100; defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, { bundleName: "com.test.app", moduleName: "module01", abilityName: "MainAbility" -}, 100, (err, data) => { +}, userId, (err, data) => { if (err) { console.error('Operation failed. Cause: ' + JSON.stringify(err)); return; @@ -298,7 +388,7 @@ defaultAppMgr.setDefaultApplication("image/png", { bundleName: "com.test.app", moduleName: "module01", abilityName: "MainAbility" -}, 100, (err, data) => { +}, userId, (err, data) => { if (err) { console.error('Operation failed. Cause: ' + JSON.stringify(err)); return; @@ -315,21 +405,32 @@ Sets the default application based on a system-defined application type or a fil **Required permissions**: ohos.permission.SET_DEFAULT_APPLICATION -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFramework.DefaultApp **System API**: This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | ----------- | ------ | ---- | --------------------------------------- | | type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype) or a file type that complies with the media type format. | | elementName | [ElementName](js-apis-bundle-ElementName.md) | Yes | Information about the element to be set as the default application. | | callback | AsyncCallback\ | Yes | Callback used to return the result. | +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ---------------------------------------------- | +| 17700004 | The specified user ID is not found. | +| 17700025 | The specified type is invalid. | +| 17700028 | The specified ability does not match the type. | + **Example** -```js +```ts +import defaultAppMgr from '@ohos.bundle.defaultAppManager'; defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, { bundleName: "com.test.app", moduleName: "module01", @@ -363,21 +464,32 @@ Resets the default application based on a system-defined application type or a f **Required permissions**: ohos.permission.SET_DEFAULT_APPLICATION -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFramework.DefaultApp **System API**: This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | ----------- | ------ | ---- | --------------------------------------- | | type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype) or a file type that complies with the media type format. | -| userId | number | No | User ID. The default value is the user ID of the caller. | +| userId | number | No | User ID. The default value is the user ID of the caller. | + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ----------------------------------- | +| 17700004 | The specified user ID is not found. | +| 17700025 | The specified type is invalid. | **Example** ```js -defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER) +import defaultAppMgr from '@ohos.bundle.defaultAppManager'; +let userId = 100; +defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, userId) .then((data) => { console.info('Operation successful.'); }) @@ -385,7 +497,7 @@ defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER) console.error('Operation failed. Cause: ' + JSON.stringify(error)); }); -defaultAppMgr.resetDefaultApplication("image/png") +defaultAppMgr.resetDefaultApplication("image/png", userId) .then((data) => { console.info('Operation successful.'); }) @@ -402,22 +514,33 @@ Resets the default application for a user based on a system-defined application **Required permissions**: ohos.permission.SET_DEFAULT_APPLICATION -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFramework.DefaultApp **System API**: This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | ----------- | ------ | ---- | --------------------------------------- | | type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype) or a file type that complies with the media type format. | | userId | number | Yes | User ID. | | callback | AsyncCallback\ | Yes | Callback used to return the result. | +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ----------------------------------- | +| 17700004 | The specified user ID is not found. | +| 17700025 | The specified type is invalid. | + **Example** ```js -defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, 100, (err, data) => { +import defaultAppMgr from '@ohos.bundle.defaultAppManager'; +let userId = 100; +defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, userId, (err, data) => { if (err) { console.error('Operation failed. Cause: ' + JSON.stringify(err)); return; @@ -425,7 +548,7 @@ defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, 100 console.info('Operation successful.'); }); -defaultAppMgr.resetDefaultApplication("image/png", 100, (err, data) => { +defaultAppMgr.resetDefaultApplication("image/png", userId, (err, data) => { if (err) { console.error('Operation failed. Cause: ' + JSON.stringify(err)); return; @@ -442,20 +565,30 @@ Resets the default application based on a system-defined application type or a f **Required permissions**: ohos.permission.SET_DEFAULT_APPLICATION -**System capability**: SystemCapability.BundleManager.BundleFramework +**System capability**: SystemCapability.BundleManager.BundleFramework.DefaultApp **System API**: This is a system API and cannot be called by third-party applications. **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory | Description | | ----------- | ------ | ---- | --------------------------------------- | | type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype) or a file type that complies with the media type format. | | callback | AsyncCallback\ | Yes | Callback used to return the result. | +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ----------------------------------- | +| 17700004 | The specified user ID is not found. | +| 17700025 | The specified type is invalid. | + **Example** -```js +```ts +import defaultAppMgr from '@ohos.bundle.defaultAppManager'; defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, (err, data) => { if (err) { console.error('Operation failed. Cause: ' + JSON.stringify(err)); diff --git a/en/application-dev/reference/apis/js-apis-dispatchInfo.md b/en/application-dev/reference/apis/js-apis-dispatchInfo.md deleted file mode 100644 index 749ff83e51..0000000000 --- a/en/application-dev/reference/apis/js-apis-dispatchInfo.md +++ /dev/null @@ -1,18 +0,0 @@ -# DispatchInfo - -The **DispatchInfo** module provides dispatch 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. - -## DispatchInfo - -**System capability**: SystemCapability.BundleManager.BundleFramework - -**System API**: This is a system API and cannot be called by third-party applications. - -| Name | Type | Readable| Writable| Description | -| ----------- | ------ | ---- | ---- | ------------------------ | -| version | string | Yes | No | Version of the API to dispatch.| -| dispatchAPI | string | Yes | No | API to dispatch. | diff --git a/en/application-dev/reference/apis/js-apis-distributedBundle.md b/en/application-dev/reference/apis/js-apis-distributedBundle.md index 4df752e4c6..98a15d8184 100644 --- a/en/application-dev/reference/apis/js-apis-distributedBundle.md +++ b/en/application-dev/reference/apis/js-apis-distributedBundle.md @@ -5,8 +5,8 @@ The **distributedBundle** module provides APIs for managing distributed bundles. > **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 APIs provided by this module are system APIs. ## Modules to Import @@ -22,9 +22,9 @@ SystemCapability.BundleManager.DistributedBundleFramework | Permission | Permission Level | Description | | ------------------------------------------ | ------------ | ------------------ | -| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | Permission to query information about all applications.| +| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | Permission to query information about all bundles.| -For details, see "Permission Levels" in [Access Control Overview](../../security/accesstoken-overview.md). +For details, see [Permission Levels](../../security/accesstoken-overview.md#permission-levels). ## distributedBundle.getRemoteAbilityInfo @@ -40,28 +40,25 @@ Obtains information about the remote ability that matches the given element name **Parameters** -| Name | Type | Mandatory| Description | -| ----------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- | -| elementName | [ElementName](js-apis-bundleManager-elementName.md) | Yes | Target element name. | +| Name | Type | Mandatory| Description | +| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| elementName | [ElementName](js-apis-bundleManager-elementName.md) | Yes | Target element name. | | callback | AsyncCallback<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the **RemoteAbilityInfo** object obtained. Otherwise, **err** is an error object.| **Error codes** -For details about the error codes, see [Bundle Error Codes](../errorcodes/errcode-bundle.md). +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). -| ID | Error Message | -|---------------|-------------------------| -| 201 | Permission denied.| -| 401 | The parameter check failed. | -| 801 | Capability not supported. | -| 17700001 | The specified bundle name is not found | +| ID| Error Message | +|----------|--------------------------------------| +| 17700001 | The specified bundle name is not found. | | 17700003 | The specified ability name is not found. | -| 17700007 | The specified device id is not found. | +| 17700007 | The specified device ID is not found. | | 17700027 | The distributed service is not running. | **Example** -```js +```ts try { distributedBundle.getRemoteAbilityInfo( { @@ -94,7 +91,7 @@ Obtains information about the remote ability that matches the given element name **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | ----------- | -------------------------------------------- | ---- | ----------------------- | | elementName | [ElementName](js-apis-bundleManager-elementName.md) | Yes | Target element name.| @@ -106,21 +103,18 @@ Obtains information about the remote ability that matches the given element name **Error codes** -For details about the error codes, see [Bundle Error Codes](../errorcodes/errcode-bundle.md). +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). -| ID | Error Message | -|---------------|-------------------------| -| 201 | Permission denied.| -| 401 | The parameter check failed. | -| 801 | Capability not supported. | -| 17700001 | The specified bundle name is not found | +| ID| Error Message | +|----------|-------------------------| +| 17700001 | The specified bundle name is not found. | | 17700003 | The specified ability name is not found. | -| 17700007 | The specified device id is not found. | +| 17700007 | The specified device ID is not found. | | 17700027 | The distributed service is not running. | **Example** -```js +```ts try { distributedBundle.getRemoteAbilityInfo( { @@ -151,28 +145,25 @@ Obtains information about remote abilities that match the given element names. T **Parameters** -| Name | Type | Mandatory| Description | -| ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- | -| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | **ElementName** array, whose maximum length is 10. | +| Name | Type | Mandatory| Description | +| ------------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | **ElementName** array, whose maximum length is 10. | | callback | AsyncCallback\> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of **RemoteAbilityInfo** objects obtained. Otherwise, **err** is an error object.| **Error codes** -For details about the error codes, see [Bundle Error Codes](../errorcodes/errcode-bundle.md). +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). -| ID | Error Message | -|---------------|-------------------------| -| 201 | Permission denied.| -| 401 | The parameter check failed. | -| 801 | Capability not supported. | -| 17700001 | The specified bundle name is not found | +| ID| Error Message | +|----------|-------------------------| +| 17700001 | The specified bundle name is not found. | | 17700003 | The specified ability name is not found. | -| 17700007 | The specified device id is not found. | +| 17700007 | The specified device ID is not found. | | 17700027 | The distributed service is not running. | **Example** -```js +```ts try { distributedBundle.getRemoteAbilityInfo( [ @@ -202,7 +193,7 @@ try { getRemoteAbilityInfo(elementNames: Array\): Promise\>; -Obtains information about remote abilities that match the given element names. This API uses a promise to return the result. +Obtains information about remote abilities that match the given element names and locales. This API uses a promise to return the result. **System API**: This is a system API. @@ -212,7 +203,7 @@ Obtains information about remote abilities that match the given element names. T **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | ------------ | --------------------------------------------------- | ---- | ----------------------- | | elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | **ElementName** array, whose maximum length is 10.| @@ -224,21 +215,18 @@ Obtains information about remote abilities that match the given element names. T **Error codes** -For details about the error codes, see [Bundle Error Codes](../errorcodes/errcode-bundle.md). +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). -| ID | Error Message | -|---------------|-------------------------| -| 201 | Permission denied.| -| 401 | The parameter check failed. | -| 801 | Capability not supported. | -| 17700001 | The specified bundle name is not found | +| ID| Error Message | +|----------|-------------------------| +| 17700001 | The specified bundle name is not found. | | 17700003 | The specified ability name is not found. | -| 17700007 | The specified device id is not found. | +| 17700007 | The specified device ID is not found. | | 17700027 | The distributed service is not running. | **Example** -```js +```ts try { distributedBundle.getRemoteAbilityInfo( [ @@ -276,7 +264,7 @@ Obtains information about the remote ability that matches the given element name **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | ----------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- | | elementName | [ElementName](js-apis-bundleManager-elementName.md) | Yes | Target element name. | | locale | string |Yes| Target locale.| @@ -284,21 +272,18 @@ Obtains information about the remote ability that matches the given element name **Error codes** -For details about the error codes, see [Bundle Error Codes](../errorcodes/errcode-bundle.md). +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). -| ID | Error Message | -|---------------|-------------------------| -| 201 | Permission denied.| -| 401 | The parameter check failed. | -| 801 | Capability not supported. | -| 17700001 | The specified bundle name is not found | +| ID| Error Message | +|----------|-------------------------| +| 17700001 | The specified bundle name is not found. | | 17700003 | The specified ability name is not found. | -| 17700007 | The specified device id is not found. | +| 17700007 | The specified device ID is not found. | | 17700027 | The distributed service is not running. | **Example** -```js +```ts try { distributedBundle.getRemoteAbilityInfo( { @@ -331,7 +316,7 @@ Obtains information about the remote ability that matches the given element name **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | ----------- | -------------------------------------------- | ---- | ----------------------- | | elementName | [ElementName](js-apis-bundleManager-elementName.md) | Yes | Target element name.| | locale | string |Yes| Target locale.| @@ -344,21 +329,18 @@ Obtains information about the remote ability that matches the given element name **Error codes** -For details about the error codes, see [Bundle Error Codes](../errorcodes/errcode-bundle.md). +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). -| ID | Error Message | -|---------------|-------------------------| -| 201 | Permission denied.| -| 401 | The parameter check failed. | -| 801 | Capability not supported. | -| 17700001 | The specified bundle name is not found | +| ID| Error Message | +|----------|-------------------------| +| 17700001 | The specified bundle name is not found. | | 17700003 | The specified ability name is not found. | -| 17700007 | The specified device id is not found. | +| 17700007 | The specified device ID is not found. | | 17700027 | The distributed service is not running. | **Example** -```js +```ts try { distributedBundle.getRemoteAbilityInfo( { @@ -389,7 +371,7 @@ Obtains information about remote abilities that match the given element names an **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- | | elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | **ElementName** array, whose maximum length is 10. | | locale | string |Yes| Target locale.| @@ -397,21 +379,18 @@ Obtains information about remote abilities that match the given element names an **Error codes** -For details about the error codes, see [Bundle Error Codes](../errorcodes/errcode-bundle.md). +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). | ID | Error Message | |---------------|-------------------------| -| 201 | Permission denied.| -| 401 | The parameter check failed. | -| 801 | Capability not supported. | -| 17700001 | The specified bundle name is not found | +| 17700001 | The specified bundle name is not found. | | 17700003 | The specified ability name is not found. | -| 17700007 | The specified device id is not found. | +| 17700007 | The specified device ID is not found. | | 17700027 | The distributed service is not running. | **Example** -```js +```ts try { distributedBundle.getRemoteAbilityInfo( [ @@ -451,7 +430,7 @@ Obtains information about remote abilities that match the given element names an **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | ------------ | --------------------------------------------------- | ---- | ----------------------- | | elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | **ElementName** array, whose maximum length is 10.| | locale | string |Yes| Target locale.| @@ -464,21 +443,18 @@ Obtains information about remote abilities that match the given element names an **Error codes** -For details about the error codes, see [Bundle Error Codes](../errorcodes/errcode-bundle.md). +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). -| ID | Error Message | -|---------------|-------------------------| -| 201 | Permission denied.| -| 401 | The parameter check failed. | -| 801 | Capability not supported. | -| 17700001 | The specified bundle name is not found | +| ID| Error Message | +|----------|-------------------------| +| 17700001 | The specified bundle name is not found. | | 17700003 | The specified ability name is not found. | -| 17700007 | The specified device id is not found. | +| 17700007 | The specified device ID is not found. | | 17700027 | The distributed service is not running. | **Example** -```js +```ts try { distributedBundle.getRemoteAbilityInfo( [ diff --git a/en/application-dev/reference/apis/js-apis-enterprise-device-manager.md b/en/application-dev/reference/apis/js-apis-enterprise-device-manager.md deleted file mode 100644 index 13db49605f..0000000000 --- a/en/application-dev/reference/apis/js-apis-enterprise-device-manager.md +++ /dev/null @@ -1,975 +0,0 @@ -# Enterprise Device Management - -The **enterpriseDeviceManager** module provides enterprise device management capabilities so that devices have the customization capabilities required in enterprise scenarios. - -> **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 enterpriseDeviceManager from '@ohos.enterpriseDeviceManager'; -``` - -## enterpriseDeviceManager.enableAdmin - -enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback\): void - -Enables a device administrator application based on the specified bundle name and class name. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| -------------- | ----------------------------------- | ---- | ------------------ | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | -| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | Yes | Enterprise information of the device administrator application. | -| type | [AdminType](#admintype) | Yes | Type of the device administrator to enable. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Error codes** - -| Type | Description | -| ------- | --------------------------------------------------------------- | -| 9200003 | The administrator ability component is invalid. | -| 9200004 | Failed to activate the administrator application of the device. | -| 9200007 | The system ability work abnormally. | - -**Example** - -```js -let wantTemp = { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", -}; -let enterpriseInfo = { - name: "enterprise name", - description: "enterprise description" -} -enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, error => { - if (error != null) { - console.log("error occurs" + error); - return; - } - console.log("enableAdmin success"); -}); -``` - -## enterpriseDeviceManager.enableAdmin - -enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId: number, callback: AsyncCallback\): void - -Enables a device administrator application based on the specified bundle name and class name. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| -------------- | ----------------------------------- | ---- | ---------------------------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | -| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | Yes | Enterprise information of the device administrator application. | -| type | [AdminType](#admintype) | Yes | Type of the device administrator to enable. | -| 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 result. | - -**Error codes** - -| Type | Description | -| ------- | --------------------------------------------------------------- | -| 9200003 | The administrator ability component is invalid. | -| 9200004 | Failed to activate the administrator application of the device. | -| 9200007 | The system ability work abnormally. | - -**Example** - -```js -let wantTemp = { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", -}; -let enterpriseInfo = { - name: "enterprise name", - description: "enterprise description" -} -enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, 100, error => { - if (error != null) { - console.log("error occurs" + error); - return; - } - console.log("enableAdmin success"); -}); -``` - -## enterpriseDeviceManager.enableAdmin - -enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId?: number): Promise\ - -Enables a device administrator application based on the specified bundle name and class name. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| -------------- | ----------------------------------- | ---- | ---------------------------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | -| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | Yes | Enterprise information of the device administrator application. | -| type | [AdminType](#admintype) | Yes | Type of the device administrator to enable. | -| 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** - -| Type | Description | -| ----------------- | ----------------- | -| Promise\ | Promise used to return the result.| - -**Error codes** - -| Type | Description | -| ------- | --------------------------------------------------------------- | -| 9200003 | The administrator ability component is invalid. | -| 9200004 | Failed to activate the administrator application of the device. | -| 9200007 | The system ability work abnormally. | - -**Example** - -```js -let wantTemp = { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", -}; -let enterpriseInfo = { - name: "enterprise name", - description: "enterprise description" -} -enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, 100) -.catch(error => { - console.log("error occurs" + error); -}); -``` - -## enterpriseDeviceManager.disableAdmin - -disableAdmin(admin: Want, callback: AsyncCallback\): void - -Disables a device common administrator application based on the specified bundle name and class name. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| -------- | ----------------------------------- | ---- | ------------------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device common administrator application. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Error codes** - -| Type | Description | -| ------- | ----------------------------------------------------------------- | -| 9200005 | Failed to deactivate the administrator application of the device. | - -**Example** - -```js -let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", -}; -enterpriseDeviceManager.disableAdmin(wantTemp, error => { - if (error != null) { - console.log("error occurs" + error); - return; - } - console.log("disableAdmin success "); -}); -``` - -## enterpriseDeviceManager.disableAdmin - -disableAdmin(admin: Want, userId: number, callback: AsyncCallback\): void - -Disables a device common administrator application based on the specified bundle name and class name. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| -------- | ----------------------------------- | ---- | ---------------------------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device common administrator 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.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. | - -**Error codes** - -| Type | Description | -| ------- | ----------------------------------------------------------------- | -| 9200005 | Failed to deactivate the administrator application of the device. | - -**Example** - -```js -let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", -}; -enterpriseDeviceManager.disableAdmin(wantTemp, 100, error => { - if (error != null) { - console.log("error occurs" + error); - return; - } - console.log("disableAdmin success "); -}); -``` - -## enterpriseDeviceManager.disableAdmin - -disableAdmin(admin: Want, userId?: number): Promise\ - -Disables a device common administrator application based on the specified bundle name and class name. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| ------ | ----------------------------------- | ---- | ---------------------------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device common administrator application. | -| 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** - -| Type | Description | -| ----------------- | ----------------- | -| Promise\ | Promise used to return the result.| - -**Error codes** - -| Type | Description | -| ------- | ----------------------------------------------------------------- | -| 9200005 | Failed to deactivate the administrator application of the device. | - -**Example** - -```js -let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", -}; -enterpriseDeviceManager.disableAdmin(wantTemp, 100).catch(error => { - console.log("error occurs" + error); -}); -``` - -## enterpriseDeviceManager.disableSuperAdmin - -disableSuperAdmin(bundleName: String, callback: AsyncCallback\): void - -Disables a device super administrator application based on the specified bundle name. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| ---------- | ----------------------- | ---- | ------------------- | -| bundleName | String | Yes | Bundle name of the device super administrator application. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Error codes** - -| Type | Description | -| ------- | ----------------------------------------------------------------- | -| 9200005 | Failed to deactivate the administrator application of the device. | - -**Example** - -```js -let bundleName = "com.example.myapplication"; -enterpriseDeviceManager.disableSuperAdmin(bundleName, error => { - if (error != null) { - console.log("error occurs" + error); - return; - } - console.log("disableSuperAdmin success"); -}); -``` - -## enterpriseDeviceManager.disableSuperAdmin - -disableSuperAdmin(bundleName: String): Promise\ - -Disables a device super administrator application based on the specified bundle name. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| ---------- | ------ | ---- | ------------ | -| bundleName | String | Yes | Bundle name of the device super administrator application.| - -**Return value** - -| Type | Description | -| ----------------- | ----------------- | -| Promise\ | Promise used to return the result.| - -**Error codes** - -| Type | Description | -| ------- | ----------------------------------------------------------------- | -| 9200005 | Failed to deactivate the administrator application of the device. | - -**Example** - -```js -let bundleName = "com.example.myapplication"; -enterpriseDeviceManager.disableSuperAdmin(bundleName).catch(error => { - console.log("error occurs" + error); -}); -``` - -## enterpriseDeviceManager.isAdminEnabled - -isAdminEnabled(admin: Want, callback: AsyncCallback\): void - -Checks whether a device administrator application is enabled based on the specified bundle name and class name. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| -------- | ----------------------------------- | ---- | -------------------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Error codes** - -| Type | Description | -| ------- | ----------------------------------------------------------------- | -| 9200005 | Failed to deactivate the administrator application of the device. | - -**Example** - -```js -let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", -}; -enterpriseDeviceManager.isAdminEnabled(wantTemp, (error, result) => { - if (error != null) { - console.log("error occurs" + error); - return; - } - console.log("result is " + result); -}); -``` - -## enterpriseDeviceManager.isAdminEnabled - -isAdminEnabled(admin: Want, userId: number, callback: AsyncCallback\): void - -Checks whether a device administrator application is enabled based on the specified bundle name and class name. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| -------- | ----------------------------------- | ---- | ---------------------------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator 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.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. | - -**Example** - -```js -let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", -}; -enterpriseDeviceManager.isAdminEnabled(wantTemp, 100, (error, result) => { - if (error != null) { - console.log("error occurs" + error); - return; - } - console.log("result is " + result); -}); -``` - -## enterpriseDeviceManager.isAdminEnabled - -isAdminEnabled(admin: Want, userId?: number): Promise\ - -Checks whether a device administrator application is enabled based on the specified bundle name and class name. This API uses a promise to return the result. - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| ------ | ----------------------------------- | ---- | ---------------------------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | -| 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** - -| Type | Description | -| ----------------- | ------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", -}; -enterpriseDeviceManager.isAdminEnabled(wantTemp, 100).then((result) => { - console.log("result is " + result); -}).catch(error => { - console.log("error occurs" + error); -}); -``` - -## enterpriseDeviceManager.isSuperAdmin - -isSuperAdmin(bundleName: String, callback: AsyncCallback\): void - -Checks whether a device super administrator application is enabled based on the specified bundle name. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| ---------- | ----------------------- | ---- | -------------------- | -| bundleName | String | Yes | Device administrator application. | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -let bundleName = "com.example.myapplication"; -enterpriseDeviceManager.isSuperAdmin(bundleName, (error, result) => { - if (error != null) { - console.log("error occurs" + error); - return; - } - console.log("result is " + result); -}); -``` - -## enterpriseDeviceManager.isSuperAdmin - -isSuperAdmin(bundleName: String): Promise\ - -Checks whether a device super administrator application is enabled based on the specified bundle name. This API uses a promise to return the result. - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| ---------- | ------ | ---- | --------- | -| bundleName | String | Yes | Device super administrator application.| - -**Return value** - -| Type | Description | -| ----------------- | ------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -let bundleName = "com.example.myapplication"; -enterpriseDeviceManager.isSuperAdmin(bundleName).then((result) => { - console.log("result is " + result); -}).catch(error => { - console.log("error occurs" + error); -}); -``` - -## enterpriseDeviceManager.getDeviceSettingsManager - -getDeviceSettingsManager(callback: AsyncCallback<DeviceSettingsManager>): void - -Obtains a **DeviceSettingsManager** object. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**Parameters** - -| Name | Type | Mandatory | Description | -| -------- | --------------------------------------- | ---- | ----------------------------------- | -| callback | AsyncCallback<[DeviceSettingsManager](js-apis-enterpriseDeviceManager-DeviceSettingsManager.md)> | Yes | Callback used to return the **DeviceSettingsManager** object obtained.| - -**Error codes** - -| Type | Description | -| ------- | ---------------------------------------------------------------------------- | -| 9200001 | The application is not a administrator of the device. | -| 9200002 | The administrator application does not have permission to manage the device. | - -**Example** - -```js -let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", -}; -enterpriseDeviceManager.getDeviceSettingsManager((error, mgr) => { - if (error != null) { - console.log("error code:" + error.code); - return; - } - mgr.setDateTime(wantTemp, 1526003846000, (error) => { - if (error != null) { - console.log("error code:" + error.code); - } - }); -}); -``` - -## enterpriseDeviceManager.getDeviceSettingsManager - -getDeviceSettingsManager(): Promise<DeviceSettingsManager> - -Obtains a **DeviceSettingsManager** object. This API uses a promise to return the result. - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**Return value** - -| Type | Description | -| ------------------------------------ | ---------------------------------- | -| Promise<[DeviceSettingsManager](js-apis-enterpriseDeviceManager-DeviceSettingsManager.md)> | Promise used to return the **DeviceSettingsManager** object obtained.| - -**Error codes** - -| Type | Description | -| ------- | ---------------------------------------------------------------------------- | -| 9200001 | The application is not a administrator of the device. | -| 9200002 | The administrator application does not have permission to manage the device. | - -**Example** - -```js -let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", -}; -enterpriseDeviceManager.getDeviceSettingsManager().then((mgr) => { - mgr.setDateTime(wantTemp, 1526003846000).catch((error) => { - console.log("error code:" + error.code); - }) -}).catch((error) => { - console.log("error code:" + error.code); -}) -``` - -## enterpriseDeviceManager.setEnterpriseInfo - -setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCallback\;): void - -Sets the enterprise information of a device administrator application. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.SET_ENTERPRISE_INFO - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| -------------- | ----------------------------------- | ---- | ---------------------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | -| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | Yes | Enterprise information of the device administrator application. | -| callback | AsyncCallback\; | Yes | Callback used to return the result.| - -**Error codes** - -| Type | Description | -| ------- | ----------------------------------------------------- | -| 9200001 | The application is not a administrator of the device. | - -**Example** - -```js -let wantTemp = { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", -}; -let enterpriseInfo = { - name: "enterprise name", - description: "enterprise description" -} -enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo, error => { - if (error != null) { - console.log("error occurs" + error); - return; - } - console.log("setEnterpriseInfo success"); -}); -``` - -## enterpriseDeviceManager.setEnterpriseInfo - -setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise\; - -Sets the enterprise information of a device administrator application. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.SET_ENTERPRISE_INFO - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| -------------- | ----------------------------------- | ---- | ------------ | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | -| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | Yes | Enterprise information of the device administrator application.| - -**Return value** - -| Type | Description | -| ----------------- | --------------------- | -| Promise\ | Promise used to return the result.| - -**Error codes** - -| Type | Description | -| ------- | ----------------------------------------------------- | -| 9200001 | The application is not a administrator of the device. | - -**Example** - -```js -let wantTemp = { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", -}; -let enterpriseInfo = { - name: "enterprise name", - description: "enterprise description" -} -enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo).catch(error => { - console.log("error occurs" + error); -}); -``` - -## enterpriseDeviceManager.getEnterpriseInfo - -getEnterpriseInfo(admin: Want, callback: AsyncCallback<EnterpriseInfo>): void - -Obtains the enterprise information of a device administrator application. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ------------------------ | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application. | -| callback | AsyncCallback<[EnterpriseInfo](#enterpriseinfo)> | Yes | Callback used to return the enterprise information of the device administrator application.| - -**Error codes** - -| Type | Description | -| ------- | ----------------------------------------------------- | -| 9200001 | The application is not a administrator of the device. | - -**Example** - -```js -let wantTemp = { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", -}; -enterpriseDeviceManager.getEnterpriseInfo(wantTemp, (error, result) => { - if (error != null) { - console.log("error occurs" + error); - return; - } - console.log(result.name); - console.log(result.description); -}); -``` - -## enterpriseDeviceManager.getEnterpriseInfo - -getEnterpriseInfo(admin: Want): Promise<EnterpriseInfo> - -Obtains the enterprise information of a device administrator application. This API uses a promise to return the result. - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application.| - -**Return value** - -| Type | Description | -| ---------------------------------------- | ------------------------- | -| Promise<[EnterpriseInfo](#enterpriseinfo)> | Promise used to return the enterprise information of the device administrator application.| - -**Error codes** - -| Type | Description | -| ------- | ----------------------------------------------------- | -| 9200001 | The application is not a administrator of the device. | - -**Example** - -```js -let wantTemp = { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", -}; -enterpriseDeviceManager.getEnterpriseInfo(wantTemp).then((result) => { - console.log(result.name); - console.log(result.description); -}).catch(error => { - console.log("error occurs" + error); -}); -``` - -## enterpriseDeviceManager.subscribeManagedEvent - -subscribeManagedEvent(admin: Want, managedEvents: Array\, callback: AsyncCallback\): void - -Subscribes to system management events. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application.| -| managedEvents | Array\<[ManagedEvent](#managedevent)> | Yes| Array of events to subscribe to.| -| callback | AsyncCallback\ | Yes| Callback used to return the result. If the subscription is successful, **err** is **null**. Otherwise, **err** is an error object.| - -**Example** - -```js -let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", -}; -let events = [0, 1]; -enterpriseDeviceManager.subscribeManagedEvent(wantTemp, events, (error) => { - if (error) { - console.log("error code:" + error.code + " error message:" + error.message); - } -}); -``` - -## enterpriseDeviceManager.subscribeManagedEvent - -subscribeManagedEvent(admin: Want, managedEvents: Array\): Promise\ - -Subscribes to system management events. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application.| -| managedEvents | Array\<[ManagedEvent](#managedevent)> | Yes| Array of events to subscribe to.| - -**Return value** - -| Type | Description | -| ----- | ----------------------------------- | -| Promise\ | Promise used to return the result. Promise that returns no value.| - -**Example** - -```js -let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", -}; -let events = [0, 1]; -enterpriseDeviceManager.subscribeManagedEvent(wantTemp, events).then(() => { -}).catch((error) => { - console.log("error code:" + error.code + " error message:" + error.message); -}) -``` - -## enterpriseDeviceManager.unsubscribeManagedEvent - -unsubscribeManagedEvent(admin: Want, managedEvents: Array\, callback: AsyncCallback\): void - -Unsubscribes from system management events. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application.| -| managedEvents | Array\<[ManagedEvent](#managedevent)> | Yes| Array of events to unsubscribe from.| -| callback | AsyncCallback\ | Yes| Callback used to return the result. If the unsubscription is successful, **err** is **null**. Otherwise, **err** is an error object.| - -**Example** - -```js -let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", -}; -let events = [0, 1]; -enterpriseDeviceManager.unsubscribeManagedEvent(wantTemp, events, (error) => { - if (error) { - console.log("error code:" + error.code + " error message:" + error.message); - } -}); -``` - -## enterpriseDeviceManager.unsubscribeManagedEvent - -unsubscribeManagedEvent(admin: Want, managedEvents: Array\): Promise\ - -Unsubscribes from system management events. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application.| -| managedEvents | Array\<[ManagedEvent](#managedevent)> | Yes| Array of events to unsubscribe from.| - -**Return value** - -| Type | Description | -| ----- | ----------------------------------- | -| Promise\ | Promise used to return the result. Promise that returns no value.| - -**Example** - -```js -let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", -}; -let events = [0, 1]; -enterpriseDeviceManager.unsubscribeManagedEvent(wantTemp, events).then(() => { -}).catch((error) => { - console.log("error code:" + error.code + " error message:" + error.message); -}) -``` - -## EnterpriseInfo - -Describes the enterprise information of a device administrator application. - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -| Name | Readable/Writable| Type | Mandatory | Description | -| ----------- | ---- | ------ | ---- | ----------------- | -| name | Read only | string | Yes | Name of the enterprise to which the device administrator application belongs.| -| description | Read only | string | Yes | Description of the enterprise to which the device administrator application belongs.| - -## AdminType - -Enumerates the administrator types of the device administrator application. - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -| Name | Default Value | Description | -| ----------------- | ---- | ----- | -| ADMIN_TYPE_NORMAL | 0x00 | Common administrator.| -| ADMIN_TYPE_SUPER | 0x01 | Super administrator.| - -## ManagedEvent - -Enumerates the system management events that can be subscribed to. - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -| Name | Default Value | Description | -| ----------------- | ---- | ----- | -| MANAGED_EVENT_BUNDLE_ADDED | 0 | Application installation event.| -| MANAGED_EVENT_BUNDLE_REMOVED | 1 | Application uninstallation event.| diff --git a/en/application-dev/reference/apis/js-apis-enterpriseDeviceManager-DeviceSettingsManager.md b/en/application-dev/reference/apis/js-apis-enterpriseDeviceManager-DeviceSettingsManager.md deleted file mode 100644 index cd5f8fb479..0000000000 --- a/en/application-dev/reference/apis/js-apis-enterpriseDeviceManager-DeviceSettingsManager.md +++ /dev/null @@ -1,123 +0,0 @@ -# Device Settings Management - -The **EnterpriseDeviceManager** module provides capabilities to manage device settings, such as time settings. The APIs of this module can only be called by enterprise device administrator 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. - -## Usage - -Before calling any API in **EnterpriseDeviceManager**, use **getDeviceSettingsManager** to create an **EnterpriseDeviceManager** instance. - -```js -import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager' - -enterpriseDeviceManager.getDeviceSettingsManager((error, mgr) => { - if (error) { - console.log("error code:" + error.code + " error message:" + error.message); - return; - } - let deviceMgr = mgr; -}); -``` - -## DeviceSettingsManager.setDateTime - -setDateTime(admin: Want, time: number, callback: AsyncCallback\): void - -Sets the system time. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.ENTERPRISE_SET_DATETIME - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application.| -| time | number | Yes| Timestamp (ms).| -| callback | AsyncCallback\ | Yes| Callback used to the result. If the system time is set successfully, **err** is **null**; otherwise, **err** is an error object.| - -**Error codes** - -| Type | Description | -| ------- | ---------------------------------------------------------------------------- | -| 9200001 | The application is not a administrator of the device. | -| 9200002 | The administrator application does not have permission to manage the device. | - -**Example** - -```js -import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager' - -let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", -}; -enterpriseDeviceManager.getDeviceSettingsManager((error, mgr) => { - if (error) { - console.log("error code:" + error.code + " error message:" + error.message); - return; - } - mgr.setDateTime(wantTemp, 1526003846000, (error) => { - if (error) { - console.log("error code:" + error.code + " error message:" + error.message); - } - }); -}); -``` - -## DeviceSettingsManager.setDateTime - -setDateTime(admin: Want, time: number): Promise\ - -Sets the system time. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.ENTERPRISE_SET_DATETIME - -**System capability**: SystemCapability.Customization.EnterpriseDeviceManager - -**System API**: This is a system API. - -**Parameters** - -| Name | Type | Mandatory | Description | -| ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-application-Want.md) | Yes | Device administrator application.| -| time | number | Yes| Timestamp (ms).| - -**Return value** - -| Type | Description | -| ----- | ----------------------------------- | -| Promise\ | Promise that returns no value.| - -**Error codes** - -| Type | Description | -| ------- | ---------------------------------------------------------------------------- | -| 9200001 | The application is not a administrator of the device. | -| 9200002 | The administrator application does not have permission to manage the device. | - -**Example** - -```js -import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager' - -let wantTemp = { - bundleName: "bundleName", - abilityName: "abilityName", -}; -enterpriseDeviceManager.getDeviceSettingsManager().then((mgr) => { - mgr.setDateTime(wantTemp, 1526003846000).then(() => { - }).catch((error) => { - console.log("error code:" + error.code + " error message:" + error.message); - }) -}).catch((error) => { - console.log("error code:" + error.code + " error message:" + error.message); -}) -``` diff --git a/en/application-dev/reference/apis/js-apis-freeInstall.md b/en/application-dev/reference/apis/js-apis-freeInstall.md new file mode 100644 index 0000000000..76fb053e5c --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-freeInstall.md @@ -0,0 +1,422 @@ +# Bundle.freeInstall + +The **Bundle.freeInstall** module provides APIs for setting and obtaining installation-free information and APIs for obtaining **BundlePackInfo** and **DispatchInfo**. + +> **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 + +```js +import freeInstall from '@ohos.bundle.freeInstall'; +``` + +## Required Permissions + +| Permission | Permission Level | Description | +| ------------------------------------------ | ------------ | ------------------ | +| 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. | + +For details, see [Permission Levels](../../security/accesstoken-overview.md#permission-levels). +## UpgradeFlag + +**System API**: This is a system API. + +**System capability**: SystemCapability.BundleManager.BundleFramework.FreeInstall + +| Name | Value | Description | +| ---------------- | ---- | ---------------- | +| NOT_UPGRADE | 0 | No module needs an upgrade. | +| SINGLE_UPGRADE | 1 | A single module needs an upgrade.| +| RELATION_UPGRADE | 2 | The module that has a relationship with the current one needs an upgrade.| + +## BundlePackFlag + +**System API**: This is a system API. + +**System capability**: SystemCapability.BundleManager.BundleFramework.FreeInstall + +| Name | Value | Description | +| ------------------ | ---------- | ---------------------------------- | +| GET_PACK_INFO_ALL | 0x00000000 | All information in the **pack.info** file. | +| GET_PACKAGES | 0x00000001 | Package information in the **pack.info** file.| +| GET_BUNDLE_SUMMARY | 0x00000002 | Bundle summary information in the **pack.info** file. | +| GET_MODULE_SUMMARY | 0x00000004 | Module summary information in the **pack.info** file. | + +## freeInstall.setHapModuleUpgradeFlag + +setHapModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag, callback: AsyncCallback\):void; + +Sets an upgrade flag for a module. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.INSTALL_BUNDLE + +**System API**: This is a system API. + +**System capability**: SystemCapability.BundleManager.BundleFramework.FreeInstall + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | ---------------------------- | +| bundleName | string | Yes | Bundle name. | +| moduleName | string | Yes | Module name. | +| upgradeFlag | [UpgradeFlag](#upgradeflag) | Yes | Upgrade flag, which is for internal use only. | +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, **err** is **null**; otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +|----------|---------------------------------------- | +| 17700001 | The specified bundle name is not found. | +| 17700002 | The specified module name is not found. | + +**Example** + +```js +import freeInstall from '@ohos.bundle.freeInstall'; +let bundleName = 'com.example.myapplication'; +let moduleName = 'entry'; +let upgradeFlag = freeInstall.UpgradeFlag.SINGLE_UPGRADE; +try { + freeInstall.setHapModuleUpgradeFlag(bundleName, moduleName, upgradeFlag, err => { + if (err) { + console.error('Operation failed:' + JSON.stringify(err)); + } else { + console.info('Operation succeed'); + } + }); +} catch (err) { + console.error('Operation failed:' + JSON.stringify(err)); +} +``` + +## setHapModuleUpgradeFlag + +setHapModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag): Promise\; + +Sets an upgrade flag for a module. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.INSTALL_BUNDLE + +**System capability**: SystemCapability.BundleManager.BundleFramework.FreeInstall + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | ---------------------- | +| bundleName | string | Yes | Bundle name. | +| moduleName | string | Yes | Module name. | +| upgradeFlag | [UpgradeFlag](#upgradeflag) | Yes | Upgrade flag, which is for internal use only.| + +**Return value** + +| Type | Description | +| ------------- | ------------------------------------ | +| Promise\ | Promise that returns no value.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +|----------|----------------------------------------| +| 17700001 | The specified bundle name is not found. | +| 17700002 | The specified module name is not found. | + +**Example** + +```js +import freeInstall from '@ohos.bundle.freeInstall'; +let bundleName = 'com.example.myapplication'; +let moduleName = 'entry'; +let upgradeFlag = freeInstall.UpgradeFlag.SINGLE_UPGRADE; +try { + freeInstall.setHapModuleUpgradeFlag(bundleName, moduleName, upgradeFlag).then(() => { + console.info('Operation succeed') + }).catch(err => { + console.error('Operation failed:' + JSON.stringify(err)); + }); +} catch (err) { + console.error('Operation failed:' + JSON.stringify(err)); +} +``` + +## isHapModuleRemovable + +isHapModuleRemovable(bundleName: string, moduleName: string, callback: AsyncCallback\): void; + +Checks whether a module can be removed. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.FreeInstall + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ---------------------- | ---- | --------------------------------------------- | +| bundleName | string | Yes | Bundle name. | +| moduleName | string | Yes | Module name. | +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the module can be removed, **true** is returned; otherwise, **false** is returned.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +|----------|----------------------------------------| +| 17700001 | The specified bundle name is not found. | +| 17700002 | The specified module name is not found. | + +**Example** + +```js +import freeInstall from '@ohos.bundle.freeInstall'; +let bundleName = 'com.example.myapplication'; +let moduleName = 'entry'; +try { + freeInstall.isHapModuleRemovable(bundleName, moduleName, (err, data) => { + if (err) { + console.error('Operation failed:' + JSON.stringify(err)); + } else { + console.info('Operation succeed:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('Operation failed:' + JSON.stringify(err)); +} +``` + +## isHapModuleRemovable + +isHapModuleRemovable(bundleName: string, moduleName: string): Promise\; + +Checks whether a module can be removed. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.FreeInstall + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | ------------------ | +| bundleName | string | Yes | Bundle name. | +| moduleName | string | Yes | Module name.| + +**Return value** + +| Type | Description | +| ---------------- | ---------------------------- | +| Promise\ | Promise used to return the result. If the module can be removed, **true** is returned; otherwise, **false** is returned.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +|----------|----------------------------------------| +| 17700001 | The specified bundle name is not found. | +| 17700002 | The specified module name is not found. | + +**Example** + +```js +import freeInstall from '@ohos.bundle.freeInstall'; +let bundleName = 'com.example.myapplication'; +let moduleName = 'entry'; +try { + freeInstall.isHapModuleRemovable(bundleName, moduleName).then(data => { + console.info('Operation succeed:' + JSON.stringify(data)); + }).catch(err => { + console.error('Operation failed:' + JSON.stringify(err)); + }); +} catch (err) { + console.error('Operation failed:' + JSON.stringify(err)); +} +``` + +## getBundlePackInfo + +getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag, callback: AsyncCallback\): void; + +Obtains **bundlePackInfo** based on **bundleName** and **bundlePackFlag**. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.FreeInstall + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| bundleName | string | Yes | Bundle name. | +| bundlePackFlag | [BundlePackFlag](#bundlepackflag) | Yes | Flag of the bundle package. | +| callback | AsyncCallback<[BundlePackInfo](js-apis-bundleManager-packInfo.md)> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the **BundlePackInfo** object obtained; otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +|----------|----------------------------------------| +| 17700001 | The specified bundle name is not found. | + +**Example** + +```js +import freeInstall from '@ohos.bundle.freeInstall'; +let bundleName = 'com.example.myapplication'; +let bundlePackFlag = freeInstall.BundlePackFlag.GET_PACK_INFO_ALL; +try { + freeInstall.getBundlePackInfo(bundleName, bundlePackFlag, (err, data) => { + if (err) { + console.error('Operation failed:' + JSON.stringify(err)); + } else { + console.info('Operation succeed:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('Operation failed:' + JSON.stringify(err)); +} +``` +## getBundlePackInfo + +getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag): Promise\; + +Obtains **bundlePackInfo** based on **bundleName** and **bundlePackFlag**. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.FreeInstall + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------- | --------------------------------- | ---- | ---------------------- | +| bundleName | string | Yes | Bundle name. | +| bundlePackFlag | [BundlePackFlag](#bundlepackflag) | Yes | Flag of the bundle package.| + +**Return value** + +| Type | Description | +| ---------------------------------------------------------- | ----------------------------------- | +| Promise<[BundlePackInfo](js-apis-bundleManager-packInfo.md)> | Promise used to return the **BundlePackInfo** object obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +|----------|----------------------------------------| +| 17700001 | The specified bundle name is not found. | + +**Example** + +```js +import freeInstall from '@ohos.bundle.freeInstall'; +let bundleName = 'com.example.myapplication'; +let bundlePackFlag = freeInstall.BundlePackFlag.GET_PACK_INFO_ALL; +try { + freeInstall.getBundlePackInfo(bundleName, bundlePackFlag).then(data => { + console.info('Operation succeed:' + JSON.stringify(data)); + }).catch(err => { + console.error('Operation failed:' + JSON.stringify(err)); + }); +} catch (err) { + console.error('Operation failed:' + JSON.stringify(err)); +} +``` + +## getDispatchInfo + +getDispatchInfo(callback: AsyncCallback\): void; + +Obtains the dispatch information. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.FreeInstall + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback<[DispatchInfo](js-apis-bundleManager-dispatchInfo.md)> | Yes | Callback used to return the result. If the operation is successful, **err** is **null**, and **data** is the [DispatchInfo](js-apis-bundleManager-dispatchInfo.md) object obtained. otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +**Example** + +```js +import freeInstall from '@ohos.bundle.freeInstall'; +try { + freeInstall.getDispatchInfo((err, data) => { + if (err) { + console.error('Operation failed:' + JSON.stringify(err)); + } else { + console.info('Operation succeed:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('Operation failed:' + JSON.stringify(err)); +} +``` + +## getDispatchInfo + +getDispatchInfo(): Promise\; + +Obtains the dispatch information. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.BundleFramework.FreeInstall + +**Return value** + +| Type | Description | +| ------------------------------------------------ | ------------------------------------------------------------ | +| Promise<[DispatchInfo](js-apis-bundleManager-dispatchInfo.md)> | Promise used to return the [DispatchInfo](js-apis-bundleManager-dispatchInfo.md) object obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +**Example** + +```js +import freeInstall from '@ohos.bundle.freeInstall'; +try { + freeInstall.getDispatchInfo().then(data => { + console.info('Operation succeed:' + JSON.stringify(data)); + }).catch(err => { + console.error('Operation failed:' + JSON.stringify(err)); + }); +} catch (err) { + console.error('Operation failed:' + JSON.stringify(err)); +} +``` diff --git a/en/application-dev/reference/apis/js-apis-installer.md b/en/application-dev/reference/apis/js-apis-installer.md new file mode 100644 index 0000000000..16db4d2391 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-installer.md @@ -0,0 +1,300 @@ +# BundleInstaller + +The **BundleInstaller** module provides APIs for you to install, uninstall, and recover bundles on devices. + +> **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 installer from '@ohos.bundle.installer'; +``` + +## Required Permissions + +| Permission | Permission Level | Description | +| ------------------------------ | ----------- | ---------------- | +| ohos.permission.INSTALL_BUNDLE | system_core | Permission to install or uninstall bundles.| + +For details, see in [Permission Levels](../../security/accesstoken-overview.md#permission-levels). + +## BundleInstaller.getBundleInstaller + +getBundleInstaller(callback: AsyncCallback\): void; + +Obtains a **BundleInstaller** object. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API and cannot be called by third-party applications. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback\<[BundleInstaller](js-apis-installer.md#BundleInstaller)> | Yes | Callback used to return the result. If the operation is successful, **err** is undefined and **data** is the **BundleInstaller** object obtained; otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +**Example** + +```ts +import installer from '@ohos.bundle.installer'; + +try { + installer.getBundleInstaller((err, data) => { + if (err) { + console.error('getBundleInstaller failed:' + err.message); + } else { + console.info('getBundleInstaller successfully'); + } + }); +} catch (error) { + console.error('getBundleInstaller failed:' + error.message); +} +``` + +## BundleInstaller.getBundleInstaller + +getBundleInstaller(): Promise\; + +Obtains a **BundleInstaller** object. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API and cannot be called by third-party applications. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Return value** +| Type | Description | +| ------------------------------------------------------------ | ------------------------------------ | +| Promise\<[BundleInstaller](js-apis-installer.md#BundleInstaller)> | Promise used to return the **BundleInstaller** object obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +**Example** + +```ts +import installer from '@ohos.bundle.installer'; + +try { + installer.getBundleInstaller().then((data) => { + console.info('getBundleInstaller successfully.'); + }).catch((error) => { + console.error('getBundleInstaller failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getBundleInstaller failed. Cause: ' + error.message); +} +``` + +## BundleInstaller.install +install(hapFilePaths: Array<string>, installParam: InstallParam, callback: AsyncCallback<void>): void; + +Installs a bundle. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API and cannot be called by third-party applications. + +**Required permissions**: ohos.permission.INSTALL_BUNDLE + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | +| hapFilePaths | Array<string> | Yes | Paths where the HAP files of the bundle are stored, which are the data directories. If only one directory is passed, the HAP files in the directory must belong to the same bundle and have the same signature.| +| installParam | [InstallParam](#installparam) | Yes | Parameters required for the installation. | +| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is undefined; otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ------------------------------------------------------------ | +| 17700004 | The specified user ID is not found. | +| 17700010 | Failed to install the HAP because the HAP fails to be parsed. | +| 17700011 | Failed to install the HAP because the HAP signature fails to be verified. | +| 17700012 | Failed to install the HAP because the HAP path is invalid or the HAP is too large. | +| 17700015 | Failed to install the HAPs because they have different configuration information. | +| 17700016 | Failed to install the HAP because of insufficient system disk space. | +| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. | +| 17700101 | The system service is excepted. | +| 17700103 | I/O operation is failed. | + +**Example** + +```ts +import installer from '@ohos.bundle.installer'; +let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/']; +let installParam = { + userId: 100, + isKeepData: false, + installFlag: 1, +}; + +try { + installer.getBundleInstaller().then(data => { + data.install(hapFilePaths, installParam, err => { + if (err) { + console.error('install failed:' + err.message); + } else { + console.info('install successfully.'); + } + }); + }).catch(error => { + console.error('getBundleInstaller failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getBundleInstaller failed. Cause: ' + error.message); +} +``` + +## BundleInstaller.uninstall + +uninstall(bundleName: string, installParam: InstallParam, callback: AsyncCallback<void>): void; + +Uninstalls a bundle. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API and cannot be called by third-party applications. + +**Required permissions**: ohos.permission.INSTALL_BUNDLE + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | +| bundleName | string | Yes | Name of the target bundle. | +| installParam | [InstallParam](#installparam) | Yes | Parameters required for the installation. | +| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is undefined; otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ------------------------------------------------------------ | +| 17700004 | The specified user ID is not found. | +| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. | +| 17700101 | The system service is excepted. | + +**Example** + +```ts +import installer from '@ohos.bundle.installer'; +let bundleName = 'com.ohos.demo'; +let installParam = { + userId: 100, + isKeepData: false, + installFlag: 1 +}; + +try { + installer.getBundleInstaller().then(data => { + data.uninstall(bundleName, installParam, err => { + if (err) { + console.error('uninstall failed:' + err.message); + } else { + console.info('uninstall successfully.'); + } + }); + }).catch(error => { + console.error('getBundleInstaller failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getBundleInstaller failed. Cause: ' + error.message); +} +``` + +## BundleInstaller.recover + +recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback<void>): void; + +Recovers a bundle. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API and cannot be called by third-party applications. + +**Required permissions**: ohos.permission.INSTALL_BUNDLE + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | +| bundleName | string | Yes | Name of the target bundle. | +| installParam | [InstallParam](#installparam) | Yes | Parameters required for the installation. | +| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is undefined; otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ----------------------------------- | +| 17700004 | The specified user ID is not found. | + +**Example** + +```ts +import installer from '@ohos.bundle.installer'; +let bundleName = 'com.ohos.demo'; +let installParam = { + userId: 100, + isKeepData: false, + installFlag: 1 +}; + +try { + installer.getBundleInstaller().then(data => { + data.recover(bundleName, installParam, err => { + if (err) { + console.error('recover failed:' + err.message); + } else { + console.info('recover successfully.'); + } + }); + }).catch(error => { + console.error('getBundleInstaller failed. Cause: ' + error.message); + }); +} catch (error) { + console.error('getBundleInstaller failed. Cause: ' + error.message); +} +``` + +## HashParam + +Defines the hash parameters for bundle installation and uninstall. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + + **System API**: This is a system API and cannot be called by third-party applications. + +| Name | Type | Description | +| ---------- | ------ | ---------------- | +| moduleName | string | Module name of the bundle.| +| hashValue | string | Hash value. | + +## InstallParam + +Defines the parameters that need to be specified for bundle installation, uninstall, or recovering. + + **System capability**: SystemCapability.BundleManager.BundleFramework.Core + + **System API**: This is a system API and cannot be called by third-party applications. + +| Name | Type | Description | +| ------------------------------ | ------------------------------ | ------------------ | +| userId | number | User ID. You can use [queryOsAccountLocalIdFromProcess](js-apis-osAccount.md#queryosaccountlocalidfromprocess9) to obtain the user of the current process.| +| installFlag | number | Installation flag. The value **0** means initial installation and **1** means overwrite installation.| +| isKeepData | boolean | Whether to retain the data directory during bundle uninstall.| +| hashParams | Array<[HashParam](#hashparam)> | Hash parameters. | +| crowdtestDeadline| number |End date of crowdtesting.| diff --git a/en/application-dev/reference/apis/js-apis-launcherBundleManager.md b/en/application-dev/reference/apis/js-apis-launcherBundleManager.md new file mode 100644 index 0000000000..f149c30d7a --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-launcherBundleManager.md @@ -0,0 +1,304 @@ +# Bundle.launcherBundleManager + +The **Bundle.launcherBundleManager** module providers APIs for the **Home Screen** application to obtain the launcher ability information and shortcut 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 launcherBundleManager from '@ohos.bundle.launcherBundleManager'; +``` + + +## launcherBundlemanager.getLauncherAbilityInfo9+ + +getLauncherAbilityInfo(bundleName: string, userId: number, callback: AsyncCallback>) : void; + +Obtains the launcher ability information based on the given bundle name and user ID. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System API**: This is a system API. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | -------------- | +| bundleName | string | Yes | Bundle name of the application.| +| userId | number | Yes | User ID.| + +**Return value** + +| Type | Description | +| ----------------------------------- | --------------------------------------------------- | +| AsyncCallback\> | Callback used to return the **LauncherAbilityInfo** object obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ---------------------------------------- | +| 17700001 | The specified bundle name is not found. | +| 17700004 | The specified userId is not found. | + +**Example** + +```ts +import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; + +try { + launcherBundleManager.getLauncherAbilityInfo('com.example.demo', 100, (errData, data) => { + if (errData !== null) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); + } + console.log("data is " + JSON.stringify(data)); + }) +} catch (errData) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); +} +``` + +## launcherBundlemanager.getLauncherAbilityInfo9+ + +getLauncherAbilityInfo(bundleName: string, userId: number) : Promise>; + +Obtains the launcher ability information based on the given bundle name and user ID. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System API**: This is a system API. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | -------------- | +| bundleName | string | Yes | Bundle name of the application.| +| userId | number | Yes | User ID.| + +**Return value** + +| Type | Description | +| ----------------------------- | -------------------------------------------------- | +| Promise\> | Promise used to return the **LauncherAbilityInfo** object obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ---------------------------------------- | +| 17700001 | The specified bundle name is not found. | +| 17700004 | The specified userId is not found. | + +**Example** + +```typescript +import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; + +try { + launcherBundleManager.getLauncherAbilityInfo("com.example.demo", 100).then(data => { + console.log("data is " + JSON.stringify(data)); + }).catch (errData => { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); + }) +} catch (errData) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); +} +``` + +## launcherBundlemanager.getAllLauncherAbilityInfo9+ + +getAllLauncherAbilityInfo(userId: number, callback: AsyncCallback>) : void; + +Obtains the launcher ability information of all applications based on the given user ID. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System API**: This is a system API. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------- | +| userId | number | Yes | User ID.| + +**Return value** + +| Type | Description | +| ----------------------------------- | ------------------------------------------------------- | +| AsyncCallback\> | Callback used to return the array of **LauncherAbilityInfo** objects obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ---------------------------------------- | +| 17700004 | The specified userId is not found. | + +Example + +```ts +import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; + +try { + launcherBundleManager.getAllLauncherAbilityInfo(100, (errData, data) => { + if (errData !== null) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); + } + console.log("data is " + JSON.stringify(data)); + }); +} catch (errData) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); +} +``` +## launcherBundlemanager.getAllLauncherAbilityInfo9+ + +getAllLauncherAbilityInfo(userId: number) : Promise>; + +Obtains the launcher ability information of all applications based on the given user ID. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System API**: This is a system API. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------- | +| userId | number | Yes | User ID.| + +**Return value** + +| Type | Description | +| ----------------------------- | ------------------------------------------------------ | +| Promise\> | Promise used to return the array of **LauncherAbilityInfo** objects obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ---------------------------------------- | +| 17700004 | The specified userId is not found. | + +**Example** + +```ts +import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; + +try { + launcherBundleManager.getAllLauncherAbilityInfo(100).then(data => { + console.log("data is " + JSON.stringify(data)); + }).catch (errData => { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); + }); +} catch (errData) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); +} +``` + +## launcherBundlemanager.getShortcutInfo9+ + +getShortcutInfo(bundleName :string, callback: AsyncCallback>) : void; + +Obtains the shortcut information of the current user based on the given bundle name. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System API**: This is a system API. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | -------------- | +| bundleName | string | Yes | Bundle name of the application.| + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| AsyncCallback\> | Callback used to return the **ShortcutInfo** object obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ---------------------------------------- | +| 17700001 | The specified bundle name is not found. | + +**Example** + +```ts +import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; + +try { + launcherBundleManager.getShortcutInfo("com.example.demo", (errData, data) => { + if (errData !== null) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); + } + console.log("data is " + JSON.stringify(data)); + }); +} catch (errData) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); +} +``` + +## launcherBundlemanager.getShortcutInfo9+ + +getShortcutInfo(bundleName : string) : Promise>; + +Obtains the shortcut information of the current user based on the given bundle name. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System API**: This is a system API. + +**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | -------------- | +| bundleName | string | Yes | Bundle name of the application.| + +**Return value** + +| Template | Description | +| ---------------------- | ----------------------------------------------- | +| Promise\> | Promise used to return the **ShortcutInfo** object obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md). + +| ID| Error Message | +| -------- | ---------------------------------------- | +| 17700001 | The specified bundle name is not found. | + +**Example** + +```ts +import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; + +try { + launcherBundleManager.getShortcutInfo("com.example.demo").then(data => { + console.log("data is " + JSON.stringify(data)); + }).catch (errData => { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); + }); +} catch (errData) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); +} +``` diff --git a/en/application-dev/reference/apis/js-apis-net-policy.md b/en/application-dev/reference/apis/js-apis-net-policy.md deleted file mode 100644 index 4537266a60..0000000000 --- a/en/application-dev/reference/apis/js-apis-net-policy.md +++ /dev/null @@ -1,1120 +0,0 @@ -# Network Policy Management - -The Network Policy Management module provides APIs for managing network policies, through which you can control and manage the data volume used. - -> **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 policy from '@ohos.net.policy' -``` - -## policy.setBackgroundPolicy - -setBackgroundPolicy(isAllowed: boolean, callback: AsyncCallback\): void - -Sets a background network policy. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| isAllowed | boolean | Yes | Whether applications running in the background are allowed to use mobile data.| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -policy.setBackgroundPolicy(Boolean(Number.parseInt(this.isBoolean))), (err, data) => { - this.callBack(err, data); - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}); -``` - -## policy.setBackgroundPolicy - -setBackgroundPolicy(isAllowed: boolean): Promise\ - -Sets a background network policy. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| isAllowed | boolean | Yes | Whether applications running in the background are allowed to use mobile data.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -policy.setBackgroundPolicy(Boolean(Number.parseInt(this.isBoolean))).then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) -``` - -## policy.getBackgroundPolicy - -getBackgroundPolicy(callback: AsyncCallback\): void; - -Obtains the background network policy. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result. If **true** is returned, applications running in the background are allowed to use mobile data.| - -**Example** - -```js -policy.getBackgroundPolicy((err, data) => { - this.callBack(err, data); - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}); -``` - -## policy.getBackgroundPolicy - -getBackgroundPolicy(): Promise\; - -Obtains the background network policy. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -policy.getBackgroundPolicy().then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) - -``` - -## policy.setPolicyByUid - -setPolicyByUid(uid: number, policy: NetUidPolicy, callback: AsyncCallback\): void; - -Sets an application-specific network policy. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes | Unique ID of the application.| -| policy | [NetUidPolicy](#netuidpolicy) | Yes| Application-specific network policy to set.| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), policy: Number.parseInt(this.currentNetUidPolicy) -} -policy.setPolicyByUid(Number.parseInt(this.firstParam), Number.parseInt(this.currentNetUidPolicy), (err, data) => { - this.callBack(err, data); -}); -``` - -## policy.setPolicyByUid - -setPolicyByUid(uid: number, policy: NetUidPolicy): Promise\; - -Sets an application-specific network policy. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes | Unique ID of the application.| -| policy | [NetUidPolicy](#netuidpolicy) | Yes| Application-specific network policy to set.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), policy: Number.parseInt(this.currentNetUidPolicy) -} -policy.setPolicyByUid(Number.parseInt(this.firstParam), Number.parseInt(this.currentNetUidPolicy)).then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) - -``` - -## policy.getPolicyByUid - -getPolicyByUid(uid: number, callback: AsyncCallback\): void; - -Obtains an application-specific network policy by **uid**. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| callback | AsyncCallback\<[NetUidPolicy](#netuidpolicy)> | Yes | Callback used to return the result.| - -**Example** - -```js -policy.getPolicyByUid(Number.parseInt(this.firstParam), (err, data) => { - this.callBack(err, data); -}); -``` - -## policy.getPolicyByUid - -getPolicyByUid(uid: number): Promise\; - -Obtains an application-specific network policy by **uid**. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\<[NetUidPolicy](#netuidpolicy)> | Promise used to return the result.| - -**Example** - -```js -policy.getPolicyByUid(Number.parseInt(this.firstParam)).then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) - -``` - -## policy.getUidsByPolicy - -getUidsByPolicy(policy: NetUidPolicy, callback: AsyncCallback\>): void; - -Obtains the UID array of applications configured with a certain application-specific network policy. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| policy | [NetUidPolicy](#netuidpolicy) | Yes| Target application-specific network policy.| -| callback | AsyncCallback\> | Yes | Callback used to return the result.| - -**Example** - -```js -policy.getUidsByPolicy(Number.parseInt(this.currentNetUidPolicy), (err, data) => { - this.callBack(err, data); -}); -``` - -## policy.getUidsByPolicy - -function getUidsByPolicy(policy: NetUidPolicy): Promise\>; - -Obtains the UID array of applications configured with a certain application-specific network policy. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| policy | [NetUidPolicy](#netuidpolicy) | Yes| Target application-specific network policy.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\> | Promise used to return the result.| - -**Example** - -```js -policy.getUidsByPolicy(Number.parseInt(this.firstParam)).then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) - -``` - -## policy.getNetQuotaPolicies - -getNetQuotaPolicies(callback: AsyncCallback\>): void; - -Obtains the network quota policies. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\> | Yes | Callback used to return the result.| - -**Example** - -```js -policy.getNetQuotaPolicies((err, data) => { - this.callBack(err, data); -}); -``` - -## policy.getNetQuotaPolicies - -getNetQuotaPolicies(): Promise\>; - -Obtains the network quota policies. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\> | Promise used to return the result.| - -**Example** - -```js -policy.getNetQuotaPolicies().then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) - -``` - -## policy.setNetQuotaPolicies - -setNetQuotaPolicies(quotaPolicies: Array\, callback: AsyncCallback\): void; - -Sets an array of network quota policies. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| quotaPolicies | Array\<[NetQuotaPolicy](#netquotapolicy)> | Yes| An array of network quota policies to set.| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -let param = {netType:Number.parseInt(this.netType), iccid:this.iccid, ident:this.ident, periodDuration:this.periodDuration, warningBytes:Number.parseInt(this.warningBytes), - limitBytes:Number.parseInt(this.limitBytes), lastWarningRemind:this.lastWarningRemind, lastLimitRemind:this.lastLimitRemind, metered:Boolean(Number.parseInt(this.metered)), limitAction:this.limitAction}; -this.netQuotaPolicyList.push(param); - -policy.setNetQuotaPolicies(this.netQuotaPolicyList, (err, data) => { - this.callBack(err, data); -}); -``` - -## policy.setNetQuotaPolicies - -setNetQuotaPolicies(quotaPolicies: Array\): Promise\; - -Sets an array of network quota policies. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| quotaPolicies | Array\<[NetQuotaPolicy](#netquotapolicy)> | Yes| An array of network quota policies to set.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -let param = {netType:Number.parseInt(this.netType), iccid:this.iccid, ident:this.ident, periodDuration:this.periodDuration, warningBytes:Number.parseInt(this.warningBytes), - limitBytes:Number.parseInt(this.limitBytes), lastWarningRemind:this.lastWarningRemind, lastLimitRemind:this.lastLimitRemind, metered:Boolean(Number.parseInt(this.metered)), limitAction:this.limitAction}; -this.netQuotaPolicyList.push(param); - -policy.setNetQuotaPolicies(this.netQuotaPolicyList).then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) -``` - -## policy.restoreAllPolicies - -restoreAllPolicies(iccid: string, callback: AsyncCallback\): void; - -Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| iccid | string | Yes| SIM card ID.| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -this.firstParam = iccid; -policy.restoreAllPolicies(this.firstParam, (err, data) => { - this.callBack(err, data); -}); -``` - -## policy.restoreAllPolicies - -restoreAllPolicies(iccid: string): Promise\; - -Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| iccid | string | Yes| SIM card ID.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -this.firstParam = iccid; -policy.restoreAllPolicies(this.firstParam).then((err, data){ - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) - -``` - -## policy.isUidNetAllowed - -isUidNetAllowed(uid: number, isMetered: boolean, callback: AsyncCallback\): void; - -Checks whether an application is allowed to access metered networks. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| isMetered | boolean | Yes| Whether the network is a metered network.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. The value **true** means that the application is allowed to access metered networks, and **false** means the opposite.| - -**Example** - -```js - -let param = { - uid: Number.parseInt(this.firstParam), isMetered: Boolean(Number.parseInt(this.isBoolean)) -} -policy.isUidNetAllowed(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (err, data) => { - this.callBack(err, data); -}); -``` - -## policy.isUidNetAllowed - -isUidNetAllowed(uid: number, isMetered: boolean): Promise\; - -Checks whether an application is allowed to access metered networks. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| isMetered | boolean | Yes| Whether the network is a metered network.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js - -let param = { - uid: Number.parseInt(this.firstParam), isMetered: Boolean(Number.parseInt(this.isBoolean)) -} -policy.isUidNetAllowed(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean))).then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) - -``` - -## policy.isUidNetAllowed - -isUidNetAllowed(uid: number, iface: string, callback: AsyncCallback\): void; - -Checks whether an application is allowed to access the given network. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| iface | string | Yes| Name of the target network.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. The value **true** means that the application is allowed to access the given network, and **false** means the opposite.| - -**Example** - -```js - -let param = { - uid: Number.parseInt(this.firstParam), iface: this.secondParam -} -policy.isUidNetAllowed(Number.parseInt(this.firstParam), this.secondParam, (err, data) => { - this.callBack(err, data); -}); -``` - -## policy.isUidNetAllowed - -isUidNetAllowed(uid: number, iface: string): Promise\; - -Checks whether an application is allowed to access the given network. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| iface | string | Yes| Name of the target network.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), iface: this.secondParam -} -policy.isUidNetAllowed(Number.parseInt(this.firstParam), this.secondParam).then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) - -``` - -## policy.setDeviceIdleAllowlist - -setDeviceIdleAllowList(uid: number, isAllowed: boolean, callback: AsyncCallback\): void; - -Sets whether to add an application to the device idle allowlist. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| isAllowed | boolean | Yes| Whether to add the application to the allowlist.| -| callback | callback: AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean)) -} -policy.setDeviceIdleAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (err, data) => { - this.callBack(err, data); -}); -``` - -## policy.setDeviceIdleAllowlist - -setDeviceIdleAllowList(uid: number, isAllowed: boolean): Promise\; - -Sets whether to add an application to the device idle allowlist. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| isAllowed | boolean | Yes| Whether to add the application to the allowlist.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -let param = { - uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean)) -} -policy.setDeviceIdleAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean))).then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) - -``` - -## policy.getDeviceIdleAllowlist - -getDeviceIdleAllowList(callback: AsyncCallback\>): void; - -Obtains the UID array of applications that are on the device idle allowlist. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\> | Yes | Callback used to return the result.| - -**Example** - -```js -policy.getDeviceIdleAllowList((err, data) => { - this.callBack(err, data); -}); -``` - -## policy.getDeviceIdleAllowlist - -getDeviceIdleAllowList(): Promise\>; - -Obtains the UID array of applications that are on the device idle allowlist. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\> | Promise used to return the result.| - -**Example** - -```js -policy.getDeviceIdleAllowList().then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) -``` - -## policy.getBackgroundPolicyByUid - -getBackgroundPolicyByUid(uid: number, callback: AsyncCallback\): void; - -Obtains the background network policies configured for the given application. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| -| callback | AsyncCallback\<[NetBackgroundPolicy](#netbackgroundpolicy)> | Yes | Callback used to return the result.| - -**Example** - -```js -this.firstParam = uid -policy.getBackgroundPolicyByUid(Number.parseInt(this.firstParam), (err, data) => { - this.callBack(err, data); -}); -``` - -## policy.getBackgroundPolicyByUid - -getBackgroundPolicyByUid(uid: number): Promise\; - -Obtains the background network policies configured for the given application. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes| Unique ID of the application.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\<[NetBackgroundPolicy](#netbackgroundpolicy)> | Promise used to return the result.| - -**Example** - -```js -this.firstParam = uid -policy.getBackgroundPolicyByUid(Number.parseInt(this.firstParam)).then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) -``` - -## policy.resetPolicies - -resetPolicies(iccid: string, callback: AsyncCallback\): void; - -Resets the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| iccid | string | Yes| SIM card ID.| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -this.firstParam = iccid -policy.resetPolicies(this.firstParam, (err, data) => { - this.callBack(err, data); -}); -``` - -## policy.resetPolicies - -resetPolicies(iccid: string): Promise\; - -Resets the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| iccid | string | Yes| SIM card ID.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -policy.getUidsByPolicy(Number.parseInt(this.firstParam)).then((err, data) { - -}) -this.firstParam = iccid -policy.resetPolicies(this.firstParam).then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) - -``` - -## policy.updateRemindPolicy - -updateRemindPolicy(netType: NetBearType, iccid: string, remindType: RemindType, callback: AsyncCallback\): void; - -Updates a reminder policy. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| netType | [NetBearType](js-apis-net-connection.md#netbeartype) | Yes| Network type.| -| iccid | string | Yes| SIM card ID.| -| remindType | [RemindType](#remindtype) | Yes| Reminder type.| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -let param = { - netType: Number.parseInt(this.netType), iccid: this.firstParam, remindType: this.currentRemindType -} -policy.updateRemindPolicy(Number.parseInt(this.netType), this.firstParam, Number.parseInt(this.currentRemindType), (err, data) => { - this.callBack(err, data); -}); -``` - -## policy.updateRemindPolicy - -updateRemindPolicy(netType: NetBearType, iccid: string, remindType: RemindType): Promise\; - -Updates a reminder policy. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| netType | [NetBearType](js-apis-net-connection.md#netbeartype) | Yes| Network type.| -| iccid | string | Yes| SIM card ID.| -| remindType | [RemindType](#remindtype) | Yes| Reminder type.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -let param = { - netType: Number.parseInt(this.netType), iccid: this.firstParam, remindType: this.currentRemindType -} -policy.updateRemindPolicy(Number.parseInt(this.netType), this.firstParam, Number.parseInt(this.currentRemindType)).then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) - -``` - -## policy.on - -Functions as the handle to a network policy. - -### on('netUidPolicyChange') - -on(type: "netUidPolicyChange", callback: Callback\<{ uid: number, policy: NetUidPolicy }>): void; - -Subscribes to policy changes. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| type | netUidPolicyChange | Yes| Event type. The value **netUidPolicyChange** indicates a policy change event.| -| callback | Callback\<{ uid: number, policy: [NetUidPolicy](#netuidpolicy) }> | Yes | Callback used to return the result.| - -**Example** - -```js -policy.on('netUidPolicyChange', (data) => { - this.log('on netUidPolicyChange: ' + JSON.stringify(data)); -}) -``` - -### on('netUidRuleChange') - -on(type: "netUidRuleChange", callback: Callback\<{ uid: number, rule: NetUidRule }>): void; - -Subscribes to rule changes. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| type | netUidRuleChange | Yes| Event type. The value **netUidRuleChange** indicates a rule change event.| -| callback | Callback\<{ uid: number, rule: [NetUidRule](#netuidrule) }> | Yes | Callback used to return the result.| - -**Example** - -```js -policy.on('netUidRuleChange', (data) => { - this.log('on netUidRuleChange: ' + JSON.stringify(data)); -}) -``` - -### on('netMeteredIfacesChange') - -on(type: "netMeteredIfacesChange", callback: Callback\>): void; - -Subscribes to metered network name (specified by **iface**) changes. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| type | netMeteredIfacesChange | Yes| Event type. The value **netMeteredIfacesChange** indicates a metered network name change event.| -| callback | Callback\> | Yes | Callback used to return the result.| - -**Example** - -```js -policy.on('netMeteredIfacesChange', (data) => { - this.log('on netMeteredIfacesChange: ' + JSON.stringify(data)); -}) -``` - -### on('netQuotaPolicyChange') - -on(type: "netQuotaPolicyChange", callback: Callback\>): void; - -Subscribes to network quota policy changes. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| type | netQuotaPolicyChange | Yes| Event type. The value **netQuotaPolicyChange** indicates a network quota policy change event.| -| callback | Callback\> | Yes | Callback used to return the result.| - -**Example** - -```js -policy.on('netQuotaPolicyChange', (data) => { - this.log('on netQuotaPolicyChange: ' + JSON.stringify(data)); -}) -``` - -### on('netBackgroundPolicyChange') - -on(type: "netBackgroundPolicyChange", callback: Callback\): void; - -Subscribes to background network policy changes. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| type | netBackgroundPolicyChange | Yes| Event type. The value **netBackgroundPolicyChange** indicates a background network policy change event.| -| callback | Callback\ | Yes | Callback used to return the result.| - -**Example** - -```js -policy.on('netBackgroundPolicyChange', (data) => { - this.log('on netBackgroundPolicyChange: ' + JSON.stringify(data)); -}) -``` - -## NetBackgroundPolicy - -Enumerates the background network policies. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name | Value | Description | -| ------------------------ | ---- | ---------------------- | -| NET_BACKGROUND_POLICY_NONE | 0 | Default policy.| -| NET_BACKGROUND_POLICY_ENABLE | 1 | Applications running in the background are allowed to access metered networks.| -| NET_BACKGROUND_POLICY_DISABLE | 2 | Applications running in the background are not allowed to access metered networks.| -| NET_BACKGROUND_POLICY_ALLOW_LIST | 3 | Only applications on the device idle allowlist are allowed to access metered networks when they are running in the background.| - -## NetQuotaPolicy - -Defines a network quota policy. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name | Type | Description | -| ----------------------- | ----------------------------------- | ------------------------------------------------------------ | -| netType | [NetBearType](js-apis-net-connection.md#netbeartype) | Network type.| -| iccid | string | Identifier of the SIM card on the metered cellular network. It is not used for Wi-Fi networks.| -| ident | string | Identifier of the SIM card on the metered cellular network. It is used for Wi-Fi networks. It is used together with **iccid**.| -| periodDuration | string | Start time of metering.| -| warningBytes | number | Data volume threshold for generating an alarm.| -| limitBytes | number | Data volume quota.| -| lastWarningRemind | string | Last time when an alarm was generated.| -| lastLimitRemind | string | Last time when the quota was exhausted.| -| metered | string | Whether the network is a metered network.| -| limitAction | [LimitAction](#limitaction) | Action to take when the data volume quota is reached.| - -## LimitAction - -Enumerates the actions that can be taken when the data volume quota is reached. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name | Value| Description | -| ---------------------- | ----- | ------------ | -| LIMIT_ACTION_NONE | -1 | Default action.| -| LIMIT_ACTION_DISABLE | 0 | Internet access is disabled.| -| LIMIT_ACTION_AUTO_BILL| 1 | Users will be automatically charged for the data volume they use.| - -## NetUidRule - -Enumerates the metered network rules. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name | Value| Description | -| ---------------------- | ----- | ------------ | -| NET_RULE_NONE | 0 | Default rule.| -| NET_RULE_ALLOW_METERED_FOREGROUND | 1 | Applications running in the foreground are allowed to access metered networks.| -| NET_RULE_ALLOW_METERED | 2 | Applications are allowed to access metered networks.| -| NET_RULE_REJECT_METERED | 4 | Applications are not allowed to access metered networks.| -| NET_RULE_ALLOW_ALL | 32 | Applications are allowed to access all networks (metered or non-metered).| -| NET_RULE_REJECT_ALL | 64 | Applications are not allowed to access any networks (metered or non-metered).| - -## RemindType - -Enumerates the reminder types. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name | Value| Description | -| ---------------------- | - | ------- | -| REMIND_TYPE_WARNING | 1 | Warning.| -| REMIND_TYPE_LIMIT | 2 | Limit.| - -## NetUidPolicy - -Enumerates the application-specific network policies. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name | Value| Description | -| ---------------------- | ----- | ------------ | -| NET_POLICY_NONE | 0 | Default network policy.| -| NET_POLICY_ALLOW_METERED_BACKGROUND | 1 | Applications running in the background are allowed to access metered networks.| -| NET_POLICY_REJECT_METERED_BACKGROUND | 2 | Applications running in the background are not allowed to access metered networks.| diff --git a/en/application-dev/reference/apis/js-apis-net-statistics.md b/en/application-dev/reference/apis/js-apis-net-statistics.md deleted file mode 100644 index 37d470deb6..0000000000 --- a/en/application-dev/reference/apis/js-apis-net-statistics.md +++ /dev/null @@ -1,409 +0,0 @@ -# Network Traffic Management - -The Network Traffic Management module collects statistics on the mobile data traffic and allows you to query the data volume by network interface (cellular or Wi-Fi) or 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 - -```js -import statistics from '@ohos.net.statistics' -``` - -## statistics.getIfaceRxBytes - -getIfaceRxBytes(nic: string, callback: AsyncCallback\): void - -Obtains the volume of mobile data traffic received by a specified NIC. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| nic | string | Yes | NIC name.| -| callback | AsyncCallback\ | Yes | Callback used to return the data volume, in bytes.| - -**Example** - -```js -statistics.getIfaceRxBytes(this.nic, (err, data) => { - this.callBack(err, data); - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## statistics.getIfaceRxBytes - -getIfaceRxBytes(nic: string): Promise\; - -Obtains the volume of mobile data traffic received by a specified NIC. This API uses a promise to return the result. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| nic | string | Yes | NIC name.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the data volume, in bytes.| - -**Example** - -```js -statistics.getIfaceRxBytes(this.nic).then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) -``` - -## statistics.getIfaceTxBytes - -getIfaceTxBytes(nic: string, callback: AsyncCallback\): void - -Obtains the volume of mobile data traffic sent by a specified NIC. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| nic | string | Yes | NIC name.| -| callback | AsyncCallback\ | Yes | Callback used to return the data volume, in bytes.| - -**Example** - -```js -statistics.getIfaceTxBytes(this.nic, (err, data) => { - this.callBack(err, data); - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## statistics.getIfaceTxBytes - -getIfaceTxBytes(nic: string): Promise\; - -Obtains the volume of mobile data traffic sent by a specified NIC. This API uses a promise to return the result. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| nic | string | Yes | NIC name.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the data volume, in bytes.| - -**Example** - -```js -statistics.getIfaceTxBytes(this.nic).then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) -``` - -## statistics.getCellularRxBytes - -getCellularRxBytes(callback: AsyncCallback\): void; - -Obtains the volume of mobile data traffic received by the cellular network. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\ | Yes | Callback used to return the data volume, in bytes.| - -**Example** - -```js -statistics.getCellularRxBytes((err, data) => { - this.callBack(err, data); - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## statistics.getCellularRxBytes - -getCellularRxBytes(): Promise\; - -Obtains the volume of mobile data traffic received by the cellular network. This API uses a promise to return the result. - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the data volume, in bytes.| - -**Example** - -```js -statistics.getCellularRxBytes().then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) -``` - -## statistics.getCellularTxBytes - -getCellularTxBytes(callback: AsyncCallback\): void; - -Obtains the volume of mobile data traffic sent by the cellular network. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\ | Yes | Callback used to return the data volume, in bytes.| - -**Example** - -```js -statistics.getCellularTxBytes((err, data) => { - this.callBack(err, data); - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## statistics.getCellularTxBytes - -getCellularTxBytes(): Promise\; - -Obtains the volume of mobile data traffic sent by the cellular network. This API uses a promise to return the result. - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the data volume, in bytes.| - -**Example** - -```js -statistics.getCellularTxBytes().then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) -``` - -## statistics.getAllRxBytes - -getAllRxBytes(callback: AsyncCallback\): void; - -Obtains the volume of mobile data traffic received by all NICs. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\ | Yes | Callback used to return the data volume, in bytes.| - -**Example** - -```js -statistics.getAllRxBytes(err, data) => { - this.callBack(err, data); - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## statistics.getAllRxBytes - -getAllRxBytes(): Promise\; - -Obtains the volume of mobile data traffic received by all NICs. This API uses a promise to return the result. - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the data volume, in bytes.| - -**Example** - -```js -statistics.getAllRxBytes().then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) -``` - -## statistics.getAllTxBytes - -getAllTxBytes(callback: AsyncCallback\): void; - -Obtains the volume of mobile data traffic sent by all NICs. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\ | Yes | Callback used to return the data volume, in bytes.| - -**Example** - -```js -statistics.getAllTxBytes((err, data) => { - this.callBack(err, data); - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## statistics.getAllTxBytes - -getAllTxBytes(): Promise\; - -Obtains the volume of mobile data traffic sent by all NICs. This API uses a promise to return the result. - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the data volume, in bytes.| - -**Example** - -```js -statistics.getAllTxBytes().then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) -``` - -## statistics.getUidRxBytes - -getUidRxBytes(uid: number, callback: AsyncCallback\): void; - -Obtains the volume of mobile data traffic received by a specified application. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes | Application ID.| -| callback | AsyncCallback\ | Yes | Callback used to return the data volume, in bytes.| - -**Example** - -```js -statistics.getUidRxBytes(this.uid, (err, data) => { - this.callBack(err, data); - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## statistics.getUidRxBytes - -getUidRxBytes(uid: number): Promise\; - -Obtains the volume of mobile data traffic received by a specified application. This API uses a promise to return the result. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes | Application ID.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the data volume, in bytes.| - -**Example** - -```js -statistics.getUidRxBytes(this.uid).then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) -``` - -## statistics.getUidTxBytes - -getUidTxBytes(uid: number, callback: AsyncCallback\): void; - -Obtains the volume of mobile data traffic sent by a specified application. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.Communication.NetManager.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes | Application ID.| -| callback | AsyncCallback\ | Yes | Callback used to return the data volume, in bytes.| - -**Example** - -```js -statistics.getUidTxBytes(this.uid, (err, data) => { - this.callBack(err, data); - console.log(JSON.stringify(error)) - console.log(JSON.stringify(data)) -}) -``` - -## statistics.getUidTxBytes - -getUidTxBytes(uid: number): Promise\; - -Obtains the volume of mobile data traffic sent by a specified application. This API uses a promise to return the result. - -**System capability**: SystemCapability.Communication.NetManager.Core - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| uid | number | Yes | Application ID.| - -**Return value** - -| Type | Description | -| --------------------------------- | ------------------------------------- | -| Promise\ | Promise used to return the data volume, in bytes.| - -**Example** - -```js -statistics.getUidTxBytes(this.uid).then((err, data) { - console.log(JSON.stringify(err)) - console.log(JSON.stringify(data)) -}) -``` diff --git a/en/application-dev/reference/apis/js-apis-tlsSocket.md b/en/application-dev/reference/apis/js-apis-tlsSocket.md deleted file mode 100644 index d734a1c4bb..0000000000 --- a/en/application-dev/reference/apis/js-apis-tlsSocket.md +++ /dev/null @@ -1,486 +0,0 @@ -# TLSSocket - -The Transport Layer Security (TLS) protocol is designed to help protect the privacy of information at the transport layer. TLSSocket is an extension to socket communication. It provides higher security than socket communication by adding a security protection layer, which consists of the following submodules: key, certificate, and communication. - -> **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 socket from '@ohos.net.tlssocket' -``` - -## socket.constructTLSSocketInstance - -constructTLSSocketInstance(): TLSSocket - -Creates a **TLSSocket** object. - -**Required permissions**: ohos.permission.INTERNET - -**System capability**: SystemCapability.Communication.NetStack - -**Example** - -```js -let tlssocket = socket.constructTLSSocketInstance(); -``` - -## tlssocket.connect - -connect(options: TLSConnectOptions, callback: AsyncCallback\): void - -Sets up a TLSSocket connection, and creates and initializes a TLS session. During this process, a TLS/SSL handshake is performed between the application and the server to implement data transmission. This API uses an asynchronous callback to return the result. - -**Parameters** - -| Name | Type | Mandatory| Description| -| -------- | ---------------------------------------| ----| --------------- | -| options | [TLSConnectOptions](#tlsconnectoptions) | Yes | Parameters required for the connection.| -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, the return result is empty. If the operation fails, an error code is returned.| - -**Example** - -```js -let options = { - ALPNProtocols: ["spdy/1", "http/1.1"], - address: { - address: "xxx", - port: "xxxx", - family: 1, - }, - secureOptions: { - key: "xxxx", - cert: "xxxx", - ca: ["xxxx"], - passwd: "xxxx", - protocols: "TlsV1_2", - useRemoteCipherPrefer: true, - signatureAlgorithms: SHA256, - cipherSuites: AES256-SHA256, - }, -}; - -tlssocket.connect(options, (err, data) => { - console.info(err); - console.info(data); -}); -``` - -## tlssocket.connect - -connect(options: TLSConnectOptions): Promise\; - -Sets up a TLSSocket connection, and creates and initializes a TLS session. During this process, a TLS/SSL handshake is performed between the application and the server to implement data transmission. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.INTERNET - -**System capability**: SystemCapability.Communication.NetStack - -**Parameters** - -| Name | Type | Mandatory| Description| -| -------- | --------------------------------------| ----| --------------- | -| options | [TLSConnectOptions](#tlsconnectoptions) | Yes | Parameters required for the connection.| - -**Return value** - -| Type | Description | -| ------------------------------------------- | ----------------------------- | -| Promise\ | Promise used to return the result. If the operation is successful, the return result is empty. If the operation fails, an error code is returned.| - -**Example** - -```js -let options = { - ALPNProtocols: ["spdy/1", "http/1.1"], - address: { - address: "xxxx", - port: "xxxx", - family: 1, - }, - secureOptions: { - key: "xxxx", - cert: "xxxx", - ca: ["xxxx"], - passwd: "xxxx", - protocols: "TlsV1_2", - useRemoteCipherPrefer: true, - signatureAlgorithms: SHA256, - cipherSuites: AES256-SHA256, - }, -}; - -tlssocket.connect(options).then(data => { - console.info(data); -}).catch(err => { - console.error(err); -}); -``` - -## tlssocket.getCertificate - -getCertificate(callback: AsyncCallback\): void; - -Obtains the local digital certificate after a TLSSocket connection is established. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.INTERNET - -**System capability**: SystemCapability.Communication.NetStack - -**Parameters** - -| Name | Type | Mandatory| Description| -| -------- | ----------------------------------------| ---- | ---------------| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -tlssocket.getCertificate((err, data) => { - if (err) { - console.log("getCertificate callback error = " + err); - } else { - console.log("getCertificate callback = " + data); - } -}); -``` - -## tlssocket.getCertificate - -getCertificate():Promise\; - -Obtains the local digital certificate after a TLSSocket connection is established. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.INTERNET - -**System capability**: SystemCapability.Communication.NetStack - -**Return value** - -| Type | Description | -| -------------- | -------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -tlssocket.getCertificate().then(data => { - console.info(data); -}).catch(err => { - console.error(err); -}); -``` - -## tlssocket.getRemoteCertificate - -getRemoteCertificate(callback: AsyncCallback\): void; - -Obtains the remote digital certificate after a TLSSocket connection is established. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.INTERNET - -**System capability**: SystemCapability.Communication.NetStack - -**Parameters** - -| Name | Type | Mandatory | Description | -| -------- | ----------------------------------------| ---- | ---------------| -| callback | AsyncCallback\ | Yes | Callback used to return the result.| - -**Example** - -```js -tlssocket.getRemoteCertificate((err, data) => { - if (err) { - console.log("getRemoteCertificate callback error = " + err); - } else { - console.log("getRemoteCertificate callback = " + data); - } -}); -``` - -## tlssocket.getRemoteCertificate - -getRemoteCertificate():Promise\; - -Obtains the remote digital certificate after a TLSSocket connection is established. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.INTERNET - -**System capability**: SystemCapability.Communication.NetStack - -**Return value** - -| Type | Description | -| -------------- | -------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -tlssocket.getRemoteCertificate().then(data => { - console.info(data); -}).catch(err => { - console.error(err); -}); -``` - -## tlssocket.getProtocol - -getProtocol(callback: AsyncCallback\): void; - -Obtains the communication protocol after a TLSSocket connection is established. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.INTERNET - -**System capability**: SystemCapability.Communication.NetStack - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ----------------------------------------| ---- | ---------------| -| callback | AsyncCallback\ | Yes | Callback used to return the result. | - -**Example** - -```js -tlssocket.getProtocol((err, data) => { - if (err) { - console.log("getProtocol callback error = " + err); - } else { - console.log("getProtocol callback = " + data); - } -}); -``` - -## tlssocket.getProtocol - -getProtocol():Promise\; - -Obtains the communication protocol after a TLSSocket connection is established. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.INTERNET - -**System capability**: SystemCapability.Communication.NetStack - -**Return value** - -| Type | Description | -| -------------- | -------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -tlssocket.getProtocol().then(data => { - console.info(data); -}).catch(err => { - console.error(err); -}); -``` - -## tlssocket.getCipherSuites - -getCipherSuites(callback: AsyncCallback\>): void; - -Obtains the cipher suites supported by both parties after a TLSSocket connection is established. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.INTERNET - -**System capability**: SystemCapability.Communication.NetStack - -**Parameters** - -| Name | Type | Mandatory| Description| -| -------- | ----------------------------------------| ---- | ---------------| -| callback | AsyncCallback\> | Yes | Callback used to return the result. | - -**Example** - -```js -tlssocket.getCipherSuites((err, data) => { - if (err) { - console.log("getCipherSuites callback error = " + err); - } else { - console.log("getCipherSuites callback = " + data); - } -}); -``` - -## tlssocket.getCipherSuites - -getCipherSuites(): Promise\>; - -Obtains the cipher suites supported by both parties after a TLSSocket connection is established. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.INTERNET - -**System capability**: SystemCapability.Communication.NetStack - -**Return value** - -| Type | Description | -| ---------------------- | --------------------- | -| Promise\> | Promise used to return the result.| - -**Example** - -```js -tlssocket.getCipherSuites().then(data => { - console.info(data); -}).catch(err => { - console.error(err); -}); -``` - -## tlssocket.getSignatureAlgorithms - -getSignatureAlgorithms(callback: AsyncCallback\>): void; - -Obtains the signing algorithms supported by both parties after a TLSSocket connection is established. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.INTERNET - -**System capability**: SystemCapability.Communication.NetStack - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------------------------| ---- | ---------------| -| callback | AsyncCallback\> | Yes | Callback used to return the result. | - -**Example** - -```js -tlssocket.getSignatureAlgorithms((err, data) => { - if (err) { - console.log("getSignatureAlgorithms callback error = " + err); - } else { - console.log("getSignatureAlgorithms callback = " + data); - } -}); -``` - -## tlssocket.getSignatureAlgorithms - -getSignatureAlgorithms(): Promise\>; - -Obtains the signing algorithms supported by both parties after a TLSSocket connection is established. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.INTERNET - -**System capability**: SystemCapability.Communication.NetStack - -**Return value** - -| Type | Description | -| ---------------------- | -------------------- | -| Promise\> | Promise used to return the result.| - -**Example** - -```js -tlssocket.getSignatureAlgorithms().then(data => { - console.info(data); -}).catch(err => { - console.error(err); -}); -``` - -## tlssocket.close - -close(callback: AsyncCallback\): void; - -Closes a TLSSocket connection. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.INTERNET - -**System capability**: SystemCapability.Communication.NetStack - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -----------------------------| ---- | ---------------| -| callback | AsyncCallback\ | Yes | Callback used to return the result. | - -**Example** - -```js -tlssocket.close((err) => { - if (err) { - console.log("close callback error = " + err); - } else { - console.log("close success"); - } -}); -``` - -## tlssocket.close - -close(): Promise\; - -Closes a TLSSocket connection. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.INTERNET - -**System capability**: SystemCapability.Communication.NetStack - -**Return value** - -| Type | Description | -| -------------- | -------------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -tlssocket.close().then(() => - console.log("close success"); -}).catch(err => { - console.error(err); -}); -``` - -## TLSConnectOptions - -Defines a TLSSocket connection. - -**System capability**: SystemCapability.Communication.NetStack - -| Name | Type | Description | -| -------------- | ------------------------------------- | -------------- | -| address | [NetAddress](#netaddress) | Gateway address. | -| secureOptions | [TLSSecureOptions](#tlssecureoptions) | TLS security options.| -| ALPNProtocols | Array\ | Application Layer Protocol Negotiation (ALPN) protocols. | - -## NetAddress - -Defines a network address. - -**System capability**: SystemCapability.Communication.NetStack - -| Name | Type | Description | -| ------- | ------ | ---------------------------- | -| address | string | Network address. | -| family | number | Address family identifier. The value is **1** for IPv4 and **2** for IPv6. The default value is **1**.| -| port | number | Port number. The value ranges from **0** to **65535**. | - -## TLSSecureOptions - -Defines TLS security options. - -**System capability**: SystemCapability.Communication.NetStack - -| Name | Type | Description | -| --------------------- | ---------------------- | ---------------------- | -| ca | string \| Array\ | CA certificate. | -| cert | string | Local digital certificate. | -| key | string | Private key of the local digital certificate. | -| passwd | string | Password. | -| protocols | string | Protocols. | -| useRemoteCipherPrefer | boolean | Whether to use the remote cipher suite preferentially.| -| signatureAlgorithms | string | Signing algorithms. | -| cipherSuites | string | Cipher suites. | diff --git a/en/application-dev/reference/errorcodes/errorcode-AccessToken.md b/en/application-dev/reference/errorcodes/errorcode-Access-token.md similarity index 100% rename from en/application-dev/reference/errorcodes/errorcode-AccessToken.md rename to en/application-dev/reference/errorcodes/errorcode-Access-token.md diff --git a/en/application-dev/reference/errorcodes/errcode-DistributedSchedule.md b/en/application-dev/reference/errorcodes/errorcode-DistributedSchedule.md similarity index 100% rename from en/application-dev/reference/errorcodes/errcode-DistributedSchedule.md rename to en/application-dev/reference/errorcodes/errorcode-DistributedSchedule.md diff --git a/en/application-dev/reference/errorcodes/errcode-bundle.md b/en/application-dev/reference/errorcodes/errorcode-bundle.md similarity index 59% rename from en/application-dev/reference/errorcodes/errcode-bundle.md rename to en/application-dev/reference/errorcodes/errorcode-bundle.md index a7a0b45213..24ae7aa613 100644 --- a/en/application-dev/reference/errorcodes/errcode-bundle.md +++ b/en/application-dev/reference/errorcodes/errorcode-bundle.md @@ -1,60 +1,60 @@ # Bundle Error Codes -## 17700001 Nonexistent Bundle Name +## 17700001 Bundle Name Does Not Exist **Error Message** The specified bundle name is not found. **Description** -This error code is reported when the bundle name passed in the API does not exist. +When a query API is called, the bundle name passed in does not exist. **Possible Causes** 1. The bundle name is misspelled. -2. The corresponding application is not installed. +2. The corresponding bundle is not installed. **Solution** 1. Check whether the spelling of the bundle name is correct. -2. Check whether the corresponding application is installed. +2. Check whether the corresponding bundle is installed. -## 17700002 Nonexistent Module Name +## 17700002 Module Name Does Not Exist **Error Message** The specified module name is not found. **Description** -This error code is reported when the module name passed in the API does not exist. +When a query API or an installation-free API is called, the module name passed in does not exist. **Possible Causes** 1. The module name is misspelled. -2. The module is not installed for the application. +2. The module is not installed. **Solution** 1. Check whether the spelling of the module name is correct. -2. Check whether the module is installed for the application. +2. Check whether the module is installed. -## 17700003 Nonexistent Ability Name +## 17700003 Ability Name Does Not Exist **Error Message** The specified ability name is not found. **Description** -This error code is reported when the ability name passed in the API does not exist. +When a query API is called, the ability name passed in does not exist. **Possible Causes** 1. The ability name is misspelled. -2. The corresponding application is not installed. +2. The corresponding bundle is not installed. **Solution** 1. Check whether the spelling of the ability name is correct. -2. Check whether the ability is installed for the application. +2. Check whether the ability is installed. -## 17700004 Nonexistent User ID +## 17700004 User ID Does Not Exist **Error Message** -The specified user id is not found. +The specified user ID is not found. **Description** -This error code is reported when the user ID passed in the API does not exist. +When a user-related API is called, the user ID passed in does not exist. **Possible Causes** The user ID is incorrect. The user does not exist. @@ -63,13 +63,13 @@ The user ID is incorrect. The user does not exist. 1. Check whether the user ID is correct. 2. Check whether the user exists. -## 17700005 Nonexistent Application ID +## 17700005 Application ID Does Not Exist **Error Message** -The specified appId is not found. +The specified app ID is not found. **Description** -This error code is reported when the value of **appId** passed in the API is an empty string. +When an API of the **appControl** module is called, the application ID passed in does not exist. **Possible Causes** **appId** is an empty string. @@ -77,13 +77,13 @@ This error code is reported when the value of **appId** passed in the API is an **Solution** Check whether **appId** is an empty string. -## 17700006 Nonexistent Permission +## 17700006 Permission Does Not Exist **Error Message** The specified permission is not found. **Description** -This error code is reported when the permission passed in the API does not exist. +When the **getPermissionDef** API of the **bundleManager** module is called, the permission passed in does not exist. **Possible Causes** 1. The permission name is misspelled. @@ -96,10 +96,10 @@ This error code is reported when the permission passed in the API does not exist ## 17700007 Incorrect Device ID **Error Message** -The specified deviceId is not found. +The specified device ID is not found. **Description** -This error code is reported when the device ID passed in the API is incorrect. +When an API of the **distributedBundle** module is called, the device ID passed in does not exist. **Possible Causes** 1. The device ID is incorrect. @@ -109,13 +109,13 @@ This error code is reported when the device ID passed in the API is incorrect. 1. Check whether the device ID is correct. 2. Check whether the device ID exists. -## 17700010 Application Installation Failure Due to File Parsing Failure +## 17700010 Bundle Installation Failure Due to File Parsing Failure **Error Message** -Failed to install the hap since the hap fails to be parsed. +Failed to install the HAP because the HAP fails to be parsed. **Description** -This error code is reported when the application fails to be installed because the HAP fails to be parsed. +When the **install** API of the **installer** module is called, the HAP passed in fails to be parsed. **Possible Causes** 1. The HAP is not in ZIP format. @@ -127,13 +127,13 @@ This error code is reported when the application fails to be installed because t 2. Check whether the configuration file is in [JSON format](../../quick-start/stage-structure.md). 3. Check whether an error message is displayed when DevEco Studio compiles the HAP. If necessary fields are missing, an error message will be displayed. -## 17700011 Application Installation Failure Due to Signature Verification Failure +## 17700011 Bundle Installation Failure Due to Signature Verification Failure **Error Message** -Failed to install the hap since the hap signature fails to be verified. +Failed to install the HAP because the HAP signature fails to be verified. **Description** -This error code is reported when the application fails to be installed due to signature verification failure. +Calling the **install** API of the **installer** module to install the bundle fails due to signature verification failure. **Possible Causes** @@ -147,13 +147,13 @@ This error code is reported when the application fails to be installed due to si 2. Check whether the same certificate is used for signing multiple HAPs. 3. Check whether the certificate used for signing the upgrade HAP is the same as the certificate used for signing the installed HAP. -## 17700012 Application Installation Failure Due to Invalid File Path or Too Large File +## 17700012 Bundle Installation Failure Due to Invalid File Path or Too Large File **Error Message** -Failed to install the hap since the path of the hap is invalid or too large size. +Failed to install the HAP because the HAP path is invalid or the HAP is too large. **Description** -This error code is reported when the application fails to be installed because the HAP path is invalid or the HAP is too large. +Calling the **install** API of the **installer** module to install the bundle fails because the HAP path is invalid or the HAP is too large. **Possible Causes** 1. The path of the HAP does not exist. @@ -165,13 +165,13 @@ This error code is reported when the application fails to be installed because t 2. Check whether the HAP is read only or executable. 3. Check whether the size of the HAP exceeds 4 GB. -## 17700015 Application Installation Failure Due to Different Configuration Information of Multiple HAP Packages +## 17700015 Bundle Installation Failure Due to Different Configuration Information of Multiple HAP Packages **Error Message** -Failed to install haps since the configuration information of multi haps is inconsistent. +Failed to install the HAPs because they have different configuration information. **Description** -This error code is reported when the application fails to be installed because the HAPs have different configuration information. +Calling the **install** API of the **installer** module to install the bundle fails because the HAPs have different configuration information. **Possible Causes** The fields under **app** in the configuration files of these HAPs are inconsistent. @@ -179,13 +179,13 @@ The fields under **app** in the configuration files of these HAPs are inconsiste **Solution** Check whether the fields under **app** are the same. -## 17700016 Application Installation Failure Due to Insufficient System Disk Space +## 17700016 Bundle Installation Failure Due to Insufficient System Disk Space **Error Message** -Failed to install the hap since the system disk space is insufficient. +Failed to install the HAP because of insufficient system disk space. **Description** -This error code is reported when the application fails to be installed due to insufficient system disk space. +Calling the **install** API of the **installer** module to install the bundle fails due to insufficient system disk space. **Possible Causes** The system disk space is insufficient. @@ -193,19 +193,19 @@ The system disk space is insufficient. **Solution** Check whether the system has sufficient disk space. -## 17700017 Application Installation Failure Because the Version to Install is Too Earlier +## 17700017 Bundle Installation Failure Because the Version to Install is Too Earlier **Error Message** -Failed to install the hap since the version of the newly installed hap is too early. +Failed to install the HAP since the version of the HAP to install is too early. **Description** -This error code is reported when the version number of the application to install is earlier than the version in use. +Calling the **install** API of the **installer** module to install the bundle fails because the version to install is earlier than the version in use. **Possible Causes** The version number is earlier than the version in use. **Solution** -Ensure that the version of the application to install is later than the version in use. +Ensure that the version of the bundle to install is later than the version in use. ## 17700020 Failure to Uninstall Preinstalled Applications @@ -213,7 +213,7 @@ Ensure that the version of the application to install is later than the version The preinstalled app cannot be uninstalled. **Description** -This error code is reported when you attempt to uninstall a preinstalled application. +Calling the **uninstall** API of the **installer** module to uninstall a preinstalled application fails. **Possible Causes** 1. You might want to uninstall a non-preinstalled application but passed the bundle name of a preinstalled app. @@ -229,7 +229,7 @@ This error code is reported when you attempt to uninstall a preinstalled applica The specified uid is invalid. **Description** -This error code is reported when the UID passed in the API is invalid. +When the **getBundleNameByUid** API of the **bundleManager** module is called, the UID passed in is invalid. **Possible Causes** 1. The UID is misspelled. @@ -245,7 +245,7 @@ This error code is reported when the UID passed in the API is invalid. The input source file is invalid. **Description** -This error code is reported when the source file to be parsed is invalid. +When the **getBundleArchiveInfo** API of the **bundleManager** module is called, the HAP path passed in is invalid. **Possible Causes** 1. The source file to be parsed does not exist. @@ -255,13 +255,13 @@ This error code is reported when the source file to be parsed is invalid. 1. Check whether the source file to be parsed exists. 2. Check whether the source file to be parsed is in ZIP format. -## 17700023 Nonexistent Default Application +## 17700023 Default Application Does Not Exist **Error Message** The specified default app does not exist. **Description** -This error code is reported when the specified default application does not exist. +When the **getDefaultApplication** API of the **defaultAppManager** module is called, the specified default application does not exist. **Possible Causes** No default application is set for the device. @@ -269,13 +269,13 @@ No default application is set for the device. **Solution** Check whether the default application is set on the device. -## 17700024 Nonexistent Configuration File +## 17700024 Configuration File Does Not Exist **Error Message** -Failed to get profile since no profile in the hap. +Failed to get the profile because there is no profile in the HAP. **Description** -This error code is reported when you attempt to obtain the configuration file that does not exist. +When an API for querying the profile is called, the configuration file does not exist **Possible Causes** 1. The metadata name passed in the API does not exist in the configuration file. @@ -291,7 +291,7 @@ This error code is reported when you attempt to obtain the configuration file th The specified type is invalid. **Description** -The type is invalid. +When an API of the **defaultAppManager** module is called, the type passed in is invalid. **Possible Causes** 1. The type passed in the API is misspelled. @@ -300,27 +300,27 @@ The type is invalid. **Solution** Check whether the spelling of type is correct. -## 17700026 Application Disabled +## 17700026 Bundle Disabled **Error Message** The specified bundle is disabled. **Description** -This error code is reported when the specified application is disabled. +When an API for querying bundle information is called, the specified bundle is disabled. **Possible Causes** -The application on the device has been disabled and cannot be queried. +The bundle on the device has been disabled and cannot be queried. **Solution** -Check whether the application on the device is disabled. +Check whether the bundle on the device is disabled. -## 17700027 Distributed Service Not Started +## 17700027 Distributed Service Is Not Started **Error Message** The distributed service is not running. **Description** -This error code is reported when the distributed service is not started. +When an API of the **distributedBundle** module is called, the distributed service is not started. **Possible Causes** The device is not networked. @@ -333,7 +333,7 @@ Check whether the device is networked. The ability does not match the type. **Description** -This error code is reported when the ability and type passed in the API do not match. +When the **setDefaultApplication** API of the **defaultAppManager** module is called, the **ability** and **type** passed in do not match. **Possible Causes** The ability and type are misspelled. @@ -347,21 +347,21 @@ Check whether the spellings of ability and type are correct. The specified ability is disabled. **Description** -This error code is reported when the specified ability is disabled. +When an API for querying ability information is called, the specified ability is disabled. **Possible Causes** The specified ability is disabled. **Solution** -Check whether the ability is disabled. You can run the [bm commands](../../../readme/bundle-management.md#bm-commands) to query the application information. +Check whether the ability is disabled. You can run the [bm commands](../../../readme/bundle-management.md#bm-commands) to query the information. ## 17700030 Failure in Clearing Cache Files **Error Message** -The specified bundle does not support clearing cache files. +The specified bundle does not support clearing of cache files. **Description** -This error code is reported when the application does not support cache file clearing. +When the **cleanBundleCacheFiles** API of the **bundleManager** module is called, the specified bundle does not support cache file clearing. **Possible Causes** The application is a system application and the **AllowAppDataNotCleared** field is configured in the signing certificate. diff --git a/en/application-dev/reference/errorcodes/errorcodes-multimodalinput.md b/en/application-dev/reference/errorcodes/errorcode-multimodalinput.md similarity index 100% rename from en/application-dev/reference/errorcodes/errorcodes-multimodalinput.md rename to en/application-dev/reference/errorcodes/errorcode-multimodalinput.md diff --git a/en/application-dev/reference/errorcodes/errorcode-sensors.md b/en/application-dev/reference/errorcodes/errorcode-sensors.md deleted file mode 100644 index 155ff9263f..0000000000 --- a/en/application-dev/reference/errorcodes/errorcode-sensors.md +++ /dev/null @@ -1,40 +0,0 @@ -# Pan-Sensor Error Codes - -## 14500101 Service exception. - -### Error information - -Service exception. - -### Description - -This error code is reported if the HDI service is abnormal when the **on**, **once**, or **off** interface of the sensor module is called. - -### Possible Causes - -The HDI service is abnormal. - -### Procedure - -1. Retry the operation at a specified interval (for example, 1s) or at an exponential increase interval. -2. If the operation fails for three consecutive times, stop the attempt. You can also attempt to obtain the sensor list to check for device availability. - -## 14600101 Device operation failed. - -### Error Message - -Device operation failed. - -### Description - -This error code is reported if the HDI service is abnormal or the device is occupied when the **startVibration** interface of the vibrator module is called. - -### Possible Causes - -1. The HDI service is abnormal. -2. The device is occupied. - -### Procedure - -1. Retry the operation at a specified interval or at an exponential increase interval. If the operation fails for three consecutive times, stop the retry. You can also obtain the vibrator list to check for device availability. -2. Set a higher priority for the vibrator. -- GitLab