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 155 /** 156 * @brief read this Sequenceable object from a Parcel. 157 * 158 * @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled. 159 * @return Returns true if read successed; returns false otherwise. 160 */ 161 bool ReadFromParcel(Parcel &parcel); 162 163 /** 164 * @brief Marshals this Sequenceable object into a Parcel. 165 * 166 * @param outParcel Indicates the Parcel object to which the Sequenceable object will be marshaled. 167 */ 168 virtual bool Marshalling(Parcel &parcel) const override; 169 170 /** 171 * @brief Unmarshals this Sequenceable object from a Parcel. 172 * 173 * @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled. 174 */ 175 static AppLaunchData *Unmarshalling(Parcel &parcel); 176 177 private: 178 ApplicationInfo applicationInfo_; 179 Profile profile_; 180 ProcessInfo processInfo_; 181 int32_t recordId_ = 0; 182 int32_t uId_ = 0; 183 int32_t appIndex_ = 0; 184 std::shared_ptr<UserTestRecord> userTestRecord_ = nullptr; 185 }; 186 } // namespace AppExecFwk 187 } // namespace OHOS 188 #endif // OHOS_ABILITY_RUNTIME_INTERFACES_INNERKITS_APPEXECFWK_CORE_APPMGR_INCLUDE_APP_LAUNCH_DATA_H 189