1 // 2 // Copyright (C) 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 "service/common/android/bluetooth/scan_settings.h" 18 19 #include <binder/Parcel.h> 20 21 using android::Parcelable; 22 using android::Parcel; 23 using android::String16; 24 using android::status_t; 25 using android::OK; 26 27 namespace android { 28 namespace bluetooth { 29 writeToParcel(Parcel * parcel) const30status_t ScanSettings::writeToParcel(Parcel* parcel) const { 31 status_t status = parcel->writeInt32(mode_); 32 if (status != OK) return status; 33 34 status = parcel->writeInt32(callback_type_); 35 if (status != OK) return status; 36 37 status = parcel->writeInt32(result_type_); 38 if (status != OK) return status; 39 40 status = parcel->writeInt64(report_delay_ms_.InMilliseconds()); 41 if (status != OK) return status; 42 43 status = parcel->writeInt32(match_mode_); 44 if (status != OK) return status; 45 46 status = parcel->writeInt32(match_count_per_filter_); 47 return status; 48 } 49 readFromParcel(const Parcel * parcel)50status_t ScanSettings::readFromParcel(const Parcel* parcel) { 51 int value; 52 status_t status = parcel->readInt32(&value); 53 if (status != OK) return status; 54 mode_ = static_cast<ScanSettings::Mode>(value); 55 56 status = parcel->readInt32(&value); 57 if (status != OK) return status; 58 callback_type_ = static_cast<ScanSettings::CallbackType>(value); 59 60 status = parcel->readInt32(&value); 61 if (status != OK) return status; 62 result_type_ = static_cast<ScanSettings::ResultType>(value); 63 64 int64_t value64; 65 status = parcel->readInt64(&value64); 66 report_delay_ms_ = ::base::TimeDelta::FromMilliseconds(value64); 67 68 status = parcel->readInt32(&value); 69 if (status != OK) return status; 70 match_mode_ = static_cast<ScanSettings::MatchMode>(value); 71 72 status = parcel->readInt32(&value); 73 if (status != OK) return status; 74 match_count_per_filter_ = static_cast<ScanSettings::MatchCount>(value); 75 76 return status; 77 } 78 79 } // namespace bluetooth 80 } // namespace android 81