• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-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 #include "bluetooth_map_mce_server.h"
16 #include "interface_adapter_manager.h"
17 #include "interface_profile_manager.h"
18 #include "interface_profile_map_mce.h"
19 #include "bluetooth_log.h"
20 #include "bluetooth_utils.h"
21 #include "remote_observer_list.h"
22 
23 using namespace OHOS::bluetooth;
24 
25 namespace OHOS {
26 namespace Bluetooth {
27 /**
28  * @brief make oberser for framework
29  */
30 class BluetoothMapMceObserverImpl : public IProfileMapMceObserver {
31 public:
32     explicit BluetoothMapMceObserverImpl(RemoteObserverList<IBluetoothMapMceObserver> *observerList);
33     ~BluetoothMapMceObserverImpl();
34     void OnMapActionCompleted(
35         const RawAddress &deviceAddress, const IProfileMapAction &action, MapExecuteStatus status) override;
36     void OnMapEventReported(const RawAddress &deviceAddress, const IProfileMapEventReport &report) override;
37     void OnConnectionStateChanged(const RawAddress &deviceAddress, int state) override;
38     void OnBmessageCompleted(
39         const RawAddress &deviceAddress, const IProfileBMessage &bmsg, MapExecuteStatus status) override;
40     void OnMessagesListingCompleted(
41         const RawAddress &deviceAddress, const IProfileMessagesListing &listing, MapExecuteStatus status) override;
42     void OnConversationListingCompleted(
43         const RawAddress &deviceAddress, const IProfileConversationListing &listing, MapExecuteStatus status) override;
44 
45 private:
46     RemoteObserverList<IBluetoothMapMceObserver> *frameworkObserverList_;
47 };
48 
BluetoothMapMceObserverImpl(RemoteObserverList<IBluetoothMapMceObserver> * observerList)49 BluetoothMapMceObserverImpl::BluetoothMapMceObserverImpl(RemoteObserverList<IBluetoothMapMceObserver> *observerList)
50 {
51     frameworkObserverList_ = observerList;
52 }
~BluetoothMapMceObserverImpl()53 BluetoothMapMceObserverImpl::~BluetoothMapMceObserverImpl()
54 {}
OnMapActionCompleted(const RawAddress & deviceAddress,const IProfileMapAction & action,MapExecuteStatus status)55 void BluetoothMapMceObserverImpl::OnMapActionCompleted(
56     const RawAddress &deviceAddress, const IProfileMapAction &action, MapExecuteStatus status)
57 {
58     BluetoothIProfileMapAction bAction;
59 
60     bAction.action_ = action.action_;
61     bAction.ownerStatus_ = action.ownerStatus_;
62     bAction.supportedFeatures_ = action.supportedFeatures_;
63 
64     frameworkObserverList_->ForEach([deviceAddress, bAction, status](IBluetoothMapMceObserver *observer) {
65         observer->OnMapActionCompleted(deviceAddress, bAction, (int)status);
66     });
67 }
OnMapEventReported(const RawAddress & deviceAddress,const IProfileMapEventReport & report)68 void BluetoothMapMceObserverImpl::OnMapEventReported(
69     const RawAddress &deviceAddress, const IProfileMapEventReport &report)
70 {
71     BluetoothIProfileMapEventReport fEventReport;
72 
73     fEventReport.type = report.type;
74     fEventReport.handle = report.handle;
75     fEventReport.folder = report.folder;
76     fEventReport.old_folder = report.old_folder;
77     fEventReport.msg_type = report.msg_type;
78     fEventReport.datetime = report.datetime;
79     fEventReport.subject = report.subject;
80     fEventReport.sender_name = report.sender_name;
81     fEventReport.priority = report.priority;
82     fEventReport.conversation_name = report.conversation_name;
83     fEventReport.conversation_id = report.conversation_id;
84     fEventReport.presence_availability = report.presence_availability;
85     fEventReport.presence_text = report.presence_text;
86     fEventReport.last_activity = report.last_activity;
87     fEventReport.chat_state = report.chat_state;
88     fEventReport.read_status = report.read_status;
89     fEventReport.extended_data = report.extended_data;
90     fEventReport.participant_uci = report.participant_uci;
91     fEventReport.contact_uid = report.contact_uid;
92     fEventReport.version = report.version;
93     fEventReport.masInstanceId_ = report.masInstanceId_;
94     fEventReport.eventReportStringObject_ = report.eventReportStringObject_;
95 
96     frameworkObserverList_->ForEach([deviceAddress, fEventReport](IBluetoothMapMceObserver *observer) {
97         observer->OnMapEventReported(deviceAddress, fEventReport);
98     });
99 }
OnConnectionStateChanged(const RawAddress & deviceAddress,int state)100 void BluetoothMapMceObserverImpl::OnConnectionStateChanged(const RawAddress &deviceAddress, int state)
101 {
102     frameworkObserverList_->ForEach([deviceAddress, state](IBluetoothMapMceObserver *observer) {
103         observer->OnConnectionStateChanged(deviceAddress, state);
104     });
105 }
OnBmessageCompleted(const RawAddress & deviceAddress,const IProfileBMessage & bmsg,MapExecuteStatus status)106 void BluetoothMapMceObserverImpl::OnBmessageCompleted(
107     const RawAddress &deviceAddress, const IProfileBMessage &bmsg, MapExecuteStatus status)
108 {
109     int fStatus = (int)status;
110     BluetoothIProfileBMessage fmsg;
111 
112     fmsg.FractionDeliver = bmsg.FractionDeliver;
113     fmsg.bMessageParam_ = bmsg.bMessageParam_;
114     fmsg.bMessageStringObject_ = bmsg.bMessageStringObject_;
115 
116     frameworkObserverList_->ForEach([deviceAddress, fmsg, fStatus](IBluetoothMapMceObserver *observer) {
117         observer->OnBmessageCompleted(deviceAddress, fmsg, fStatus);
118     });
119 }
OnMessagesListingCompleted(const RawAddress & deviceAddress,const IProfileMessagesListing & listing,MapExecuteStatus status)120 void BluetoothMapMceObserverImpl::OnMessagesListingCompleted(
121     const RawAddress &deviceAddress, const IProfileMessagesListing &listing, MapExecuteStatus status)
122 {
123     int fStatus = (int)status;
124     BluetoothIProfileMessagesListing fListing;
125 
126     fListing.messageOutlineList_ = listing.messageOutlineList_;
127     fListing.messagesListingParam_ = listing.messagesListingParam_;
128     fListing.messagesListingStringObject_ = listing.messagesListingStringObject_;
129 
130     frameworkObserverList_->ForEach([deviceAddress, fListing, fStatus](IBluetoothMapMceObserver *observer) {
131         observer->OnMessagesListingCompleted(deviceAddress, fListing, fStatus);
132     });
133 }
OnConversationListingCompleted(const RawAddress & deviceAddress,const IProfileConversationListing & listing,MapExecuteStatus status)134 void BluetoothMapMceObserverImpl::OnConversationListingCompleted(
135     const RawAddress &deviceAddress, const IProfileConversationListing &listing, MapExecuteStatus status)
136 {
137     int fStatus = (int)status;
138     BluetoothIProfileConversationListing fListing;
139 
140     fListing.conversationOutlineList_ = listing.conversationOutlineList_;
141     fListing.conversationListingParam_ = listing.conversationListingParam_;
142     fListing.conversationListingStringObject_ = listing.conversationListingStringObject_;
143 
144     frameworkObserverList_->ForEach([deviceAddress, fListing, fStatus](IBluetoothMapMceObserver *observer) {
145         observer->OnConversationListingCompleted(deviceAddress, fListing, fStatus);
146     });
147 }
148 
149 struct BluetoothMapMceServer::impl {
150     RemoteObserverList<IBluetoothMapMceObserver> observersList_;
151     BluetoothMapMceObserverImpl *observerImp_ = nullptr;
152     bluetooth::IProfileMapMce *mceService_ = nullptr;
153     class MapMceSystemStateObserver;
154     MapMceSystemStateObserver *systemStateObserver_ = nullptr;
155 };
156 
157 class BluetoothMapMceServer::impl::MapMceSystemStateObserver : public ISystemStateObserver {
158 public:
MapMceSystemStateObserver(BluetoothMapMceServer::impl * impl)159     MapMceSystemStateObserver(BluetoothMapMceServer::impl *impl) : implPtr_(impl) {};
160     ~MapMceSystemStateObserver() override = default;
OnSystemStateChange(const BTSystemState state)161     void OnSystemStateChange(const BTSystemState state) override
162     {
163         if (state == BTSystemState::ON) {
164             IProfileManager *serviceMgr = IProfileManager::GetInstance();
165             if (serviceMgr != nullptr) {
166                 implPtr_->mceService_ = (IProfileMapMce *)serviceMgr->GetProfileService(PROFILE_NAME_MAP_MCE);
167                 if (implPtr_->mceService_ != nullptr) {
168                     implPtr_->mceService_->RegisterObserver(*(implPtr_->observerImp_));  // re regist observer
169                 }
170             }
171         } else if (state == BTSystemState::OFF) {
172             implPtr_->mceService_ = nullptr;
173         } else {
174             // erro
175         }
176     }
177 
178 private:
179     BluetoothMapMceServer::impl *implPtr_;
180 };
181 
BluetoothMapMceServer()182 BluetoothMapMceServer::BluetoothMapMceServer()
183 {
184     pimpl = std::make_unique<impl>();
185 
186     IProfileManager *serviceMgr = IProfileManager::GetInstance();
187     if (serviceMgr != nullptr) {
188         pimpl->mceService_ = (IProfileMapMce *)serviceMgr->GetProfileService(PROFILE_NAME_MAP_MCE);
189         if (pimpl->mceService_ != nullptr) {
190             // register service callback
191             pimpl->observerImp_ = new BluetoothMapMceObserverImpl(&(pimpl->observersList_));
192             pimpl->mceService_->RegisterObserver(*(pimpl->observerImp_));
193         } else {
194             // erro
195             HILOGI("pimpl->mceService_ null");
196         }
197     } else {
198         // erro
199         HILOGI("serviceMgr null");
200     }
201 
202     pimpl->systemStateObserver_ = new BluetoothMapMceServer::impl::MapMceSystemStateObserver(pimpl.get());
203     IAdapterManager::GetInstance()->RegisterSystemStateObserver(*(pimpl->systemStateObserver_));
204 }
205 
~BluetoothMapMceServer()206 BluetoothMapMceServer::~BluetoothMapMceServer()
207 {
208     IProfileManager *serviceMgr = IProfileManager::GetInstance();
209     if (serviceMgr != nullptr) {
210         pimpl->mceService_ = (IProfileMapMce *)serviceMgr->GetProfileService(PROFILE_NAME_MAP_MCE);
211         if (pimpl->mceService_ != nullptr) {
212             pimpl->mceService_->DeregisterObserver(*(pimpl->observerImp_));
213         }
214         pimpl->mceService_ = nullptr;
215     }
216     if (pimpl->observerImp_ != nullptr) {
217         delete pimpl->observerImp_;
218         pimpl->observerImp_ = nullptr;
219     }
220 
221     IAdapterManager::GetInstance()->DeregisterSystemStateObserver(*(pimpl->systemStateObserver_));
222     if (pimpl->systemStateObserver_ != nullptr) {
223         delete pimpl->systemStateObserver_;
224         pimpl->systemStateObserver_ = nullptr;
225     }
226 }
227 
RegisterObserver(const sptr<IBluetoothMapMceObserver> & observer)228 void BluetoothMapMceServer::RegisterObserver(
229     const sptr<IBluetoothMapMceObserver> &observer)
230 {
231     HILOGI("start");
232     if (!observer) {
233         HILOGE("called with NULL . Ignoring.");
234         return;
235     }
236     pimpl->observersList_.Register(observer);
237     HILOGI("end");
238 }
239 
DeregisterObserver(const sptr<IBluetoothMapMceObserver> & observer)240 void BluetoothMapMceServer::DeregisterObserver(
241     const sptr<IBluetoothMapMceObserver> &observer)
242 {
243     HILOGI("start");
244     if (!observer) {
245         HILOGE("UnregisterObserver called with NULL . Ignoring.");
246         return;
247     }
248     pimpl->observersList_.Deregister(observer);
249 }
250 
Connect(const BluetoothRawAddress & device)251 int BluetoothMapMceServer::Connect(
252     const BluetoothRawAddress &device)
253 {
254     HILOGI("device: %{public}s", GetEncryptAddr(device.GetAddress()).c_str());
255     int ret = -1;
256     if (pimpl->mceService_ != nullptr) {
257         ret = pimpl->mceService_->Connect((RawAddress)device);
258     } else {
259         HILOGE("pimpl->mceService_ null");
260     }
261     HILOGI("ret: %{public}d", ret);
262     return ret;
263 }
264 
Disconnect(const BluetoothRawAddress & device)265 int BluetoothMapMceServer::Disconnect(
266     const BluetoothRawAddress &device)
267 {
268     HILOGI("device: %{public}s", GetEncryptAddr(device.GetAddress()).c_str());
269     int ret = -1;
270     if (pimpl->mceService_ != nullptr) {
271         ret =  pimpl->mceService_->Disconnect((RawAddress)device);
272     } else {
273         HILOGE("pimpl->mceService_ null");
274     }
275     HILOGI("ret: %{public}d", ret);
276     return ret;
277 }
278 
IsConnected(const BluetoothRawAddress & device)279 int BluetoothMapMceServer::IsConnected(
280     const BluetoothRawAddress &device)
281 {
282     HILOGI("device: %{public}s", GetEncryptAddr(device.GetAddress()).c_str());
283     int ret = -1;
284     if (pimpl->mceService_ != nullptr) {
285         ret =  (int)pimpl->mceService_->IsConnected((RawAddress)device);
286     } else {
287         HILOGE("pimpl->mceService_ null");
288     }
289     HILOGI("ret: %{public}d", ret);
290     return ret;
291 }
292 
GetConnectDevices(std::vector<BluetoothRawAddress> & devices)293 void BluetoothMapMceServer::GetConnectDevices(
294     std::vector<BluetoothRawAddress> &devices)
295 {
296     HILOGI("start");
297     if (pimpl->mceService_ != nullptr) {
298         std::list<RawAddress> btDevice = pimpl->mceService_->GetConnectDevices();
299         for (auto it : btDevice) {
300             devices.push_back(BluetoothRawAddress(it));
301         }
302         pimpl->mceService_->GetConnectDevices();
303     } else {
304         HILOGE("pimpl->mceService_ null");
305     }
306     HILOGI("end");
307 }
308 
GetDevicesByStates(const std::vector<int32_t> & statusList,std::vector<BluetoothRawAddress> & devices)309 void BluetoothMapMceServer::GetDevicesByStates(
310     const std::vector<int32_t> &statusList, std::vector<BluetoothRawAddress> &devices)
311 {
312     HILOGI("start");
313     std::vector<RawAddress> serviceDeviceList;
314 
315     if (pimpl->mceService_ != nullptr) {
316         serviceDeviceList = pimpl->mceService_->GetDevicesByStates(statusList);
317         RawAddress serviceDevice;
318         BluetoothRawAddress *bluetoothDevice;
319         for (auto it = serviceDeviceList.begin(); it != serviceDeviceList.end(); it++) {
320             serviceDevice = *it;
321             bluetoothDevice = new BluetoothRawAddress(serviceDevice.GetAddress());
322             devices.push_back(*bluetoothDevice);
323             delete bluetoothDevice;
324         }
325     } else {
326         HILOGE("pimpl->mceService_ null");
327     }
328     HILOGI("end");
329 }
330 
GetConnectionState(const BluetoothRawAddress & device)331 int BluetoothMapMceServer::GetConnectionState(
332     const BluetoothRawAddress &device)
333 {
334     HILOGI("device: %{public}s", GetEncryptAddr(device.GetAddress()).c_str());
335     int ret = -1;
336     if (pimpl->mceService_ != nullptr) {
337         ret =  pimpl->mceService_->GetDeviceConnectState((RawAddress)device);
338     } else {
339         HILOGE("pimpl->mceService_ null");
340     }
341     HILOGI("ret: %{public}d", ret);
342     return ret;
343 }
344 
SetConnectionStrategy(const BluetoothRawAddress & device,int32_t strategy)345 int BluetoothMapMceServer::SetConnectionStrategy(
346     const BluetoothRawAddress &device, int32_t strategy)
347 {
348     HILOGI("device: %{public}s, strategy: %{public}d", GetEncryptAddr(device.GetAddress()).c_str(), strategy);
349     int ret = -1;
350     if (pimpl->mceService_ != nullptr) {
351         ret =  pimpl->mceService_->SetConnectionStrategy((RawAddress)device, strategy);
352     } else {
353         HILOGE("pimpl->mceService_ null");
354     }
355     HILOGI("ret: %{public}d", ret);
356     return ret;
357 }
358 
GetConnectionStrategy(const BluetoothRawAddress & device)359 int BluetoothMapMceServer::GetConnectionStrategy(
360     const BluetoothRawAddress &device)
361 {
362     HILOGI("device: %{public}s", GetEncryptAddr(device.GetAddress()).c_str());
363     int ret = -1;
364     if (pimpl->mceService_ != nullptr) {
365         ret =  pimpl->mceService_->GetConnectionStrategy((RawAddress)device);
366     } else {
367         HILOGE("pimpl->mceService_ null");
368     }
369     HILOGI("ret: %{public}d", ret);
370     return ret;
371 }
372 
GetSupportedFeatures(const BluetoothRawAddress & device)373 int BluetoothMapMceServer::GetSupportedFeatures(
374     const BluetoothRawAddress &device)
375 {
376     HILOGI("device: %{public}s", GetEncryptAddr(device.GetAddress()).c_str());
377     int ret = -1;
378     if (pimpl->mceService_ != nullptr) {
379         ret =  pimpl->mceService_->GetSupportedFeatures((RawAddress)device);
380     } else {
381         HILOGE("pimpl->mceService_ null");
382     }
383     HILOGI("ret: %{public}d", ret);
384     return ret;
385 }
386 
SetNotificationFilter(const BluetoothRawAddress & device,int32_t mask)387 int BluetoothMapMceServer::SetNotificationFilter(
388     const BluetoothRawAddress &device, int32_t mask)
389 {
390     HILOGI("device: %{public}s, mask: %{public}d", GetEncryptAddr(device.GetAddress()).c_str(), mask);
391     int ret = -1;
392     if (pimpl->mceService_ != nullptr) {
393         ret =  pimpl->mceService_->SetNotificationFilter((RawAddress)device, mask);
394     } else {
395         HILOGE("pimpl->mceService_ null");
396     }
397     HILOGI("ret: %{public}d", ret);
398     return ret;
399 }
400 
UpdateInbox(const BluetoothRawAddress & device,int32_t msgType)401 int BluetoothMapMceServer::UpdateInbox(
402     const BluetoothRawAddress &device, int32_t msgType)
403 {
404     HILOGI("device: %{public}s, msgType: %{public}d", GetEncryptAddr(device.GetAddress()).c_str(), msgType);
405     int ret = -1;
406     if (pimpl->mceService_ != nullptr) {
407         ret =  pimpl->mceService_->UpdateInbox((RawAddress)device, MapMessageType(msgType));
408     } else {
409         HILOGE("pimpl->mceService_ null");
410     }
411     HILOGI("ret: %{public}d", ret);
412     return ret;
413 }
414 
SetMessageStatus(const BluetoothRawAddress & device,int32_t msgType,const std::u16string & msgHandle,int32_t statusIndicator,int32_t statusValue,const std::string & extendedData)415 int BluetoothMapMceServer::SetMessageStatus(const BluetoothRawAddress &device,
416     int32_t msgType, const std::u16string &msgHandle, int32_t statusIndicator, int32_t statusValue,
417     const std::string &extendedData)
418 {
419     HILOGI("device: %{public}s, msgType: %{public}d, statusIndicator: %{public}d, statusValue: %{public}d",
420         GetEncryptAddr(device.GetAddress()).c_str(), msgType, statusIndicator, statusValue);
421     int ret = -1;
422     IProfileSetMessageStatus serviceStatus;
423     serviceStatus.msgHandle = msgHandle;
424     serviceStatus.statusIndicator = MapStatusIndicatorType(statusIndicator);
425     serviceStatus.statusValue = MapStatusValueType(statusValue);
426     serviceStatus.extendedData = extendedData;
427 
428     if (pimpl->mceService_ != nullptr) {
429         ret =
430             pimpl->mceService_->SetMessageStatus((RawAddress)device, MapMessageType(msgType), serviceStatus);
431     } else {
432         HILOGE("pimpl->mceService_ null");
433     }
434     HILOGI("ret: %{public}d", ret);
435     return ret;
436 }
437 
GetOwnerStatus(const BluetoothRawAddress & device,const std::string & conversationId)438 int BluetoothMapMceServer::GetOwnerStatus(const BluetoothRawAddress &device,
439     const std::string &conversationId)
440 {
441     HILOGI("device: %{public}s, conversationId: %{public}s",
442         GetEncryptAddr(device.GetAddress()).c_str(), conversationId.c_str());
443     int ret = -1;
444     if (pimpl->mceService_ != nullptr) {
445         ret =  pimpl->mceService_->GetOwnerStatus((RawAddress)device, conversationId);
446     } else {
447         HILOGE("pimpl->mceService_ null");
448         ret =  -1;
449     }
450     HILOGI("ret: %{public}d", ret);
451     return ret;
452 }
453 
GetUnreadMessages(const BluetoothRawAddress & device,int32_t msgType,int32_t max)454 int BluetoothMapMceServer::GetUnreadMessages(
455     const BluetoothRawAddress &device, int32_t msgType, int32_t max)
456 {
457     HILOGI("device: %{public}s, msgType: %{public}d, max: %{public}d",
458         GetEncryptAddr(device.GetAddress()).c_str(), msgType, max);
459     int ret = -1;
460     if (pimpl->mceService_ != nullptr) {
461         ret =
462             pimpl->mceService_->GetUnreadMessages((RawAddress)device, MapMessageType(msgType), (uint8_t)max);
463     } else {
464         HILOGE("pimpl->mceService_ null");
465     }
466     HILOGI("ret: %{public}d", ret);
467     return ret;
468 }
469 
SendMessage(const BluetoothRawAddress & device,const BluetoothIProfileSendMessageParameters & msg)470 int BluetoothMapMceServer::SendMessage(const BluetoothRawAddress &device,
471     const BluetoothIProfileSendMessageParameters &msg)
472 {
473     HILOGI("device: %{public}s", GetEncryptAddr(device.GetAddress()).c_str());
474     int ret = -1;
475     if (pimpl->mceService_ != nullptr) {
476         ret =  pimpl->mceService_->SendMessage((RawAddress)device, (IProfileSendMessageParameters)msg);
477     } else {
478         HILOGE("pimpl->mceService_ null");
479     }
480     HILOGI("ret: %{public}d", ret);
481     return ret;
482 }
483 
GetMessagesListing(const BluetoothRawAddress & device,const BluetoothIProfileGetMessagesListingParameters & para)484 int BluetoothMapMceServer::GetMessagesListing(const BluetoothRawAddress &device,
485     const BluetoothIProfileGetMessagesListingParameters &para)
486 {
487     HILOGI("device: %{public}s", GetEncryptAddr(device.GetAddress()).c_str());
488     int ret = -1;
489     if (pimpl->mceService_ != nullptr) {
490         ret =
491             pimpl->mceService_->GetMessagesListing((RawAddress)device, (IProfileGetMessagesListingParameters)para);
492     } else {
493         HILOGE("pimpl->mceService_ null");
494     }
495     HILOGI("ret: %{public}d", ret);
496     return ret;
497 }
498 
GetMessage(const BluetoothRawAddress & device,int32_t msgType,const std::u16string & msgHandle,const BluetoothIProfileGetMessageParameters & para)499 int BluetoothMapMceServer::GetMessage(const BluetoothRawAddress &device, int32_t msgType,
500     const std::u16string &msgHandle, const BluetoothIProfileGetMessageParameters &para)
501 {
502     HILOGI("device: %{public}s, msgType: %{public}d", GetEncryptAddr(device.GetAddress()).c_str(), msgType);
503     int ret = -1;
504     if (pimpl->mceService_ != nullptr) {
505         ret =  pimpl->mceService_->GetMessage(
506             (RawAddress)device, MapMessageType(msgType), msgHandle, (IProfileGetMessageParameters)para);
507     } else {
508         HILOGE("pimpl->mceService_ null");
509     }
510     HILOGI("ret: %{public}d", ret);
511     return ret;
512 }
513 
GetConversationListing(const BluetoothRawAddress & device,const BluetoothIProfileGetConversationListingParameters & para)514 int BluetoothMapMceServer::GetConversationListing(const BluetoothRawAddress &device,
515     const BluetoothIProfileGetConversationListingParameters &para)
516 {
517     HILOGI("device: %{public}s", GetEncryptAddr(device.GetAddress()).c_str());
518     int ret = -1;
519     if (pimpl->mceService_ != nullptr) {
520         ret =  pimpl->mceService_->GetConversationListing(
521             (RawAddress)device, (IProfileGetConversationListingParameters)para);
522     } else {
523         HILOGE("pimpl->mceService_ null");
524     }
525     HILOGI("ret: %{public}d", ret);
526     return ret;
527 }
528 
SetOwnerStatus(const BluetoothRawAddress & device,const BluetoothIProfileSetOwnerStatusParameters & para)529 int BluetoothMapMceServer::SetOwnerStatus(const BluetoothRawAddress &device,
530     const BluetoothIProfileSetOwnerStatusParameters &para)
531 {
532     HILOGI("device: %{public}s", GetEncryptAddr(device.GetAddress()).c_str());
533     int ret = -1;
534     if (pimpl->mceService_ != nullptr) {
535         ret =  pimpl->mceService_->SetOwnerStatus((RawAddress)device, (IProfileSetOwnerStatusParameters)para);
536     } else {
537         HILOGE("pimpl->mceService_ null");
538     }
539     HILOGI("ret: %{public}d", ret);
540     return ret;
541 }
542 
GetMasInstanceInfo(const BluetoothRawAddress & device)543 BluetoothIProfileMasInstanceInfoList BluetoothMapMceServer::GetMasInstanceInfo(const BluetoothRawAddress &device)
544 {
545     HILOGI("device: %{public}s", GetEncryptAddr(device.GetAddress()).c_str());
546     BluetoothIProfileMasInstanceInfoList bluetoothlist;
547     bluetoothlist.isValid = false;
548     if (pimpl->mceService_ != nullptr) {
549         IProfileMasInstanceInfoList serviceInstanceList = pimpl->mceService_->GetMasInstanceInfo((RawAddress)device);
550         bluetoothlist.isValid = serviceInstanceList.isValid;
551         for (auto &masInfo : serviceInstanceList.masInfoList) {
552             bluetoothlist.masInfoList.push_back(masInfo);
553         }
554     } else {
555         HILOGE("pimpl->mceService_ null");
556     }
557     return bluetoothlist;
558 }
559 }  // namespace Bluetooth
560 }  // namespace OHOS
561