Loading framework/java/android/bluetooth/BluetoothAdapter.java +18 −0 Original line number Diff line number Diff line Loading @@ -994,6 +994,24 @@ public final class BluetoothAdapter { return false; } /** * Return true if hardware has entries available for matching beacons * * @return true if there are hw entries available for matching beacons * @hide */ public boolean isHardwareTrackingFiltersAvailable() { if (getState() != STATE_ON) return false; try { synchronized(mManagerCallback) { if(mService != null) return (mService.numOfHwTrackFiltersAvailable() != 0); } } catch (RemoteException e) { Log.e(TAG, "", e); } return false; } /** * Return the record of {@link BluetoothActivityEnergyInfo} object that * has the activity and energy info. This can be used to ascertain what Loading framework/java/android/bluetooth/IBluetooth.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,7 @@ interface IBluetooth boolean isActivityAndEnergyReportingSupported(); void getActivityEnergyInfoFromController(); BluetoothActivityEnergyInfo reportActivityInfo(); int numOfHwTrackFiltersAvailable(); // for dumpsys support String dump(); Loading framework/java/android/bluetooth/le/BluetoothLeScanner.java +39 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,16 @@ public final class BluetoothLeScanner { ScanCallback.SCAN_FAILED_FEATURE_UNSUPPORTED); return; } if (!isHardwareResourcesAvailableForScan(settings)) { postCallbackError(callback, ScanCallback.SCAN_FAILED_OUT_OF_HARDWARE_RESOURCES); return; } if (!isSettingsAndFilterComboAllowed(settings, filters)) { postCallbackError(callback, ScanCallback.SCAN_FAILED_FEATURE_UNSUPPORTED); return; } BleScanCallbackWrapper wrapper = new BleScanCallbackWrapper(gatt, filters, settings, callback, resultStorages); wrapper.startRegisteration(); Loading Loading @@ -394,4 +404,33 @@ public final class BluetoothLeScanner { } return false; } private boolean isSettingsAndFilterComboAllowed(ScanSettings settings, List <ScanFilter> filterList) { final int callbackType = settings.getCallbackType(); // If onlost/onfound is requested, a non-empty filter is expected if ((callbackType & ScanSettings.CALLBACK_TYPE_FIRST_MATCH | ScanSettings.CALLBACK_TYPE_MATCH_LOST) != 0) { if (filterList == null) { return false; } for (ScanFilter filter : filterList) { if (filter.isAllFieldsEmpty()) { return false; } } } return true; } private boolean isHardwareResourcesAvailableForScan(ScanSettings settings) { final int callbackType = settings.getCallbackType(); if ((callbackType & ScanSettings.CALLBACK_TYPE_FIRST_MATCH) != 0 || (callbackType & ScanSettings.CALLBACK_TYPE_MATCH_LOST) != 0) { // For onlost/onfound, we required hw support be available return (mBluetoothAdapter.isOffloadedFilteringSupported() && mBluetoothAdapter.isHardwareTrackingFiltersAvailable()); } return true; } } framework/java/android/bluetooth/le/ScanCallback.java +8 −2 Original line number Diff line number Diff line Loading @@ -44,11 +44,17 @@ public abstract class ScanCallback { */ public static final int SCAN_FAILED_FEATURE_UNSUPPORTED = 4; /** * Fails to start scan as it is out of hardware resources. * @hide */ public static final int SCAN_FAILED_OUT_OF_HARDWARE_RESOURCES = 5; /** * Callback when a BLE advertisement has been found. * * @param callbackType Determines how this callback was triggered. Currently could only be * {@link ScanSettings#CALLBACK_TYPE_ALL_MATCHES}. * @param callbackType Determines how this callback was triggered. Could be of * {@link ScanSettings#CALLBACK_TYPE_ALL_MATCHES} * @param result A Bluetooth LE scan result. */ public void onScanResult(int callbackType, ScanResult result) { Loading framework/java/android/bluetooth/le/ScanFilter.java +10 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,8 @@ public final class ScanFilter implements Parcelable { private final byte[] mManufacturerData; @Nullable private final byte[] mManufacturerDataMask; private static final ScanFilter EMPTY = new ScanFilter.Builder().build() ; private ScanFilter(String name, String deviceAddress, ParcelUuid uuid, ParcelUuid uuidMask, ParcelUuid serviceDataUuid, Loading Loading @@ -409,6 +411,14 @@ public final class ScanFilter implements Parcelable { Objects.equals(mServiceUuidMask, other.mServiceUuidMask); } /** * Checks if the scanfilter is empty * @hide */ public boolean isAllFieldsEmpty() { return EMPTY.equals(this); } /** * Builder class for {@link ScanFilter}. */ Loading Loading
framework/java/android/bluetooth/BluetoothAdapter.java +18 −0 Original line number Diff line number Diff line Loading @@ -994,6 +994,24 @@ public final class BluetoothAdapter { return false; } /** * Return true if hardware has entries available for matching beacons * * @return true if there are hw entries available for matching beacons * @hide */ public boolean isHardwareTrackingFiltersAvailable() { if (getState() != STATE_ON) return false; try { synchronized(mManagerCallback) { if(mService != null) return (mService.numOfHwTrackFiltersAvailable() != 0); } } catch (RemoteException e) { Log.e(TAG, "", e); } return false; } /** * Return the record of {@link BluetoothActivityEnergyInfo} object that * has the activity and energy info. This can be used to ascertain what Loading
framework/java/android/bluetooth/IBluetooth.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,7 @@ interface IBluetooth boolean isActivityAndEnergyReportingSupported(); void getActivityEnergyInfoFromController(); BluetoothActivityEnergyInfo reportActivityInfo(); int numOfHwTrackFiltersAvailable(); // for dumpsys support String dump(); Loading
framework/java/android/bluetooth/le/BluetoothLeScanner.java +39 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,16 @@ public final class BluetoothLeScanner { ScanCallback.SCAN_FAILED_FEATURE_UNSUPPORTED); return; } if (!isHardwareResourcesAvailableForScan(settings)) { postCallbackError(callback, ScanCallback.SCAN_FAILED_OUT_OF_HARDWARE_RESOURCES); return; } if (!isSettingsAndFilterComboAllowed(settings, filters)) { postCallbackError(callback, ScanCallback.SCAN_FAILED_FEATURE_UNSUPPORTED); return; } BleScanCallbackWrapper wrapper = new BleScanCallbackWrapper(gatt, filters, settings, callback, resultStorages); wrapper.startRegisteration(); Loading Loading @@ -394,4 +404,33 @@ public final class BluetoothLeScanner { } return false; } private boolean isSettingsAndFilterComboAllowed(ScanSettings settings, List <ScanFilter> filterList) { final int callbackType = settings.getCallbackType(); // If onlost/onfound is requested, a non-empty filter is expected if ((callbackType & ScanSettings.CALLBACK_TYPE_FIRST_MATCH | ScanSettings.CALLBACK_TYPE_MATCH_LOST) != 0) { if (filterList == null) { return false; } for (ScanFilter filter : filterList) { if (filter.isAllFieldsEmpty()) { return false; } } } return true; } private boolean isHardwareResourcesAvailableForScan(ScanSettings settings) { final int callbackType = settings.getCallbackType(); if ((callbackType & ScanSettings.CALLBACK_TYPE_FIRST_MATCH) != 0 || (callbackType & ScanSettings.CALLBACK_TYPE_MATCH_LOST) != 0) { // For onlost/onfound, we required hw support be available return (mBluetoothAdapter.isOffloadedFilteringSupported() && mBluetoothAdapter.isHardwareTrackingFiltersAvailable()); } return true; } }
framework/java/android/bluetooth/le/ScanCallback.java +8 −2 Original line number Diff line number Diff line Loading @@ -44,11 +44,17 @@ public abstract class ScanCallback { */ public static final int SCAN_FAILED_FEATURE_UNSUPPORTED = 4; /** * Fails to start scan as it is out of hardware resources. * @hide */ public static final int SCAN_FAILED_OUT_OF_HARDWARE_RESOURCES = 5; /** * Callback when a BLE advertisement has been found. * * @param callbackType Determines how this callback was triggered. Currently could only be * {@link ScanSettings#CALLBACK_TYPE_ALL_MATCHES}. * @param callbackType Determines how this callback was triggered. Could be of * {@link ScanSettings#CALLBACK_TYPE_ALL_MATCHES} * @param result A Bluetooth LE scan result. */ public void onScanResult(int callbackType, ScanResult result) { Loading
framework/java/android/bluetooth/le/ScanFilter.java +10 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,8 @@ public final class ScanFilter implements Parcelable { private final byte[] mManufacturerData; @Nullable private final byte[] mManufacturerDataMask; private static final ScanFilter EMPTY = new ScanFilter.Builder().build() ; private ScanFilter(String name, String deviceAddress, ParcelUuid uuid, ParcelUuid uuidMask, ParcelUuid serviceDataUuid, Loading Loading @@ -409,6 +411,14 @@ public final class ScanFilter implements Parcelable { Objects.equals(mServiceUuidMask, other.mServiceUuidMask); } /** * Checks if the scanfilter is empty * @hide */ public boolean isAllFieldsEmpty() { return EMPTY.equals(this); } /** * Builder class for {@link ScanFilter}. */ Loading