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 BasicServicesKit 19 */ 20 21import { AsyncCallback, BusinessError } from './@ohos.base'; 22 23/** 24 * The interface of system parameters class. 25 * 26 * @namespace systemParameterEnhance 27 * @syscap SystemCapability.Startup.SystemInfo 28 * @systemapi Hide this for inner system use. 29 * @since 9 30 */ 31declare namespace systemParameterEnhance { 32 /** 33 * Gets the value of the attribute with the specified key. 34 * 35 * @param { string } key Key of the system attribute, cannot exceed 128 characters, 36 * only allow alphanumeric, plus '.', '-', '@', ':', or '_', don't allow '..'. 37 * @param { string } def Default value. 38 * @returns { string } the value of the parameter. 39 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 40 * 2.incorrect parameter types; 3.parameter verification failed. 41 * @throws { BusinessError } 14700101 - System parameter not found. 42 * @throws { BusinessError } 14700103 - The operation on the system permission is denied. 43 * @throws { BusinessError } 14700104 - System internal error such as out memory or deadlock. 44 * @syscap SystemCapability.Startup.SystemInfo 45 * @systemapi Hide this for inner system use. 46 * @since 9 47 */ 48 function getSync(key: string, def?: string): string; 49 50 /** 51 * Gets the value of the attribute with the specified key. 52 * 53 * @param { string } key Key of the system attribute, cannot exceed 128 characters, 54 * only allow alphanumeric, plus '.', '-', '@', ':', or '_', don't allow '..'. 55 * @param { AsyncCallback<string> } callback Callback function. 56 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 57 * 2.incorrect parameter types; 3.parameter verification failed. 58 * @throws { BusinessError } 14700101 - System parameter not found. 59 * @throws { BusinessError } 14700103 - The operation on the system permission is denied. 60 * @throws { BusinessError } 14700104 - System internal error such as out memory or deadlock. 61 * @syscap SystemCapability.Startup.SystemInfo 62 * @systemapi Hide this for inner system use. 63 * @since 9 64 */ 65 function get(key: string, callback: AsyncCallback<string>): void; 66 67 /** 68 * Gets the value of the attribute with the specified key. 69 * 70 * @param { string } key Key of the system attribute, cannot exceed 128 characters, 71 * only allow alphanumeric, plus '.', '-', '@', ':', or '_', don't allow '..'. 72 * @param { string } def Default value. 73 * @param { AsyncCallback<string> } callback Callback function. 74 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 75 * 2.incorrect parameter types; 3.parameter verification failed. 76 * @throws { BusinessError } 14700101 - System parameter not found. 77 * @throws { BusinessError } 14700103 - The operation on the system permission is denied. 78 * @throws { BusinessError } 14700104 - System internal error such as out memory or deadlock. 79 * @syscap SystemCapability.Startup.SystemInfo 80 * @systemapi Hide this for inner system use. 81 * @since 9 82 */ 83 function get(key: string, def: string, callback: AsyncCallback<string>): void; 84 85 /** 86 * Gets the value of the attribute with the specified key. 87 * 88 * @param { string } key Key of the system attribute, cannot exceed 128 characters, 89 * only allow alphanumeric, plus '.', '-', '@', ':', or '_', don't allow '..'. 90 * @param { string } def Default value. 91 * @returns { Promise<string> }, which is used to obtain the result asynchronously. 92 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 93 * 2.incorrect parameter types; 3.parameter verification failed. 94 * @throws { BusinessError } 14700101 - System parameter not found. 95 * @throws { BusinessError } 14700103 - The operation on the system permission is denied. 96 * @throws { BusinessError } 14700104 - System internal error such as out memory or deadlock. 97 * @syscap SystemCapability.Startup.SystemInfo 98 * @systemapi Hide this for inner system use. 99 * @since 9 100 */ 101 function get(key: string, def?: string): Promise<string>; 102 103 /** 104 * Sets a value for the attribute with the specified key. 105 * 106 * @param { string } key Key of the system attribute, cannot exceed 128 characters, 107 * only allow alphanumeric, plus '.', '-', '@', ':', or '_', don't allow '..'. 108 * @param { string } value System attribute value to set, cannot exceed 96 characters. 109 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 110 * 2.incorrect parameter types; 3.parameter verification failed. 111 * @throws { BusinessError } 14700102 - Invalid system parameter value. 112 * @throws { BusinessError } 14700103 - The operation on the system permission is denied. 113 * @throws { BusinessError } 14700104 - System internal error such as out memory or deadlock. 114 * @syscap SystemCapability.Startup.SystemInfo 115 * @systemapi Hide this for inner system use. 116 * @since 9 117 */ 118 function setSync(key: string, value: string): void; 119 120 /** 121 * Sets a value for the attribute with the specified key. 122 * 123 * @param { string } key Key of the system attribute, cannot exceed 128 characters, 124 * only allow alphanumeric, plus '.', '-', '@', ':', or '_', don't allow '..'. 125 * @param { string } value System attribute value to set, cannot exceed 96 characters. 126 * @param { AsyncCallback<void> } callback Callback function. 127 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 128 * 2.incorrect parameter types; 3.parameter verification failed. 129 * @throws { BusinessError } 14700102 - Invalid system parameter value. 130 * @throws { BusinessError } 14700103 - The operation on the system permission is denied. 131 * @throws { BusinessError } 14700104 - System internal error such as out memory or deadlock. 132 * @syscap SystemCapability.Startup.SystemInfo 133 * @systemapi Hide this for inner system use. 134 * @since 9 135 */ 136 function set(key: string, value: string, callback: AsyncCallback<void>): void; 137 138 /** 139 * Sets a value for the attribute with the specified key. 140 * 141 * @param { string } key Key of the system attribute, cannot exceed 128 characters, 142 * only allow alphanumeric, plus '.', '-', '@', ':', or '_', don't allow '..'. 143 * @param { string } value Default value, cannot exceed 96 characters. 144 * @returns { Promise<void> }, which is used to obtain the result asynchronously. 145 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 146 * 2.incorrect parameter types; 3.parameter verification failed. 147 * @throws { BusinessError } 14700102 - Invalid system parameter value. 148 * @throws { BusinessError } 14700103 - The operation on the system permission is denied. 149 * @throws { BusinessError } 14700104 - System internal error such as out memory or deadlock. 150 * @syscap SystemCapability.Startup.SystemInfo 151 * @systemapi Hide this for inner system use. 152 * @since 9 153 */ 154 function set(key: string, value: string): Promise<void>; 155} 156 157export default systemParameterEnhance; 158