public class BluetoothCrashResolver
extends java.lang.Object
This class can both recover from crashes and prevent crashes from happening in the first place
More details on the bug can be found at the following URLs:
https://code.google.com/p/android/issues/detail?id=67272 https://github.com/RadiusNetworks/android-ibeacon-service/issues/16
Version 1.0
Created by dyoung on 3/24/14.
Modifier and Type | Class and Description |
---|---|
static interface |
BluetoothCrashResolver.UpdateNotifier |
Constructor and Description |
---|
BluetoothCrashResolver(android.content.Context context)
Constructor should be called only once per long-running process that does Bluetooth LE
scanning.
|
Modifier and Type | Method and Description |
---|---|
void |
crashDetected() |
void |
disableDebug()
Disable debug logging
|
void |
enableDebug()
Enable debug logging.
|
void |
forceFlush()
Used to force a recovery operation
|
int |
getDetectedCrashCount() |
long |
getLastBluetoothCrashDetectionTime() |
int |
getRecoveryAttemptCount() |
boolean |
isLastRecoverySucceeded() |
boolean |
isRecoveryInProgress() |
void |
notifyScannedDevice(android.bluetooth.BluetoothDevice device,
android.bluetooth.BluetoothAdapter.LeScanCallback scanner)
Call this method from your BluetoothAdapter.LeScanCallback method.
|
void |
setUpdateNotifier(BluetoothCrashResolver.UpdateNotifier updateNotifier) |
void |
start()
Starts looking for crashes of the Bluetooth LE system and taking proactive steps to stop
crashes from happening.
|
void |
stop()
Stops looking for crashes.
|
public BluetoothCrashResolver(android.content.Context context)
context
- the Activity or Service that is doing the Bluetooth scanningpublic void start()
public void stop()
public void enableDebug()
public void disableDebug()
public void notifyScannedDevice(android.bluetooth.BluetoothDevice device, android.bluetooth.BluetoothAdapter.LeScanCallback scanner)
This works very well if the app containing this class is the only one running bluetooth LE scans on the device, or it is constantly doing scans (e.g. is in the foreground for extended periods of time.)
This will not work well if the application using this class is only scanning periodically (e.g. when in the background to save battery) and another application is also scanning on the same device, because this class will only get the counts from this application.
Future augmentation of this class may improve this by somehow centralizing the list of unique scanned devices.
device
- public void crashDetected()
public long getLastBluetoothCrashDetectionTime()
public int getDetectedCrashCount()
public int getRecoveryAttemptCount()
public boolean isLastRecoverySucceeded()
public boolean isRecoveryInProgress()
public void setUpdateNotifier(BluetoothCrashResolver.UpdateNotifier updateNotifier)
public void forceFlush()