提交 ae5833a5 编写于 作者: Y yaobaohua

disallow install hap

Signed-off-by: Nyaobaohua <yaobaohua1@huawei.com>
上级 1e139629
...@@ -26,7 +26,7 @@ addAllowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCal ...@@ -26,7 +26,7 @@ addAllowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCal
**参数:** **参数:**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- | | -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | | admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appIds | Array&lt;string&gt; | 是 | 允许安装包的白名单。 | | appIds | Array&lt;string&gt; | 是 | 允许安装包的白名单。 |
...@@ -38,8 +38,8 @@ addAllowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCal ...@@ -38,8 +38,8 @@ addAllowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCal
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- | | ------- | ---------------------------------------------------------------------------- |
| 9200003 | the administrator ability component is invalid. | | 9200001 | the application is not an administrator of the device. |
| 9200007 | the system ability work abnormally. | | 9200002 | the administrator application does not have permission to manage the device. |
**示例:** **示例:**
...@@ -71,7 +71,7 @@ addAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, ca ...@@ -71,7 +71,7 @@ addAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, ca
**参数:** **参数:**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- | | ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | | admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appIds | Array&lt;string&gt; | 是 | 允许安装包的白名单。 | | appIds | Array&lt;string&gt; | 是 | 允许安装包的白名单。 |
...@@ -84,8 +84,8 @@ addAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, ca ...@@ -84,8 +84,8 @@ addAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, ca
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- | | ------- | ---------------------------------------------------------------------------- |
| 9200003 | the administrator ability component is invalid. | | 9200001 | the application is not an administrator of the device. |
| 9200007 | the system ability work abnormally. | | 9200002 | the administrator application does not have permission to manage the device. |
**示例:** **示例:**
...@@ -117,7 +117,7 @@ addAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number): ...@@ -117,7 +117,7 @@ addAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number):
**参数:** **参数:**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- | | ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | | admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appIds | Array&lt;string&gt; | 是 | 允许安装包的白名单。 | | appIds | Array&lt;string&gt; | 是 | 允许安装包的白名单。 |
...@@ -135,8 +135,8 @@ addAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number): ...@@ -135,8 +135,8 @@ addAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number):
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- | | ------- | ---------------------------------------------------------------------------- |
| 9200003 | the administrator ability component is invalid. | | 9200001 | the application is not an administrator of the device. |
| 9200007 | the system ability work abnormally. | | 9200002 | the administrator application does not have permission to manage the device. |
**示例:** **示例:**
...@@ -168,7 +168,7 @@ removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, callback: Async ...@@ -168,7 +168,7 @@ removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, callback: Async
**参数:** **参数:**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- | | -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | | admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appIds | Array&lt;string&gt; | 是 | 移除允许安装包的白名单。 | | appIds | Array&lt;string&gt; | 是 | 移除允许安装包的白名单。 |
...@@ -180,8 +180,8 @@ removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, callback: Async ...@@ -180,8 +180,8 @@ removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, callback: Async
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- | | ------- | ---------------------------------------------------------------------------- |
| 9200003 | the administrator ability component is invalid. | | 9200001 | the application is not an administrator of the device. |
| 9200007 | the system ability work abnormally. | | 9200002 | the administrator application does not have permission to manage the device. |
**示例:** **示例:**
...@@ -213,7 +213,7 @@ removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, ...@@ -213,7 +213,7 @@ removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number,
**参数:** **参数:**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- | | ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | | admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appIds | Array&lt;string&gt; | 是 | 允许安装包的白名单。 | | appIds | Array&lt;string&gt; | 是 | 允许安装包的白名单。 |
...@@ -226,8 +226,8 @@ removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, ...@@ -226,8 +226,8 @@ removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number,
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- | | ------- | ---------------------------------------------------------------------------- |
| 9200003 | the administrator ability component is invalid. | | 9200001 | the application is not an administrator of the device. |
| 9200007 | the system ability work abnormally. | | 9200002 | the administrator application does not have permission to manage the device. |
**示例:** **示例:**
...@@ -259,7 +259,7 @@ removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number ...@@ -259,7 +259,7 @@ removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number
**参数:** **参数:**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- | | ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | | admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appIds | Array\&lt;string&gt; | 是 | 允许安装包的白名单。 | | appIds | Array\&lt;string&gt; | 是 | 允许安装包的白名单。 |
...@@ -277,8 +277,8 @@ removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number ...@@ -277,8 +277,8 @@ removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- | | ------- | ---------------------------------------------------------------------------- |
| 9200003 | the administrator ability component is invalid. | | 9200001 | the application is not an administrator of the device. |
| 9200007 | the system ability work abnormally. | | 9200002 | the administrator application does not have permission to manage the device. |
**示例:** **示例:**
...@@ -310,7 +310,7 @@ getAllowedInstallBundles(admin: Want, callback: AsyncCallback&lt;Array&lt;string ...@@ -310,7 +310,7 @@ getAllowedInstallBundles(admin: Want, callback: AsyncCallback&lt;Array&lt;string
**参数:** **参数:**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- | | -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | | admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | | callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
...@@ -321,8 +321,8 @@ getAllowedInstallBundles(admin: Want, callback: AsyncCallback&lt;Array&lt;string ...@@ -321,8 +321,8 @@ getAllowedInstallBundles(admin: Want, callback: AsyncCallback&lt;Array&lt;string
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- | | ------- | ---------------------------------------------------------------------------- |
| 9200003 | the administrator ability component is invalid. | | 9200001 | the application is not an administrator of the device. |
| 9200007 | the system ability work abnormally. | | 9200002 | the administrator application does not have permission to manage the device. |
**示例:** **示例:**
...@@ -353,7 +353,7 @@ getAllowedInstallBundles(admin: Want, userId: number, callback: AsyncCallback&lt ...@@ -353,7 +353,7 @@ getAllowedInstallBundles(admin: Want, userId: number, callback: AsyncCallback&lt
**参数:** **参数:**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- | | -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | | admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | | userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
...@@ -365,8 +365,8 @@ getAllowedInstallBundles(admin: Want, userId: number, callback: AsyncCallback&lt ...@@ -365,8 +365,8 @@ getAllowedInstallBundles(admin: Want, userId: number, callback: AsyncCallback&lt
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- | | ------- | ---------------------------------------------------------------------------- |
| 9200003 | the administrator ability component is invalid. | | 9200001 | the application is not an administrator of the device. |
| 9200007 | the system ability work abnormally. | | 9200002 | the administrator application does not have permission to manage the device. |
**示例:** **示例:**
...@@ -397,7 +397,7 @@ getAllowedInstallBundles(admin: Want, userId?: number): Promise&lt;Array&lt;stri ...@@ -397,7 +397,7 @@ getAllowedInstallBundles(admin: Want, userId?: number): Promise&lt;Array&lt;stri
**参数:** **参数:**
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- | | ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | | admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | | userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
...@@ -414,8 +414,8 @@ getAllowedInstallBundles(admin: Want, userId?: number): Promise&lt;Array&lt;stri ...@@ -414,8 +414,8 @@ getAllowedInstallBundles(admin: Want, userId?: number): Promise&lt;Array&lt;stri
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- | | ------- | ---------------------------------------------------------------------------- |
| 9200003 | the administrator ability component is invalid. | | 9200001 | the application is not an administrator of the device. |
| 9200007 | the system ability work abnormally. | | 9200002 | the administrator application does not have permission to manage the device. |
**示例:** **示例:**
...@@ -430,3 +430,421 @@ bundleManager.getAllowedInstallBundles(wantTemp, 100).then(() => { ...@@ -430,3 +430,421 @@ bundleManager.getAllowedInstallBundles(wantTemp, 100).then(() => {
console.log("error code:" + error.code + " error message:" + error.message); console.log("error code:" + error.code + " error message:" + error.message);
}); });
``` ```
## bundleManager.addDisallowedInstallBundles
addDisallowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback&lt;void&gt;): void;
指定设备管理员应用添加包安装黑名单接口,添加至黑名单的应用不允许安装,使用callback形式返回是否添加成功。
**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appIds | Array&lt;string&gt; | 是 | 不允许安装包的黑名单。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
let appIds = {"com.example.myapplication"};
bundleManager.AddDisallowedInstallBundles(wantTemp, appIds, (error) => {
if (error != null) {
console.log("error code:" + error.code + " error message:" + error.message);
}
});
```
## bundleManager.addDisallowedInstallBundles
addDisallowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback&lt;void&gt;): void;
指定设备管理员应用添加包安装黑名单接口,添加至黑名单的应用不允许在指定用户(通过userId指定)下安装,使用callback形式返回是否添加成功。
**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appIds | Array&lt;string&gt; | 是 | 不允许安装包的黑名单。 |
| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
let appIds = {"com.example.myapplication"};
bundleManager.AddDisallowedInstallBundles(wantTemp, appIds, 100, (error) => {
if (error != null) {
console.log("error code:" + error.code + " error message:" + error.message);
}
});
```
## bundleManager.addDisallowedInstallBundles
addDisallowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise&lt;void&gt;;
指定设备管理员应用添加包安装黑名单接口。如果调用接口时传入了可选参数userId,则添加至黑名单的应用不允许在指定用户下安装;如果调用接口时没有传入参数userId,则添加至黑名单的应用不允许在当前用户下安装,使用promise形式返回是否添加成功。
**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appIds | Array&lt;string&gt; | 是 | 不允许安装包的黑名单。 |
| userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。当指定设备管理员应用添加包安装黑名单失败时会抛出错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
let appIds = {"com.example.myapplication"};
bundleManager.addDisallowedInstallBundles(wantTemp, appIds, 100).then(() => {
console.log("success");
}).catch(error => {
console.log("error code:" + error.code + " error message:" + error.message);
});
```
## bundleManager.removeDisallowedInstallBundles
removeDisallowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback&lt;void&gt;): void;
指定设备管理员应用移除包安装黑名单接口,在黑名单存在的情况下,在包安装黑名单中的应用不允许在当前用户下安装,使用callback形式返回移除结果。
**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appIds | Array&lt;string&gt; | 是 | 移除不允许安装包的黑名单。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
let appIds = {"com.example.myapplication"};
bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, (error) => {
if (error != null) {
console.log("error code:" + error.code + " error message:" + error.message);
}
});
```
## bundleManager.removeDisallowedInstallBundles
removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback&lt;void&gt;): void;
指定设备管理员应用移除包安装黑名单接口,在黑名单存在的情况下,在包安装黑名单中的应用不允许在指定用户(通过userId指定)下安装,使用callback形式返回移除结果。
**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appIds | Array&lt;string&gt; | 是 | 不允许安装包的黑名单。 |
| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
let appIds = {"com.example.myapplication"};
bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, 100, (error) => {
if (error != null) {
console.log("error code:" + error.code + " error message:" + error.message);
}
});
```
## bundleManager.removeDisallowedInstallBundles
removeDisallowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise&lt;void&gt;;
指定设备管理员应用移除包安装黑名单接口。在黑名单存在的情况下,如果调用接口时传入参数userId,则在包安装黑名单中的应用不允许在指定用户下安装;如果调用接口时没有传入参数userId,则在包安装黑名单中的应用不允许在当前用户下安装,使用promise形式返回移除结果。
**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appIds | Array\&lt;string&gt; | 是 | 不允许安装包的黑名单。 |
| userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。当指定设备管理员应用移除包安装黑名单失败时会抛出错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
let appIds = {"com.example.myapplication"};
bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, 100).then(() => {
console.log("success");
}).catch(error => {
console.log("error code:" + error.code + " error message:" + error.message);
});
```
## bundleManager.getDisallowedInstallBundles
getDisallowedInstallBundles(admin: Want, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void;
指定管理员应用获取管理员用户下的包安装黑名单接口,使用callback形式返回获取包安装黑名单。
**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
bundleManager.getDisallowedInstallBundles(wantTemp, (error) => {
if (error != null) {
console.log("error code:" + error.code + " error message:" + error.message);
}
});
```
## bundleManager.getDisallowedInstallBundles
getDisallowedInstallBundles(admin: Want, userId: number, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void;
指定管理员应用获取指定用户(通过userId指定)下的包安装黑名单接口,使用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&lt;Array&lt;string&gt;&gt; | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
bundleManager.getDisallowedInstallBundles(wantTemp, 100, (error) => {
if (error != null) {
console.log("error code:" + error.code + " error message:" + error.message);
}
});
```
## bundleManager.getDisallowedInstallBundles
getDisallowedInstallBundles(admin: Want, userId?: number): Promise&lt;Array&lt;string&gt;&gt;;
如果调用接口时传入参数userId,指定管理员应用获取指定用户下包安装黑名单接口。如果调用接口时没有传入参数userId,指定管理员应用获取当前用户下包安装黑名单接口,使用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&lt;Array&lt;string&gt;&gt; | Promise对象,返回管理员用户下的包安装白名单。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
bundleManager.getDisallowedInstallBundles(wantTemp, 100).then(() => {
console.log("success");
}).catch(error => {
console.log("error code:" + error.code + " error message:" + error.message);
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册