1eace7efcSopenharmony_ci/* 2eace7efcSopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 3eace7efcSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4eace7efcSopenharmony_ci * you may not use this file except in compliance with the License. 5eace7efcSopenharmony_ci * You may obtain a copy of the License at 6eace7efcSopenharmony_ci * 7eace7efcSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8eace7efcSopenharmony_ci * 9eace7efcSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10eace7efcSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11eace7efcSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12eace7efcSopenharmony_ci * See the License for the specific language governing permissions and 13eace7efcSopenharmony_ci * limitations under the License. 14eace7efcSopenharmony_ci */ 15eace7efcSopenharmony_ci 16eace7efcSopenharmony_ci#ifndef OHOS_ABILITY_RUNTIME_MISSION_H 17eace7efcSopenharmony_ci#define OHOS_ABILITY_RUNTIME_MISSION_H 18eace7efcSopenharmony_ci 19eace7efcSopenharmony_ci#include <memory> 20eace7efcSopenharmony_ci 21eace7efcSopenharmony_ci#include "ability_record.h" 22eace7efcSopenharmony_ci#include "inner_mission_info.h" 23eace7efcSopenharmony_ci 24eace7efcSopenharmony_cinamespace OHOS { 25eace7efcSopenharmony_cinamespace AAFwk { 26eace7efcSopenharmony_ciclass MissionList; 27eace7efcSopenharmony_ci 28eace7efcSopenharmony_ci/** 29eace7efcSopenharmony_ci * @class Mission 30eace7efcSopenharmony_ci * a mission only contains an AbilityRecord 31eace7efcSopenharmony_ci */ 32eace7efcSopenharmony_ciclass Mission : public std::enable_shared_from_this<Mission> { 33eace7efcSopenharmony_cipublic: 34eace7efcSopenharmony_ci Mission(int32_t id, const std::shared_ptr<AbilityRecord> abilityRecord, const std::string &missionName = "", 35eace7efcSopenharmony_ci int32_t startMethod = 0); 36eace7efcSopenharmony_ci explicit Mission(const std::shared_ptr<Mission> &mission); 37eace7efcSopenharmony_ci virtual ~Mission(); 38eace7efcSopenharmony_ci 39eace7efcSopenharmony_ci /** 40eace7efcSopenharmony_ci * set the mission list. 41eace7efcSopenharmony_ci * 42eace7efcSopenharmony_ci * @param missionList: the parent mission list 43eace7efcSopenharmony_ci */ 44eace7efcSopenharmony_ci void SetMissionList(const std::shared_ptr<MissionList> &missionList); 45eace7efcSopenharmony_ci 46eace7efcSopenharmony_ci /** 47eace7efcSopenharmony_ci * check whether ability contains by this mission is singleton. 48eace7efcSopenharmony_ci * 49eace7efcSopenharmony_ci * @return is ability contains by this mission is singleton. 50eace7efcSopenharmony_ci */ 51eace7efcSopenharmony_ci bool IsSingletonAbility() const; 52eace7efcSopenharmony_ci 53eace7efcSopenharmony_ci /** 54eace7efcSopenharmony_ci * check whether ability contains by this mission is specified. 55eace7efcSopenharmony_ci * 56eace7efcSopenharmony_ci * @return is ability contains by this mission is specified. 57eace7efcSopenharmony_ci */ 58eace7efcSopenharmony_ci bool IsSpecifiedAbility() const; 59eace7efcSopenharmony_ci 60eace7efcSopenharmony_ci /** 61eace7efcSopenharmony_ci * check whether ability contains by this mission is standard. 62eace7efcSopenharmony_ci * 63eace7efcSopenharmony_ci * @return is ability contains by this mission is standard. 64eace7efcSopenharmony_ci */ 65eace7efcSopenharmony_ci bool IsStandardAbility() const; 66eace7efcSopenharmony_ci 67eace7efcSopenharmony_ci /** 68eace7efcSopenharmony_ci * get owner mission list. 69eace7efcSopenharmony_ci * 70eace7efcSopenharmony_ci * @return mission list. 71eace7efcSopenharmony_ci */ 72eace7efcSopenharmony_ci std::shared_ptr<MissionList> GetMissionList(); 73eace7efcSopenharmony_ci 74eace7efcSopenharmony_ci /** 75eace7efcSopenharmony_ci * get name of this mission. 76eace7efcSopenharmony_ci * 77eace7efcSopenharmony_ci * @return missionName. 78eace7efcSopenharmony_ci */ 79eace7efcSopenharmony_ci std::string GetMissionName() const; 80eace7efcSopenharmony_ci 81eace7efcSopenharmony_ci /** 82eace7efcSopenharmony_ci * @brief Get the Ability Record object 83eace7efcSopenharmony_ci * 84eace7efcSopenharmony_ci * @return std::shared_ptr<AbilityRecord> 85eace7efcSopenharmony_ci */ 86eace7efcSopenharmony_ci std::shared_ptr<AbilityRecord> GetAbilityRecord() const; 87eace7efcSopenharmony_ci 88eace7efcSopenharmony_ci /** 89eace7efcSopenharmony_ci * @brief Get the mission id 90eace7efcSopenharmony_ci * 91eace7efcSopenharmony_ci * @return the mission id 92eace7efcSopenharmony_ci */ 93eace7efcSopenharmony_ci int32_t GetMissionId() const; 94eace7efcSopenharmony_ci 95eace7efcSopenharmony_ci /** 96eace7efcSopenharmony_ci * @brief Set the Locked State 97eace7efcSopenharmony_ci * 98eace7efcSopenharmony_ci * @param lockedState true/false 99eace7efcSopenharmony_ci */ 100eace7efcSopenharmony_ci void SetLockedState(bool lockedState); 101eace7efcSopenharmony_ci 102eace7efcSopenharmony_ci /** 103eace7efcSopenharmony_ci * @brief get the Locked State 104eace7efcSopenharmony_ci * 105eace7efcSopenharmony_ci * @return the lockedState 106eace7efcSopenharmony_ci */ 107eace7efcSopenharmony_ci bool IsLockedState() const; 108eace7efcSopenharmony_ci 109eace7efcSopenharmony_ci /** 110eace7efcSopenharmony_ci * @brief Set the Moving State 111eace7efcSopenharmony_ci * 112eace7efcSopenharmony_ci * @param movingState true/false 113eace7efcSopenharmony_ci */ 114eace7efcSopenharmony_ci void SetMovingState(bool movingState); 115eace7efcSopenharmony_ci 116eace7efcSopenharmony_ci /** 117eace7efcSopenharmony_ci * @brief get the Moving State 118eace7efcSopenharmony_ci * 119eace7efcSopenharmony_ci * @return the movingState 120eace7efcSopenharmony_ci */ 121eace7efcSopenharmony_ci bool IsMovingState() const; 122eace7efcSopenharmony_ci 123eace7efcSopenharmony_ci /** 124eace7efcSopenharmony_ci * @brief Set application not response state true 125eace7efcSopenharmony_ci */ 126eace7efcSopenharmony_ci void SetANRState(bool state); 127eace7efcSopenharmony_ci 128eace7efcSopenharmony_ci /** 129eace7efcSopenharmony_ci * @brief Is application not response state 130eace7efcSopenharmony_ci */ 131eace7efcSopenharmony_ci bool IsANRState() const; 132eace7efcSopenharmony_ci 133eace7efcSopenharmony_ci /** 134eace7efcSopenharmony_ci * @brief dump mission 135eace7efcSopenharmony_ci * 136eace7efcSopenharmony_ci * @param info dump result. 137eace7efcSopenharmony_ci */ 138eace7efcSopenharmony_ci void Dump(std::vector<std::string> &info); 139eace7efcSopenharmony_ci 140eace7efcSopenharmony_ci /** 141eace7efcSopenharmony_ci * @brief whether it is a form ByCall start-up 142eace7efcSopenharmony_ci * 143eace7efcSopenharmony_ci * @return true form BaCall start-up, false other 144eace7efcSopenharmony_ci */ 145eace7efcSopenharmony_ci bool IsStartByCall(); 146eace7efcSopenharmony_ci 147eace7efcSopenharmony_ci /** 148eace7efcSopenharmony_ci * @brief update mission id 149eace7efcSopenharmony_ci * 150eace7efcSopenharmony_ci * @param id mission id. 151eace7efcSopenharmony_ci * @param method start method. 152eace7efcSopenharmony_ci * @return Returns true on success, false on failure 153eace7efcSopenharmony_ci */ 154eace7efcSopenharmony_ci bool UpdateMissionId(int32_t id, int32_t method); 155eace7efcSopenharmony_ci 156eace7efcSopenharmony_ci /** 157eace7efcSopenharmony_ci * Set whether to notify Launcher that the mission has been created. 158eace7efcSopenharmony_ci * 159eace7efcSopenharmony_ci * @param needNotify Indicates whether the Launcher needs to be notified. 160eace7efcSopenharmony_ci */ 161eace7efcSopenharmony_ci inline void SetNotifyLabel(bool needNotify) 162eace7efcSopenharmony_ci { 163eace7efcSopenharmony_ci needNotify_ = needNotify; 164eace7efcSopenharmony_ci } 165eace7efcSopenharmony_ci 166eace7efcSopenharmony_ci /** 167eace7efcSopenharmony_ci * Get whether to notify Launcher that the mission has been created. 168eace7efcSopenharmony_ci * 169eace7efcSopenharmony_ci * @param return Whether the Launcher needs to be notified. 170eace7efcSopenharmony_ci */ 171eace7efcSopenharmony_ci inline bool NeedNotify() const 172eace7efcSopenharmony_ci { 173eace7efcSopenharmony_ci return needNotify_; 174eace7efcSopenharmony_ci } 175eace7efcSopenharmony_ci 176eace7efcSopenharmony_ci /** 177eace7efcSopenharmony_ci * Set mission specified flag. 178eace7efcSopenharmony_ci * 179eace7efcSopenharmony_ci * @param flag specified flag. 180eace7efcSopenharmony_ci */ 181eace7efcSopenharmony_ci void SetSpecifiedFlag(const std::string &flag); 182eace7efcSopenharmony_ci 183eace7efcSopenharmony_ci /** 184eace7efcSopenharmony_ci * Get mission specified flag. 185eace7efcSopenharmony_ci * 186eace7efcSopenharmony_ci * @return specified flag. 187eace7efcSopenharmony_ci */ 188eace7efcSopenharmony_ci std::string GetSpecifiedFlag() const; 189eace7efcSopenharmony_ci 190eace7efcSopenharmony_ci inline void SetNeedNotifyUpdateLabel(bool flag) 191eace7efcSopenharmony_ci { 192eace7efcSopenharmony_ci needNotifyUpdateLabel_ = flag; 193eace7efcSopenharmony_ci } 194eace7efcSopenharmony_ci 195eace7efcSopenharmony_ci inline bool NeedNotifyUpdateLabel() const 196eace7efcSopenharmony_ci { 197eace7efcSopenharmony_ci return needNotifyUpdateLabel_; 198eace7efcSopenharmony_ci } 199eace7efcSopenharmony_ci 200eace7efcSopenharmony_ci inline void UpdateMissionTime(const std::string &missionTime) 201eace7efcSopenharmony_ci { 202eace7efcSopenharmony_ci missionTime_ = missionTime; 203eace7efcSopenharmony_ci } 204eace7efcSopenharmony_ci 205eace7efcSopenharmony_ci inline std::string GetMissionTime() const 206eace7efcSopenharmony_ci { 207eace7efcSopenharmony_ci return missionTime_; 208eace7efcSopenharmony_ci } 209eace7efcSopenharmony_ci 210eace7efcSopenharmony_ci inline void SetUnclearable(const bool &unclearable) 211eace7efcSopenharmony_ci { 212eace7efcSopenharmony_ci unclearable_ = unclearable; 213eace7efcSopenharmony_ci } 214eace7efcSopenharmony_ci 215eace7efcSopenharmony_ci bool IsUnclearable() 216eace7efcSopenharmony_ci { 217eace7efcSopenharmony_ci return unclearable_; 218eace7efcSopenharmony_ci } 219eace7efcSopenharmony_ci 220eace7efcSopenharmony_ciprivate: 221eace7efcSopenharmony_ci int32_t missionId_; 222eace7efcSopenharmony_ci int32_t startMethod_; 223eace7efcSopenharmony_ci std::shared_ptr<AbilityRecord> abilityRecord_; 224eace7efcSopenharmony_ci std::string missionName_; 225eace7efcSopenharmony_ci std::string specifiedFlag_; 226eace7efcSopenharmony_ci std::weak_ptr<MissionList> ownerMissionList_; 227eace7efcSopenharmony_ci bool lockedState_ = false; 228eace7efcSopenharmony_ci bool isMovingToFront_ = false; 229eace7efcSopenharmony_ci bool isANRState_ = false; 230eace7efcSopenharmony_ci bool needNotify_ = true; 231eace7efcSopenharmony_ci bool needNotifyUpdateLabel_ = false; 232eace7efcSopenharmony_ci std::string missionTime_ = "0"; 233eace7efcSopenharmony_ci bool unclearable_ = false; 234eace7efcSopenharmony_ci}; 235eace7efcSopenharmony_ci} // namespace AAFwk 236eace7efcSopenharmony_ci} // namespace OHOS 237eace7efcSopenharmony_ci#endif // OHOS_ABILITY_RUNTIME_MISSION_H 238