1 // 2 // Copyright 2017 Google, Inc. 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at: 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 // 16 17 #include "android/bluetooth/bluetooth_avrcp_media_attr.h" 18 19 #include <utils/String16.h> 20 #include <utils/String8.h> 21 22 using android::OK; 23 using android::String16; 24 using android::String8; 25 26 namespace android { 27 namespace bluetooth { 28 writeToParcel(Parcel * parcel) const29status_t BluetoothAvrcpMediaAttr::writeToParcel(Parcel* parcel) const { 30 status_t status = 31 parcel->writeString16(String16(title_.c_str(), title_.size())); 32 if (status != OK) return status; 33 34 status = parcel->writeString16(String16(artist_.c_str(), artist_.size())); 35 if (status != OK) return status; 36 37 status = parcel->writeString16(String16(album_.c_str(), album_.size())); 38 if (status != OK) return status; 39 40 status = parcel->writeString16(String16(genre_.c_str(), genre_.size())); 41 if (status != OK) return status; 42 43 status = parcel->writeInt32(track_num_); 44 if (status != OK) return status; 45 46 status = parcel->writeInt32(num_tracks_); 47 if (status != OK) return status; 48 49 status = parcel->writeInt32(play_time_); 50 if (status != OK) return status; 51 52 return status; 53 } 54 readFromParcel(const Parcel * parcel)55status_t BluetoothAvrcpMediaAttr::readFromParcel(const Parcel* parcel) { 56 String16 title; 57 status_t status = parcel->readString16(&title); 58 if (status != OK) return status; 59 title_ = String8(title).string(); 60 61 String16 artist; 62 status = parcel->readString16(&artist); 63 if (status != OK) return status; 64 artist_ = String8(artist).string(); 65 66 String16 album; 67 status = parcel->readString16(&album); 68 if (status != OK) return status; 69 album_ = String8(album).string(); 70 71 String16 genre; 72 status = parcel->readString16(&genre); 73 if (status != OK) return status; 74 genre_ = String8(genre).string(); 75 76 int32_t tmp; 77 status = parcel->readInt32(&tmp); 78 if (status != OK) return status; 79 track_num_ = tmp; 80 81 status = parcel->readInt32(&tmp); 82 if (status != OK) return status; 83 num_tracks_ = tmp; 84 85 status = parcel->readInt32(&tmp); 86 if (status != OK) return status; 87 play_time_ = tmp; 88 89 return status; 90 } 91 92 } // namespace bluetooth 93 } // namespace android 94