diff options
| author | Jakub Pawlowski <jpawlowski@google.com> | 2017-04-19 21:44:50 +0000 |
|---|---|---|
| committer | android-build-merger <android-build-merger@google.com> | 2017-04-19 21:44:50 +0000 |
| commit | f3732e2fe23a39434e07f365dcd64311d0a3637f (patch) | |
| tree | 7a8985286e85724ac375917ee7ab6821ed00395e /core/java | |
| parent | 86c579678ee614cf3dd744b42bbd46c772688f46 (diff) | |
| parent | fc99848b964eab556f25fd5e15cbabea30e764a6 (diff) | |
Merge "Expose LE advertiser address for easier PTS tests (1/6)" am: f2e6988350
am: fc99848b96
Change-Id: Ie3ded1b0237b56bb4c81ad7a51c50b82267bc536
Diffstat (limited to 'core/java')
5 files changed, 41 insertions, 1 deletions
diff --git a/core/java/android/bluetooth/IBluetoothGatt.aidl b/core/java/android/bluetooth/IBluetoothGatt.aidl index 38ba9adafe68..a2066cb4991e 100644 --- a/core/java/android/bluetooth/IBluetoothGatt.aidl +++ b/core/java/android/bluetooth/IBluetoothGatt.aidl @@ -56,6 +56,7 @@ interface IBluetoothGatt { in IAdvertisingSetCallback callback); void stopAdvertisingSet(in IAdvertisingSetCallback callback); + void getOwnAddress(in int advertiserId); void enableAdvertisingSet(in int advertiserId, in boolean enable, in int duration, in int maxExtAdvEvents); void setAdvertisingData(in int advertiserId, in AdvertiseData data); void setScanResponseData(in int advertiserId, in AdvertiseData data); diff --git a/core/java/android/bluetooth/le/AdvertisingSet.java b/core/java/android/bluetooth/le/AdvertisingSet.java index 51571b2746a4..3021be1f8c02 100644 --- a/core/java/android/bluetooth/le/AdvertisingSet.java +++ b/core/java/android/bluetooth/le/AdvertisingSet.java @@ -181,7 +181,23 @@ public final class AdvertisingSet { } /** - * Returns advertiserId associated with thsi advertising set. + * Returns address associated with this advertising set. + * This method is exposed only for Bluetooth PTS tests, no app or system service + * should ever use it. + * + * This method requires {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED} permission. + * @hide + */ + public void getOwnAddress(){ + try { + gatt.getOwnAddress(this.advertiserId); + } catch (RemoteException e) { + Log.e(TAG, "remote exception - ", e); + } + } + + /** + * Returns advertiserId associated with this advertising set. * * @hide */ diff --git a/core/java/android/bluetooth/le/AdvertisingSetCallback.java b/core/java/android/bluetooth/le/AdvertisingSetCallback.java index fe3b1cdd63a0..2c46e856db4a 100644 --- a/core/java/android/bluetooth/le/AdvertisingSetCallback.java +++ b/core/java/android/bluetooth/le/AdvertisingSetCallback.java @@ -143,4 +143,15 @@ public abstract class AdvertisingSetCallback { */ public void onPeriodicAdvertisingEnabled(AdvertisingSet advertisingSet, boolean enable, int status) {} + + /** + * Callback triggered in response to {@link AdvertisingSet#getOwnAddress()} + * indicating result of the operation. + * + * @param advertisingSet The advertising set. + * @param addressType type of address. + * @param address advertising set bluetooth address. + * @hide + */ + public void onOwnAddressRead(AdvertisingSet advertisingSet, int addressType, String address) {} }
\ No newline at end of file diff --git a/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java b/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java index ea3031b20177..21e9497daa62 100644 --- a/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java +++ b/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java @@ -545,6 +545,17 @@ public final class BluetoothLeAdvertiser { } @Override + public void onOwnAddressRead(int advertiserId, int addressType, String address) { + handler.post(new Runnable() { + @Override + public void run() { + AdvertisingSet advertisingSet = mAdvertisingSets.get(advertiserId); + callback.onOwnAddressRead(advertisingSet, addressType, address); + } + }); + } + + @Override public void onAdvertisingSetStopped(int advertiserId) { handler.post(new Runnable() { @Override diff --git a/core/java/android/bluetooth/le/IAdvertisingSetCallback.aidl b/core/java/android/bluetooth/le/IAdvertisingSetCallback.aidl index 2c9f4baad520..3628c775b798 100644 --- a/core/java/android/bluetooth/le/IAdvertisingSetCallback.aidl +++ b/core/java/android/bluetooth/le/IAdvertisingSetCallback.aidl @@ -21,6 +21,7 @@ package android.bluetooth.le; */ oneway interface IAdvertisingSetCallback { void onAdvertisingSetStarted(in int advertiserId, in int tx_power, in int status); + void onOwnAddressRead(in int advertiserId, in int addressType, in String address); void onAdvertisingSetStopped(in int advertiserId); void onAdvertisingEnabled(in int advertiserId, in boolean enable, in int status); void onAdvertisingDataSet(in int advertiserId, in int status); |
