1/* 2 * Copyright (c) 2023-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit MDMKit 19 */ 20 21import type { AsyncCallback } from './@ohos.base'; 22import type Want from './@ohos.app.ability.Want'; 23 24/** 25 * This module provides the capability to manage the applications of the enterprise devices. 26 * 27 * @namespace applicationManager 28 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 29 * @since 10 30 */ 31declare namespace applicationManager { 32 /** 33 * Add appid list of bundles that is disallowed to run in the device. 34 * This function can be called by a super administrator. 35 * 36 * @permission ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY 37 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 38 * The admin must have the corresponding permission. 39 * @param { Array<string> } appIds - ids of the bundle are disallowed to run. The size of the array after setting 40 * cannot be greater than 200. 41 * @param { AsyncCallback<void> } callback - the callback of addDisallowedRunningBundles. 42 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 43 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 44 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 45 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 46 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 47 * 2. Incorrect parameter types; 3. Parameter verification failed. 48 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 49 * @systemapi 50 * @StageModelOnly 51 * @since 10 52 */ 53 function addDisallowedRunningBundles(admin: Want, appIds: Array<string>, callback: AsyncCallback<void>): void; 54 55 /** 56 * Add appid list of bundles that is disallowed to run in the device. 57 * This function can be called by a super administrator. 58 * 59 * @permission ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY 60 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 61 * The admin must have the corresponding permission. 62 * @param { Array<string> } appIds - ids of the bundle are disallowed to run. The size of the array after setting 63 * cannot be greater than 200. 64 * @param { number } userId - userId indicates the user ID. 65 * @param { AsyncCallback<void> } callback - the callback of addDisallowedRunningBundles. 66 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 67 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 68 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 69 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 70 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 71 * 2. Incorrect parameter types; 3. Parameter verification failed. 72 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 73 * @systemapi 74 * @StageModelOnly 75 * @since 10 76 */ 77 function addDisallowedRunningBundles(admin: Want, appIds: Array<string>, userId: number, callback: AsyncCallback<void>): void; 78 79 /** 80 * Add appid list of bundles that is disallowed to run in the device. 81 * This function can be called by a super administrator. 82 * 83 * @permission ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY 84 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 85 * The admin must have the corresponding permission. 86 * @param { Array<string> } appIds - ids of the bundle are disallowed to run. The size of the array after setting 87 * cannot be greater than 200. 88 * @param { number } userId - userId indicates the user ID. 89 * @returns { Promise<void> } the promise returned by the addDisallowedRunningBundles. 90 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 91 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 92 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 93 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 94 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 95 * 2. Incorrect parameter types; 3. Parameter verification failed. 96 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 97 * @systemapi 98 * @StageModelOnly 99 * @since 10 100 */ 101 function addDisallowedRunningBundles(admin: Want, appIds: Array<string>, userId?: number): Promise<void>; 102 103 /** 104 * Add appid list of bundles that is disallowed to run in the device. 105 * This function can be called by a super administrator. 106 * 107 * @permission ohos.permission.ENTERPRISE_MANAGE_APPLICATION 108 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 109 * The admin must have the corresponding permission. 110 * @param { Array<string> } appIds - ids of the bundle are disallowed to run. The size of the array after setting 111 * cannot be greater than 200. 112 * @param { number } [accountId] - accountId indicates the account ID. 113 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 114 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 115 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 116 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 117 * 2. Incorrect parameter types; 3. Parameter verification failed. 118 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 119 * @StageModelOnly 120 * @since 12 121 */ 122 function addDisallowedRunningBundlesSync(admin: Want, appIds: Array<string>, accountId?: number): void; 123 124 /** 125 * Remove appid list of bundles that is disallowed to run in the device. 126 * This function can be called by a super administrator. 127 * 128 * @permission ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY 129 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 130 * The admin must have the corresponding permission. 131 * @param { Array<string> } appIds - ids of the bundle are disallowed to run. The size of the array after setting 132 * cannot be greater than 200. 133 * @param { AsyncCallback<void> } callback - the callback of removeDisallowedRunningBundles. 134 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 135 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 136 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 137 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 138 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 139 * 2. Incorrect parameter types; 3. Parameter verification failed. 140 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 141 * @systemapi 142 * @StageModelOnly 143 * @since 10 144 */ 145 function removeDisallowedRunningBundles(admin: Want, appIds: Array<string>, callback: AsyncCallback<void>): void; 146 147 /** 148 * Remove appid list of bundles that is disallowed to run in the device. 149 * This function can be called by a super administrator. 150 * 151 * @permission ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY 152 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 153 * The admin must have the corresponding permission. 154 * @param { Array<string> } appIds - ids of the bundle are disallowed to run. The size of the array after setting 155 * cannot be greater than 200. 156 * @param { number } userId - userId indicates the user ID. 157 * @param { AsyncCallback<void> } callback - the callback of removeDisallowedRunningBundles. 158 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 159 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 160 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 161 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 162 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 163 * 2. Incorrect parameter types; 3. Parameter verification failed. 164 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 165 * @systemapi 166 * @StageModelOnly 167 * @since 10 168 */ 169 function removeDisallowedRunningBundles(admin: Want, appIds: Array<string>, userId: number, callback: AsyncCallback<void>): void; 170 171 /** 172 * Remove appid list of bundles that is disallowed to run in the device. 173 * This function can be called by a super administrator. 174 * 175 * @permission ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY 176 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 177 * The admin must have the corresponding permission. 178 * @param { Array<string> } appIds - ids of the bundle are disallowed to run. The size of the array after setting 179 * cannot be greater than 200. 180 * @param { number } userId - userId indicates the user ID. 181 * @returns { Promise<void> } the promise returned by the removeDisallowedRunningBundles. 182 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 183 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 184 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 185 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 186 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 187 * 2. Incorrect parameter types; 3. Parameter verification failed. 188 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 189 * @systemapi 190 * @StageModelOnly 191 * @since 10 192 */ 193 function removeDisallowedRunningBundles(admin: Want, appIds: Array<string>, userId?: number): Promise<void>; 194 195 /** 196 * Remove appid list of bundles that is disallowed to run in the device. 197 * This function can be called by a super administrator. 198 * 199 * @permission ohos.permission.ENTERPRISE_MANAGE_APPLICATION 200 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 201 * The admin must have the corresponding permission. 202 * @param { Array<string> } appIds - ids of the bundle are disallowed to run. The size of the array after setting 203 * cannot be greater than 200. 204 * @param { number } [accountId] - accountId indicates the user ID. 205 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 206 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 207 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 208 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 209 * 2. Incorrect parameter types; 3. Parameter verification failed. 210 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 211 * @StageModelOnly 212 * @since 12 213 */ 214 function removeDisallowedRunningBundlesSync(admin: Want, appIds: Array<string>, accountId?: number): void; 215 216 /** 217 * Get appid list of bundles that is disallowed to run in the device. 218 * This function can be called by a super administrator. 219 * 220 * @permission ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY 221 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 222 * The admin must have the corresponding permission. 223 * @param { AsyncCallback<Array<string>> } callback - the callback of getDisallowedRunningBundles. 224 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 225 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 226 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 227 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 228 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 229 * 2. Incorrect parameter types; 3. Parameter verification failed. 230 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 231 * @systemapi 232 * @StageModelOnly 233 * @since 10 234 */ 235 function getDisallowedRunningBundles(admin: Want, callback: AsyncCallback<Array<string>>): void; 236 237 /** 238 * Get appid list of bundles that is disallowed to run in the device. 239 * This function can be called by a super administrator. 240 * 241 * @permission ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY 242 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 243 * The admin must have the corresponding permission. 244 * @param { number } userId - userId indicates the user ID. 245 * @param { AsyncCallback<Array<string>> } callback - the callback of getDisallowedRunningBundles. 246 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 247 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 248 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 249 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 250 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 251 * 2. Incorrect parameter types; 3. Parameter verification failed. 252 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 253 * @systemapi 254 * @StageModelOnly 255 * @since 10 256 */ 257 function getDisallowedRunningBundles(admin: Want, userId: number, callback: AsyncCallback<Array<string>>): void; 258 259 /** 260 * Get appid list of bundles that is disallowed to run in the device. 261 * This function can be called by a super administrator. 262 * 263 * @permission ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY 264 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 265 * The admin must have the corresponding permission. 266 * @param { number } userId - userId indicates the user ID. 267 * @returns { Promise<Array<string>> } the promise returned by the getDisallowedRunningBundles. 268 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 269 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 270 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 271 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 272 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 273 * 2. Incorrect parameter types; 3. Parameter verification failed. 274 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 275 * @systemapi 276 * @StageModelOnly 277 * @since 10 278 */ 279 function getDisallowedRunningBundles(admin: Want, userId?: number): Promise<Array<string>>; 280 281 /** 282 * Get appid list of bundles that is disallowed to run in the device. 283 * This function can be called by a super administrator. 284 * 285 * @permission ohos.permission.ENTERPRISE_MANAGE_APPLICATION 286 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 287 * The admin must have the corresponding permission. 288 * @param { number } [accountId] - accountId indicates the user ID. 289 * @returns { Array<string> } ids of the bundle are disallowed to run. 290 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 291 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 292 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 293 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 294 * 2. Incorrect parameter types; 3. Parameter verification failed. 295 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 296 * @StageModelOnly 297 * @since 12 298 */ 299 function getDisallowedRunningBundlesSync(admin: Want, accountId?: number): Array<string>; 300 301 /** 302 * Adds auto start applications. 303 * This function can be called by a super administrator. 304 * 305 * @permission ohos.permission.ENTERPRISE_MANAGE_APPLICATION 306 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 307 * The admin must have the corresponding permission. 308 * @param { Array<Want> } autoStartApps - autoStartApps indicates the information of auto start app ability. 309 * The bundleName and abilityName of the want cannot be non-exist. 310 * The size of the array after setting cannot be greater than 10. 311 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 312 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 313 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 314 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 315 * 2. Incorrect parameter types; 3. Parameter verification failed. 316 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 317 * @stagemodelonly 318 * @since 12 319 */ 320 function addAutoStartApps(admin: Want, autoStartApps: Array<Want>): void; 321 322 /** 323 * Removes auto start applications. 324 * This function can be called by a super administrator. 325 * 326 * @permission ohos.permission.ENTERPRISE_MANAGE_APPLICATION 327 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 328 * The admin must have the corresponding permission. 329 * @param { Array<Want> } autoStartApps - autoStartApps indicates the information of auto start app ability. 330 * The bundleName and abilityName of the want cannot be non-exist. 331 * The size of the array after setting cannot be greater 10. 332 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 333 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 334 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 335 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 336 * 2. Incorrect parameter types; 3. Parameter verification failed. 337 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 338 * @stagemodelonly 339 * @since 12 340 */ 341 function removeAutoStartApps(admin: Want, autoStartApps: Array<Want>): void; 342 343 /** 344 * Gets information of auto start applications. 345 * This function can be called by a super administrator. 346 * 347 * @permission ohos.permission.ENTERPRISE_MANAGE_APPLICATION 348 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 349 * The admin must have the corresponding permission. 350 * @returns { Array<Want> } the information of auto start applications. 351 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 352 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 353 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 354 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 355 * 2. Incorrect parameter types; 3. Parameter verification failed. 356 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 357 * @stagemodelonly 358 * @since 12 359 */ 360 function getAutoStartApps(admin: Want): Array<Want>; 361} 362 363export default applicationManager;