Merge "Add support of advertising through standard instance.(1/4)" into lmp-sprout-dev
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index f0b609a..210bbdf 100644
--- a/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/core/java/android/bluetooth/BluetoothAdapter.java
@@ -464,7 +464,8 @@
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 @@
}
/**
+ * 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 cf2a343..992f601 100644
--- a/core/java/android/bluetooth/IBluetooth.aidl
+++ b/core/java/android/bluetooth/IBluetooth.aidl
@@ -92,6 +92,7 @@
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 d468508..a019d5c 100644
--- a/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java
+++ b/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java
@@ -111,7 +111,8 @@
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;