1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef OHOS_DISTRIBUTEDWANT_WANT_H
17#define OHOS_DISTRIBUTEDWANT_WANT_H
18
19#include <algorithm>
20#include <string>
21#include <vector>
22#include "distributedWant/distributed_operation.h"
23#include "distributedWant/distributed_want_params.h"
24#include "element_name.h"
25#include "nlohmann/json.hpp"
26#include "parcel.h"
27#include "uri.h"
28#include "want.h"
29
30using DistributedOperation = OHOS::DistributedSchedule::DistributedOperation;
31
32namespace OHOS {
33namespace DistributedSchedule {
34class DistributedWant final : public Parcelable {
35public:
36    /**
37     * Indicates the grant to perform read operations on the URI.
38     */
39    static constexpr unsigned int FLAG_AUTH_READ_URI_PERMISSION = 0x00000001;
40    /**
41     * Indicates the grant to perform write operations on the URI.
42     */
43    static constexpr unsigned int FLAG_AUTH_WRITE_URI_PERMISSION = 0x00000002;
44    /**
45     * Returns the result to the source ability.
46     */
47    static constexpr unsigned int FLAG_ABILITY_FORWARD_RESULT = 0x00000004;
48    /**
49     * Determines whether an ability on the local device can be migrated to a remote device.
50     */
51    static constexpr unsigned int FLAG_ABILITY_CONTINUATION = 0x00000008;
52    /**
53     * Specifies whether a component does not belong to OHOS.
54     */
55    static constexpr unsigned int FLAG_NOT_OHOS_COMPONENT = 0x00000010;
56    /**
57     * Specifies whether an ability is started.
58     */
59    static constexpr unsigned int FLAG_ABILITY_FORM_ENABLED = 0x00000020;
60    /**
61     * Indicates the grant for possible persisting on the URI.
62     */
63    static constexpr unsigned int FLAG_AUTH_PERSISTABLE_URI_PERMISSION = 0x00000040;
64    /**
65     * Returns the result to the source ability slice.
66     */
67    static constexpr unsigned int FLAG_AUTH_PREFIX_URI_PERMISSION = 0x00000080;
68    /**
69     * Supports multi-device startup in the distributed scheduling system.
70     */
71    static constexpr unsigned int FLAG_ABILITYSLICE_MULTI_DEVICE = 0x00000100;
72    /**
73     * Indicates that an ability using the Service template is started regardless of whether the host application has
74     * been started.
75     */
76    static constexpr unsigned int FLAG_START_FOREGROUND_ABILITY = 0x00000200;
77
78    /**
79     * Indicates the continuation is reversible.
80     */
81    static constexpr unsigned int FLAG_ABILITY_CONTINUATION_REVERSIBLE = 0x00000400;
82
83    /**
84     * Install the specified ability if it's not installed.
85     */
86    static constexpr unsigned int FLAG_INSTALL_ON_DEMAND = 0x00000800;
87    /**
88     * Returns the result to the source ability slice.
89     */
90    static constexpr unsigned int FLAG_ABILITYSLICE_FORWARD_RESULT = 0x04000000;
91    /**
92     * Install the specifiedi ability with background mode if it's not installed.
93     */
94    static constexpr unsigned int FLAG_INSTALL_WITH_BACKGROUND_MODE = 0x80000000;
95
96    /**
97     * @description:  Default construcotr of DistributedWant class, which is used to initialzie flags and URI.
98     * @param None
99     * @return None
100     */
101    DistributedWant();
102
103    /**
104     * @description: Default deconstructor of DistributedWant class
105     * @param None
106     * @return None
107     */
108    ~DistributedWant();
109
110    /**
111     * @description: Copy construcotr of DistributedWant class, which is used to initialzie flags, URI, etc.
112     * @param want the source instance of DistributedWant.
113     * @return None
114     */
115    DistributedWant(const DistributedWant& want);
116    DistributedWant& operator=(const DistributedWant&);
117    DistributedWant(const AAFwk::Want& want);
118
119    /**
120     * @description: Sets a flag in a DistributedWant.
121     * @param flags Indicates the flag to set.
122     * @return Returns this DistributedWant object containing the flag.
123     */
124    DistributedWant& SetFlags(unsigned int flags);
125
126    /**
127     * @description: Obtains the description of flags in a DistributedWant.
128     * @return Returns the flag description in the DistributedWant.
129     */
130    unsigned int GetFlags() const;
131
132    /**
133     * @description: Adds a flag to a DistributedWant.
134     * @param flags Indicates the flag to add.
135     * @return Returns the DistributedWant object with the added flag.
136     */
137    DistributedWant& AddFlags(unsigned int flags);
138
139    /**
140     * @description: Removes the description of a flag from a DistributedWant.
141     * @param flags Indicates the flag to remove.
142     * @return Removes the description of a flag from a DistributedWant.
143     */
144    void RemoveFlags(unsigned int flag);
145
146    /**
147     * @description: Sets the bundleName and abilityName attributes for this DistributedWant object.
148     * @param bundleName Indicates the bundleName to set for the operation attribute in the DistributedWant.
149     * @param abilityName Indicates the abilityName to set for the operation attribute in the DistributedWant.
150     * @return Returns this DistributedWant object that contains the specified bundleName and abilityName attributes.
151     */
152    DistributedWant& SetElementName(const std::string& bundleName, const std::string& abilityName);
153
154    /**
155     * @description: Sets the bundleName and abilityName attributes for this DistributedWant object.
156     * @param deviceId Indicates the deviceId to set for the operation attribute in the DistributedWant.
157     * @param bundleName Indicates the bundleName to set for the operation attribute in the DistributedWant.
158     * @param abilityName Indicates the abilityName to set for the operation attribute in the DistributedWant.
159     * @return Returns this DistributedWant object that contains the specified bundleName and abilityName attributes.
160     */
161    DistributedWant& SetElementName(
162        const std::string& deviceId, const std::string& bundleName, const std::string& abilityName);
163
164    /**
165     * @description: Sets an ElementName object in a DistributedWant.
166     * @param element Indicates the ElementName description.
167     * @return Returns this DistributedWant object containing the ElementName
168     */
169    DistributedWant& SetElement(const OHOS::AppExecFwk::ElementName& element);
170
171    /**
172     * @description: Obtains the description of the ElementName object in a DistributedWant.
173     * @return Returns the ElementName description in the DistributedWant.
174     */
175    OHOS::AppExecFwk::ElementName GetElement() const;
176
177    /**
178     * @description: Obtains the description of a URI in a DistributedWant.
179     * @return Returns the URI description in the DistributedWant.
180     */
181    OHOS::Uri GetUri() const;
182
183    /**
184     * @description: Obtains the string representation of the URI in this DistributedWant.
185     * @return Returns the string of the URI.
186     */
187    std::string GetUriString() const;
188
189    /**
190     * @description: Sets the description of a URI in a DistributedWant.
191     * @param uri Indicates the URI description.
192     * @return Returns this DistributedWant object containing the URI.
193     */
194    DistributedWant& SetUri(const std::string& uri);
195
196    /**
197     * @description: Sets the description of a URI in a DistributedWant.
198     * @param uri Indicates the URI description.
199     * @return Returns this DistributedWant object containing the URI.
200     */
201    DistributedWant& SetUri(const OHOS::Uri& uri);
202
203    /**
204     * @description: Sets the description of a URI and a type in this DistributedWant.
205     * @param uri Indicates the URI description.
206     * @param type Indicates the type description.
207     * @return Returns the DistributedWant object containing the URI and the type by setting.
208     */
209    DistributedWant& SetUriAndType(const OHOS::Uri& uri, const std::string& type);
210
211    /**
212     * @description: Formats a specified URI.
213     * This method uses the Uri.getLowerCaseScheme() method to format a URI and then saves
214     * the formatted URI to this DistributedWant object.
215     * @param uri Indicates the string of URI to format.
216     * @return Returns this DistributedWant object that contains the formatted uri attribute.
217     */
218    DistributedWant& FormatUri(const std::string& uri);
219
220    /**
221     * @description: Formats a specified URI.
222     * This method uses the Uri.getLowerCaseScheme() method to format a URI and then saves
223     * the formatted URI to this DistributedWant object.
224     * @param uri Indicates the URI to format.
225     * @return Returns this DistributedWant object that contains the formatted URI attribute.
226     */
227    DistributedWant& FormatUri(const OHOS::Uri& uri);
228
229    /**
230     * @description: Obtains the description of an action in a DistributedWant.
231     * @return Returns a DistributedWant object that contains the action description.
232     */
233    std::string GetAction() const;
234
235    /**
236     * @description: Sets the description of an action in a DistributedWant.
237     * @param action Indicates the action description to set.
238     * @return Returns a DistributedWant object that contains the action description.
239     */
240    DistributedWant& SetAction(const std::string& action);
241
242    /**
243     * @description: Obtains the name of the specified bundle in a DistributedWant.
244     * @return Returns the specified bundle name in the DistributedWant.
245     */
246    std::string GetBundle() const;
247
248    /**
249     * @description: Sets a bundle name in this DistributedWant.
250     * If a bundle name is specified in a DistributedWant, the DistributedWant will match only
251     * the abilities in the specified bundle. You cannot use this method and
252     * setPicker(ohos.aafwk.content.DistributedWant) on the same DistributedWant.
253     * @param bundleName Indicates the bundle name to set.
254     * @return Returns a DistributedWant object containing the specified bundle name.
255     */
256    DistributedWant& SetBundle(const std::string& bundleName);
257
258    /**
259     * @description: Obtains the description of all entities in a DistributedWant
260     * @return Returns a set of entities
261     */
262    const std::vector<std::string>& GetEntities() const;
263
264    /**
265     * @description: Adds the description of an entity to a DistributedWant
266     * @param entity Indicates the entity description to add
267     * @return {DistributedWant} Returns this DistributedWant object containing the entity.
268     */
269    DistributedWant& AddEntity(const std::string& entity);
270
271    /**
272     * @description: Removes the description of an entity from a DistributedWant
273     * @param entity Indicates the entity description to remove.
274     * @return void
275     */
276    void RemoveEntity(const std::string& entity);
277
278    /**
279     * @description: Checks whether a DistributedWant contains the given entity
280     * @param entity Indicates the entity to check
281     * @return Returns true if the given entity is contained; returns false otherwise
282     */
283    bool HasEntity(const std::string& key) const;
284
285    /**
286     * @description: Obtains the number of entities in a DistributedWant
287     * @return Returns the entity quantity
288     */
289    int CountEntities();
290
291    /**
292     * @description: Obtains the description of the URI scheme in this DistributedWant.
293     * @return Returns the URI scheme description in this DistributedWant.
294     */
295    const std::string GetScheme() const;
296
297    /**
298     * @description: Obtains the description of the type in this DistributedWant
299     * @return Returns the type description in this DistributedWant
300     */
301    std::string GetType() const;
302
303    /**
304     * @description: Sets the description of a type in this DistributedWant
305     * @param type Indicates the type description
306     * @return Returns this DistributedWant object containing the type
307     */
308    DistributedWant& SetType(const std::string& type);
309
310    /**
311     * @description: clear the specific DistributedWant object.
312     * @param want Indicates the DistributedWant to clear
313     */
314    static void ClearWant(DistributedWant* want);
315
316    /**
317     * @description: Obtains the description of the DistributedWantParams object in a DistributedWant
318     * @return Returns the DistributedWantParams description in the DistributedWant
319     */
320    const DistributedWantParams& GetParams() const;
321
322    /**
323     * @description: Sets a DistributedWantParams object in a want.
324     * @param wantParams  Indicates the DistributedWantParams description.
325     * @return Returns this want object containing the DistributedWantParams.
326     */
327    DistributedWant& SetParams(const DistributedWantParams& wantParams);
328
329    /**
330     * @description: Obtains a bool-type value matching the given key.
331     * @param key   Indicates the key of DistributedWantParams.
332     * @param defaultValue  Indicates the default bool-type value.
333     * @return Returns the bool-type value of the parameter matching the given key;
334     * returns the default value if the key does not exist.
335     */
336    bool GetBoolParam(const std::string& key, bool defaultValue) const;
337
338    /**
339     * @description: Obtains a bool-type array matching the given key.
340     * @param key   Indicates the key of DistributedWantParams.
341     * @return Returns the bool-type array of the parameter matching the given key;
342     * returns null if the key does not exist.
343     */
344    std::vector<bool> GetBoolArrayParam(const std::string& key) const;
345
346    /**
347     * @description: Sets a parameter value of the IRemoteObject type.
348     * @param key   Indicates the key matching the parameter.
349     * @param value Indicates the IRemoteObject value of the parameter.
350     * @return Returns this want object containing the parameter value.
351     */
352    DistributedWant& SetParam(const std::string& key, const sptr<IRemoteObject>& remoteObject);
353
354    /**
355     * @description: Sets a parameter value of the boolean type.
356     * @param key   Indicates the key matching the parameter.
357     * @param value Indicates the boolean value of the parameter.
358     * @return Returns this DistributedWant object containing the parameter value.
359     */
360    DistributedWant& SetParam(const std::string& key, bool value);
361
362    /**
363     * @description: Sets a parameter value of the boolean array type.
364     * @param key   Indicates the key matching the parameter.
365     * @param value Indicates the boolean array of the parameter.
366     * @return Returns this DistributedWant object containing the parameter value.
367     */
368    DistributedWant& SetParam(const std::string& key, const std::vector<bool>& value);
369
370    /**
371     * @description: Obtains a byte-type value matching the given key.
372     * @param key   Indicates the key of DistributedWantParams.
373     * @param defaultValue  Indicates the default byte-type value.
374     * @return Returns the byte-type value of the parameter matching the given key;
375     * returns the default value if the key does not exist.
376     */
377    AAFwk::byte GetByteParam(const std::string& key, AAFwk::byte defaultValue) const;
378
379    /**
380     * @description: Obtains a byte-type array matching the given key.
381     * @param key   Indicates the key of DistributedWantParams.
382     * @return Returns the byte-type array of the parameter matching the given key;
383     * returns null if the key does not exist.
384     */
385    std::vector<AAFwk::byte> GetByteArrayParam(const std::string& key) const;
386
387    /**
388     * @description: Sets a parameter value of the byte type.
389     * @param key   Indicates the key matching the parameter.
390     * @param value Indicates the byte-type value of the parameter.
391     * @return Returns this DistributedWant object containing the parameter value.
392     */
393    DistributedWant& SetParam(const std::string& key, AAFwk::byte value);
394
395    /**
396     * @description: Sets a parameter value of the byte array type.
397     * @param key   Indicates the key matching the parameter.
398     * @param value Indicates the byte array of the parameter.
399     * @return Returns this DistributedWant object containing the parameter value.
400     */
401    DistributedWant& SetParam(const std::string& key, const std::vector<AAFwk::byte>& value);
402
403    /**
404     * @description: Obtains a char value matching the given key.
405     * @param key   Indicates the key of wnatParams.
406     * @param value Indicates the default char value.
407     * @return Returns the char value of the parameter matching the given key;
408     * returns the default value if the key does not exist.
409     */
410    AAFwk::zchar GetCharParam(const std::string& key, AAFwk::zchar defaultValue) const;
411
412    /**
413     * @description: Obtains a char array matching the given key.
414     * @param key   Indicates the key of DistributedWantParams.
415     * @return Returns the char array of the parameter matching the given key;
416     * returns null if the key does not exist.
417     */
418    std::vector<AAFwk::zchar> GetCharArrayParam(const std::string& key) const;
419
420    /**
421     * @description: Sets a parameter value of the char type.
422     * @param key   Indicates the key of DistributedWantParams.
423     * @param value Indicates the char value of the parameter.
424     * @return Returns this DistributedWant object containing the parameter value.
425     */
426    DistributedWant& SetParam(const std::string& key, AAFwk::zchar value);
427
428    /**
429     * @description: Sets a parameter value of the char array type.
430     * @param key   Indicates the key of DistributedWantParams.
431     * @param value Indicates the char array of the parameter.
432     * @return Returns this DistributedWant object containing the parameter value.
433     */
434    DistributedWant& SetParam(const std::string& key, const std::vector<AAFwk::zchar>& value);
435
436    /**
437     * @description: Obtains an int value matching the given key.
438     * @param key   Indicates the key of DistributedWantParams.
439     * @param value Indicates the default int value.
440     * @return Returns the int value of the parameter matching the given key;
441     * returns the default value if the key does not exist.
442     */
443    int GetIntParam(const std::string& key, int defaultValue) const;
444
445    /**
446     * @description: Obtains an int array matching the given key.
447     * @param key   Indicates the key of DistributedWantParams.
448     * @return Returns the int array of the parameter matching the given key;
449     * returns null if the key does not exist.
450     */
451    std::vector<int> GetIntArrayParam(const std::string& key) const;
452
453    /**
454     * @description: Sets a parameter value of the int type.
455     * @param key   Indicates the key matching the parameter.
456     * @param value Indicates the int value of the parameter.
457     * @return Returns this DistributedWant object containing the parameter value.
458     */
459    DistributedWant& SetParam(const std::string& key, int value);
460
461    /**
462     * @description: Sets a parameter value of the int array type.
463     * @param key   Indicates the key matching the parameter.
464     * @param value Indicates the int array of the parameter.
465     * @return Returns this DistributedWant object containing the parameter value.
466     */
467    DistributedWant& SetParam(const std::string& key, const std::vector<int>& value);
468
469    /**
470     * @description: Obtains a double value matching the given key.
471     * @param key   Indicates the key of DistributedWantParams.
472     * @param defaultValue  Indicates the default double value.
473     * @return Returns the double value of the parameter matching the given key;
474     * returns the default value if the key does not exist.
475     */
476    double GetDoubleParam(const std::string& key, double defaultValue) const;
477
478    /**
479     * @description: Obtains a double array matching the given key.
480     * @param key   Indicates the key of DistributedWantParams.
481     * @return Returns the double array of the parameter matching the given key;
482     * returns null if the key does not exist.
483     */
484    std::vector<double> GetDoubleArrayParam(const std::string& key) const;
485
486    /**
487     * @description: Sets a parameter value of the double type.
488     * @param key   Indicates the key matching the parameter.
489     * @param value Indicates the int value of the parameter.
490     * @return Returns this DistributedWant object containing the parameter value.
491     */
492    DistributedWant& SetParam(const std::string& key, double value);
493
494    /**
495     * @description: Sets a parameter value of the double array type.
496     * @param key   Indicates the key matching the parameter.
497     * @param value Indicates the double array of the parameter.
498     * @return Returns this DistributedWant object containing the parameter value.
499     */
500    DistributedWant& SetParam(const std::string& key, const std::vector<double>& value);
501
502    /**
503     * @description: Obtains a float value matching the given key.
504     * @param key   Indicates the key of wnatParams.
505     * @param value Indicates the default float value.
506     * @return Returns the float value of the parameter matching the given key;
507     * returns the default value if the key does not exist.
508     */
509    float GetFloatParam(const std::string& key, float defaultValue) const;
510
511    /**
512     * @description: Obtains a float array matching the given key.
513     * @param key Indicates the key of DistributedWantParams.
514     * @return Obtains a float array matching the given key.
515     */
516    std::vector<float> GetFloatArrayParam(const std::string& key) const;
517
518    /**
519     * @description: Sets a parameter value of the float type.
520     * @param key Indicates the key matching the parameter.
521     * @param value Indicates the byte-type value of the parameter.
522     * @return Returns this DistributedWant object containing the parameter value.
523     */
524    DistributedWant& SetParam(const std::string& key, float value);
525
526    /**
527     * @description: Sets a parameter value of the float array type.
528     * @param key Indicates the key matching the parameter.
529     * @param value Indicates the byte-type value of the parameter.
530     * @return Returns this DistributedWant object containing the parameter value.
531     */
532    DistributedWant& SetParam(const std::string& key, const std::vector<float>& value);
533
534    /**
535     * @description: Obtains a long value matching the given key.
536     * @param key Indicates the key of DistributedWantParams.
537     * @param value Indicates the default long value.
538     * @return Returns the long value of the parameter matching the given key;
539     * returns the default value if the key does not exist.
540     */
541    long GetLongParam(const std::string& key, long defaultValue) const;
542
543    /**
544     * @description: Obtains a long array matching the given key.
545     * @param key Indicates the key of DistributedWantParams.
546     * @return Returns the long array of the parameter matching the given key;
547     * returns null if the key does not exist.
548     */
549    std::vector<long> GetLongArrayParam(const std::string& key) const;
550
551    DistributedWant& SetParam(const std::string& key, long long value);
552
553    /**
554     * @description: Sets a parameter value of the long type.
555     * @param key Indicates the key matching the parameter.
556     * @param value Indicates the byte-type value of the parameter.
557     * @return Returns this DistributedWant object containing the parameter value.
558     */
559    DistributedWant& SetParam(const std::string& key, long value);
560
561    /**
562     * @description: Sets a parameter value of the long array type.
563     * @param key Indicates the key matching the parameter.
564     * @param value Indicates the byte-type value of the parameter.
565     * @return Returns this DistributedWant object containing the parameter value.
566     */
567    DistributedWant& SetParam(const std::string& key, const std::vector<long>& value);
568
569    /**
570     * @description: a short value matching the given key.
571     * @param key Indicates the key of DistributedWantParams.
572     * @param defaultValue Indicates the default short value.
573     * @return Returns the short value of the parameter matching the given key;
574     * returns the default value if the key does not exist.
575     */
576    short GetShortParam(const std::string& key, short defaultValue) const;
577
578    /**
579     * @description: Obtains a short array matching the given key.
580     * @param key Indicates the key of DistributedWantParams.
581     * @return Returns the short array of the parameter matching the given key;
582     * returns null if the key does not exist.
583     */
584    std::vector<short> GetShortArrayParam(const std::string& key) const;
585
586    /**
587     * @description: Sets a parameter value of the short type.
588     * @param key Indicates the key matching the parameter.
589     * @param value Indicates the byte-type value of the parameter.
590     * @return Returns this DistributedWant object containing the parameter value.
591     */
592    DistributedWant& SetParam(const std::string& key, short value);
593
594    /**
595     * @description: Sets a parameter value of the short array type.
596     * @param key Indicates the key matching the parameter.
597     * @param value Indicates the byte-type value of the parameter.
598     * @return Returns this DistributedWant object containing the parameter value.
599     */
600    DistributedWant& SetParam(const std::string& key, const std::vector<short>& value);
601
602    /**
603     * @description: Obtains a string value matching the given key.
604     * @param key Indicates the key of DistributedWantParams.
605     * @return Returns the string value of the parameter matching the given key;
606     * returns null if the key does not exist.
607     */
608    std::string GetStringParam(const std::string& key) const;
609
610    /**
611     * @description: Obtains a string array matching the given key.
612     * @param key Indicates the key of DistributedWantParams.
613     * @return Returns the string array of the parameter matching the given key;
614     * returns null if the key does not exist.
615     */
616    std::vector<std::string> GetStringArrayParam(const std::string& key) const;
617
618    /**
619     * @description: Sets a parameter value of the string type.
620     * @param key Indicates the key matching the parameter.
621     * @param value Indicates the byte-type value of the parameter.
622     * @return Returns this DistributedWant object containing the parameter value.
623     */
624    DistributedWant& SetParam(const std::string& key, const std::string& value);
625
626    /**
627     * @description: Sets a parameter value of the string array type.
628     * @param key Indicates the key matching the parameter.
629     * @param value Indicates the byte-type value of the parameter.
630     * @return Returns this DistributedWant object containing the parameter value.
631     */
632    DistributedWant& SetParam(const std::string& key, const std::vector<std::string>& value);
633
634    /**
635     * @description: Checks whether a DistributedWant contains the parameter matching a given key.
636     * @param key Indicates the key.
637     * @return Returns true if the DistributedWant contains the parameter; returns false otherwise.
638     */
639    bool HasParameter(const std::string& key) const;
640
641    /**
642     * @description: Replaces parameters in this Want object with those in the given DistributedWantParams object.
643     * @param wantParams Indicates the DistributedWantParams object containing the new parameters.
644     * @return Returns this Want object containing the new parameters.
645     */
646    DistributedWant* ReplaceParams(DistributedWantParams& wantParams);
647
648    /**
649     * @description: Replaces parameters in this DistributedWant object with those in the given Want object.
650     * @param want Indicates the DistributedWant object containing the new parameters.
651     * @return Returns this DistributedWant object containing the new parameters.
652     */
653    DistributedWant* ReplaceParams(DistributedWant& want);
654
655    /**
656     * @description: Removes the parameter matching the given key.
657     * @param key Indicates the key matching the parameter to be removed.
658     */
659    void RemoveParam(const std::string& key);
660
661    /**
662     * @description: Gets the description of an operation in a DistributedWant.
663     * @return Returns the operation included in this DistributedWant.
664     */
665    DistributedOperation GetOperation() const;
666
667    /**
668     * @description: Sets the description of an operation in a DistributedWant.
669     * @param operation Indicates the operation description.
670     */
671    void SetOperation(const DistributedOperation& operation);
672
673    /**
674     * @description: Sets the description of an operation in a DistributedWant.
675     * @param want Indicates the DistributedWant object to compare.
676     * @return Returns true if the operation components of the two objects are equal; returns false otherwise.
677     */
678    bool OperationEquals(const DistributedWant& want);
679
680    /**
681     * @description: Marshals a DistributedWant into a Parcel.
682     * Fields in the DistributedWant are marshalled separately. If any field fails to be marshalled, false is returned.
683     * @param parcel Indicates the Parcel object for marshalling.
684     * @return Returns true if the marshalling is successful; returns false otherwise.
685     */
686    virtual bool Marshalling(Parcel& parcel) const;
687
688    /**
689     * @description: Unmarshals a DistributedWant from a Parcel.
690     * Fields in the DistributedWant are unmarshalled separately.
691     * If any field fails to be unmarshalled, false is returned.
692     * @param parcel Indicates the Parcel object for unmarshalling.
693     * @return Returns true if the unmarshalling is successful; returns false otherwise.
694     */
695    static DistributedWant* Unmarshalling(Parcel& parcel);
696
697    std::string ToString() const;
698
699    static DistributedWant* FromString(std::string& string);
700
701    std::shared_ptr<AAFwk::Want> ToWant();
702
703    /**
704    * @description: Sets a device id in a DistributedWant.
705    * @param deviceId Indicates the device id to set.
706    * @return Returns this DistributedWant object containing the flag.
707    */
708    DistributedWant& SetDeviceId(const std::string& deviceId);
709public:
710    static const std::string ACTION_PLAY;
711    static const std::string ACTION_HOME;
712    static const std::string ENTITY_HOME;
713    static const std::string ENTITY_VIDEO;
714    static const std::string FLAG_HOME_INTENT_FROM_SYSTEM;
715    static const std::string ENTITY_MUSIC;
716    static const std::string ENTITY_EMAIL;
717    static const std::string ENTITY_CONTACTS;
718    static const std::string ENTITY_MAPS;
719    static const std::string ENTITY_BROWSER;
720    static const std::string ENTITY_CALENDAR;
721    static const std::string ENTITY_MESSAGING;
722    static const std::string ENTITY_FILES;
723    static const std::string ENTITY_GALLERY;
724    static unsigned int FLAG_ABILITY_NEW_MISSION;
725    static unsigned int FLAG_ABILITY_CLEAR_MISSION;
726    static constexpr int HEX_STRING_BUF_LEN = 36;
727    static constexpr int HEX_STRING_LEN = 10;
728    static const std::string PARAM_RESV_WINDOW_MODE;
729    static const std::string PARAM_RESV_DISPLAY_ID;
730    static const std::string PARAM_RESV_CALLER_TOKEN;
731    static const std::string PARAM_RESV_CALLER_UID;
732    static const std::string PARAM_RESV_CALLER_PID;
733
734private:
735    DistributedWantParams parameters_;
736    DistributedOperation operation_;
737
738    static const std::string OCT_EQUALSTO;
739    static const std::string OCT_SEMICOLON;
740    static const std::string MIME_TYPE;
741    static const std::string WANT_HEADER;
742
743    static constexpr int VALUE_NULL = -1;
744    static constexpr int VALUE_OBJECT = 1;
745
746private:
747    bool ReadFromParcel(Parcel& parcel);
748    OHOS::Uri GetLowerCaseScheme(const OHOS::Uri& uri);
749    nlohmann::json ToJson() const;
750    bool ReadFromJson(nlohmann::json& wantJson);
751    bool CanReadFromJson(nlohmann::json& wantJson);
752    bool MarshallingWriteEntities(Parcel& parcel) const;
753    bool MarshallingWriteElement(Parcel& parcel) const;
754    bool MarshallingWriteParameters(Parcel& parcel) const;
755    bool MarshallingWriteUri(Parcel& parcel) const;
756    bool ReadUriFromParcel(Parcel& parcel);
757    bool ReadEntitiesFromParcel(Parcel& parcel);
758    bool ReadElementFromParcel(Parcel& parcel);
759    bool ReadParametersFromParcel(Parcel& parcel);
760};
761} // namespace DistributedSchedule
762} // namespace OHOS
763#endif // OHOS_DISTRIBUTEDWANT_WANT_H
764