public abstract class CycledLeScanner extends Object
| Modifier and Type | Field and Description |
|---|---|
static long |
ANDROID_N_MAX_SCAN_DURATION_MILLIS |
protected boolean |
mBackgroundFlag |
protected long |
mBetweenScanPeriod |
protected BluetoothCrashResolver |
mBluetoothCrashResolver |
protected Context |
mContext |
protected CycledLeScanCallback |
mCycledLeScanCallback |
protected Handler |
mHandler
Main thread handle for scheduling scan cycle tasks.
|
protected long |
mNextScanCycleStartTime |
protected boolean |
mRestartNeeded |
protected Handler |
mScanHandler
Handler to background thread for interacting with the low-level Android BLE scanner.
|
protected boolean |
mScanningPaused |
| Modifier | Constructor and Description |
|---|---|
protected |
CycledLeScanner(Context context,
long scanPeriod,
long betweenScanPeriod,
boolean backgroundFlag,
CycledLeScanCallback cycledLeScanCallback,
BluetoothCrashResolver crashResolver) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
cancelAlarmOnUserSwitch() |
protected void |
cancelWakeUpAlarm() |
protected void |
cleanupCancelAlarmOnUserSwitch() |
static CycledLeScanner |
createScanner(Context context,
long scanPeriod,
long betweenScanPeriod,
boolean backgroundFlag,
CycledLeScanCallback cycledLeScanCallback,
BluetoothCrashResolver crashResolver) |
protected abstract boolean |
deferScanIfNeeded() |
void |
destroy() |
protected abstract void |
finishScan() |
protected BluetoothAdapter |
getBluetoothAdapter() |
boolean |
getDistinctPacketsDetectedPerScan() |
protected PendingIntent |
getWakeUpOperation() |
protected void |
scanLeDevice(Boolean enable) |
protected void |
scheduleScanCycleStop() |
void |
setDistinctPacketsDetectedPerScan(boolean detected) |
void |
setLongScanForcingEnabled(boolean enabled)
Enables the scanner to go to extra lengths to keep scans going for longer than would
otherwise be allowed.
|
void |
setScanPeriods(long scanPeriod,
long betweenScanPeriod,
boolean backgroundFlag)
Tells the cycler the scan rate and whether it is in operating in background mode.
|
protected void |
setWakeUpAlarm() |
void |
start() |
protected abstract void |
startScan() |
void |
stop() |
protected abstract void |
stopScan() |
public static final long ANDROID_N_MAX_SCAN_DURATION_MILLIS
protected long mNextScanCycleStartTime
protected boolean mScanningPaused
protected final Context mContext
protected long mBetweenScanPeriod
@NonNull protected final Handler mHandler
Use this to schedule deferred tasks such as the following:
@NonNull protected final Handler mScanHandler
Use this to queue any potentially long running BLE scanner actions such as starts and stops.
protected final BluetoothCrashResolver mBluetoothCrashResolver
protected final CycledLeScanCallback mCycledLeScanCallback
protected boolean mBackgroundFlag
protected boolean mRestartNeeded
protected CycledLeScanner(Context context, long scanPeriod, long betweenScanPeriod, boolean backgroundFlag, CycledLeScanCallback cycledLeScanCallback, BluetoothCrashResolver crashResolver)
public static CycledLeScanner createScanner(Context context, long scanPeriod, long betweenScanPeriod, boolean backgroundFlag, CycledLeScanCallback cycledLeScanCallback, BluetoothCrashResolver crashResolver)
public void setLongScanForcingEnabled(boolean enabled)
enabled - @MainThread
public void setScanPeriods(long scanPeriod,
long betweenScanPeriod,
boolean backgroundFlag)
backgroundFlag - @MainThread public void start()
@MainThread public void stop()
@AnyThread public boolean getDistinctPacketsDetectedPerScan()
@AnyThread public void setDistinctPacketsDetectedPerScan(boolean detected)
@MainThread public void destroy()
protected abstract void stopScan()
protected abstract boolean deferScanIfNeeded()
protected abstract void startScan()
@MainThread protected void scanLeDevice(Boolean enable)
@MainThread protected void scheduleScanCycleStop()
protected abstract void finishScan()
protected BluetoothAdapter getBluetoothAdapter()
protected void setWakeUpAlarm()
protected void cancelAlarmOnUserSwitch()
protected void cleanupCancelAlarmOnUserSwitch()
protected PendingIntent getWakeUpOperation()
protected void cancelWakeUpAlarm()