harmony 鸿蒙@ohos.enterprise.bundleManager(包管理)(系统接口)
@ohos.enterprise.bundleManager(包管理)(系统接口)
本模块提供包管理能力,包括添加包安装白名单、获取包安装白名单、移除包安装白名单等。
说明:
本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
本模块接口仅可在Stage模型下使用。
本模块接口仅对设备管理应用开放,需将设备管理应用激活后调用。
当前页面仅包含本模块的系统接口,其他公开接口参见。其他公开接口参见@ohos.enterprise.bundleManager。
导入模块
import { bundleManager } from '@kit.MDMKit';
bundleManager.addAllowedInstallBundles
addAllowedInstallBundles(admin: Want, appIds: Array<string>, callback: AsyncCallback<void>): void
添加应用至当前用户的应用程序包安装白名单,添加至白名单的应用允许在当前用户下安装,否则不允许安装,使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
appIds | Array<string> | 是 | 应用ID数组。 |
callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appIds: Array<string> = ['com.example.******_******/******5t5CoBM='];
bundleManager.addAllowedInstallBundles(wantTemp, appIds, (err) => {
if (err) {
console.error(`Failed to add allowed install bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in adding allowed install bundles');
});
bundleManager.addAllowedInstallBundles
addAllowedInstallBundles(admin: Want, appIds: Array<string>, userId: number, callback: AsyncCallback<void>): void
添加应用至应用程序包安装白名单,添加至白名单的应用允许在指定用户(通过userId指定)下安装,否则不允许安装,使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
appIds | Array<string> | 是 | 应用ID数组。 |
userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 |
callback | AsyncCallback<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appIds: Array<string> = ['com.example.******_******/******5t5CoBM='];
bundleManager.addAllowedInstallBundles(wantTemp, appIds, 100, (err) => {
if (err) {
console.error(`Failed to add allowed install bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in adding allowed install bundles');
});
bundleManager.addAllowedInstallBundles
addAllowedInstallBundles(admin: Want, appIds: Array<string>, userId?: number): Promise<void>
添加应用至应用程序包安装白名单,添加至白名单的应用允许在当前/指定用户下安装,否则不允许安装。使用promise异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
appIds | Array<string> | 是 | 应用ID数组。 |
userId | number | 否 | 用户ID,取值范围:大于等于0。 - 调用接口时,若传入userId,表示指定用户。 - 调用接口时,若未传入userId,表示当前用户。 |
返回值:
类型 | 说明 |
---|---|
Promise<void> | 无返回结果的Promise对象。当添加应用程序包安装白名单失败时,会抛出错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appIds: Array<string> = ['com.example.******_******/******5t5CoBM='];
bundleManager.addAllowedInstallBundles(wantTemp, appIds, 100).then(() => {
console.info('Succeeded in adding allowed install bundles');
}).catch((err: BusinessError) => {
console.error(`Failed to add allowed install bundles. Code is ${err.code}, message is ${err.message}`);
});
bundleManager.removeAllowedInstallBundles
removeAllowedInstallBundles(admin: Want, appIds: Array<string>, callback: AsyncCallback<void>): void
移除当前用户的应用程序包安装白名单中的指定应用。安装白名单存在时,不在白名单中的应用不允许在当前用户下安装,使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
appIds | Array<string> | 是 | 应用ID数组。 |
callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appIds: Array<string> = ['com.example.******_******/******5t5CoBM='];
bundleManager.removeAllowedInstallBundles(wantTemp, appIds, (err) => {
if (err) {
console.error(`Failed to remove allowed install bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in removing allowed install bundles');
});
bundleManager.removeAllowedInstallBundles
removeAllowedInstallBundles(admin: Want, appIds: Array<string>, userId: number, callback: AsyncCallback<void>): void
移除在应用程序包安装白名单中的应用,在白名单存在的情况下,不在白名单中的应用不允许在指定用户(通过userId指定)下安装,使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
appIds | Array<string> | 是 | 应用ID数组。 |
userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 |
callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appIds: Array<string> = ['com.example.******_******/******5t5CoBM='];
bundleManager.removeAllowedInstallBundles(wantTemp, appIds, 100, (err) => {
if (err) {
console.error(`Failed to remove allowed install bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in removing allowed install bundles');
});
bundleManager.removeAllowedInstallBundles
removeAllowedInstallBundles(admin: Want, appIds: Array<string>, userId?: number): Promise<void>
移除在应用程序包安装白名单中的应用,在白名单存在的情况下,不在白名单中的应用不允许在当前/指定用户下安装。使用promise异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
appIds | Array<string> | 是 | 应用ID数组。 |
userId | number | 否 | 用户ID,取值范围:大于等于0。 - 调用接口时,若传入userId,表示指定用户。 - 调用接口时,若未传入userId,表示当前用户。 |
返回值:
类型 | 说明 |
---|---|
Promise<void> | 无返回结果的Promise对象。当移除应用程序包安装白名单失败时,会抛出错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appIds: Array<string> = ['com.example.******_******/******5t5CoBM='];
bundleManager.removeAllowedInstallBundles(wantTemp, appIds, 100).then(() => {
console.info('Succeeded in removing allowed install bundles');
}).catch((err: BusinessError) => {
console.error(`Failed to remove allowed install bundles. Code is ${err.code}, message is ${err.message}`);
});
bundleManager.getAllowedInstallBundles
getAllowedInstallBundles(admin: Want, callback: AsyncCallback<Array<string>>): void
获取当前用户下的应用程序包安装白名单,使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
callback | AsyncCallback<Array<string>> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
bundleManager.getAllowedInstallBundles(wantTemp, (err, result) => {
if (err) {
console.error(`Failed to get allowed install bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info(`Succeeded in getting allowed install bundles, result : ${JSON.stringify(result)}`);
});
bundleManager.getAllowedInstallBundles
getAllowedInstallBundles(admin: Want, userId: number, callback: AsyncCallback<Array<string>>): void
获取指定用户(通过userId指定)下的应用程序包安装白名单,使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 |
callback | AsyncCallback<Array<string>> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
bundleManager.getAllowedInstallBundles(wantTemp, 100, (err, result) => {
if (err) {
console.error(`Failed to get allowed install bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info(`Succeeded in getting allowed install bundles, result : ${JSON.stringify(result)}`);
});
bundleManager.getAllowedInstallBundles
getAllowedInstallBundles(admin: Want, userId?: number): Promise<Array<string>>
获取当前/指定用户下的应用程序包安装白名单,使用promise异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
userId | number | 否 | 用户ID,取值范围:大于等于0。 - 调用接口时,若传入userId,表示指定用户。 - 调用接口时,若未传入userId,表示当前用户。 |
返回值:
类型 | 说明 |
---|---|
Promise<Array<string>> | Promise对象,返回当前/指定用户下的应用程序包安装白名单。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
bundleManager.getAllowedInstallBundles(wantTemp, 100).then((result) => {
console.info(`Succeeded in getting allowed install bundles, result : ${JSON.stringify(result)}`);
}).catch((err: BusinessError) => {
console.error(`Failed to get allowed install bundles. Code is ${err.code}, message is ${err.message}`);
});
bundleManager.addDisallowedInstallBundles
addDisallowedInstallBundles(admin: Want, appIds: Array<string>, callback: AsyncCallback<void>): void
添加应用至应用程序包安装黑名单,添加至黑名单的应用不允许在当前用户下安装,使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
appIds | Array<string> | 是 | 应用ID数组。 |
callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appIds: Array<string> = ['com.example.******_******/******5t5CoBM='];
bundleManager.addDisallowedInstallBundles(wantTemp, appIds, (err) => {
if (err) {
console.error(`Failed to add disallowed install bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in adding disallowed install bundles');
});
bundleManager.addDisallowedInstallBundles
addDisallowedInstallBundles(admin: Want, appIds: Array<string>, userId: number, callback: AsyncCallback<void>): void
添加应用至应用程序包安装黑名单,添加至黑名单的应用不允许在指定用户(通过userId指定)下安装。使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
appIds | Array<string> | 是 | 应用ID数组。 |
userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 |
callback | AsyncCallback<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appIds: Array<string> = ['com.example.******_******/******5t5CoBM='];
bundleManager.addDisallowedInstallBundles(wantTemp, appIds, 100, (err) => {
if (err) {
console.error(`Failed to add disallowed install bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in adding disallowed install bundles');
});
bundleManager.addDisallowedInstallBundles
addDisallowedInstallBundles(admin: Want, appIds: Array<string>, userId?: number): Promise<void>
添加应用至应用程序包安装黑名单,添加至黑名单的应用不允许在当前/指定用户下安装。使用promise异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
appIds | Array<string> | 是 | 应用ID数组。 |
userId | number | 否 | 用户ID,取值范围:大于等于0。 - 调用接口时,若传入userId,表示指定用户。 - 调用接口时,若未传入userId,表示当前用户。 |
返回值:
类型 | 说明 |
---|---|
Promise<void> | 无返回结果的Promise对象。当添加应用程序包安装黑名单失败时,会抛出错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appIds: Array<string> = ['com.example.******_******/******5t5CoBM='];
bundleManager.addDisallowedInstallBundles(wantTemp, appIds, 100).then(() => {
console.info('Succeeded in adding disallowed install bundles');
}).catch((err: BusinessError) => {
console.error(`Failed to add disallowed install bundles. Code is ${err.code}, message is ${err.message}`);
});
bundleManager.removeDisallowedInstallBundles
removeDisallowedInstallBundles(admin: Want, appIds: Array<string>, callback: AsyncCallback<void>): void
移除在应用程序包安装黑名单中的应用,在黑名单存在的情况下,在黑名单中的应用不允许在当前用户下安装。使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
appIds | Array<string> | 是 | 应用ID数组。 |
callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appIds: Array<string> = ['com.example.******_******/******5t5CoBM='];
bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, (err) => {
if (err) {
console.error(`Failed to remove disallowed install bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in removing disallowed install bundles');
});
bundleManager.removeDisallowedInstallBundles
removeDisallowedInstallBundles(admin: Want, appIds: Array<string>, userId: number, callback: AsyncCallback<void>): void
移除在应用程序包安装黑名单中的应用,在黑名单存在的情况下,在黑名单中的应用不允许在指定用户(通过userId指定)下安装,使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
appIds | Array<string> | 是 | 应用ID数组。 |
userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 |
callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appIds: Array<string> = ['com.example.******_******/******5t5CoBM='];
bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, 100, (err) => {
if (err) {
console.error(`Failed to remove disallowed install bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in removing disallowed install bundles');
});
bundleManager.removeDisallowedInstallBundles
removeDisallowedInstallBundles(admin: Want, appIds: Array<string>, userId?: number): Promise<void>
移除在应用程序包安装黑名单中的应用,在黑名单存在的情况下,在黑名单中的应用不允许在当前/指定用户下安装。使用promise异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
appIds | Array<string> | 是 | 应用ID数组。 |
userId | number | 否 | 用户ID,取值范围:大于等于0。 - 调用接口时,若传入userId,表示指定用户。 - 调用接口时,若未传入userId,表示当前用户。 |
返回值:
类型 | 说明 |
---|---|
Promise<void> | 无返回结果的Promise对象。当移除应用程序包安装黑名单失败时,会抛出错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appIds: Array<string> = ['com.example.******_******/******5t5CoBM='];
bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, 100).then(() => {
console.info('Succeeded in removing disallowed install bundles');
}).catch((err: BusinessError) => {
console.error(`Failed to remove disallowed install bundles. Code is ${err.code}, message is ${err.message}`);
});
bundleManager.getDisallowedInstallBundles
getDisallowedInstallBundles(admin: Want, callback: AsyncCallback<Array<string>>): void
获取当前用户下的应用程序包安装黑名单,使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
callback | AsyncCallback<Array<string>> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
bundleManager.getDisallowedInstallBundles(wantTemp, (err, result) => {
if (err) {
console.error(`Failed to get disallowed install bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info(`Succeeded in getting disallowed install bundles, result : ${JSON.stringify(result)}`);
});
bundleManager.getDisallowedInstallBundles
getDisallowedInstallBundles(admin: Want, userId: number, callback: AsyncCallback<Array<string>>): void
获取指定用户(通过userId指定)下的应用程序包安装黑名单,使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 |
callback | AsyncCallback<Array<string>> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
bundleManager.getDisallowedInstallBundles(wantTemp, 100, (err, result) => {
if (err) {
console.error(`Failed to get disallowed install bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info(`Succeeded in getting disallowed install bundles, result : ${JSON.stringify(result)}`);
});
bundleManager.getDisallowedInstallBundles
getDisallowedInstallBundles(admin: Want, userId?: number): Promise<Array<string>>
获取当前/指定用户下的应用程序包安装黑名单,使用promise异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
userId | number | 否 | 用户ID,取值范围:大于等于0。 - 调用接口时,若传入userId,表示指定用户。 - 调用接口时,若未传入userId,表示当前用户。 |
返回值:
类型 | 说明 |
---|---|
Promise<Array<string>> | Promise对象,返回当前/指定用户下的应用程序包安装黑名单。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
bundleManager.getDisallowedInstallBundles(wantTemp, 100).then((result) => {
console.info(`Succeeded in getting disallowed install bundles, result : ${JSON.stringify(result)}`);
}).catch((err: BusinessError) => {
console.error(`Failed to get disallowed install bundles. Code is ${err.code}, message is ${err.message}`);
});
bundleManager.addDisallowedUninstallBundles
addDisallowedUninstallBundles(admin: Want, appIds: Array<string>, callback: AsyncCallback<void>): void
添加应用至应用程序包卸载黑名单,添加至黑名单的应用不允许在当前用户下卸载,使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
appIds | Array<string> | 是 | 应用ID数组。 |
callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appIds: Array<string> = ['com.example.******_******/******5t5CoBM='];
bundleManager.addDisallowedUninstallBundles(wantTemp, appIds, (err) => {
if (err) {
console.error(`Failed to add disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in adding disallowed uninstall bundles');
});
bundleManager.addDisallowedUninstallBundles
addDisallowedUninstallBundles(admin: Want, appIds: Array<string>, userId: number, callback: AsyncCallback<void>): void
添加应用至应用程序包卸载黑名单,添加至黑名单的应用不允许在指定用户(通过userId指定)下卸载。使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
appIds | Array<string> | 是 | 应用ID数组。 |
userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 |
callback | AsyncCallback<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appIds: Array<string> = ['com.example.******_******/******5t5CoBM='];
bundleManager.addDisallowedUninstallBundles(wantTemp, appIds, 100, (err) => {
if (err) {
console.error(`Failed to add disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in adding disallowed uninstall bundles');
});
bundleManager.addDisallowedUninstallBundles
addDisallowedUninstallBundles(admin: Want, appIds: Array<string>, userId?: number): Promise<void>
添加应用至应用程序包卸载黑名单,添加至黑名单的应用不允许在当前/指定用户下卸载。使用promise异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
appIds | Array<string> | 是 | 应用ID数组。 |
userId | number | 否 | 用户ID,取值范围:大于等于0。 - 调用接口时,若传入userId,表示指定用户。 - 调用接口时,若未传入userId,表示当前用户。 |
返回值:
类型 | 说明 |
---|---|
Promise<void> | 无返回结果的Promise对象。当添加应用程序包卸载黑名单失败时,会抛出错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appIds: Array<string> = ['com.example.******_******/******5t5CoBM='];
bundleManager.addDisallowedUninstallBundles(wantTemp, appIds, 100).then(() => {
console.info('Succeeded in adding disallowed uninstall bundles');
}).catch((err: BusinessError) => {
console.error(`Failed to add disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`);
});
bundleManager.removeDisallowedUninstallBundles
removeDisallowedUninstallBundles(admin: Want, appIds: Array<string>, callback: AsyncCallback<void>): void
移除在应用程序包卸载黑名单中的应用,在黑名单存在的情况下,在黑名单中的应用不允许在当前用户下卸载,使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
appIds | Array<string> | 是 | 应用ID数组。 |
callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appIds: Array<string> = ['com.example.******_******/******5t5CoBM='];
bundleManager.removeDisallowedUninstallBundles(wantTemp, appIds, (err) => {
if (err) {
console.error(`Failed to remove disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in removing disallowed uninstall bundles');
});
bundleManager.removeDisallowedUninstallBundles
removeDisallowedUninstallBundles(admin: Want, appIds: Array<string>, userId: number, callback: AsyncCallback<void>): void
移除在应用程序包卸载黑名单中的应用,在黑名单存在的情况下,在黑名单中的应用不允许在指定用户(通过userId指定)下卸载。使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
appIds | Array<string> | 是 | 应用ID数组。 |
userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 |
callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appIds: Array<string> = ['com.example.******_******/******5t5CoBM='];
bundleManager.removeDisallowedUninstallBundles(wantTemp, appIds, 100, (err) => {
if (err) {
console.error(`Failed to remove disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in removing disallowed uninstall bundles');
});
bundleManager.removeDisallowedUninstallBundles
removeDisallowedUninstallBundles(admin: Want, appIds: Array<string>, userId?: number): Promise<void>
移除在应用程序包卸载黑名单中的应用。在黑名单存在的情况下,在黑名单中的应用不允许在当前/指定用户下卸载。使用promise异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
appIds | Array<string> | 是 | 应用ID数组。 |
userId | number | 否 | 用户ID,取值范围:大于等于0。 - 调用接口时,若传入userId,表示指定用户。 - 调用接口时,若未传入userId,表示当前用户。 |
返回值:
类型 | 说明 |
---|---|
Promise<void> | 无返回结果的Promise对象。当移除应用程序包卸载黑名单失败时会抛出错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let appIds: Array<string> = ['com.example.******_******/******5t5CoBM='];
bundleManager.removeDisallowedUninstallBundles(wantTemp, appIds, 100).then(() => {
console.info('Succeeded in removing disallowed uninstall bundles');
}).catch((err: BusinessError) => {
console.error(`Failed to remove disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`);
});
bundleManager.getDisallowedUninstallBundles
getDisallowedUninstallBundles(admin: Want, callback: AsyncCallback<Array<string>>): void
获取当前用户下的应用程序包卸载黑名单,使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
callback | AsyncCallback<Array<string>> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
bundleManager.getDisallowedUninstallBundles(wantTemp, (err, result) => {
if (err) {
console.error(`Failed to get disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info(`Succeeded in getting disallowed uninstall bundles, result : ${JSON.stringify(result)}`);
});
bundleManager.getDisallowedUninstallBundles
getDisallowedUninstallBundles(admin: Want, userId: number, callback: AsyncCallback<Array<string>>): void
获取指定用户(通过userId指定)下的应用程序包卸载黑名单,使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 |
callback | AsyncCallback<Array<string>> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
bundleManager.getDisallowedUninstallBundles(wantTemp, 100, (err, result) => {
if (err) {
console.error(`Failed to get disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info(`Succeeded in getting disallowed uninstall bundles, result : ${JSON.stringify(result)}`);
});
bundleManager.getDisallowedUninstallBundles
getDisallowedUninstallBundles(admin: Want, userId?: number): Promise<Array<string>>
获取当前/指定用户下应用程序包卸载黑名单接口,使用promise异步回调。
需要权限: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
userId | number | 否 | 用户ID,取值范围:大于等于0。 - 调用接口时,若传入userId,表示指定用户。 - 调用接口时,若未传入userId,表示当前用户。 |
返回值:
类型 | 说明 |
---|---|
Promise<Array<string>> | Promise对象,返回当前/指定用户下的应用程序包卸载黑名单。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
bundleManager.getDisallowedUninstallBundles(wantTemp, 100).then((result) => {
console.info(`Succeeded in getting disallowed uninstall bundles, result : ${JSON.stringify(result)}`);
}).catch((err: BusinessError) => {
console.error(`Failed to get disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`);
});
bundleManager.uninstall
uninstall(admin: Want, bundleName: string, callback: AsyncCallback<void>): void
卸载当前用户下的指定应用程序包,且不保留应用程序包数据。使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_INSTALL_BUNDLE
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
bundleName | string | 是 | 包名。 |
callback | AsyncCallback<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
bundleManager.uninstall(wantTemp, 'bundleName', (err) => {
if (err) {
console.error(`Failed to uninstall bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in uninstalling bundles');
});
bundleManager.uninstall
uninstall(admin: Want, bundleName: string, userId: number, callback: AsyncCallback<void>): void
卸载指定用户下(由参数userId指定)的指定应用程序包,且不保留应用程序包数据。使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_INSTALL_BUNDLE
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
bundleName | string | 是 | 包名。 |
userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 |
callback | AsyncCallback<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
bundleManager.uninstall(wantTemp, 'bundleName', 100, (err) => {
if (err) {
console.error(`Failed to uninstall bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in uninstalling bundles');
});
bundleManager.uninstall
uninstall(admin: Want, bundleName: string, isKeepData: boolean, callback: AsyncCallback<void>): void
卸载当前用户下的指定应用程序包,选择是否保留应用程序包数据(由isKeepData指定)。使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_INSTALL_BUNDLE
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
bundleName | string | 是 | 包名。 |
isKeepData | boolean | 是 | 是否保留包数据,true表示保留,false表示不保留。 |
callback | AsyncCallback<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
bundleManager.uninstall(wantTemp, 'bundleName', true, (err) => {
if (err) {
console.error(`Failed to uninstall bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in uninstalling bundles');
});
bundleManager.uninstall
uninstall(admin: Want, bundleName: string, userId: number, isKeepData: boolean, callback: AsyncCallback<void>): void
卸载指定用户下(由参数userId指定)的指定应用程序包接口,选择是否保留应用程序包数据(由isKeepData指定)。使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_INSTALL_BUNDLE
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
bundleName | string | 是 | 包名。 |
userId | number | 是 | 用户ID,指定具体用户。取值范围:大于等于0。 |
isKeepData | boolean | 是 | 是否保留包数据,true表示保留,false表示不保留。 |
callback | AsyncCallback<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
bundleManager.uninstall(wantTemp, 'bundleName', 100, true, (err) => {
if (err) {
console.error(`Failed to uninstall bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in uninstalling bundles');
});
bundleManager.install
install(admin: Want, hapFilePaths: Array<string>, callback: AsyncCallback<void>): void
安装指定路径下的应用包。使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_INSTALL_BUNDLE
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
hapFilePaths | Array<string> | 是 | 待安装应用包路径数组。 |
callback | AsyncCallback<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
9201002 | Failed to install the application. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let hapFilePaths: Array<string> = ['/data/storage/el2/base/haps/entry/testinstall/ExtensionTest.hap'];
bundleManager.install(wantTemp, hapFilePaths, (err) => {
if (err) {
console.error(`Failed to install bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in installing bundles');
});
bundleManager.install
install(admin: Want, hapFilePaths: Array<string>, installParam: InstallParam, callback: AsyncCallback<void>): void
安装指定路径下的指定安装参数的应用包。使用callback异步回调。
需要权限: ohos.permission.ENTERPRISE_INSTALL_BUNDLE
系统能力: SystemCapability.Customization.EnterpriseDeviceManager
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
admin | Want | 是 | 企业设备管理扩展组件。 |
hapFilePaths | Array<string> | 是 | 待安装应用包路径数组。 |
installParam | InstallParam | 是 | 应用包安装参数。 |
callback | AsyncCallback<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
错误码:
错误码ID | 错误信息 |
---|---|
9200001 | The application is not an administrator application of the device. |
9200002 | The administrator application does not have permission to manage the device. |
9201002 | Failed to install the application. |
201 | Permission verification failed. The application does not have the permission required to call the API. |
202 | Permission verification failed. A non-system application calls a system API. |
401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
示例:
import { Want } from '@kit.AbilityKit';
let wantTemp: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
};
let hapFilePaths: Array<string> = ['/data/storage/el2/base/haps/entry/testinstall/ExtensionTest.hap'];
let installParam: bundleManager.InstallParam = {
userId: 100,
installFlag: 1,
};
bundleManager.install(wantTemp, hapFilePaths, installParam, (err) => {
if (err) {
console.error(`Failed to install bundles. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in installing bundles');
});
你可能感兴趣的鸿蒙文章
harmony 鸿蒙@ohos.enterprise.EnterpriseAdminExtensionAbility(企业设备管理扩展能力)
harmony 鸿蒙@ohos.enterprise.accountManager(账户管理)(系统接口)
harmony 鸿蒙@ohos.enterprise.accountManager(账户管理)
harmony 鸿蒙@ohos.enterprise.adminManager(企业设备管理)(系统接口)
harmony 鸿蒙@ohos.enterprise.adminManager (admin权限管理)
harmony 鸿蒙@ohos.enterprise.applicationManager(应用管理)(系统接口)
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦