1e41f4b71Sopenharmony_ci# Matching Rules of Explicit Want and Implicit Want
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciBoth explicit [Want](../reference/apis-ability-kit/js-apis-app-ability-want.md) and implicit [Want](../reference/apis-ability-kit/js-apis-app-ability-want.md) can be used to match an application component to start based on certain rules. These rules determine how the parameters set in [want](../reference/apis-ability-kit/js-apis-app-ability-want.md) match the configuration file declared by the target application component.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci## Matching Rules of Explicit Want
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ciThe table below describes the matching rules of explicit [Want](../reference/apis-ability-kit/js-apis-app-ability-want.md).
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci| Name| Type| Matching Item| Mandatory| Rule Description|
11e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
12e41f4b71Sopenharmony_ci| deviceId | string | Yes| No| If this field is unspecified, only application components on the local device are matched.|
13e41f4b71Sopenharmony_ci| bundleName | string | Yes| Yes| If **abilityName** is specified but **bundleName** is unspecified, the matching fails.|
14e41f4b71Sopenharmony_ci| 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.|
15e41f4b71Sopenharmony_ci| abilityName | string | Yes| Yes| To use explicit Want, this field must be specified.|
16e41f4b71Sopenharmony_ci| uri | string | No| No| This field is not used for matching. It is passed to the target application component as a parameter.|
17e41f4b71Sopenharmony_ci| type | string | No| No| This field is not used for matching. It is passed to the target application component as a parameter.|
18e41f4b71Sopenharmony_ci| action | string | No| No| This field is not used for matching. It is passed to the target application component as a parameter.|
19e41f4b71Sopenharmony_ci| entities | Array<string> | No| No| This field is not used for matching. It is passed to the target application component as a parameter.|
20e41f4b71Sopenharmony_ci| 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.|
21e41f4b71Sopenharmony_ci| parameters | {[key: string]: Object} | No| No| This field is not used for matching. It is passed to the target application component as a parameter.|
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci## Matching Rules of Implicit Want
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ciThe table below describes the matching rules of implicit [Want](../reference/apis-ability-kit/js-apis-app-ability-want.md).
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci| Name       | Type                          | Matching Item| Mandatory| Rule Description                                                        |
28e41f4b71Sopenharmony_ci| ----------- | ------------------------------ | ------ | ---- | ------------------------------------------------------------ |
29e41f4b71Sopenharmony_ci| deviceId    | string                         | Yes    | No  | Implicit invoking is not supported across devices.                                  |
30e41f4b71Sopenharmony_ci| abilityName | string                         | No    | No  | To use implicit Want, this field must be left unspecified.                                |
31e41f4b71Sopenharmony_ci| bundleName  | string                         | Yes    | No  | This field is used to match the target application component in the given bundle.                             |
32e41f4b71Sopenharmony_ci| moduleName  | string                         | Yes    | No  | This field is used to match the target application component in the given module.                             |
33e41f4b71Sopenharmony_ci| uri         | string                         | Yes    | No  | For details, see [Matching Rules of uri and type in the want Parameter](#matching-rules-of-uri-and-type-in-the-want-parameter).                                                            |
34e41f4b71Sopenharmony_ci| type        | string                         | Yes    | No  | For details, see [Matching Rules of uri and type in the want Parameter](#matching-rules-of-uri-and-type-in-the-want-parameter).                                                            |
35e41f4b71Sopenharmony_ci| action      | string                         | Yes    | No  | For details, see [Matching Rules of action in the want Parameter](#matching-rules-of-action-in-the-want-parameter).                                                            |
36e41f4b71Sopenharmony_ci| entities    | Array<string>            | Yes    | No  | For details, see [Matching Rules of entities in the want Parameter](#matching-rules-of-entities-in-the-want-parameter).                                                            |
37e41f4b71Sopenharmony_ci| 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.|
38e41f4b71Sopenharmony_ci| 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.|
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ciGet familiar with the following about implicit Want:
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci- The **want** parameter passed by the caller indicates the operation to be performed by the caller. It also provides data and application type restrictions.
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci- The **skills** field declares the capabilities of the target application component. For details, see [the skills tag](../quick-start/module-configuration-file.md#skills) in the [module.json5 file](../quick-start/module-configuration-file.md).
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ciThe 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.
49e41f4b71Sopenharmony_ci- If the **linkFeature** field in **parameters** is not null, a matching against **linkFeature** is carried out preferentially.
50e41f4b71Sopenharmony_ci  - If **linkFeature** is matched and **uri** or **type** in the **want** parameter is configured, the system continues to match **uri** or **type**. If they are matched, the implicit matching is successful. Otherwise, the matching fails. If neither **uri** nor **type** in the **want** parameter is configured, the implicit matching is successful.
51e41f4b71Sopenharmony_ci  - If **linkFeature** is not matched, no matching is performed and the matching fails.
52e41f4b71Sopenharmony_ci- If the **linkFeature** field in **parameters** is not specified or is null, the matching is successful only when the **action**, **entities**, **uri**, and **type** attributes are all matched.
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci### Matching Rules of action in the want Parameter
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ciThe system matches the **action** attribute in the **want** parameter passed by the caller against **actions** under **skills** of the application components.
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci- If **action** in the passed **want** parameter is null and **actions** under **skills** of an application component is null, the matching fails.
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci- If **action** in the passed **want** parameter is not null but **actions** under **skills** of an application component is null, the matching fails.
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci- If **action** in the passed **want** parameter is null but **actions** under **skills** of an application component is not null, the matching is successful.
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci- If **action** in the passed **want** parameter is not null, and **actions** under **skills** of an application component is not null and contains **action** in the passed **want** parameter, the matching is successful.
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ci- If **action** in the passed **want** parameter is not null, and **actions** under **skills** of an application component is not null but does not contain **action** in the passed **want** parameter, the matching fails.
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci  **Figure 1** Matching rules of action in the want parameter
70e41f4b71Sopenharmony_ci![want-action](figures/want-action.png)
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci### Matching Rules of entities in the want Parameter
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ciThe system matches the **entities** attribute in the **want** parameter passed by the caller against **entities** under **skills** of the application components.
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci- If **entities** in the passed **want** parameter is null but **entities** under **skills** of an application component is not null, the matching is successful.
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci- If **entities** in the passed **want** parameter is null but **entities** under **skills** of an application component is null, the matching is successful.
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci- If **entities** in the passed **want** parameter is not null but **entities** under **skills** of an application component is null, the matching fails.
82e41f4b71Sopenharmony_ci
83e41f4b71Sopenharmony_ci- If **entities** in the passed **want** parameter is not null, and **entities** under **skills** of an application component is not null and contains **entities** in the passed **want** parameter, the matching is successful.
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci- If **entities** in the passed **want** parameter is not null, and **entities** under **skills** of an application component is not null but does not contain **entities** in the passed **want** parameter, the matching fails.
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_ci  **Figure 2** Matching rules of entities in the want parameter
88e41f4b71Sopenharmony_ci![want-entities](figures/want-entities.png)
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ci### Matching Rules of uri and type in the want Parameter
92e41f4b71Sopenharmony_ci
93e41f4b71Sopenharmony_ciWhen 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.
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ciThere are four combinations of **uri** and **type** settings. The matching rules are as follows:
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ci- Both **uri** and **type** are null in the **want** parameter.
98e41f4b71Sopenharmony_ci  - If the **uris** array under **skills** of an application component is null, the matching is successful.
99e41f4b71Sopenharmony_ci  - If the **uris** array under **skills** of an application component contains an URI element whose **scheme** and **type** are null, the matching is successful.
100e41f4b71Sopenharmony_ci  - In other cases, the matching fails.
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci- Only **uri** is not null in the **want** parameter.
103e41f4b71Sopenharmony_ci  - If the **uris** array under **skills** of an application component is null, the matching fails.
104e41f4b71Sopenharmony_ci  - If the **uris** array under **skills** of an application component contains an element whose [uri is matched](#matching-rules-of-uri) and **type** is null, the matching is successful. Otherwise, the matching fails.
105e41f4b71Sopenharmony_ci  - If the matching fails for the preceding two scenarios and the input URI is a file path URI, the system obtains the MIME type of the file based on the file name extension. If the MIME type matches **type** configured under **skills**, the matching is successful.
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci- Only **type** is not null in the **want** parameter.
108e41f4b71Sopenharmony_ci  - If the **uris** array under **skills** of an application component is null, the matching fails.
109e41f4b71Sopenharmony_ci  - If the **uris** array under **skills** of an application component contains an URI element whose **scheme** is null and [type is matched](#matching-rules-of-type), the matching is successful. Otherwise, the matching fails.
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci- Both **uri** and **type** are not null in the **want** parameter, as shown below.
112e41f4b71Sopenharmony_ci  - If the **uris** array under **skills** of an application component is null, the matching fails.
113e41f4b71Sopenharmony_ci  - If the **uris** array under **skills** of an application component contains an element whose [uri is matched](#matching-rules-of-uri) and [type is matched](#matching-rules-of-type), the matching is successful. Otherwise, the matching fails.
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ciLeftmost 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**.
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci**Figure 3** Matching rules when uri and type are not null in the want parameter
118e41f4b71Sopenharmony_ci![want-uri-type1](figures/want-uri-type1.png)
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ciTo simplify the description:
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci- **uri** in the **want** parameter passed in by the caller is called **w_uri**; each element in the **uris** array under **skills** of the application component to match is called **s_uri**.
123e41f4b71Sopenharmony_ci- **type** in the **want** parameter passed in by the caller is called **w_type**; the type in the **uris** array under **skills** of the application component to match is called **s_type**.
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ci**Figure 4** Matching rules of uri and type in the want parameter
126e41f4b71Sopenharmony_ci![want-uri-type2](figures/want-uri-type2.png)
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci### Matching Rules of uri
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ciThe matching rules are as follows:
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci- If **scheme** of **s_uri** is null and **w_uri** is null, the matching is successful. Otherwise, the matching fails.
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci- If **host** of **s_uri** is null and **scheme** of **w_uri** and **scheme** of **s_uri** are the same, the matching is successful. Otherwise, the matching fails.
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_ci- If **port** of **s_uri** is null and the combination of **scheme** and **host** of **w_uri** is the same as the combination of **scheme** and **host** of **s_uri**, the matching is successful. Otherwise, the matching fails.
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ci- If **path**, **pathStartWith**, and **pathRegex** of **s_uri** are null and the combination of **scheme**, **host**, and **port** of **w_uri** is the same as the combination of **scheme**, **host**, and **port** of **s_uri**, the matching is successful. Otherwise, the matching fails.
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ci- If **path** of **s_uri** is not null and the **full path expressions** of **w_uri** and **s_uri** are the same, the matching is successful. Otherwise, the matching of **pathStartWith** continues.
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci- If **pathStartWith** of **s_uri** is not null and **w_uri** contains the prefix expression of **s_uri**, the matching is successful. Otherwise, **pathRegex** matching continues.
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ci- If **pathRegex** of **s_uri** is not null and **w_uri** meets the regular expression of **s_uri**, the matching is successful. Otherwise, the matching fails.
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci> **NOTE**
148e41f4b71Sopenharmony_ci>
149e41f4b71Sopenharmony_ci> 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:
150e41f4b71Sopenharmony_ci>
151e41f4b71Sopenharmony_ci> - **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.
152e41f4b71Sopenharmony_ci>     * `scheme://`
153e41f4b71Sopenharmony_ci>     * `scheme://host`
154e41f4b71Sopenharmony_ci>     * `scheme://host:port`
155e41f4b71Sopenharmony_ci> - **Full path expression**: `scheme://host:port/path`
156e41f4b71Sopenharmony_ci> - **Prefix expression**: `scheme://host:port/pathStartWith`
157e41f4b71Sopenharmony_ci> - **Regular expression**: `scheme://host:port/pathRegex`
158e41f4b71Sopenharmony_ci>
159e41f4b71Sopenharmony_ci> 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.
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_ci### Matching Rules of type
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ci> **NOTE**
164e41f4b71Sopenharmony_ci>
165e41f4b71Sopenharmony_ci> 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](#matching-rules-of-uri-and-type-in-the-want-parameter).
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ciThe matching rules are as follows:
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_ci- If **s_type** is null, the matching fails.
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ci- If **s_type** or **w_type** contains the wildcard `*/*`, the matching is successful.
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ci- If the last character of **s_type** is the wildcard `*`, for example, `prefixType/*`, the matching is successful only when **w_type** contains `prefixType/`.
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci- If the last character of **w_type** is the wildcard `*`, for example, `prefixType/*`, the matching is successful only when **s_type** contains `prefixType/`.
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_ci### Matching Rules of linkFeature
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_ci> **NOTE**
180e41f4b71Sopenharmony_ci>
181e41f4b71Sopenharmony_ci> 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.
182e41f4b71Sopenharmony_ci
183e41f4b71Sopenharmony_ciThe 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:
184e41f4b71Sopenharmony_ci- If both **uri** and **type** in the **want** parameter are null, only **linkFeature** is used for matching. If the value of **w_linkFeature** matches that of **s_uri**, the matching is successful. Otherwise, the matching fails.
185e41f4b71Sopenharmony_ci- If **uri** or **type** in the **want** parameter is not null, the system matches **linkFeature**, **uri**, and **type** in sequence. For details, see [Matching Rules of uri and type in the want Parameter](#matching-rules-of-uri-and-type-in-the-want-parameter). If all the three fields are matched, the matching is successful. Otherwise, the matching fails.
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ci
189e41f4b71Sopenharmony_ci**Figure 5** Matching rules of linkFeature in the want parameter
190e41f4b71Sopenharmony_ci
191e41f4b71Sopenharmony_ci![want-linkFeature](figures/linkFeature.png)
192e41f4b71Sopenharmony_ci
193e41f4b71Sopenharmony_ci![want-linkFeature-case](figures/want-linkFeature-case.png)
194