1/* 2 * Copyright (c) 2022-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'; 23import common from '@ohos.app.ability.common'; 24 25/** 26 * This module provides the capability to manage the administrator of the enterprise devices. 27 * 28 * @namespace adminManager 29 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 30 * @since 9 31 */ 32declare namespace adminManager { 33 /** 34 * Provides the enterprise information. 35 * 36 * @typedef EnterpriseInfo 37 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 38 * @systemapi 39 * @since 9 40 */ 41 export interface EnterpriseInfo { 42 /** 43 * The name of enterprise. 44 * 45 * @type { string } 46 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 47 * @systemapi 48 * @since 9 49 */ 50 name: string; 51 52 /** 53 * The description of enterprise. 54 * 55 * @type { string } 56 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 57 * @systemapi 58 * @since 9 59 */ 60 description: string; 61 } 62 63 /** 64 * Enum for type of administrator. 65 * 66 * @enum { number } 67 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 68 * @since 15 69 */ 70 export enum AdminType { 71 /** 72 * The value of normal administrator. 73 * 74 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 75 * @systemapi 76 * @since 9 77 */ 78 ADMIN_TYPE_NORMAL = 0x00, 79 80 /** 81 * The value of super administrator. 82 * 83 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 84 * @systemapi 85 * @since 9 86 */ 87 ADMIN_TYPE_SUPER = 0x01, 88 89 /** 90 * The value of administrator used in BYOD device. 91 * 92 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 93 * @since 15 94 */ 95 ADMIN_TYPE_BYOD = 0x02 96 } 97 98 /** 99 * Enum for managed event 100 * 101 * @enum { number } 102 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 103 * @since 12 104 */ 105 export enum ManagedEvent { 106 /** 107 * The event of bundle added. 108 * 109 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 110 * @since 12 111 */ 112 MANAGED_EVENT_BUNDLE_ADDED = 0, 113 114 /** 115 * The event of bundle removed. 116 * 117 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 118 * @since 12 119 */ 120 MANAGED_EVENT_BUNDLE_REMOVED = 1, 121 122 /** 123 * The event of app start. 124 * 125 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 126 * @since 12 127 */ 128 MANAGED_EVENT_APP_START = 2, 129 130 /** 131 * The event of app stop. 132 * 133 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 134 * @since 12 135 */ 136 MANAGED_EVENT_APP_STOP = 3, 137 138 /** 139 * The event of system update. 140 * 141 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 142 * @since 12 143 */ 144 MANAGED_EVENT_SYSTEM_UPDATE = 4, 145 146 /** 147 * Event indicating that a system account is added. 148 * 149 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 150 * @since 18 151 */ 152 MANAGED_EVENT_ACCOUNT_ADDED = 5, 153 154 /** 155 * Event indicating that a system account is switched. 156 * 157 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 158 * @since 18 159 */ 160 MANAGED_EVENT_ACCOUNT_SWITCHED = 6, 161 162 /** 163 * Event indicating that a system account is removed. 164 * 165 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 166 * @since 18 167 */ 168 MANAGED_EVENT_ACCOUNT_REMOVED = 7 169 } 170 171 /** 172 * Enables the given ability as a administrator of the device. 173 * Only apps with the ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN permission or the shell uid can call this method. 174 * 175 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 176 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 177 * The admin must have the corresponding permission. 178 * @param { EnterpriseInfo } enterpriseInfo - enterpriseInfo indicates the enterprise information of the calling application. 179 * @param { AdminType } type - type indicates the type of administrator to set. 180 * @param { AsyncCallback<void> } callback - the callback of enableAdmin. 181 * @throws { BusinessError } 9200003 - The administrator ability component is invalid. 182 * @throws { BusinessError } 9200004 - Failed to activate the administrator application of the device. 183 * @throws { BusinessError } 9200007 - The system ability works abnormally. 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 9 192 */ 193 function enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback<void>): void; 194 195 /** 196 * Enables the given ability as a administrator of the device. 197 * Only apps with the ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN permission or the shell uid can call this method. 198 * 199 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 200 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 201 * The admin must have the corresponding permission. 202 * @param { EnterpriseInfo } enterpriseInfo - enterpriseInfo indicates the enterprise information of the calling application. 203 * @param { AdminType } type - type indicates the type of administrator to set. 204 * @param { number } userId - userId indicates the user ID. 205 * @param { AsyncCallback<void> } callback - the callback of enableAdmin. 206 * @throws { BusinessError } 9200003 - The administrator ability component is invalid. 207 * @throws { BusinessError } 9200004 - Failed to activate the administrator application of the device. 208 * @throws { BusinessError } 9200007 - The system ability works abnormally. 209 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 210 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 211 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 212 * 2. Incorrect parameter types; 3. Parameter verification failed. 213 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 214 * @systemapi 215 * @stagemodelonly 216 * @since 9 217 */ 218 function enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId: number, callback: AsyncCallback<void>): void; 219 220 /** 221 * Enables the given ability as a administrator of the device. 222 * Only apps with the ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN permission or the shell uid can call this method. 223 * 224 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 225 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 226 * The admin must have the corresponding permission. 227 * @param { EnterpriseInfo } enterpriseInfo - enterpriseInfo indicates the enterprise information of the calling application. 228 * @param { AdminType } type - type indicates the type of administrator to set. 229 * @param { number } [userId] - userId indicates the user ID or do not pass user ID. 230 * @returns { Promise<void> } the promise returned by the enableAdmin. 231 * @throws { BusinessError } 9200003 - The administrator ability component is invalid. 232 * @throws { BusinessError } 9200004 - Failed to activate the administrator application of the device. 233 * @throws { BusinessError } 9200007 - The system ability works abnormally. 234 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 235 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 236 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 237 * 2. Incorrect parameter types; 3. Parameter verification failed. 238 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 239 * @systemapi 240 * @stagemodelonly 241 * @since 9 242 */ 243 function enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId?: number): Promise<void>; 244 245 /** 246 * Disables a current normal administrator ability. 247 * Only apps with the ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN permission or the shell uid can call this method. 248 * 249 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 250 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 251 * The admin must have the corresponding permission. 252 * @param { AsyncCallback<void> } callback - the callback of disableAdmin. 253 * @throws { BusinessError } 9200005 - Failed to deactivate the administrator application of the device. 254 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 255 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 256 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 257 * 2. Incorrect parameter types; 3. Parameter verification failed. 258 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 259 * @systemapi 260 * @stagemodelonly 261 * @since 9 262 */ 263 function disableAdmin(admin: Want, callback: AsyncCallback<void>): void; 264 265 /** 266 * Disables a current normal administrator ability. 267 * Only apps with the ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN permission or the shell uid can call this method. 268 * 269 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 270 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 271 * The admin must have the corresponding permission. 272 * @param { number } userId - userId indicates the user ID. 273 * @param { AsyncCallback<void> } callback - the callback of disableAdmin. 274 * @throws { BusinessError } 9200005 - Failed to deactivate the administrator application of the device. 275 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 276 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 277 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 278 * 2. Incorrect parameter types; 3. Parameter verification failed. 279 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 280 * @systemapi 281 * @stagemodelonly 282 * @since 9 283 */ 284 function disableAdmin(admin: Want, userId: number, callback: AsyncCallback<void>): void; 285 286 /** 287 * Disables a current administrator ability. 288 * Only apps with the ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN permission or the shell uid can call this method. 289 * 290 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 291 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 292 * The admin must have the corresponding permission. 293 * @param { number } [userId] - userId indicates the user ID or do not pass user ID. 294 * @returns { Promise<void> } the promise returned by the disableAdmin. 295 * @throws { BusinessError } 9200005 - Failed to deactivate the administrator application of the device. 296 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 297 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 298 * 2. Incorrect parameter types; 3. Parameter verification failed. 299 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 300 * @stagemodelonly 301 * @since 12 302 */ 303 function disableAdmin(admin: Want, userId?: number): Promise<void>; 304 305 /** 306 * Disables a current super administrator ability. 307 * Only the administrator app or apps with the shell uid can call this method. 308 * 309 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 310 * @param { String } bundleName - bundleName indicates the administrator bundle information. 311 * @param { AsyncCallback<void> } callback - the callback of disableSuperAdmin. 312 * @throws { BusinessError } 9200005 - Failed to deactivate the administrator application of the device. 313 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 314 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 315 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 316 * 2. Incorrect parameter types; 3. Parameter verification failed. 317 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 318 * @systemapi 319 * @stagemodelonly 320 * @since 9 321 */ 322 function disableSuperAdmin(bundleName: String, callback: AsyncCallback<void>): void; 323 324 /** 325 * Disables a current super administrator ability. 326 * Only the administrator app or apps with the shell uid can call this method. 327 * 328 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 329 * @param { String } bundleName - bundleName indicates the administrator bundle information. 330 * @returns { Promise<void> } the promise returned by the disableSuperAdmin. 331 * @throws { BusinessError } 9200005 - Failed to deactivate the administrator application of the device. 332 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 333 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 334 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 335 * 2. Incorrect parameter types; 3. Parameter verification failed. 336 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 337 * @systemapi 338 * @stagemodelonly 339 * @since 9 340 */ 341 function disableSuperAdmin(bundleName: String): Promise<void>; 342 343 /** 344 * Get whether the ability is enabled as device administrator. 345 * 346 * @param { Want } admin - admin indicates the administrator ability information. 347 * @param { AsyncCallback<boolean> } callback - callback contained true if the administrator is enabled. 348 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 349 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 350 * 2. Incorrect parameter types. 351 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 352 * @systemapi 353 * @stagemodelonly 354 * @since 9 355 */ 356 function isAdminEnabled(admin: Want, callback: AsyncCallback<boolean>): void; 357 358 /** 359 * Get whether the ability is enabled as device administrator. 360 * 361 * @param { Want } admin - admin indicates the administrator ability information. 362 * @param { number } userId - userId indicates the user ID. 363 * @param { AsyncCallback<boolean> } callback - callback contained true if the administrator is enabled. 364 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 365 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 366 * 2. Incorrect parameter types. 367 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 368 * @systemapi 369 * @stagemodelonly 370 * @since 9 371 */ 372 function isAdminEnabled(admin: Want, userId: number, callback: AsyncCallback<boolean>): void; 373 374 /** 375 * Get whether the ability is enabled as device administrator. 376 * 377 * @param { Want } admin - admin indicates the administrator ability information. 378 * @param { number } [userId] - userId indicates the user ID or do not pass user ID. 379 * @returns { Promise<boolean> } promise contained true if the administrator is enabled. 380 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 381 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 382 * 2. Incorrect parameter types. 383 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 384 * @systemapi 385 * @stagemodelonly 386 * @since 9 387 */ 388 function isAdminEnabled(admin: Want, userId?: number): Promise<boolean>; 389 390 /** 391 * Get information of the administrator's enterprise. 392 * 393 * @param { Want } admin - admin indicates the administrator ability information. 394 * @param { AsyncCallback<EnterpriseInfo> } callback - callback contained the enterprise info of administrator. 395 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 396 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 397 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 398 * 2. Incorrect parameter types; 3. Parameter verification failed. 399 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 400 * @systemapi 401 * @stagemodelonly 402 * @since 9 403 */ 404 function getEnterpriseInfo(admin: Want, callback: AsyncCallback<EnterpriseInfo>): void; 405 406 /** 407 * Get information of the administrator's enterprise. 408 * 409 * @param { Want } admin - admin indicates the administrator ability information. 410 * @returns { Promise<EnterpriseInfo> } promise contained the enterprise info of administrator. 411 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 412 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 413 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 414 * 2. Incorrect parameter types; 3. Parameter verification failed. 415 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 416 * @systemapi 417 * @stagemodelonly 418 * @since 9 419 */ 420 function getEnterpriseInfo(admin: Want): Promise<EnterpriseInfo>; 421 422 /** 423 * Set the information of the administrator's enterprise. 424 * Only the administrator app can call this method. 425 * 426 * @permission ohos.permission.SET_ENTERPRISE_INFO 427 * @param { Want } admin - admin indicates the administrator ability information. 428 * @param { EnterpriseInfo } enterpriseInfo - enterpriseInfo indicates the enterprise information of the calling application. 429 * @param { AsyncCallback<void> } callback - the callback of setEnterpriseInfo. 430 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 431 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 432 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 433 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 434 * 2. Incorrect parameter types; 3. Parameter verification failed. 435 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 436 * @systemapi 437 * @stagemodelonly 438 * @since 9 439 */ 440 function setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCallback<void>): void; 441 442 /** 443 * Set the information of the administrator's enterprise. 444 * Only the administrator app can call this method. 445 * 446 * @permission ohos.permission.SET_ENTERPRISE_INFO 447 * @param { Want } admin - admin indicates the administrator ability information. 448 * @param { EnterpriseInfo } enterpriseInfo - enterpriseInfo indicates the enterprise information of the calling application. 449 * @returns { Promise<void> } the promise returned by the setEnterpriseInfo. 450 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 451 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 452 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 453 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 454 * 2. Incorrect parameter types; 3. Parameter verification failed. 455 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 456 * @systemapi 457 * @stagemodelonly 458 * @since 9 459 */ 460 function setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise<void>; 461 462 /** 463 * Get whether the ability is enabled as super device administrator. 464 * 465 * @param { String } bundleName - bundleName indicates the administrator bundle information. 466 * @param { AsyncCallback<boolean> } callback - callback contained true if the administrator is super administrator. 467 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 468 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 469 * 2. Incorrect parameter types. 470 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 471 * @systemapi 472 * @stagemodelonly 473 * @since 9 474 */ 475 function isSuperAdmin(bundleName: String, callback: AsyncCallback<boolean>): void; 476 477 /** 478 * Get whether the ability is enabled as super device administrator. 479 * 480 * @param { String } bundleName - bundleName indicates the administrator bundle information. 481 * @returns { Promise<boolean> } promise contained true if the administrator is super administrator. 482 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 483 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 484 * 2. Incorrect parameter types. 485 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 486 * @systemapi 487 * @stagemodelonly 488 * @since 9 489 */ 490 function isSuperAdmin(bundleName: String): Promise<boolean>; 491 492 /** 493 * Subscribes the managed event of admin. 494 * 495 * @permission ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 496 * @param { Want } admin - admin indicates the administrator ability information. 497 * @param { Array<ManagedEvent> } managedEvents - managedEvents indicates the managed events to subscribe. 498 * @param { AsyncCallback<void> } callback - the callback of subscribeManagedEvent. 499 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 500 * @throws { BusinessError } 9200008 - The specified system event is invalid. 501 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 502 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 503 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 504 * 2. Incorrect parameter types; 3. Parameter verification failed. 505 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 506 * @systemapi 507 * @stagemodelonly 508 * @since 9 509 */ 510 function subscribeManagedEvent(admin: Want, managedEvents: Array<ManagedEvent>, callback: AsyncCallback<void>): void; 511 512 /** 513 * Subscribes the managed event of admin. 514 * 515 * @permission ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 516 * @param { Want } admin - admin indicates the administrator ability information. 517 * @param { Array<ManagedEvent> } managedEvents - managedEvents indicates the managed events to subscribe. 518 * @returns { Promise<void> } the promise returned by the subscribeManagedEvent. 519 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 520 * @throws { BusinessError } 9200008 - The specified system event is invalid. 521 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 522 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 523 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 524 * 2. Incorrect parameter types; 3. Parameter verification failed. 525 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 526 * @systemapi 527 * @stagemodelonly 528 * @since 9 529 */ 530 function subscribeManagedEvent(admin: Want, managedEvents: Array<ManagedEvent>): Promise<void>; 531 532 /** 533 * Unsubscribes the managed event of admin. 534 * 535 * @permission ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 536 * @param { Want } admin - admin indicates the administrator ability information. 537 * @param { Array<ManagedEvent> } managedEvents - managedEvents indicates the managed events to subscribe. 538 * @param { AsyncCallback<void> } callback - the callback of unsubscribeManagedEvent. 539 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 540 * @throws { BusinessError } 9200008 - The specified system event is invalid. 541 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 542 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 543 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 544 * 2. Incorrect parameter types; 3. Parameter verification failed. 545 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 546 * @systemapi 547 * @stagemodelonly 548 * @since 9 549 */ 550 function unsubscribeManagedEvent(admin: Want, managedEvents: Array<ManagedEvent>, callback: AsyncCallback<void>): void; 551 552 /** 553 * Unsubscribes the managed event of admin. 554 * 555 * @permission ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 556 * @param { Want } admin - admin indicates the administrator ability information. 557 * @param { Array<ManagedEvent> } managedEvents - managedEvents indicates the managed events to subscribe. 558 * @returns { Promise<void> } the promise returned by the unsubscribeManagedEvent. 559 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 560 * @throws { BusinessError } 9200008 - The specified system event is invalid. 561 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 562 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 563 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 564 * 2. Incorrect parameter types; 3. Parameter verification failed. 565 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 566 * @systemapi 567 * @stagemodelonly 568 * @since 9 569 */ 570 function unsubscribeManagedEvent(admin: Want, managedEvents: Array<ManagedEvent>): Promise<void>; 571 572 /** 573 * Administrator authorize permissions to other applications. 574 * 575 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 576 * @param { Want } admin - admin indicates the administrator ability information. 577 * @param { string } bundleName - bundleName indicates the administrator bundle information. 578 * @param { AsyncCallback<void> } callback - the callback of authorizeAdmin. 579 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 580 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 581 * @throws { BusinessError } 9200009 - Failed to grant the permission to the application. 582 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 583 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 584 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 585 * 2. Incorrect parameter types; 3. Parameter verification failed. 586 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 587 * @systemapi 588 * @stagemodelonly 589 * @since 10 590 */ 591 function authorizeAdmin(admin: Want, bundleName: string, callback: AsyncCallback<void>): void; 592 593 /** 594 * Administrator authorize permissions to other applications. 595 * 596 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 597 * @param { Want } admin - admin indicates the administrator ability information. 598 * @param { string } bundleName - bundleName indicates the administrator bundle information. 599 * @returns { Promise<void> } the promise returned by the authorizeAdmin. 600 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 601 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 602 * @throws { BusinessError } 9200009 - Failed to grant the permission to the application. 603 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 604 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 605 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 606 * 2. Incorrect parameter types; 3. Parameter verification failed. 607 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 608 * @systemapi 609 * @stagemodelonly 610 * @since 10 611 */ 612 function authorizeAdmin(admin: Want, bundleName: string): Promise<void>; 613 614 /** 615 * Get the super administrator of device. 616 * 617 * @returns { Promise<Want> } promise contained the want indicates the super administrator of the device. 618 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 619 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 620 * @systemapi 621 * @stagemodelonly 622 * @since 12 623 */ 624 function getSuperAdmin(): Promise<Want>; 625 626 /** 627 * Subscribes the managed event of admin. 628 * 629 * @permission ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 630 * @param { Want } admin - admin indicates the administrator ability information. 631 * @param { Array<ManagedEvent> } managedEvents - managedEvents indicates the managed events to subscribe. 632 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 633 * @throws { BusinessError } 9200008 - The specified system event is invalid. 634 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 635 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 636 * 2. Incorrect parameter types; 3. Parameter verification failed. 637 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 638 * @stagemodelonly 639 * @since 12 640 */ 641 function subscribeManagedEventSync(admin: Want, managedEvents: Array<ManagedEvent>): void; 642 643 /** 644 * Unsubscribes the managed event of admin. 645 * 646 * @permission ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 647 * @param { Want } admin - admin indicates the administrator ability information. 648 * @param { Array<ManagedEvent> } managedEvents - managedEvents indicates the managed events to subscribe. 649 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 650 * @throws { BusinessError } 9200008 - The specified system event is invalid. 651 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 652 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 653 * 2. Incorrect parameter types; 3. Parameter verification failed. 654 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 655 * @stagemodelonly 656 * @since 12 657 */ 658 function unsubscribeManagedEventSync(admin: Want, managedEvents: Array<ManagedEvent>): void; 659 660 /** 661 * Administrator delegates access to policies to another application. 662 * 663 * @permission ohos.permission.ENTERPRISE_MANAGE_DELEGATED_POLICY 664 * @param { Want } admin - admin indicates the administrator ability information. 665 * @param { string } bundleName - bundleName indicates the bundle name of the delegated application. 666 * @param { Array<string> } policies - policies indicates the policies accessible to the delegated application. 667 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 668 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 669 * @throws { BusinessError } 9200009 - Failed to grant the permission to the application. 670 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 671 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 672 * 2. Incorrect parameter types; 3. Parameter verification failed. 673 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 674 * @stagemodelonly 675 * @since 14 676 */ 677 function setDelegatedPolicies(admin: Want, bundleName: string, policies: Array<string>): void; 678 679 /** 680 * Administrator gets the list of delegation policies for the application. 681 * 682 * @permission ohos.permission.ENTERPRISE_MANAGE_DELEGATED_POLICY 683 * @param { Want } admin - admin indicates the administrator ability information. 684 * @param { string } bundleName - bundleName indicates the bundle name of the delegated application. 685 * @returns { Array<string> } the policies accessible to the delegated application. 686 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 687 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 688 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 689 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 690 * 2. Incorrect parameter types; 3. Parameter verification failed. 691 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 692 * @stagemodelonly 693 * @since 14 694 */ 695 function getDelegatedPolicies(admin: Want, bundleName: string): Array<string>; 696 697 /** 698 * Administrator gets the delegated applications which access to the policy. 699 * 700 * @permission ohos.permission.ENTERPRISE_MANAGE_DELEGATED_POLICY 701 * @param { Want } admin - admin indicates the administrator ability information. 702 * @param { string } policy - policy indicates the policy that delegated to other applications. 703 * @returns { Array<string> } the bundle names of the delegated application that access to the policy. 704 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 705 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 706 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 707 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 708 * 2. Incorrect parameter types; 3. Parameter verification failed. 709 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 710 * @stagemodelonly 711 * @since 14 712 */ 713 function getDelegatedBundleNames(admin: Want, policy: string): Array<string>; 714 715 /** 716 * Starts an ability of admin provision application. 717 * 718 * @permission ohos.permission.START_PROVISIONING_MESSAGE 719 * @param { Want } admin - admin indicates the administrator ability information. 720 * @param { AdminType } type - type indicates the type of administrator to set. 721 * @param { common.Context } context - context indicates the context of application. 722 * @param { Record<string, string> } parameters - the parameters indicates the custom parameters of start an administrator provision. 723 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 724 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 725 * 2. Incorrect parameter types; 3. Parameter verification failed. 726 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 727 * @stagemodelonly 728 * @since 15 729 */ 730 function startAdminProvision(admin: Want, type: AdminType, context: common.Context, parameters: Record<string, string>): void; 731 732 /** 733 * Gets administrators of device. 734 * 735 * @returns { Promise<Array<Want>> } returns the want list indicates the administrators of the device. 736 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 737 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 738 * @systemapi 739 * @stagemodelonly 740 * @since 15 741 */ 742 function getAdmins(): Promise<Array<Want>>; 743 744 /** 745 * replace old admin with new admin. 746 * 747 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 748 * @param { Want } oldAdmin - oldAdmin indicates the old administrator ability information. 749 * @param { Want } newAdmin - newAdmin indicates the new administrator ability information. 750 * @param { boolean } isKeepPolicy - true indicates whether keep admin policy. 751 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 752 * @throws { BusinessError } 9200003 - The administrator ability component is invalid. 753 * @throws { BusinessError } 9200011 - Failed to replace the administrator application of the device. 754 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 755 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 756 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 757 * @systemapi 758 * @stagemodelonly 759 * @since 18 760 */ 761 function replaceSuperAdmin(oldAdmin: Want, newAdmin: Want, isKeepPolicy: boolean): void; 762} 763 764export default adminManager; 765