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 /** 148 * Enables the given ability as a administrator of the device. 149 * Only apps with the ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN permission or the shell uid can call this method. 150 * 151 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 152 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 153 * The admin must have the corresponding permission. 154 * @param { EnterpriseInfo } enterpriseInfo - enterpriseInfo indicates the enterprise information of the calling application. 155 * @param { AdminType } type - type indicates the type of administrator to set. 156 * @param { AsyncCallback<void> } callback - the callback of enableAdmin. 157 * @throws { BusinessError } 9200003 - The administrator ability component is invalid. 158 * @throws { BusinessError } 9200004 - Failed to activate the administrator application of the device. 159 * @throws { BusinessError } 9200007 - The system ability works abnormally. 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 9 168 */ 169 function enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback<void>): void; 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 { number } userId - userId indicates the user ID. 181 * @param { AsyncCallback<void> } callback - the callback of enableAdmin. 182 * @throws { BusinessError } 9200003 - The administrator ability component is invalid. 183 * @throws { BusinessError } 9200004 - Failed to activate the administrator application of the device. 184 * @throws { BusinessError } 9200007 - The system ability works abnormally. 185 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 186 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 187 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 188 * 2. Incorrect parameter types; 3. Parameter verification failed. 189 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 190 * @systemapi 191 * @stagemodelonly 192 * @since 9 193 */ 194 function enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId: number, callback: AsyncCallback<void>): void; 195 196 /** 197 * Enables the given ability as a administrator of the device. 198 * Only apps with the ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN permission or the shell uid can call this method. 199 * 200 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 201 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 202 * The admin must have the corresponding permission. 203 * @param { EnterpriseInfo } enterpriseInfo - enterpriseInfo indicates the enterprise information of the calling application. 204 * @param { AdminType } type - type indicates the type of administrator to set. 205 * @param { number } [userId] - userId indicates the user ID or do not pass user ID. 206 * @returns { Promise<void> } the promise returned by the enableAdmin. 207 * @throws { BusinessError } 9200003 - The administrator ability component is invalid. 208 * @throws { BusinessError } 9200004 - Failed to activate the administrator application of the device. 209 * @throws { BusinessError } 9200007 - The system ability works abnormally. 210 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 211 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 212 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 213 * 2. Incorrect parameter types; 3. Parameter verification failed. 214 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 215 * @systemapi 216 * @stagemodelonly 217 * @since 9 218 */ 219 function enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId?: number): Promise<void>; 220 221 /** 222 * Disables a current normal administrator ability. 223 * Only apps with the ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN permission or the shell uid can call this method. 224 * 225 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 226 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 227 * The admin must have the corresponding permission. 228 * @param { AsyncCallback<void> } callback - the callback of disableAdmin. 229 * @throws { BusinessError } 9200005 - Failed to deactivate the administrator application of the device. 230 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 231 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 232 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 233 * 2. Incorrect parameter types; 3. Parameter verification failed. 234 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 235 * @systemapi 236 * @stagemodelonly 237 * @since 9 238 */ 239 function disableAdmin(admin: Want, callback: AsyncCallback<void>): void; 240 241 /** 242 * Disables a current normal administrator ability. 243 * Only apps with the ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN permission or the shell uid can call this method. 244 * 245 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 246 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 247 * The admin must have the corresponding permission. 248 * @param { number } userId - userId indicates the user ID. 249 * @param { AsyncCallback<void> } callback - the callback of disableAdmin. 250 * @throws { BusinessError } 9200005 - Failed to deactivate the administrator application of the device. 251 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 252 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 253 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 254 * 2. Incorrect parameter types; 3. Parameter verification failed. 255 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 256 * @systemapi 257 * @stagemodelonly 258 * @since 9 259 */ 260 function disableAdmin(admin: Want, userId: number, callback: AsyncCallback<void>): void; 261 262 /** 263 * Disables a current administrator ability. 264 * Only apps with the ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN permission or the shell uid can call this method. 265 * 266 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 267 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 268 * The admin must have the corresponding permission. 269 * @param { number } [userId] - userId indicates the user ID or do not pass user ID. 270 * @returns { Promise<void> } the promise returned by the disableAdmin. 271 * @throws { BusinessError } 9200005 - Failed to deactivate the administrator application of the device. 272 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 273 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 274 * 2. Incorrect parameter types; 3. Parameter verification failed. 275 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 276 * @stagemodelonly 277 * @since 12 278 */ 279 function disableAdmin(admin: Want, userId?: number): Promise<void>; 280 281 /** 282 * Disables a current super administrator ability. 283 * Only the administrator app or apps with the shell uid can call this method. 284 * 285 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 286 * @param { String } bundleName - bundleName indicates the administrator bundle information. 287 * @param { AsyncCallback<void> } callback - the callback of disableSuperAdmin. 288 * @throws { BusinessError } 9200005 - Failed to deactivate the administrator application of the device. 289 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 290 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 291 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 292 * 2. Incorrect parameter types; 3. Parameter verification failed. 293 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 294 * @systemapi 295 * @stagemodelonly 296 * @since 9 297 */ 298 function disableSuperAdmin(bundleName: String, callback: AsyncCallback<void>): void; 299 300 /** 301 * Disables a current super administrator ability. 302 * Only the administrator app or apps with the shell uid can call this method. 303 * 304 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 305 * @param { String } bundleName - bundleName indicates the administrator bundle information. 306 * @returns { Promise<void> } the promise returned by the disableSuperAdmin. 307 * @throws { BusinessError } 9200005 - Failed to deactivate the administrator application of the device. 308 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 309 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 310 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 311 * 2. Incorrect parameter types; 3. Parameter verification failed. 312 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 313 * @systemapi 314 * @stagemodelonly 315 * @since 9 316 */ 317 function disableSuperAdmin(bundleName: String): Promise<void>; 318 319 /** 320 * Get whether the ability is enabled as device administrator. 321 * 322 * @param { Want } admin - admin indicates the administrator ability information. 323 * @param { AsyncCallback<boolean> } callback - callback contained true if the administrator is enabled. 324 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 325 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 326 * 2. Incorrect parameter types. 327 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 328 * @systemapi 329 * @stagemodelonly 330 * @since 9 331 */ 332 function isAdminEnabled(admin: Want, callback: AsyncCallback<boolean>): void; 333 334 /** 335 * Get whether the ability is enabled as device administrator. 336 * 337 * @param { Want } admin - admin indicates the administrator ability information. 338 * @param { number } userId - userId indicates the user ID. 339 * @param { AsyncCallback<boolean> } callback - callback contained true if the administrator is enabled. 340 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 341 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 342 * 2. Incorrect parameter types. 343 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 344 * @systemapi 345 * @stagemodelonly 346 * @since 9 347 */ 348 function isAdminEnabled(admin: Want, userId: number, callback: AsyncCallback<boolean>): void; 349 350 /** 351 * Get whether the ability is enabled as device administrator. 352 * 353 * @param { Want } admin - admin indicates the administrator ability information. 354 * @param { number } [userId] - userId indicates the user ID or do not pass user ID. 355 * @returns { Promise<boolean> } promise contained true if the administrator is enabled. 356 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 357 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 358 * 2. Incorrect parameter types. 359 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 360 * @systemapi 361 * @stagemodelonly 362 * @since 9 363 */ 364 function isAdminEnabled(admin: Want, userId?: number): Promise<boolean>; 365 366 /** 367 * Get information of the administrator's enterprise. 368 * 369 * @param { Want } admin - admin indicates the administrator ability information. 370 * @param { AsyncCallback<EnterpriseInfo> } callback - callback contained the enterprise info of administrator. 371 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 372 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 373 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 374 * 2. Incorrect parameter types; 3. Parameter verification failed. 375 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 376 * @systemapi 377 * @stagemodelonly 378 * @since 9 379 */ 380 function getEnterpriseInfo(admin: Want, callback: AsyncCallback<EnterpriseInfo>): void; 381 382 /** 383 * Get information of the administrator's enterprise. 384 * 385 * @param { Want } admin - admin indicates the administrator ability information. 386 * @returns { Promise<EnterpriseInfo> } promise contained the enterprise info of administrator. 387 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 388 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 389 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 390 * 2. Incorrect parameter types; 3. Parameter verification failed. 391 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 392 * @systemapi 393 * @stagemodelonly 394 * @since 9 395 */ 396 function getEnterpriseInfo(admin: Want): Promise<EnterpriseInfo>; 397 398 /** 399 * Set the information of the administrator's enterprise. 400 * Only the administrator app can call this method. 401 * 402 * @permission ohos.permission.SET_ENTERPRISE_INFO 403 * @param { Want } admin - admin indicates the administrator ability information. 404 * @param { EnterpriseInfo } enterpriseInfo - enterpriseInfo indicates the enterprise information of the calling application. 405 * @param { AsyncCallback<void> } callback - the callback of setEnterpriseInfo. 406 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 407 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 408 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 409 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 410 * 2. Incorrect parameter types; 3. Parameter verification failed. 411 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 412 * @systemapi 413 * @stagemodelonly 414 * @since 9 415 */ 416 function setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCallback<void>): void; 417 418 /** 419 * Set the information of the administrator's enterprise. 420 * Only the administrator app can call this method. 421 * 422 * @permission ohos.permission.SET_ENTERPRISE_INFO 423 * @param { Want } admin - admin indicates the administrator ability information. 424 * @param { EnterpriseInfo } enterpriseInfo - enterpriseInfo indicates the enterprise information of the calling application. 425 * @returns { Promise<void> } the promise returned by the setEnterpriseInfo. 426 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 427 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 428 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 429 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 430 * 2. Incorrect parameter types; 3. Parameter verification failed. 431 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 432 * @systemapi 433 * @stagemodelonly 434 * @since 9 435 */ 436 function setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise<void>; 437 438 /** 439 * Get whether the ability is enabled as super device administrator. 440 * 441 * @param { String } bundleName - bundleName indicates the administrator bundle information. 442 * @param { AsyncCallback<boolean> } callback - callback contained true if the administrator is super administrator. 443 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 444 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 445 * 2. Incorrect parameter types. 446 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 447 * @systemapi 448 * @stagemodelonly 449 * @since 9 450 */ 451 function isSuperAdmin(bundleName: String, callback: AsyncCallback<boolean>): void; 452 453 /** 454 * Get whether the ability is enabled as super device administrator. 455 * 456 * @param { String } bundleName - bundleName indicates the administrator bundle information. 457 * @returns { Promise<boolean> } promise contained true if the administrator is super administrator. 458 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 459 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 460 * 2. Incorrect parameter types. 461 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 462 * @systemapi 463 * @stagemodelonly 464 * @since 9 465 */ 466 function isSuperAdmin(bundleName: String): Promise<boolean>; 467 468 /** 469 * Subscribes the managed event of admin. 470 * 471 * @permission ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 472 * @param { Want } admin - admin indicates the administrator ability information. 473 * @param { Array<ManagedEvent> } managedEvents - managedEvents indicates the managed events to subscribe. 474 * @param { AsyncCallback<void> } callback - the callback of subscribeManagedEvent. 475 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 476 * @throws { BusinessError } 9200008 - The specified system event is invalid. 477 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 478 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 479 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 480 * 2. Incorrect parameter types; 3. Parameter verification failed. 481 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 482 * @systemapi 483 * @stagemodelonly 484 * @since 9 485 */ 486 function subscribeManagedEvent(admin: Want, managedEvents: Array<ManagedEvent>, callback: AsyncCallback<void>): void; 487 488 /** 489 * Subscribes the managed event of admin. 490 * 491 * @permission ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 492 * @param { Want } admin - admin indicates the administrator ability information. 493 * @param { Array<ManagedEvent> } managedEvents - managedEvents indicates the managed events to subscribe. 494 * @returns { Promise<void> } the promise returned by the subscribeManagedEvent. 495 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 496 * @throws { BusinessError } 9200008 - The specified system event is invalid. 497 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 498 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 499 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 500 * 2. Incorrect parameter types; 3. Parameter verification failed. 501 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 502 * @systemapi 503 * @stagemodelonly 504 * @since 9 505 */ 506 function subscribeManagedEvent(admin: Want, managedEvents: Array<ManagedEvent>): Promise<void>; 507 508 /** 509 * Unsubscribes the managed event of admin. 510 * 511 * @permission ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 512 * @param { Want } admin - admin indicates the administrator ability information. 513 * @param { Array<ManagedEvent> } managedEvents - managedEvents indicates the managed events to subscribe. 514 * @param { AsyncCallback<void> } callback - the callback of unsubscribeManagedEvent. 515 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 516 * @throws { BusinessError } 9200008 - The specified system event is invalid. 517 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 518 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 519 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 520 * 2. Incorrect parameter types; 3. Parameter verification failed. 521 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 522 * @systemapi 523 * @stagemodelonly 524 * @since 9 525 */ 526 function unsubscribeManagedEvent(admin: Want, managedEvents: Array<ManagedEvent>, callback: AsyncCallback<void>): void; 527 528 /** 529 * Unsubscribes the managed event of admin. 530 * 531 * @permission ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 532 * @param { Want } admin - admin indicates the administrator ability information. 533 * @param { Array<ManagedEvent> } managedEvents - managedEvents indicates the managed events to subscribe. 534 * @returns { Promise<void> } the promise returned by the unsubscribeManagedEvent. 535 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 536 * @throws { BusinessError } 9200008 - The specified system event is invalid. 537 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 538 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 539 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 540 * 2. Incorrect parameter types; 3. Parameter verification failed. 541 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 542 * @systemapi 543 * @stagemodelonly 544 * @since 9 545 */ 546 function unsubscribeManagedEvent(admin: Want, managedEvents: Array<ManagedEvent>): Promise<void>; 547 548 /** 549 * Administrator authorize permissions to other applications. 550 * 551 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 552 * @param { Want } admin - admin indicates the administrator ability information. 553 * @param { string } bundleName - bundleName indicates the administrator bundle information. 554 * @param { AsyncCallback<void> } callback - the callback of authorizeAdmin. 555 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 556 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 557 * @throws { BusinessError } 9200009 - Failed to grant the permission to the application. 558 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 559 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 560 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 561 * 2. Incorrect parameter types; 3. Parameter verification failed. 562 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 563 * @systemapi 564 * @stagemodelonly 565 * @since 10 566 */ 567 function authorizeAdmin(admin: Want, bundleName: string, callback: AsyncCallback<void>): void; 568 569 /** 570 * Administrator authorize permissions to other applications. 571 * 572 * @permission ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 573 * @param { Want } admin - admin indicates the administrator ability information. 574 * @param { string } bundleName - bundleName indicates the administrator bundle information. 575 * @returns { Promise<void> } the promise returned by the authorizeAdmin. 576 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 577 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 578 * @throws { BusinessError } 9200009 - Failed to grant the permission to the application. 579 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 580 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 581 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 582 * 2. Incorrect parameter types; 3. Parameter verification failed. 583 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 584 * @systemapi 585 * @stagemodelonly 586 * @since 10 587 */ 588 function authorizeAdmin(admin: Want, bundleName: string): Promise<void>; 589 590 /** 591 * Get the super administrator of device. 592 * 593 * @returns { Promise<Want> } promise contained the want indicates the super administrator of the device. 594 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 595 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 596 * @systemapi 597 * @stagemodelonly 598 * @since 12 599 */ 600 function getSuperAdmin(): Promise<Want>; 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 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 609 * @throws { BusinessError } 9200008 - The specified system event is invalid. 610 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 611 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 612 * 2. Incorrect parameter types; 3. Parameter verification failed. 613 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 614 * @stagemodelonly 615 * @since 12 616 */ 617 function subscribeManagedEventSync(admin: Want, managedEvents: Array<ManagedEvent>): void; 618 619 /** 620 * Unsubscribes the managed event of admin. 621 * 622 * @permission ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 623 * @param { Want } admin - admin indicates the administrator ability information. 624 * @param { Array<ManagedEvent> } managedEvents - managedEvents indicates the managed events to subscribe. 625 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 626 * @throws { BusinessError } 9200008 - The specified system event is invalid. 627 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 628 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 629 * 2. Incorrect parameter types; 3. Parameter verification failed. 630 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 631 * @stagemodelonly 632 * @since 12 633 */ 634 function unsubscribeManagedEventSync(admin: Want, managedEvents: Array<ManagedEvent>): void; 635 636 /** 637 * Administrator delegates access to policies to another application. 638 * 639 * @permission ohos.permission.ENTERPRISE_MANAGE_DELEGATED_POLICY 640 * @param { Want } admin - admin indicates the administrator ability information. 641 * @param { string } bundleName - bundleName indicates the bundle name of the delegated application. 642 * @param { Array<string> } policies - policies indicates the policies accessible to the delegated application. 643 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 644 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 645 * @throws { BusinessError } 9200009 - Failed to grant the permission to the application. 646 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 647 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 648 * 2. Incorrect parameter types; 3. Parameter verification failed. 649 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 650 * @stagemodelonly 651 * @since 14 652 */ 653 function setDelegatedPolicies(admin: Want, bundleName: string, policies: Array<string>): void; 654 655 /** 656 * Administrator gets the list of delegation policies for the application. 657 * 658 * @permission ohos.permission.ENTERPRISE_MANAGE_DELEGATED_POLICY 659 * @param { Want } admin - admin indicates the administrator ability information. 660 * @param { string } bundleName - bundleName indicates the bundle name of the delegated application. 661 * @returns { Array<string> } the policies accessible to the delegated application. 662 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 663 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 664 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 665 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 666 * 2. Incorrect parameter types; 3. Parameter verification failed. 667 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 668 * @stagemodelonly 669 * @since 14 670 */ 671 function getDelegatedPolicies(admin: Want, bundleName: string): Array<string>; 672 673 /** 674 * Administrator gets the delegated applications which access to the policy. 675 * 676 * @permission ohos.permission.ENTERPRISE_MANAGE_DELEGATED_POLICY 677 * @param { Want } admin - admin indicates the administrator ability information. 678 * @param { string } policy - policy indicates the policy that delegated to other applications. 679 * @returns { Array<string> } the bundle names of the delegated application that access to the policy. 680 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 681 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 682 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 683 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 684 * 2. Incorrect parameter types; 3. Parameter verification failed. 685 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 686 * @stagemodelonly 687 * @since 14 688 */ 689 function getDelegatedBundleNames(admin: Want, policy: string): Array<string>; 690 691 /** 692 * Starts an ability of admin provision application. 693 * 694 * @permission ohos.permission.START_PROVISIONING_MESSAGE 695 * @param { Want } admin - admin indicates the administrator ability information. 696 * @param { AdminType } type - type indicates the type of administrator to set. 697 * @param { common.Context } context - context indicates the context of application. 698 * @param { Record<string, string> } parameters - the parameters indicates the custom parameters of start an administrator provision. 699 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 700 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 701 * 2. Incorrect parameter types; 3. Parameter verification failed. 702 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 703 * @stagemodelonly 704 * @since 15 705 */ 706 function startAdminProvision(admin: Want, type: AdminType, context: common.Context, parameters: Record<string, string>): void; 707 708 /** 709 * Gets administrators of device. 710 * 711 * @returns { Promise<Array<Want>> } returns the want list indicates the administrators of the device. 712 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 713 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 714 * @systemapi 715 * @stagemodelonly 716 * @since 15 717 */ 718 function getAdmins(): Promise<Array<Want>>; 719} 720 721export default adminManager; 722