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