• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 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 6
22 * @syscap SystemCapability.Startup.SystemInfo
23 * @systemapi Hide this for inner system use.
24 */
25declare namespace systemParameter {
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 if the parameter is empty or doesn't exist, empty string will be returned.
32     * @syscap SystemCapability.Startup.SystemInfo
33     * @since 6
34     */
35    function getSync(key: string, def?: string): string;
36
37    /**
38     * Gets the value of the attribute with the specified key.
39     *
40     * @param key Key of the system attribute.
41     * @param callback Callback function.
42     * @syscap SystemCapability.Startup.SystemInfo
43     * @since 6
44     */
45    function get(key: string, callback: AsyncCallback<string>): void;
46
47    /**
48     * Gets the value of the attribute with the specified key.
49     *
50     * @param key Key of the system attribute.
51     * @param def Default value.
52     * @param callback Callback function.
53     * @syscap SystemCapability.Startup.SystemInfo
54     * @since 6
55     */
56    function get(key: string, def: string, callback: AsyncCallback<string>): void;
57
58    /**
59     * Gets the value of the attribute with the specified key.
60     *
61     * @param key Key of the system attribute.
62     * @param def Default value.
63     * @returns Promise, which is used to obtain the result asynchronously.
64     * @syscap SystemCapability.Startup.SystemInfo
65     * @since 6
66     */
67    function get(key: string, def?: string): Promise<string>;
68
69    /**
70     * Sets a value for the attribute with the specified key.
71     *
72     * @param key Key of the system attribute.
73     * @param value System attribute value to set.
74     * @syscap SystemCapability.Startup.SystemInfo
75     * @since 6
76     */
77    function setSync(key: string, value: string): void;
78
79    /**
80     * Sets a value for the attribute with the specified key.
81     *
82     * @param key Key of the system attribute.
83     * @param value System attribute value to set.
84     * @param callback Callback function.
85     * @syscap SystemCapability.Startup.SystemInfo
86     * @since 6
87     */
88    function set(key: string, value: string, callback: AsyncCallback<void>): void;
89
90    /**
91     * Sets a value for the attribute with the specified key.
92     *
93     * @param key Key of the system attribute.
94     * @param value Default value.
95     * @returns Promise, which is used to obtain the result asynchronously.
96     * @syscap SystemCapability.Startup.SystemInfo
97     * @since 6
98     */
99    function set(key: string, value: string): Promise<void>;
100}
101
102export default systemParameter;
103