1b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski// 2b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski// Copyright 2017, The Android Open Source Project 3b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski// 4b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski// Licensed under the Apache License, Version 2.0 (the "License"); 5b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski// you may not use this file except in compliance with the License. 6b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski// You may obtain a copy of the License at: 7b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski// 8b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski// http://www.apache.org/licenses/LICENSE-2.0 9b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski// 10b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski// Unless required by applicable law or agreed to in writing, software 11b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski// distributed under the License is distributed on an "AS IS" BASIS, 12b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski// See the License for the specific language governing permissions and 14b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski// limitations under the License. 15b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski// 16b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski 17b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski#include "android/bluetooth/bluetooth_device.h" 18b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski 19b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski#include <utils/String16.h> 20b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski 21b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowskiusing android::OK; 22b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowskiusing android::Parcel; 23b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowskiusing android::status_t; 24b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowskiusing android::String16; 25b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowskiusing android::String8; 26b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski 27b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowskinamespace android { 28b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowskinamespace bluetooth { 29b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski 30b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowskistatus_t BluetoothDevice::writeToParcel(Parcel* parcel) const { 31b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski status_t status = parcel->writeString16(String16(address.ToString().c_str())); 32b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski return status; 33b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski} 34b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski 35b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowskistatus_t BluetoothDevice::readFromParcel(const Parcel* parcel) { 36b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski String16 tmp; 37b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski 38b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski status_t status = parcel->readString16(&tmp); 39b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski if (status != OK) return status; 40b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski 41b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski RawAddress::FromString(String8(tmp).string(), address); 42b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski return OK; 43b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski} 44b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski 45b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski} // namespace bluetooth 46b38374d71a63812712de4a4e20c0df4ff8accf28Jakub Pawlowski} // namespace android