1# @ohos.configPolicy (Configuration Policy) (System API) 2 3<!--Kit: Basic Services Kit--> 4<!--Subsystem: Customization--> 5<!--Owner: @liule_123--> 6<!--Designer: @sunshine_1984--> 7<!--Tester: @lpw_work--> 8<!--Adviser: @Brilliantry_Rui--> 9 10The **configPolicy** module provides APIs for obtaining the custom configuration directory and file path based on the predefined configuration level. 11 12> **NOTE** 13> 14> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. 15> 16> The APIs provided by this module are system APIs. 17 18## Modules to Import 19 20```ts 21import configPolicy from '@ohos.configPolicy'; 22``` 23 24## getOneCfgFile 25 26getOneCfgFile(relPath: string, callback: AsyncCallback<string>) 27 28Obtains the path of the configuration file with the highest priority based on the specified file name. This API uses an asynchronous callback to return the result. 29If there are two **config.xml** files, **/system/etc/config.xml** and **/sys_pod/etc/config.xml**, in ascending order of priority, **/sys_pod/etc/config.xml** is returned. 30 31**System capability**: SystemCapability.Customization.ConfigPolicy 32 33**Parameters** 34 35| Name | Type | Mandatory| Description | 36| -------- | --------------------------- | ---- | ------------------------------------------ | 37| relPath | string | Yes | Name of the configuration file. | 38| callback | AsyncCallback<string> | Yes | Callback used to return the path of the configuration file.| 39 40**Error codes** 41 42For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 43 44| ID| Error Message | 45| ------- | ---------------------------------------------------------------------------- | 46| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.| 47 48**Example** 49 50 ```ts 51 import { BusinessError } from '@ohos.base'; 52 import configPolicy from '@ohos.configPolicy'; 53 54 let relpath: string = 'etc/config.xml'; 55 configPolicy.getOneCfgFile(relpath, (error: BusinessError, value: string) => { 56 if (error == null) { 57 console.log('value is ' + value); 58 } else { 59 console.error('error: ' + error.code + ', ' + error.message); 60 } 61 }); 62 ``` 63 64## getOneCfgFile 65 66getOneCfgFile(relPath: string): Promise<string> 67 68Obtains the path of the configuration file with the highest priority based on the specified file name. This API uses a promise to return the result. 69 70**System capability**: SystemCapability.Customization.ConfigPolicy 71 72**Parameters** 73 74| Name | Type | Mandatory| Description | 75| ------- | ------ | ---- | ---------- | 76| relPath | string | Yes | Name of the configuration file.| 77 78**Error codes** 79 80For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 81 82| ID| Error Message | 83| ------- | ---------------------------------------------------------------------------- | 84| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.| 85 86**Return value** 87 88| Type | Description | 89| ---------------------- | ------------------------ | 90| Promise<string> | Promise used to return the result.| 91 92**Example** 93 94 ```ts 95 import { BusinessError } from '@ohos.base'; 96 import configPolicy from '@ohos.configPolicy'; 97 98 async function fetchConfigFile() { 99 try { 100 let relpath: string = 'etc/config.xml'; 101 let value: string = await configPolicy.getOneCfgFile(relpath); 102 console.log('value is ' + value); 103 } catch (error) { 104 let code = (error as BusinessError).code; 105 let message = (error as BusinessError).message; 106 console.error('error:' + code + ', ' + message); 107 } 108 } 109 110 fetchConfigFile() 111 ``` 112 113## getCfgFiles 114 115getCfgFiles(relPath: string, callback: AsyncCallback<Array<string>>) 116 117Obtains a list of configuration files with the specified name, sorted in ascending order of priority. This API uses an asynchronous callback to return the result. 118If there are two **config.xml** files, **/system/etc/config.xml** and **/sys_pod/etc/config.xml**, in ascending order of priority, **/system/etc/config.xml, /sys_pod/etc/config.xml** is returned. 119 120**System capability**: SystemCapability.Customization.ConfigPolicy 121 122**Parameters** 123 124| Name | Type | Mandatory| Description | 125| -------- | ---------------------------------------- | ---- | -------------------------- | 126| relPath | string | Yes | Name of the configuration file. | 127| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the file lists.| 128 129**Error codes** 130 131For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 132 133| ID| Error Message | 134| ------- | ---------------------------------------------------------------------------- | 135| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.| 136 137**Example** 138 139 ```ts 140 import { BusinessError } from '@ohos.base'; 141 import configPolicy from '@ohos.configPolicy'; 142 143 configPolicy.getCfgFiles('etc/config.xml', (error: BusinessError, value: Array<string>) => { 144 if (error == null) { 145 console.log('value is ' + value); 146 } else { 147 console.error('error: ' + error.code + ', ' + error.message); 148 } 149 }); 150 ``` 151 152## getCfgFiles 153 154getCfgFiles(relPath: string): Promise<Array<string>> 155 156Obtains a list of configuration files with the specified name, sorted in ascending order of priority. This API uses a promise to return the result. 157 158**System capability**: SystemCapability.Customization.ConfigPolicy 159 160**Parameters** 161 162| Name | Type | Mandatory| Description | 163| ------- | ------ | ---- | ---------- | 164| relPath | string | Yes | Name of the configuration file.| 165 166**Error codes** 167 168For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 169 170| ID| Error Message | 171| ------- | ---------------------------------------------------------------------------- | 172| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.| 173 174**Return value** 175 176| Type | Description | 177| ---------------------------------- | -------- | 178| Promise<Array<string>> | Promise used to return the result.| 179 180**Example** 181 182 ```ts 183 import { BusinessError } from '@ohos.base'; 184 import configPolicy from '@ohos.configPolicy'; 185 186 async function fetchCfgFiles() { 187 try { 188 let relpath: string = 'etc/config.xml'; 189 let value: Array<string> = await configPolicy.getCfgFiles(relpath); 190 console.log('value is ' + value); 191 } catch (error) { 192 let code = (error as BusinessError).code; 193 let message = (error as BusinessError).message; 194 console.error('error:' + code + ', ' + message); 195 } 196 } 197 198 fetchCfgFiles(); 199 ``` 200 201## getCfgDirList 202 203getCfgDirList(callback: AsyncCallback<Array<string>>) 204 205Obtains the list of configuration level directories. This API uses an asynchronous callback to return the result. 206 207**System capability**: SystemCapability.Customization.ConfigPolicy 208 209**Parameters** 210 211| Name | Type | Mandatory| Description | 212| -------- | ---------------------------------------- | ---- | ---------------------------------- | 213| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the configuration level directory list.| 214 215**Error codes** 216 217For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 218 219| ID| Error Message | 220| ------- | ---------------------------------------------------------------------------- | 221| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.| 222 223**Example** 224 225 ```ts 226 import { BusinessError } from '@ohos.base'; 227 import configPolicy from '@ohos.configPolicy'; 228 229 configPolicy.getCfgDirList((error: BusinessError, value: Array<string>) => { 230 if (error == null) { 231 console.log('value is ' + value); 232 } else { 233 console.error('error: ' + error.code + ', ' + error.message); 234 } 235 }); 236 ``` 237 238## getCfgDirList 239 240getCfgDirList(): Promise<Array<string>> 241 242Obtains the list of configuration level directories. This API uses a promise to return the result. 243 244**System capability**: SystemCapability.Customization.ConfigPolicy 245 246**Return value** 247 248| Type | Description | 249| ---------------------------------- | ---------------- | 250| Promise<Array<string>> | Obtains the list of configuration level directories. This API returns the result synchronously.| 251 252**Example** 253 254 ```ts 255 import { BusinessError } from '@ohos.base'; 256 import configPolicy from '@ohos.configPolicy'; 257 258 async function fetchCfgDirList() { 259 try { 260 let value: Array<string> = await configPolicy.getCfgDirList(); 261 console.log('value is ' + value); 262 } catch (error) { 263 let code = (error as BusinessError).code; 264 let message = (error as BusinessError).message; 265 console.error('error:' + code + ', ' + message); 266 } 267 } 268 269 fetchCfgDirList(); 270 ``` 271 272## getOneCfgFile<sup>11+</sup> 273 274getOneCfgFile(relPath: string, followMode: FollowXMode, callback: AsyncCallback<string>) 275 276Obtains the path of the configuration file with the highest priority based on the specified file name and follow mode. This API uses an asynchronous callback to return the result. 277For example, there are three **config.xml** files (in ascending order of priority): **/system/etc/config.xml**, **/sys_pod/etc/config.xml**, and **/sys_pod/etc/carrier/46060/etc/config.xml**. If the opkey of the default card is **46060** and the follow mode is **SIM_DEFAULT**, **/sys_pod/etc/carrier/46060/etc/config.xml** is returned. 278 279**System capability**: SystemCapability.Customization.ConfigPolicy 280 281**Parameters** 282 283| Name | Type | Mandatory| Description | 284| ---------- | ----------------------------- | ---- | ------------------------------------------ | 285| relPath | string | Yes | Name of the configuration file. | 286| followMode | [FollowXMode](#followxmode11) | Yes | Follow mode. | 287| callback | AsyncCallback<string> | Yes | Callback used to return the path of the configuration file.| 288 289**Error codes** 290 291For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 292 293| ID| Error Message | 294| ------- | ---------------------------------------------------------------------------- | 295| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.| 296 297**Example** 298 299 ```ts 300 import { BusinessError } from '@ohos.base'; 301 import configPolicy from '@ohos.configPolicy'; 302 303 let relpath: string = 'etc/config.xml'; 304 configPolicy.getOneCfgFile(relpath, configPolicy.FollowXMode.SIM_DEFAULT, 305 (error: BusinessError, value: string) => { 306 if (error == null) { 307 console.log('value is ' + value); 308 } else { 309 console.error('error: ' + error.code + ', ' + error.message); 310 } 311 }); 312 313 ``` 314 315## getOneCfgFile<sup>11+</sup> 316 317getOneCfgFile(relPath: string, followMode: FollowXMode, extra: string, callback: AsyncCallback<string>) 318 319Obtains the path of the configuration file with the highest priority based on the specified file name and follow mode. This API uses an asynchronous callback to return the result. 320For example, there are three **config.xml** files (in ascending order of priority): **/system/etc/config.xml**, **/sys_pod/etc/config.xml**, and **/sys_pod/etc/carrier/46060/etc/config.xml**. If the opkey of card 1 is **46060**, the follow mode is **USER_DEFINED**, and the custom follow rule is **etc/carrier/${telephony.sim.opkey0}**, **/sys_pod/etc/carrier/46060/etc/config.xml** is returned. 321 322**System capability**: SystemCapability.Customization.ConfigPolicy 323 324**Parameters** 325 326| Name | Type | Mandatory| Description | 327| ---------- | ----------------------------- | ---- | ------------------------------------------------------ | 328| relPath | string | Yes | Name of the configuration file. | 329| followMode | [FollowXMode](#followxmode11) | Yes | Follow mode. | 330| extra | string | Yes | Custom follow rule. This parameter is valid only when **followMode** is set to **USER_DEFINED**.| 331| callback | AsyncCallback<string> | Yes | Callback used to return the path of the configuration file. | 332 333**Error codes** 334 335For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 336 337| ID| Error Message | 338| ------- | ---------------------------------------------------------------------------- | 339| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.| 340 341**Example** 342 343 ```ts 344 import { BusinessError } from '@ohos.base'; 345 import configPolicy from '@ohos.configPolicy'; 346 347 let relpath: string = 'etc/config.xml'; 348 let extra: string = 'etc/carrier/${telephony.sim.opkey0}'; 349 configPolicy.getOneCfgFile(relpath, configPolicy.FollowXMode.USER_DEFINED, extra, 350 (error: BusinessError, value: string) => { 351 if (error == null) { 352 console.log('value is ' + value); 353 } else { 354 console.error('error: ' + error.code + ', ' + error.message); 355 } 356 }); 357 ``` 358 359## getOneCfgFile<sup>11+</sup> 360 361getOneCfgFile(relPath: string, followMode: FollowXMode, extra?: string): Promise<string> 362 363Obtains the path of the configuration file with the highest priority based on the specified file name and follow mode. This API uses a promise to return the result. 364 365**System capability**: SystemCapability.Customization.ConfigPolicy 366 367**Parameters** 368 369| Name | Type | Mandatory| Description | 370| ---------- | ----------------------------- | ---- | ------------------------------------------------------ | 371| relPath | string | Yes | Name of the configuration file. | 372| followMode | [FollowXMode](#followxmode11) | Yes | Follow mode. | 373| extra | string | No | Custom follow rule. This parameter is valid only when **followMode** is set to **USER_DEFINED**.| 374 375**Error codes** 376 377For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 378 379| ID| Error Message | 380| ------- | ---------------------------------------------------------------------------- | 381| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.| 382 383**Return value** 384 385| Type | Description | 386| ---------------------- | ------------------------ | 387| Promise<string> | Promise used to return the result.| 388 389**Example** 390 391 ```ts 392 import { BusinessError } from '@ohos.base'; 393 import configPolicy from '@ohos.configPolicy'; 394 395 async function fetchOneCfgFile() { 396 try { 397 let relpath: string = 'etc/config.xml'; 398 let extra: string = 'etc/carrier/${telephony.sim.opkey0}'; 399 let value: string = await configPolicy.getOneCfgFile(relpath, configPolicy.FollowXMode.SIM_DEFAULT, extra); 400 console.log('value is ' + value); 401 } catch (error) { 402 let code = (error as BusinessError).code; 403 let message = (error as BusinessError).message; 404 console.error('error:' + code + ', ' + message); 405 } 406 } 407 408 fetchOneCfgFile(); 409 ``` 410 411## getOneCfgFileSync<sup>11+</sup> 412 413getOneCfgFileSync(relPath: string, followMode?: FollowXMode, extra?: string): string 414 415Obtains the path of the configuration file with the highest priority based on the specified file name and follow mode. This API returns the result synchronously. 416 417**System capability**: SystemCapability.Customization.ConfigPolicy 418 419**Parameters** 420 421| Name | Type | Mandatory| Description | 422| ---------- | ----------------------------- | ---- | ----------------------------------------------------| 423| relPath | string | Yes | Name of the configuration file. | 424| followMode | [FollowXMode](#followxmode11) | No | Follow mode. The default value is **DEFAULT**. | 425| extra | string | No | Custom follow rule. This parameter is valid only when **followMode** is set to **USER_DEFINED**.| 426 427**Error codes** 428 429For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 430 431| ID| Error Message | 432| ------- | ---------------------------------------------------------------------------- | 433| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.| 434 435**Return value** 436 437| Type | Description | 438| ------ | ------------------------ | 439| string | Returns the path of the configuration file with the highest priority.| 440 441 442**Example** 443 444 ```ts 445 import { BusinessError } from '@ohos.base'; 446 447 try { 448 let relpath: string = 'etc/config.xml'; 449 let extra: string = 'etc/carrier/${telephony.sim.opkey0}'; 450 let result: string = configPolicy.getOneCfgFileSync(relpath, configPolicy.FollowXMode.USER_DEFINED, extra); 451 console.log('result is ' + result); 452 } catch (error) { 453 let code = (error as BusinessError).code; 454 let message = (error as BusinessError).message; 455 console.error('error:' + code + ', ' + message); 456 } 457 ``` 458 459## getCfgFiles<sup>11+</sup> 460 461getCfgFiles(relPath: string, followMode: FollowXMode, callback: AsyncCallback<Array<string>>) 462 463Obtains a list of configuration files based on the specified file name and follow mode, sorted in ascending order of priority. This API uses an asynchronous callback to return the result. 464For example, there are three **config.xml** files (in ascending order of priority): **/system/etc/config.xml**, **/sys_pod/etc/config.xml**, and **/sys_pod/etc/carrier/46060/etc/config.xml**. If the opkey of the default card is **46060** and the follow mode is **SIM_DEFAULT**, **/system/etc/config.xml, /sys_pod/etc/config.xml, /sys_pod/etc/carrier/46060/etc/config.xml** is returned. 465 466**System capability**: SystemCapability.Customization.ConfigPolicy 467 468**Parameters** 469 470| Name | Type | Mandatory| Description | 471| ---------- | ---------------------------------------- | ---- | -------------------------- | 472| relPath | string | Yes | Name of the configuration file. | 473| followMode | [FollowXMode](#followxmode11) | Yes | Follow mode. | 474| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the file lists.| 475 476**Error codes** 477 478For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 479 480| ID| Error Message | 481| ------- | ---------------------------------------------------------------------------- | 482| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.| 483 484**Example** 485 486 ```ts 487 import { BusinessError } from '@ohos.base'; 488 import configPolicy from '@ohos.configPolicy'; 489 490 let relpath: string = 'etc/config.xml'; 491 configPolicy.getCfgFiles(relpath, configPolicy.FollowXMode.SIM_DEFAULT, 492 (error: BusinessError, value: Array<string>) => { 493 if (error == null) { 494 console.log('value is ' + value); 495 } else { 496 console.error('error: ' + error.code + ', ' + error.message); 497 } 498 }); 499 ``` 500 501## getCfgFiles<sup>11+</sup> 502 503getCfgFiles(relPath: string, followMode: FollowXMode, extra: string, callback: AsyncCallback<Array<string>>) 504 505Obtains a list of configuration files based on the specified file name and follow mode, sorted in ascending order of priority. This API uses an asynchronous callback to return the result. 506For example, there are three **config.xml** files (in ascending order of priority): **/system/etc/config.xml**, **/sys_pod/etc/config.xml**, and **/sys_pod/etc/carrier/46060/etc/config.xml**. If the opkey of card 1 is **46060**, the follow mode is **USER_DEFINED**, and the custom follow rule is **etc/carrier/${telephony.sim.opkey0}**, **/system/etc/config.xml, /sys_pod/etc/config.xml, /sys_pod/etc/carrier/46060/etc/config.xml** is returned. 507 508**System capability**: SystemCapability.Customization.ConfigPolicy 509 510**Parameters** 511 512| Name | Type | Mandatory| Description | 513| ---------- | ---------------------------------------- | ---- | ------------------------------------------------------ | 514| relPath | string | Yes | Name of the configuration file. | 515| followMode | [FollowXMode](#followxmode11) | Yes | Follow mode. | 516| extra | string | Yes | Custom follow rule. This parameter is valid only when **followMode** is set to **USER_DEFINED**.| 517| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the file lists. | 518 519**Error codes** 520 521For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 522 523| ID| Error Message | 524| ------- | ---------------------------------------------------------------------------- | 525| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.| 526 527**Example** 528 529 ```ts 530 import { BusinessError } from '@ohos.base'; 531 import configPolicy from '@ohos.configPolicy'; 532 533 let relpath: string = 'etc/config.xml'; 534 let extra: string = 'etc/carrier/${telephony.sim.opkey0}'; 535 configPolicy.getCfgFiles(relpath, configPolicy.FollowXMode.SIM_DEFAULT, extra, 536 (error: BusinessError, value: Array<string>) => { 537 if (error == null) { 538 console.log('value is ' + value); 539 } else { 540 console.error('error: ' + error.code + ', ' + error.message); 541 } 542 }); 543 ``` 544 545## getCfgFiles<sup>11+</sup> 546 547getCfgFiles(relPath: string, followMode: FollowXMode, extra?: string): Promise<Array<string>> 548 549Obtains a list of configuration files based on the specified file name and follow mode, sorted in ascending order of priority. This API uses a promise to return the result. 550 551**System capability**: SystemCapability.Customization.ConfigPolicy 552 553**Parameters** 554 555| Name | Type | Mandatory| Description | 556| ---------- | ----------------------------- | ---- | ------------------------------------------------------ | 557| relPath | string | Yes | Name of the configuration file. | 558| followMode | [FollowXMode](#followxmode11) | Yes | Follow mode. | 559| extra | string | No | Custom follow rule. This parameter is valid only when **followMode** is set to **USER_DEFINED**.| 560 561**Error codes** 562 563For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 564 565| ID| Error Message | 566| ------- | ---------------------------------------------------------------------------- | 567| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.| 568 569**Return value** 570 571| Type | Description | 572| ---------------------------------- | -------- | 573| Promise<Array<string>> | Promise used to return the result.| 574 575**Example** 576 577 ```ts 578 import { BusinessError } from '@ohos.base'; 579 import configPolicy from '@ohos.configPolicy'; 580 581 async function fetchCfgFiles() { 582 try { 583 let relpath: string = 'etc/config.xml'; 584 let extra: string = 'etc/carrier/${telephony.sim.opkey0}'; 585 let value: Array<string> = await configPolicy.getCfgFiles(relpath, configPolicy.FollowXMode.SIM_DEFAULT, extra); 586 console.log('value is ' + value); 587 } catch (error) { 588 let code = (error as BusinessError).code; 589 let message = (error as BusinessError).message; 590 console.error('error:' + code + ', ' + message); 591 } 592 } 593 594 fetchCfgFiles(); 595 ``` 596 597## getCfgFilesSync<sup>11+</sup> 598 599getCfgFilesSync(relPath: string, followMode?: FollowXMode, extra?: string): Array<string> 600 601Obtains a list of configuration files based on the specified file name and follow mode, sorted in ascending order of priority. This API returns the result synchronously. 602 603**System capability**: SystemCapability.Customization.ConfigPolicy 604 605**Parameters** 606 607| Name | Type | Mandatory| Description | 608| ---------- | ----------------------------- | ---- | ------------------------------------------------------ | 609| relPath | string | Yes | Name of the configuration file. | 610| followMode | [FollowXMode](#followxmode11) | No | Follow mode. The default value is **DEFAULT**. | 611| extra | string | No | Custom follow rule. This parameter is valid only when **followMode** is set to **USER_DEFINED**.| 612 613**Error codes** 614 615For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 616 617| ID| Error Message | 618| ------- | ---------------------------------------------------------------------------- | 619| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.| 620 621**Return value** 622 623| Type | Description | 624| ------------------- | -------- | 625| Array<string> | Returns a list of configuration files.| 626 627 628**Example** 629 630 ```ts 631 import { BusinessError } from '@ohos.base'; 632 633 try { 634 let relpath: string = 'etc/config.xml'; 635 let extra: string = 'etc/carrier/${telephony.sim.opkey0}'; 636 let result: Array<string> = configPolicy.getCfgFilesSync(relpath, configPolicy.FollowXMode.USER_DEFINED, extra); 637 console.log('result is ' + result); 638 } catch (error) { 639 let code = (error as BusinessError).code; 640 let message = (error as BusinessError).message; 641 console.error('error:' + code + ', ' + message); 642 } 643 ``` 644 645## getCfgDirListSync<sup>11+</sup> 646 647getCfgDirListSync(): Array<string> 648 649Obtains the list of configuration level directories. This API returns the result synchronously. 650 651**System capability**: SystemCapability.Customization.ConfigPolicy 652 653**Return value** 654 655| Type | Description | 656| ------------------- | ---------------- | 657| Array<string> | Obtains the list of configuration level directories. This API returns the result synchronously.| 658 659 660**Example** 661 662 ```ts 663 import { BusinessError } from '@ohos.base'; 664 665 try { 666 let result: Array<string> = configPolicy.getCfgDirListSync(); 667 console.log('result is ' + result); 668 } catch (error) { 669 let code = (error as BusinessError).code; 670 let message = (error as BusinessError).message; 671 console.error('error:' + code + ', ' + message); 672 } 673 ``` 674 675## FollowXMode<sup>11+</sup> 676 677**System capability**: SystemCapability.Customization.ConfigPolicy 678 679| Name | Value | Description | 680| ---------------- | --- | -------------------------------------------------------------------------------------------------------------------------- | 681| DEFAULT | 0 | Files are searched based on the follow rules configured in the **followx_file_list.cfg** file at each configuration level. | 682| NO_RULE_FOLLOWED | 1 | No follow rule is used, even if the **followx_file_list.cfg** file exists. | 683| SIM_DEFAULT | 10 | Files are searched in **etc/carrier/${opkey}** file at each configuration level based on the opkey of the default card. | 684| SIM_1 | 11 | Files are searched in **etc/carrier/${opkey}** at each configuration level based on the opkey of card 1. | 685| SIM_2 | 12 | Files are searched in **etc/carrier/${opkey}** at each configuration level based on the opkey of card 2. | 686| USER_DEFINED | 100 | Files are searched based on the follow rule passed in **extra**, rather than the **followx_file_list.cfg** file at each configuration level.| 687