1 /*
2  * Copyright (c) 2020 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_SLITE_ABILITY_LIST_H
17 #define OHOS_ABILITY_SLITE_ABILITY_LIST_H
18 
19 #include "ability_record.h"
20 #include "cmsis_os2.h"
21 #include "mission_info.h"
22 #include "utils_list.h"
23 
24 namespace OHOS {
25 namespace AbilitySlite {
26 constexpr char MAIN_BUNDLE_NAME[] = "main";
27 const uint32_t LAUNCHER_TOKEN = 0;
28 
29 class AbilityList {
30 public:
31     AbilityList();
32 
33     ~AbilityList();
34 
35     void Add(AbilityRecord *abilityRecord);
36 
37     AbilityRecord *Get(uint16_t token) const;
38 
39     AbilityRecord *Get(const char *bundleName) const;
40 
41     AbilityRecord *GetByTaskId(uint32_t taskId) const;
42 
43     void Erase(uint16_t token);
44 
45     uint32_t Size() const;
46 
47     bool MoveToTop(uint16_t token);
48 
49     void PopAbility();
50 
51     AbilityRecord *GetTopAbility() const;
52 
53     MissionInfoList *GetMissionInfos(uint32_t maxNum) const;
54 
55     void GetAbilityList(uint32_t mission, List<uint32_t> &result);
56 
57     void PopBottomAbility();
58 
59     int32_t PopAllAbility(const char *excludedBundleName);
60 
61     static bool IsPermanentAbility(const AbilityRecord &abilityRecord);
62 
63 private:
64     List<AbilityRecord *> abilityList_ {};
65     mutable osMutexId_t abilityListMutex_;
66 };
67 } // AbilitySlite
68 } // namespace OHOS
69 #endif // OHOS_ABILITY_SLITE_ABILITY_LIST_H
70