1 /*
2  * Copyright (c) 2021 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_ABILITY_RUNTIME_PENDING_WANT_KEY_H
17 #define OHOS_ABILITY_RUNTIME_PENDING_WANT_KEY_H
18 
19 #include <mutex>
20 #include <vector>
21 #include <string>
22 
23 #include "want.h"
24 #include "wants_info.h"
25 
26 namespace OHOS {
27 namespace AAFwk {
28 #define ODD_PRIME_NUMBER (37)
29 
30 class PendingWantKey {
31 public:
32     PendingWantKey() = default;
33     virtual ~PendingWantKey() = default;
34     void SetType(const int32_t type);
35     void SetBundleName(const std::string &bundleName);
36     void SetRequestWho(const std::string &requestWho);
37     void SetRequestCode(int32_t requestCode);
38     void SetRequestWant(const Want &requestWant);
39     void SetRequestResolvedType(const std::string &requestResolvedType);
40     void SetAllWantsInfos(const std::vector<WantsInfo> &allWantsInfos);
41     void SetFlags(int32_t flags);
42     void SetCode(int32_t code);
43     void SetUserId(int32_t userId);
44     void SetAppIndex(int32_t appIndex);
45 
46     int32_t GetType();
47     std::string GetBundleName();
48     std::string GetRequestWho();
49     int32_t GetRequestCode();
50     Want GetRequestWant();
51     Want& GetRequestWantRef();
52     std::string GetRequestResolvedType();
53     std::vector<WantsInfo> GetAllWantsInfos();
54     int32_t GetFlags();
55     int32_t GetCode();
56     int32_t GetUserId();
57     bool IsEqualsRequestWant(const Want &otherWant);
58     int32_t GetAppIndex();
59     void GetAllBundleNames(std::vector<std::string> &bundleNames);
60 
61 private:
62     int32_t type_ = {};
63     std::string bundleName_ = {};
64     std::string requestWho_ = {};
65     int32_t requestCode_ = {};
66     Want requestWant_ = {};
67     std::string requestResolvedType_ = {};
68     std::vector<WantsInfo> allWantsInfos_ = {};
69     int32_t flags_ = {};
70     int32_t code_ = {};
71     int32_t userId_ = {};
72     int32_t appIndex_ = 0;
73     std::mutex wantsInfosMutex_;
74     std::mutex requestWantMutex_;
75 };
76 }  // namespace AAFwk
77 }  // namespace OHOS
78 #endif  // OHOS_ABILITY_RUNTIME_PENDING_WANT_KEY_H
79