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 * Enum for admin running mode. 173 * 174 * @enum { number } 175 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 176 * @systemapi 177 * @since 19 178 */ 179 export enum RunningMode { 180 /** 181 * The default mode. 182 * 183 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 184 * @systemapi 185 * @since 19 186 */ 187 DEFAULT = 0, 188 189 /** 190 * Multi-user running mode. 191 * 192 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 193 * @systemapi 194 * @since 19 195 */ 196 MULTI_USER = 1, 197 } 198 199 /** 200 * Enum for Policy. 201 * 202 * @enum { number } 203 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 204 * @stagemodelonly 205 * @since 20 206 */ 207 export enum Policy { 208 /** 209 * flag bolck list. 210 * 211 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 212 * @stagemodelonly 213 * @since 20 214 */ 215 BLOCK_LIST = 0, 216 217 /** 218 * flag trust list. 219 * 220 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 221 * @stagemodelonly 222 * @since 20 223 */ 224 TRUST_LIST = 1 225 } 226 227 /** 228 * Enables the given ability as a administrator of the device. 229 * Only apps with the ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN permission or the shell uid can call this method. 230 * 231 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 232 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 233 * The admin must have the corresponding permission. 234 * @param { EnterpriseInfo } enterpriseInfo - enterpriseInfo indicates the enterprise information of the calling application. 235 * @param { AdminType } type - type indicates the type of administrator to set. 236 * @param { AsyncCallback<void> } callback - the callback of enableAdmin. 237 * @throws { BusinessError } 9200003 - The administrator ability component is invalid. 238 * @throws { BusinessError } 9200004 - Failed to activate the administrator application of the device. 239 * @throws { BusinessError } 9200007 - The system ability works abnormally. 240 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 241 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 242 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 243 * 2. Incorrect parameter types; 3. Parameter verification failed. 244 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 245 * @systemapi 246 * @stagemodelonly 247 * @since 9 248 */ 249 function enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback<void>): void; 250 251 /** 252 * Enables the given ability as a administrator of the device. 253 * Only apps with the ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN permission or the shell uid can call this method. 254 * 255 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 256 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 257 * The admin must have the corresponding permission. 258 * @param { EnterpriseInfo } enterpriseInfo - enterpriseInfo indicates the enterprise information of the calling application. 259 * @param { AdminType } type - type indicates the type of administrator to set. 260 * @param { number } userId - userId indicates the user ID. 261 * @param { AsyncCallback<void> } callback - the callback of enableAdmin. 262 * @throws { BusinessError } 9200003 - The administrator ability component is invalid. 263 * @throws { BusinessError } 9200004 - Failed to activate the administrator application of the device. 264 * @throws { BusinessError } 9200007 - The system ability works abnormally. 265 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 266 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 267 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 268 * 2. Incorrect parameter types; 3. Parameter verification failed. 269 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 270 * @systemapi 271 * @stagemodelonly 272 * @since 9 273 */ 274 function enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId: number, callback: AsyncCallback<void>): void; 275 276 /** 277 * Enables the given ability as a administrator of the device. 278 * Only apps with the ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN permission or the shell uid can call this method. 279 * 280 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 281 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 282 * The admin must have the corresponding permission. 283 * @param { EnterpriseInfo } enterpriseInfo - enterpriseInfo indicates the enterprise information of the calling application. 284 * @param { AdminType } type - type indicates the type of administrator to set. 285 * @param { number } [userId] - userId indicates the user ID or do not pass user ID. 286 * @returns { Promise<void> } the promise returned by the enableAdmin. 287 * @throws { BusinessError } 9200003 - The administrator ability component is invalid. 288 * @throws { BusinessError } 9200004 - Failed to activate the administrator application of the device. 289 * @throws { BusinessError } 9200007 - The system ability works abnormally. 290 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 291 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 292 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 293 * 2. Incorrect parameter types; 3. Parameter verification failed. 294 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 295 * @systemapi 296 * @stagemodelonly 297 * @since 9 298 */ 299 function enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId?: number): Promise<void>; 300 301 /** 302 * Disables a current normal administrator ability. 303 * Only apps with the ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN permission or the shell uid can call this method. 304 * 305 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 306 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 307 * The admin must have the corresponding permission. 308 * @param { AsyncCallback<void> } callback - the callback of disableAdmin. 309 * @throws { BusinessError } 9200005 - Failed to deactivate the administrator application of the device. 310 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 311 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 312 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 313 * 2. Incorrect parameter types; 3. Parameter verification failed. 314 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 315 * @systemapi 316 * @stagemodelonly 317 * @since 9 318 */ 319 function disableAdmin(admin: Want, callback: AsyncCallback<void>): void; 320 321 /** 322 * Disables a current normal administrator ability. 323 * Only apps with the ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN permission or the shell uid can call this method. 324 * 325 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 326 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 327 * The admin must have the corresponding permission. 328 * @param { number } userId - userId indicates the user ID. 329 * @param { AsyncCallback<void> } callback - the callback of disableAdmin. 330 * @throws { BusinessError } 9200005 - Failed to deactivate the administrator application of the device. 331 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 332 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 333 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 334 * 2. Incorrect parameter types; 3. Parameter verification failed. 335 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 336 * @systemapi 337 * @stagemodelonly 338 * @since 9 339 */ 340 function disableAdmin(admin: Want, userId: number, callback: AsyncCallback<void>): void; 341 342 /** 343 * Disables a current administrator ability. 344 * Only apps with the ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN permission or the shell uid can call this method. 345 * 346 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 347 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 348 * The admin must have the corresponding permission. 349 * @param { number } [userId] - userId indicates the user ID or do not pass user ID. 350 * @returns { Promise<void> } the promise returned by the disableAdmin. 351 * @throws { BusinessError } 9200005 - Failed to deactivate the administrator application of the device. 352 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 353 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 354 * 2. Incorrect parameter types; 3. Parameter verification failed. 355 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 356 * @stagemodelonly 357 * @since 12 358 */ 359 /** 360 * Disables a current administrator ability. 361 * Only apps with the ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN permission, 362 * ohos.permission.START_PROVISIONING_MESSAGE or the shell uid can call this method. 363 * 364 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN or ohos.permission.START_PROVISIONING_MESSAGE 365 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 366 * The admin must have the corresponding permission. 367 * @param { number } [userId] - userId indicates the user ID or do not pass user ID. 368 * @returns { Promise<void> } the promise returned by the disableAdmin. 369 * @throws { BusinessError } 9200005 - Failed to deactivate the administrator application of the device. 370 * @throws { BusinessError } 201 - Permission verification failed. 371 * The application does not have the permission required to call the API. 372 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 373 * @stagemodelonly 374 * @since 20 375 */ 376 function disableAdmin(admin: Want, userId?: number): Promise<void>; 377 378 /** 379 * Disables a current super administrator ability. 380 * Only the administrator app or apps with the shell uid can call this method. 381 * 382 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 383 * @param { String } bundleName - bundleName indicates the administrator bundle information. 384 * @param { AsyncCallback<void> } callback - the callback of disableSuperAdmin. 385 * @throws { BusinessError } 9200005 - Failed to deactivate the administrator application of the device. 386 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 387 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 388 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 389 * 2. Incorrect parameter types; 3. Parameter verification failed. 390 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 391 * @systemapi 392 * @stagemodelonly 393 * @since 9 394 */ 395 function disableSuperAdmin(bundleName: String, callback: AsyncCallback<void>): void; 396 397 /** 398 * Disables a current super administrator ability. 399 * Only the administrator app or apps with the shell uid can call this method. 400 * 401 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 402 * @param { String } bundleName - bundleName indicates the administrator bundle information. 403 * @returns { Promise<void> } the promise returned by the disableSuperAdmin. 404 * @throws { BusinessError } 9200005 - Failed to deactivate the administrator application of the device. 405 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 406 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 407 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 408 * 2. Incorrect parameter types; 3. Parameter verification failed. 409 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 410 * @systemapi 411 * @stagemodelonly 412 * @since 9 413 */ 414 function disableSuperAdmin(bundleName: String): Promise<void>; 415 416 /** 417 * Get whether the ability is enabled as device administrator. 418 * 419 * @param { Want } admin - admin indicates the administrator ability information. 420 * @param { AsyncCallback<boolean> } callback - callback contained true if the administrator is enabled. 421 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 422 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 423 * 2. Incorrect parameter types. 424 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 425 * @systemapi 426 * @stagemodelonly 427 * @since 9 428 */ 429 function isAdminEnabled(admin: Want, callback: AsyncCallback<boolean>): void; 430 431 /** 432 * Get whether the ability is enabled as device administrator. 433 * 434 * @param { Want } admin - admin indicates the administrator ability information. 435 * @param { number } userId - userId indicates the user ID. 436 * @param { AsyncCallback<boolean> } callback - callback contained true if the administrator is enabled. 437 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 438 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 439 * 2. Incorrect parameter types. 440 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 441 * @systemapi 442 * @stagemodelonly 443 * @since 9 444 */ 445 function isAdminEnabled(admin: Want, userId: number, callback: AsyncCallback<boolean>): void; 446 447 /** 448 * Get whether the ability is enabled as device administrator. 449 * 450 * @param { Want } admin - admin indicates the administrator ability information. 451 * @param { number } [userId] - userId indicates the user ID or do not pass user ID. 452 * @returns { Promise<boolean> } promise contained true if the administrator is enabled. 453 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 454 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 455 * 2. Incorrect parameter types. 456 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 457 * @systemapi 458 * @stagemodelonly 459 * @since 9 460 */ 461 function isAdminEnabled(admin: Want, userId?: number): Promise<boolean>; 462 463 /** 464 * Get information of the administrator's enterprise. 465 * 466 * @param { Want } admin - admin indicates the administrator ability information. 467 * @param { AsyncCallback<EnterpriseInfo> } callback - callback contained the enterprise info of administrator. 468 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 469 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 470 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 471 * 2. Incorrect parameter types; 3. Parameter verification failed. 472 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 473 * @systemapi 474 * @stagemodelonly 475 * @since 9 476 */ 477 function getEnterpriseInfo(admin: Want, callback: AsyncCallback<EnterpriseInfo>): void; 478 479 /** 480 * Get information of the administrator's enterprise. 481 * 482 * @param { Want } admin - admin indicates the administrator ability information. 483 * @returns { Promise<EnterpriseInfo> } promise contained the enterprise info of administrator. 484 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 485 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 486 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 487 * 2. Incorrect parameter types; 3. Parameter verification failed. 488 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 489 * @systemapi 490 * @stagemodelonly 491 * @since 9 492 */ 493 function getEnterpriseInfo(admin: Want): Promise<EnterpriseInfo>; 494 495 /** 496 * Set the information of the administrator's enterprise. 497 * Only the administrator app can call this method. 498 * 499 * @permission ohos.permission.SET_ENTERPRISE_INFO 500 * @param { Want } admin - admin indicates the administrator ability information. 501 * @param { EnterpriseInfo } enterpriseInfo - enterpriseInfo indicates the enterprise information of the calling application. 502 * @param { AsyncCallback<void> } callback - the callback of setEnterpriseInfo. 503 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 504 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 505 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 506 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 507 * 2. Incorrect parameter types; 3. Parameter verification failed. 508 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 509 * @systemapi 510 * @stagemodelonly 511 * @since 9 512 */ 513 function setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCallback<void>): void; 514 515 /** 516 * Set the information of the administrator's enterprise. 517 * Only the administrator app can call this method. 518 * 519 * @permission ohos.permission.SET_ENTERPRISE_INFO 520 * @param { Want } admin - admin indicates the administrator ability information. 521 * @param { EnterpriseInfo } enterpriseInfo - enterpriseInfo indicates the enterprise information of the calling application. 522 * @returns { Promise<void> } the promise returned by the setEnterpriseInfo. 523 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 524 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 525 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 526 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 527 * 2. Incorrect parameter types; 3. Parameter verification failed. 528 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 529 * @systemapi 530 * @stagemodelonly 531 * @since 9 532 */ 533 function setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise<void>; 534 535 /** 536 * Set the running mode for admin. 537 * Only the administrator app can call this method. 538 * 539 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 540 * @param { Want } admin - admin indicates the administrator ability information. 541 * @param { RuningMode } mode - indicates the running mode for admin. 542 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 543 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 544 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 545 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 546 * @systemapi 547 * @stagemodelonly 548 * @since 19 549 */ 550 function setAdminRunningMode(admin: Want, mode: RunningMode): void; 551 552 /** 553 * Get whether the ability is enabled as super device administrator. 554 * 555 * @param { String } bundleName - bundleName indicates the administrator bundle information. 556 * @param { AsyncCallback<boolean> } callback - callback contained true if the administrator is super administrator. 557 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 558 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 559 * 2. Incorrect parameter types. 560 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 561 * @systemapi 562 * @stagemodelonly 563 * @since 9 564 */ 565 function isSuperAdmin(bundleName: String, callback: AsyncCallback<boolean>): void; 566 567 /** 568 * Get whether the ability is enabled as super device administrator. 569 * 570 * @param { String } bundleName - bundleName indicates the administrator bundle information. 571 * @returns { Promise<boolean> } promise contained true if the administrator is super administrator. 572 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 573 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 574 * 2. Incorrect parameter types. 575 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 576 * @systemapi 577 * @stagemodelonly 578 * @since 9 579 */ 580 function isSuperAdmin(bundleName: String): Promise<boolean>; 581 582 /** 583 * Subscribes the managed event of admin. 584 * 585 * @permission ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 586 * @param { Want } admin - admin indicates the administrator ability information. 587 * @param { Array<ManagedEvent> } managedEvents - managedEvents indicates the managed events to subscribe. 588 * @param { AsyncCallback<void> } callback - the callback of subscribeManagedEvent. 589 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 590 * @throws { BusinessError } 9200008 - The specified system event is invalid. 591 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 592 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 593 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 594 * 2. Incorrect parameter types; 3. Parameter verification failed. 595 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 596 * @systemapi 597 * @stagemodelonly 598 * @since 9 599 */ 600 function subscribeManagedEvent(admin: Want, managedEvents: Array<ManagedEvent>, callback: AsyncCallback<void>): void; 601 602 /** 603 * Subscribes the managed event of admin. 604 * 605 * @permission ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 606 * @param { Want } admin - admin indicates the administrator ability information. 607 * @param { Array<ManagedEvent> } managedEvents - managedEvents indicates the managed events to subscribe. 608 * @returns { Promise<void> } the promise returned by the subscribeManagedEvent. 609 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 610 * @throws { BusinessError } 9200008 - The specified system event is invalid. 611 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 612 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 613 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 614 * 2. Incorrect parameter types; 3. Parameter verification failed. 615 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 616 * @systemapi 617 * @stagemodelonly 618 * @since 9 619 */ 620 function subscribeManagedEvent(admin: Want, managedEvents: Array<ManagedEvent>): Promise<void>; 621 622 /** 623 * Unsubscribes the managed event of admin. 624 * 625 * @permission ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 626 * @param { Want } admin - admin indicates the administrator ability information. 627 * @param { Array<ManagedEvent> } managedEvents - managedEvents indicates the managed events to subscribe. 628 * @param { AsyncCallback<void> } callback - the callback of unsubscribeManagedEvent. 629 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 630 * @throws { BusinessError } 9200008 - The specified system event is invalid. 631 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 632 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 633 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 634 * 2. Incorrect parameter types; 3. Parameter verification failed. 635 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 636 * @systemapi 637 * @stagemodelonly 638 * @since 9 639 */ 640 function unsubscribeManagedEvent(admin: Want, managedEvents: Array<ManagedEvent>, callback: AsyncCallback<void>): void; 641 642 /** 643 * Unsubscribes the managed event of admin. 644 * 645 * @permission ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 646 * @param { Want } admin - admin indicates the administrator ability information. 647 * @param { Array<ManagedEvent> } managedEvents - managedEvents indicates the managed events to subscribe. 648 * @returns { Promise<void> } the promise returned by the unsubscribeManagedEvent. 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 } 202 - Permission verification failed. A non-system application calls a system API. 653 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 654 * 2. Incorrect parameter types; 3. Parameter verification failed. 655 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 656 * @systemapi 657 * @stagemodelonly 658 * @since 9 659 */ 660 function unsubscribeManagedEvent(admin: Want, managedEvents: Array<ManagedEvent>): Promise<void>; 661 662 /** 663 * Administrator authorize permissions to other applications. 664 * 665 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 666 * @param { Want } admin - admin indicates the administrator ability information. 667 * @param { string } bundleName - bundleName indicates the administrator bundle information. 668 * @param { AsyncCallback<void> } callback - the callback of authorizeAdmin. 669 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 670 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 671 * @throws { BusinessError } 9200009 - Failed to grant the permission to the application. 672 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 673 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 674 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 675 * 2. Incorrect parameter types; 3. Parameter verification failed. 676 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 677 * @systemapi 678 * @stagemodelonly 679 * @since 10 680 */ 681 function authorizeAdmin(admin: Want, bundleName: string, callback: AsyncCallback<void>): void; 682 683 /** 684 * Administrator authorize permissions to other applications. 685 * 686 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 687 * @param { Want } admin - admin indicates the administrator ability information. 688 * @param { string } bundleName - bundleName indicates the administrator bundle information. 689 * @returns { Promise<void> } the promise returned by the authorizeAdmin. 690 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 691 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 692 * @throws { BusinessError } 9200009 - Failed to grant the permission to the application. 693 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 694 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 695 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 696 * 2. Incorrect parameter types; 3. Parameter verification failed. 697 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 698 * @systemapi 699 * @stagemodelonly 700 * @since 10 701 */ 702 function authorizeAdmin(admin: Want, bundleName: string): Promise<void>; 703 704 /** 705 * Get the super administrator of device. 706 * 707 * @returns { Promise<Want> } promise contained the want indicates the super administrator of the device. 708 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 709 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 710 * @systemapi 711 * @stagemodelonly 712 * @since 12 713 */ 714 function getSuperAdmin(): Promise<Want>; 715 716 /** 717 * Subscribes the managed event of admin. 718 * 719 * @permission ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 720 * @param { Want } admin - admin indicates the administrator ability information. 721 * @param { Array<ManagedEvent> } managedEvents - managedEvents indicates the managed events to subscribe. 722 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 723 * @throws { BusinessError } 9200008 - The specified system event is invalid. 724 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 725 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 726 * 2. Incorrect parameter types; 3. Parameter verification failed. 727 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 728 * @stagemodelonly 729 * @since 12 730 */ 731 function subscribeManagedEventSync(admin: Want, managedEvents: Array<ManagedEvent>): void; 732 733 /** 734 * Unsubscribes the managed event of admin. 735 * 736 * @permission ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 737 * @param { Want } admin - admin indicates the administrator ability information. 738 * @param { Array<ManagedEvent> } managedEvents - managedEvents indicates the managed events to subscribe. 739 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 740 * @throws { BusinessError } 9200008 - The specified system event is invalid. 741 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 742 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 743 * 2. Incorrect parameter types; 3. Parameter verification failed. 744 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 745 * @stagemodelonly 746 * @since 12 747 */ 748 function unsubscribeManagedEventSync(admin: Want, managedEvents: Array<ManagedEvent>): void; 749 750 /** 751 * Administrator delegates access to policies to another application. 752 * 753 * @permission ohos.permission.ENTERPRISE_MANAGE_DELEGATED_POLICY 754 * @param { Want } admin - admin indicates the administrator ability information. 755 * @param { string } bundleName - bundleName indicates the bundle name of the delegated application. 756 * @param { Array<string> } policies - policies indicates the policies accessible to the delegated application. 757 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 758 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 759 * @throws { BusinessError } 9200009 - Failed to grant the permission to the application. 760 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 761 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 762 * 2. Incorrect parameter types; 3. Parameter verification failed. 763 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 764 * @stagemodelonly 765 * @since 14 766 */ 767 function setDelegatedPolicies(admin: Want, bundleName: string, policies: Array<string>): void; 768 769 /** 770 * Administrator gets the list of delegation policies for the application. 771 * 772 * @permission ohos.permission.ENTERPRISE_MANAGE_DELEGATED_POLICY 773 * @param { Want } admin - admin indicates the administrator ability information. 774 * @param { string } bundleName - bundleName indicates the bundle name of the delegated application. 775 * @returns { Array<string> } the policies accessible to the delegated application. 776 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 777 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 778 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 779 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 780 * 2. Incorrect parameter types; 3. Parameter verification failed. 781 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 782 * @stagemodelonly 783 * @since 14 784 */ 785 function getDelegatedPolicies(admin: Want, bundleName: string): Array<string>; 786 787 /** 788 * Query wether self is a BYOD administrater. 789 * 790 * @permission ohos.permission.START_PROVISIONING_MESSAGE 791 * @param { Want } admin - admin indicates the administrator ability information. 792 * @returns { boolean } true if byod admin is active, otherwise false. 793 * @throws { BusinessError } 9200012 - Parameter verification failed. 794 * @throws { BusinessError } 201 - Permission verification failed. 795 * The application does not have the permission required to call the API. 796 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 797 * @stagemodelonly 798 * @since 20 799 */ 800 function isByodAdmin(admin: Want): boolean; 801 802/** 803 * Administrator gets the delegated applications which access to the policy. 804 * 805 * @permission ohos.permission.ENTERPRISE_MANAGE_DELEGATED_POLICY 806 * @param { Want } admin - admin indicates the administrator ability information. 807 * @param { string } policy - policy indicates the policy that delegated to other applications. 808 * @returns { Array<string> } the bundle names of the delegated application that access to the policy. 809 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 810 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 811 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 812 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 813 * 2. Incorrect parameter types; 3. Parameter verification failed. 814 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 815 * @stagemodelonly 816 * @since 14 817 */ 818 function getDelegatedBundleNames(admin: Want, policy: string): Array<string>; 819 820 /** 821 * Starts an ability of admin provision application. 822 * 823 * @permission ohos.permission.START_PROVISIONING_MESSAGE 824 * @param { Want } admin - admin indicates the administrator ability information. 825 * @param { AdminType } type - type indicates the type of administrator to set. 826 * @param { common.Context } context - context indicates the context of application. 827 * @param { Record<string, string> } parameters - the parameters indicates the custom parameters of start an administrator provision. 828 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 829 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 830 * 2. Incorrect parameter types; 3. Parameter verification failed. 831 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 832 * @stagemodelonly 833 * @since 15 834 */ 835 function startAdminProvision(admin: Want, type: AdminType, context: common.Context, parameters: Record<string, string>): void; 836 837 /** 838 * Gets administrators of device. 839 * 840 * @returns { Promise<Array<Want>> } returns the want list indicates the administrators of the device. 841 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 842 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 843 * @systemapi 844 * @stagemodelonly 845 * @since 15 846 */ 847 function getAdmins(): Promise<Array<Want>>; 848 849 /** 850 * replace old admin with new admin. 851 * 852 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 853 * @param { Want } oldAdmin - oldAdmin indicates the old administrator ability information. 854 * @param { Want } newAdmin - newAdmin indicates the new administrator ability information. 855 * @param { boolean } isKeepPolicy - true indicates whether keep admin policy. 856 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 857 * @throws { BusinessError } 9200003 - The administrator ability component is invalid. 858 * @throws { BusinessError } 9200011 - Failed to replace the administrator application of the device. 859 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 860 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 861 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 862 * @systemapi 863 * @stagemodelonly 864 * @since 18 865 */ 866 function replaceSuperAdmin(oldAdmin: Want, newAdmin: Want, isKeepPolicy: boolean): void; 867 868 /** 869 * Administrator delegates access to policies to another application. 870 * 871 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 872 * @param { string } bundleName - bundleName indicates the bundle name of the delegated application. 873 * @param { Array<string> } policies - policies indicates the policies accessible to the delegated application. 874 * @param { number } accountId - accountId indicates the local ID of the OS account. 875 * @throws { BusinessError } 9200009 - Failed to grant the permission to the application. 876 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 877 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 878 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 879 * @systemapi 880 * @stagemodelonly 881 * @since 20 882 */ 883 function setDelegatedPolicies(bundleName: string, accountId: number, policies: Array<string>): void; 884} 885 886export default adminManager; 887