1/* 2 * Copyright (c) 2022 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 datetime of the enterprise devices. 26 * 27 * @namespace dateTimeManager 28 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 29 * @systemapi 30 * @since 9 31 */ 32declare namespace dateTimeManager { 33 /** 34 * Sets the system time. 35 * This function can be called by a super administrator. 36 * 37 * @permission ohos.permission.ENTERPRISE_SET_DATETIME 38 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 39 * The admin must have the corresponding permission. 40 * @param { number } time - time indicates the target time stamp (ms). 41 * @param { AsyncCallback<void> } callback - the callback of setDateTime. 42 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 43 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 44 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 45 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 46 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 47 * 2. Incorrect parameter types; 3. Parameter verification failed. 48 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 49 * @systemapi 50 * @StageModelOnly 51 * @since 9 52 */ 53 function setDateTime(admin: Want, time: number, callback: AsyncCallback<void>): void; 54 55 /** 56 * Sets the system time. 57 * This function can be called by a super administrator. 58 * 59 * @permission ohos.permission.ENTERPRISE_SET_DATETIME 60 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 61 * The admin must have the corresponding permission. 62 * @param { number } time - time indicates the target time stamp (ms). 63 * @returns { Promise<void> } the promise returned by the setDateTime. 64 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 65 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 66 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 67 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 68 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 69 * 2. Incorrect parameter types; 3. Parameter verification failed. 70 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 71 * @systemapi 72 * @StageModelOnly 73 * @since 9 74 */ 75 function setDateTime(admin: Want, time: number): Promise<void>; 76 77 /** 78 * Disallow modify the system time. 79 * This function can be called by a super administrator. 80 * 81 * @permission ohos.permission.ENTERPRISE_SET_DATETIME 82 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 83 * The admin must have the corresponding permission. 84 * @param { boolean } disallow - true if the user is not allowed to modify the system time. 85 * @param { AsyncCallback<void> } callback - the callback of disallowModifyDateTime. 86 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 87 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 88 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 89 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 90 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 91 * 2. Incorrect parameter types; 3. Parameter verification failed. 92 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 93 * @systemapi 94 * @StageModelOnly 95 * @since 10 96 */ 97 function disallowModifyDateTime(admin: Want, disallow: boolean, callback: AsyncCallback<void>): void; 98 99 /** 100 * Disallow modify the system time. 101 * This function can be called by a super administrator. 102 * 103 * @permission ohos.permission.ENTERPRISE_SET_DATETIME 104 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 105 * The admin must have the corresponding permission. 106 * @param { boolean } disallow - true if the user is not allowed to modify the system time. 107 * @returns { Promise<void> } the promise returned by the disallowModifyDateTime. 108 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 109 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 110 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 111 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 112 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 113 * 2. Incorrect parameter types; 3. Parameter verification failed. 114 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 115 * @systemapi 116 * @StageModelOnly 117 * @since 10 118 */ 119 function disallowModifyDateTime(admin: Want, disallow: boolean): Promise<void>; 120 121 /** 122 * Query the capability of modify the system time is allowed or disallowed. 123 * This function can be called by a super administrator. 124 * 125 * @permission ohos.permission.ENTERPRISE_SET_DATETIME 126 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 127 * If the admin is not empty, it must have the corresponding permission. 128 * @param { AsyncCallback<boolean> } callback - return true if modify datetime is not allowed. 129 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 130 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 131 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 132 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 133 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 134 * 2. Incorrect parameter types; 3. Parameter verification failed. 135 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 136 * @systemapi 137 * @StageModelOnly 138 * @since 10 139 */ 140 function isModifyDateTimeDisallowed(admin: Want, callback: AsyncCallback<boolean>): void; 141 142 /** 143 * Query the capability of modify the system time is allowed or disallowed. 144 * This function can be called by a super administrator. 145 * 146 * @permission ohos.permission.ENTERPRISE_SET_DATETIME 147 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 148 * If the admin is not empty, it must have the corresponding permission. 149 * @returns { Promise<boolean> } return true if modify datetime is not allowed. 150 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 151 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 152 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 153 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 154 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 155 * 2. Incorrect parameter types; 3. Parameter verification failed. 156 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 157 * @systemapi 158 * @StageModelOnly 159 * @since 10 160 */ 161 function isModifyDateTimeDisallowed(admin: Want): Promise<boolean>; 162} 163 164 165export default dateTimeManager; 166