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 #pragma once 18 19 #include "bluetooth/uuid.h" 20 21 #include <binder/Parcel.h> 22 #include <binder/Parcelable.h> 23 24 using android::Parcel; 25 using android::Parcelable; 26 using android::status_t; 27 28 namespace android { 29 namespace bluetooth { 30 31 class UUID : public Parcelable { 32 public: 33 UUID() = default; 34 // NOLINT, implicit converter UUID(const::bluetooth::Uuid & uuid)35 UUID(const ::bluetooth::Uuid& uuid) : uuid(uuid){}; // NOLINT 36 ~UUID() = default; 37 38 // Write |this| parcelable to the given |parcel|. Keep in mind that 39 // implementations of writeToParcel must be manually kept in sync 40 // with readFromParcel and the Java equivalent versions of these methods. 41 // 42 // Returns android::OK on success and an appropriate error otherwise. 43 status_t writeToParcel(Parcel* parcel) const override; 44 45 // Read data from the given |parcel| into |this|. After readFromParcel 46 // completes, |this| should have equivalent state to the object that 47 // wrote itself to the parcel. 48 // 49 // Returns android::OK on success and an appropriate error otherwise. 50 status_t readFromParcel(const Parcel* parcel) override; 51 52 bool operator==(::bluetooth::Uuid rhs) const { return uuid == rhs; } 53 54 ::bluetooth::Uuid uuid; 55 }; 56 } // namespace bluetooth 57 } // namespace android 58 59 inline bool operator==(const ::bluetooth::Uuid& lhs, 60 const android::bluetooth::UUID& rhs) { 61 return lhs == rhs.uuid; 62 } 63