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 175 /** 176 * @brief read this Sequenceable object from a Parcel. 177 * 178 * @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled. 179 * @return Returns true if read successed; returns false otherwise. 180 */ 181 bool ReadFromParcel(Parcel &parcel); 182 183 /** 184 * @brief Marshals this Sequenceable object into a Parcel. 185 * 186 * @param outParcel Indicates the Parcel object to which the Sequenceable object will be marshaled. 187 */ 188 virtual bool Marshalling(Parcel &parcel) const override; 189 190 /** 191 * @brief Unmarshals this Sequenceable object from a Parcel. 192 * 193 * @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled. 194 */ 195 static AppLaunchData *Unmarshalling(Parcel &parcel); 196 197 private: 198 ApplicationInfo applicationInfo_; 199 Profile profile_; 200 ProcessInfo processInfo_; 201 int32_t recordId_ = 0; 202 int32_t uId_ = 0; 203 int32_t appIndex_ = 0; 204 std::shared_ptr<UserTestRecord> userTestRecord_ = nullptr; 205 bool debugApp_ = false; 206 std::string perfCmd_; 207 }; 208 } // namespace AppExecFwk 209 } // namespace OHOS 210 #endif // OHOS_ABILITY_RUNTIME_INTERFACES_INNERKITS_APPEXECFWK_CORE_APPMGR_INCLUDE_APP_LAUNCH_DATA_H 211