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_SLICE_SCHEDULER_H
17 #define OHOS_ABILITY_SLICE_SCHEDULER_H
18 
19 #include <want.h>
20 
21 #include "ability_slice_manager.h"
22 #include "ability_slice_route.h"
23 #include "ability_slice_stack.h"
24 
25 namespace OHOS {
26 class AbilitySliceScheduler {
27 public:
28     explicit AbilitySliceScheduler(AbilitySliceManager &abilitySliceManager);
29     ~AbilitySliceScheduler();
30 
31     void HandleStartAbilitySlice(const Want &want);
32     void HandleInactiveAbilitySlice();
33     void HandleActiveAbilitySlice(const Want &want);
34     void HandleMoveAbilitySliceToBackground();
35     void HandleStopAbilitySlice();
36 
37     void AddAbilitySlice(const AbilitySlice &caller, AbilitySlice &target, const Want &want);
38     void RemoveAbilitySlice(AbilitySlice &slice);
39 
40     void SetMainRoute(const std::string &entry);
41     void AddActionRoute(const std::string &action, const std::string &entry);
42 
43     const std::string GetSliceStackInfo() const;
44 private:
45     AbilitySlice *GetTargetAbilitySlice() const;
46     bool CheckLegalForAdd(const AbilitySlice &caller, AbilitySlice &target, const Want &want);
47     bool CheckLegalForRemove(const AbilitySlice &slice);
48 
49     AbilitySliceRoute *abilitySliceRoute_ { nullptr };
50     AbilitySliceStack *abilitySliceStack_ { nullptr };
51     AbilitySlice *topAbilitySlice_ { nullptr };
52     AbilitySliceManager &abilitySliceManager_;
53 };
54 } // namespace OHOS
55 
56 #endif // OHOS_ABILITY_SLICE_SCHEDULER_H
57 
58