Home | History | Annotate | Download | only in bluetooth
      1 //
      2 //  Copyright (C) 2015 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/bluetooth_gatt_descriptor.h"
     18 #include "service/common/android/bluetooth/uuid.h"
     19 
     20 #include <utils/String16.h>
     21 #include <utils/String8.h>
     22 
     23 using android::OK;
     24 using android::String8;
     25 using android::String16;
     26 
     27 namespace android {
     28 namespace bluetooth {
     29 
     30 status_t BluetoothGattDescriptor::writeToParcel(Parcel* parcel) const {
     31   status_t status = parcel->writeParcelable((UUID)uuid_);
     32   if (status != OK) return status;
     33 
     34   status = parcel->writeInt32(handle_);
     35   if (status != OK) return status;
     36 
     37   status = parcel->writeInt32(permissions_);
     38   return status;
     39 }
     40 
     41 status_t BluetoothGattDescriptor::readFromParcel(const Parcel* parcel) {
     42   UUID uuid;
     43   status_t status = parcel->readParcelable(&uuid);
     44   if (status != OK) return status;
     45   uuid_ = (bluetooth::UUID)uuid;
     46 
     47   int32_t tmp;
     48   status = parcel->readInt32(&tmp);
     49   if (status != OK) return status;
     50   handle_ = tmp;
     51 
     52   status = parcel->readInt32(&tmp);
     53   if (status != OK) return status;
     54   permissions_ = tmp;
     55 
     56   return status;
     57 }
     58 
     59 }  // namespace bluetooth
     60 }  // namespace android
     61