• 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 "bluetooth_log.h"
17 #include "bluetooth_map_mce_parameter.h"
18 
19 namespace OHOS {
20 namespace Bluetooth {
21 const int MAP_MCE_VCARD_COUNT_MAX = 0xFFFF;
22 const int MAP_MCE_MASINSTANCEINFO_COUNT_MAX = 0xFFFF;
23 const int MAP_MCE_PARTICIPANTLIST_COUNT_MAX = 0xFFFF;
24 const int MAP_MCE_CONVOUTLINELIST_COUNT_MAX = 0xFFFF;
25 const int MAP_MCE_OUTLINE_COUNT_MAX = 0xFFFF;
Marshalling(Parcel & parcel) const26 bool BluetoothIProfileMapAction::Marshalling(Parcel &parcel) const
27 {
28     bool status;
29     status = parcel.WriteInt32(static_cast<int>(action_));
30     if (!status) {
31         return status;
32     }
33 
34     status = parcel.WriteInt32(supportedFeatures_);
35     if (!status) {
36         return status;
37     }
38 
39     status = parcel.WriteUint8(ownerStatus_.PresenceAvailability);
40     if (!status) {
41         return status;
42     }
43 
44     status = parcel.WriteString(ownerStatus_.PresenceText);
45     if (!status) {
46         return status;
47     }
48 
49     status = parcel.WriteString(ownerStatus_.LastActivity);
50     if (!status) {
51         return status;
52     }
53 
54     status = parcel.WriteUint8(ownerStatus_.ChatState);
55     if (!status) {
56         return status;
57     }
58 
59     return status;
60 }
61 
WriteToParcel(Parcel & parcel)62 bool BluetoothIProfileMapAction::WriteToParcel(Parcel &parcel)
63 {
64     return Marshalling(parcel);
65 }
66 
Unmarshalling(Parcel & parcel)67 BluetoothIProfileMapAction *BluetoothIProfileMapAction::Unmarshalling(Parcel &parcel)
68 {
69     BluetoothIProfileMapAction *obj = new BluetoothIProfileMapAction();
70     if (obj != nullptr && !obj->ReadFromParcel(parcel)) {
71         delete obj;
72         obj = nullptr;
73     }
74     return obj;
75 }
76 
ReadFromParcel(Parcel & parcel)77 bool BluetoothIProfileMapAction::ReadFromParcel(Parcel &parcel)
78 {
79     bool status;
80     int action;
81 
82     status = parcel.ReadInt32(action);
83     if (!status) {
84         return status;
85     }
86     action_ = bluetooth::MapActionType(action);
87 
88     status = parcel.ReadInt32(supportedFeatures_);
89     if (!status) {
90         return status;
91     }
92 
93     status = parcel.ReadUint8(ownerStatus_.PresenceAvailability);
94     if (!status) {
95         return status;
96     }
97 
98     status = parcel.ReadString(ownerStatus_.PresenceText);
99     if (!status) {
100         return status;
101     }
102 
103     status = parcel.ReadString(ownerStatus_.LastActivity);
104     if (!status) {
105         return status;
106     }
107 
108     status = parcel.ReadUint8(ownerStatus_.ChatState);
109     return status;
110 }
111 
Marshalling(Parcel & parcel) const112 bool BluetoothIProfileMasInstanceInfoList::Marshalling(Parcel &parcel) const
113 {
114     bool status;
115 
116     status = parcel.WriteBool(isValid);
117     if (!status) {
118         return status;
119     }
120 
121     status = parcel.WriteInt32((int)masInfoList.size());
122     if (!status) {
123         return status;
124     }
125 
126     bluetooth::IProfileMasInstanceInfo info;
127     for (auto it = masInfoList.begin(); it != masInfoList.end(); it++) {
128         info = *it;
129         status = parcel.WriteString(info.OwnerUCI);
130         if (!status)
131             return status;
132 
133         status = parcel.WriteString(info.MASInstanceInformation);
134         if (!status)
135             return status;
136 
137         status = parcel.WriteInt32(info.supportedMsgTypes_);
138         if (!status)
139             return status;
140 
141         status = parcel.WriteInt32(info.instanceId);
142         if (!status)
143             return status;
144     }
145     return status;
146 }
147 
WriteToParcel(Parcel & parcel)148 bool BluetoothIProfileMasInstanceInfoList::WriteToParcel(Parcel &parcel)
149 {
150     return Marshalling(parcel);
151 }
152 
Unmarshalling(Parcel & parcel)153 BluetoothIProfileMasInstanceInfoList *BluetoothIProfileMasInstanceInfoList::Unmarshalling(Parcel &parcel)
154 {
155     BluetoothIProfileMasInstanceInfoList *obj = new BluetoothIProfileMasInstanceInfoList();
156     if (obj != nullptr && !obj->ReadFromParcel(parcel)) {
157         delete obj;
158         obj = nullptr;
159     }
160     return obj;
161 }
162 
ReadFromParcel(Parcel & parcel)163 bool BluetoothIProfileMasInstanceInfoList::ReadFromParcel(Parcel &parcel)
164 {
165     bool status;
166     int tempInt;
167 
168     status = parcel.ReadBool(isValid);
169     if (!status) {
170         return status;
171     }
172 
173     status = parcel.ReadInt32(tempInt);
174     if (!status) {
175         return status;
176     }
177     if (tempInt > MAP_MCE_MASINSTANCEINFO_COUNT_MAX) {
178         HILOGE("check fail, invalid parameter.");
179         return false;
180     }
181     bluetooth::IProfileMasInstanceInfo tempInfo;
182     for (int i = 0; i < tempInt; i++) {
183         status = parcel.ReadString(tempInfo.OwnerUCI);
184         if (!status) {
185             return status;
186         }
187 
188         status = parcel.ReadString(tempInfo.MASInstanceInformation);
189         if (!status) {
190             return status;
191         }
192 
193         status = parcel.ReadInt32(tempInfo.supportedMsgTypes_);
194         if (!status) {
195             return status;
196         }
197 
198         status = parcel.ReadInt32(tempInfo.instanceId);
199         if (!status) {
200             return status;
201         }
202 
203         masInfoList.push_back(tempInfo);
204     }
205     return status;
206 }
207 
WriteToParcelIProfileMapVcard(Parcel & parcel,const bluetooth::IProfileMapVcard & vcard) const208 bool BluetoothIProfileBMessageStruct::WriteToParcelIProfileMapVcard(
209     Parcel &parcel, const bluetooth::IProfileMapVcard &vcard) const
210 {
211     bool status;
212 
213     status = parcel.WriteString(vcard.VERSION);
214     if (!status) {
215         return status;
216     }
217 
218     status = parcel.WriteString(vcard.N);
219     if (!status) {
220         return status;
221     }
222 
223     status = parcel.WriteStringVector(vcard.TEL);
224     if (!status) {
225         return status;
226     }
227 
228     status = parcel.WriteStringVector(vcard.EMAIL);
229     if (!status) {
230         return status;
231     }
232 
233     status = parcel.WriteStringVector(vcard.X_BT_UID);
234     if (!status) {
235         return status;
236     }
237 
238     status = parcel.WriteStringVector(vcard.X_BT_UCI);
239     if (!status) {
240         return status;
241     }
242 
243     status = parcel.WriteString(vcard.FN);
244     if (!status) {
245         return status;
246     }
247 
248     return status;
249 }
250 
ReadFromParcelIProfileMapVcard(Parcel & parcel,bluetooth::IProfileMapVcard & vcard)251 bool BluetoothIProfileBMessageStruct::ReadFromParcelIProfileMapVcard(
252     Parcel &parcel, bluetooth::IProfileMapVcard &vcard)
253 {
254     bool status;
255 
256     status = parcel.ReadString(vcard.VERSION);
257     if (!status) {
258         return status;
259     }
260 
261     status = parcel.ReadString(vcard.N);
262     if (!status) {
263         return status;
264     }
265 
266     status = parcel.ReadStringVector(&(vcard.TEL));
267     if (!status) {
268         return status;
269     }
270 
271     status = parcel.ReadStringVector(&(vcard.EMAIL));
272     if (!status) {
273         return status;
274     }
275 
276     status = parcel.ReadStringVector(&(vcard.X_BT_UID));
277     if (!status) {
278         return status;
279     }
280 
281     status = parcel.ReadStringVector(&(vcard.X_BT_UCI));
282     if (!status) {
283         return status;
284     }
285 
286     status = parcel.ReadString(vcard.FN);
287     if (!status) {
288         return status;
289     }
290 
291     return status;
292 }
293 
WriteToParcel(Parcel & parcel,const bluetooth::IProfileBMessageStruct & msgStruct) const294 bool BluetoothIProfileBMessageStruct::WriteToParcel(
295     Parcel &parcel, const bluetooth::IProfileBMessageStruct &msgStruct) const
296 {
297     bool status;
298     bluetooth::IProfileMapVcard vcard;
299 
300     status = parcel.WriteString(msgStruct.version_property);
301     if (!status) {
302         return status;
303     }
304 
305     status = parcel.WriteInt32(static_cast<int>(msgStruct.readstatus_property));
306     if (!status) {
307         return status;
308     }
309 
310     status = parcel.WriteInt32(static_cast<int>(msgStruct.type_property));
311     if (!status) {
312         return status;
313     }
314 
315     status = parcel.WriteString16(msgStruct.folder_property);
316     if (!status) {
317         return status;
318     }
319 
320     status = parcel.WriteString(msgStruct.extendeddata_property);
321     if (!status) {
322         return status;
323     }
324 
325     status = parcel.WriteInt32(static_cast<int>(msgStruct.originator_.size()));
326     if (!status) {
327         return status;
328     }
329 
330     if (msgStruct.originator_.size() != 0) {
331         vcard = *(msgStruct.originator_.begin());
332         status = WriteToParcelIProfileMapVcard(parcel, vcard);
333         if (!status)
334             return status;
335     }
336 
337     status = parcel.WriteInt32(static_cast<int>(msgStruct.envelope_.recipientLevel1_.size()));
338     if (!status) {
339         return status;
340     }
341 
342     for (auto it = msgStruct.envelope_.recipientLevel1_.begin(); it != msgStruct.envelope_.recipientLevel1_.end();
343          it++) {
344         vcard = *it;
345         status = WriteToParcelIProfileMapVcard(parcel, vcard);
346         if (!status)
347             return status;
348     }
349 
350     status = parcel.WriteInt32(static_cast<int>(msgStruct.envelope_.recipientLevel2_.size()));
351     if (!status) {
352         return status;
353     }
354 
355     for (auto it2 = msgStruct.envelope_.recipientLevel2_.begin(); it2 != msgStruct.envelope_.recipientLevel2_.end();
356          it2++) {
357         vcard = *it2;
358         status = WriteToParcelIProfileMapVcard(parcel, vcard);
359         if (!status)
360             return status;
361     }
362 
363     status = parcel.WriteInt32(static_cast<int>(msgStruct.envelope_.recipientLevel3_.size()));
364     if (!status) {
365         return status;
366     }
367 
368     for (auto it3 = msgStruct.envelope_.recipientLevel3_.begin(); it3 != msgStruct.envelope_.recipientLevel3_.end();
369          it3++) {
370         vcard = *it3;
371         status = WriteToParcelIProfileMapVcard(parcel, vcard);
372         if (!status)
373             return status;
374     }
375     status = parcel.WriteInt32(static_cast<int>(msgStruct.envelope_.maxLevelOfEnvelope_));
376     if (!status) {
377         return status;
378     }
379 
380     status = parcel.WriteString(msgStruct.envelope_.msgBody_.bodyPartID);
381     if (!status) {
382         return status;
383     }
384 
385     status = parcel.WriteString(msgStruct.envelope_.msgBody_.body_encoding);
386     if (!status) {
387         return status;
388     }
389 
390     status = parcel.WriteString(msgStruct.envelope_.msgBody_.body_charset);
391     if (!status) {
392         return status;
393     }
394 
395     status = parcel.WriteString(msgStruct.envelope_.msgBody_.body_language);
396     if (!status) {
397         return status;
398     }
399 
400     status = parcel.WriteInt32(static_cast<int>(msgStruct.envelope_.msgBody_.body_content_length));
401     if (!status) {
402         return status;
403     }
404 
405     status = parcel.WriteString(msgStruct.envelope_.msgBody_.body_content);
406     if (!status) {
407         return status;
408     }
409 
410     return status;
411 }
412 
ReadFromParcel(Parcel & parcel,bluetooth::IProfileBMessageStruct & msgStruct)413 bool BluetoothIProfileBMessageStruct::ReadFromParcel(
414     Parcel &parcel, bluetooth::IProfileBMessageStruct &msgStruct)
415 {
416     bool status;
417     int tempInt;
418     bluetooth::IProfileMapVcard vcard;
419     int i;
420 
421     status = parcel.ReadString(msgStruct.version_property);
422     if (!status) {
423         return status;
424     }
425 
426     status = parcel.ReadInt32(tempInt);
427     if (!status) {
428         return status;
429     }
430     msgStruct.readstatus_property = bluetooth::MapMessageStatus(tempInt);
431 
432     status = parcel.ReadInt32(tempInt);
433     if (!status) {
434         return status;
435     }
436     msgStruct.type_property = bluetooth::MapMessageType(tempInt);
437 
438     status = parcel.ReadString16(msgStruct.folder_property);
439     if (!status) {
440         return status;
441     }
442 
443     status = parcel.ReadString(msgStruct.extendeddata_property);
444     if (!status) {
445         return status;
446     }
447 
448     status = parcel.ReadInt32(tempInt);
449     if (!status) {
450         return status;
451     }
452 
453     if (tempInt != 0) {
454         ReadFromParcelIProfileMapVcard(parcel, vcard);
455         msgStruct.originator_.push_back(vcard);
456     }
457 
458     status = parcel.ReadInt32(tempInt);
459     if (!status) {
460         return status;
461     }
462     if (tempInt > MAP_MCE_VCARD_COUNT_MAX) {
463         HILOGE("check fail, invalid parameter.");
464         return false;
465     }
466     for (i = 0; i < tempInt; i++) {
467         ReadFromParcelIProfileMapVcard(parcel, vcard);
468         msgStruct.envelope_.recipientLevel1_.push_back(vcard);
469     }
470 
471     status = parcel.ReadInt32(tempInt);
472     if (!status) {
473         return status;
474     }
475     if (tempInt > MAP_MCE_VCARD_COUNT_MAX) {
476         HILOGE("check fail, invalid parameter.");
477         return false;
478     }
479     for (i = 0; i < tempInt; i++) {
480         ReadFromParcelIProfileMapVcard(parcel, vcard);
481         msgStruct.envelope_.recipientLevel2_.push_back(vcard);
482     }
483 
484     status = parcel.ReadInt32(tempInt);
485     if (!status) {
486         return status;
487     }
488     if (tempInt > MAP_MCE_VCARD_COUNT_MAX) {
489         HILOGE("check fail, invalid parameter.");
490         return false;
491     }
492     for (i = 0; i < tempInt; i++) {
493         ReadFromParcelIProfileMapVcard(parcel, vcard);
494         msgStruct.envelope_.recipientLevel3_.push_back(vcard);
495     }
496 
497     status = parcel.ReadInt32(tempInt);
498     if (!status) {
499         return status;
500     }
501     msgStruct.envelope_.maxLevelOfEnvelope_ = tempInt;
502 
503     status = parcel.ReadString(msgStruct.envelope_.msgBody_.bodyPartID);
504     if (!status) {
505         return status;
506     }
507 
508     status = parcel.ReadString(msgStruct.envelope_.msgBody_.body_encoding);
509     if (!status) {
510         return status;
511     }
512 
513     status = parcel.ReadString(msgStruct.envelope_.msgBody_.body_charset);
514     if (!status) {
515         return status;
516     }
517 
518     status = parcel.ReadString(msgStruct.envelope_.msgBody_.body_language);
519     if (!status) {
520         return status;
521     }
522 
523     status = parcel.ReadInt32(tempInt);
524     if (!status) {
525         return status;
526     }
527     msgStruct.envelope_.msgBody_.body_content_length = tempInt;
528 
529     status = parcel.ReadString(msgStruct.envelope_.msgBody_.body_content);
530     if (!status) {
531         return status;
532     }
533 
534     return status;
535 }
536 
Marshalling(Parcel & parcel) const537 bool BluetoothIProfileSendMessageParameters::Marshalling(Parcel &parcel) const
538 {
539     bool status;
540 
541     status = parcel.WriteString(ConversationID);
542     if (!status) {
543         return status;
544     }
545 
546     status = parcel.WriteInt32(static_cast<int>(Attachment));
547     if (!status) {
548         return status;
549     }
550 
551     status = parcel.WriteInt32(static_cast<int>(Charset));
552     if (!status) {
553         return status;
554     }
555 
556     status = parcel.WriteInt32(static_cast<int>(Transparent));
557     if (!status) {
558         return status;
559     }
560 
561     status = parcel.WriteInt32(static_cast<int>(Retry));
562     if (!status) {
563         return status;
564     }
565 
566     status = parcel.WriteString(MessageHandle);
567     if (!status) {
568         return status;
569     }
570 
571     status = parcel.WriteInt32(static_cast<int>(ModifyText));
572     if (!status) {
573         return status;
574     }
575 
576     BluetoothIProfileBMessageStruct bMessageStruct;
577     status = bMessageStruct.WriteToParcel(parcel, bmessage_);
578     if (!status) {
579         return status;
580     }
581 
582     return status;
583 }
584 
WriteToParcel(Parcel & parcel)585 bool BluetoothIProfileSendMessageParameters::WriteToParcel(Parcel &parcel)
586 {
587     return Marshalling(parcel);
588 }
589 
Unmarshalling(Parcel & parcel)590 BluetoothIProfileSendMessageParameters *BluetoothIProfileSendMessageParameters::Unmarshalling(Parcel &parcel)
591 {
592     BluetoothIProfileSendMessageParameters *obj = new BluetoothIProfileSendMessageParameters();
593     if (obj != nullptr && !obj->ReadFromParcel(parcel)) {
594         delete obj;
595         obj = nullptr;
596     }
597     return obj;
598 }
599 
ReadFromParcel(Parcel & parcel)600 bool BluetoothIProfileSendMessageParameters::ReadFromParcel(Parcel &parcel)
601 {
602     bool status;
603     int tempInt;
604 
605     status = parcel.ReadString(ConversationID);
606     if (!status) {
607         return status;
608     }
609 
610     status = parcel.ReadInt32(tempInt);
611     if (!status) {
612         return status;
613     }
614     Attachment = bluetooth::MapAttachmentType(tempInt);
615 
616     status = parcel.ReadInt32(tempInt);
617     if (!status) {
618         return status;
619     }
620     Charset = bluetooth::MapCharsetType(tempInt);
621 
622     status = parcel.ReadInt32(tempInt);
623     if (!status) {
624         return status;
625     }
626     Transparent = bluetooth::MapOnOffType(tempInt);
627 
628     status = parcel.ReadInt32(tempInt);
629     if (!status) {
630         return status;
631     }
632     Retry = bluetooth::MapOnOffType(tempInt);
633 
634     status = parcel.ReadString(MessageHandle);
635     if (!status) {
636         return status;
637     }
638 
639     status = parcel.ReadInt32(tempInt);
640     if (!status) {
641         return status;
642     }
643     ModifyText = bluetooth::MapModifyTextType(tempInt);
644 
645     BluetoothIProfileBMessageStruct bMessageStruct;
646     status = bMessageStruct.ReadFromParcel(parcel, bmessage_);
647     if (!status) {
648         return status;
649     }
650 
651     return status;
652 }
653 
Marshalling(Parcel & parcel) const654 bool BluetoothIProfileSetOwnerStatusParameters::Marshalling(Parcel &parcel) const
655 {
656     bool status;
657 
658     status = parcel.WriteString(ConversationID);
659     if (!status) {
660         return status;
661     }
662 
663     status = parcel.WriteUint8(ownerStatus_.PresenceAvailability);
664     if (!status) {
665         return status;
666     }
667 
668     status = parcel.WriteString(ownerStatus_.PresenceText);
669     if (!status) {
670         return status;
671     }
672 
673     status = parcel.WriteString(ownerStatus_.LastActivity);
674     if (!status) {
675         return status;
676     }
677 
678     status = parcel.WriteUint32(ownerStatus_.ChatState);
679     if (!status) {
680         return status;
681     }
682 
683     return status;
684 }
685 
WriteToParcel(Parcel & parcel)686 bool BluetoothIProfileSetOwnerStatusParameters::WriteToParcel(Parcel &parcel)
687 {
688     return Marshalling(parcel);
689 }
690 
Unmarshalling(Parcel & parcel)691 BluetoothIProfileSetOwnerStatusParameters *BluetoothIProfileSetOwnerStatusParameters::Unmarshalling(Parcel &parcel)
692 {
693     BluetoothIProfileSetOwnerStatusParameters *obj = new BluetoothIProfileSetOwnerStatusParameters();
694     if (obj != nullptr && !obj->ReadFromParcel(parcel)) {
695         delete obj;
696         obj = nullptr;
697     }
698     return obj;
699 }
700 
ReadFromParcel(Parcel & parcel)701 bool BluetoothIProfileSetOwnerStatusParameters::ReadFromParcel(Parcel &parcel)
702 {
703     bool status;
704 
705     status = parcel.ReadString(ConversationID);
706     if (!status) {
707         return status;
708     }
709 
710     status = parcel.ReadUint8(ownerStatus_.PresenceAvailability);
711     if (!status) {
712         return status;
713     }
714 
715     status = parcel.ReadString(ownerStatus_.PresenceText);
716     if (!status) {
717         return status;
718     }
719 
720     status = parcel.ReadString(ownerStatus_.LastActivity);
721     if (!status) {
722         return status;
723     }
724 
725     status = parcel.ReadUint8(ownerStatus_.ChatState);
726     if (!status) {
727         return status;
728     }
729 
730     return status;
731 }
732 
Marshalling(Parcel & parcel) const733 bool BluetoothIProfileGetConversationListingParameters::Marshalling(Parcel &parcel) const
734 {
735     bool status;
736 
737     status = parcel.WriteUint16(MaxListCount);
738     if (!status) {
739         return status;
740     }
741 
742     status = parcel.WriteUint16(ListStartOffset);
743     if (!status) {
744         return status;
745     }
746 
747     status = parcel.WriteUint8(FilterReadStatus);
748     if (!status) {
749         return status;
750     }
751 
752     status = parcel.WriteString(FilterRecipient);
753     if (!status) {
754         return status;
755     }
756 
757     status = parcel.WriteString(ConversationID);
758     if (!status) {
759         return status;
760     }
761 
762     status = parcel.WriteString(FilterLastActivityBegin);
763     if (!status) {
764         return status;
765     }
766 
767     status = parcel.WriteString(FilterLastActivityEnd);
768     if (!status) {
769         return status;
770     }
771 
772     status = parcel.WriteUint32(ConvParameterMask);
773     if (!status) {
774         return status;
775     }
776 
777     return status;
778 }
779 
WriteToParcel(Parcel & parcel)780 bool BluetoothIProfileGetConversationListingParameters::WriteToParcel(Parcel &parcel)
781 {
782     return Marshalling(parcel);
783 }
784 
Unmarshalling(Parcel & parcel)785 BluetoothIProfileGetConversationListingParameters *BluetoothIProfileGetConversationListingParameters::Unmarshalling(
786     Parcel &parcel)
787 {
788     BluetoothIProfileGetConversationListingParameters *obj =
789         new BluetoothIProfileGetConversationListingParameters();
790     if (obj != nullptr && !obj->ReadFromParcel(parcel)) {
791         delete obj;
792         obj = nullptr;
793     }
794     return obj;
795 }
796 
ReadFromParcel(Parcel & parcel)797 bool BluetoothIProfileGetConversationListingParameters::ReadFromParcel(Parcel &parcel)
798 {
799     bool status;
800 
801     status = parcel.ReadUint16(MaxListCount);
802     if (!status) {
803         return status;
804     }
805 
806     status = parcel.ReadUint16(ListStartOffset);
807     if (!status) {
808         return status;
809     }
810 
811     status = parcel.ReadUint8(FilterReadStatus);
812     if (!status) {
813         return status;
814     }
815 
816     status = parcel.ReadString(FilterRecipient);
817     if (!status) {
818         return status;
819     }
820 
821     status = parcel.ReadString(ConversationID);
822     if (!status) {
823         return status;
824     }
825 
826     status = parcel.ReadString(FilterLastActivityBegin);
827     if (!status) {
828         return status;
829     }
830 
831     status = parcel.ReadString(FilterLastActivityEnd);
832     if (!status) {
833         return status;
834     }
835 
836     status = parcel.ReadUint32(ConvParameterMask);
837     if (!status) {
838         return status;
839     }
840 
841     return status;
842 }
843 
Marshalling(Parcel & parcel) const844 bool BluetoothIProfileGetMessageParameters::Marshalling(Parcel &parcel) const
845 {
846     bool status;
847 
848     status = parcel.WriteInt32(static_cast<int>(Attachment));
849     if (!status) {
850         return status;
851     }
852 
853     status = parcel.WriteInt32(static_cast<int>(Charset));
854     if (!status) {
855         return status;
856     }
857 
858     status = parcel.WriteInt32(static_cast<int>(FractionRequest));
859     return status;
860 }
861 
WriteToParcel(Parcel & parcel)862 bool BluetoothIProfileGetMessageParameters::WriteToParcel(Parcel &parcel)
863 {
864     return Marshalling(parcel);
865 }
866 
Unmarshalling(Parcel & parcel)867 BluetoothIProfileGetMessageParameters *BluetoothIProfileGetMessageParameters::Unmarshalling(Parcel &parcel)
868 {
869     BluetoothIProfileGetMessageParameters *obj = new BluetoothIProfileGetMessageParameters();
870     if (obj != nullptr && !obj->ReadFromParcel(parcel)) {
871         delete obj;
872         obj = nullptr;
873     }
874     return obj;
875 }
876 
ReadFromParcel(Parcel & parcel)877 bool BluetoothIProfileGetMessageParameters::ReadFromParcel(Parcel &parcel)
878 {
879     bool status;
880     int tempInt;
881 
882     status = parcel.ReadInt32(tempInt);
883     if (!status) {
884         return status;
885     }
886     Attachment = bluetooth::MapAttachmentType(tempInt);
887 
888     status = parcel.ReadInt32(tempInt);
889     if (!status) {
890         return status;
891     }
892     Charset = bluetooth::MapCharsetType(tempInt);
893 
894     status = parcel.ReadInt32(tempInt);
895     FractionRequest = bluetooth::MapFractionRequestType(tempInt);
896     return status;
897 }
898 
Marshalling(Parcel & parcel) const899 bool BluetoothIProfileGetMessagesListingParameters::Marshalling(Parcel &parcel) const
900 {
901     bool status;
902 
903     status = parcel.WriteString16(folder);
904     if (!status) {
905         return status;
906     }
907 
908     status = parcel.WriteUint16(MaxListCount);
909     if (!status) {
910         return status;
911     }
912 
913     status = parcel.WriteUint16(ListStartOffset);
914     if (!status) {
915         return status;
916     }
917 
918     status = parcel.WriteUint8(SubjectLength);
919     if (!status) {
920         return status;
921     }
922 
923     status = parcel.WriteUint32(ParameterMask);
924     if (!status) {
925         return status;
926     }
927 
928     status = parcel.WriteUint8(FilterMessageType);
929     if (!status) {
930         return status;
931     }
932 
933     status = parcel.WriteString(FilterPeriodBegin);
934     if (!status) {
935         return status;
936     }
937 
938     status = parcel.WriteString(FilterPeriodEnd);
939     if (!status) {
940         return status;
941     }
942 
943     status = parcel.WriteUint8(FilterReadStatus);
944     if (!status) {
945         return status;
946     }
947 
948     status = parcel.WriteString(FilterRecipient);
949     if (!status) {
950         return status;
951     }
952 
953     status = parcel.WriteString(FilterOriginator);
954     if (!status) {
955         return status;
956     }
957 
958     status = parcel.WriteUint8(FilterPriority);
959     if (!status) {
960         return status;
961     }
962 
963     status = parcel.WriteString(ConversationID);
964     if (!status) {
965         return status;
966     }
967 
968     status = parcel.WriteString(FilterMessageHandle);
969     if (!status) {
970         return status;
971     }
972 
973     return status;
974 }
975 
WriteToParcel(Parcel & parcel)976 bool BluetoothIProfileGetMessagesListingParameters::WriteToParcel(Parcel &parcel)
977 {
978     return Marshalling(parcel);
979 }
980 
Unmarshalling(Parcel & parcel)981 BluetoothIProfileGetMessagesListingParameters *BluetoothIProfileGetMessagesListingParameters::Unmarshalling(
982     Parcel &parcel)
983 {
984     BluetoothIProfileGetMessagesListingParameters *obj = new BluetoothIProfileGetMessagesListingParameters();
985     if (obj != nullptr && !obj->ReadFromParcel(parcel)) {
986         delete obj;
987         obj = nullptr;
988     }
989     return obj;
990 }
991 
ReadFromParcel(Parcel & parcel)992 bool BluetoothIProfileGetMessagesListingParameters::ReadFromParcel(Parcel &parcel)
993 {
994     bool status;
995 
996     status = parcel.ReadString16(folder);
997     if (!status) {
998         return status;
999     }
1000 
1001     status = parcel.ReadUint16(MaxListCount);
1002     if (!status) {
1003         return status;
1004     }
1005 
1006     status = parcel.ReadUint16(ListStartOffset);
1007     if (!status) {
1008         return status;
1009     }
1010 
1011     status = parcel.ReadUint8(SubjectLength);
1012     if (!status) {
1013         return status;
1014     }
1015 
1016     status = parcel.ReadUint32(ParameterMask);
1017     if (!status) {
1018         return status;
1019     }
1020 
1021     status = parcel.ReadUint8(FilterMessageType);
1022     if (!status) {
1023         return status;
1024     }
1025 
1026     status = parcel.ReadString(FilterPeriodBegin);
1027     if (!status) {
1028         return status;
1029     }
1030 
1031     status = parcel.ReadString(FilterPeriodEnd);
1032     if (!status) {
1033         return status;
1034     }
1035 
1036     status = parcel.ReadUint8(FilterReadStatus);
1037     if (!status) {
1038         return status;
1039     }
1040 
1041     status = parcel.ReadString(FilterRecipient);
1042     if (!status) {
1043         return status;
1044     }
1045 
1046     status = parcel.ReadString(FilterOriginator);
1047     if (!status) {
1048         return status;
1049     }
1050 
1051     status = parcel.ReadUint8(FilterPriority);
1052     if (!status) {
1053         return status;
1054     }
1055 
1056     status = parcel.ReadString(ConversationID);
1057     if (!status) {
1058         return status;
1059     }
1060 
1061     status = parcel.ReadString(FilterMessageHandle);
1062     if (!status) {
1063         return status;
1064     }
1065 
1066     return status;
1067 }
1068 
Marshalling(Parcel & parcel) const1069 bool BluetoothIProfileBMessage::Marshalling(Parcel &parcel) const
1070 {
1071     bool status;
1072 
1073     status = parcel.WriteInt32(static_cast<int>(FractionDeliver));
1074     if (!status) {
1075         return status;
1076     }
1077 
1078     BluetoothIProfileBMessageStruct bMessageStruct;
1079     status = bMessageStruct.WriteToParcel(parcel, bMessageParam_);
1080     if (!status) {
1081         return status;
1082     }
1083 
1084     status = parcel.WriteString(bMessageStringObject_);
1085     if (!status) {
1086         return status;
1087     }
1088 
1089     return status;
1090 }
1091 
WriteToParcel(Parcel & parcel)1092 bool BluetoothIProfileBMessage::WriteToParcel(Parcel &parcel)
1093 {
1094     return Marshalling(parcel);
1095 }
1096 
Unmarshalling(Parcel & parcel)1097 BluetoothIProfileBMessage *BluetoothIProfileBMessage::Unmarshalling(Parcel &parcel)
1098 {
1099     BluetoothIProfileBMessage *obj = new BluetoothIProfileBMessage();
1100     if (obj != nullptr && !obj->ReadFromParcel(parcel)) {
1101         delete obj;
1102         obj = nullptr;
1103     }
1104     return obj;
1105 }
1106 
ReadFromParcel(Parcel & parcel)1107 bool BluetoothIProfileBMessage::ReadFromParcel(Parcel &parcel)
1108 {
1109     bool status;
1110     int tmpInt;
1111 
1112     status = parcel.ReadInt32(tmpInt);
1113     if (!status) {
1114         return status;
1115     }
1116     FractionDeliver = bluetooth::MapFractionDeliverType(tmpInt);
1117 
1118     BluetoothIProfileBMessageStruct bMessageStruct;
1119     status = bMessageStruct.ReadFromParcel(parcel, bMessageParam_);
1120     if (!status) {
1121         return status;
1122     }
1123 
1124     status = parcel.ReadString(bMessageStringObject_);
1125     if (!status) {
1126         return status;
1127     }
1128 
1129     return status;
1130 }
1131 
WriteToParcelIProfileMessageOutline(Parcel & parcel,const bluetooth::IProfileMessageOutline & outline) const1132 bool BluetoothIProfileMessagesListing::WriteToParcelIProfileMessageOutline(
1133     Parcel &parcel, const bluetooth::IProfileMessageOutline &outline) const
1134 {
1135     bool status;
1136 
1137     status = parcel.WriteString(outline.handle);
1138     if (!status) {
1139         return status;
1140     }
1141 
1142     status = parcel.WriteString(outline.subject);
1143     if (!status) {
1144         return status;
1145     }
1146 
1147     status = parcel.WriteString(outline.datetime);
1148     if (!status) {
1149         return status;
1150     }
1151 
1152     status = parcel.WriteString(outline.sender_name);
1153     if (!status) {
1154         return status;
1155     }
1156 
1157     status = parcel.WriteString(outline.sender_addressing);
1158     if (!status) {
1159         return status;
1160     }
1161 
1162     status = parcel.WriteString(outline.replyto_addressing);
1163     if (!status) {
1164         return status;
1165     }
1166 
1167     status = parcel.WriteString(outline.recipient_name);
1168     if (!status) {
1169         return status;
1170     }
1171 
1172     status = parcel.WriteString(outline.recipient_addressing);
1173     if (!status) {
1174         return status;
1175     }
1176 
1177     status = parcel.WriteInt32(static_cast<int>(outline.type));
1178     if (!status) {
1179         return status;
1180     }
1181 
1182     status = parcel.WriteInt32(static_cast<int>(outline.receptionStatus));
1183     if (!status) {
1184         return status;
1185     }
1186 
1187     status = parcel.WriteInt32(static_cast<int>(outline.size));
1188     if (!status) {
1189         return status;
1190     }
1191 
1192     status = parcel.WriteInt32(static_cast<int>(outline.attachment_size));
1193     if (!status) {
1194         return status;
1195     }
1196 
1197     status = parcel.WriteInt32(static_cast<int>(outline.text));
1198     if (!status) {
1199         return status;
1200     }
1201 
1202     status = parcel.WriteInt32(static_cast<int>(outline.read));
1203     if (!status) {
1204         return status;
1205     }
1206 
1207     status = parcel.WriteInt32(static_cast<int>(outline.sent));
1208     if (!status) {
1209         return status;
1210     }
1211 
1212     status = parcel.WriteInt32(static_cast<int>(outline.protected_));
1213     if (!status) {
1214         return status;
1215     }
1216 
1217     status = parcel.WriteInt32(static_cast<int>(outline.priority));
1218     if (!status) {
1219         return status;
1220     }
1221 
1222     status = parcel.WriteInt32(static_cast<int>(outline.delivery_status));
1223     if (!status) {
1224         return status;
1225     }
1226 
1227     status = parcel.WriteString(outline.conversation_id);
1228     if (!status) {
1229         return status;
1230     }
1231 
1232     status = parcel.WriteString(outline.conversation_name);
1233     if (!status) {
1234         return status;
1235     }
1236     status = parcel.WriteInt32(static_cast<int>(outline.direction));
1237     if (!status) {
1238         return status;
1239     }
1240 
1241     status = parcel.WriteString(outline.attachment_mime_types);
1242     if (!status) {
1243         return status;
1244     }
1245 
1246     return status;
1247 }
1248 
WriteToParcel(Parcel & parcel)1249 bool BluetoothIProfileMessagesListing::WriteToParcel(Parcel &parcel)
1250 {
1251     return Marshalling(parcel);
1252 }
1253 
Unmarshalling(Parcel & parcel)1254 BluetoothIProfileMessagesListing *BluetoothIProfileMessagesListing::Unmarshalling(Parcel &parcel)
1255 {
1256     BluetoothIProfileMessagesListing *obj = new BluetoothIProfileMessagesListing();
1257     if (obj != nullptr && !obj->ReadFromParcel(parcel)) {
1258         delete obj;
1259         obj = nullptr;
1260     }
1261     return obj;
1262 }
1263 
ReadFromParcelIProfileMessageOutline(Parcel & parcel,bluetooth::IProfileMessageOutline & outline)1264 bool BluetoothIProfileMessagesListing::ReadFromParcelIProfileMessageOutline(
1265     Parcel &parcel, bluetooth::IProfileMessageOutline &outline)
1266 {
1267     bool status;
1268     int tmpInt;
1269 
1270     status = parcel.ReadString(outline.handle);
1271     if (!status) {
1272         return status;
1273     }
1274 
1275     status = parcel.ReadString(outline.subject);
1276     if (!status) {
1277         return status;
1278     }
1279 
1280     status = parcel.ReadString(outline.datetime);
1281     if (!status) {
1282         return status;
1283     }
1284 
1285     status = parcel.ReadString(outline.sender_name);
1286     if (!status) {
1287         return status;
1288     }
1289 
1290     status = parcel.ReadString(outline.sender_addressing);
1291     if (!status) {
1292         return status;
1293     }
1294 
1295     status = parcel.ReadString(outline.replyto_addressing);
1296     if (!status) {
1297         return status;
1298     }
1299 
1300     status = parcel.ReadString(outline.recipient_name);
1301     if (!status) {
1302         return status;
1303     }
1304 
1305     status = parcel.ReadString(outline.recipient_addressing);
1306     if (!status) {
1307         return status;
1308     }
1309 
1310     status = parcel.ReadInt32(tmpInt);
1311     if (!status) {
1312         return status;
1313     }
1314     outline.type = bluetooth::MapMessageType(tmpInt);
1315 
1316     status = parcel.ReadInt32(tmpInt);
1317     if (!status) {
1318         return status;
1319     }
1320     outline.receptionStatus = bluetooth::MapMsgReceptionStatus(tmpInt);
1321 
1322     status = parcel.ReadInt32(tmpInt);
1323     if (!status) {
1324         return status;
1325     }
1326     outline.size = tmpInt;
1327 
1328     status = parcel.ReadInt32(tmpInt);
1329     if (!status) {
1330         return status;
1331     }
1332     outline.attachment_size = tmpInt;
1333 
1334     status = parcel.ReadInt32(tmpInt);
1335     if (!status) {
1336         return status;
1337     }
1338     outline.text = bluetooth::MapBoolType(tmpInt);
1339 
1340     status = parcel.ReadInt32(tmpInt);
1341     if (!status) {
1342         return status;
1343     }
1344     outline.read = bluetooth::MapMessageStatus(tmpInt);
1345 
1346     status = parcel.ReadInt32(tmpInt);
1347     if (!status) {
1348         return status;
1349     }
1350     outline.sent = bluetooth::MapBoolType(tmpInt);
1351 
1352     status = parcel.ReadInt32(tmpInt);
1353     if (!status) {
1354         return status;
1355     }
1356     outline.protected_ = bluetooth::MapBoolType(tmpInt);
1357 
1358     status = parcel.ReadInt32(tmpInt);
1359     if (!status) {
1360         return status;
1361     }
1362     outline.priority = bluetooth::MapBoolType(tmpInt);
1363 
1364     status = parcel.ReadInt32(tmpInt);
1365     if (!status) {
1366         return status;
1367     }
1368     outline.delivery_status = bluetooth::MapMsgDeliveryStatus(tmpInt);
1369 
1370     status = parcel.ReadString(outline.conversation_id);
1371     if (!status) {
1372         return status;
1373     }
1374 
1375     status = parcel.ReadString(outline.conversation_name);
1376     if (!status) {
1377         return status;
1378     }
1379 
1380     status = parcel.ReadInt32(tmpInt);
1381     if (!status) {
1382         return status;
1383     }
1384     outline.direction = bluetooth::MapMsgDirection(tmpInt);
1385 
1386     status = parcel.ReadString(outline.attachment_mime_types);
1387     if (!status) {
1388         return status;
1389     }
1390 
1391     return status;
1392 }
1393 
Marshalling(Parcel & parcel) const1394 bool BluetoothIProfileMessagesListing::Marshalling(Parcel &parcel) const
1395 {
1396     bool status;
1397 
1398     // save size first
1399     status = parcel.WriteInt32((int)messageOutlineList_.size());
1400     if (!status) {
1401         return status;
1402     }
1403 
1404     // save the IProfileMessageOutline
1405     bluetooth::IProfileMessageOutline msgOutline;
1406     for (auto it = messageOutlineList_.begin(); it != messageOutlineList_.end(); it++) {
1407         msgOutline = *it;
1408         status = WriteToParcelIProfileMessageOutline(parcel, msgOutline);
1409         if (!status)
1410             return status;
1411     }
1412 
1413     status = parcel.WriteUint8((uint8_t)messagesListingParam_.NewMessage);
1414     if (!status) {
1415         return status;
1416     }
1417 
1418     status = parcel.WriteString(messagesListingParam_.MseTime);
1419     if (!status) {
1420         return status;
1421     }
1422 
1423     status = parcel.WriteUint16(messagesListingParam_.ListingSize);
1424     if (!status) {
1425         return status;
1426     }
1427 
1428     status = parcel.WriteString(messagesListingParam_.DatabaseIdentifier);
1429     if (!status) {
1430         return status;
1431     }
1432 
1433     status = parcel.WriteString(messagesListingParam_.FolderVersionCounter);
1434     if (!status) {
1435         return status;
1436     }
1437 
1438     status = parcel.WriteString(messagesListingParam_.Version);
1439     if (!status) {
1440         return status;
1441     }
1442 
1443     status = parcel.WriteString(messagesListingStringObject_);
1444     return status;
1445 }
1446 
ReadFromParcel(Parcel & parcel)1447 bool BluetoothIProfileMessagesListing::ReadFromParcel(Parcel &parcel)
1448 {
1449     bool status;
1450     int tmpInt;
1451 
1452     // get the outlineListSize first
1453     status = parcel.ReadInt32(outlineListSize);
1454     if (outlineListSize > MAP_MCE_OUTLINE_COUNT_MAX) {
1455         HILOGE("check fail, invalid parameter.");
1456         return false;
1457     }
1458     if (!status) {
1459         return status;
1460     }
1461 
1462     // get the outline list
1463     bluetooth::IProfileMessageOutline msgOutline;
1464     for (int i = 0; i < outlineListSize; i++) {
1465         ReadFromParcelIProfileMessageOutline(parcel, msgOutline);
1466         messageOutlineList_.push_back(msgOutline);
1467     }
1468 
1469     status = parcel.ReadInt32(tmpInt);
1470     if (!status) {
1471         return status;
1472     }
1473     messagesListingParam_.NewMessage = bluetooth::MapOnOffType(tmpInt);
1474 
1475     status = parcel.ReadString(messagesListingParam_.MseTime);
1476     if (!status) {
1477         return status;
1478     }
1479 
1480     status = parcel.ReadUint16(messagesListingParam_.ListingSize);
1481     if (!status) {
1482         return status;
1483     }
1484 
1485     status = parcel.ReadString(messagesListingParam_.DatabaseIdentifier);
1486     if (!status) {
1487         return status;
1488     }
1489 
1490     status = parcel.ReadString(messagesListingParam_.FolderVersionCounter);
1491     if (!status) {
1492         return status;
1493     }
1494 
1495     status = parcel.ReadString(messagesListingParam_.Version);
1496     if (!status) {
1497         return status;
1498     }
1499 
1500     status = parcel.ReadString(messagesListingStringObject_);
1501     if (!status) {
1502         return status;
1503     }
1504     return status;
1505 }
1506 
WriteToParcelIProfileConversation(Parcel & parcel,const bluetooth::IProfileConversation & outline) const1507 bool BluetoothIProfileConversationListing::WriteToParcelIProfileConversation(
1508     Parcel &parcel, const bluetooth::IProfileConversation &outline) const
1509 {
1510     bool status;
1511 
1512     status = parcel.WriteString(outline.id);
1513     if (!status) {
1514         return status;
1515     }
1516 
1517     status = parcel.WriteString(outline.name);
1518     if (!status) {
1519         return status;
1520     }
1521 
1522     status = parcel.WriteString(outline.last_activity);
1523     if (!status) {
1524         return status;
1525     }
1526 
1527     status = parcel.WriteString(outline.read_status);
1528     if (!status) {
1529         return status;
1530     }
1531 
1532     status = parcel.WriteString(outline.version_counter);
1533     if (!status) {
1534         return status;
1535     }
1536 
1537     status = parcel.WriteString(outline.summary);
1538     if (!status) {
1539         return status;
1540     }
1541 
1542     status = parcel.WriteInt32(static_cast<int>(outline.participantList_.size()));
1543     if (!status) {
1544         return status;
1545     }
1546 
1547     bluetooth::IProfileParticipant participant;
1548     for (auto it = outline.participantList_.begin(); it != outline.participantList_.end(); it++) {
1549         participant = *it;
1550         WriteToParcelIProfileParticipant(parcel, participant);
1551     }
1552 
1553     return status;
1554 }
1555 
ReadFromParcelIProfileConversation(Parcel & parcel,bluetooth::IProfileConversation & outline)1556 bool BluetoothIProfileConversationListing::ReadFromParcelIProfileConversation(
1557     Parcel &parcel, bluetooth::IProfileConversation &outline)
1558 {
1559     bool status;
1560     int tmpInt;
1561 
1562     status = parcel.ReadString(outline.id);
1563     if (!status) {
1564         return status;
1565     }
1566 
1567     status = parcel.ReadString(outline.name);
1568     if (!status) {
1569         return status;
1570     }
1571 
1572     status = parcel.ReadString(outline.last_activity);
1573     if (!status) {
1574         return status;
1575     }
1576 
1577     status = parcel.ReadString(outline.read_status);
1578     if (!status) {
1579         return status;
1580     }
1581 
1582     status = parcel.ReadString(outline.version_counter);
1583     if (!status) {
1584         return status;
1585     }
1586 
1587     status = parcel.ReadString(outline.summary);
1588     if (!status) {
1589         return status;
1590     }
1591 
1592     status = parcel.ReadInt32(tmpInt);
1593     if (!status) {
1594         return status;
1595     }
1596     participantListNum_ = tmpInt;
1597     if (participantListNum_ > MAP_MCE_PARTICIPANTLIST_COUNT_MAX) {
1598         HILOGE("check fail, invalid parameter.");
1599         return false;
1600     }
1601     bluetooth::IProfileParticipant participant;
1602     for (int i = 0; i < participantListNum_; i++) {
1603         ReadFromParcelIProfileParticipant(parcel, participant);
1604         outline.participantList_.push_back(participant);
1605     }
1606 
1607     return status;
1608 }
1609 
WriteToParcelIProfileParticipant(Parcel & parcel,const bluetooth::IProfileParticipant & outline) const1610 bool BluetoothIProfileConversationListing::WriteToParcelIProfileParticipant(
1611     Parcel &parcel, const bluetooth::IProfileParticipant &outline) const
1612 {
1613     bool status;
1614 
1615     status = parcel.WriteString(outline.uci);
1616     if (!status) {
1617         return status;
1618     }
1619 
1620     status = parcel.WriteString(outline.display_name);
1621     if (!status) {
1622         return status;
1623     }
1624 
1625     status = parcel.WriteString(outline.chat_state);
1626     if (!status) {
1627         return status;
1628     }
1629 
1630     status = parcel.WriteString(outline.last_activity);
1631     if (!status) {
1632         return status;
1633     }
1634 
1635     status = parcel.WriteString(outline.x_bt_uid);
1636     if (!status) {
1637         return status;
1638     }
1639 
1640     status = parcel.WriteString(outline.name);
1641     if (!status) {
1642         return status;
1643     }
1644 
1645     status = parcel.WriteString(outline.presence_availability);
1646     if (!status) {
1647         return status;
1648     }
1649 
1650     status = parcel.WriteString(outline.presence_text);
1651     if (!status) {
1652         return status;
1653     }
1654 
1655     status = parcel.WriteString(outline.priority);
1656     if (!status) {
1657         return status;
1658     }
1659 
1660     return status;
1661 }
1662 
ReadFromParcelIProfileParticipant(Parcel & parcel,bluetooth::IProfileParticipant & outline)1663 bool BluetoothIProfileConversationListing::ReadFromParcelIProfileParticipant(
1664     Parcel &parcel, bluetooth::IProfileParticipant &outline)
1665 {
1666     bool status;
1667 
1668     status = parcel.ReadString(outline.uci);
1669     if (!status) {
1670         return status;
1671     }
1672 
1673     status = parcel.ReadString(outline.display_name);
1674     if (!status) {
1675         return status;
1676     }
1677 
1678     status = parcel.ReadString(outline.chat_state);
1679     if (!status) {
1680         return status;
1681     }
1682 
1683     status = parcel.ReadString(outline.last_activity);
1684     if (!status) {
1685         return status;
1686     }
1687 
1688     status = parcel.ReadString(outline.x_bt_uid);
1689     if (!status) {
1690         return status;
1691     }
1692 
1693     status = parcel.ReadString(outline.name);
1694     if (!status) {
1695         return status;
1696     }
1697 
1698     status = parcel.ReadString(outline.presence_availability);
1699     if (!status) {
1700         return status;
1701     }
1702 
1703     status = parcel.ReadString(outline.presence_text);
1704     if (!status) {
1705         return status;
1706     }
1707 
1708     status = parcel.ReadString(outline.priority);
1709     if (!status) {
1710         return status;
1711     }
1712 
1713     return status;
1714 }
1715 
Marshalling(Parcel & parcel) const1716 bool BluetoothIProfileConversationListing::Marshalling(Parcel &parcel) const
1717 {
1718     bool status;
1719 
1720     status = parcel.WriteInt32((int)conversationOutlineList_.size());
1721     if (!status) {
1722         return status;
1723     }
1724 
1725     bluetooth::IProfileConversation conversation;
1726     for (auto it = conversationOutlineList_.begin(); it != conversationOutlineList_.end(); it++) {
1727         conversation = *it;
1728         WriteToParcelIProfileConversation(parcel, conversation);
1729     }
1730 
1731     status = parcel.WriteString(conversationListingParam_.ConversationListingVersionCounter);
1732     if (!status) {
1733         return status;
1734     }
1735 
1736     status = parcel.WriteUint16(conversationListingParam_.ListingSize);
1737     if (!status) {
1738         return status;
1739     }
1740 
1741     status = parcel.WriteString(conversationListingParam_.DatabaseIdentifier);
1742     if (!status) {
1743         return status;
1744     }
1745 
1746     status = parcel.WriteString(conversationListingParam_.MseTime);
1747     if (!status) {
1748         return status;
1749     }
1750 
1751     status = parcel.WriteString(conversationListingParam_.Version);
1752     if (!status) {
1753         return status;
1754     }
1755 
1756     status = parcel.WriteString(conversationListingStringObject_);
1757     if (!status) {
1758         return status;
1759     }
1760 
1761     return status;
1762 }
1763 
WriteToParcel(Parcel & parcel)1764 bool BluetoothIProfileConversationListing::WriteToParcel(Parcel &parcel)
1765 {
1766     return Marshalling(parcel);
1767 }
1768 
Unmarshalling(Parcel & parcel)1769 BluetoothIProfileConversationListing *BluetoothIProfileConversationListing::Unmarshalling(Parcel &parcel)
1770 {
1771     BluetoothIProfileConversationListing *obj = new BluetoothIProfileConversationListing();
1772     if (obj != nullptr && !obj->ReadFromParcel(parcel)) {
1773         delete obj;
1774         obj = nullptr;
1775     }
1776     return obj;
1777 }
1778 
ReadFromParcel(Parcel & parcel)1779 bool BluetoothIProfileConversationListing::ReadFromParcel(Parcel &parcel)
1780 {
1781     bool status;
1782     int tmpInt;
1783 
1784     status = parcel.ReadInt32(tmpInt);
1785     if (!status) {
1786         return status;
1787     }
1788     conversationOutlineListNum_ = tmpInt;
1789     if (conversationOutlineListNum_ > MAP_MCE_CONVOUTLINELIST_COUNT_MAX) {
1790         HILOGE("check fail, invalid parameter.");
1791         return false;
1792     }
1793     bluetooth::IProfileConversation conversation;
1794     for (int i = 0; i < conversationOutlineListNum_; i++) {
1795         ReadFromParcelIProfileConversation(parcel, conversation);
1796         conversationOutlineList_.push_back(conversation);
1797     }
1798 
1799     status = parcel.ReadString(conversationListingParam_.ConversationListingVersionCounter);
1800     if (!status) {
1801         return status;
1802     }
1803 
1804     status = parcel.ReadUint16(conversationListingParam_.ListingSize);
1805     if (!status) {
1806         return status;
1807     }
1808 
1809     status = parcel.ReadString(conversationListingParam_.DatabaseIdentifier);
1810     if (!status) {
1811         return status;
1812     }
1813 
1814     status = parcel.ReadString(conversationListingParam_.MseTime);
1815     if (!status) {
1816         return status;
1817     }
1818 
1819     status = parcel.ReadString(conversationListingParam_.Version);
1820     if (!status) {
1821         return status;
1822     }
1823 
1824     status = parcel.ReadString(conversationListingStringObject_);
1825     if (!status) {
1826         return status;
1827     }
1828 
1829     return status;
1830 }
1831 
Marshalling(Parcel & parcel) const1832 bool BluetoothIProfileMapEventReport::Marshalling(Parcel &parcel) const
1833 {
1834     bool status = parcel.WriteString(type);
1835     if (!status) {
1836         return status;
1837     }
1838 
1839     status = parcel.WriteString(handle);
1840     if (!status) {
1841         return status;
1842     }
1843 
1844     status = parcel.WriteString16(folder);
1845     if (!status) {
1846         return status;
1847     }
1848 
1849     status = parcel.WriteString16(old_folder);
1850     if (!status) {
1851         return status;
1852     }
1853 
1854     status = parcel.WriteInt32(static_cast<int>(msg_type));
1855     if (!status) {
1856         return status;
1857     }
1858 
1859     status = parcel.WriteString(datetime);
1860     if (!status) {
1861         return status;
1862     }
1863 
1864     status = parcel.WriteString(subject);
1865     if (!status) {
1866         return status;
1867     }
1868 
1869     status = parcel.WriteString(sender_name);
1870     if (!status) {
1871         return status;
1872     }
1873 
1874     status = parcel.WriteInt32(static_cast<int>(priority));
1875     if (!status) {
1876         return status;
1877     }
1878 
1879     status = parcel.WriteString(conversation_name);
1880     if (!status) {
1881         return status;
1882     }
1883 
1884     status = parcel.WriteString(conversation_id);
1885     if (!status) {
1886         return status;
1887     }
1888 
1889     status = parcel.WriteString(presence_availability);
1890     if (!status) {
1891         return status;
1892     }
1893 
1894     status = parcel.WriteString(presence_text);
1895     if (!status) {
1896         return status;
1897     }
1898 
1899     status = parcel.WriteString(last_activity);
1900     if (!status) {
1901         return status;
1902     }
1903 
1904     status = parcel.WriteString(chat_state);
1905     if (!status) {
1906         return status;
1907     }
1908 
1909     status = parcel.WriteInt32(static_cast<int>(read_status));
1910     if (!status) {
1911         return status;
1912     }
1913 
1914     status = parcel.WriteString(extended_data);
1915     if (!status) {
1916         return status;
1917     }
1918 
1919     status = parcel.WriteString(participant_uci);
1920     if (!status) {
1921         return status;
1922     }
1923 
1924     status = parcel.WriteString(contact_uid);
1925     if (!status) {
1926         return status;
1927     }
1928 
1929     status = parcel.WriteString(version);
1930     if (!status) {
1931         return status;
1932     }
1933 
1934     status = parcel.WriteUint8(masInstanceId_);
1935     if (!status) {
1936         return status;
1937     }
1938 
1939     status = parcel.WriteString(eventReportStringObject_);
1940     if (!status) {
1941         return status;
1942     }
1943     return status;
1944 }
1945 
WriteToParcel(Parcel & parcel)1946 bool BluetoothIProfileMapEventReport::WriteToParcel(Parcel &parcel)
1947 {
1948     return Marshalling(parcel);
1949 }
1950 
Unmarshalling(Parcel & parcel)1951 BluetoothIProfileMapEventReport *BluetoothIProfileMapEventReport::Unmarshalling(Parcel &parcel)
1952 {
1953     BluetoothIProfileMapEventReport *obj = new BluetoothIProfileMapEventReport();
1954     if (obj != nullptr && !obj->ReadFromParcel(parcel)) {
1955         delete obj;
1956         obj = nullptr;
1957     }
1958     return obj;
1959 }
1960 
ReadFromParcel(Parcel & parcel)1961 bool BluetoothIProfileMapEventReport::ReadFromParcel(Parcel &parcel)
1962 {
1963     bool status;
1964     int tempInt;
1965 
1966     status = parcel.ReadString(type);
1967     if (!status) {
1968         return status;
1969     }
1970 
1971     status = parcel.ReadString(handle);
1972     if (!status) {
1973         return status;
1974     }
1975 
1976     status = parcel.ReadString16(folder);
1977     if (!status) {
1978         return status;
1979     }
1980 
1981     status = parcel.ReadString16(old_folder);
1982     if (!status) {
1983         return status;
1984     }
1985 
1986     status = parcel.ReadInt32(tempInt);
1987     if (!status) {
1988         return status;
1989     }
1990     msg_type = bluetooth::MapMessageType(tempInt);
1991 
1992     status = parcel.ReadString(datetime);
1993     if (!status) {
1994         return status;
1995     }
1996 
1997     status = parcel.ReadString(subject);
1998     if (!status) {
1999         return status;
2000     }
2001 
2002     status = parcel.ReadString(sender_name);
2003     if (!status) {
2004         return status;
2005     }
2006 
2007     status = parcel.ReadInt32(tempInt);
2008     if (!status) {
2009         return status;
2010     }
2011     priority = bluetooth::MapBoolType(tempInt);
2012 
2013     status = parcel.ReadString(conversation_name);
2014     if (!status) {
2015         return status;
2016     }
2017 
2018     status = parcel.ReadString(conversation_id);
2019     if (!status) {
2020         return status;
2021     }
2022 
2023     status = parcel.ReadString(presence_availability);
2024     if (!status) {
2025         return status;
2026     }
2027 
2028     status = parcel.ReadString(presence_text);
2029     if (!status) {
2030         return status;
2031     }
2032 
2033     status = parcel.ReadString(last_activity);
2034     if (!status) {
2035         return status;
2036     }
2037 
2038     status = parcel.ReadString(chat_state);
2039     if (!status) {
2040         return status;
2041     }
2042 
2043     status = parcel.ReadInt32(tempInt);
2044     if (!status) {
2045         return status;
2046     }
2047     read_status = bluetooth::MapMessageStatus(tempInt);
2048 
2049     status = parcel.ReadString(extended_data);
2050     if (!status) {
2051         return status;
2052     }
2053 
2054     status = parcel.ReadString(participant_uci);
2055     if (!status) {
2056         return status;
2057     }
2058 
2059     status = parcel.ReadString(contact_uid);
2060     if (!status) {
2061         return status;
2062     }
2063 
2064     status = parcel.ReadString(version);
2065     if (!status) {
2066         return status;
2067     }
2068 
2069     status = parcel.ReadUint8(masInstanceId_);
2070     if (!status) {
2071         return status;
2072     }
2073 
2074     status = parcel.ReadString(eventReportStringObject_);
2075     if (!status) {
2076         return status;
2077     }
2078 
2079     return status;
2080 }
2081 
2082 }  // namespace Bluetooth
2083 }  // namespace OHOS
2084