diff options
| author | Jakub Pawlowski <jpawlowski@google.com> | 2017-01-16 07:21:01 -0800 |
|---|---|---|
| committer | Jakub Pawlowski <jpawlowski@google.com> | 2017-03-08 19:03:12 +0000 |
| commit | b74a8cd801d63b94c1770299f02bcb1de5b3b8ea (patch) | |
| tree | 8745214eb8b29f5616250fb0414acbaafe6161b0 /framework/java/android/bluetooth/BluetoothAdapter.java | |
| parent | dfeded5a05d2634c5b8984669b3bb2608f7eb1d3 (diff) | |
Bluetooth 5 periodc scan API (1/2)
Bug: 30622771
Test: manual
Change-Id: I61853bc71f6013e9406d1d151bb51ea4484bb92c
(cherry picked from commit a48e03745becc96181c676dc3d194d0572f11c10)
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothAdapter.java')
| -rw-r--r-- | framework/java/android/bluetooth/BluetoothAdapter.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothAdapter.java b/framework/java/android/bluetooth/BluetoothAdapter.java index 4ecf1249d1..818693773a 100644 --- a/framework/java/android/bluetooth/BluetoothAdapter.java +++ b/framework/java/android/bluetooth/BluetoothAdapter.java @@ -26,6 +26,7 @@ import android.annotation.SystemApi; import android.app.ActivityThread; import android.bluetooth.le.BluetoothLeAdvertiser; import android.bluetooth.le.BluetoothLeScanner; +import android.bluetooth.le.PeriodicAdvertisingManager; import android.bluetooth.le.ScanCallback; import android.bluetooth.le.ScanFilter; import android.bluetooth.le.ScanRecord; @@ -525,6 +526,7 @@ public final class BluetoothAdapter { private static BluetoothLeScanner sBluetoothLeScanner; private static BluetoothLeAdvertiser sBluetoothLeAdvertiser; + private static PeriodicAdvertisingManager sPeriodicAdvertisingManager; private final IBluetoothManager mManagerService; private IBluetooth mService; @@ -630,6 +632,30 @@ public final class BluetoothAdapter { } /** + * Returns a {@link PeriodicAdvertisingManager} object for Bluetooth LE Periodic Advertising + * operations. Will return null if Bluetooth is turned off or if Bluetooth LE Periodic + * Advertising is not supported on this device. + * <p> + * Use {@link #isLePeriodicAdvertisingSupported()} to check whether LE Periodic Advertising is + * supported on this device before calling this method. + */ + public PeriodicAdvertisingManager getPeriodicAdvertisingManager() { + if (!getLeAccess()) + return null; + + if (!isLePeriodicAdvertisingSupported()) + return null; + + synchronized (mLock) { + if (sPeriodicAdvertisingManager == null) { + sPeriodicAdvertisingManager = + new PeriodicAdvertisingManager(mManagerService); + } + } + return sPeriodicAdvertisingManager; + } + + /** * Returns a {@link BluetoothLeScanner} object for Bluetooth LE scan operations. */ public BluetoothLeScanner getBluetoothLeScanner() { |
