161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (c) 2022-2023 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci/** 1761847f8eSopenharmony_ci * @file 1861847f8eSopenharmony_ci * @kit BasicServicesKit 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci 2161847f8eSopenharmony_ciimport { AsyncCallback } from './@ohos.base'; 2261847f8eSopenharmony_ci 2361847f8eSopenharmony_ci/** 2461847f8eSopenharmony_ci * Provides file path related APIS. 2561847f8eSopenharmony_ci * 2661847f8eSopenharmony_ci * @namespace configPolicy 2761847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 2861847f8eSopenharmony_ci * @systemapi 2961847f8eSopenharmony_ci * @since 8 3061847f8eSopenharmony_ci */ 3161847f8eSopenharmony_cideclare namespace configPolicy { 3261847f8eSopenharmony_ci /** 3361847f8eSopenharmony_ci * Define followXMode. 3461847f8eSopenharmony_ci * 3561847f8eSopenharmony_ci * @enum { number } 3661847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 3761847f8eSopenharmony_ci * @systemapi 3861847f8eSopenharmony_ci * @since 11 3961847f8eSopenharmony_ci */ 4061847f8eSopenharmony_ci export enum FollowXMode { 4161847f8eSopenharmony_ci /** 4261847f8eSopenharmony_ci * Default mode. 4361847f8eSopenharmony_ci * 4461847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 4561847f8eSopenharmony_ci * @systemapi 4661847f8eSopenharmony_ci * @since 11 4761847f8eSopenharmony_ci */ 4861847f8eSopenharmony_ci DEFAULT = 0, 4961847f8eSopenharmony_ci 5061847f8eSopenharmony_ci /** 5161847f8eSopenharmony_ci * No rules are followed, will not use any follow rule, even if the followx_file_list.cfg exists. 5261847f8eSopenharmony_ci * 5361847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 5461847f8eSopenharmony_ci * @systemapi 5561847f8eSopenharmony_ci * @since 11 5661847f8eSopenharmony_ci */ 5761847f8eSopenharmony_ci NO_RULE_FOLLOWED = 1, 5861847f8eSopenharmony_ci 5961847f8eSopenharmony_ci /** 6061847f8eSopenharmony_ci * Follow rule by default SIM card. 6161847f8eSopenharmony_ci * 6261847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 6361847f8eSopenharmony_ci * @systemapi 6461847f8eSopenharmony_ci * @since 11 6561847f8eSopenharmony_ci */ 6661847f8eSopenharmony_ci SIM_DEFAULT = 10, 6761847f8eSopenharmony_ci 6861847f8eSopenharmony_ci /** 6961847f8eSopenharmony_ci * Follow rule by slot 1 SIM card. 7061847f8eSopenharmony_ci * 7161847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 7261847f8eSopenharmony_ci * @systemapi 7361847f8eSopenharmony_ci * @since 11 7461847f8eSopenharmony_ci */ 7561847f8eSopenharmony_ci SIM_1 = 11, 7661847f8eSopenharmony_ci 7761847f8eSopenharmony_ci /** 7861847f8eSopenharmony_ci * Follow rule by slot 2 SIM card. 7961847f8eSopenharmony_ci * 8061847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 8161847f8eSopenharmony_ci * @systemapi 8261847f8eSopenharmony_ci * @since 11 8361847f8eSopenharmony_ci */ 8461847f8eSopenharmony_ci SIM_2 = 12, 8561847f8eSopenharmony_ci 8661847f8eSopenharmony_ci /** 8761847f8eSopenharmony_ci * Follow rule by user defined, get follow rule add path from @param extra. 8861847f8eSopenharmony_ci * Follow rule in followx_file_list.cfg will be ignored. 8961847f8eSopenharmony_ci * 9061847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 9161847f8eSopenharmony_ci * @systemapi 9261847f8eSopenharmony_ci * @since 11 9361847f8eSopenharmony_ci */ 9461847f8eSopenharmony_ci USER_DEFINED = 100 9561847f8eSopenharmony_ci } 9661847f8eSopenharmony_ci 9761847f8eSopenharmony_ci /** 9861847f8eSopenharmony_ci * Gets the file from the highest priority config path containing the given file name. 9961847f8eSopenharmony_ci * 10061847f8eSopenharmony_ci * @param { string } relPath - the relative path of the config file. 10161847f8eSopenharmony_ci * @param { AsyncCallback<string> } callback - contains the path of the highest priority config file. 10261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 10361847f8eSopenharmony_ci * <br>2.Incorrect parameter types. 10461847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 10561847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 10661847f8eSopenharmony_ci * @since 8 10761847f8eSopenharmony_ci */ 10861847f8eSopenharmony_ci function getOneCfgFile(relPath: string, callback: AsyncCallback<string>); 10961847f8eSopenharmony_ci 11061847f8eSopenharmony_ci /** 11161847f8eSopenharmony_ci * Gets the file from the highest priority config path containing the given file name in follow mode. 11261847f8eSopenharmony_ci * 11361847f8eSopenharmony_ci * @param { string } relPath - the relative path of the config file. 11461847f8eSopenharmony_ci * @param { FollowXMode } followMode - the follow mode. 11561847f8eSopenharmony_ci * @param { AsyncCallback<string> } callback - contains the path of the highest priority config file. 11661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 11761847f8eSopenharmony_ci * <br>2.Incorrect parameter types. 11861847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 11961847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 12061847f8eSopenharmony_ci * @since 11 12161847f8eSopenharmony_ci */ 12261847f8eSopenharmony_ci function getOneCfgFile(relPath: string, followMode: FollowXMode, callback: AsyncCallback<string>); 12361847f8eSopenharmony_ci 12461847f8eSopenharmony_ci /** 12561847f8eSopenharmony_ci * Gets the file from the highest priority config path containing the given file name in follow mode. 12661847f8eSopenharmony_ci * 12761847f8eSopenharmony_ci * @param { string } relPath - the relative path of the config file. 12861847f8eSopenharmony_ci * @param { FollowXMode } followMode - the follow mode. 12961847f8eSopenharmony_ci * @param { string } extra - set follow rule add path, only valid when followMode is USER_DEFINED. 13061847f8eSopenharmony_ci * @param { AsyncCallback<string> } callback - contains the path of the highest priority config file. 13161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 13261847f8eSopenharmony_ci * <br>2.Incorrect parameter types. 13361847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 13461847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 13561847f8eSopenharmony_ci * @since 11 13661847f8eSopenharmony_ci */ 13761847f8eSopenharmony_ci function getOneCfgFile(relPath: string, followMode: FollowXMode, extra: string, callback: AsyncCallback<string>); 13861847f8eSopenharmony_ci 13961847f8eSopenharmony_ci /** 14061847f8eSopenharmony_ci * Gets the file from the highest priority config path containing the given file name. 14161847f8eSopenharmony_ci * 14261847f8eSopenharmony_ci * @param { string } relPath - the relative path of the config file. 14361847f8eSopenharmony_ci * @returns { Promise<string> } the promise returns the path of the highest priority config file. 14461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 14561847f8eSopenharmony_ci * <br>2.Incorrect parameter types. 14661847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 14761847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 14861847f8eSopenharmony_ci * @since 8 14961847f8eSopenharmony_ci */ 15061847f8eSopenharmony_ci function getOneCfgFile(relPath: string): Promise<string>; 15161847f8eSopenharmony_ci 15261847f8eSopenharmony_ci /** 15361847f8eSopenharmony_ci * Gets the file from the highest priority config path containing the given file name in follow mode. 15461847f8eSopenharmony_ci * 15561847f8eSopenharmony_ci * @param { string } relPath - the relative path of the config file. 15661847f8eSopenharmony_ci * @param { FollowXMode } followMode - the follow mode. 15761847f8eSopenharmony_ci * @param { string } extra - set follow rule add path, must be set when followMode is USER_DEFINED. 15861847f8eSopenharmony_ci * @returns { Promise<string> } the promise returns the path of the highest priority config file. 15961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 16061847f8eSopenharmony_ci * <br>2.Incorrect parameter types; 3.Parameter verification failed. 16161847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 16261847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 16361847f8eSopenharmony_ci * @since 11 16461847f8eSopenharmony_ci */ 16561847f8eSopenharmony_ci function getOneCfgFile(relPath: string, followMode: FollowXMode, extra?: string): Promise<string>; 16661847f8eSopenharmony_ci 16761847f8eSopenharmony_ci /** 16861847f8eSopenharmony_ci * Gets the file from the highest priority config path containing the given file name, can set follow mode or not. 16961847f8eSopenharmony_ci * 17061847f8eSopenharmony_ci * @param { string } relPath - the relative path of the config file. 17161847f8eSopenharmony_ci * @param { FollowXMode } followMode - the follow mode. 17261847f8eSopenharmony_ci * @param { string } extra - set follow rule add path, must be set when followMode is USER_DEFINED. 17361847f8eSopenharmony_ci * @returns { string } the path of the highest priority config file. 17461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 17561847f8eSopenharmony_ci * <br>2.Incorrect parameter types; 3.Parameter verification failed. 17661847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 17761847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 17861847f8eSopenharmony_ci * @since 11 17961847f8eSopenharmony_ci */ 18061847f8eSopenharmony_ci function getOneCfgFileSync(relPath: string, followMode?: FollowXMode, extra?: string): string; 18161847f8eSopenharmony_ci 18261847f8eSopenharmony_ci /** 18361847f8eSopenharmony_ci * Gets the config files in device architecture, ordered by priority from low to high. 18461847f8eSopenharmony_ci * 18561847f8eSopenharmony_ci * @param { string } relPath - the relative path of the config file. 18661847f8eSopenharmony_ci * @param { AsyncCallback<Array<string>> } callback - contains paths of config files. 18761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 18861847f8eSopenharmony_ci * <br>2.Incorrect parameter types. 18961847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 19061847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 19161847f8eSopenharmony_ci * @since 8 19261847f8eSopenharmony_ci */ 19361847f8eSopenharmony_ci function getCfgFiles(relPath: string, callback: AsyncCallback<Array<string>>); 19461847f8eSopenharmony_ci 19561847f8eSopenharmony_ci /** 19661847f8eSopenharmony_ci * Gets the config files in device architecture in follow mode, ordered by priority from low to high. 19761847f8eSopenharmony_ci * 19861847f8eSopenharmony_ci * @param { string } relPath - the relative path of the config file. 19961847f8eSopenharmony_ci * @param { FollowXMode } followMode - the follow mode. 20061847f8eSopenharmony_ci * @param { AsyncCallback<Array<string>> } callback - contains paths of config files. 20161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 20261847f8eSopenharmony_ci * <br>2.Incorrect parameter types. 20361847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 20461847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 20561847f8eSopenharmony_ci * @since 11 20661847f8eSopenharmony_ci */ 20761847f8eSopenharmony_ci function getCfgFiles(relPath: string, followMode: FollowXMode, callback: AsyncCallback<Array<string>>); 20861847f8eSopenharmony_ci 20961847f8eSopenharmony_ci /** 21061847f8eSopenharmony_ci * Gets the config files in device architecture in follow mode, ordered by priority from low to high. 21161847f8eSopenharmony_ci * 21261847f8eSopenharmony_ci * @param { string } relPath - the relative path of the config file. 21361847f8eSopenharmony_ci * @param { FollowXMode } followMode - the follow mode. 21461847f8eSopenharmony_ci * @param { string } extra - set follow rule add path, only valid when followMode is USER_DEFINED. 21561847f8eSopenharmony_ci * @param { AsyncCallback<Array<string>> } callback - contains paths of config files. 21661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 21761847f8eSopenharmony_ci * <br>2.Incorrect parameter types. 21861847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 21961847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 22061847f8eSopenharmony_ci * @since 11 22161847f8eSopenharmony_ci */ 22261847f8eSopenharmony_ci function getCfgFiles(relPath: string, followMode: FollowXMode, extra: string, callback: AsyncCallback<Array<string>>); 22361847f8eSopenharmony_ci 22461847f8eSopenharmony_ci /** 22561847f8eSopenharmony_ci * Gets the config files in device architecture, ordered by priority from low to high. 22661847f8eSopenharmony_ci * 22761847f8eSopenharmony_ci * @param { string } relPath - the relative path of the config file. 22861847f8eSopenharmony_ci * @returns { Promise<Array<string>> } the promise returns paths of config files. 22961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 23061847f8eSopenharmony_ci * <br>2.Incorrect parameter types. 23161847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 23261847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 23361847f8eSopenharmony_ci * @since 8 23461847f8eSopenharmony_ci */ 23561847f8eSopenharmony_ci function getCfgFiles(relPath: string): Promise<Array<string>>; 23661847f8eSopenharmony_ci 23761847f8eSopenharmony_ci /** 23861847f8eSopenharmony_ci * Gets the config files in device architecture in follow mode, ordered by priority from low to high, can set follow mode or not. 23961847f8eSopenharmony_ci * 24061847f8eSopenharmony_ci * @param { string } relPath - the relative path of the config file. 24161847f8eSopenharmony_ci * @param { FollowXMode } followMode - the follow mode. 24261847f8eSopenharmony_ci * @param { string } extra - set follow rule add path, must be set when followMode is USER_DEFINED. 24361847f8eSopenharmony_ci * @returns { Promise<Array<string>> } the promise returns paths of config files. 24461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 24561847f8eSopenharmony_ci * <br>2.Incorrect parameter types; 3.Parameter verification failed. 24661847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 24761847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 24861847f8eSopenharmony_ci * @since 11 24961847f8eSopenharmony_ci */ 25061847f8eSopenharmony_ci function getCfgFiles(relPath: string, followMode: FollowXMode, extra?: string): Promise<Array<string>>; 25161847f8eSopenharmony_ci 25261847f8eSopenharmony_ci /** 25361847f8eSopenharmony_ci * Gets the config files in device architecture, ordered by priority from low to high. 25461847f8eSopenharmony_ci * 25561847f8eSopenharmony_ci * @param { string } relPath - the relative path of the config file. 25661847f8eSopenharmony_ci * @param { FollowXMode } followMode - the follow mode. 25761847f8eSopenharmony_ci * @param { string } extra - set follow rule add path, must be set when followMode is USER_DEFINED. 25861847f8eSopenharmony_ci * @returns { Array<string> } the paths of config files. 25961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 26061847f8eSopenharmony_ci * <br>2.Incorrect parameter types; 3.Parameter verification failed. 26161847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 26261847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 26361847f8eSopenharmony_ci * @since 11 26461847f8eSopenharmony_ci */ 26561847f8eSopenharmony_ci function getCfgFilesSync(relPath: string, followMode?: FollowXMode, extra?: string): Array<string>; 26661847f8eSopenharmony_ci 26761847f8eSopenharmony_ci /** 26861847f8eSopenharmony_ci * Gets the config directory in the device architecture, ordered by priority from low to high. 26961847f8eSopenharmony_ci * 27061847f8eSopenharmony_ci * @param { AsyncCallback<Array<string>> } callback - contains paths of config directories. 27161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 27261847f8eSopenharmony_ci * <br>2.Incorrect parameter types. 27361847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 27461847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 27561847f8eSopenharmony_ci * @since 8 27661847f8eSopenharmony_ci */ 27761847f8eSopenharmony_ci function getCfgDirList(callback: AsyncCallback<Array<string>>); 27861847f8eSopenharmony_ci 27961847f8eSopenharmony_ci /** 28061847f8eSopenharmony_ci * Gets the config directory in the device architecture, ordered by priority from low to high. 28161847f8eSopenharmony_ci * 28261847f8eSopenharmony_ci * @returns { Promise<Array<string>> } the promise returns paths of config directories. 28361847f8eSopenharmony_ci * @throws { BusinessError } 401 - invalid input parameter. 28461847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 28561847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 28661847f8eSopenharmony_ci * @since 8 28761847f8eSopenharmony_ci */ 28861847f8eSopenharmony_ci /** 28961847f8eSopenharmony_ci * Gets the list of configuration level directories, sorted in ascending order of priority. 29061847f8eSopenharmony_ci * 29161847f8eSopenharmony_ci * @returns { Promise<Array<string>> } the promise returns the list of configuration level directories. 29261847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 29361847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 29461847f8eSopenharmony_ci * @since 12 29561847f8eSopenharmony_ci */ 29661847f8eSopenharmony_ci function getCfgDirList(): Promise<Array<string>>; 29761847f8eSopenharmony_ci 29861847f8eSopenharmony_ci /** 29961847f8eSopenharmony_ci * Gets the config directory in the device architecture, ordered by priority from low to high. 30061847f8eSopenharmony_ci * 30161847f8eSopenharmony_ci * @returns { Array<string> } the paths of config directories. 30261847f8eSopenharmony_ci * @throws { BusinessError } 401 - invalid input parameter. 30361847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 30461847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 30561847f8eSopenharmony_ci * @since 11 30661847f8eSopenharmony_ci */ 30761847f8eSopenharmony_ci /** 30861847f8eSopenharmony_ci * Gets the list of configuration level directories, sorted in ascending order of priority. 30961847f8eSopenharmony_ci * 31061847f8eSopenharmony_ci * @returns { Array<string> } the list of configuration level directories. 31161847f8eSopenharmony_ci * @syscap SystemCapability.Customization.ConfigPolicy 31261847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 31361847f8eSopenharmony_ci * @since 12 31461847f8eSopenharmony_ci */ 31561847f8eSopenharmony_ci function getCfgDirListSync(): Array<string>; 31661847f8eSopenharmony_ci} 31761847f8eSopenharmony_ci 31861847f8eSopenharmony_ciexport default configPolicy; 319