diff options
| author | HsingYuan Lo <hylo@google.com> | 2020-09-25 06:19:51 +0000 |
|---|---|---|
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-09-25 06:19:51 +0000 |
| commit | b784e06bb00c6e4871874930ead903d20ef50d80 (patch) | |
| tree | c683a4003cdc7dbf6088acb9862d024f56d36180 /core/java/android/bluetooth | |
| parent | c871472fb804a0aaa05a0bc6fff05a71364893d2 (diff) | |
| parent | 0e73bae3af545d3d88258d05315e052608bc1a24 (diff) | |
Merge "Expose service changed event to application (2/3)" am: 199d2c7384 am: 90fd6a303f am: b9fadf6916 am: 0e73bae3af
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1433925
Change-Id: If6b1bd5ee1e3719c1f803ad06eb5e5fa931398df
Diffstat (limited to 'core/java/android/bluetooth')
| -rw-r--r-- | core/java/android/bluetooth/BluetoothGatt.java | 25 | ||||
| -rw-r--r-- | core/java/android/bluetooth/BluetoothGattCallback.java | 13 |
2 files changed, 38 insertions, 0 deletions
diff --git a/core/java/android/bluetooth/BluetoothGatt.java b/core/java/android/bluetooth/BluetoothGatt.java index c58b5d218e74..6d22eb93fd02 100644 --- a/core/java/android/bluetooth/BluetoothGatt.java +++ b/core/java/android/bluetooth/BluetoothGatt.java @@ -688,6 +688,31 @@ public final class BluetoothGatt implements BluetoothProfile { } }); } + + /** + * Callback invoked when service changed event is received + * @hide + */ + @Override + public void onServiceChanged(String address) { + if (DBG) { + Log.d(TAG, "onServiceChanged() - Device=" + address); + } + + if (!address.equals(mDevice.getAddress())) { + return; + } + + runOrQueueCallback(new Runnable() { + @Override + public void run() { + final BluetoothGattCallback callback = mCallback; + if (callback != null) { + callback.onServiceChanged(BluetoothGatt.this); + } + } + }); + } }; /*package*/ BluetoothGatt(IBluetoothGatt iGatt, BluetoothDevice device, diff --git a/core/java/android/bluetooth/BluetoothGattCallback.java b/core/java/android/bluetooth/BluetoothGattCallback.java index f718c0b57c1b..9f6b8287e791 100644 --- a/core/java/android/bluetooth/BluetoothGattCallback.java +++ b/core/java/android/bluetooth/BluetoothGattCallback.java @@ -194,4 +194,17 @@ public abstract class BluetoothGattCallback { public void onConnectionUpdated(BluetoothGatt gatt, int interval, int latency, int timeout, int status) { } + + /** + * Callback indicating service changed event is received + * + * <p>Receiving this event means that the GATT database is out of sync with + * the remote device. {@link BluetoothGatt#discoverServices} should be + * called to re-discover the services. + * + * @param gatt GATT client involved + * @hide + */ + public void onServiceChanged(BluetoothGatt gatt) { + } } |
