1 /*
2 * Copyright (c) 2022 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 "communication_provider_impl.h"
17
18 #include <logger.h>
19
20 namespace OHOS {
21 namespace ObjectStore {
22 std::mutex CommunicationProviderImpl::mutex_;
CommunicationProviderImpl(AppPipeMgr & appPipeMgr,AppDeviceHandler & deviceHandler)23 CommunicationProviderImpl::CommunicationProviderImpl(AppPipeMgr &appPipeMgr, AppDeviceHandler &deviceHandler)
24 : appPipeMgr_(appPipeMgr), appDeviceHandler_(deviceHandler)
25 {
26 }
27
~CommunicationProviderImpl()28 CommunicationProviderImpl::~CommunicationProviderImpl()
29 {
30 LOG_DEBUG("destructor.");
31 }
32
Initialize()33 Status CommunicationProviderImpl::Initialize()
34 {
35 appDeviceHandler_.Init();
36 return Status::SUCCESS;
37 }
38
StartWatchDeviceChange(const AppDeviceStatusChangeListener * observer,const PipeInfo & pipeInfo)39 Status CommunicationProviderImpl::StartWatchDeviceChange(
40 const AppDeviceStatusChangeListener *observer, const PipeInfo &pipeInfo)
41 {
42 return appDeviceHandler_.StartWatchDeviceChange(observer, pipeInfo);
43 }
44
StopWatchDeviceChange(const AppDeviceStatusChangeListener * observer,const PipeInfo & pipeInfo)45 Status CommunicationProviderImpl::StopWatchDeviceChange(
46 const AppDeviceStatusChangeListener *observer, const PipeInfo &pipeInfo)
47 {
48 return appDeviceHandler_.StopWatchDeviceChange(observer, pipeInfo);
49 }
50
GetLocalDevice() const51 DeviceInfo CommunicationProviderImpl::GetLocalDevice() const
52 {
53 return appDeviceHandler_.GetLocalDevice();
54 }
55
GetDeviceList() const56 std::vector<DeviceInfo> CommunicationProviderImpl::GetDeviceList() const
57 {
58 return appDeviceHandler_.GetDeviceList();
59 }
60
StartWatchDataChange(const AppDataChangeListener * observer,const PipeInfo & pipeInfo)61 Status CommunicationProviderImpl::StartWatchDataChange(const AppDataChangeListener *observer, const PipeInfo &pipeInfo)
62 {
63 return appPipeMgr_.StartWatchDataChange(observer, pipeInfo);
64 }
65
StopWatchDataChange(const AppDataChangeListener * observer,const PipeInfo & pipeInfo)66 Status CommunicationProviderImpl::StopWatchDataChange(const AppDataChangeListener *observer, const PipeInfo &pipeInfo)
67 {
68 return appPipeMgr_.StopWatchDataChange(observer, pipeInfo);
69 }
70
SendData(const PipeInfo & pipeInfo,const DeviceId & deviceId,const DataInfo & dataInfo,uint32_t totalLength,const MessageInfo & info)71 Status CommunicationProviderImpl::SendData(const PipeInfo &pipeInfo, const DeviceId &deviceId,
72 const DataInfo &dataInfo, uint32_t totalLength, const MessageInfo &info)
73 {
74 return appPipeMgr_.SendData(pipeInfo, deviceId, dataInfo, totalLength, info);
75 }
76
Start(const PipeInfo & pipeInfo)77 Status CommunicationProviderImpl::Start(const PipeInfo &pipeInfo)
78 {
79 return appPipeMgr_.Start(pipeInfo);
80 }
81
Stop(const PipeInfo & pipeInfo)82 Status CommunicationProviderImpl::Stop(const PipeInfo &pipeInfo)
83 {
84 return appPipeMgr_.Stop(pipeInfo);
85 }
86
IsSameStartedOnPeer(const PipeInfo & pipeInfo,const DeviceId & peer) const87 bool CommunicationProviderImpl::IsSameStartedOnPeer(const PipeInfo &pipeInfo, const DeviceId &peer) const
88 {
89 return appPipeMgr_.IsSameStartedOnPeer(pipeInfo, peer);
90 }
91 } // namespace ObjectStore
92 } // namespace OHOS
93