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 #include "ability_slice_manager.h"
17
18 #include <ability.h>
19
20 #include "ability_slice_scheduler.h"
21 #include "ability_window.h"
22
23 namespace OHOS {
AbilitySliceManager(Ability & ability)24 AbilitySliceManager::AbilitySliceManager(Ability &ability) : ability_(ability)
25 {
26 abilitySliceScheduler_ = new AbilitySliceScheduler(*this);
27 }
28
~AbilitySliceManager()29 AbilitySliceManager::~AbilitySliceManager()
30 {
31 delete abilitySliceScheduler_;
32 abilitySliceScheduler_ = nullptr;
33 }
34
OnAbilityStart(const Want & want)35 void AbilitySliceManager::OnAbilityStart(const Want &want)
36 {
37 abilitySliceScheduler_->HandleStartAbilitySlice(want);
38 }
39
OnAbilityInactive()40 void AbilitySliceManager::OnAbilityInactive()
41 {
42 abilitySliceScheduler_->HandleInactiveAbilitySlice();
43 }
44
OnAbilityActive(const Want & want)45 void AbilitySliceManager::OnAbilityActive(const Want &want)
46 {
47 abilitySliceScheduler_->HandleActiveAbilitySlice(want);
48 }
49
OnAbilityBackground()50 void AbilitySliceManager::OnAbilityBackground()
51 {
52 abilitySliceScheduler_->HandleMoveAbilitySliceToBackground();
53 }
54
OnAbilityStop()55 void AbilitySliceManager::OnAbilityStop()
56 {
57 abilitySliceScheduler_->HandleStopAbilitySlice();
58 }
59
Present(const AbilitySlice & caller,AbilitySlice & target,const Want & want)60 void AbilitySliceManager::Present(const AbilitySlice &caller, AbilitySlice &target, const Want &want)
61 {
62 abilitySliceScheduler_->AddAbilitySlice(caller, target, want);
63 }
64
Terminate(AbilitySlice & slice)65 void AbilitySliceManager::Terminate(AbilitySlice &slice)
66 {
67 abilitySliceScheduler_->RemoveAbilitySlice(slice);
68 }
69
SetMainRoute(const std::string & entry)70 void AbilitySliceManager::SetMainRoute(const std::string &entry)
71 {
72 abilitySliceScheduler_->SetMainRoute(entry);
73 }
74
AddActionRoute(const std::string & action,const std::string & entry)75 void AbilitySliceManager::AddActionRoute(const std::string &action, const std::string &entry)
76 {
77 abilitySliceScheduler_->AddActionRoute(action, entry);
78 }
79
SetUIContent(RootView * rootView)80 void AbilitySliceManager::SetUIContent(RootView *rootView)
81 {
82 ability_.SetUIContent(rootView);
83 }
84
GetAbilityState()85 int AbilitySliceManager::GetAbilityState()
86 {
87 return ability_.GetState();
88 }
89
TerminateAbility()90 int AbilitySliceManager::TerminateAbility()
91 {
92 return ability_.TerminateAbility();
93 }
94
GetSliceStackInfo() const95 std::string AbilitySliceManager::GetSliceStackInfo() const
96 {
97 return abilitySliceScheduler_->GetSliceStackInfo();
98 }
99
GetToken() const100 uint64_t AbilitySliceManager::GetToken() const
101 {
102 return ability_.token_;
103 }
104 } // namespace OHOS