1 /* 2 * Copyright (C) 2025-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 #include "interoperable_client_manager.h" 17 #include "telephony_log_wrapper.h" 18 #include "call_object_manager.h" 19 #include "transmission_manager.h" 20 21 namespace OHOS { 22 namespace Telephony { 23 constexpr const char* SOFTNET_SESSION_NAME = "ohos.telephony.callmanager.interoperable_communication"; 24 OnCallCreated(const sptr<CallBase> & call,const std::string & networkId)25void InteroperableClientManager::OnCallCreated(const sptr<CallBase> &call, const std::string &networkId) 26 { 27 ConnectRemote(networkId); 28 } 29 OnCallDestroyed()30void InteroperableClientManager::OnCallDestroyed() 31 { 32 if (session_ != nullptr) { 33 TELEPHONY_LOGI("disconnect session_"); 34 session_->Disconnect(); 35 session_.reset(); 36 session_ = nullptr; 37 } 38 } 39 ConnectRemote(const std::string & networkId)40void InteroperableClientManager::ConnectRemote(const std::string &networkId) 41 { 42 if (session_ != nullptr) { 43 return; 44 } 45 auto transMgr = DelayedSingleton<TransmissionManager>::GetInstance(); 46 session_ = transMgr->CreateClientSession(shared_from_this()); 47 if (session_ != nullptr) { 48 TELEPHONY_LOGI("connect session_"); 49 session_->Connect(networkId, SOFTNET_SESSION_NAME, SOFTNET_SESSION_NAME); 50 } 51 } 52 } // namespace Telephony 53 } // namespace OHOS