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 16import { AsyncCallback, BusinessError } from './basic'; 17 18 /** 19 * The interface of system parameters class. 20 * 21 * @since 9 22 * @syscap SystemCapability.Startup.SystemInfo 23 * @systemapi Hide this for inner system use. 24 */ 25declare namespace systemParameterEnhance { 26 /** 27 * Gets the value of the attribute with the specified key. 28 * 29 * @param key Key of the system attribute. 30 * @param def Default value. 31 * @returns the value of the parameter. 32 * @throws {BusinessError} 401 - if type of key is not string or key is not specified. 33 * @throws {BusinessError} 14700101 - if key is not found 34 * @throws {BusinessError} 14700103 - if permission denied 35 * @throws {BusinessError} 14700104 - if system internal error 36 * @syscap SystemCapability.Startup.SystemInfo 37 * @since 9 38 */ 39 function getSync(key: string, def?: string): string; 40 41 /** 42 * Gets the value of the attribute with the specified key. 43 * 44 * @param key Key of the system attribute. 45 * @param callback Callback function. 46 * @throws {BusinessError} 401 - if type of key is not string or key is not specified. 47 * @throws {BusinessError} 14700101 - if key is not found 48 * @throws {BusinessError} 14700103 - if permission denied 49 * @throws {BusinessError} 14700104 - if system internal error 50 * @syscap SystemCapability.Startup.SystemInfo 51 * @since 9 52 */ 53 function get(key: string, callback: AsyncCallback<string>): void; 54 55 /** 56 * Gets the value of the attribute with the specified key. 57 * 58 * @param key Key of the system attribute. 59 * @param def Default value. 60 * @param callback Callback function. 61 * @throws {BusinessError} 401 - if type of key is not string or key is not specified. 62 * @throws {BusinessError} 14700101 - if key is not found 63 * @throws {BusinessError} 14700103 - if permission denied 64 * @throws {BusinessError} 14700104 - if system internal error 65 * @syscap SystemCapability.Startup.SystemInfo 66 * @since 9 67 */ 68 function get(key: string, def: string, callback: AsyncCallback<string>): void; 69 70 /** 71 * Gets the value of the attribute with the specified key. 72 * 73 * @param key Key of the system attribute. 74 * @param def Default value. 75 * @throws {BusinessError} 401 - if type of key is not string or key is not specified. 76 * @throws {BusinessError} 14700101 - if key is not found 77 * @throws {BusinessError} 14700103 - if permission denied 78 * @throws {BusinessError} 14700104 - if system internal error 79 * @returns Promise, which is used to obtain the result asynchronously. 80 * @syscap SystemCapability.Startup.SystemInfo 81 * @since 9 82 */ 83 function get(key: string, def?: string): Promise<string>; 84 85 /** 86 * Sets a value for the attribute with the specified key. 87 * 88 * @param key Key of the system attribute. 89 * @param value System attribute value to set. 90 * @throws {BusinessError} 401 - if type of key is not string or key is not specified. 91 * @throws {BusinessError} 14700102 - if value is invalid 92 * @throws {BusinessError} 14700103 - if permission denied 93 * @throws {BusinessError} 14700104 - if system internal error 94 * @syscap SystemCapability.Startup.SystemInfo 95 * @since 9 96 */ 97 function setSync(key: string, value: string): void; 98 99 /** 100 * Sets a value for the attribute with the specified key. 101 * 102 * @param key Key of the system attribute. 103 * @param value System attribute value to set. 104 * @param callback Callback function. 105 * @throws {BusinessError} 401 - if type of key is not string or key is not specified. 106 * @throws {BusinessError} 14700102 - if value is invalid 107 * @throws {BusinessError} 14700103 - if permission denied 108 * @throws {BusinessError} 14700104 - if system internal error 109 * @syscap SystemCapability.Startup.SystemInfo 110 * @since 9 111 */ 112 function set(key: string, value: string, callback: AsyncCallback<void>): void; 113 114 /** 115 * Sets a value for the attribute with the specified key. 116 * 117 * @param key Key of the system attribute. 118 * @param value Default value. 119 * @returns Promise, which is used to obtain the result asynchronously. 120 * @throws {BusinessError} 401 - if type of key is not string or key is not specified. 121 * @throws {BusinessError} 14700102 - if value is invalid 122 * @throws {BusinessError} 14700103 - if permission denied 123 * @throws {BusinessError} 14700104 - if system internal error 124 * @syscap SystemCapability.Startup.SystemInfo 125 * @since 9 126 */ 127 function set(key: string, value: string): Promise<void>; 128} 129 130export default systemParameterEnhance; 131