1 /* 2 * Copyright (c) 2022-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 16 #include "iservice_registry.h" 17 18 #include <cstddef> 19 #include <future> 20 #include <gtest/gtest.h> 21 22 #include "system_ability_definition.h" 23 #include "system_ability_manager_proxy.h" 24 #include "utils_mock_global_variable.h" 25 26 namespace OHOS { 27 using namespace FileManagement::Backup; 28 GetInstance()29SystemAbilityManagerClient &SystemAbilityManagerClient::GetInstance() 30 { 31 static auto instance = new SystemAbilityManagerClient(); 32 return *instance; 33 } 34 GetSystemAbilityManager()35sptr<ISystemAbilityManager> SystemAbilityManagerClient::GetSystemAbilityManager() 36 { 37 GTEST_LOG_(INFO) << "GetSystemAbilityManager is ok"; 38 std::lock_guard<std::mutex> lock(systemAbilityManagerLock_); 39 if (systemAbilityManager_ != nullptr) { 40 return systemAbilityManager_; 41 } 42 43 systemAbilityManager_ = new SystemAbilityManagerProxy(nullptr); 44 return systemAbilityManager_; 45 } 46 LoadSystemAbility(int32_t systemAbilityId,const sptr<ISystemAbilityLoadCallback> & callback)47int32_t SystemAbilityManagerProxy::LoadSystemAbility(int32_t systemAbilityId, 48 const sptr<ISystemAbilityLoadCallback> &callback) 49 { 50 GTEST_LOG_(INFO) << "LoadSystemAbility is ok"; 51 if (!GetMockLoadSystemAbility()) { 52 return -1; 53 } 54 return ERR_OK; 55 } 56 } // namespace OHOS