Home | History | Annotate | Download | only in bluetooth
      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/service.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 using ::bluetooth::Uuid;
     29 
     30 namespace android {
     31 namespace bluetooth {
     32 
     33 class BluetoothGattIncludedService : public Parcelable {
     34  public:
     35   BluetoothGattIncludedService() = default;
     36   BluetoothGattIncludedService(
     37       const ::bluetooth::Service& service)  // NOLINT(implicit)
     38       : handle_(service.handle()),
     39         uuid_(service.uuid()),
     40         primary_(service.primary()){};
     41   ~BluetoothGattIncludedService() = default;
     42 
     43   // Write |this| parcelable to the given |parcel|.  Keep in mind that
     44   // implementations of writeToParcel must be manually kept in sync
     45   // with readFromParcel and the Java equivalent versions of these methods.
     46   //
     47   // Returns android::OK on success and an appropriate error otherwise.
     48   status_t writeToParcel(Parcel* parcel) const override;
     49 
     50   // Read data from the given |parcel| into |this|.  After readFromParcel
     51   // completes, |this| should have equivalent state to the object that
     52   // wrote itself to the parcel.
     53   //
     54   // Returns android::OK on success and an appropriate error otherwise.
     55   status_t readFromParcel(const Parcel* parcel) override;
     56 
     57   uint16_t handle() const { return handle_; }
     58   bool primary() const { return primary_; }
     59   Uuid uuid() const { return uuid_; }
     60 
     61  protected:
     62   uint16_t handle_;
     63   Uuid uuid_;
     64   bool primary_;
     65 };
     66 }  // namespace bluetooth
     67 }  // namespace android
     68