Merge "Add support of advertising through standard instance.(1/4)" into lmp-sprout-dev

This commit is contained in:
Wei Wang
2014-10-13 23:02:29 +00:00
committed by Android (Google) Code Review
3 changed files with 20 additions and 2 deletions

View File

@@ -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) {
@@ -916,6 +917,21 @@ public final class BluetoothAdapter {
return false;
}
/**
* 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
*

View File

@@ -92,6 +92,7 @@ interface IBluetooth
boolean configHciSnoopLog(boolean enable);
boolean isMultiAdvertisementSupported();
boolean isPeripheralModeSupported();
boolean isOffloadedFilteringSupported();
boolean isOffloadedScanBatchingSupported();
boolean isActivityAndEnergyReportingSupported();

View File

@@ -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;