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_STACK_MANAGER_H
17 #define OHOS_ABILITY_STACK_MANAGER_H
18 
19 #include <string>
20 
21 #include "ability_mission_stack.h"
22 #include "ability_mgr_context.h"
23 #include "ability_info.h"
24 #include "bundle_info.h"
25 #include "nocopyable.h"
26 #include "want.h"
27 
28 namespace OHOS {
29 class AbilityStackManager : public NoCopyable {
30 public:
GetInstance()31     static AbilityStackManager &GetInstance()
32     {
33         static AbilityStackManager instance;
34         return instance;
35     };
36     ~AbilityStackManager() = default;
37 
38     PageAbilityRecord *GeneratePageAbility(const AbilityInfo &target,
39         const Want &want, const PageAbilityRecord *topAbility, AbilityMgrContext &amsContext) const;
40     PageAbilityRecord *FindPageAbility(const AbilityMgrContext &amsContext, uint64_t token) const;
41     const PageAbilityRecord *FindPageAbility(const AbilityMgrContext &amsContext, const Want &want) const;
42     const PageAbilityRecord *GetTopPageAbility(const AbilityMgrContext &amsContext) const;
43     const PageAbilityRecord *GetPrevPageAbility(const AbilityMgrContext &amsContext,
44         const PageAbilityRecord &current) const;
45     void RemovePageAbility(const PageAbilityRecord &target, AbilityMgrContext &amsContext);
46     bool ExistAppInStack(const AbilityInfo &target, AbilityMgrContext &amsContext) const;
47     void ClearAbilityStack(const char *bundleName, AbilityMgrContext &amsContext) const;
48 #ifdef OHOS_DEBUG
49     AbilityMsStatus DumpAllAbilityRecord(const AbilityMgrContext &amsContext) const;
50 #endif
51     PageAbilityRecord *FindServiceAbility(const AbilityMgrContext &amsContext, uint64_t token) const;
52     PageAbilityRecord *FindServiceAbility(const AbilityMgrContext &amsContext, const char *bundleName,
53         const char *abilityName) const;
54 private:
55     AbilityStackManager() = default;
56 };
57 } // namespace OHOS
58 #endif // OHOS_ABILITY_STACK_MANAGER_H
59