1 // 2 // Copyright 2016 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/advertise_settings.h" 18 19 using android::OK; 20 21 namespace android { 22 namespace bluetooth { 23 writeToParcel(Parcel * parcel) const24status_t AdvertiseSettings::writeToParcel(Parcel* parcel) const { 25 status_t status = parcel->writeInt32(mode_); 26 if (status != OK) return status; 27 28 status = parcel->writeInt32(tx_power_level_); 29 if (status != OK) return status; 30 31 status = parcel->writeInt32(connectable_); 32 if (status != OK) return status; 33 34 status = parcel->writeInt32(timeout_.InMilliseconds()); 35 return status; 36 } 37 readFromParcel(const Parcel * parcel)38status_t AdvertiseSettings::readFromParcel(const Parcel* parcel) { 39 int32_t value; 40 status_t status = parcel->readInt32(&value); 41 if (status != OK) return status; 42 43 mode_ = static_cast<AdvertiseSettings::Mode>(value); 44 45 status = parcel->readInt32(&value); 46 if (status != OK) return status; 47 48 tx_power_level_ = static_cast<AdvertiseSettings::TxPowerLevel>(value); 49 50 status = parcel->readInt32(&value); 51 if (status != OK) return status; 52 53 connectable_ = static_cast<bool>(value); 54 55 status = parcel->readInt32(&value); 56 if (status != OK) return status; 57 58 timeout_ = ::base::TimeDelta::FromMilliseconds(value); 59 return status; 60 } 61 62 } // namespace bluetooth 63 } // namespace android 64