public abstract class BluetoothLeScannerCompat
extends java.lang.Object
Build.VERSION_CODES.JELLY_BEAN_MR2
and later.Modifier and Type | Field and Description |
---|---|
protected long |
scanLostOverrideMillis |
Constructor and Description |
---|
BluetoothLeScannerCompat() |
Modifier and Type | Method and Description |
---|---|
protected abstract android.app.PendingIntent |
getAlarmIntent() |
protected abstract android.app.AlarmManager |
getAlarmManager() |
protected abstract Clock |
getClock() |
protected abstract int |
getMaxPriorityScanMode() |
protected abstract boolean |
hasClients() |
protected abstract void |
onNewScanCycle() |
void |
setCustomScanTiming(int scanMillis,
int idleMillis,
long serialScanDurationMillis)
Sets the Bluetooth LE scan cycle overriding values set on individual scans from
ScanSettings . |
void |
setScanLostOverride(long lostOverrideMillis)
Sets the delay after which a device will be marked as lost if it hasn't been sighted
within the given time.
|
protected void |
setScanMode(int scanMode)
Sets parameters for the various scan modes
|
abstract boolean |
startScan(java.util.List<ScanFilter> filters,
ScanSettings settings,
ScanCallback callback)
Starts a scan for Bluetooth LE devices, looking for device advertisements that match the
given filters.
|
void |
startScan(ScanCallback callback)
Start Bluetooth LE scan with default parameters and no filters.
|
abstract void |
stopScan(ScanCallback callback)
Stops an ongoing Bluetooth LE device scan.
|
protected void |
updateRepeatingAlarm()
Update the repeating alarm wake-up based on the period defined for the scanner If there are
no clients, or a batch scan running, it will cancel the alarm.
|
public void startScan(ScanCallback callback)
callback
.
Requires Manifest.permission.BLUETOOTH_ADMIN
permission.callback
- Callback used to deliver scan results.java.lang.IllegalArgumentException
- If callback
is null.public abstract boolean startScan(java.util.List<ScanFilter> filters, ScanSettings settings, ScanCallback callback)
false
.
Due to the resource limitations in BLE chipset, an app cannot add more than N(real number
TBD) filters.
Once the controller storage reaches its limitation on scan filters, the framework will try to
merge the existing scan filters and set the merged filters to chipset. The framework will
need to keep a copy of the original scan filters to make sure each app gets only its desired
results.
The callback will be invoked when LE scan finds a matching BLE advertising packet. A BLE
advertising record is considered matching the filters if it matches any of the
BluetoothLeScanFilter in the list.
Results of the scan are reported using the onResult(Listpublic abstract void stopScan(ScanCallback callback)
callback
- public void setCustomScanTiming(int scanMillis, int idleMillis, long serialScanDurationMillis)
ScanSettings
.
This is an extension of the "L" Platform API.
scanMillis
- duration in milliseconds for the scan to be active, or -1 to remove, 0 to
pause. Ignored by hardware and truncated batch scanners.idleMillis
- duration in milliseconds for the scan to be idle. Ignored by hardware
and truncated batch scanners.serialScanDurationMillis
- duration in milliseconds of the on-demand serial scan
launched opportunistically by the truncated batch mode scanner. Ignored by
non-truncated scanners.public void setScanLostOverride(long lostOverrideMillis)
protected void updateRepeatingAlarm()
protected void setScanMode(int scanMode)
scanMode
- the ScanMode in BluetoothLeScanner Settingsprotected abstract Clock getClock()
protected abstract int getMaxPriorityScanMode()
protected abstract boolean hasClients()
protected abstract android.app.AlarmManager getAlarmManager()
protected abstract android.app.PendingIntent getAlarmIntent()
protected abstract void onNewScanCycle()