• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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_MISSION_H
17 #define OHOS_ABILITY_RUNTIME_MISSION_H
18 
19 #include <memory>
20 
21 #include "ability_record.h"
22 #include "inner_mission_info.h"
23 
24 namespace OHOS {
25 namespace AAFwk {
26 /**
27  * @class Mission
28  * a mission only contains an AbilityRecord
29  */
30 class Mission : public std::enable_shared_from_this<Mission> {
31 public:
32     Mission(int32_t id, const std::shared_ptr<AbilityRecord> abilityRecord, const std::string &missionName = "",
33         int32_t startMethod = 0);
34     explicit Mission(const std::shared_ptr<Mission> &mission);
35     virtual ~Mission();
36 
37     /**
38      * set the mission list.
39      *
40      * @param missionList: the parent mission list
41      */
42     void SetMissionList(const std::shared_ptr<MissionList> &missionList);
43 
44     /**
45      * check whether ability contains by this mission is singleton.
46      *
47      * @return is ability contains by this mission is singleton.
48      */
49     bool IsSingletonAbility() const;
50 
51     /**
52      * check whether ability contains by this mission is specified.
53      *
54      * @return is ability contains by this mission is specified.
55      */
56     bool IsSpecifiedAbility() const;
57 
58     /**
59      * check whether ability contains by this mission is standard.
60      *
61      * @return is ability contains by this mission is standard.
62      */
63     bool IsStandardAbility() const;
64 
65     /**
66      * get owner mission list.
67      *
68      * @return mission list.
69      */
70     std::shared_ptr<MissionList> GetMissionList();
71 
72     /**
73      * get name of this mission.
74      *
75      * @return missionName.
76      */
77     std::string GetMissionName() const;
78 
79     /**
80      * @brief Get the Ability Record object
81      *
82      * @return std::shared_ptr<AbilityRecord>
83      */
84     std::shared_ptr<AbilityRecord> GetAbilityRecord() const;
85 
86     /**
87      * @brief Get the mission id
88      *
89      * @return the mission id
90      */
91     int32_t GetMissionId() const;
92 
93     /**
94      * @brief Set the Locked State
95      *
96      * @param lockedState true/false
97      */
98     void SetLockedState(bool lockedState);
99 
100     /**
101      * @brief get the Locked State
102      *
103      * @return the lockedState
104      */
105     bool IsLockedState() const;
106 
107     /**
108      * @brief Set the Moving State
109      *
110      * @param movingState true/false
111      */
112     void SetMovingState(bool movingState);
113 
114     /**
115      * @brief get the Moving State
116      *
117      * @return the movingState
118      */
119     bool IsMovingState() const;
120 
121     /**
122      * @brief Set application not response state true
123      */
124     void SetANRState(bool state);
125 
126     /**
127      * @brief Is application not response state
128      */
129     bool IsANRState() const;
130 
131     /**
132      * @brief dump mission
133      *
134      * @param info dump result.
135      */
136     void Dump(std::vector<std::string> &info);
137 
138     /**
139      * @brief whether it is a form ByCall start-up
140      *
141      * @return true form BaCall start-up, false other
142      */
143     bool IsStartByCall();
144 
145     /**
146      * @brief update mission id
147      *
148      * @param id mission id.
149      * @param method start method.
150      * @return Returns true on success, false on failure
151      */
152     bool UpdateMissionId(int32_t id, int32_t method);
153 
154     /**
155      * Set whether to notify Launcher that the mission has been created.
156      *
157      * @param needNotify Indicates whether the Launcher needs to be notified.
158      */
SetNotifyLabel(bool needNotify)159     inline void SetNotifyLabel(bool needNotify)
160     {
161         needNotify_ = needNotify;
162     }
163 
164     /**
165      * Get whether to notify Launcher that the mission has been created.
166      *
167      * @param return Whether the Launcher needs to be notified.
168      */
NeedNotify()169     inline bool NeedNotify() const
170     {
171         return needNotify_;
172     }
173 
174     /**
175      * Set mission specified flag.
176      *
177      * @param flag specified flag.
178      */
179     void SetSpecifiedFlag(const std::string &flag);
180 
181     /**
182      * Get mission specified flag.
183      *
184      * @return specified flag.
185      */
186     std::string GetSpecifiedFlag() const;
187 
SetNeedNotifyUpdateLabel(bool flag)188     inline void SetNeedNotifyUpdateLabel(bool flag)
189     {
190         needNotifyUpdateLabel_ = flag;
191     }
192 
NeedNotifyUpdateLabel()193     inline bool NeedNotifyUpdateLabel() const
194     {
195         return needNotifyUpdateLabel_;
196     }
197 
UpdateMissionTime(const std::string & missionTime)198     inline void UpdateMissionTime(const std::string &missionTime)
199     {
200         missionTime_ = missionTime;
201     }
202 
GetMissionTime()203     inline std::string GetMissionTime() const
204     {
205         return missionTime_;
206     }
207 
SetUnclearable(const bool & unclearable)208     inline void SetUnclearable(const bool &unclearable)
209     {
210         unclearable_ = unclearable;
211     }
212 
IsUnclearable()213     bool IsUnclearable()
214     {
215         return unclearable_;
216     }
217 
GetMissionAffinity()218     std::string GetMissionAffinity() const
219     {
220         return missionAffinity_;
221     }
222 
SetMissionAffinity(const std::string & missionAffinity)223     void SetMissionAffinity(const std::string &missionAffinity)
224     {
225         missionAffinity_ = missionAffinity;
226     }
227 
228 private:
229     int32_t missionId_;
230     int32_t startMethod_;
231     std::shared_ptr<AbilityRecord> abilityRecord_;
232     std::string missionName_;
233     std::string missionAffinity_;
234     std::string specifiedFlag_;
235     std::weak_ptr<MissionList> ownerMissionList_;
236     bool lockedState_ = false;
237     bool isMovingToFront_ = false;
238     bool isANRState_ = false;
239     bool needNotify_ = true;
240     bool needNotifyUpdateLabel_ = false;
241     std::string missionTime_ = "0";
242     bool unclearable_ = false;
243 };
244 }  // namespace AAFwk
245 }  // namespace OHOS
246 #endif  // OHOS_ABILITY_RUNTIME_MISSION_H
247