diff options
| author | Jakub Pawlowski <jpawlowski@google.com> | 2017-03-08 19:14:22 +0000 |
|---|---|---|
| committer | android-build-merger <android-build-merger@google.com> | 2017-03-08 19:14:22 +0000 |
| commit | a46cc490a9916848c8d20a677f9230efc6b54ca4 (patch) | |
| tree | afa2fc414436b6d15e719a44cd2e84f485869ecb /framework/java/android/bluetooth/BluetoothAdapter.java | |
| parent | ca0238aa32d7d8c29396f336afc33d94e102f580 (diff) | |
| parent | e3bcff433b51945f6e3033a4e0f1a1c05ad68855 (diff) | |
Merge "Bluetooth 5 periodc scan API (1/2)"
am: e3bcff433b
Change-Id: I7b68746e3dc02a12d13380a90bcf26cebfd31f16
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 c403487e60..d36692a74a 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() { |
