diff options
author | Wei Wang <weiwa@google.com> | 2014-09-25 19:05:03 -0700 |
---|---|---|
committer | Wei Wang <weiwa@google.com> | 2014-10-09 18:01:39 +0000 |
commit | 35cd4c853f748e295352bda708b26ee39544d06d (patch) | |
tree | ec2c2221ef87f8a4b14fcc287bf7621547298aa8 /core/java/android/bluetooth | |
parent | f91222327e71edccb5b5d34fde61abc54f580fab (diff) | |
download | frameworks_base-35cd4c853f748e295352bda708b26ee39544d06d.zip frameworks_base-35cd4c853f748e295352bda708b26ee39544d06d.tar.gz frameworks_base-35cd4c853f748e295352bda708b26ee39544d06d.tar.bz2 |
Add support of advertising through standard instance.(1/4)
Use config overlay to check whether peripheral mode is supported.
Bug: 17552672
Change-Id: I1081bc84da9fe033426f82ece2ec74c2d663e3aa
Diffstat (limited to 'core/java/android/bluetooth')
-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 f0b609a..210bbdf 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 cf2a343..992f601 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 d468508..a019d5c 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; |