summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothGattServer.java
diff options
context:
space:
mode:
authorAndre Eisenbach <andre@broadcom.com>2014-03-28 14:54:53 -0700
committerAndre Eisenbach <eisenbach@google.com>2014-06-27 10:31:41 -0700
commit745ef9e3f3793abf0f0a14ab8765f17be153ece0 (patch)
tree2019b3b610296a64e73051786e02e0230f8ed0c4 /framework/java/android/bluetooth/BluetoothGattServer.java
parent0bebe40f0dcbe3d0ee25abb348e0481ed38591cd (diff)
LE: Add notification sent and congestion callbacks (3/4)
This change introduces two new callbacks for applications to better handle LE notification flow control and transport congestion. The notification callback is invoked when the remote platform confirms an indication or when a local notification has been passed to the controller. No new notifications should be sent until a callback is received. Congestion callbacks are triggered when a GATT operation cannot be sent to the local Bluetooth controller. Repeatedly calling writeCharacteristic() for example will eventually trigger a congestion callback. Applications cannot send additional data until a further callback is received, indicating that the congestion has cleared up. Also made server callbacks "oneway" in the AIDL definition file. Change-Id: I7fa3324712205c79efce58e5e3df8b80a265a442
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothGattServer.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothGattServer.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothGattServer.java b/framework/java/android/bluetooth/BluetoothGattServer.java
index 34e86055db..2e993c9df1 100644
--- a/framework/java/android/bluetooth/BluetoothGattServer.java
+++ b/framework/java/android/bluetooth/BluetoothGattServer.java
@@ -265,6 +265,42 @@ public final class BluetoothGattServer implements BluetoothProfile {
Log.w(TAG, "Unhandled exception in callback", ex);
}
}
+
+ /**
+ * A notification/indication has been sent.
+ * @hide
+ */
+ public void onNotificationSent(String address, int status) {
+ if (DBG) Log.d(TAG, "onNotificationSent() - "
+ + "device=" + address + ", status=" + status);
+
+ BluetoothDevice device = mAdapter.getRemoteDevice(address);
+ if (device == null) return;
+
+ try {
+ mCallback.onNotificationSent(device, status);
+ } catch (Exception ex) {
+ Log.w(TAG, "Unhandled exception: " + ex);
+ }
+ }
+
+ /**
+ * Callback indicating the remote device connection is congested.
+ * @hide
+ */
+ public void onConnectionCongested(String address, boolean congested) {
+ if (DBG) Log.d(TAG, "onConnectionCongested() - Device=" + address
+ + " congested=" + congested);
+
+ BluetoothDevice device = mAdapter.getRemoteDevice(address);
+ if (device == null) return;
+
+ try {
+ mCallback.onConnectionCongested(device, congested);
+ } catch (Exception ex) {
+ Log.w(TAG, "Unhandled exception in callback", ex);
+ }
+ }
};
/**