1 /* 2 * Copyright (c) 2021 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 MODULETEST_OHOS_ABILITY_RUNTIME_SYSTEM_ABILITY_H 17 #define MODULETEST_OHOS_ABILITY_RUNTIME_SYSTEM_ABILITY_H 18 19 #include "hilog/log.h" 20 #include "iremote_object.h" 21 namespace OHOS { 22 #define REGISTER_SYSTEM_ABILITY_BY_ID(a, b, c) 23 #define REGISTER_SYSTEM_ABILITY(abilityClassName, abilityId, runOnCreate) 24 #define DECLEAR_SYSTEM_ABILITY(className) 25 static constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0xD001100, "MockSystemAbility"}; 26 27 class SystemAbility { 28 public: MakeAndRegisterAbility(SystemAbility *)29 static bool MakeAndRegisterAbility(SystemAbility *) 30 { 31 return true; 32 } 33 34 bool AddSystemAbilityListener(int32_t systemAbilityId); 35 36 protected: OnStart()37 virtual void OnStart() 38 { 39 HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility OnStart called"); 40 } 41 OnStop()42 virtual void OnStop() 43 { 44 HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility OnStop called"); 45 } 46 OnAddSystemAbility(int32_t systemAbilityId,const std::string & deviceId)47 virtual void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) 48 { 49 HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility OnAddSystemAbility called"); 50 } 51 OnRemoveSystemAbility(int32_t systemAbilityId,const std::string & deviceId)52 virtual void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId) 53 { 54 HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility OnRemoveSystemAbility called"); 55 } 56 Publish(sptr<IRemoteObject> systemAbility)57 bool Publish(sptr<IRemoteObject> systemAbility) 58 { 59 HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility Publish called"); 60 systemAbility.ForceSetRefPtr(nullptr); 61 return true; 62 } 63 64 explicit SystemAbility(bool runOnCreate = false) 65 { 66 HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility default Creator called %d", runOnCreate); 67 } 68 69 SystemAbility(const int32_t serviceId, bool runOnCreate = false) 70 { 71 HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility Creator called %d", runOnCreate); 72 } 73 ~SystemAbility()74 virtual ~SystemAbility() 75 { 76 HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility Destructor called"); 77 } 78 }; 79 } // namespace OHOS 80 #endif // MODULETEST_OHOS_ABILITY_RUNTIME_SYSTEM_ABILITY_H 81