summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothGattService.java
diff options
context:
space:
mode:
authorMatthew Xie <mattx@google.com>2013-03-28 23:04:47 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-03-28 23:04:48 +0000
commitee0032bacbe11ee3b62402a65f79ea897cbd7e95 (patch)
tree2ceb844a6fbe2fca8ed265c69a8906fcaed0b53b /framework/java/android/bluetooth/BluetoothGattService.java
parent2ea9840cd3b8c0fe3e397e968e742669c23e3540 (diff)
parent9afa274491ca272dc30f6f6211ef2719b7a2226e (diff)
Merge "Unhide Bluetooth Low Energy public APIs" into jb-mr2-dev
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothGattService.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothGattService.java63
1 files changed, 47 insertions, 16 deletions
diff --git a/framework/java/android/bluetooth/BluetoothGattService.java b/framework/java/android/bluetooth/BluetoothGattService.java
index 6a3ce66e8f..c3b3cfe239 100644
--- a/framework/java/android/bluetooth/BluetoothGattService.java
+++ b/framework/java/android/bluetooth/BluetoothGattService.java
@@ -22,8 +22,7 @@ import java.util.List;
import java.util.UUID;
/**
- * Represents a Bluetooth Gatt Service
- * @hide
+ * Represents a Bluetooth GATT Service
*/
public class BluetoothGattService {
@@ -81,9 +80,14 @@ public class BluetoothGattService {
/**
* Create a new BluetoothGattService.
- * @hide
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
+ *
+ * @param uuid The UUID for this service
+ * @param serviceType The type of this service,
+ * {@link BluetoothGattService#SERVICE_TYPE_PRIMARY} or
+ * {@link BluetoothGattService#SERVICE_TYPE_SECONDARY}
*/
- /*package*/ BluetoothGattService(UUID uuid, int serviceType) {
+ public BluetoothGattService(UUID uuid, int serviceType) {
mDevice = null;
mUuid = uuid;
mInstanceId = 0;
@@ -115,11 +119,28 @@ public class BluetoothGattService {
}
/**
+ * Add an included service to this service.
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
+ *
+ * @param service The service to be added
+ * @return true, if the included service was added to the service
+ */
+ public boolean addService(BluetoothGattService service) {
+ mIncludedServices.add(service);
+ return true;
+ }
+
+ /**
* Add a characteristic to this service.
- * @hide
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
+ *
+ * @param characteristic The characteristics to be added
+ * @return true, if the characteristic was added to the service
*/
- /*package*/ void addCharacteristic(BluetoothGattCharacteristic characteristic) {
+ public boolean addCharacteristic(BluetoothGattCharacteristic characteristic) {
mCharacteristics.add(characteristic);
+ characteristic.setService(this);
+ return true;
}
/**
@@ -136,6 +157,15 @@ public class BluetoothGattService {
}
/**
+ * Force the instance ID.
+ * This is needed for conformance testing only.
+ * @hide
+ */
+ public void setInstanceId(int instanceId) {
+ mInstanceId = instanceId;
+ }
+
+ /**
* Get the handle count override (conformance testing.
* @hide
*/
@@ -144,6 +174,15 @@ public class BluetoothGattService {
}
/**
+ * Force the number of handles to reserve for this service.
+ * This is needed for conformance testing only.
+ * @hide
+ */
+ public void setHandles(int handles) {
+ mHandles = handles;
+ }
+
+ /**
* Add an included service to the internal map.
* @hide
*/
@@ -153,7 +192,6 @@ public class BluetoothGattService {
/**
* Returns the UUID of this service
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
* @return UUID of this service
*/
@@ -168,8 +206,6 @@ public class BluetoothGattService {
* (ex. multiple battery services for different batteries), the instance
* ID is used to distuinguish services.
*
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
- *
* @return Instance ID of this service
*/
public int getInstanceId() {
@@ -178,15 +214,13 @@ public class BluetoothGattService {
/**
* Get the type of this service (primary/secondary)
- * @hide
*/
public int getType() {
return mServiceType;
}
/**
- * Get the list of included Gatt services for this service.
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
+ * Get the list of included GATT services for this service.
*
* @return List of included services or empty list if no included services
* were discovered.
@@ -197,7 +231,6 @@ public class BluetoothGattService {
/**
* Returns a list of characteristics included in this service.
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
* @return Characteristics included in this service
*/
@@ -217,9 +250,7 @@ public class BluetoothGattService {
* UUID, the first instance of a characteristic with the given UUID
* is returned.
*
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
- *
- * @return Gatt characteristic object or null if no characteristic with the
+ * @return GATT characteristic object or null if no characteristic with the
* given UUID was found.
*/
public BluetoothGattCharacteristic getCharacteristic(UUID uuid) {