1 /* 2 * Copyright (c) 2025 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 MOCK_SYSTEM_ABILITY_H 17 #define MOCK_SYSTEM_ABILITY_H 18 19 #include <string> 20 21 #include "iremote_object.h" 22 #include "refbase.h" 23 24 namespace OHOS { 25 enum { 26 ABILITY_MGR_SERVICE_ID = 180, 27 BUNDLE_MGR_SERVICE_SYS_ABILITY_ID = 401, 28 DISTRIBUTED_SCHED_SA_ID = 1401, 29 BACKGROUND_TASK_MANAGER_SERVICE_ID = 1903, 30 MULTIMODAL_INPUT_SERVICE_ID = 3101, 31 WINDOW_MANAGER_SERVICE_ID = 4606, 32 }; 33 34 #define DECLEAR_SYSTEM_ABILITY(className) \ 35 public: \ 36 std::string GetClassName() { \ 37 return #className; \ 38 } 39 40 class SystemAbility { 41 public: SystemAbility()42 SystemAbility() {} 43 SystemAbility(int32_t systemAbilityId, bool runOnCreate = false) {} MakeAndRegisterAbility(SystemAbility * systemAbility)44 static bool MakeAndRegisterAbility(SystemAbility* systemAbility) 45 { 46 return false; 47 } 48 AddSystemAbilityListener(int32_t systemAbilityId)49 bool AddSystemAbilityListener(int32_t systemAbilityId) 50 { 51 return false; 52 } 53 54 protected: OnStart()55 virtual void OnStart() {} 56 OnStop()57 virtual void OnStop() {} 58 OnAddSystemAbility(int32_t systemAbilityId,const std::string & deviceId)59 virtual void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) {} 60 OnRemoveSystemAbility(int32_t systemAbilityId,const std::string & deviceId)61 virtual void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId) {} 62 GetSystemAbility(int32_t systemAbilityId)63 sptr<IRemoteObject> GetSystemAbility(int32_t systemAbilityId) 64 { 65 return nullptr; 66 } 67 Publish(sptr<IRemoteObject> systemAbility)68 bool Publish(sptr<IRemoteObject> systemAbility) 69 { 70 return false; 71 } 72 }; 73 } 74 #endif