1 /* 2 * Copyright (c) 2021-2022 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 #ifndef OHOS_ABILITY_BASE_EXTRA_PARAMS_H 16 #define OHOS_ABILITY_BASE_EXTRA_PARAMS_H 17 18 #include <string> 19 20 #include "parcel.h" 21 22 using string = std::string; 23 24 namespace OHOS { 25 namespace AppExecFwk { 26 class ExtraParams : public Parcelable { 27 public: 28 /** 29 * @brief A default constructor used to create an empty {@code ExtraParams} instance. 30 * @param none 31 */ 32 ExtraParams(); 33 /** 34 * @brief A copy constructor used to create an empty {@code ExtraParams} instance. 35 * @param other indicates object instance. 36 */ 37 ExtraParams(const ExtraParams &other); 38 /** 39 * @brief Overloading assignment operators to create the same object instance. 40 * @param other Indicates object instance. 41 */ 42 ExtraParams &operator=(const ExtraParams &other); 43 44 /** 45 * @brief Judge whether the parameter of extraparam instance is equal to that of other instance parameter 46 * @param other Indicates object instance. 47 * @return returns true the parameter of extraparam instance is equal to that of other instance parameter 48 * otherwise false 49 */ 50 bool operator==(const ExtraParams &other) const; 51 52 /** 53 * @brief A constructor used to create an {@code ExtraParams} instance based on the input parameters{@code devType}, 54 * {@code targetBundleName}, and {@code description}. 55 * 56 * @param devType Indicates the type of devices to be matched. This parameter can be any combination of 57 * {@link #DEVICETYPE_SMART_PHONE}, {@link #DEVICETYPE_SMART_PAD}, {@link #DEVICETYPE_SMART_WATCH}, and 58 * {@link #DEVICETYPE_SMART_TV}. 59 * 60 * @param targetBundleName Indicates the bundle name of the target application where the ability will be migrated. 61 * 62 * @param description Indicates the description used for device filtering. 63 * 64 * @param jsonParams Indicates the custom JSON parameters to be used as filter conditions. 65 * 66 * @return none 67 */ 68 ExtraParams(const std::vector<string> &devType, const string &targetBundleName, const string &description, 69 const string &jsonParams); 70 71 /** 72 * @brief A destructor release an empty {@code ExtraParams} instance. 73 * @param none 74 */ 75 ~ExtraParams(); 76 77 /** 78 * @brief Sets the list of device types. 79 * 80 * @param devType Indicates the type of devices to be matched. This parameter can be any combination of 81 * {@link #DEVICETYPE_SMART_PHONE}, {@link #DEVICETYPE_SMART_PAD}, {@link #DEVICETYPE_SMART_WATCH}, and 82 * {@link #DEVICETYPE_SMART_TV}. 83 * 84 * @return none 85 */ 86 void SetDevType(const std::vector<string> &devType); 87 88 /** 89 * @brief Obtains the list of device types. 90 * 91 * @param none 92 * 93 * @return Returns the list of device types. 94 */ 95 std::vector<string> GetDevType() const; 96 97 /** 98 * @brief Sets the bundle name of the target application where ability will be migrated. 99 * 100 * @param targetBundleName Indicates the bundle name of the target application to set. 101 * 102 * @return none 103 */ 104 void SetTargetBundleName(const string &targetBundleName); 105 106 /** 107 * @brief Obtains the bundle name of the target application where the ability will be migrated. 108 * 109 * @return Returns the bundle name of the target application. 110 * 111 * @return none 112 */ 113 string GetTargetBundleName() const; 114 115 /** 116 * @brief Sets the description used for device filtering. 117 * 118 * @param jsonParams Indicates the device description to set. 119 * 120 * @return none 121 */ 122 void SetJsonParams(const string &jsonParams); 123 124 /** 125 * @brief Obtains the custom JSON parameters used as filter conditions. 126 * 127 * @param none 128 * 129 * @return Returns the custom JSON parameters. 130 */ 131 string GetJsonParams() const; 132 133 /** 134 * @brief Sets the custom JSON parameters to be used as filter conditions. 135 * 136 * @param description Indicates the custom JSON parameters to set. 137 * 138 */ 139 void SetDescription(const string &description); 140 141 /** 142 * @brief Obtains the description used for device filtering. 143 * 144 * @param none 145 * 146 * @return Returns the description used for device filtering. 147 */ 148 string GetDescription() const; 149 150 /** 151 * @brief Marshals this {@code ExtraParams} object into a {@link ohos.utils.Parcel} object. 152 * 153 * @param parcel Indicates the {@code Parcel} object for marshalling. 154 * 155 * @return Returns {@code true} if the marshalling is successful; returns {@code false} otherwise. 156 */ 157 virtual bool Marshalling(Parcel &parcel) const override; 158 159 /** 160 * @brief Unmarshals this {@code ExtraParams} object from a {@link ohos.utils.Parcel} object. 161 * 162 * @param parcel Indicates the {@code Parcel} object for unmarshalling. 163 * 164 * @return Returns {@code true} if the unmarshalling is successful; returns {@code false} otherwise. 165 */ 166 static ExtraParams *Unmarshalling(Parcel &parcel); 167 168 public: 169 // Indicates a smart speaker. 170 static constexpr char DEVICETYPE_SMART_SPEAKER[] = "00A"; 171 172 // Indicates a desktop pad. 173 static constexpr char DEVICETYPE_DESKTOP_PAD[] = "00B"; 174 175 // Indicates a laptop. 176 static constexpr char DEVICETYPE_LAPTOP[] = "00C"; 177 178 // Indicates a smartphone. 179 static constexpr char DEVICETYPE_SMART_PHONE[] = "00E"; 180 181 // Indicates a tablet. 182 static constexpr char DEVICETYPE_SMART_PAD[] = "011"; 183 184 // Indicates a smart watch. 185 static constexpr char DEVICETYPE_SMART_WATCH[] = "06D"; 186 187 // Indicates a smart car. 188 static constexpr char DEVICETYPE_SMART_CAR[] = "083"; 189 190 // Indicates a kids smart watch. 191 static constexpr char DEVICETYPE_CHILDREN_WATCH[] = "085"; 192 193 // Indicates a smart TV. 194 static constexpr char DEVICETYPE_SMART_TV[] = "09C"; 195 196 private: 197 string targetBundleName_; 198 string description_; 199 string jsonParams_; 200 std::vector<string> devType_; 201 }; 202 } // namespace AppExecFwk 203 } // namespace OHOS 204 #endif // OHOS_ABILITY_BASE_EXTRA_PARAMS_H 205