1 /*
2 * Copyright (c) 2022-2024 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 "cj_ability_monitor.h"
17
18 #include "cj_ability_monitor_object.h"
19 #include "hilog_tag_wrapper.h"
20
21 namespace OHOS {
22 namespace AbilityDelegatorCJ {
23
CJAbilityMonitor(const std::string & name,const std::shared_ptr<CJMonitorObject> & cjAbilityMonitor)24 CJAbilityMonitor::CJAbilityMonitor(const std::string& name, const std::shared_ptr<CJMonitorObject>& cjAbilityMonitor)
25 : CJIAbilityMonitor(name), cjMonitor_(cjAbilityMonitor)
26 {}
27
CJAbilityMonitor(const std::string & name,const std::string & moduleName,const std::shared_ptr<CJMonitorObject> & cjAbilityMonitor)28 CJAbilityMonitor::CJAbilityMonitor(
29 const std::string& name, const std::string& moduleName, const std::shared_ptr<CJMonitorObject>& cjAbilityMonitor)
30 : CJIAbilityMonitor(name, moduleName), cjMonitor_(cjAbilityMonitor)
31 {}
32
OnAbilityStart(const int64_t abilityId)33 void CJAbilityMonitor::OnAbilityStart(const int64_t abilityId)
34 {
35 TAG_LOGD(AAFwkTag::DELEGATOR, "CJAbilityMonitor::OnAbilityStart called");
36
37 if (cjMonitor_ == nullptr) {
38 return;
39 }
40
41 cjMonitor_->OnAbilityCreate(abilityId);
42 }
43
OnAbilityForeground(const int64_t abilityId)44 void CJAbilityMonitor::OnAbilityForeground(const int64_t abilityId)
45 {
46 TAG_LOGD(AAFwkTag::DELEGATOR, "CJAbilityMonitor::OnAbilityForeground called");
47
48 if (cjMonitor_ == nullptr) {
49 return;
50 }
51
52 cjMonitor_->OnAbilityForeground(abilityId);
53 }
54
OnAbilityBackground(const int64_t abilityId)55 void CJAbilityMonitor::OnAbilityBackground(const int64_t abilityId)
56 {
57 TAG_LOGD(AAFwkTag::DELEGATOR, "CJAbilityMonitor::OnAbilityBackground called");
58
59 if (cjMonitor_ == nullptr) {
60 return;
61 }
62
63 cjMonitor_->OnAbilityBackground(abilityId);
64 }
65
OnAbilityStop(const int64_t abilityId)66 void CJAbilityMonitor::OnAbilityStop(const int64_t abilityId)
67 {
68 TAG_LOGD(AAFwkTag::DELEGATOR, "CJAbilityMonitor::OnAbilityStop called");
69
70 if (cjMonitor_ == nullptr) {
71 return;
72 }
73
74 cjMonitor_->OnAbilityDestroy(abilityId);
75 }
76
OnWindowStageCreate(const int64_t abilityId)77 void CJAbilityMonitor::OnWindowStageCreate(const int64_t abilityId)
78 {
79 TAG_LOGD(AAFwkTag::DELEGATOR, "CJAbilityMonitor::OnWindowStageCreate called");
80
81 if (cjMonitor_ == nullptr) {
82 return;
83 }
84
85 cjMonitor_->OnWindowStageCreate(abilityId);
86 }
87
OnWindowStageRestore(const int64_t abilityId)88 void CJAbilityMonitor::OnWindowStageRestore(const int64_t abilityId)
89 {
90 TAG_LOGD(AAFwkTag::DELEGATOR, "CJAbilityMonitor::OnWindowStageRestore called");
91
92 if (cjMonitor_ == nullptr) {
93 return;
94 }
95
96 cjMonitor_->OnWindowStageRestore(abilityId);
97 }
98
OnWindowStageDestroy(const int64_t abilityId)99 void CJAbilityMonitor::OnWindowStageDestroy(const int64_t abilityId)
100 {
101 TAG_LOGD(AAFwkTag::DELEGATOR, "CJAbilityMonitor::OnWindowStageDestroy called");
102
103 if (cjMonitor_ == nullptr) {
104 return;
105 }
106
107 cjMonitor_->OnWindowStageDestroy(abilityId);
108 }
109 } // namespace AbilityDelegatorCJ
110 } // namespace OHOS