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, Callback } from './@ohos.base'; 22import type Want from './@ohos.app.ability.Want'; 23 24/** 25 * This module provides the capability to control the enterprise devices. 26 * 27 * @namespace deviceControl 28 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 29 * @since 10 30 */ 31declare namespace deviceControl { 32 /** 33 * Allow the administrator to reset the enterprise devices. 34 * This function can be called by a super administrator. 35 * 36 * @permission ohos.permission.ENTERPRISE_RESET_DEVICE 37 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 38 * The admin must have the corresponding permission. 39 * @param { AsyncCallback<void> } callback - the callback of resetFactory. 40 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 41 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 42 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 43 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 44 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 45 * 2. Incorrect parameter types; 3. Parameter verification failed. 46 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 47 * @systemapi 48 * @StageModelOnly 49 * @since 10 50 */ 51 function resetFactory(admin: Want, callback: AsyncCallback<void>): void; 52 53 /** 54 * Allow the administrator to reset the enterprise devices. 55 * This function can be called by a super administrator. 56 * 57 * @permission ohos.permission.ENTERPRISE_RESET_DEVICE 58 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 59 * The admin must have the corresponding permission. 60 * @returns { Promise<void> } the promise returned by the resetFactory. 61 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 62 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 63 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 64 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 65 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 66 * 2. Incorrect parameter types; 3. Parameter verification failed. 67 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 68 * @systemapi 69 * @StageModelOnly 70 * @since 10 71 */ 72 function resetFactory(admin: Want): Promise<void>; 73 74 /** 75 * Allows the administrator to shutdown the devices. 76 * This function can be called by a super administrator. 77 * 78 * @permission ohos.permission.ENTERPRISE_REBOOT 79 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 80 * The admin must have the corresponding permission. 81 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 82 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 83 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 84 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 85 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 86 * 2. Incorrect parameter types; 3. Parameter verification failed. 87 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 88 * @systemapi 89 * @stagemodelonly 90 * @since 11 91 */ 92 function shutdown(admin: Want): void; 93 94 /** 95 * Allows the administrator to reboot the devices. 96 * This function can be called by a super administrator. 97 * 98 * @permission ohos.permission.ENTERPRISE_REBOOT 99 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 100 * The admin must have the corresponding permission. 101 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 102 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 103 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 104 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 105 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 106 * 2. Incorrect parameter types; 3. Parameter verification failed. 107 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 108 * @systemapi 109 * @stagemodelonly 110 * @since 11 111 */ 112 function reboot(admin: Want): void; 113 114 /** 115 * Allows the administrator to lock screen. 116 * This function can be called by a super administrator. 117 * 118 * @permission ohos.permission.ENTERPRISE_LOCK_DEVICE 119 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 120 * The admin must have the corresponding permission. 121 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 122 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 123 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 124 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 125 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 126 * 2. Incorrect parameter types; 3. Parameter verification failed. 127 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 128 * @systemapi 129 * @stagemodelonly 130 * @since 11 131 */ 132 function lockScreen(admin: Want): void; 133 134 /** 135 * Allows the administrator to operate device. 136 * This function can be called by a super administrator. 137 * 138 * @permission ohos.permission.ENTERPRISE_OPERATE_DEVICE 139 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 140 * The admin must have the corresponding permission. 141 * @param { string } operate - operate indicates the operation to be performed, 142 * the supported device operations include lockScreen, resetFactory, reboot and shutDown. 143 * @param { string } [addition] - addition indicates the specify additional parameters when performing the operation. 144 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 145 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 146 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 147 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 148 * 2. Incorrect parameter types; 3. Parameter verification failed. 149 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 150 * @stagemodelonly 151 * @since 12 152 */ 153 function operateDevice(admin: Want, operate: string, addition?: string): void; 154} 155 156export default deviceControl; 157