1 // 2 // Copyright (C) 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_string_value.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 BluetoothAvrcpStringValue::writeToParcel(Parcel* parcel) const { 30 status_t status = parcel->writeInt32(id_); 31 if (status != OK) return status; 32 33 status = parcel->writeString16(String16(value_.c_str(), value_.size())); 34 if (status != OK) return status; 35 36 return status; 37 } 38 readFromParcel(const Parcel * parcel)39status_t BluetoothAvrcpStringValue::readFromParcel(const Parcel* parcel) { 40 int32_t tmp; 41 status_t status = parcel->readInt32(&tmp); 42 if (status != OK) return status; 43 id_ = tmp; 44 45 String16 value; 46 status = parcel->readString16(&value); 47 if (status != OK) return status; 48 value_ = String8(value).string(); 49 50 return status; 51 } 52 53 } // namespace bluetooth 54 } // namespace android 55