1 /* 2 * Copyright (c) 2023 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 #ifndef SEC_COMP_MOCK_SYSTEM_ABILITY_IF_MANAGER_CLINET_INCLUDE_H 16 #define SEC_COMP_MOCK_SYSTEM_ABILITY_IF_MANAGER_CLINET_INCLUDE_H 17 #include "iremote_broker.h" 18 #include "iremote_object.h" 19 #include "iremote_proxy.h" 20 #include "mock_app_mgr_proxy.h" 21 22 namespace OHOS { 23 class MockIRemoteObject : public virtual RefBase { 24 public: AddDeathRecipient(const sptr<IPCObjectProxy::DeathRecipient> & recipient)25 bool AddDeathRecipient(const sptr<IPCObjectProxy::DeathRecipient>& recipient) 26 { 27 (void)recipient; 28 return addResult; 29 } 30 bool addResult = true; 31 }; 32 iface_cast(const sptr<MockIRemoteObject> & object)33template <typename INTERFACE> inline sptr<INTERFACE> iface_cast(const sptr<MockIRemoteObject> &object) 34 { 35 if (object == nullptr) { 36 return nullptr; 37 } 38 const std::u16string descriptor = INTERFACE::GetDescriptor(); 39 if (descriptor == u"ohos.appexecfwk.mock.AppMgr") { 40 return static_cast<INTERFACE *>(MockAppMgrProxy::g_MockAppMgrProxy); 41 } 42 return nullptr; 43 } 44 45 class ISystemAbilityManager : public IRemoteBroker { 46 public: 47 virtual sptr<MockIRemoteObject> GetSystemAbility(int32_t systemAbilityId) = 0; 48 virtual int32_t UnloadSystemAbility(int32_t systemAbilityId) = 0; 49 }; 50 } // namespace OHOS 51 #endif // SEC_COMP_MOCK_SYSTEM_ABILITY_IF_MANAGER_CLINET_INCLUDE_H 52