• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-2023 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 } from './@ohos.base';
22
23/**
24 * Provides file path related APIS.
25 *
26 * @namespace configPolicy
27 * @syscap SystemCapability.Customization.ConfigPolicy
28 * @systemapi
29 * @since 8
30 */
31declare namespace configPolicy {
32  /**
33   * Define followXMode.
34   *
35   * @enum { number }
36   * @syscap SystemCapability.Customization.ConfigPolicy
37   * @systemapi
38   * @since 11
39   */
40  export enum FollowXMode {
41    /**
42     * Default mode.
43     *
44     * @syscap SystemCapability.Customization.ConfigPolicy
45     * @systemapi
46     * @since 11
47     */
48    DEFAULT = 0,
49
50    /**
51     * No rules are followed, will not use any follow rule, even if the followx_file_list.cfg exists.
52     *
53     * @syscap SystemCapability.Customization.ConfigPolicy
54     * @systemapi
55     * @since 11
56     */
57    NO_RULE_FOLLOWED = 1,
58
59    /**
60     * Follow rule by default SIM card.
61     *
62     * @syscap SystemCapability.Customization.ConfigPolicy
63     * @systemapi
64     * @since 11
65     */
66    SIM_DEFAULT = 10,
67
68    /**
69     * Follow rule by slot 1 SIM card.
70     *
71     * @syscap SystemCapability.Customization.ConfigPolicy
72     * @systemapi
73     * @since 11
74     */
75    SIM_1 = 11,
76
77    /**
78     * Follow rule by slot 2 SIM card.
79     *
80     * @syscap SystemCapability.Customization.ConfigPolicy
81     * @systemapi
82     * @since 11
83     */
84    SIM_2 = 12,
85
86    /**
87     * Follow rule by user defined, get follow rule add path from @param extra.
88     * Follow rule in followx_file_list.cfg will be ignored.
89     *
90     * @syscap SystemCapability.Customization.ConfigPolicy
91     * @systemapi
92     * @since 11
93     */
94    USER_DEFINED = 100
95  }
96
97  /**
98   * Gets the file from the highest priority config path containing the given file name.
99   *
100   * @param { string } relPath - the relative path of the config file.
101   * @param { AsyncCallback<string> } callback - contains the path of the highest priority config file.
102   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified;
103   * <br>2.Incorrect parameter types.
104   * @syscap SystemCapability.Customization.ConfigPolicy
105   * @systemapi Hide this for inner system use.
106   * @since 8
107   */
108  function getOneCfgFile(relPath: string, callback: AsyncCallback<string>);
109
110  /**
111   * Gets the file from the highest priority config path containing the given file name in follow mode.
112   *
113   * @param { string } relPath - the relative path of the config file.
114   * @param { FollowXMode } followMode - the follow mode.
115   * @param { AsyncCallback<string> } callback - contains the path of the highest priority config file.
116   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified;
117   * <br>2.Incorrect parameter types.
118   * @syscap SystemCapability.Customization.ConfigPolicy
119   * @systemapi Hide this for inner system use.
120   * @since 11
121   */
122  function getOneCfgFile(relPath: string, followMode: FollowXMode, callback: AsyncCallback<string>);
123
124  /**
125   * Gets the file from the highest priority config path containing the given file name in follow mode.
126   *
127   * @param { string } relPath - the relative path of the config file.
128   * @param { FollowXMode } followMode - the follow mode.
129   * @param { string } extra - set follow rule add path, only valid when followMode is USER_DEFINED.
130   * @param { AsyncCallback<string> } callback - contains the path of the highest priority config file.
131   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified;
132   * <br>2.Incorrect parameter types.
133   * @syscap SystemCapability.Customization.ConfigPolicy
134   * @systemapi Hide this for inner system use.
135   * @since 11
136   */
137  function getOneCfgFile(relPath: string, followMode: FollowXMode, extra: string, callback: AsyncCallback<string>);
138
139  /**
140   * Gets the file from the highest priority config path containing the given file name.
141   *
142   * @param { string } relPath - the relative path of the config file.
143   * @returns { Promise<string> } the promise returns the path of the highest priority config file.
144   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified;
145   * <br>2.Incorrect parameter types.
146   * @syscap SystemCapability.Customization.ConfigPolicy
147   * @systemapi Hide this for inner system use.
148   * @since 8
149   */
150  function getOneCfgFile(relPath: string): Promise<string>;
151
152  /**
153   * Gets the file from the highest priority config path containing the given file name in follow mode.
154   *
155   * @param { string } relPath - the relative path of the config file.
156   * @param { FollowXMode } followMode - the follow mode.
157   * @param { string } extra - set follow rule add path, must be set when followMode is USER_DEFINED.
158   * @returns { Promise<string> } the promise returns the path of the highest priority config file.
159   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified;
160   * <br>2.Incorrect parameter types; 3.Parameter verification failed.
161   * @syscap SystemCapability.Customization.ConfigPolicy
162   * @systemapi Hide this for inner system use.
163   * @since 11
164   */
165  function getOneCfgFile(relPath: string, followMode: FollowXMode, extra?: string): Promise<string>;
166
167  /**
168   * Gets the file from the highest priority config path containing the given file name, can set follow mode or not.
169   *
170   * @param { string } relPath - the relative path of the config file.
171   * @param { FollowXMode } followMode - the follow mode.
172   * @param { string } extra - set follow rule add path, must be set when followMode is USER_DEFINED.
173   * @returns { string } the path of the highest priority config file.
174   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified;
175   * <br>2.Incorrect parameter types; 3.Parameter verification failed.
176   * @syscap SystemCapability.Customization.ConfigPolicy
177   * @systemapi Hide this for inner system use.
178   * @since 11
179   */
180  function getOneCfgFileSync(relPath: string, followMode?: FollowXMode, extra?: string): string;
181
182  /**
183   * Gets the config files in device architecture, ordered by priority from low to high.
184   *
185   * @param { string } relPath - the relative path of the config file.
186   * @param { AsyncCallback<Array<string>> } callback - contains paths of config files.
187   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified;
188   * <br>2.Incorrect parameter types.
189   * @syscap SystemCapability.Customization.ConfigPolicy
190   * @systemapi Hide this for inner system use.
191   * @since 8
192   */
193  function getCfgFiles(relPath: string, callback: AsyncCallback<Array<string>>);
194
195  /**
196   * Gets the config files in device architecture in follow mode, ordered by priority from low to high.
197   *
198   * @param { string } relPath - the relative path of the config file.
199   * @param { FollowXMode } followMode - the follow mode.
200   * @param { AsyncCallback<Array<string>> } callback - contains paths of config files.
201   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified;
202   * <br>2.Incorrect parameter types.
203   * @syscap SystemCapability.Customization.ConfigPolicy
204   * @systemapi Hide this for inner system use.
205   * @since 11
206   */
207  function getCfgFiles(relPath: string, followMode: FollowXMode, callback: AsyncCallback<Array<string>>);
208
209  /**
210   * Gets the config files in device architecture in follow mode, ordered by priority from low to high.
211   *
212   * @param { string } relPath - the relative path of the config file.
213   * @param { FollowXMode } followMode - the follow mode.
214   * @param { string } extra - set follow rule add path, only valid when followMode is USER_DEFINED.
215   * @param { AsyncCallback<Array<string>> } callback - contains paths of config files.
216   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified;
217   * <br>2.Incorrect parameter types.
218   * @syscap SystemCapability.Customization.ConfigPolicy
219   * @systemapi Hide this for inner system use.
220   * @since 11
221   */
222  function getCfgFiles(relPath: string, followMode: FollowXMode, extra: string, callback: AsyncCallback<Array<string>>);
223
224  /**
225   * Gets the config files in device architecture, ordered by priority from low to high.
226   *
227   * @param { string } relPath - the relative path of the config file.
228   * @returns { Promise<Array<string>> } the promise returns paths of config files.
229   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified;
230   * <br>2.Incorrect parameter types.
231   * @syscap SystemCapability.Customization.ConfigPolicy
232   * @systemapi Hide this for inner system use.
233   * @since 8
234   */
235  function getCfgFiles(relPath: string): Promise<Array<string>>;
236
237  /**
238   * Gets the config files in device architecture in follow mode, ordered by priority from low to high, can set follow mode or not.
239   *
240   * @param { string } relPath - the relative path of the config file.
241   * @param { FollowXMode } followMode - the follow mode.
242   * @param { string } extra - set follow rule add path, must be set when followMode is USER_DEFINED.
243   * @returns { Promise<Array<string>> } the promise returns paths of config files.
244   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified;
245   * <br>2.Incorrect parameter types; 3.Parameter verification failed.
246   * @syscap SystemCapability.Customization.ConfigPolicy
247   * @systemapi Hide this for inner system use.
248   * @since 11
249   */
250  function getCfgFiles(relPath: string, followMode: FollowXMode, extra?: string): Promise<Array<string>>;
251
252  /**
253   * Gets the config files in device architecture, ordered by priority from low to high.
254   *
255   * @param { string } relPath - the relative path of the config file.
256   * @param { FollowXMode } followMode - the follow mode.
257   * @param { string } extra - set follow rule add path, must be set when followMode is USER_DEFINED.
258   * @returns { Array<string> } the paths of config files.
259   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified;
260   * <br>2.Incorrect parameter types; 3.Parameter verification failed.
261   * @syscap SystemCapability.Customization.ConfigPolicy
262   * @systemapi Hide this for inner system use.
263   * @since 11
264   */
265  function getCfgFilesSync(relPath: string, followMode?: FollowXMode, extra?: string): Array<string>;
266
267  /**
268   * Gets the config directory in the device architecture, ordered by priority from low to high.
269   *
270   * @param { AsyncCallback<Array<string>> } callback - contains paths of config directories.
271   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified;
272   * <br>2.Incorrect parameter types.
273   * @syscap SystemCapability.Customization.ConfigPolicy
274   * @systemapi Hide this for inner system use.
275   * @since 8
276   */
277  function getCfgDirList(callback: AsyncCallback<Array<string>>);
278
279  /**
280   * Gets the config directory in the device architecture, ordered by priority from low to high.
281   *
282   * @returns { Promise<Array<string>> } the promise returns paths of config directories.
283   * @throws { BusinessError } 401 - invalid input parameter.
284   * @syscap SystemCapability.Customization.ConfigPolicy
285   * @systemapi Hide this for inner system use.
286   * @since 8
287   */
288  /**
289   * Gets the list of configuration level directories, sorted in ascending order of priority.
290   *
291   * @returns { Promise<Array<string>> } the promise returns the list of configuration level directories.
292   * @syscap SystemCapability.Customization.ConfigPolicy
293   * @systemapi Hide this for inner system use.
294   * @since 12
295   */
296  function getCfgDirList(): Promise<Array<string>>;
297
298  /**
299   * Gets the config directory in the device architecture, ordered by priority from low to high.
300   *
301   * @returns { Array<string> } the paths of config directories.
302   * @throws { BusinessError } 401 - invalid input parameter.
303   * @syscap SystemCapability.Customization.ConfigPolicy
304   * @systemapi Hide this for inner system use.
305   * @since 11
306   */
307  /**
308   * Gets the list of configuration level directories, sorted in ascending order of priority.
309   *
310   * @returns { Array<string> } the list of configuration level directories.
311   * @syscap SystemCapability.Customization.ConfigPolicy
312   * @systemapi Hide this for inner system use.
313   * @since 12
314   */
315  function getCfgDirListSync(): Array<string>;
316}
317
318export default configPolicy;
319