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