• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
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 package android.bluetooth;
17 
18 import android.os.Parcel;
19 import android.os.Parcelable;
20 import android.os.ParcelUuid;
21 import java.util.ArrayList;
22 import java.util.List;
23 import java.util.UUID;
24 
25 /**
26  * Represents a Bluetooth GATT Included Service
27  * @hide
28  */
29 public class BluetoothGattIncludedService implements Parcelable {
30 
31     /**
32      * The UUID of this service.
33      */
34     protected UUID mUuid;
35 
36     /**
37      * Instance ID for this service.
38      */
39     protected int mInstanceId;
40 
41     /**
42      * Service type (Primary/Secondary).
43      */
44     protected int mServiceType;
45 
46     /**
47      * Create a new BluetoothGattIncludedService
48      */
BluetoothGattIncludedService(UUID uuid, int instanceId, int serviceType)49     public BluetoothGattIncludedService(UUID uuid, int instanceId, int serviceType) {
50         mUuid = uuid;
51         mInstanceId = instanceId;
52         mServiceType = serviceType;
53     }
54 
describeContents()55     public int describeContents() {
56         return 0;
57     }
58 
writeToParcel(Parcel out, int flags)59     public void writeToParcel(Parcel out, int flags) {
60         out.writeParcelable(new ParcelUuid(mUuid), 0);
61         out.writeInt(mInstanceId);
62         out.writeInt(mServiceType);
63      }
64 
65     public static final Parcelable.Creator<BluetoothGattIncludedService> CREATOR
66             = new Parcelable.Creator<BluetoothGattIncludedService>() {
67         public BluetoothGattIncludedService createFromParcel(Parcel in) {
68             return new BluetoothGattIncludedService(in);
69         }
70 
71         public BluetoothGattIncludedService[] newArray(int size) {
72             return new BluetoothGattIncludedService[size];
73         }
74     };
75 
BluetoothGattIncludedService(Parcel in)76     private BluetoothGattIncludedService(Parcel in) {
77         mUuid = ((ParcelUuid)in.readParcelable(null)).getUuid();
78         mInstanceId = in.readInt();
79         mServiceType = in.readInt();
80     }
81 
82     /**
83      * Returns the UUID of this service
84      *
85      * @return UUID of this service
86      */
getUuid()87     public UUID getUuid() {
88         return mUuid;
89     }
90 
91     /**
92      * Returns the instance ID for this service
93      *
94      * <p>If a remote device offers multiple services with the same UUID
95      * (ex. multiple battery services for different batteries), the instance
96      * ID is used to distuinguish services.
97      *
98      * @return Instance ID of this service
99      */
getInstanceId()100     public int getInstanceId() {
101         return mInstanceId;
102     }
103 
104     /**
105      * Get the type of this service (primary/secondary)
106      */
getType()107     public int getType() {
108         return mServiceType;
109     }
110 }
111