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_WANT_AGENT_INFO_H 17 #define OHOS_ABILITY_RUNTIME_WANT_AGENT_INFO_H 18 19 #include <vector> 20 #include <memory> 21 #include "want.h" 22 #include "want_agent_constant.h" 23 #include "want_params.h" 24 25 namespace OHOS::AbilityRuntime::WantAgent { 26 /** 27 * A parametric class that contains the parameters required by WantAgentHelper GetWantAgent. 28 * 29 * This class is used to encapsulate parameters requestCode, operationType, 30 * flag, Wants, and extraInfo. It is used as the input parameter for 31 * the WantAgentHelper GetWantAgent method. 32 * 33 */ 34 class WantAgentInfo final : public std::enable_shared_from_this<WantAgentInfo> { 35 public: 36 /** 37 * Default constructor used to create an empty WantAgentInfo instance. 38 * 39 */ 40 WantAgentInfo(); 41 virtual ~WantAgentInfo() = default; 42 43 /** 44 * A constructor used to create an WantAgentInfo instance based on the input parameters. 45 * 46 * @param requestCode Indicates the request code to set. It is a private value defined by the user. 47 * @param operationType Indicates the type of the operation to be performed by the WantAgent object. 48 * For details about the value range, see WantAgentConstant.OperationType. 49 * @param flag Indicates the flag for handling the WantAgent. 50 * For details about the value range, see WantAgentConstant.Flags. 51 * @param Wants Indicates the collection of Want objects to be used for creating the WantAgent 52 * object. The number of Wants in the collection is determined by WantAgentConstant.OperationType. 53 * @param extraInfo Indicates the extra information to be used for creating the WantAgent object. 54 */ 55 WantAgentInfo(int requestCode, const WantAgentConstant::OperationType &operationType, WantAgentConstant::Flags flag, 56 std::vector<std::shared_ptr<AAFwk::Want>> &Wants, const std::shared_ptr<AAFwk::WantParams> &extraInfo); 57 58 /** 59 * A constructor used to create an WantAgentInfo instance based on the input parameters. 60 * 61 * @param requestCode Indicates the request code to set. It is a private value defined by the user. 62 * @param operationType Indicates the type of the operation to be performed by the WantAgent object. 63 * For details about the value range, see WantAgentConstant.OperationType. 64 * @param flags Indicates the flags for handling the WantAgent. 65 * For details about the value range, see WantAgentConstant.Flags. 66 * @param Wants Indicates the collection of Want objects to be used for creating the WantAgent 67 * object. The number of Wants in the collection is determined by WantAgentConstant.OperationType. 68 * @param extraInfo Indicates the extra information to be used for creating the WantAgent object. 69 */ 70 WantAgentInfo(int requestCode, const WantAgentConstant::OperationType &operationType, 71 const std::vector<WantAgentConstant::Flags> &flags, std::vector<std::shared_ptr<AAFwk::Want>> &Wants, 72 const std::shared_ptr<AAFwk::WantParams> &extraInfo); 73 74 /** 75 * A constructor used to create an WantAgentInfo instance by copying parameters from an existing one. 76 * 77 * @param paramInfo Indicates the existing WantAgentInfo object. 78 */ 79 explicit WantAgentInfo(const std::shared_ptr<WantAgentInfo> ¶mInfo); 80 81 /** 82 * Obtains the requestCode of the WantAgent object. 83 * 84 * @return Returns the requestCode of the WantAgent object. 85 */ 86 int GetRequestCode() const; 87 88 /** 89 * Obtains the operationType of the WantAgent object. 90 * 91 * @return Returns the operationType of the WantAgent object. 92 */ 93 WantAgentConstant::OperationType GetOperationType() const; 94 95 /** 96 * Obtains the flag of the WantAgent object. 97 * 98 * @return Returns the flag of the WantAgent object. 99 */ 100 std::vector<WantAgentConstant::Flags> GetFlags() const; 101 102 /** 103 * Obtains the collection of all Wants of the WantAgent object. 104 * 105 * @return Returns the collection of all Wants of the WantAgent object. 106 */ 107 std::vector<std::shared_ptr<AAFwk::Want>> GetWants() const; 108 109 /** 110 * Obtains the extra information of the WantAgent object. 111 * 112 * @return Returns the extra information of the WantAgent object. 113 */ 114 std::shared_ptr<AAFwk::WantParams> GetExtraInfo() const; 115 116 private: 117 int requestCode_ = 0; 118 WantAgentConstant::OperationType operationType_ = WantAgentConstant::OperationType::UNKNOWN_TYPE; 119 std::vector<WantAgentConstant::Flags> flags_ = std::vector<WantAgentConstant::Flags>(); 120 std::vector<std::shared_ptr<AAFwk::Want>> wants_ = std::vector<std::shared_ptr<AAFwk::Want>>(); 121 std::shared_ptr<AAFwk::WantParams> extraInfo_; 122 }; 123 } // namespace OHOS::AbilityRuntime::WantAgent 124 #endif // OHOS_ABILITY_RUNTIME_WANT_AGENT_INFO_H 125