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 FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_APPMGR_INCLUDE_APP_LAUNCH_DATA_H 17 #define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_APPMGR_INCLUDE_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 &); 52 53 /** 54 * @brief Setting information for the profile. 55 * 56 * @param Profile&, the current profile. 57 */ 58 void SetProfile(const Profile &); 59 60 /** 61 * @brief Setting information for the process. 62 * 63 * @param Profile&, the current process info. 64 */ 65 void SetProcessInfo(const ProcessInfo &); 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); 73 74 /** 75 * @brief Setting id for User. 76 * 77 * @param int32_t, the current app User. 78 */ 79 void SetUId(const int32_t); 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 /** 89 * @brief Obtains the info of the application. 90 * 91 * @return Returns the current application info. 92 */ GetApplicationInfo()93 inline const ApplicationInfo &GetApplicationInfo() const 94 { 95 return applicationInfo_; 96 } 97 98 /** 99 * @brief Obtains the profile. 100 * 101 * @return Returns the current profile. 102 */ GetProfile()103 inline const Profile &GetProfile() const 104 { 105 return profile_; 106 } 107 108 /** 109 * @brief Obtains the info of the process. 110 * 111 * @return Returns the current process info. 112 */ GetProcessInfo()113 inline const ProcessInfo &GetProcessInfo() const 114 { 115 return processInfo_; 116 } 117 118 /** 119 * @brief Obtains the id of the app record. 120 * 121 * @return Returns the current appRecord id. 122 */ GetRecordId()123 inline int32_t GetRecordId() const 124 { 125 return recordId_; 126 } 127 128 /** 129 * @brief Obtains the id of the User. 130 * 131 * @return Returns the current User id. 132 */ GetUId()133 inline int32_t GetUId() const 134 { 135 return uId_; 136 } 137 138 /** 139 * @brief get user test info. 140 * 141 * @return Returns user test info. 142 */ GetUserTestInfo()143 inline std::shared_ptr<UserTestRecord> GetUserTestInfo() const 144 { 145 return userTestRecord_; 146 } 147 148 /** 149 * @brief read this Sequenceable object from a Parcel. 150 * 151 * @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled. 152 * @return Returns true if read successed; returns false otherwise. 153 */ 154 bool ReadFromParcel(Parcel &parcel); 155 156 /** 157 * @brief Marshals this Sequenceable object into a Parcel. 158 * 159 * @param outParcel Indicates the Parcel object to which the Sequenceable object will be marshaled. 160 */ 161 virtual bool Marshalling(Parcel &parcel) const override; 162 163 /** 164 * @brief Unmarshals this Sequenceable object from a Parcel. 165 * 166 * @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled. 167 */ 168 static AppLaunchData *Unmarshalling(Parcel &parcel); 169 170 private: 171 ApplicationInfo applicationInfo_; 172 Profile profile_; 173 ProcessInfo processInfo_; 174 int32_t recordId_ = 0; 175 int32_t uId_ = 0; 176 std::shared_ptr<UserTestRecord> userTestRecord_ = nullptr; 177 }; 178 } // namespace AppExecFwk 179 } // namespace OHOS 180 #endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_APPMGR_INCLUDE_APP_LAUNCH_DATA_H 181