Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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 | |
Mathew Inwood | 7acad5e | 2018-08-01 15:00:35 +0100 | [diff] [blame] | 18 | import android.annotation.UnsupportedAppUsage; |
Jakub Pawlowski | 8d312a8 | 2016-03-01 18:50:27 -0800 | [diff] [blame] | 19 | import android.os.Parcel; |
Jakub Pawlowski | 8d312a8 | 2016-03-01 18:50:27 -0800 | [diff] [blame] | 20 | import android.os.ParcelUuid; |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 21 | import android.os.Parcelable; |
| 22 | |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 23 | import java.util.ArrayList; |
| 24 | import java.util.List; |
| 25 | import java.util.UUID; |
| 26 | |
| 27 | /** |
Matthew Xie | ddf7e47 | 2013-03-01 18:41:02 -0800 | [diff] [blame] | 28 | * Represents a Bluetooth GATT Service |
Matthew Xie | 33ec984 | 2013-04-03 00:29:27 -0700 | [diff] [blame] | 29 | * |
| 30 | * <p> Gatt Service contains a collection of {@link BluetoothGattCharacteristic}, |
| 31 | * as well as referenced services. |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 32 | */ |
Jakub Pawlowski | 8d312a8 | 2016-03-01 18:50:27 -0800 | [diff] [blame] | 33 | public class BluetoothGattService implements Parcelable { |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 34 | |
| 35 | /** |
| 36 | * Primary service |
| 37 | */ |
| 38 | public static final int SERVICE_TYPE_PRIMARY = 0; |
| 39 | |
| 40 | /** |
| 41 | * Secondary service (included by primary services) |
| 42 | */ |
| 43 | public static final int SERVICE_TYPE_SECONDARY = 1; |
| 44 | |
| 45 | |
| 46 | /** |
| 47 | * The remote device his service is associated with. |
| 48 | * This applies to client applications only. |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 49 | * |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 50 | * @hide |
| 51 | */ |
Mathew Inwood | 7acad5e | 2018-08-01 15:00:35 +0100 | [diff] [blame] | 52 | @UnsupportedAppUsage |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 53 | protected BluetoothDevice mDevice; |
| 54 | |
| 55 | /** |
| 56 | * The UUID of this service. |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 57 | * |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 58 | * @hide |
| 59 | */ |
| 60 | protected UUID mUuid; |
| 61 | |
| 62 | /** |
| 63 | * Instance ID for this service. |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 64 | * |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 65 | * @hide |
| 66 | */ |
| 67 | protected int mInstanceId; |
| 68 | |
| 69 | /** |
| 70 | * Handle counter override (for conformance testing). |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 71 | * |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 72 | * @hide |
| 73 | */ |
| 74 | protected int mHandles = 0; |
| 75 | |
| 76 | /** |
| 77 | * Service type (Primary/Secondary). |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 78 | * |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 79 | * @hide |
| 80 | */ |
| 81 | protected int mServiceType; |
| 82 | |
| 83 | /** |
| 84 | * List of characteristics included in this service. |
| 85 | */ |
| 86 | protected List<BluetoothGattCharacteristic> mCharacteristics; |
| 87 | |
| 88 | /** |
| 89 | * List of included services for this service. |
| 90 | */ |
| 91 | protected List<BluetoothGattService> mIncludedServices; |
| 92 | |
| 93 | /** |
Wei Wang | 18c7693 | 2013-10-29 21:05:37 -0700 | [diff] [blame] | 94 | * Whether the service uuid should be advertised. |
| 95 | */ |
| 96 | private boolean mAdvertisePreferred; |
| 97 | |
| 98 | /** |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 99 | * Create a new BluetoothGattService. |
Matthew Xie | ddf7e47 | 2013-03-01 18:41:02 -0800 | [diff] [blame] | 100 | * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission. |
| 101 | * |
| 102 | * @param uuid The UUID for this service |
| 103 | * @param serviceType The type of this service, |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 104 | * {@link BluetoothGattService#SERVICE_TYPE_PRIMARY} |
| 105 | * or {@link BluetoothGattService#SERVICE_TYPE_SECONDARY} |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 106 | */ |
Matthew Xie | ddf7e47 | 2013-03-01 18:41:02 -0800 | [diff] [blame] | 107 | public BluetoothGattService(UUID uuid, int serviceType) { |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 108 | mDevice = null; |
| 109 | mUuid = uuid; |
| 110 | mInstanceId = 0; |
| 111 | mServiceType = serviceType; |
| 112 | mCharacteristics = new ArrayList<BluetoothGattCharacteristic>(); |
| 113 | mIncludedServices = new ArrayList<BluetoothGattService>(); |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Create a new BluetoothGattService |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 118 | * |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 119 | * @hide |
| 120 | */ |
| 121 | /*package*/ BluetoothGattService(BluetoothDevice device, UUID uuid, |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 122 | int instanceId, int serviceType) { |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 123 | mDevice = device; |
| 124 | mUuid = uuid; |
| 125 | mInstanceId = instanceId; |
| 126 | mServiceType = serviceType; |
| 127 | mCharacteristics = new ArrayList<BluetoothGattCharacteristic>(); |
| 128 | mIncludedServices = new ArrayList<BluetoothGattService>(); |
| 129 | } |
| 130 | |
| 131 | /** |
Jakub Pawlowski | 8d312a8 | 2016-03-01 18:50:27 -0800 | [diff] [blame] | 132 | * Create a new BluetoothGattService |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 133 | * |
Jakub Pawlowski | 8d312a8 | 2016-03-01 18:50:27 -0800 | [diff] [blame] | 134 | * @hide |
| 135 | */ |
| 136 | public BluetoothGattService(UUID uuid, int instanceId, int serviceType) { |
| 137 | mDevice = null; |
| 138 | mUuid = uuid; |
| 139 | mInstanceId = instanceId; |
| 140 | mServiceType = serviceType; |
| 141 | mCharacteristics = new ArrayList<BluetoothGattCharacteristic>(); |
| 142 | mIncludedServices = new ArrayList<BluetoothGattService>(); |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * @hide |
| 147 | */ |
| 148 | public int describeContents() { |
| 149 | return 0; |
| 150 | } |
| 151 | |
| 152 | @Override |
| 153 | public void writeToParcel(Parcel out, int flags) { |
| 154 | out.writeParcelable(new ParcelUuid(mUuid), 0); |
| 155 | out.writeInt(mInstanceId); |
| 156 | out.writeInt(mServiceType); |
| 157 | out.writeTypedList(mCharacteristics); |
| 158 | |
| 159 | ArrayList<BluetoothGattIncludedService> includedServices = |
| 160 | new ArrayList<BluetoothGattIncludedService>(mIncludedServices.size()); |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 161 | for (BluetoothGattService s : mIncludedServices) { |
Jakub Pawlowski | 8d312a8 | 2016-03-01 18:50:27 -0800 | [diff] [blame] | 162 | includedServices.add(new BluetoothGattIncludedService(s.getUuid(), |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 163 | s.getInstanceId(), s.getType())); |
Jakub Pawlowski | 8d312a8 | 2016-03-01 18:50:27 -0800 | [diff] [blame] | 164 | } |
| 165 | out.writeTypedList(includedServices); |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 166 | } |
Jakub Pawlowski | 8d312a8 | 2016-03-01 18:50:27 -0800 | [diff] [blame] | 167 | |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 168 | public static final Parcelable.Creator<BluetoothGattService> CREATOR = |
| 169 | new Parcelable.Creator<BluetoothGattService>() { |
Jakub Pawlowski | 8d312a8 | 2016-03-01 18:50:27 -0800 | [diff] [blame] | 170 | public BluetoothGattService createFromParcel(Parcel in) { |
| 171 | return new BluetoothGattService(in); |
| 172 | } |
| 173 | |
| 174 | public BluetoothGattService[] newArray(int size) { |
| 175 | return new BluetoothGattService[size]; |
| 176 | } |
| 177 | }; |
| 178 | |
| 179 | private BluetoothGattService(Parcel in) { |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 180 | mUuid = ((ParcelUuid) in.readParcelable(null)).getUuid(); |
Jakub Pawlowski | 8d312a8 | 2016-03-01 18:50:27 -0800 | [diff] [blame] | 181 | mInstanceId = in.readInt(); |
| 182 | mServiceType = in.readInt(); |
| 183 | |
| 184 | mCharacteristics = new ArrayList<BluetoothGattCharacteristic>(); |
| 185 | |
| 186 | ArrayList<BluetoothGattCharacteristic> chrcs = |
| 187 | in.createTypedArrayList(BluetoothGattCharacteristic.CREATOR); |
| 188 | if (chrcs != null) { |
| 189 | for (BluetoothGattCharacteristic chrc : chrcs) { |
| 190 | chrc.setService(this); |
| 191 | mCharacteristics.add(chrc); |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | mIncludedServices = new ArrayList<BluetoothGattService>(); |
| 196 | |
| 197 | ArrayList<BluetoothGattIncludedService> inclSvcs = |
| 198 | in.createTypedArrayList(BluetoothGattIncludedService.CREATOR); |
| 199 | if (chrcs != null) { |
| 200 | for (BluetoothGattIncludedService isvc : inclSvcs) { |
| 201 | mIncludedServices.add(new BluetoothGattService(null, isvc.getUuid(), |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 202 | isvc.getInstanceId(), isvc.getType())); |
Jakub Pawlowski | 8d312a8 | 2016-03-01 18:50:27 -0800 | [diff] [blame] | 203 | } |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | /** |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 208 | * Returns the device associated with this service. |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 209 | * |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 210 | * @hide |
| 211 | */ |
| 212 | /*package*/ BluetoothDevice getDevice() { |
| 213 | return mDevice; |
| 214 | } |
| 215 | |
| 216 | /** |
Jakub Pawlowski | 8d312a8 | 2016-03-01 18:50:27 -0800 | [diff] [blame] | 217 | * Returns the device associated with this service. |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 218 | * |
Jakub Pawlowski | 8d312a8 | 2016-03-01 18:50:27 -0800 | [diff] [blame] | 219 | * @hide |
| 220 | */ |
| 221 | /*package*/ void setDevice(BluetoothDevice device) { |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 222 | mDevice = device; |
Jakub Pawlowski | 8d312a8 | 2016-03-01 18:50:27 -0800 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | /** |
Matthew Xie | ddf7e47 | 2013-03-01 18:41:02 -0800 | [diff] [blame] | 226 | * Add an included service to this service. |
| 227 | * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission. |
| 228 | * |
| 229 | * @param service The service to be added |
| 230 | * @return true, if the included service was added to the service |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 231 | */ |
Matthew Xie | ddf7e47 | 2013-03-01 18:41:02 -0800 | [diff] [blame] | 232 | public boolean addService(BluetoothGattService service) { |
| 233 | mIncludedServices.add(service); |
| 234 | return true; |
| 235 | } |
| 236 | |
| 237 | /** |
| 238 | * Add a characteristic to this service. |
| 239 | * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission. |
| 240 | * |
| 241 | * @param characteristic The characteristics to be added |
| 242 | * @return true, if the characteristic was added to the service |
| 243 | */ |
| 244 | public boolean addCharacteristic(BluetoothGattCharacteristic characteristic) { |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 245 | mCharacteristics.add(characteristic); |
Matthew Xie | ddf7e47 | 2013-03-01 18:41:02 -0800 | [diff] [blame] | 246 | characteristic.setService(this); |
| 247 | return true; |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | /** |
| 251 | * Get characteristic by UUID and instanceId. |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 252 | * |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 253 | * @hide |
| 254 | */ |
| 255 | /*package*/ BluetoothGattCharacteristic getCharacteristic(UUID uuid, int instanceId) { |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 256 | for (BluetoothGattCharacteristic characteristic : mCharacteristics) { |
Andre Eisenbach | 25b9cf9 | 2013-07-08 23:58:16 -0700 | [diff] [blame] | 257 | if (uuid.equals(characteristic.getUuid()) |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 258 | && characteristic.getInstanceId() == instanceId) { |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 259 | return characteristic; |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 260 | } |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 261 | } |
| 262 | return null; |
| 263 | } |
| 264 | |
| 265 | /** |
Matthew Xie | ddf7e47 | 2013-03-01 18:41:02 -0800 | [diff] [blame] | 266 | * Force the instance ID. |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 267 | * |
Matthew Xie | ddf7e47 | 2013-03-01 18:41:02 -0800 | [diff] [blame] | 268 | * @hide |
| 269 | */ |
Mathew Inwood | 7acad5e | 2018-08-01 15:00:35 +0100 | [diff] [blame] | 270 | @UnsupportedAppUsage |
Matthew Xie | ddf7e47 | 2013-03-01 18:41:02 -0800 | [diff] [blame] | 271 | public void setInstanceId(int instanceId) { |
| 272 | mInstanceId = instanceId; |
| 273 | } |
| 274 | |
| 275 | /** |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 276 | * Get the handle count override (conformance testing. |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 277 | * |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 278 | * @hide |
| 279 | */ |
| 280 | /*package*/ int getHandles() { |
| 281 | return mHandles; |
| 282 | } |
| 283 | |
| 284 | /** |
Matthew Xie | ddf7e47 | 2013-03-01 18:41:02 -0800 | [diff] [blame] | 285 | * Force the number of handles to reserve for this service. |
| 286 | * This is needed for conformance testing only. |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 287 | * |
Matthew Xie | ddf7e47 | 2013-03-01 18:41:02 -0800 | [diff] [blame] | 288 | * @hide |
| 289 | */ |
| 290 | public void setHandles(int handles) { |
| 291 | mHandles = handles; |
| 292 | } |
| 293 | |
| 294 | /** |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 295 | * Add an included service to the internal map. |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 296 | * |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 297 | * @hide |
| 298 | */ |
Jakub Pawlowski | 8d312a8 | 2016-03-01 18:50:27 -0800 | [diff] [blame] | 299 | public void addIncludedService(BluetoothGattService includedService) { |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 300 | mIncludedServices.add(includedService); |
| 301 | } |
| 302 | |
| 303 | /** |
| 304 | * Returns the UUID of this service |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 305 | * |
| 306 | * @return UUID of this service |
| 307 | */ |
| 308 | public UUID getUuid() { |
| 309 | return mUuid; |
| 310 | } |
| 311 | |
| 312 | /** |
| 313 | * Returns the instance ID for this service |
| 314 | * |
| 315 | * <p>If a remote device offers multiple services with the same UUID |
| 316 | * (ex. multiple battery services for different batteries), the instance |
| 317 | * ID is used to distuinguish services. |
| 318 | * |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 319 | * @return Instance ID of this service |
| 320 | */ |
| 321 | public int getInstanceId() { |
| 322 | return mInstanceId; |
| 323 | } |
| 324 | |
| 325 | /** |
| 326 | * Get the type of this service (primary/secondary) |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 327 | */ |
| 328 | public int getType() { |
| 329 | return mServiceType; |
| 330 | } |
| 331 | |
| 332 | /** |
Matthew Xie | ddf7e47 | 2013-03-01 18:41:02 -0800 | [diff] [blame] | 333 | * Get the list of included GATT services for this service. |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 334 | * |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 335 | * @return List of included services or empty list if no included services were discovered. |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 336 | */ |
| 337 | public List<BluetoothGattService> getIncludedServices() { |
| 338 | return mIncludedServices; |
| 339 | } |
| 340 | |
| 341 | /** |
| 342 | * Returns a list of characteristics included in this service. |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 343 | * |
| 344 | * @return Characteristics included in this service |
| 345 | */ |
| 346 | public List<BluetoothGattCharacteristic> getCharacteristics() { |
| 347 | return mCharacteristics; |
| 348 | } |
| 349 | |
| 350 | /** |
| 351 | * Returns a characteristic with a given UUID out of the list of |
| 352 | * characteristics offered by this service. |
| 353 | * |
| 354 | * <p>This is a convenience function to allow access to a given characteristic |
| 355 | * without enumerating over the list returned by {@link #getCharacteristics} |
| 356 | * manually. |
| 357 | * |
| 358 | * <p>If a remote service offers multiple characteristics with the same |
| 359 | * UUID, the first instance of a characteristic with the given UUID |
| 360 | * is returned. |
| 361 | * |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 362 | * @return GATT characteristic object or null if no characteristic with the given UUID was |
| 363 | * found. |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 364 | */ |
| 365 | public BluetoothGattCharacteristic getCharacteristic(UUID uuid) { |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 366 | for (BluetoothGattCharacteristic characteristic : mCharacteristics) { |
| 367 | if (uuid.equals(characteristic.getUuid())) { |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 368 | return characteristic; |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 369 | } |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 370 | } |
| 371 | return null; |
| 372 | } |
Wei Wang | 18c7693 | 2013-10-29 21:05:37 -0700 | [diff] [blame] | 373 | |
| 374 | /** |
| 375 | * Returns whether the uuid of the service should be advertised. |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 376 | * |
Wei Wang | 18c7693 | 2013-10-29 21:05:37 -0700 | [diff] [blame] | 377 | * @hide |
| 378 | */ |
| 379 | public boolean isAdvertisePreferred() { |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 380 | return mAdvertisePreferred; |
Wei Wang | 18c7693 | 2013-10-29 21:05:37 -0700 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | /** |
| 384 | * Set whether the service uuid should be advertised. |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 385 | * |
Wei Wang | 18c7693 | 2013-10-29 21:05:37 -0700 | [diff] [blame] | 386 | * @hide |
| 387 | */ |
Mathew Inwood | 7acad5e | 2018-08-01 15:00:35 +0100 | [diff] [blame] | 388 | @UnsupportedAppUsage |
Wei Wang | 18c7693 | 2013-10-29 21:05:37 -0700 | [diff] [blame] | 389 | public void setAdvertisePreferred(boolean advertisePreferred) { |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 390 | mAdvertisePreferred = advertisePreferred; |
Wei Wang | 18c7693 | 2013-10-29 21:05:37 -0700 | [diff] [blame] | 391 | } |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 392 | } |