• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 struct StartupTaskData : public Parcelable {
45     std::string action;
46     std::string insightIntentName;
47     std::string uri;
48 
49     bool ReadFromParcel(Parcel &parcel);
50     virtual bool Marshalling(Parcel &parcel) const override;
51     static StartupTaskData *Unmarshalling(Parcel &parcel);
52 };
53 
54 class AppLaunchData : public Parcelable {
55 public:
56     /**
57      * @brief setting information for the application.
58      *
59      * @param ApplicationInfo&, the current application info.
60      */
61     void SetApplicationInfo(const ApplicationInfo &info);
62 
63     /**
64      * @brief Setting information for the profile.
65      *
66      * @param Profile&, the current profile.
67      */
68     void SetProfile(const Profile &profile);
69 
70     /**
71      * @brief Setting information for the process.
72      *
73      * @param Profile&, the current process info.
74      */
75     void SetProcessInfo(const ProcessInfo &info);
76 
77     /**
78      * @brief Setting id for app record.
79      *
80      * @param int32_t, the current app record id.
81      */
82     void SetRecordId(const int32_t recordId);
83 
84     /**
85      * @brief Setting id for User.
86      *
87      * @param int32_t, the current app User.
88      */
89     void SetUId(const int32_t uId);
90 
91     /**
92      * @brief set user test info.
93      *
94      * @param UserTestRecord, user test info.
95      */
96     void SetUserTestInfo(const std::shared_ptr<UserTestRecord> &record);
97 
98     void SetAppIndex(const int32_t appIndex);
99 
100     /**
101      * @brief Obtains the info of the application.
102      *
103      * @return Returns the current application info.
104      */
GetApplicationInfo()105     inline const ApplicationInfo &GetApplicationInfo() const
106     {
107         return applicationInfo_;
108     }
109 
110     /**
111      * @brief Obtains the profile.
112      *
113      * @return Returns the current profile.
114      */
GetProfile()115     inline const Profile &GetProfile() const
116     {
117         return profile_;
118     }
119 
120     /**
121      * @brief Obtains the info of the process.
122      *
123      * @return Returns the current process info.
124      */
GetProcessInfo()125     inline const ProcessInfo &GetProcessInfo() const
126     {
127         return processInfo_;
128     }
129 
130     /**
131      * @brief Obtains the id of the app record.
132      *
133      * @return Returns the current appRecord id.
134      */
GetRecordId()135     inline int32_t GetRecordId() const
136     {
137         return recordId_;
138     }
139 
140     /**
141      * @brief Obtains the id of the User.
142      *
143      * @return Returns the current User id.
144      */
GetUId()145     inline int32_t GetUId() const
146     {
147         return uId_;
148     }
149 
150     /**
151      * @brief get user test info.
152      *
153      * @return Returns user test info.
154      */
GetUserTestInfo()155     inline std::shared_ptr<UserTestRecord> GetUserTestInfo() const
156     {
157         return userTestRecord_;
158     }
159 
GetAppIndex()160     inline int32_t GetAppIndex() const
161     {
162         return appIndex_;
163     }
164 
SetDebugApp(bool debugApp)165     inline void SetDebugApp(bool debugApp)
166     {
167         debugApp_ = debugApp;
168     }
169 
GetDebugApp()170     inline bool GetDebugApp() const
171     {
172         return debugApp_;
173     }
174 
SetPerfCmd(const std::string & perfCmd)175     inline void SetPerfCmd(const std::string &perfCmd)
176     {
177         perfCmd_ = perfCmd;
178     }
179 
GetPerfCmd()180     inline std::string GetPerfCmd() const
181     {
182         return perfCmd_;
183     }
184 
SetMultiThread(const bool multiThread)185     inline void SetMultiThread(const bool multiThread)
186     {
187         isMultiThread_ = multiThread;
188     }
189 
GetMultiThread()190     inline bool GetMultiThread() const
191     {
192         return isMultiThread_;
193     }
194 
SetErrorInfoEnhance(const bool errorInfoEnhance)195     inline void SetErrorInfoEnhance(const bool errorInfoEnhance)
196     {
197         isErrorInfoEnhance_ = errorInfoEnhance;
198     }
199 
GetErrorInfoEnhance()200     inline bool GetErrorInfoEnhance() const
201     {
202         return isErrorInfoEnhance_;
203     }
204 
SetJITEnabled(const bool jitEnabled)205     inline void SetJITEnabled(const bool jitEnabled)
206     {
207         jitEnabled_ = jitEnabled;
208     }
209 
IsJITEnabled()210     inline bool IsJITEnabled() const
211     {
212         return jitEnabled_;
213     }
214 
GetAppRunningUniqueId()215     inline std::string GetAppRunningUniqueId() const
216     {
217         return appRunningUniqueId_;
218     }
219 
SetAppRunningUniqueId(const std::string & appRunningUniqueId)220     inline void SetAppRunningUniqueId(const std::string &appRunningUniqueId)
221     {
222         appRunningUniqueId_ = appRunningUniqueId;
223     }
224 
GetPreloadModuleName()225     inline std::string GetPreloadModuleName() const
226     {
227         return preloadModuleName_;
228     }
229 
SetPreloadModuleName(const std::string & moduleName)230     inline void SetPreloadModuleName(const std::string& moduleName)
231     {
232         preloadModuleName_ = moduleName;
233     }
234 
GetInstanceKey()235     inline std::string GetInstanceKey() const
236     {
237         return instanceKey_;
238     }
239 
SetInstanceKey(const std::string & instanceKey)240     inline void SetInstanceKey(const std::string& instanceKey)
241     {
242         instanceKey_ = instanceKey;
243     }
244 
SetStartupTaskData(std::shared_ptr<StartupTaskData> startupTaskData)245     void SetStartupTaskData(std::shared_ptr<StartupTaskData> startupTaskData)
246     {
247         startupTaskData_ = startupTaskData;
248     }
249 
GetStartupTaskData()250     std::shared_ptr<StartupTaskData> GetStartupTaskData() const
251     {
252         return startupTaskData_;
253     }
254 
255     /**
256      * @brief read this Sequenceable object from a Parcel.
257      *
258      * @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled.
259      * @return Returns true if read successed; returns false otherwise.
260      */
261     bool ReadFromParcel(Parcel &parcel);
262 
263     /**
264      * @brief Marshals this Sequenceable object into a Parcel.
265      *
266      * @param outParcel Indicates the Parcel object to which the Sequenceable object will be marshaled.
267      */
268     virtual bool Marshalling(Parcel &parcel) const override;
269 
270     /**
271      * @brief to solve cyclomatic of Marshalling
272      *
273      * @param outParcel Indicates the Parcel object to which the Sequenceable object will be marshaled.
274      */
275     bool MarshallingExtend(Parcel &parcel) const;
276 
277     /**
278      * @brief Unmarshals this Sequenceable object from a Parcel.
279      *
280      * @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled.
281      */
282     static AppLaunchData *Unmarshalling(Parcel &parcel);
283 
284     bool ReadStartupTaskDataFromParcel(Parcel &parcel);
285 
286     /**
287      * @brief Setting is aa start with native.
288      *
289      * @param isNativeStart, is aa start with native.
290      */
291     void SetNativeStart(bool isNativeStart);
292     /**
293      * @brief Obtains is native start.
294      *
295      * @return Returns is native start.
296      */
297     bool isNativeStart() const;
298 
299     /**
300      * @brief Setting is need preload module.
301      *
302      * @param isNeedPreloadModule, is need preload module.
303      */
304     void SetIsNeedPreloadModule(bool isNeedPreloadModule);
305     /**
306      * @brief Obtains  is need preload module..
307      *
308      * @return Returns  is need preload module..
309      */
310     bool IsNeedPreloadModule() const;
311 
312     /**
313      * @brief Setting preload mode.
314      *
315      * @param preloadMode PreloadMode enum
316      */
317     void SetAppPreloadMode(PreloadMode preloadMode);
318 
319     /**
320      * @brief Obtains preload mode.
321      *
322      * @return Returns preloadMode enum
323      */
324     PreloadMode GetAppPreloadMode() const;
325 
326     /**
327      * @brief Setting if allow nweb preload.
328      *
329      * @param isAllowedNWebPreload, if allow nweb preload.
330      */
331     void SetNWebPreload(const bool isAllowedNWebPreload);
332     /**
333      * @brief Get if allow nweb preload.
334      *
335      * @return Returns if allow nweb preload.
336      */
337     bool IsAllowedNWebPreload() const;
338 
339     /**
340      * @brief Setting debug mode.
341      *
342      * @param ideDebugMode, false:old debug, true:local debug.
343      */
344     void SetDebugFromLocal(bool isDebugFromLocal);
345     /**
346      * @brief Get debug mode.
347      *
348      * @return Returns debug mode.
349      */
350     bool GetDebugFromLocal() const;
351 
352 private:
353     bool debugApp_ = false;
354     bool jitEnabled_ = false;
355     bool isNativeStart_ = false;
356     bool isMultiThread_ = false;
357     bool isErrorInfoEnhance_ = false;
358     bool isNeedPreloadModule_ = false;
359     PreloadMode appPreloadMode_ = PreloadMode::PRELOAD_NONE;
360     bool isAllowedNWebPreload_ = false;
361     int32_t recordId_ = 0;
362     int32_t uId_ = 0;
363     int32_t appIndex_ = 0;
364     std::shared_ptr<UserTestRecord> userTestRecord_ = nullptr;
365     ApplicationInfo applicationInfo_;
366     Profile profile_;
367     ProcessInfo processInfo_;
368     std::string perfCmd_;
369     std::string appRunningUniqueId_;
370     std::string instanceKey_;
371     std::string preloadModuleName_;
372     bool isDebugFromLocal_;
373     std::shared_ptr<StartupTaskData> startupTaskData_ = nullptr;
374 };
375 }  // namespace AppExecFwk
376 }  // namespace OHOS
377 #endif  // OHOS_ABILITY_RUNTIME_INTERFACES_INNERKITS_APPEXECFWK_CORE_APPMGR_INCLUDE_APP_LAUNCH_DATA_H
378