From 48091bbd78f6c747be5e33d78911a14f83af0a92 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowski Date: Tue, 7 Feb 2017 18:05:39 -0800 Subject: [PATCH] Bluetooth 5 feature check API (1/2) Bug: 30622771 Test: manual Change-Id: I90e2efe989745c07c2f2fb8f4ea5bc3b718382f6 (cherry picked from commit 79d66495c32996a5b532328571bf6ceecca70ca5) --- api/current.txt | 4 ++ api/system-current.txt | 4 ++ api/test-current.txt | 4 ++ .../android/bluetooth/BluetoothAdapter.java | 72 +++++++++++++++++++ core/java/android/bluetooth/IBluetooth.aidl | 4 ++ 5 files changed, 88 insertions(+) diff --git a/api/current.txt b/api/current.txt index fc92768e5735d..ac91a0a7281d1 100644 --- a/api/current.txt +++ b/api/current.txt @@ -6703,6 +6703,10 @@ package android.bluetooth { method public int getState(); method public boolean isDiscovering(); method public boolean isEnabled(); + method public boolean isLe2MPhySupported(); + method public boolean isLeCodedPhySupported(); + method public boolean isLeExtendedAdvertisingSupported(); + method public boolean isLePeriodicAdvertisingSupported(); method public boolean isMultipleAdvertisementSupported(); method public boolean isOffloadedFilteringSupported(); method public boolean isOffloadedScanBatchingSupported(); diff --git a/api/system-current.txt b/api/system-current.txt index 919775b60e6d4..c122fcccddb9a 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -7002,7 +7002,11 @@ package android.bluetooth { method public boolean isBleScanAlwaysAvailable(); method public boolean isDiscovering(); method public boolean isEnabled(); + method public boolean isLe2MPhySupported(); + method public boolean isLeCodedPhySupported(); method public boolean isLeEnabled(); + method public boolean isLeExtendedAdvertisingSupported(); + method public boolean isLePeriodicAdvertisingSupported(); method public boolean isMultipleAdvertisementSupported(); method public boolean isOffloadedFilteringSupported(); method public boolean isOffloadedScanBatchingSupported(); diff --git a/api/test-current.txt b/api/test-current.txt index 568baa7cf575e..03374bd5382a5 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -6712,6 +6712,10 @@ package android.bluetooth { method public int getState(); method public boolean isDiscovering(); method public boolean isEnabled(); + method public boolean isLe2MPhySupported(); + method public boolean isLeCodedPhySupported(); + method public boolean isLeExtendedAdvertisingSupported(); + method public boolean isLePeriodicAdvertisingSupported(); method public boolean isMultipleAdvertisementSupported(); method public boolean isOffloadedFilteringSupported(); method public boolean isOffloadedScanBatchingSupported(); diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index dbc25afcd08fb..4ecf1249d18c4 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/java/android/bluetooth/BluetoothAdapter.java @@ -1384,6 +1384,78 @@ public final class BluetoothAdapter { return false; } + /** + * Return true if LE 2M PHY feature is supported. + * + * @return true if chipset supports LE 2M PHY feature + */ + public boolean isLe2MPhySupported() { + if (!getLeAccess()) return false; + try { + mServiceLock.readLock().lock(); + if (mService != null) return mService.isLe2MPhySupported(); + } catch (RemoteException e) { + Log.e(TAG, "failed to get isExtendedAdvertisingSupported, error: ", e); + } finally { + mServiceLock.readLock().unlock(); + } + return false; + } + + /** + * Return true if LE Coded PHY feature is supported. + * + * @return true if chipset supports LE Coded PHY feature + */ + public boolean isLeCodedPhySupported() { + if (!getLeAccess()) return false; + try { + mServiceLock.readLock().lock(); + if (mService != null) return mService.isLeCodedPhySupported(); + } catch (RemoteException e) { + Log.e(TAG, "failed to get isLeCodedPhySupported, error: ", e); + } finally { + mServiceLock.readLock().unlock(); + } + return false; + } + + /** + * Return true if LE Periodic Advertising feature is supported. + * + * @return true if chipset supports LE Periodic Advertising feature + */ + public boolean isLeExtendedAdvertisingSupported() { + if (!getLeAccess()) return false; + try { + mServiceLock.readLock().lock(); + if (mService != null) return mService.isLeExtendedAdvertisingSupported(); + } catch (RemoteException e) { + Log.e(TAG, "failed to get isLeExtendedAdvertisingSupported, error: ", e); + } finally { + mServiceLock.readLock().unlock(); + } + return false; + } + + /** + * Return true if LE Periodic Advertising feature is supported. + * + * @return true if chipset supports LE Periodic Advertising feature + */ + public boolean isLePeriodicAdvertisingSupported() { + if (!getLeAccess()) return false; + try { + mServiceLock.readLock().lock(); + if (mService != null) return mService.isLePeriodicAdvertisingSupported(); + } catch (RemoteException e) { + Log.e(TAG, "failed to get isLePeriodicAdvertisingSupported, error: ", e); + } finally { + mServiceLock.readLock().unlock(); + } + return false; + } + /** * Return true if hardware has entries available for matching beacons * diff --git a/core/java/android/bluetooth/IBluetooth.aidl b/core/java/android/bluetooth/IBluetooth.aidl index 53fef2add3447..76ca554e5984b 100644 --- a/core/java/android/bluetooth/IBluetooth.aidl +++ b/core/java/android/bluetooth/IBluetooth.aidl @@ -104,6 +104,10 @@ interface IBluetooth boolean isOffloadedFilteringSupported(); boolean isOffloadedScanBatchingSupported(); boolean isActivityAndEnergyReportingSupported(); + boolean isLe2MPhySupported(); + boolean isLeCodedPhySupported(); + boolean isLeExtendedAdvertisingSupported(); + boolean isLePeriodicAdvertisingSupported(); BluetoothActivityEnergyInfo reportActivityInfo(); /**