Introduction to the
There is a config file “config.json” in the root directory of each HAP application. The content of the file mainly covers the following three aspects:
- Global configuration information about an application, including the package name, manufacturer, and version.
- Application configuration information on a specific device, including application backup and restoration, and network security.
- HAP package configuration information, including the basic properties that each Ability must define (such as package name, class name, type, and capabilities provided by Ability), as well as the permissions the application needs to access the system or other protected parts of the application.
Composition of a configuration file
The configuration file config.json adopts the JSON file format and contains a series of configuration items. Each configuration item consists of attributes and values.
- attribute
Attributes appear in no particular order, and each attribute is allowed to appear at most once.
- value
The value of each property is a basic JSON data type (numeric, string, Boolean, array, object, or NULL). If attribute values need to refer to resource files, see Resource Files.
Elements of the configuration file
This section provides a detailed explanation of all the properties in the config file config.json.
DevEco Studio provides two ways to edit the “config.json” file. In the config.json editing window, you can switch between the code editing view and the visual editing view in the upper right corner.
Figure 1. A visual edit view of the config.json file
The internal structure of the configuration file
Config. json consists of app, deviceConfig, and Module.
The internal structure of an APP object
The internal structure of the deviceConfig object
The inner structure of a Module object
Name: indicates the name of Ability. Description: indicates the description of Ability. Icon: Indicates the index of the Ability icon resource file. Label: indicates the name displayed to the user by Ability. Uri: A uniform resource identifier representing Ability. LaunchType: indicates the launch mode of Ability, and supports both standard and Singleton modes
- Standard: indicates that the Ability can have multiple instances. The “Standard” mode applies to most application fields.
- Singleton: indicates that there can be only one instance of the Ability. For example, an incoming call interface with global uniqueness uses the Singleton mode.
Visible: indicates whether Ability can be called by other applications. Permissions: represents the permissions that need to be requested when the Ability of another application calls this Ability. Orientation: Indicates the display mode of the Ability.