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