1 /* 2 * Copyright (c) 2022 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_RUNTIME_CJ_ABILITY_MONITOR_H 17 #define OHOS_ABILITY_RUNTIME_CJ_ABILITY_MONITOR_H 18 19 #include "cj_ability_monitor_object.h" 20 #include "cj_iability_monitor.h" 21 22 namespace OHOS { 23 namespace AbilityDelegatorCJ { 24 using namespace OHOS::AppExecFwk; 25 class CJAbilityMonitor : public CJIAbilityMonitor { 26 public: 27 /** 28 * A constructor used to create a CJAbilityMonitor instance with the input 29 * parameter passed. 30 * 31 * @param name Indicates the specified ability name. 32 * @param cjAbilityMonitor Indicates the CJMonitorObject object. 33 */ 34 CJAbilityMonitor(const std::string& name, const std::shared_ptr<CJMonitorObject>& cjAbilityMonitor); 35 36 /** 37 * A constructor used to create a CJAbilityMonitor instance with the input 38 * parameter passed. 39 * 40 * @param name Indicates the specified ability name. 41 * @param moduleName Indicates the specified ability moduleName. 42 * @param cjAbilityMonitor Indicates the CJMonitorObject object. 43 */ 44 CJAbilityMonitor(const std::string& name, const std::string& moduleName, 45 const std::shared_ptr<CJMonitorObject>& cjAbilityMonitor); 46 47 /** 48 * Default deconstructor used to deconstruct. 49 */ 50 ~CJAbilityMonitor() = default; 51 52 /** 53 * Called when ability is started. 54 * 55 * @param abilityId Indicates the ability object. 56 */ 57 void OnAbilityStart(const int64_t abilityId) override; 58 59 /** 60 * Called when ability is in foreground. 61 * 62 * @param abilityId Indicates the ability object. 63 */ 64 void OnAbilityForeground(const int64_t abilityId) override; 65 66 /** 67 * Called when ability is in background. 68 * 69 * @param abilityId Indicates the ability object. 70 */ 71 void OnAbilityBackground(const int64_t abilityId) override; 72 73 /** 74 * Called when ability is stopped. 75 * 76 * @param abilityId Indicates the ability object. 77 */ 78 void OnAbilityStop(const int64_t abilityId) override; 79 80 /** 81 * Called when window stage is created. 82 * 83 * @param abilityId Indicates the ability object. 84 */ 85 void OnWindowStageCreate(const int64_t abilityId) override; 86 87 /** 88 * Called when window stage is restored. 89 * 90 * @param abilityId Indicates the ability object. 91 */ 92 void OnWindowStageRestore(const int64_t abilityId) override; 93 94 /** 95 * Called when window stage is destroyed. 96 * 97 * @param abilityId Indicates the ability object. 98 */ 99 void OnWindowStageDestroy(const int64_t abilityId) override; 100 101 private: 102 std::shared_ptr<CJMonitorObject> cjMonitor_; 103 }; 104 } // namespace AbilityDelegatorCJ 105 } // namespace OHOS 106 #endif // OHOS_ABILITY_RUNTIME_CJ_ABILITY_MONITOR_H 107