blob: a33f8ccf55298d4ea1815051674272f7305b62cf [file] [log] [blame]
Jakub Pawlowskic9ba8c72016-03-01 18:50:27 -08001/*
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 */
16package android.bluetooth;
17
William Escande77e6c2d2022-09-03 16:28:12 -070018import android.annotation.NonNull;
Jakub Pawlowskic9ba8c72016-03-01 18:50:27 -080019import android.os.Parcel;
Jakub Pawlowskic9ba8c72016-03-01 18:50:27 -080020import android.os.ParcelUuid;
Jack He910201b2017-08-22 16:06:54 -070021import android.os.Parcelable;
22
Jakub Pawlowskic9ba8c72016-03-01 18:50:27 -080023import java.util.UUID;
24
25/**
26 * Represents a Bluetooth GATT Included Service
Jack He910201b2017-08-22 16:06:54 -070027 *
Jakub Pawlowskic9ba8c72016-03-01 18:50:27 -080028 * @hide
29 */
30public class BluetoothGattIncludedService implements Parcelable {
31
32 /**
33 * The UUID of this service.
34 */
35 protected UUID mUuid;
36
37 /**
38 * Instance ID for this service.
39 */
40 protected int mInstanceId;
41
42 /**
43 * Service type (Primary/Secondary).
44 */
45 protected int mServiceType;
46
47 /**
48 * Create a new BluetoothGattIncludedService
49 */
50 public BluetoothGattIncludedService(UUID uuid, int instanceId, int serviceType) {
51 mUuid = uuid;
52 mInstanceId = instanceId;
53 mServiceType = serviceType;
54 }
55
Jack He9e045d22017-08-22 21:21:23 -070056 @Override
Jakub Pawlowskic9ba8c72016-03-01 18:50:27 -080057 public int describeContents() {
58 return 0;
59 }
60
Jack He9e045d22017-08-22 21:21:23 -070061 @Override
Jakub Pawlowskic9ba8c72016-03-01 18:50:27 -080062 public void writeToParcel(Parcel out, int flags) {
63 out.writeParcelable(new ParcelUuid(mUuid), 0);
64 out.writeInt(mInstanceId);
65 out.writeInt(mServiceType);
Jack He910201b2017-08-22 16:06:54 -070066 }
Jakub Pawlowskic9ba8c72016-03-01 18:50:27 -080067
William Escande77e6c2d2022-09-03 16:28:12 -070068 public static final @NonNull Creator<BluetoothGattIncludedService> CREATOR = new Creator<>() {
Jakub Pawlowskic9ba8c72016-03-01 18:50:27 -080069 public BluetoothGattIncludedService createFromParcel(Parcel in) {
70 return new BluetoothGattIncludedService(in);
71 }
72
73 public BluetoothGattIncludedService[] newArray(int size) {
74 return new BluetoothGattIncludedService[size];
75 }
76 };
77
78 private BluetoothGattIncludedService(Parcel in) {
Jack He910201b2017-08-22 16:06:54 -070079 mUuid = ((ParcelUuid) in.readParcelable(null)).getUuid();
Jakub Pawlowskic9ba8c72016-03-01 18:50:27 -080080 mInstanceId = in.readInt();
81 mServiceType = in.readInt();
82 }
83
84 /**
85 * Returns the UUID of this service
86 *
87 * @return UUID of this service
88 */
89 public UUID getUuid() {
90 return mUuid;
91 }
92
93 /**
94 * Returns the instance ID for this service
95 *
96 * <p>If a remote device offers multiple services with the same UUID
97 * (ex. multiple battery services for different batteries), the instance
98 * ID is used to distuinguish services.
99 *
100 * @return Instance ID of this service
101 */
102 public int getInstanceId() {
103 return mInstanceId;
104 }
105
106 /**
107 * Get the type of this service (primary/secondary)
108 */
109 public int getType() {
110 return mServiceType;
111 }
112}