From 10b590585617ffa3e7c888d2269eedb8bdfb8416 Mon Sep 17 00:00:00 2001 From: liwuli Date: Fri, 31 Mar 2023 15:16:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8C=85=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liwuli --- .../reference/apis/Readme-CN.md | 1 + .../apis/js-apis-enterprise-bundleManager.md | 389 ++++++++++++++++++ 2 files changed, 390 insertions(+) create mode 100644 zh-cn/application-dev/reference/apis/js-apis-enterprise-bundleManager.md diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index 07d9d19b88..17b0407e4d 100755 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -352,6 +352,7 @@ - 定制管理 - [@ohos.configPolicy (配置策略)](js-apis-configPolicy.md) - [@ohos.enterprise.accountManager (帐户管理)](js-apis-enterprise-accountManager.md) + - [@ohos.enterprise.bundleManager (包管理)](js-apis-enterprise-bundleManager.md) - [@ohos.enterprise.adminManager (企业设备管理)](js-apis-enterprise-adminManager.md) - [@ohos.enterprise.dateTimeManager (系统时间管理)](js-apis-enterprise-dateTimeManager.md) - [@ohos.enterprise.deviceControl (设备控制管理)](js-apis-enterprise-deviceControl.md) diff --git a/zh-cn/application-dev/reference/apis/js-apis-enterprise-bundleManager.md b/zh-cn/application-dev/reference/apis/js-apis-enterprise-bundleManager.md new file mode 100644 index 0000000000..66249739bb --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-enterprise-bundleManager.md @@ -0,0 +1,389 @@ +# @ohos.enterprise.bundleManager(包管理) + +本模块提供包管理能力,包括添加包安装白名单、获取包安装白名单、移除包安装白名单等。仅企业设备管理员应用才能调用。 + +> **说明:** +> +> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +```js +import bundleManager from '@ohos.enterprise.bundleManager'; +``` + +## bundleManager.addAllowedInstallBundles + +addAllowedInstallBundles(admin: Want, appIds: Array\, callback: AsyncCallback<void>): void; + +添加包安装白名单接口,使用callback异步回调。 + +**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY + +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager + +**系统API**: 此接口为系统接口。 + +**参数:** + +| 参数 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------- | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | +| appIds | Array<string> | 是 | 允许安装包的白名单 | +| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功err为null,否则为错误对象。 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) + +| 错误码ID | 错误信息 | +| ------- | ---------------------------------------------------------------------------- | +| 9200003 | the administrator ability component is invalid. | +| 9200007 | the system ability work abnormally. | + +**示例:** + +```js +let wantTemp = { + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", +}; +let appIds = {"com.example.myapplication"}; + +bundleManager.AddAllowedInstallBundles(wantTemp, appIds, (error) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## bundleManager.addAllowedInstallBundles + +addAllowedInstallBundles(admin: Want, appIds: Array\, userId: number, callback: AsyncCallback<void>): void; + +添加包安装白名单接口,使用callback异步回调。 + +**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY + +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager + +**系统API**: 此接口为系统接口。 + +**参数:** + +| 参数 | 类型 | 必填 | 说明 | +| ----- | ----------------------------------- | ---- | ------- | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | +| appIds | Array<string> | 是 | 允许安装包的白名单 | +| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功err为null,否则为错误对象。 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) + +| 错误码ID | 错误信息 | +| ------- | ---------------------------------------------------------------------------- | +| 9200003 | the administrator ability component is invalid. | +| 9200007 | the system ability work abnormally. | + +**示例:** + +```js +let wantTemp = { + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", +}; +let appIds = {"com.example.myapplication"}; + +bundleManager.AddAllowedInstallBundles(wantTemp, appIds, 100, (error) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## bundleManager.addAllowedInstallBundles + +addAllowedInstallBundles(admin: Want, appIds: Array\, userId?: number): Promise<void>; + +添加包安装白名单接口,使用promise异步回调。 + +**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY + +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager + +**系统API**: 此接口为系统接口。 + +**参数:** + +| 参数 | 类型 | 必填 | 说明 | +| ----- | ----------------------------------- | ---- | ------- | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | +| appIds | Array<string> | 是 | 允许安装包的白名单 | +| userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | + +**返回值:** + +| 类型 | 说明 | +| --------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) + +| 错误码ID | 错误信息 | +| ------- | ---------------------------------------------------------------------------- | +| 9200003 | the administrator ability component is invalid. | +| 9200007 | the system ability work abnormally. | + +**示例:** + +```js +let wantTemp = { + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", +}; +let appIds = {"com.example.myapplication"}; + +bundleManager.addAllowedInstallBundles(wantTemp, appIds, 100).then(() => { + console.log("success"); +}).catch(error => { + console.log("error code:" + error.code + " error message:" + error.message); +}); +``` + +## bundleManager.removeAllowedInstallBundles + +removeAllowedInstallBundles(admin: Want, appIds: Array\, callback: AsyncCallback<void>): void; + +移除包安装白名单接口,使用callback异步回调。 + +**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY + +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager + +**系统API**: 此接口为系统接口。 + +**参数:** + +| 参数 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------- | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | +| appIds | Array<string> | 是 | 移除允许安装包的白名单 | +| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功err为null,否则为错误对象。 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) + +| 错误码ID | 错误信息 | +| ------- | ---------------------------------------------------------------------------- | +| 9200003 | the administrator ability component is invalid. | +| 9200007 | the system ability work abnormally. | + +**示例:** + +```js +let wantTemp = { + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", +}; +let appIds = {"com.example.myapplication"}; + +bundleManager.removeAllowedInstallBundles(wantTemp, appIds, (error) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## bundleManager.removeAllowedInstallBundles + +removeAllowedInstallBundles(admin: Want, appIds: Array\, userId: number, callback: AsyncCallback<void>): void; + +移除包安装白名单接口,使用callback异步回调。 + +**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY + +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager + +**系统API**: 此接口为系统接口。 + +**参数:** + +| 参数 | 类型 | 必填 | 说明 | +| ----- | ----------------------------------- | ---- | ------- | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | +| appIds | Array<string> | 是 | 允许安装包的白名单 | +| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功err为null,否则为错误对象。 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) + +| 错误码ID | 错误信息 | +| ------- | ---------------------------------------------------------------------------- | +| 9200003 | the administrator ability component is invalid. | +| 9200007 | the system ability work abnormally. | + +**示例:** + +```js +let wantTemp = { + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", +}; +let appIds = {"com.example.myapplication"}; + +bundleManager.removeAllowedInstallBundles(wantTemp, appIds, 100, (error) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## bundleManager.removeAllowedInstallBundles + +removeAllowedInstallBundles(admin: Want, appIds: Array\, userId?: number): Promise<void>; + +移除包安装白名单接口,使用promise异步回调。 + +**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY + +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager + +**系统API**: 此接口为系统接口。 + +**参数:** + +| 参数 | 类型 | 必填 | 说明 | +| ----- | ----------------------------------- | ---- | ------- | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | +| appIds | Array\<string> | 是 | 允许安装包的白名单 | +| userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | + +**返回值:** + +| 类型 | 说明 | +| --------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) + +| 错误码ID | 错误信息 | +| ------- | ---------------------------------------------------------------------------- | +| 9200003 | the administrator ability component is invalid. | +| 9200007 | the system ability work abnormally. | + +**示例:** + +```js +let wantTemp = { + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", +}; +let appIds = {"com.example.myapplication"}; + +bundleManager.removeAllowedInstallBundles(wantTemp, appIds, 100).then(() => { + console.log("success"); +}).catch(error => { + console.log("error code:" + error.code + " error message:" + error.message); +}); +``` + +## bundleManager.getAllowedInstallBundles + +getAllowedInstallBundles(admin: Want, userId: number, callback: AsyncCallback<Array<string>>): void; + +获取包安装白名单接口,使用callback异步回调。 + +**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY + +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager + +**系统API**: 此接口为系统接口。 + +**参数:** + +| 参数 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------- | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | +| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | +| callback | AsyncCallback<Array<string>> | 是 | 回调函数。当接口调用成功err为null,否则为错误对象。 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) + +| 错误码ID | 错误信息 | +| ------- | ---------------------------------------------------------------------------- | +| 9200003 | the administrator ability component is invalid. | +| 9200007 | the system ability work abnormally. | + +**示例:** + +```js +let wantTemp = { + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", +}; + +bundleManager.getAllowedInstallBundles(wantTemp, 100, (error) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## bundleManager.getAllowedInstallBundles + +getAllowedInstallBundles(admin: Want, userId?: number): Promise<Array<string>>; + +获取包安装白名单接口,使用promise异步回调。 + +**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY + +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager + +**系统API**: 此接口为系统接口。 + +**参数:** + +| 参数 | 类型 | 必填 | 说明 | +| ----- | ----------------------------------- | ---- | ------- | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | +| userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | + +**返回值:** + +| 类型 | 说明 | +| --------------------- | ------------------------- | +| Promise<void> | 返回结果为String类型数组的Promise对象。 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) + +| 错误码ID | 错误信息 | +| ------- | ---------------------------------------------------------------------------- | +| 9200003 | the administrator ability component is invalid. | +| 9200007 | the system ability work abnormally. | + +**示例:** + +```js +let wantTemp = { + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", +}; +bundleManager.getAllowedInstallBundles(wantTemp, 100).then(() => { + console.log("success"); +}).catch(error => { + console.log("error code:" + error.code + " error message:" + error.message); +}); +``` -- GitLab