目录

Matching Rules of Explicit Want and Implicit Want

Both explicit Want and implicit Want can be used to match an application component to start based on certain rules. These rules determine how the parameters set in want match the configuration file declared by the target application component.

Matching Rules of Explicit Want

The table below describes the matching rules of explicit Want.

Name Type Matching Item Mandatory Rule Description
deviceId string Yes No If this field is unspecified, only application components on the local device are matched.
bundleName string Yes Yes If abilityName is specified but bundleName is unspecified, the matching fails.
moduleName string Yes No If this field is unspecified and multiple modules with the same ability name exist in the application, the first application component is matched by default.
abilityName string Yes Yes To use explicit Want, this field must be specified.
uri string No No This field is not used for matching. It is passed to the target application component as a parameter.
type string No No This field is not used for matching. It is passed to the target application component as a parameter.
action string No No This field is not used for matching. It is passed to the target application component as a parameter.
entities Array<string> No No This field is not used for matching. It is passed to the target application component as a parameter.
flags number No No This field is not used for matching and is directly transferred to the system for processing. It is generally used to set runtime information, such as URI data authorization.
parameters {[key: string]: Object} No No This field is not used for matching. It is passed to the target application component as a parameter.

Matching Rules of Implicit Want

The table below describes the matching rules of implicit Want.

Name Type Matching Item Mandatory Rule Description
deviceId string Yes No Implicit invoking is not supported across devices.
abilityName string No No To use implicit Want, this field must be left unspecified.
bundleName string Yes No This field is used to match the target application component in the given bundle.
moduleName string Yes No This field is used to match the target application component in the given module.
uri string Yes No For details, see Matching Rules of uri and type in the want Parameter.
type string Yes No For details, see Matching Rules of uri and type in the want Parameter.
action string Yes No For details, see Matching Rules of action in the want Parameter.
entities Array<string> Yes No For details, see Matching Rules of entities in the want Parameter.
flags number No No This field is not used for matching and is directly transferred to the system for processing. It is generally used to set runtime information, such as URI data authorization.
parameters {[key: string]: Object} Yes No This field is used to transfer custom data to the target application component. Currently, only the parameter with the key set to linkFeature is used for matching. When linkFeature is not null, a matching against linkFeature is carried out preferentially.

Get familiar with the following about implicit Want:

The system matches the want parameter (including the action, entities, uri, type, and parameters attributes) passed by the caller against the skills configuration (including the actions, entities, uris, and type attributes) of the application components. If none of the five attributes in the want parameter is configured, implicit matching fails.

[h2]Matching Rules of action in the want Parameter

The system matches the action attribute in the want parameter passed by the caller against actions under skills of the application components.

Figure 1 Matching rules of action in the want parameter

[h2]Matching Rules of entities in the want Parameter

The system matches the entities attribute in the want parameter passed by the caller against entities under skills of the application components.

Figure 2 Matching rules of entities in the want parameter

[h2]Matching Rules of uri and type in the want Parameter

When the uri and type parameters are not null in the want parameter to initiate an application component startup request, the system traverses the list of installed components and matches the uris array under skills of the application components one by one. If one of the uris arrays under skills matches the uri and type in the passed want, the matching is successful.

There are four combinations of uri and type settings. The matching rules are as follows:

Leftmost URI matching: When only scheme, a combination of scheme and host, or a combination of scheme, host, and port is configured in the uris array under skills of the application component, the matching is successful only if the leftmost URI in the passed want parameter matches scheme, the combination of scheme and host, or the combination of scheme, host, and port.

Figure 3 Matching rules when uri and type are not null in the want parameter

To simplify the description:

Figure 4 Matching rules of uri and type in the want parameter

[h2]Matching Rules of uri

The matching rules are as follows:

The scheme, host, port, path, pathStartWith, and pathRegex attributes of uris under skills of an application component are concatenated. If path, pathStartWith, and pathRegex are declared in sequence, uris can be concatenated into the following expressions:

  • Prefix URI expression: When only scheme, a combination of scheme and host, or a combination of scheme, host, and port is configured in the configuration file, the matching is successful if a URI prefixed with the configuration file is passed in.
    • scheme://
    • scheme://host
    • scheme://host:port
  • Full path expression: scheme://host:port/path
  • Prefix expression: scheme://host:port/pathStartWith
  • Regular expression: scheme://host:port/pathRegex

For system applications, scheme of their URIs starts with ohos, for example, ohosclock://. The URI of a third-party application cannot be the same as that of a system application. Otherwise, the third-party application cannot be started using the URI.

Figure 5 Example of the matching rules of uri in the want parameter

[h2]Matching Rules of type

The matching rules of type described in this section are based on the fact that type in the want parameter is not null. If type is null, follow the matching rules of uri and type in the want parameter.

The matching rules are as follows:

[h2]Matching Rules of linkFeature

The linkFeature matching rules described below apply to the scenario where parameters in the want parameter contains the linkFeature key and the value of the key is not null.

The system matches parameters in the want parameter passed by the caller against uris under skills of the application components. To simplify the description, linkFeature in the want parameter passed in by the caller is called w_linkFeature. The matching rules are as follows:

Figure 6 Matching rules of linkFeature in the want parameter