• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_object.h"
17 
18 #include <cstdint>
19 
20 #include "hilog_tag_wrapper.h"
21 
22 namespace {
23 CJMonitorFuncs g_cjMonitorFuncs = {};
24 }
25 
RegisterCJMonitorFuncs(void (* registerFunc)(CJMonitorFuncs *))26 void RegisterCJMonitorFuncs(void (*registerFunc)(CJMonitorFuncs*))
27 {
28     TAG_LOGD(AAFwkTag::DELEGATOR, "RegisterCJMonitorFuncs called");
29 
30     if (registerFunc == nullptr) {
31         TAG_LOGE(AAFwkTag::DELEGATOR, "null registerFunc");
32         return;
33     }
34 
35     registerFunc(&g_cjMonitorFuncs);
36     TAG_LOGD(AAFwkTag::DELEGATOR, "RegisterCJMonitorFuncs end");
37 }
38 
39 namespace OHOS {
40 namespace AbilityDelegatorCJ {
41 
CJMonitorObject(const int64_t monitorId)42 CJMonitorObject::CJMonitorObject(const int64_t monitorId) : monitorId_(monitorId) {}
43 
OnAbilityCreate(const int64_t abilityId)44 void CJMonitorObject::OnAbilityCreate(const int64_t abilityId)
45 {
46     TAG_LOGD(AAFwkTag::DELEGATOR, "CJMonitorObject::OnAbilityCreate called");
47     if (g_cjMonitorFuncs.cjOnAbilityCreate) {
48         g_cjMonitorFuncs.cjOnAbilityCreate(monitorId_, abilityId);
49     }
50 }
51 
OnAbilityForeground(const int64_t abilityId)52 void CJMonitorObject::OnAbilityForeground(const int64_t abilityId)
53 {
54     TAG_LOGD(AAFwkTag::DELEGATOR, "CJMonitorObject::OnAbilityForeground called");
55     if (g_cjMonitorFuncs.cjOnAbilityForeground) {
56         g_cjMonitorFuncs.cjOnAbilityForeground(monitorId_, abilityId);
57     }
58 }
59 
OnAbilityBackground(const int64_t abilityId)60 void CJMonitorObject::OnAbilityBackground(const int64_t abilityId)
61 {
62     TAG_LOGD(AAFwkTag::DELEGATOR, "CJMonitorObject::OnAbilityBackground called");
63     if (g_cjMonitorFuncs.cjOnAbilityBackground) {
64         g_cjMonitorFuncs.cjOnAbilityBackground(monitorId_, abilityId);
65     }
66 }
67 
OnAbilityDestroy(const int64_t abilityId)68 void CJMonitorObject::OnAbilityDestroy(const int64_t abilityId)
69 {
70     TAG_LOGD(AAFwkTag::DELEGATOR, "CJMonitorObject::OnAbilityDestroy called");
71     if (g_cjMonitorFuncs.cjOnAbilityDestroy) {
72         g_cjMonitorFuncs.cjOnAbilityDestroy(monitorId_, abilityId);
73     }
74 }
75 
OnWindowStageCreate(const int64_t abilityId)76 void CJMonitorObject::OnWindowStageCreate(const int64_t abilityId)
77 {
78     TAG_LOGD(AAFwkTag::DELEGATOR, "CJMonitorObject::OnWindowStageCreate called");
79     if (g_cjMonitorFuncs.cjOnWindowStageCreate) {
80         g_cjMonitorFuncs.cjOnWindowStageCreate(monitorId_, abilityId);
81     }
82 }
83 
OnWindowStageRestore(const int64_t abilityId)84 void CJMonitorObject::OnWindowStageRestore(const int64_t abilityId)
85 {
86     TAG_LOGD(AAFwkTag::DELEGATOR, "CJMonitorObject::OnWindowStageRestore called");
87     if (g_cjMonitorFuncs.cjOnWindowStageRestore) {
88         g_cjMonitorFuncs.cjOnWindowStageRestore(monitorId_, abilityId);
89     }
90 }
91 
OnWindowStageDestroy(const int64_t abilityId)92 void CJMonitorObject::OnWindowStageDestroy(const int64_t abilityId)
93 {
94     TAG_LOGD(AAFwkTag::DELEGATOR, "CJMonitorObject::OnWindowStageDestroy called");
95     if (g_cjMonitorFuncs.cjOnWindowStageDestroy) {
96         g_cjMonitorFuncs.cjOnWindowStageDestroy(monitorId_, abilityId);
97     }
98 }
99 } // namespace AbilityDelegatorCJ
100 } // namespace OHOS
101