1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit MDMKit 19 */ 20 21import type { AsyncCallback } from './@ohos.base'; 22import type Want from './@ohos.app.ability.Want'; 23 24/** 25 * This module provides the capability to manage the device settings of the enterprise devices. 26 * 27 * @namespace deviceSettings 28 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 29 * @systemapi 30 * @since 10 31 */ 32declare namespace deviceSettings { 33 /** 34 * Device power policy. 35 * 36 * @typedef PowerPolicy 37 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 38 * @systemapi 39 * @stagemodelonly 40 * @since 11 41 */ 42 export interface PowerPolicy { 43 /** 44 * An action that needs to be performed after a certain delay 45 * 46 * @type { PowerPolicyAction } 47 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 48 * @systemapi 49 * @stagemodelonly 50 * @since 11 51 */ 52 powerPolicyAction: PowerPolicyAction; 53 54 /** 55 * Delay time fo execute power policy action 56 * 57 * @type { number } 58 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 59 * @systemapi 60 * @stagemodelonly 61 * @since 11 62 */ 63 delayTime: number; 64 } 65 66 /** 67 * Actions of power policy. 68 * 69 * @enum { number } 70 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 71 * @systemapi 72 * @since 11 73 */ 74 enum PowerPolicyAction { 75 /** 76 * Performs no action after a certain delay 77 * 78 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 79 * @systemapi 80 * @stagemodelonly 81 * @since 11 82 */ 83 NONE = 0, 84 85 /** 86 * Performs auto suspend action after a certain delay 87 * 88 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 89 * @systemapi 90 * @stagemodelonly 91 * @since 11 92 */ 93 AUTO_SUSPEND, 94 95 /** 96 * Performs force suspend action after a certain delay 97 * 98 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 99 * @systemapi 100 * @stagemodelonly 101 * @since 11 102 */ 103 FORCE_SUSPEND, 104 105 /** 106 * Performs hibernate action after a certain delay 107 * 108 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 109 * @systemapi 110 * @stagemodelonly 111 * @since 11 112 */ 113 HIBERNATE, 114 115 /** 116 * Performs shutdown action after a certain delay 117 * 118 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 119 * @systemapi 120 * @stagemodelonly 121 * @since 11 122 */ 123 SHUTDOWN 124 } 125 126 /** 127 * The scene to execute power policy. 128 * 129 * @enum { number } 130 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 131 * @systemapi 132 * @since 11 133 */ 134 enum PowerScene { 135 /** 136 * Time out scene 137 * 138 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 139 * @systemapi 140 * @stagemodelonly 141 * @since 11 142 */ 143 TIME_OUT = 0 144 } 145 146 /** 147 * User certificate data. 148 * 149 * @typedef CertBlob 150 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 151 * @systemapi 152 * @stagemodelonly 153 * @since 10 154 */ 155 export interface CertBlob { 156 /** 157 * The certificate content 158 * 159 * @type { Uint8Array } 160 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 161 * @systemapi 162 * @stagemodelonly 163 * @since 10 164 */ 165 inData: Uint8Array; 166 167 /** 168 * The certificate alias 169 * 170 * @type { string } 171 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 172 * @systemapi 173 * @stagemodelonly 174 * @since 10 175 */ 176 alias: string; 177 } 178 179 /** 180 * Sets the screen off time. 181 * This function can be called by a super administrator. 182 * 183 * @permission ohos.permission.ENTERPRISE_SET_SCREENOFF_TIME 184 * @param { Want } admin - admin indicates the administrator ability information. 185 * @param { number } time - screen off time. 186 * @throws { BusinessError } 9200001 - the application is not an administrator of the device. 187 * @throws { BusinessError } 9200002 - the administrator application does not have permission to manage the device. 188 * @throws { BusinessError } 201 - the application does not have permission to call this function. 189 * @throws { BusinessError } 202 - not system application. 190 * @throws { BusinessError } 401 - invalid input parameter. 191 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 192 * @systemapi 193 * @stagemodelonly 194 * @since 11 195 */ 196 function setScreenOffTime(admin: Want, time: number): void; 197 198 /** 199 * Gets the device screen off time. 200 * This function can be called by a super administrator. 201 * 202 * @permission ohos.permission.ENTERPRISE_GET_SETTINGS 203 * @param { Want } admin - admin indicates the administrator ability information. 204 * @param { AsyncCallback<number> } callback - the callback of getScreenOffTime. 205 * @throws { BusinessError } 9200001 - the application is not an administrator of the device. 206 * @throws { BusinessError } 9200002 - the administrator application does not have permission to manage the device. 207 * @throws { BusinessError } 201 - the application does not have permission to call this function. 208 * @throws { BusinessError } 202 - not system application. 209 * @throws { BusinessError } 401 - invalid input parameter. 210 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 211 * @systemapi 212 * @StageModelOnly 213 * @since 10 214 */ 215 function getScreenOffTime(admin: Want, callback: AsyncCallback<number>): void; 216 217 /** 218 * Gets the device screen off time. 219 * This function can be called by a super administrator. 220 * 221 * @permission ohos.permission.ENTERPRISE_GET_SETTINGS 222 * @param { Want } admin - admin indicates the administrator ability information. 223 * @returns { Promise<number> } the promise returned by the getScreenOffTime. 224 * @throws { BusinessError } 9200001 - the application is not an administrator of the device. 225 * @throws { BusinessError } 9200002 - the administrator application does not have permission to manage the device. 226 * @throws { BusinessError } 201 - the application does not have permission to call this function. 227 * @throws { BusinessError } 202 - not system application. 228 * @throws { BusinessError } 401 - invalid input parameter. 229 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 230 * @systemapi 231 * @StageModelOnly 232 * @since 10 233 */ 234 function getScreenOffTime(admin: Want): Promise<number>; 235 236 /** 237 * Install user certificate. 238 * This function can be called by a super administrator. 239 * 240 * @permission ohos.permission.ENTERPRISE_MANAGE_CERTIFICATE 241 * @param { Want } admin - admin indicates the administrator ability information. 242 * @param { CertBlob } certificate - certificate file content and alias. 243 * @param { AsyncCallback<string> } callback - The callback carries the uri of the certificate used to uninstall 244 * @throws { BusinessError } 9200001 - the application is not an administrator of the device. 245 * @throws { BusinessError } 9200002 - the administrator application does not have permission to manage the device. 246 * @throws { BusinessError } 9201001 - manage certificate failed 247 * @throws { BusinessError } 201 - the application does not have permission to call this function. 248 * @throws { BusinessError } 202 - not system application. 249 * @throws { BusinessError } 401 - invalid input parameter. 250 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 251 * @systemapi 252 * @stagemodelonly 253 * @since 10 254 */ 255 function installUserCertificate(admin: Want, certificate: CertBlob, callback: AsyncCallback<string>): void; 256 257 /** 258 * Install user certificate. 259 * This function can be called by a super administrator. 260 * 261 * @permission ohos.permission.ENTERPRISE_MANAGE_CERTIFICATE 262 * @param { Want } admin - admin indicates the administrator ability information. 263 * @param { CertBlob } certificate - certificate file content and alias. 264 * @returns { Promise<string> } the promise carries the uri of the certificate used to uninstall 265 * @throws { BusinessError } 9200001 - the application is not an administrator of the device. 266 * @throws { BusinessError } 9200002 - the administrator application does not have permission to manage the device. 267 * @throws { BusinessError } 9201001 - manage certificate failed 268 * @throws { BusinessError } 201 - the application does not have permission to call this function. 269 * @throws { BusinessError } 202 - not system application. 270 * @throws { BusinessError } 401 - invalid input parameter. 271 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 272 * @systemapi 273 * @stagemodelonly 274 * @since 10 275 */ 276 function installUserCertificate(admin: Want, certificate: CertBlob): Promise<string>; 277 278 /** 279 * Uninstall user certificate. 280 * This function can be called by a super administrator. 281 * 282 * @permission ohos.permission.ENTERPRISE_MANAGE_CERTIFICATE 283 * @param { Want } admin - admin indicates the administrator ability information. 284 * @param { string } certUri - uri of the certificate. 285 * @param { AsyncCallback<void> } callback - the callback of uninstallUserCertificate. 286 * @throws { BusinessError } 9200001 - the application is not an administrator of the device. 287 * @throws { BusinessError } 9200002 - the administrator application does not have permission to manage the device. 288 * @throws { BusinessError } 9201001 - manage certificate failed 289 * @throws { BusinessError } 201 - the application does not have permission to call this function. 290 * @throws { BusinessError } 202 - not system application. 291 * @throws { BusinessError } 401 - invalid input parameter. 292 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 293 * @systemapi 294 * @stagemodelonly 295 * @since 10 296 */ 297 function uninstallUserCertificate(admin: Want, certUri: string, callback: AsyncCallback<void>): void; 298 299 /** 300 * Uninstall user certificate. 301 * This function can be called by a super administrator. 302 * 303 * @permission ohos.permission.ENTERPRISE_MANAGE_CERTIFICATE 304 * @param { Want } admin - admin indicates the administrator ability information. 305 * @param { string } certUri - uri of the certificate. 306 * @returns { Promise<void> } the promise returned by the uninstallUserCertificate. 307 * @throws { BusinessError } 9200001 - the application is not an administrator of the device. 308 * @throws { BusinessError } 9200002 - the administrator application does not have permission to manage the device. 309 * @throws { BusinessError } 9201001 - manage certificate failed 310 * @throws { BusinessError } 201 - the application does not have permission to call this function. 311 * @throws { BusinessError } 202 - not system application. 312 * @throws { BusinessError } 401 - invalid input parameter. 313 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 314 * @systemapi 315 * @stagemodelonly 316 * @since 10 317 */ 318 function uninstallUserCertificate(admin: Want, certUri: string): Promise<void>; 319 320 /** 321 * Sets the power policy. 322 * This function can be called by a super administrator. 323 * 324 * @permission ohos.permission.ENTERPRISE_MANAGE_SETTINGS 325 * @param { Want } admin - admin indicates the administrator ability information. 326 * @param { PowerScene } powerScene - the scene to execute power policy. 327 * @param { PowerPolicy } powerPolicy - device power policy. 328 * @throws { BusinessError } 9200001 - the application is not an administrator of the device. 329 * @throws { BusinessError } 9200002 - the administrator application does not have permission to manage the device. 330 * @throws { BusinessError } 201 - the application does not have permission to call this function. 331 * @throws { BusinessError } 202 - not system application. 332 * @throws { BusinessError } 401 - invalid input parameter. 333 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 334 * @systemapi 335 * @stagemodelonly 336 * @since 11 337 */ 338 function setPowerPolicy(admin: Want, powerScene: PowerScene, powerPolicy: PowerPolicy): void; 339 340 /** 341 * Gets the power policy. 342 * This function can be called by a super administrator. 343 * 344 * @permission ohos.permission.ENTERPRISE_MANAGE_SETTINGS 345 * @param { Want } admin - admin indicates the administrator ability information. 346 * @param { PowerScene } powerScene - the scene to execute power policy. 347 * @returns { PowerPolicy } device power policy. 348 * @throws { BusinessError } 9200001 - the application is not an administrator of the device. 349 * @throws { BusinessError } 9200002 - the administrator application does not have permission to manage the device. 350 * @throws { BusinessError } 201 - the application does not have permission to call this function. 351 * @throws { BusinessError } 202 - not system application. 352 * @throws { BusinessError } 401 - invalid input parameter. 353 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 354 * @systemapi 355 * @stagemodelonly 356 * @since 11 357 */ 358 function getPowerPolicy(admin: Want, powerScene: PowerScene): PowerPolicy; 359} 360 361export default deviceSettings; 362