diff options
6 files changed, 107 insertions, 9 deletions
diff --git a/core/java/android/bluetooth/BluetoothGatt.java b/core/java/android/bluetooth/BluetoothGatt.java index 56bf1e8604cb..a314aaf96acd 100644 --- a/core/java/android/bluetooth/BluetoothGatt.java +++ b/core/java/android/bluetooth/BluetoothGatt.java @@ -141,6 +141,7 @@ public final class BluetoothGatt implements BluetoothProfile { * Application interface registered - app is ready to go * @hide */ + @Override public void onClientRegistered(int status, int clientIf) { if (DBG) Log.d(TAG, "onClientRegistered() - status=" + status + " clientIf=" + clientIf); @@ -210,6 +211,7 @@ public final class BluetoothGatt implements BluetoothProfile { * Client connection state changed * @hide */ + @Override public void onClientConnectionState(int status, int clientIf, boolean connected, String address) { if (DBG) Log.d(TAG, "onClientConnectionState() - status=" + status @@ -245,6 +247,7 @@ public final class BluetoothGatt implements BluetoothProfile { * we are done at this point. * @hide */ + @Override public void onSearchComplete(String address, List<BluetoothGattService> services, int status) { if (DBG) Log.d(TAG, "onSearchComplete() = Device=" + address + " Status=" + status); @@ -288,6 +291,7 @@ public final class BluetoothGatt implements BluetoothProfile { * Updates the internal value. * @hide */ + @Override public void onCharacteristicRead(String address, int status, int handle, byte[] value) { if (VDBG) Log.d(TAG, "onCharacteristicRead() - Device=" + address + " handle=" + handle + " Status=" + status); @@ -336,6 +340,7 @@ public final class BluetoothGatt implements BluetoothProfile { * Let the app know how we did... * @hide */ + @Override public void onCharacteristicWrite(String address, int status, int handle) { if (VDBG) Log.d(TAG, "onCharacteristicWrite() - Device=" + address + " handle=" + handle + " Status=" + status); @@ -380,6 +385,7 @@ public final class BluetoothGatt implements BluetoothProfile { * Updates the internal value. * @hide */ + @Override public void onNotify(String address, int handle, byte[] value) { if (VDBG) Log.d(TAG, "onNotify() - Device=" + address + " handle=" + handle); @@ -403,6 +409,7 @@ public final class BluetoothGatt implements BluetoothProfile { * Descriptor has been read. * @hide */ + @Override public void onDescriptorRead(String address, int status, int handle, byte[] value) { if (VDBG) Log.d(TAG, "onDescriptorRead() - Device=" + address + " handle=" + handle); @@ -446,6 +453,7 @@ public final class BluetoothGatt implements BluetoothProfile { * Descriptor write operation complete. * @hide */ + @Override public void onDescriptorWrite(String address, int status, int handle) { if (VDBG) Log.d(TAG, "onDescriptorWrite() - Device=" + address + " handle=" + handle); @@ -488,6 +496,7 @@ public final class BluetoothGatt implements BluetoothProfile { * Prepared write transaction completed (or aborted) * @hide */ + @Override public void onExecuteWrite(String address, int status) { if (VDBG) Log.d(TAG, "onExecuteWrite() - Device=" + address + " status=" + status); @@ -510,6 +519,7 @@ public final class BluetoothGatt implements BluetoothProfile { * Remote device RSSI has been read * @hide */ + @Override public void onReadRemoteRssi(String address, int rssi, int status) { if (VDBG) Log.d(TAG, "onReadRemoteRssi() - Device=" + address + " rssi=" + rssi + " status=" + status); @@ -527,6 +537,7 @@ public final class BluetoothGatt implements BluetoothProfile { * Callback invoked when the MTU for a given connection changes * @hide */ + @Override public void onConfigureMTU(String address, int mtu, int status) { if (DBG) Log.d(TAG, "onConfigureMTU() - Device=" + address + " mtu=" + mtu + " status=" + status); @@ -539,6 +550,27 @@ public final class BluetoothGatt implements BluetoothProfile { Log.w(TAG, "Unhandled exception in callback", ex); } } + + /** + * Callback invoked when the given connection is updated + * @hide + */ + @Override + public void onConnectionUpdated(String address, int interval, int latency, + int timeout, int status) { + if (DBG) Log.d(TAG, "onConnectionUpdated() - Device=" + address + + " interval=" + interval + " latency=" + latency + + " timeout=" + timeout + " status=" + status); + if (!address.equals(mDevice.getAddress())) { + return; + } + try { + mCallback.onConnectionUpdated(BluetoothGatt.this, interval, latency, + timeout, status); + } catch (Exception ex) { + Log.w(TAG, "Unhandled exception in callback", ex); + } + } }; /*package*/ BluetoothGatt(IBluetoothGatt iGatt, BluetoothDevice device, diff --git a/core/java/android/bluetooth/BluetoothGattCallback.java b/core/java/android/bluetooth/BluetoothGattCallback.java index be69df928e17..11a15c66385a 100644 --- a/core/java/android/bluetooth/BluetoothGattCallback.java +++ b/core/java/android/bluetooth/BluetoothGattCallback.java @@ -179,4 +179,22 @@ public abstract class BluetoothGattCallback{ */ public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) { } + + /** + * Callback indicating the connection parameters were updated. + * + * @param gatt GATT client involved + * @param interval Connection interval used on this connection, 1.25ms unit. Valid + * range is from 6 (7.5ms) to 3200 (4000ms). + * @param latency Slave latency for the connection in number of connection events. Valid + * range is from 0 to 499 + * @param timeout Supervision timeout for this connection, in 10ms unit. Valid range is + * from 10 (0.1s) to 3200 (32s) + * @param status {@link BluetoothGatt#GATT_SUCCESS} if the connection has been updated + * successfully + * @hide + */ + public void onConnectionUpdated(BluetoothGatt gatt, int interval, int latency, int timeout, + int status) { + } } diff --git a/core/java/android/bluetooth/BluetoothGattServer.java b/core/java/android/bluetooth/BluetoothGattServer.java index 1bd7bd4dc6f3..c991e2f71bb8 100644 --- a/core/java/android/bluetooth/BluetoothGattServer.java +++ b/core/java/android/bluetooth/BluetoothGattServer.java @@ -65,6 +65,7 @@ public final class BluetoothGattServer implements BluetoothProfile { * Application interface registered - app is ready to go * @hide */ + @Override public void onServerRegistered(int status, int serverIf) { if (DBG) Log.d(TAG, "onServerRegistered() - status=" + status + " serverIf=" + serverIf); @@ -80,18 +81,10 @@ public final class BluetoothGattServer implements BluetoothProfile { } /** - * Callback reporting an LE scan result. - * @hide - */ - public void onScanResult(String address, int rssi, byte[] advData) { - if (VDBG) Log.d(TAG, "onScanResult() - Device=" + address + " RSSI=" +rssi); - // no op - } - - /** * Server connection state changed * @hide */ + @Override public void onServerConnectionState(int status, int serverIf, boolean connected, String address) { if (DBG) Log.d(TAG, "onServerConnectionState() - status=" + status @@ -109,6 +102,7 @@ public final class BluetoothGattServer implements BluetoothProfile { * Service has been added * @hide */ + @Override public void onServiceAdded(int status, BluetoothGattService service) { if (DBG) Log.d(TAG, "onServiceAdded() - handle=" + service.getInstanceId() + " uuid=" + service.getUuid() + " status=" + status); @@ -149,6 +143,7 @@ public final class BluetoothGattServer implements BluetoothProfile { * Remote client characteristic read request. * @hide */ + @Override public void onCharacteristicReadRequest(String address, int transId, int offset, boolean isLong, int handle) { if (VDBG) Log.d(TAG, "onCharacteristicReadRequest() - handle=" + handle); @@ -171,6 +166,7 @@ public final class BluetoothGattServer implements BluetoothProfile { * Remote client descriptor read request. * @hide */ + @Override public void onDescriptorReadRequest(String address, int transId, int offset, boolean isLong, int handle) { if (VDBG) Log.d(TAG, "onCharacteristicReadRequest() - handle=" + handle); @@ -193,6 +189,7 @@ public final class BluetoothGattServer implements BluetoothProfile { * Remote client characteristic write request. * @hide */ + @Override public void onCharacteristicWriteRequest(String address, int transId, int offset, int length, boolean isPrep, boolean needRsp, int handle, byte[] value) { @@ -218,6 +215,7 @@ public final class BluetoothGattServer implements BluetoothProfile { * Remote client descriptor write request. * @hide */ + @Override public void onDescriptorWriteRequest(String address, int transId, int offset, int length, boolean isPrep, boolean needRsp, int handle, byte[] value) { if (VDBG) Log.d(TAG, "onDescriptorWriteRequest() - handle=" + handle); @@ -241,6 +239,7 @@ public final class BluetoothGattServer implements BluetoothProfile { * Execute pending writes. * @hide */ + @Override public void onExecuteWrite(String address, int transId, boolean execWrite) { if (DBG) Log.d(TAG, "onExecuteWrite() - " @@ -261,6 +260,7 @@ public final class BluetoothGattServer implements BluetoothProfile { * A notification/indication has been sent. * @hide */ + @Override public void onNotificationSent(String address, int status) { if (VDBG) Log.d(TAG, "onNotificationSent() - " + "device=" + address + ", status=" + status); @@ -279,6 +279,7 @@ public final class BluetoothGattServer implements BluetoothProfile { * The MTU for a connection has changed * @hide */ + @Override public void onMtuChanged(String address, int mtu) { if (DBG) Log.d(TAG, "onMtuChanged() - " + "device=" + address + ", mtu=" + mtu); @@ -297,6 +298,7 @@ public final class BluetoothGattServer implements BluetoothProfile { * The PHY for a connection was updated * @hide */ + @Override public void onPhyUpdate(String address, int txPhy, int rxPhy, int status) { if (DBG) Log.d(TAG, "onPhyUpdate() - " + "device=" + address + ", txPHy=" + txPhy + ", rxPHy=" + rxPhy); @@ -315,6 +317,7 @@ public final class BluetoothGattServer implements BluetoothProfile { * The PHY for a connection was read * @hide */ + @Override public void onPhyRead(String address, int txPhy, int rxPhy, int status) { if (DBG) Log.d(TAG, "onPhyUpdate() - " + "device=" + address + ", txPHy=" + txPhy + ", rxPHy=" + rxPhy); @@ -328,6 +331,28 @@ public final class BluetoothGattServer implements BluetoothProfile { Log.w(TAG, "Unhandled exception: " + ex); } } + + /** + * Callback invoked when the given connection is updated + * @hide + */ + @Override + public void onConnectionUpdated(String address, int interval, int latency, + int timeout, int status) { + if (DBG) Log.d(TAG, "onConnectionUpdated() - Device=" + address + + " interval=" + interval + " latency=" + latency + + " timeout=" + timeout + " status=" + status); + BluetoothDevice device = mAdapter.getRemoteDevice(address); + if (device == null) return; + + try { + mCallback.onConnectionUpdated(device, interval, latency, + timeout, status); + } catch (Exception ex) { + Log.w(TAG, "Unhandled exception: " + ex); + } + } + }; /** diff --git a/core/java/android/bluetooth/BluetoothGattServerCallback.java b/core/java/android/bluetooth/BluetoothGattServerCallback.java index 0a890721de66..3b8f962bf73e 100644 --- a/core/java/android/bluetooth/BluetoothGattServerCallback.java +++ b/core/java/android/bluetooth/BluetoothGattServerCallback.java @@ -184,4 +184,23 @@ public abstract class BluetoothGattServerCallback { */ public void onPhyRead(BluetoothDevice device, int txPhy, int rxPhy, int status) { } + + /** + * Callback indicating the connection parameters were updated. + * + * @param device The remote device involved + * @param interval Connection interval used on this connection, 1.25ms unit. Valid + * range is from 6 (7.5ms) to 3200 (4000ms). + * @param latency Slave latency for the connection in number of connection events. Valid + * range is from 0 to 499 + * @param timeout Supervision timeout for this connection, in 10ms unit. Valid range is + * from 10 (0.1s) to 3200 (32s) + * @param status {@link BluetoothGatt#GATT_SUCCESS} if the connection has been updated + * successfully + * @hide + */ + public void onConnectionUpdated(BluetoothDevice gatt, int interval, int latency, int timeout, + int status) { + } + } diff --git a/core/java/android/bluetooth/IBluetoothGattCallbackExt.aidl b/core/java/android/bluetooth/IBluetoothGattCallbackExt.aidl index 736f4b2b048f..ed69e54671ca 100644 --- a/core/java/android/bluetooth/IBluetoothGattCallbackExt.aidl +++ b/core/java/android/bluetooth/IBluetoothGattCallbackExt.aidl @@ -37,4 +37,6 @@ oneway interface IBluetoothGattCallbackExt { void onNotify(in String address, in int handle, in byte[] value); void onReadRemoteRssi(in String address, in int rssi, in int status); void onConfigureMTU(in String address, in int mtu, in int status); + void onConnectionUpdated(in String address, in int interval, in int latency, + in int timeout, in int status); } diff --git a/core/java/android/bluetooth/IBluetoothGattServerCallbackExt.aidl b/core/java/android/bluetooth/IBluetoothGattServerCallbackExt.aidl index 091ffb3fe987..267e8824439d 100644 --- a/core/java/android/bluetooth/IBluetoothGattServerCallbackExt.aidl +++ b/core/java/android/bluetooth/IBluetoothGattServerCallbackExt.aidl @@ -42,4 +42,6 @@ oneway interface IBluetoothGattServerCallbackExt { void onMtuChanged(in String address, in int mtu); void onPhyUpdate(in String address, in int txPhy, in int rxPhy, in int status); void onPhyRead(in String address, in int txPhy, in int rxPhy, in int status); + void onConnectionUpdated(in String address, in int interval, in int latency, + in int timeout, in int status); } |