diff options
| -rw-r--r-- | core/java/android/bluetooth/BluetoothAdapter.java | 18 | ||||
| -rw-r--r-- | core/java/android/bluetooth/IBluetooth.aidl | 1 | ||||
| -rw-r--r-- | core/java/android/bluetooth/le/BluetoothLeAdvertiser.java | 3 |
3 files changed, 20 insertions, 2 deletions
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index f0b609aec1ea..210bbdf05486 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/java/android/bluetooth/BluetoothAdapter.java @@ -464,7 +464,8 @@ public final class BluetoothAdapter { if (getState() != STATE_ON) { return null; } - if (!isMultipleAdvertisementSupported()) { + if (!isMultipleAdvertisementSupported() && !isPeripheralModeSupported()) { + Log.e(TAG, "bluetooth le advertising not supported"); return null; } synchronized(mLock) { @@ -917,6 +918,21 @@ public final class BluetoothAdapter { } /** + * Returns whether peripheral mode is supported. + * + * @hide + */ + public boolean isPeripheralModeSupported() { + if (getState() != STATE_ON) return false; + try { + return mService.isPeripheralModeSupported(); + } catch (RemoteException e) { + Log.e(TAG, "failed to get peripheral mode capability: ", e); + } + return false; + } + + /** * Return true if offloaded filters are supported * * @return true if chipset supports on-chip filtering diff --git a/core/java/android/bluetooth/IBluetooth.aidl b/core/java/android/bluetooth/IBluetooth.aidl index cf2a343dc047..992f601a20db 100644 --- a/core/java/android/bluetooth/IBluetooth.aidl +++ b/core/java/android/bluetooth/IBluetooth.aidl @@ -92,6 +92,7 @@ interface IBluetooth boolean configHciSnoopLog(boolean enable); boolean isMultiAdvertisementSupported(); + boolean isPeripheralModeSupported(); boolean isOffloadedFilteringSupported(); boolean isOffloadedScanBatchingSupported(); boolean isActivityAndEnergyReportingSupported(); diff --git a/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java b/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java index d46850843f6a..a019d5cff2a1 100644 --- a/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java +++ b/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java @@ -111,7 +111,8 @@ public final class BluetoothLeAdvertiser { if (callback == null) { throw new IllegalArgumentException("callback cannot be null"); } - if (!mBluetoothAdapter.isMultipleAdvertisementSupported()) { + if (!mBluetoothAdapter.isMultipleAdvertisementSupported() && + !mBluetoothAdapter.isPeripheralModeSupported()) { postStartFailure(callback, AdvertiseCallback.ADVERTISE_FAILED_FEATURE_UNSUPPORTED); return; |