diff --git a/zh-cn/application-dev/reference/apis/js-apis-installer.md b/zh-cn/application-dev/reference/apis/js-apis-installer.md index 02c05776e1800413ef36cf062425c015dde2c2be..95ea29e2378213b65cb0521c1aa99cdf72d5ff61 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-installer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-installer.md @@ -91,6 +91,34 @@ try { } ``` +## BundleInstaller.getBundleInstallerSync10+ + +getBundleInstallerSync(): BundleInstaller; + +获取并返回BundleInstaller对象。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.BundleManager.BundleFramework.Core + +**返回值:** +| 类型 | 说明 | +| ------------------------------------------------------------ | ------------------------------------ | +| [BundleInstaller](js-apis-installer.md#BundleInstaller) | 返回BundleInstaller对象。 | + +**示例:** + +```ts +import installer from '@ohos.bundle.installer'; + +try { + installer.getBundleInstallerSync(); + console.info('getBundleInstallerSync successfully.'); +} catch (error) { + console.error('getBundleInstallerSync failed. Cause: ' + error.message); +} +``` + ## BundleInstaller.install install(hapFilePaths: Array<string>, installParam: InstallParam, callback: AsyncCallback<void>): void; diff --git a/zh-cn/application-dev/reference/apis/js-apis-launcherBundleManager.md b/zh-cn/application-dev/reference/apis/js-apis-launcherBundleManager.md index c0eee70d41e4a9dd645b472388f8821dc56ca5cb..da9dff1fd8b36082cddf45731166ce4727206555 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-launcherBundleManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-launcherBundleManager.md @@ -115,6 +115,53 @@ try { } ``` +## launcherBundlemanager.getLauncherAbilityInfoSync10+ + +getLauncherAbilityInfoSync(bundleName: string, userId: number) : Array\<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)>; + +查询指定bundleName及用户的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)。 + +**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统接口:** 此接口为系统接口 + +**系统能力:** SystemCapability.BundleManager.BundleFramework.Launcher + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | -------------- | +| bundleName | string | 是 | 应用Bundle名称。 | +| userId | number | 是 | 被查询的用户id。 | + +**返回值:** + +| 类型 | 说明 | +| ----------------------------- | -------------------------------------------------- | +| Array\<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)> | Array形式返回bundle包含的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)信息。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 17700001 | The specified bundle name is not found. | +| 17700004 | The specified user ID is not found. | + +**示例:** + +```typescript +import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; + +try { + let data = launcherBundleManager.getLauncherAbilityInfoSync("com.example.demo", 100); + console.log("data is " + JSON.stringify(data)); +} catch (errData) { + console.error(`errData is errCode:${errData.code} message:${errData.message}`); +} +``` + ## launcherBundlemanager.getAllLauncherAbilityInfo9+ getAllLauncherAbilityInfo(userId: number, callback: AsyncCallback>) : void; @@ -305,3 +352,46 @@ try { console.error(`errData is errCode:${errData.code} message:${errData.message}`); } ``` + +## launcherBundlemanager.getShortcutInfoSync10+ + +getShortcutInfoSync(bundleName : string) : Array\<[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md)>; + +查询当前用户下指定应用的[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md)。 + +**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统接口:** 此接口为系统接口 + +**系统能力:** SystemCapability.BundleManager.BundleFramework.Launcher + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | -------------- | +| bundleName | string | 是 | 应用Bundle名称。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------------- | ----------------------------------------------- | +| Array\<[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md)> | Array形式返回当前用户下指定应用的[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md)。 | + +**错误码:** + +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 17700001 | The specified bundle name is not found. | + +**示例:** + +```ts +import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; + +try { + let data = launcherBundleManager.getShortcutInfoSync("com.example.demo"); + console.log("data is " + JSON.stringify(data)); +} catch (errData) { + console.error(`errData is errCode:${errData.code} message:${errData.message}`); +} +```