1e0857b17Sopenharmony_ci/*
2e0857b17Sopenharmony_ci * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3e0857b17Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e0857b17Sopenharmony_ci * you may not use this file except in compliance with the License.
5e0857b17Sopenharmony_ci * You may obtain a copy of the License at
6e0857b17Sopenharmony_ci *
7e0857b17Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e0857b17Sopenharmony_ci *
9e0857b17Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e0857b17Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e0857b17Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e0857b17Sopenharmony_ci * See the License for the specific language governing permissions and
13e0857b17Sopenharmony_ci * limitations under the License.
14e0857b17Sopenharmony_ci */
15e0857b17Sopenharmony_ci
16e0857b17Sopenharmony_ci#ifndef OHOS_ABILITY_BASE_WANT_H
17e0857b17Sopenharmony_ci#define OHOS_ABILITY_BASE_WANT_H
18e0857b17Sopenharmony_ci
19e0857b17Sopenharmony_ci#include <string>
20e0857b17Sopenharmony_ci#include <vector>
21e0857b17Sopenharmony_ci#include <algorithm>
22e0857b17Sopenharmony_ci
23e0857b17Sopenharmony_ci#include "uri.h"
24e0857b17Sopenharmony_ci#include "want_params.h"
25e0857b17Sopenharmony_ci#include "element_name.h"
26e0857b17Sopenharmony_ci#include "operation.h"
27e0857b17Sopenharmony_ci#include "parcel.h"
28e0857b17Sopenharmony_ci#include "nlohmann/json.hpp"
29e0857b17Sopenharmony_ci
30e0857b17Sopenharmony_ciusing Operation = OHOS::AAFwk::Operation;
31e0857b17Sopenharmony_ci
32e0857b17Sopenharmony_cinamespace OHOS {
33e0857b17Sopenharmony_cinamespace AAFwk {
34e0857b17Sopenharmony_ciclass Want final : public Parcelable {
35e0857b17Sopenharmony_cipublic:
36e0857b17Sopenharmony_ci    /**
37e0857b17Sopenharmony_ci     * Indicates the grant to perform read operations on the URI.
38e0857b17Sopenharmony_ci     */
39e0857b17Sopenharmony_ci    static constexpr unsigned int FLAG_AUTH_READ_URI_PERMISSION = 0x00000001;
40e0857b17Sopenharmony_ci    /**
41e0857b17Sopenharmony_ci     * Indicates the grant to perform write operations on the URI.
42e0857b17Sopenharmony_ci     */
43e0857b17Sopenharmony_ci    static constexpr unsigned int FLAG_AUTH_WRITE_URI_PERMISSION = 0x00000002;
44e0857b17Sopenharmony_ci    /**
45e0857b17Sopenharmony_ci     * Returns the result to the source ability.
46e0857b17Sopenharmony_ci     */
47e0857b17Sopenharmony_ci    static constexpr unsigned int FLAG_ABILITY_FORWARD_RESULT = 0x00000004;
48e0857b17Sopenharmony_ci    /**
49e0857b17Sopenharmony_ci     * Determines whether an ability on the local device can be migrated to a remote device.
50e0857b17Sopenharmony_ci     */
51e0857b17Sopenharmony_ci    static constexpr unsigned int FLAG_ABILITY_CONTINUATION = 0x00000008;
52e0857b17Sopenharmony_ci    /**
53e0857b17Sopenharmony_ci     * Specifies whether a component does not belong to OHOS.
54e0857b17Sopenharmony_ci     */
55e0857b17Sopenharmony_ci    static constexpr unsigned int FLAG_NOT_OHOS_COMPONENT = 0x00000010;
56e0857b17Sopenharmony_ci    /**
57e0857b17Sopenharmony_ci     * Specifies whether an ability is started.
58e0857b17Sopenharmony_ci     */
59e0857b17Sopenharmony_ci    static constexpr unsigned int FLAG_ABILITY_FORM_ENABLED = 0x00000020;
60e0857b17Sopenharmony_ci    /**
61e0857b17Sopenharmony_ci     * Indicates the grant for possible persisting on the URI.
62e0857b17Sopenharmony_ci     */
63e0857b17Sopenharmony_ci    static constexpr unsigned int FLAG_AUTH_PERSISTABLE_URI_PERMISSION = 0x00000040;
64e0857b17Sopenharmony_ci    /**
65e0857b17Sopenharmony_ci     * Returns the result to the source ability slice.
66e0857b17Sopenharmony_ci     */
67e0857b17Sopenharmony_ci    static constexpr unsigned int FLAG_AUTH_PREFIX_URI_PERMISSION = 0x00000080;
68e0857b17Sopenharmony_ci    /**
69e0857b17Sopenharmony_ci     * Supports multi-device startup in the distributed scheduling system.
70e0857b17Sopenharmony_ci     */
71e0857b17Sopenharmony_ci    static constexpr unsigned int FLAG_ABILITYSLICE_MULTI_DEVICE = 0x00000100;
72e0857b17Sopenharmony_ci    /**
73e0857b17Sopenharmony_ci     * Indicates that an ability using the Service template is started regardless of whether the host application has
74e0857b17Sopenharmony_ci     * been started.
75e0857b17Sopenharmony_ci     */
76e0857b17Sopenharmony_ci    static constexpr unsigned int FLAG_START_FOREGROUND_ABILITY = 0x00000200;
77e0857b17Sopenharmony_ci
78e0857b17Sopenharmony_ci    /**
79e0857b17Sopenharmony_ci     * Indicates the continuation is reversible.
80e0857b17Sopenharmony_ci     */
81e0857b17Sopenharmony_ci    static constexpr unsigned int FLAG_ABILITY_CONTINUATION_REVERSIBLE = 0x00000400;
82e0857b17Sopenharmony_ci
83e0857b17Sopenharmony_ci    /**
84e0857b17Sopenharmony_ci     * Install the specified ability if it's not installed.
85e0857b17Sopenharmony_ci     */
86e0857b17Sopenharmony_ci    static constexpr unsigned int FLAG_INSTALL_ON_DEMAND = 0x00000800;
87e0857b17Sopenharmony_ci    /**
88e0857b17Sopenharmony_ci     * Indicates the continuation is quick start
89e0857b17Sopenharmony_ci     */
90e0857b17Sopenharmony_ci    static constexpr unsigned int FLAG_ABILITY_PREPARE_CONTINUATION = 0x00001000;
91e0857b17Sopenharmony_ci    /**
92e0857b17Sopenharmony_ci     * Returns the result to the source ability slice.
93e0857b17Sopenharmony_ci     */
94e0857b17Sopenharmony_ci    static constexpr unsigned int FLAG_ABILITYSLICE_FORWARD_RESULT = 0x04000000;
95e0857b17Sopenharmony_ci    /**
96e0857b17Sopenharmony_ci     * Install the specifiedi ability with background mode if it's not installed.
97e0857b17Sopenharmony_ci     */
98e0857b17Sopenharmony_ci    static constexpr unsigned int FLAG_INSTALL_WITH_BACKGROUND_MODE = 0x80000000;
99e0857b17Sopenharmony_ci    /**
100e0857b17Sopenharmony_ci     * Indicates the operation of clearing other missions.
101e0857b17Sopenharmony_ci     */
102e0857b17Sopenharmony_ci    static constexpr unsigned int FLAG_ABILITY_CLEAR_MISSION = 0x00008000;
103e0857b17Sopenharmony_ci    /**
104e0857b17Sopenharmony_ci     * Indicates the operation of creating a task on the historical mission stack.
105e0857b17Sopenharmony_ci     */
106e0857b17Sopenharmony_ci    static constexpr unsigned int FLAG_ABILITY_NEW_MISSION = 0x10000000;
107e0857b17Sopenharmony_ci    /**
108e0857b17Sopenharmony_ci     * Indicates that the existing instance of the ability to start will be reused if it is already at the top of
109e0857b17Sopenharmony_ci     * the mission stack. Otherwise, a new ability instance will be created.
110e0857b17Sopenharmony_ci     */
111e0857b17Sopenharmony_ci    static constexpr unsigned int FLAG_ABILITY_MISSION_TOP = 0x20000000;
112e0857b17Sopenharmony_ci    /**
113e0857b17Sopenharmony_ci     * Indicates that if implicit start ability couldn't match any application, no tip dialog will be pulled up.
114e0857b17Sopenharmony_ci     */
115e0857b17Sopenharmony_ci    static constexpr unsigned int FLAG_START_WITHOUT_TIPS = 0x40000000;
116e0857b17Sopenharmony_ci
117e0857b17Sopenharmony_ci    /**
118e0857b17Sopenharmony_ci     * @description:  Default construcotr of Want class, which is used to initialzie flags and URI.
119e0857b17Sopenharmony_ci     * @param None
120e0857b17Sopenharmony_ci     * @return None
121e0857b17Sopenharmony_ci     */
122e0857b17Sopenharmony_ci    Want();
123e0857b17Sopenharmony_ci
124e0857b17Sopenharmony_ci    /**
125e0857b17Sopenharmony_ci     * @description: Default deconstructor of Want class
126e0857b17Sopenharmony_ci     * @param None
127e0857b17Sopenharmony_ci     * @return None
128e0857b17Sopenharmony_ci     */
129e0857b17Sopenharmony_ci    ~Want();
130e0857b17Sopenharmony_ci
131e0857b17Sopenharmony_ci    /**
132e0857b17Sopenharmony_ci     * @description: Copy construcotr of Want class, which is used to initialzie flags, URI, etc.
133e0857b17Sopenharmony_ci     * @param want the source instance of Want.
134e0857b17Sopenharmony_ci     * @return None
135e0857b17Sopenharmony_ci     */
136e0857b17Sopenharmony_ci    Want(const Want &want);
137e0857b17Sopenharmony_ci    Want &operator=(const Want &want);
138e0857b17Sopenharmony_ci
139e0857b17Sopenharmony_ci    /**
140e0857b17Sopenharmony_ci     * @description: Sets a flag in a Want.
141e0857b17Sopenharmony_ci     * @param flags Indicates the flag to set.
142e0857b17Sopenharmony_ci     * @return Returns this Want object containing the flag.
143e0857b17Sopenharmony_ci     */
144e0857b17Sopenharmony_ci    Want &SetFlags(unsigned int flags);
145e0857b17Sopenharmony_ci
146e0857b17Sopenharmony_ci    /**
147e0857b17Sopenharmony_ci     * @description: Obtains the description of flags in a Want.
148e0857b17Sopenharmony_ci     * @return Returns the flag description in the Want.
149e0857b17Sopenharmony_ci     */
150e0857b17Sopenharmony_ci    unsigned int GetFlags() const;
151e0857b17Sopenharmony_ci
152e0857b17Sopenharmony_ci    /**
153e0857b17Sopenharmony_ci     * @description: Adds a flag to a Want.
154e0857b17Sopenharmony_ci     * @param flags Indicates the flag to add.
155e0857b17Sopenharmony_ci     * @return Returns the Want object with the added flag.
156e0857b17Sopenharmony_ci     */
157e0857b17Sopenharmony_ci    Want &AddFlags(unsigned int flags);
158e0857b17Sopenharmony_ci
159e0857b17Sopenharmony_ci    /**
160e0857b17Sopenharmony_ci     * @description: Removes the description of a flag from a Want.
161e0857b17Sopenharmony_ci     * @param flags Indicates the flag to remove.
162e0857b17Sopenharmony_ci     * @return Removes the description of a flag from a Want.
163e0857b17Sopenharmony_ci     */
164e0857b17Sopenharmony_ci    void RemoveFlags(unsigned int flags);
165e0857b17Sopenharmony_ci
166e0857b17Sopenharmony_ci    /**
167e0857b17Sopenharmony_ci     * @description: Sets the bundleName and abilityName attributes for this Want object.
168e0857b17Sopenharmony_ci     * @param bundleName Indicates the bundleName to set for the operation attribute in the Want.
169e0857b17Sopenharmony_ci     * @param abilityName Indicates the abilityName to set for the operation attribute in the Want.
170e0857b17Sopenharmony_ci     * @return Returns this Want object that contains the specified bundleName and abilityName attributes.
171e0857b17Sopenharmony_ci     */
172e0857b17Sopenharmony_ci    Want &SetElementName(const std::string &bundleName, const std::string &abilityName);
173e0857b17Sopenharmony_ci
174e0857b17Sopenharmony_ci    /**
175e0857b17Sopenharmony_ci     * @description: Sets the bundleName and abilityName attributes for this Want object.
176e0857b17Sopenharmony_ci     * @param deviceId Indicates the deviceId to set for the operation attribute in the Want.
177e0857b17Sopenharmony_ci     * @param bundleName Indicates the bundleName to set for the operation attribute in the Want.
178e0857b17Sopenharmony_ci     * @param abilityName Indicates the abilityName to set for the operation attribute in the Want.
179e0857b17Sopenharmony_ci     * @return Returns this Want object that contains the specified bundleName and abilityName attributes.
180e0857b17Sopenharmony_ci     */
181e0857b17Sopenharmony_ci    Want &SetElementName(const std::string &deviceId, const std::string &bundleName,
182e0857b17Sopenharmony_ci        const std::string &abilityName, const std::string &moduleName = "");
183e0857b17Sopenharmony_ci
184e0857b17Sopenharmony_ci    /**
185e0857b17Sopenharmony_ci     * @description: Sets an ElementName object in a Want.
186e0857b17Sopenharmony_ci     * @param element Indicates the ElementName description.
187e0857b17Sopenharmony_ci     * @return Returns this Want object containing the ElementName
188e0857b17Sopenharmony_ci     */
189e0857b17Sopenharmony_ci    Want &SetElement(const OHOS::AppExecFwk::ElementName &element);
190e0857b17Sopenharmony_ci
191e0857b17Sopenharmony_ci    /**
192e0857b17Sopenharmony_ci     * @description: Obtains the description of the ElementName object in a Want.
193e0857b17Sopenharmony_ci     * @return Returns the ElementName description in the Want.
194e0857b17Sopenharmony_ci     */
195e0857b17Sopenharmony_ci    OHOS::AppExecFwk::ElementName GetElement() const;
196e0857b17Sopenharmony_ci
197e0857b17Sopenharmony_ci    /**
198e0857b17Sopenharmony_ci     * @description: Creates a want with its corresponding attributes specified for starting the main ability of an
199e0857b17Sopenharmony_ci     * application.
200e0857b17Sopenharmony_ci     * @param ElementName  Indicates the ElementName object defining the deviceId, bundleName,
201e0857b17Sopenharmony_ci     * and abilityName sub-attributes of the operation attribute in a want.
202e0857b17Sopenharmony_ci     * @return Returns the want object used to start the main ability of an application.
203e0857b17Sopenharmony_ci     */
204e0857b17Sopenharmony_ci    static Want *MakeMainAbility(const OHOS::AppExecFwk::ElementName &elementName);
205e0857b17Sopenharmony_ci
206e0857b17Sopenharmony_ci    /**
207e0857b17Sopenharmony_ci     * @description: Creates a Want instance by using a given Uniform Resource Identifier (URI).
208e0857b17Sopenharmony_ci     * This method parses the input URI and saves it in a Want object.
209e0857b17Sopenharmony_ci     * @param uri Indicates the URI to parse.
210e0857b17Sopenharmony_ci     * @return Returns a Want object containing the URI.
211e0857b17Sopenharmony_ci     */
212e0857b17Sopenharmony_ci    static Want *WantParseUri(const char *uri);
213e0857b17Sopenharmony_ci
214e0857b17Sopenharmony_ci    /**
215e0857b17Sopenharmony_ci     * @description: Creates a Want instance by using a given Uniform Resource Identifier (URI).
216e0857b17Sopenharmony_ci     * This method parses the input URI and saves it in a Want object.
217e0857b17Sopenharmony_ci     * @param uri Indicates the URI to parse.
218e0857b17Sopenharmony_ci     * @return Returns a Want object containing the URI.
219e0857b17Sopenharmony_ci     */
220e0857b17Sopenharmony_ci    static Want *ParseUri(const std::string &uri);
221e0857b17Sopenharmony_ci
222e0857b17Sopenharmony_ci    /**
223e0857b17Sopenharmony_ci     * @description: Obtains the description of a URI in a Want.
224e0857b17Sopenharmony_ci     * @return Returns the URI description in the Want.
225e0857b17Sopenharmony_ci     */
226e0857b17Sopenharmony_ci    Uri GetUri() const;
227e0857b17Sopenharmony_ci
228e0857b17Sopenharmony_ci    /**
229e0857b17Sopenharmony_ci     * @description: Obtains the string representation of the URI in this Want.
230e0857b17Sopenharmony_ci     * @return Returns the string of the URI.
231e0857b17Sopenharmony_ci     */
232e0857b17Sopenharmony_ci    std::string GetUriString() const;
233e0857b17Sopenharmony_ci
234e0857b17Sopenharmony_ci    /**
235e0857b17Sopenharmony_ci     * @description: Sets the description of a URI in a Want.
236e0857b17Sopenharmony_ci     * @param uri Indicates the URI description.
237e0857b17Sopenharmony_ci     * @return Returns this Want object containing the URI.
238e0857b17Sopenharmony_ci     */
239e0857b17Sopenharmony_ci    Want &SetUri(const std::string &uri);
240e0857b17Sopenharmony_ci
241e0857b17Sopenharmony_ci    /**
242e0857b17Sopenharmony_ci     * @description: Sets the description of a URI in a Want.
243e0857b17Sopenharmony_ci     * @param uri Indicates the URI description.
244e0857b17Sopenharmony_ci     * @return Returns this Want object containing the URI.
245e0857b17Sopenharmony_ci     */
246e0857b17Sopenharmony_ci    Want &SetUri(const Uri &uri);
247e0857b17Sopenharmony_ci
248e0857b17Sopenharmony_ci    /**
249e0857b17Sopenharmony_ci     * @description: Sets the description of a URI and a type in this Want.
250e0857b17Sopenharmony_ci     * @param uri Indicates the URI description.
251e0857b17Sopenharmony_ci     * @param type Indicates the type description.
252e0857b17Sopenharmony_ci     * @return Returns the Want object containing the URI and the type by setting.
253e0857b17Sopenharmony_ci     */
254e0857b17Sopenharmony_ci    Want &SetUriAndType(const Uri &uri, const std::string &type);
255e0857b17Sopenharmony_ci
256e0857b17Sopenharmony_ci    /**
257e0857b17Sopenharmony_ci     * @description: Converts a Want into a URI string containing a representation of it.
258e0857b17Sopenharmony_ci     * @param want Indicates the want description.--Want.
259e0857b17Sopenharmony_ci     * @return   Returns an encoding URI string describing the Want object.
260e0857b17Sopenharmony_ci     */
261e0857b17Sopenharmony_ci    std::string WantToUri(Want &want);
262e0857b17Sopenharmony_ci
263e0857b17Sopenharmony_ci    /**
264e0857b17Sopenharmony_ci     * @description: Converts parameter information in a Want into a URI string.
265e0857b17Sopenharmony_ci     * @return Returns the URI string.
266e0857b17Sopenharmony_ci     */
267e0857b17Sopenharmony_ci    std::string ToUri() const;
268e0857b17Sopenharmony_ci
269e0857b17Sopenharmony_ci    /**
270e0857b17Sopenharmony_ci     * @description: Formats a specified URI.
271e0857b17Sopenharmony_ci     * This method uses the Uri.getLowerCaseScheme() method to format a URI and then saves
272e0857b17Sopenharmony_ci     * the formatted URI to this Want object.
273e0857b17Sopenharmony_ci     * @param uri Indicates the string of URI to format.
274e0857b17Sopenharmony_ci     * @return Returns this Want object that contains the formatted uri attribute.
275e0857b17Sopenharmony_ci     */
276e0857b17Sopenharmony_ci    Want &FormatUri(const std::string &uri);
277e0857b17Sopenharmony_ci
278e0857b17Sopenharmony_ci    /**
279e0857b17Sopenharmony_ci     * @description: Formats a specified URI.
280e0857b17Sopenharmony_ci     * This method uses the Uri.getLowerCaseScheme() method to format a URI and then saves
281e0857b17Sopenharmony_ci     * the formatted URI to this Want object.
282e0857b17Sopenharmony_ci     * @param uri Indicates the URI to format.
283e0857b17Sopenharmony_ci     * @return Returns this Want object that contains the formatted URI attribute.
284e0857b17Sopenharmony_ci     */
285e0857b17Sopenharmony_ci    Want &FormatUri(const Uri &uri);
286e0857b17Sopenharmony_ci
287e0857b17Sopenharmony_ci    /**
288e0857b17Sopenharmony_ci     * @description: Obtains the description of an action in a want.
289e0857b17Sopenharmony_ci     * @return Returns a Want object that contains the action description.
290e0857b17Sopenharmony_ci     */
291e0857b17Sopenharmony_ci    std::string GetAction() const;
292e0857b17Sopenharmony_ci
293e0857b17Sopenharmony_ci    /**
294e0857b17Sopenharmony_ci     * @description: Sets the description of an action in a want.
295e0857b17Sopenharmony_ci     * @param action Indicates the action description to set.
296e0857b17Sopenharmony_ci     * @return Returns a Want object that contains the action description.
297e0857b17Sopenharmony_ci     */
298e0857b17Sopenharmony_ci    Want &SetAction(const std::string &action);
299e0857b17Sopenharmony_ci
300e0857b17Sopenharmony_ci    /**
301e0857b17Sopenharmony_ci     * @description: Obtains the name of the specified bundle in a Want.
302e0857b17Sopenharmony_ci     * @return Returns the specified bundle name in the Want.
303e0857b17Sopenharmony_ci     */
304e0857b17Sopenharmony_ci    std::string GetBundle() const;
305e0857b17Sopenharmony_ci
306e0857b17Sopenharmony_ci    /**
307e0857b17Sopenharmony_ci     * @description: Sets a bundle name in this Want.
308e0857b17Sopenharmony_ci     * If a bundle name is specified in a Want, the Want will match only
309e0857b17Sopenharmony_ci     * the abilities in the specified bundle. You cannot use this method and
310e0857b17Sopenharmony_ci     * setPicker(ohos.aafwk.content.Want) on the same Want.
311e0857b17Sopenharmony_ci     * @param bundleName Indicates the bundle name to set.
312e0857b17Sopenharmony_ci     * @return Returns a Want object containing the specified bundle name.
313e0857b17Sopenharmony_ci     */
314e0857b17Sopenharmony_ci    Want &SetBundle(const std::string &bundleName);
315e0857b17Sopenharmony_ci
316e0857b17Sopenharmony_ci    /**
317e0857b17Sopenharmony_ci     * @description: Obtains the description of all entities in a Want
318e0857b17Sopenharmony_ci     * @return Returns a set of entities
319e0857b17Sopenharmony_ci     */
320e0857b17Sopenharmony_ci    const std::vector<std::string> &GetEntities() const;
321e0857b17Sopenharmony_ci
322e0857b17Sopenharmony_ci    /**
323e0857b17Sopenharmony_ci     * @description: Adds the description of an entity to a Want
324e0857b17Sopenharmony_ci     * @param entity Indicates the entity description to add
325e0857b17Sopenharmony_ci     * @return {Want} Returns this Want object containing the entity.
326e0857b17Sopenharmony_ci     */
327e0857b17Sopenharmony_ci    Want &AddEntity(const std::string &entity);
328e0857b17Sopenharmony_ci
329e0857b17Sopenharmony_ci    /**
330e0857b17Sopenharmony_ci     * @description: Removes the description of an entity from a Want
331e0857b17Sopenharmony_ci     * @param entity Indicates the entity description to remove.
332e0857b17Sopenharmony_ci     * @return void
333e0857b17Sopenharmony_ci     */
334e0857b17Sopenharmony_ci    void RemoveEntity(const std::string &entity);
335e0857b17Sopenharmony_ci
336e0857b17Sopenharmony_ci    /**
337e0857b17Sopenharmony_ci     * @description: Checks whether a Want contains the given entity
338e0857b17Sopenharmony_ci     * @param entity Indicates the entity to check
339e0857b17Sopenharmony_ci     * @return Returns true if the given entity is contained; returns false otherwise
340e0857b17Sopenharmony_ci     */
341e0857b17Sopenharmony_ci    bool HasEntity(const std::string &key) const;
342e0857b17Sopenharmony_ci
343e0857b17Sopenharmony_ci    /**
344e0857b17Sopenharmony_ci     * @description: Obtains the number of entities in a Want
345e0857b17Sopenharmony_ci     * @return Returns the entity quantity
346e0857b17Sopenharmony_ci     */
347e0857b17Sopenharmony_ci    int CountEntities();
348e0857b17Sopenharmony_ci
349e0857b17Sopenharmony_ci    /**
350e0857b17Sopenharmony_ci     * @description: Obtains the description of the URI scheme in this want.
351e0857b17Sopenharmony_ci     * @return Returns the URI scheme description in this want.
352e0857b17Sopenharmony_ci     */
353e0857b17Sopenharmony_ci    const std::string GetScheme() const;
354e0857b17Sopenharmony_ci
355e0857b17Sopenharmony_ci    /**
356e0857b17Sopenharmony_ci     * @description: Obtains the description of the type in this Want
357e0857b17Sopenharmony_ci     * @return Returns the type description in this Want
358e0857b17Sopenharmony_ci     */
359e0857b17Sopenharmony_ci    std::string GetType() const;
360e0857b17Sopenharmony_ci
361e0857b17Sopenharmony_ci    /**
362e0857b17Sopenharmony_ci     * @description: Sets the description of a type in this Want
363e0857b17Sopenharmony_ci     * @param type Indicates the type description
364e0857b17Sopenharmony_ci     * @return Returns this Want object containing the type
365e0857b17Sopenharmony_ci     */
366e0857b17Sopenharmony_ci    Want &SetType(const std::string &type);
367e0857b17Sopenharmony_ci
368e0857b17Sopenharmony_ci    /**
369e0857b17Sopenharmony_ci     * @description: Formats a specified MIME type. This method uses
370e0857b17Sopenharmony_ci     * the formatMimeType(java.lang.String) method to format a MIME type
371e0857b17Sopenharmony_ci     * and then saves the formatted type to this Want object.
372e0857b17Sopenharmony_ci     * @param type Indicates the MIME type to format
373e0857b17Sopenharmony_ci     * @return Returns this Want object that contains the formatted type attribute
374e0857b17Sopenharmony_ci     */
375e0857b17Sopenharmony_ci    Want &FormatType(const std::string &type);
376e0857b17Sopenharmony_ci
377e0857b17Sopenharmony_ci    /**
378e0857b17Sopenharmony_ci     * @description: Formats a specified URI and MIME type.
379e0857b17Sopenharmony_ci     * This method works in the same way as formatUri(ohos.utils.net.URI)
380e0857b17Sopenharmony_ci     * and formatType(java.lang.String).
381e0857b17Sopenharmony_ci     * @param uri Indicates the URI to format.
382e0857b17Sopenharmony_ci     * @param type Indicates the MIME type to format.
383e0857b17Sopenharmony_ci     * @return Returns this Want object that contains the formatted URI and type attributes.
384e0857b17Sopenharmony_ci     */
385e0857b17Sopenharmony_ci    Want &FormatUriAndType(const Uri &uri, const std::string &type);
386e0857b17Sopenharmony_ci
387e0857b17Sopenharmony_ci    /**
388e0857b17Sopenharmony_ci     * @description: This method formats data of a specified MIME type
389e0857b17Sopenharmony_ci     * by removing spaces from the data and converting the data into
390e0857b17Sopenharmony_ci     * lowercase letters. You can use this method to normalize
391e0857b17Sopenharmony_ci     * the external data used to create Want information.
392e0857b17Sopenharmony_ci     * @param type Indicates the MIME type to format
393e0857b17Sopenharmony_ci     * @return Returns this Want object that contains the formatted type attribute
394e0857b17Sopenharmony_ci     */
395e0857b17Sopenharmony_ci    static std::string FormatMimeType(const std::string &mimeType);
396e0857b17Sopenharmony_ci
397e0857b17Sopenharmony_ci    /**
398e0857b17Sopenharmony_ci     * @description: clear the specific want object.
399e0857b17Sopenharmony_ci     * @param want Indicates the want to clear
400e0857b17Sopenharmony_ci     */
401e0857b17Sopenharmony_ci    static void ClearWant(Want *want);
402e0857b17Sopenharmony_ci
403e0857b17Sopenharmony_ci    /**
404e0857b17Sopenharmony_ci     * @description: Obtains the description of the WantParams object in a Want
405e0857b17Sopenharmony_ci     * @return Returns the WantParams description in the Want
406e0857b17Sopenharmony_ci     */
407e0857b17Sopenharmony_ci    const WantParams &GetParams() const;
408e0857b17Sopenharmony_ci
409e0857b17Sopenharmony_ci    /**
410e0857b17Sopenharmony_ci     * @description: Sets a wantParams object in a want.
411e0857b17Sopenharmony_ci     * @param wantParams  Indicates the wantParams description.
412e0857b17Sopenharmony_ci     * @return Returns this want object containing the wantParams.
413e0857b17Sopenharmony_ci     */
414e0857b17Sopenharmony_ci    Want &SetParams(const WantParams &wantParams);
415e0857b17Sopenharmony_ci
416e0857b17Sopenharmony_ci    /**
417e0857b17Sopenharmony_ci     * @description: Obtains a bool-type value matching the given key.
418e0857b17Sopenharmony_ci     * @param key   Indicates the key of WantParams.
419e0857b17Sopenharmony_ci     * @param defaultValue  Indicates the default bool-type value.
420e0857b17Sopenharmony_ci     * @return Returns the bool-type value of the parameter matching the given key;
421e0857b17Sopenharmony_ci     * returns the default value if the key does not exist.
422e0857b17Sopenharmony_ci     */
423e0857b17Sopenharmony_ci    bool GetBoolParam(const std::string &key, bool defaultValue) const;
424e0857b17Sopenharmony_ci
425e0857b17Sopenharmony_ci    /**
426e0857b17Sopenharmony_ci     * @description: Obtains a bool-type array matching the given key.
427e0857b17Sopenharmony_ci     * @param key   Indicates the key of WantParams.
428e0857b17Sopenharmony_ci     * @return Returns the bool-type array of the parameter matching the given key;
429e0857b17Sopenharmony_ci     * returns null if the key does not exist.
430e0857b17Sopenharmony_ci     */
431e0857b17Sopenharmony_ci    std::vector<bool> GetBoolArrayParam(const std::string &key) const;
432e0857b17Sopenharmony_ci
433e0857b17Sopenharmony_ci    /**
434e0857b17Sopenharmony_ci     * @description: Sets a parameter value of the IRemoteObject type.
435e0857b17Sopenharmony_ci     * @param key   Indicates the key matching the parameter.
436e0857b17Sopenharmony_ci     * @param value Indicates the IRemoteObject value of the parameter.
437e0857b17Sopenharmony_ci     * @return Returns this want object containing the parameter value.
438e0857b17Sopenharmony_ci     */
439e0857b17Sopenharmony_ci    Want& SetParam(const std::string& key, const sptr<IRemoteObject>& remoteObject);
440e0857b17Sopenharmony_ci
441e0857b17Sopenharmony_ci    /**
442e0857b17Sopenharmony_ci     * @description: Obtains a IRemoteObject-type value matching the given key.
443e0857b17Sopenharmony_ci     * @param key   Indicates the key of WantParams.
444e0857b17Sopenharmony_ci     * @param defaultValue  Indicates the default IRemoteObject-type value.
445e0857b17Sopenharmony_ci     * @return Returns the IRemoteObject-type value of the parameter matching the given key;
446e0857b17Sopenharmony_ci     * returns the nullptr if the key does not exist.
447e0857b17Sopenharmony_ci     */
448e0857b17Sopenharmony_ci    sptr<IRemoteObject> GetRemoteObject(const std::string &key) const;
449e0857b17Sopenharmony_ci
450e0857b17Sopenharmony_ci    /**
451e0857b17Sopenharmony_ci     * @description: Sets a parameter value of the boolean type.
452e0857b17Sopenharmony_ci     * @param key   Indicates the key matching the parameter.
453e0857b17Sopenharmony_ci     * @param value Indicates the boolean value of the parameter.
454e0857b17Sopenharmony_ci     * @return Returns this want object containing the parameter value.
455e0857b17Sopenharmony_ci     */
456e0857b17Sopenharmony_ci    Want &SetParam(const std::string &key, bool value);
457e0857b17Sopenharmony_ci
458e0857b17Sopenharmony_ci    /**
459e0857b17Sopenharmony_ci     * @description: Sets a parameter value of the boolean array type.
460e0857b17Sopenharmony_ci     * @param key   Indicates the key matching the parameter.
461e0857b17Sopenharmony_ci     * @param value Indicates the boolean array of the parameter.
462e0857b17Sopenharmony_ci     * @return Returns this want object containing the parameter value.
463e0857b17Sopenharmony_ci     */
464e0857b17Sopenharmony_ci    Want &SetParam(const std::string &key, const std::vector<bool> &value);
465e0857b17Sopenharmony_ci
466e0857b17Sopenharmony_ci    /**
467e0857b17Sopenharmony_ci     * @description: Obtains a byte-type value matching the given key.
468e0857b17Sopenharmony_ci     * @param key   Indicates the key of WantParams.
469e0857b17Sopenharmony_ci     * @param defaultValue  Indicates the default byte-type value.
470e0857b17Sopenharmony_ci     * @return Returns the byte-type value of the parameter matching the given key;
471e0857b17Sopenharmony_ci     * returns the default value if the key does not exist.
472e0857b17Sopenharmony_ci     */
473e0857b17Sopenharmony_ci    byte GetByteParam(const std::string &key, byte defaultValue) const;
474e0857b17Sopenharmony_ci
475e0857b17Sopenharmony_ci    /**
476e0857b17Sopenharmony_ci     * @description: Obtains a byte-type array matching the given key.
477e0857b17Sopenharmony_ci     * @param key   Indicates the key of WantParams.
478e0857b17Sopenharmony_ci     * @return Returns the byte-type array of the parameter matching the given key;
479e0857b17Sopenharmony_ci     * returns null if the key does not exist.
480e0857b17Sopenharmony_ci     */
481e0857b17Sopenharmony_ci    std::vector<byte> GetByteArrayParam(const std::string &key) const;
482e0857b17Sopenharmony_ci
483e0857b17Sopenharmony_ci    /**
484e0857b17Sopenharmony_ci     * @description: Sets a parameter value of the byte type.
485e0857b17Sopenharmony_ci     * @param key   Indicates the key matching the parameter.
486e0857b17Sopenharmony_ci     * @param value Indicates the byte-type value of the parameter.
487e0857b17Sopenharmony_ci     * @return Returns this Want object containing the parameter value.
488e0857b17Sopenharmony_ci     */
489e0857b17Sopenharmony_ci    Want &SetParam(const std::string &key, byte value);
490e0857b17Sopenharmony_ci
491e0857b17Sopenharmony_ci    /**
492e0857b17Sopenharmony_ci     * @description: Sets a parameter value of the byte array type.
493e0857b17Sopenharmony_ci     * @param key   Indicates the key matching the parameter.
494e0857b17Sopenharmony_ci     * @param value Indicates the byte array of the parameter.
495e0857b17Sopenharmony_ci     * @return Returns this Want object containing the parameter value.
496e0857b17Sopenharmony_ci     */
497e0857b17Sopenharmony_ci    Want &SetParam(const std::string &key, const std::vector<byte> &value);
498e0857b17Sopenharmony_ci
499e0857b17Sopenharmony_ci    /**
500e0857b17Sopenharmony_ci     * @description: Obtains a char value matching the given key.
501e0857b17Sopenharmony_ci     * @param key   Indicates the key of wnatParams.
502e0857b17Sopenharmony_ci     * @param value Indicates the default char value.
503e0857b17Sopenharmony_ci     * @return Returns the char value of the parameter matching the given key;
504e0857b17Sopenharmony_ci     * returns the default value if the key does not exist.
505e0857b17Sopenharmony_ci     */
506e0857b17Sopenharmony_ci    zchar GetCharParam(const std::string &key, zchar defaultValue) const;
507e0857b17Sopenharmony_ci
508e0857b17Sopenharmony_ci    /**
509e0857b17Sopenharmony_ci     * @description: Obtains a char array matching the given key.
510e0857b17Sopenharmony_ci     * @param key   Indicates the key of wantParams.
511e0857b17Sopenharmony_ci     * @return Returns the char array of the parameter matching the given key;
512e0857b17Sopenharmony_ci     * returns null if the key does not exist.
513e0857b17Sopenharmony_ci     */
514e0857b17Sopenharmony_ci    std::vector<zchar> GetCharArrayParam(const std::string &key) const;
515e0857b17Sopenharmony_ci
516e0857b17Sopenharmony_ci    /**
517e0857b17Sopenharmony_ci     * @description: Sets a parameter value of the char type.
518e0857b17Sopenharmony_ci     * @param key   Indicates the key of wantParams.
519e0857b17Sopenharmony_ci     * @param value Indicates the char value of the parameter.
520e0857b17Sopenharmony_ci     * @return Returns this want object containing the parameter value.
521e0857b17Sopenharmony_ci     */
522e0857b17Sopenharmony_ci    Want &SetParam(const std::string &key, zchar value);
523e0857b17Sopenharmony_ci
524e0857b17Sopenharmony_ci    /**
525e0857b17Sopenharmony_ci     * @description: Sets a parameter value of the char array type.
526e0857b17Sopenharmony_ci     * @param key   Indicates the key of wantParams.
527e0857b17Sopenharmony_ci     * @param value Indicates the char array of the parameter.
528e0857b17Sopenharmony_ci     * @return Returns this want object containing the parameter value.
529e0857b17Sopenharmony_ci     */
530e0857b17Sopenharmony_ci    Want &SetParam(const std::string &key, const std::vector<zchar> &value);
531e0857b17Sopenharmony_ci
532e0857b17Sopenharmony_ci    /**
533e0857b17Sopenharmony_ci     * @description: Obtains an int value matching the given key.
534e0857b17Sopenharmony_ci     * @param key   Indicates the key of wantParams.
535e0857b17Sopenharmony_ci     * @param value Indicates the default int value.
536e0857b17Sopenharmony_ci     * @return Returns the int value of the parameter matching the given key;
537e0857b17Sopenharmony_ci     * returns the default value if the key does not exist.
538e0857b17Sopenharmony_ci     */
539e0857b17Sopenharmony_ci    int GetIntParam(const std::string &key, int defaultValue) const;
540e0857b17Sopenharmony_ci
541e0857b17Sopenharmony_ci    /**
542e0857b17Sopenharmony_ci     * @description: Obtains an int array matching the given key.
543e0857b17Sopenharmony_ci     * @param key   Indicates the key of wantParams.
544e0857b17Sopenharmony_ci     * @return Returns the int array of the parameter matching the given key;
545e0857b17Sopenharmony_ci     * returns null if the key does not exist.
546e0857b17Sopenharmony_ci     */
547e0857b17Sopenharmony_ci    std::vector<int> GetIntArrayParam(const std::string &key) const;
548e0857b17Sopenharmony_ci
549e0857b17Sopenharmony_ci    /**
550e0857b17Sopenharmony_ci     * @description: Sets a parameter value of the int type.
551e0857b17Sopenharmony_ci     * @param key   Indicates the key matching the parameter.
552e0857b17Sopenharmony_ci     * @param value Indicates the int value of the parameter.
553e0857b17Sopenharmony_ci     * @return Returns this Want object containing the parameter value.
554e0857b17Sopenharmony_ci     */
555e0857b17Sopenharmony_ci    Want &SetParam(const std::string &key, int value);
556e0857b17Sopenharmony_ci
557e0857b17Sopenharmony_ci    /**
558e0857b17Sopenharmony_ci     * @description: Sets a parameter value of the int array type.
559e0857b17Sopenharmony_ci     * @param key   Indicates the key matching the parameter.
560e0857b17Sopenharmony_ci     * @param value Indicates the int array of the parameter.
561e0857b17Sopenharmony_ci     * @return Returns this Want object containing the parameter value.
562e0857b17Sopenharmony_ci     */
563e0857b17Sopenharmony_ci    Want &SetParam(const std::string &key, const std::vector<int> &value);
564e0857b17Sopenharmony_ci
565e0857b17Sopenharmony_ci    /**
566e0857b17Sopenharmony_ci     * @description: Obtains a double value matching the given key.
567e0857b17Sopenharmony_ci     * @param key   Indicates the key of wantParams.
568e0857b17Sopenharmony_ci     * @param defaultValue  Indicates the default double value.
569e0857b17Sopenharmony_ci     * @return Returns the double value of the parameter matching the given key;
570e0857b17Sopenharmony_ci     * returns the default value if the key does not exist.
571e0857b17Sopenharmony_ci     */
572e0857b17Sopenharmony_ci    double GetDoubleParam(const std::string &key, double defaultValue) const;
573e0857b17Sopenharmony_ci
574e0857b17Sopenharmony_ci    /**
575e0857b17Sopenharmony_ci     * @description: Obtains a double array matching the given key.
576e0857b17Sopenharmony_ci     * @param key   Indicates the key of WantParams.
577e0857b17Sopenharmony_ci     * @return Returns the double array of the parameter matching the given key;
578e0857b17Sopenharmony_ci     * returns null if the key does not exist.
579e0857b17Sopenharmony_ci     */
580e0857b17Sopenharmony_ci    std::vector<double> GetDoubleArrayParam(const std::string &key) const;
581e0857b17Sopenharmony_ci
582e0857b17Sopenharmony_ci    /**
583e0857b17Sopenharmony_ci     * @description: Sets a parameter value of the double type.
584e0857b17Sopenharmony_ci     * @param key   Indicates the key matching the parameter.
585e0857b17Sopenharmony_ci     * @param value Indicates the int value of the parameter.
586e0857b17Sopenharmony_ci     * @return Returns this Want object containing the parameter value.
587e0857b17Sopenharmony_ci     */
588e0857b17Sopenharmony_ci    Want &SetParam(const std::string &key, double value);
589e0857b17Sopenharmony_ci
590e0857b17Sopenharmony_ci    /**
591e0857b17Sopenharmony_ci     * @description: Sets a parameter value of the double array type.
592e0857b17Sopenharmony_ci     * @param key   Indicates the key matching the parameter.
593e0857b17Sopenharmony_ci     * @param value Indicates the double array of the parameter.
594e0857b17Sopenharmony_ci     * @return Returns this want object containing the parameter value.
595e0857b17Sopenharmony_ci     */
596e0857b17Sopenharmony_ci    Want &SetParam(const std::string &key, const std::vector<double> &value);
597e0857b17Sopenharmony_ci
598e0857b17Sopenharmony_ci    /**
599e0857b17Sopenharmony_ci     * @description: Obtains a float value matching the given key.
600e0857b17Sopenharmony_ci     * @param key   Indicates the key of wnatParams.
601e0857b17Sopenharmony_ci     * @param value Indicates the default float value.
602e0857b17Sopenharmony_ci     * @return Returns the float value of the parameter matching the given key;
603e0857b17Sopenharmony_ci     * returns the default value if the key does not exist.
604e0857b17Sopenharmony_ci     */
605e0857b17Sopenharmony_ci    float GetFloatParam(const std::string &key, float defaultValue) const;
606e0857b17Sopenharmony_ci
607e0857b17Sopenharmony_ci    /**
608e0857b17Sopenharmony_ci     * @description: Obtains a float array matching the given key.
609e0857b17Sopenharmony_ci     * @param key Indicates the key of WantParams.
610e0857b17Sopenharmony_ci     * @return Obtains a float array matching the given key.
611e0857b17Sopenharmony_ci     */
612e0857b17Sopenharmony_ci    std::vector<float> GetFloatArrayParam(const std::string &key) const;
613e0857b17Sopenharmony_ci
614e0857b17Sopenharmony_ci    /**
615e0857b17Sopenharmony_ci     * @description: Sets a parameter value of the float type.
616e0857b17Sopenharmony_ci     * @param key Indicates the key matching the parameter.
617e0857b17Sopenharmony_ci     * @param value Indicates the byte-type value of the parameter.
618e0857b17Sopenharmony_ci     * @return Returns this Want object containing the parameter value.
619e0857b17Sopenharmony_ci     */
620e0857b17Sopenharmony_ci    Want &SetParam(const std::string &key, float value);
621e0857b17Sopenharmony_ci
622e0857b17Sopenharmony_ci    /**
623e0857b17Sopenharmony_ci     * @description: Sets a parameter value of the float array type.
624e0857b17Sopenharmony_ci     * @param key Indicates the key matching the parameter.
625e0857b17Sopenharmony_ci     * @param value Indicates the byte-type value of the parameter.
626e0857b17Sopenharmony_ci     * @return Returns this Want object containing the parameter value.
627e0857b17Sopenharmony_ci     */
628e0857b17Sopenharmony_ci    Want &SetParam(const std::string &key, const std::vector<float> &value);
629e0857b17Sopenharmony_ci
630e0857b17Sopenharmony_ci    /**
631e0857b17Sopenharmony_ci     * @description: Obtains a long value matching the given key.
632e0857b17Sopenharmony_ci     * @param key Indicates the key of wantParams.
633e0857b17Sopenharmony_ci     * @param value Indicates the default long value.
634e0857b17Sopenharmony_ci     * @return Returns the long value of the parameter matching the given key;
635e0857b17Sopenharmony_ci     * returns the default value if the key does not exist.
636e0857b17Sopenharmony_ci     */
637e0857b17Sopenharmony_ci    long GetLongParam(const std::string &key, long defaultValue) const;
638e0857b17Sopenharmony_ci
639e0857b17Sopenharmony_ci    /**
640e0857b17Sopenharmony_ci     * @description: Obtains a long array matching the given key.
641e0857b17Sopenharmony_ci     * @param key Indicates the key of wantParams.
642e0857b17Sopenharmony_ci     * @return Returns the long array of the parameter matching the given key;
643e0857b17Sopenharmony_ci     * returns null if the key does not exist.
644e0857b17Sopenharmony_ci     */
645e0857b17Sopenharmony_ci    std::vector<long> GetLongArrayParam(const std::string &key) const;
646e0857b17Sopenharmony_ci
647e0857b17Sopenharmony_ci    Want &SetParam(const std::string &key, long long value);
648e0857b17Sopenharmony_ci
649e0857b17Sopenharmony_ci    /**
650e0857b17Sopenharmony_ci     * @description: Sets a parameter value of the long type.
651e0857b17Sopenharmony_ci     * @param key Indicates the key matching the parameter.
652e0857b17Sopenharmony_ci     * @param value Indicates the byte-type value of the parameter.
653e0857b17Sopenharmony_ci     * @return Returns this Want object containing the parameter value.
654e0857b17Sopenharmony_ci     */
655e0857b17Sopenharmony_ci    Want &SetParam(const std::string &key, long value);
656e0857b17Sopenharmony_ci
657e0857b17Sopenharmony_ci    /**
658e0857b17Sopenharmony_ci     * @description: Sets a parameter value of the long array type.
659e0857b17Sopenharmony_ci     * @param key Indicates the key matching the parameter.
660e0857b17Sopenharmony_ci     * @param value Indicates the byte-type value of the parameter.
661e0857b17Sopenharmony_ci     * @return Returns this Want object containing the parameter value.
662e0857b17Sopenharmony_ci     */
663e0857b17Sopenharmony_ci    Want &SetParam(const std::string &key, const std::vector<long> &value);
664e0857b17Sopenharmony_ci
665e0857b17Sopenharmony_ci    /**
666e0857b17Sopenharmony_ci     * @description: a short value matching the given key.
667e0857b17Sopenharmony_ci     * @param key Indicates the key of wantParams.
668e0857b17Sopenharmony_ci     * @param defaultValue Indicates the default short value.
669e0857b17Sopenharmony_ci     * @return Returns the short value of the parameter matching the given key;
670e0857b17Sopenharmony_ci     * returns the default value if the key does not exist.
671e0857b17Sopenharmony_ci     */
672e0857b17Sopenharmony_ci    short GetShortParam(const std::string &key, short defaultValue) const;
673e0857b17Sopenharmony_ci
674e0857b17Sopenharmony_ci    /**
675e0857b17Sopenharmony_ci     * @description: Obtains a short array matching the given key.
676e0857b17Sopenharmony_ci     * @param key Indicates the key of wantParams.
677e0857b17Sopenharmony_ci     * @return Returns the short array of the parameter matching the given key;
678e0857b17Sopenharmony_ci     * returns null if the key does not exist.
679e0857b17Sopenharmony_ci     */
680e0857b17Sopenharmony_ci    std::vector<short> GetShortArrayParam(const std::string &key) const;
681e0857b17Sopenharmony_ci
682e0857b17Sopenharmony_ci    /**
683e0857b17Sopenharmony_ci     * @description: Sets a parameter value of the short type.
684e0857b17Sopenharmony_ci     * @param key Indicates the key matching the parameter.
685e0857b17Sopenharmony_ci     * @param value Indicates the byte-type value of the parameter.
686e0857b17Sopenharmony_ci     * @return Returns this Want object containing the parameter value.
687e0857b17Sopenharmony_ci     */
688e0857b17Sopenharmony_ci    Want &SetParam(const std::string &key, short value);
689e0857b17Sopenharmony_ci
690e0857b17Sopenharmony_ci    /**
691e0857b17Sopenharmony_ci     * @description: Sets a parameter value of the short array type.
692e0857b17Sopenharmony_ci     * @param key Indicates the key matching the parameter.
693e0857b17Sopenharmony_ci     * @param value Indicates the byte-type value of the parameter.
694e0857b17Sopenharmony_ci     * @return Returns this Want object containing the parameter value.
695e0857b17Sopenharmony_ci     */
696e0857b17Sopenharmony_ci    Want &SetParam(const std::string &key, const std::vector<short> &value);
697e0857b17Sopenharmony_ci
698e0857b17Sopenharmony_ci    /**
699e0857b17Sopenharmony_ci     * @description: Obtains a string value matching the given key.
700e0857b17Sopenharmony_ci     * @param key Indicates the key of wantParams.
701e0857b17Sopenharmony_ci     * @return Returns the string value of the parameter matching the given key;
702e0857b17Sopenharmony_ci     * returns null if the key does not exist.
703e0857b17Sopenharmony_ci     */
704e0857b17Sopenharmony_ci    std::string GetStringParam(const std::string &key) const;
705e0857b17Sopenharmony_ci
706e0857b17Sopenharmony_ci    /**
707e0857b17Sopenharmony_ci     * @description: Obtains a string array matching the given key.
708e0857b17Sopenharmony_ci     * @param key Indicates the key of wantParams.
709e0857b17Sopenharmony_ci     * @return Returns the string array of the parameter matching the given key;
710e0857b17Sopenharmony_ci     * returns null if the key does not exist.
711e0857b17Sopenharmony_ci     */
712e0857b17Sopenharmony_ci    std::vector<std::string> GetStringArrayParam(const std::string &key) const;
713e0857b17Sopenharmony_ci
714e0857b17Sopenharmony_ci    /**
715e0857b17Sopenharmony_ci     * @description: Sets a parameter value of the string type.
716e0857b17Sopenharmony_ci     * @param key Indicates the key matching the parameter.
717e0857b17Sopenharmony_ci     * @param value Indicates the byte-type value of the parameter.
718e0857b17Sopenharmony_ci     * @return Returns this Want object containing the parameter value.
719e0857b17Sopenharmony_ci     */
720e0857b17Sopenharmony_ci    Want &SetParam(const std::string &key, const std::string &value);
721e0857b17Sopenharmony_ci
722e0857b17Sopenharmony_ci    /**
723e0857b17Sopenharmony_ci     * @description: Sets a parameter value of the string array type.
724e0857b17Sopenharmony_ci     * @param key Indicates the key matching the parameter.
725e0857b17Sopenharmony_ci     * @param value Indicates the byte-type value of the parameter.
726e0857b17Sopenharmony_ci     * @return Returns this Want object containing the parameter value.
727e0857b17Sopenharmony_ci     */
728e0857b17Sopenharmony_ci    Want &SetParam(const std::string &key, const std::vector<std::string> &value);
729e0857b17Sopenharmony_ci
730e0857b17Sopenharmony_ci    /**
731e0857b17Sopenharmony_ci     * @description: Checks whether a Want contains the parameter matching a given key.
732e0857b17Sopenharmony_ci     * @param key Indicates the key.
733e0857b17Sopenharmony_ci     * @return Returns true if the Want contains the parameter; returns false otherwise.
734e0857b17Sopenharmony_ci     */
735e0857b17Sopenharmony_ci    bool HasParameter(const std::string &key) const;
736e0857b17Sopenharmony_ci
737e0857b17Sopenharmony_ci    /**
738e0857b17Sopenharmony_ci     * @description: Replaces parameters in this Want object with those in the given WantParams object.
739e0857b17Sopenharmony_ci     * @param wantParams Indicates the WantParams object containing the new parameters.
740e0857b17Sopenharmony_ci     * @return Returns this Want object containing the new parameters.
741e0857b17Sopenharmony_ci     */
742e0857b17Sopenharmony_ci    Want *ReplaceParams(WantParams &wantParams);
743e0857b17Sopenharmony_ci
744e0857b17Sopenharmony_ci    /**
745e0857b17Sopenharmony_ci     * @description: Replaces parameters in this Want object with those in the given Want object.
746e0857b17Sopenharmony_ci     * @param want Indicates the Want object containing the new parameters.
747e0857b17Sopenharmony_ci     * @return Returns this Want object containing the new parameters.
748e0857b17Sopenharmony_ci     */
749e0857b17Sopenharmony_ci    Want *ReplaceParams(Want &want);
750e0857b17Sopenharmony_ci
751e0857b17Sopenharmony_ci    /**
752e0857b17Sopenharmony_ci     * @description: Removes the parameter matching the given key.
753e0857b17Sopenharmony_ci     * @param key Indicates the key matching the parameter to be removed.
754e0857b17Sopenharmony_ci     */
755e0857b17Sopenharmony_ci    void RemoveParam(const std::string &key);
756e0857b17Sopenharmony_ci
757e0857b17Sopenharmony_ci    /**
758e0857b17Sopenharmony_ci     * @description: Gets the description of an operation in a Want.
759e0857b17Sopenharmony_ci     * @return Returns the operation included in this Want.
760e0857b17Sopenharmony_ci     */
761e0857b17Sopenharmony_ci    Operation GetOperation() const;
762e0857b17Sopenharmony_ci
763e0857b17Sopenharmony_ci    /**
764e0857b17Sopenharmony_ci     * @description: Sets the description of an operation in a Want.
765e0857b17Sopenharmony_ci     * @param operation Indicates the operation description.
766e0857b17Sopenharmony_ci     */
767e0857b17Sopenharmony_ci    void SetOperation(const OHOS::AAFwk::Operation &operation);
768e0857b17Sopenharmony_ci
769e0857b17Sopenharmony_ci    /**
770e0857b17Sopenharmony_ci     * @description: Sets the description of an operation in a Want.
771e0857b17Sopenharmony_ci     * @param want Indicates the Want object to compare.
772e0857b17Sopenharmony_ci     * @return Returns true if the operation components of the two objects are equal; returns false otherwise.
773e0857b17Sopenharmony_ci     */
774e0857b17Sopenharmony_ci    bool OperationEquals(const Want &want);
775e0857b17Sopenharmony_ci
776e0857b17Sopenharmony_ci    bool IsEquals(const Want &want);
777e0857b17Sopenharmony_ci
778e0857b17Sopenharmony_ci    /**
779e0857b17Sopenharmony_ci     * @description: Creates a Want object that contains only the operation component of this Want.
780e0857b17Sopenharmony_ci     * @return Returns the created Want object.
781e0857b17Sopenharmony_ci     */
782e0857b17Sopenharmony_ci    Want *CloneOperation();
783e0857b17Sopenharmony_ci
784e0857b17Sopenharmony_ci    /**
785e0857b17Sopenharmony_ci     * @description: Marshals a Want into a Parcel.
786e0857b17Sopenharmony_ci     * Fields in the Want are marshalled separately. If any field fails to be marshalled, false is returned.
787e0857b17Sopenharmony_ci     * @param parcel Indicates the Parcel object for marshalling.
788e0857b17Sopenharmony_ci     * @return Returns true if the marshalling is successful; returns false otherwise.
789e0857b17Sopenharmony_ci     */
790e0857b17Sopenharmony_ci    virtual bool Marshalling(Parcel &parcel) const;
791e0857b17Sopenharmony_ci
792e0857b17Sopenharmony_ci    /**
793e0857b17Sopenharmony_ci     * @description: Unmarshals a Want from a Parcel.
794e0857b17Sopenharmony_ci     * Fields in the Want are unmarshalled separately. If any field fails to be unmarshalled, false is returned.
795e0857b17Sopenharmony_ci     * @param parcel Indicates the Parcel object for unmarshalling.
796e0857b17Sopenharmony_ci     * @return Returns true if the unmarshalling is successful; returns false otherwise.
797e0857b17Sopenharmony_ci     */
798e0857b17Sopenharmony_ci    static Want *Unmarshalling(Parcel &parcel);
799e0857b17Sopenharmony_ci
800e0857b17Sopenharmony_ci    void DumpInfo(int level) const;
801e0857b17Sopenharmony_ci
802e0857b17Sopenharmony_ci    std::string ToString() const;
803e0857b17Sopenharmony_ci
804e0857b17Sopenharmony_ci    static Want *FromString(std::string &string);
805e0857b17Sopenharmony_ci
806e0857b17Sopenharmony_ci    /**
807e0857b17Sopenharmony_ci    * @description: Sets a device id in a Want.
808e0857b17Sopenharmony_ci    * @param deviceId Indicates the device id to set.
809e0857b17Sopenharmony_ci    * @return Returns this Want object containing the flag.
810e0857b17Sopenharmony_ci    */
811e0857b17Sopenharmony_ci    Want &SetDeviceId(const std::string &deviceId);
812e0857b17Sopenharmony_ci
813e0857b17Sopenharmony_ci    std::string GetDeviceId() const;
814e0857b17Sopenharmony_ci
815e0857b17Sopenharmony_ci    /**
816e0857b17Sopenharmony_ci     * @description: Sets an ModuleName object in a Want.
817e0857b17Sopenharmony_ci     * @param moduleName Indicates the ModuleName description.
818e0857b17Sopenharmony_ci     * @return Returns this Want object containing the ModuleName.
819e0857b17Sopenharmony_ci     */
820e0857b17Sopenharmony_ci    Want &SetModuleName(const std::string &moduleName);
821e0857b17Sopenharmony_ci
822e0857b17Sopenharmony_ci    /**
823e0857b17Sopenharmony_ci     * @description: Obtains the description of the ModuleName object in a Want.
824e0857b17Sopenharmony_ci     * @return Returns the ModuleName description in the Want.
825e0857b17Sopenharmony_ci     */
826e0857b17Sopenharmony_ci    std::string GetModuleName() const;
827e0857b17Sopenharmony_ci
828e0857b17Sopenharmony_ci    void CloseAllFd();
829e0857b17Sopenharmony_ci
830e0857b17Sopenharmony_ci    void RemoveAllFd();
831e0857b17Sopenharmony_ci
832e0857b17Sopenharmony_ci    void DupAllFd();
833e0857b17Sopenharmony_ci
834e0857b17Sopenharmony_ci    void SetEntities(const std::vector<std::string> &entities);
835e0857b17Sopenharmony_cipublic:
836e0857b17Sopenharmony_ci    // action definition
837e0857b17Sopenharmony_ci    static const std::string ACTION_PLAY;
838e0857b17Sopenharmony_ci    static const std::string ACTION_HOME;
839e0857b17Sopenharmony_ci
840e0857b17Sopenharmony_ci    // entity definition
841e0857b17Sopenharmony_ci    static const std::string ENTITY_HOME;
842e0857b17Sopenharmony_ci    static const std::string ENTITY_VIDEO;
843e0857b17Sopenharmony_ci    static const std::string FLAG_HOME_INTENT_FROM_SYSTEM;
844e0857b17Sopenharmony_ci    static const std::string ENTITY_MUSIC;
845e0857b17Sopenharmony_ci    static const std::string ENTITY_EMAIL;
846e0857b17Sopenharmony_ci    static const std::string ENTITY_CONTACTS;
847e0857b17Sopenharmony_ci    static const std::string ENTITY_MAPS;
848e0857b17Sopenharmony_ci    static const std::string ENTITY_BROWSER;
849e0857b17Sopenharmony_ci    static const std::string ENTITY_CALENDAR;
850e0857b17Sopenharmony_ci    static const std::string ENTITY_MESSAGING;
851e0857b17Sopenharmony_ci    static const std::string ENTITY_FILES;
852e0857b17Sopenharmony_ci    static const std::string ENTITY_GALLERY;
853e0857b17Sopenharmony_ci
854e0857b17Sopenharmony_ci    static constexpr int HEX_STRING_BUF_LEN = 36;
855e0857b17Sopenharmony_ci    static constexpr int HEX_STRING_LEN = 10;
856e0857b17Sopenharmony_ci
857e0857b17Sopenharmony_ci    // reserved param definition
858e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_WINDOW_MODE;
859e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_DISPLAY_ID;
860e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_WITH_ANIMATION;
861e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_WINDOW_FOCUSED;
862e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_WINDOW_LEFT;
863e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_WINDOW_TOP;
864e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_WINDOW_WIDTH;
865e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_WINDOW_HEIGHT;
866e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_CALLER_TOKEN;
867e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_CALLER_BUNDLE_NAME;
868e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_CALLER_ABILITY_NAME;
869e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_CALLER_NATIVE_NAME;
870e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_CALLER_APP_ID;
871e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_CALLER_APP_IDENTIFIER;
872e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_CALLER_UID;
873e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_CALLER_PID;
874e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_FOR_RESULT;
875e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_CALL_TO_FOREGROUND;
876e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_START_RECENT;
877e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_REQUEST_PROC_CODE;
878e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_REQUEST_TOKEN_CODE;
879e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_ABILITY_INFO_CALLBACK;
880e0857b17Sopenharmony_ci    static const std::string PARAM_RESV_START_TIME;
881e0857b17Sopenharmony_ci    static const std::string PARAM_ABILITY_ACQUIRE_SHARE_DATA;
882e0857b17Sopenharmony_ci    static const std::string PARAM_ABILITY_RECOVERY_RESTART;
883e0857b17Sopenharmony_ci    static const std::string PARAM_ABILITY_URITYPES;
884e0857b17Sopenharmony_ci    static const std::string PARAM_ABILITY_APPINFOS;
885e0857b17Sopenharmony_ci    static const std::string PARAM_ASSERT_FAULT_SESSION_ID;
886e0857b17Sopenharmony_ci    // module name string
887e0857b17Sopenharmony_ci    static const std::string PARAM_MODULE_NAME;
888e0857b17Sopenharmony_ci
889e0857b17Sopenharmony_ci    // parameter key
890e0857b17Sopenharmony_ci    static const std::string PARAM_BACK_TO_OTHER_MISSION_STACK;
891e0857b17Sopenharmony_ci
892e0857b17Sopenharmony_ci    // application auto startup launch reason
893e0857b17Sopenharmony_ci    static const std::string PARAM_APP_AUTO_STARTUP_LAUNCH_REASON;
894e0857b17Sopenharmony_ci
895e0857b17Sopenharmony_ci    // app clone index
896e0857b17Sopenharmony_ci    static const std::string PARAM_APP_CLONE_INDEX_KEY;
897e0857b17Sopenharmony_ci    static const std::string APP_INSTANCE_KEY;
898e0857b17Sopenharmony_ci    static const std::string CREATE_APP_INSTANCE_KEY;
899e0857b17Sopenharmony_ci
900e0857b17Sopenharmony_ci    static const std::string PARAM_ATOMIC_SERVICE_PAGE_PATH;
901e0857b17Sopenharmony_ci    static const std::string PARAM_ATOMIC_SERVICE_ROUTER_NAME;
902e0857b17Sopenharmony_ci    static const std::string PARAM_ATOMIC_SERVICE_PAGE_SOURCE_FILE;
903e0857b17Sopenharmony_ci    static const std::string PARAM_ATOMIC_SERVICE_BUILD_FUNCTION;
904e0857b17Sopenharmony_ci    static const std::string PARAM_ATOMIC_SERVICE_SUB_PACKAGE_NAME;
905e0857b17Sopenharmony_ci
906e0857b17Sopenharmony_ciprivate:
907e0857b17Sopenharmony_ci    WantParams parameters_;
908e0857b17Sopenharmony_ci    Operation operation_;
909e0857b17Sopenharmony_ci
910e0857b17Sopenharmony_ci    static const std::string OCT_EQUALSTO;
911e0857b17Sopenharmony_ci    static const std::string OCT_SEMICOLON;
912e0857b17Sopenharmony_ci    static const std::string MIME_TYPE;
913e0857b17Sopenharmony_ci    static const std::string WANT_HEADER;
914e0857b17Sopenharmony_ci    static const std::string WANT_END;
915e0857b17Sopenharmony_ci
916e0857b17Sopenharmony_ci    // no object in parcel
917e0857b17Sopenharmony_ci    static constexpr int VALUE_NULL = -1;
918e0857b17Sopenharmony_ci    // object exist in parcel
919e0857b17Sopenharmony_ci    static constexpr int VALUE_OBJECT = 1;
920e0857b17Sopenharmony_ci
921e0857b17Sopenharmony_ciprivate:
922e0857b17Sopenharmony_ci    static bool ParseFlag(const std::string &content, Want &want);
923e0857b17Sopenharmony_ci    static std::string Decode(const std::string &str);
924e0857b17Sopenharmony_ci    static std::string Encode(const std::string &str);
925e0857b17Sopenharmony_ci    static bool ParseContent(const std::string &content, std::string &prop, std::string &value);
926e0857b17Sopenharmony_ci    static bool ParseUriInternal(const std::string &content, OHOS::AppExecFwk::ElementName &element, Want &want);
927e0857b17Sopenharmony_ci    static bool CheckUri(const std::string &uri);
928e0857b17Sopenharmony_ci    bool ReadFromParcel(Parcel &parcel);
929e0857b17Sopenharmony_ci    static bool CheckAndSetParameters(Want &want, const std::string &key, std::string &prop, const std::string &value);
930e0857b17Sopenharmony_ci    Uri GetLowerCaseScheme(const Uri &uri);
931e0857b17Sopenharmony_ci    void ToUriStringInner(std::string &uriString) const;
932e0857b17Sopenharmony_ci    nlohmann::json ToJson() const;
933e0857b17Sopenharmony_ci    bool ReadFromJson(nlohmann::json &wantJson);
934e0857b17Sopenharmony_ci    void UriStringAppendParam(std::string &uriString) const;
935e0857b17Sopenharmony_ci    bool WriteUri(Parcel &parcel) const;
936e0857b17Sopenharmony_ci    bool WriteEntities(Parcel &parcel) const;
937e0857b17Sopenharmony_ci    bool WriteElement(Parcel &parcel) const;
938e0857b17Sopenharmony_ci    bool WriteParameters(Parcel &parcel) const;
939e0857b17Sopenharmony_ci    bool ReadUri(Parcel &parcel);
940e0857b17Sopenharmony_ci    bool ReadEntities(Parcel &parcel);
941e0857b17Sopenharmony_ci    bool ReadElement(Parcel &parcel);
942e0857b17Sopenharmony_ci    bool ReadParameters(Parcel &parcel);
943e0857b17Sopenharmony_ci};
944e0857b17Sopenharmony_ci}  // namespace AAFwk
945e0857b17Sopenharmony_ci}  // namespace OHOS
946e0857b17Sopenharmony_ci
947e0857b17Sopenharmony_ci#endif  // OHOS_ABILITY_BASE_WANT_H
948