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_APP_LAUNCH_DATA_H 17 #define OHOS_ABILITY_RUNTIME_APP_LAUNCH_DATA_H 18 19 #include <string> 20 21 #include "iremote_object.h" 22 #include "parcel.h" 23 24 #include "application_info.h" 25 #include "process_info.h" 26 #include "profile.h" 27 #include "want.h" 28 29 namespace OHOS { 30 namespace AppExecFwk { 31 struct UserTestRecord : public Parcelable { 32 AAFwk::Want want; 33 sptr<IRemoteObject> observer; 34 bool isFinished; 35 int32_t userId; UserTestRecordUserTestRecord36 UserTestRecord() : observer(nullptr), isFinished(false), userId(-1) 37 {} 38 39 bool ReadFromParcel(Parcel &parcel); 40 virtual bool Marshalling(Parcel &parcel) const override; 41 static UserTestRecord *Unmarshalling(Parcel &parcel); 42 }; 43 44 class AppLaunchData : public Parcelable { 45 public: 46 /** 47 * @brief setting information for the application. 48 * 49 * @param ApplicationInfo&, the current application info. 50 */ 51 void SetApplicationInfo(const ApplicationInfo &info); 52 53 /** 54 * @brief Setting information for the profile. 55 * 56 * @param Profile&, the current profile. 57 */ 58 void SetProfile(const Profile &profile); 59 60 /** 61 * @brief Setting information for the process. 62 * 63 * @param Profile&, the current process info. 64 */ 65 void SetProcessInfo(const ProcessInfo &info); 66 67 /** 68 * @brief Setting id for app record. 69 * 70 * @param int32_t, the current app record id. 71 */ 72 void SetRecordId(const int32_t recordId); 73 74 /** 75 * @brief Setting id for User. 76 * 77 * @param int32_t, the current app User. 78 */ 79 void SetUId(const int32_t uId); 80 81 /** 82 * @brief set user test info. 83 * 84 * @param UserTestRecord, user test info. 85 */ 86 void SetUserTestInfo(const std::shared_ptr<UserTestRecord> &record); 87 88 void SetAppIndex(const int32_t appIndex); 89 90 /** 91 * @brief Obtains the info of the application. 92 * 93 * @return Returns the current application info. 94 */ GetApplicationInfo()95 inline const ApplicationInfo &GetApplicationInfo() const 96 { 97 return applicationInfo_; 98 } 99 100 /** 101 * @brief Obtains the profile. 102 * 103 * @return Returns the current profile. 104 */ GetProfile()105 inline const Profile &GetProfile() const 106 { 107 return profile_; 108 } 109 110 /** 111 * @brief Obtains the info of the process. 112 * 113 * @return Returns the current process info. 114 */ GetProcessInfo()115 inline const ProcessInfo &GetProcessInfo() const 116 { 117 return processInfo_; 118 } 119 120 /** 121 * @brief Obtains the id of the app record. 122 * 123 * @return Returns the current appRecord id. 124 */ GetRecordId()125 inline int32_t GetRecordId() const 126 { 127 return recordId_; 128 } 129 130 /** 131 * @brief Obtains the id of the User. 132 * 133 * @return Returns the current User id. 134 */ GetUId()135 inline int32_t GetUId() const 136 { 137 return uId_; 138 } 139 140 /** 141 * @brief get user test info. 142 * 143 * @return Returns user test info. 144 */ GetUserTestInfo()145 inline std::shared_ptr<UserTestRecord> GetUserTestInfo() const 146 { 147 return userTestRecord_; 148 } 149 GetAppIndex()150 inline int32_t GetAppIndex() const 151 { 152 return appIndex_; 153 } 154 SetDebugApp(bool debugApp)155 inline void SetDebugApp(bool debugApp) 156 { 157 debugApp_ = debugApp; 158 } 159 GetDebugApp()160 inline bool GetDebugApp() const 161 { 162 return debugApp_; 163 } 164 SetPerfCmd(const std::string & perfCmd)165 inline void SetPerfCmd(const std::string &perfCmd) 166 { 167 perfCmd_ = perfCmd; 168 } 169 GetPerfCmd()170 inline std::string GetPerfCmd() const 171 { 172 return perfCmd_; 173 } 174 SetMultiThread(const bool multiThread)175 inline void SetMultiThread(const bool multiThread) 176 { 177 isMultiThread_ = multiThread; 178 } 179 GetMultiThread()180 inline bool GetMultiThread() const 181 { 182 return isMultiThread_; 183 } 184 SetErrorInfoEnhance(const bool errorInfoEnhance)185 inline void SetErrorInfoEnhance(const bool errorInfoEnhance) 186 { 187 isErrorInfoEnhance_ = errorInfoEnhance; 188 } 189 GetErrorInfoEnhance()190 inline bool GetErrorInfoEnhance() const 191 { 192 return isErrorInfoEnhance_; 193 } 194 SetJITEnabled(const bool jitEnabled)195 inline void SetJITEnabled(const bool jitEnabled) 196 { 197 jitEnabled_ = jitEnabled; 198 } 199 IsJITEnabled()200 inline bool IsJITEnabled() const 201 { 202 return jitEnabled_; 203 } 204 GetAppRunningUniqueId()205 inline std::string GetAppRunningUniqueId() const 206 { 207 return appRunningUniqueId_; 208 } 209 SetAppRunningUniqueId(const std::string & appRunningUniqueId)210 inline void SetAppRunningUniqueId(const std::string &appRunningUniqueId) 211 { 212 appRunningUniqueId_ = appRunningUniqueId; 213 } 214 GetInstanceKey()215 inline std::string GetInstanceKey() const 216 { 217 return instanceKey_; 218 } 219 SetInstanceKey(const std::string & instanceKey)220 inline void SetInstanceKey(const std::string& instanceKey) 221 { 222 instanceKey_ = instanceKey; 223 } 224 225 /** 226 * @brief read this Sequenceable object from a Parcel. 227 * 228 * @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled. 229 * @return Returns true if read successed; returns false otherwise. 230 */ 231 bool ReadFromParcel(Parcel &parcel); 232 233 /** 234 * @brief Marshals this Sequenceable object into a Parcel. 235 * 236 * @param outParcel Indicates the Parcel object to which the Sequenceable object will be marshaled. 237 */ 238 virtual bool Marshalling(Parcel &parcel) const override; 239 240 /** 241 * @brief to solve cyclomatic of Marshalling 242 * 243 * @param outParcel Indicates the Parcel object to which the Sequenceable object will be marshaled. 244 */ 245 bool MarshallingExtend(Parcel &parcel) const; 246 247 /** 248 * @brief Unmarshals this Sequenceable object from a Parcel. 249 * 250 * @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled. 251 */ 252 static AppLaunchData *Unmarshalling(Parcel &parcel); 253 /** 254 * @brief Setting is aa start with native. 255 * 256 * @param isNativeStart, is aa start with native. 257 */ 258 void SetNativeStart(bool isNativeStart); 259 /** 260 * @brief Obtains is native start. 261 * 262 * @return Returns is native start. 263 */ 264 bool isNativeStart() const; 265 266 /** 267 * @brief Setting if allow nweb preload. 268 * 269 * @param isAllowedNWebPreload, if allow nweb preload. 270 */ 271 void SetNWebPreload(const bool isAllowedNWebPreload); 272 /** 273 * @brief Get if allow nweb preload. 274 * 275 * @return Returns if allow nweb preload. 276 */ 277 bool IsAllowedNWebPreload() const; 278 /** 279 * @brief Setting is need preload module. 280 * 281 * @param isNeedPreloadModule, is need preload module. 282 */ 283 void SetIsNeedPreloadModule(bool isNeedPreloadModule); 284 /** 285 * @brief Obtains is need preload module.. 286 * 287 * @return Returns is need preload module.. 288 */ 289 bool IsNeedPreloadModule() const; 290 291 private: 292 ApplicationInfo applicationInfo_; 293 Profile profile_; 294 ProcessInfo processInfo_; 295 int32_t recordId_ = 0; 296 int32_t uId_ = 0; 297 int32_t appIndex_ = 0; 298 std::shared_ptr<UserTestRecord> userTestRecord_ = nullptr; 299 bool debugApp_ = false; 300 std::string perfCmd_; 301 bool jitEnabled_ = false; 302 bool isNativeStart_ = false; 303 bool isMultiThread_ = false; 304 bool isErrorInfoEnhance_ = false; 305 std::string appRunningUniqueId_; 306 std::string instanceKey_; 307 bool isAllowedNWebPreload_ = false; 308 bool isNeedPreloadModule_ = false; 309 }; 310 } // namespace AppExecFwk 311 } // namespace OHOS 312 #endif // OHOS_ABILITY_RUNTIME_INTERFACES_INNERKITS_APPEXECFWK_CORE_APPMGR_INCLUDE_APP_LAUNCH_DATA_H 313