Added timestamp to the BluetoothLeDevice
This commit is contained in:
@@ -12,10 +12,17 @@ import android.os.Parcel;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
public class BluetoothLeDevice implements Parcelable{
|
public class BluetoothLeDevice implements Parcelable{
|
||||||
|
private static final String PARCEL_EXTRA_BLUETOOTH_DEVICE = "bluetooth_device";
|
||||||
|
private static final String PARCEL_EXTRA_DEVICE_RSSI = "device_rssi";
|
||||||
|
private static final String PARCEL_EXTRA_DEVICE_SCANRECORD = "device_scanrecord";
|
||||||
|
private static final String PARCEL_EXTRA_DEVICE_SCANRECORD_STORE = "device_scanrecord_store";
|
||||||
|
private static final String PARCEL_EXTRA_TIMESTAMP = "timestamp";
|
||||||
|
|
||||||
private final AdRecordStore mRecordStore;
|
private final AdRecordStore mRecordStore;
|
||||||
private final BluetoothDevice mDevice;
|
private final BluetoothDevice mDevice;
|
||||||
private final byte[] mScanRecord;
|
private final byte[] mScanRecord;
|
||||||
private transient final int mRssi;
|
private transient final int mRssi;
|
||||||
|
private transient final long mTimestamp;
|
||||||
|
|
||||||
public static final Parcelable.Creator<BluetoothLeDevice> CREATOR = new Parcelable.Creator<BluetoothLeDevice>() {
|
public static final Parcelable.Creator<BluetoothLeDevice> CREATOR = new Parcelable.Creator<BluetoothLeDevice>() {
|
||||||
public BluetoothLeDevice createFromParcel(Parcel in) {
|
public BluetoothLeDevice createFromParcel(Parcel in) {
|
||||||
@@ -27,20 +34,26 @@ public class BluetoothLeDevice implements Parcelable{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public BluetoothLeDevice(BluetoothDevice device, int rssi, byte[] scanRecord){
|
public BluetoothLeDevice(BluetoothDevice device, int rssi, byte[] scanRecord, long timestamp){
|
||||||
mDevice = device;
|
mDevice = device;
|
||||||
mRssi = rssi;
|
mRssi = rssi;
|
||||||
mScanRecord = scanRecord;
|
mScanRecord = scanRecord;
|
||||||
mRecordStore = new AdRecordStore(AdRecordUtils.parseScanRecordAsSparseArray(scanRecord));
|
mRecordStore = new AdRecordStore(AdRecordUtils.parseScanRecordAsSparseArray(scanRecord));
|
||||||
|
mTimestamp = timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BluetoothLeDevice(BluetoothDevice device, int rssi, byte[] scanRecord){
|
||||||
|
this(device, rssi, scanRecord, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BluetoothLeDevice(Parcel in) {
|
private BluetoothLeDevice(Parcel in) {
|
||||||
final Bundle b = in.readBundle(getClass().getClassLoader());
|
final Bundle b = in.readBundle(getClass().getClassLoader());
|
||||||
|
|
||||||
mDevice = b.getParcelable("bluetooth_device");
|
mDevice = b.getParcelable(PARCEL_EXTRA_BLUETOOTH_DEVICE);
|
||||||
mRecordStore = b.getParcelable("device_scanrecord_store");
|
mRecordStore = b.getParcelable(PARCEL_EXTRA_DEVICE_SCANRECORD_STORE);
|
||||||
mRssi = b.getInt("device_rssi");
|
mRssi = b.getInt(PARCEL_EXTRA_DEVICE_RSSI, 0);
|
||||||
mScanRecord = b.getByteArray("device_scanrecord");
|
mScanRecord = b.getByteArray(PARCEL_EXTRA_DEVICE_SCANRECORD);
|
||||||
|
mTimestamp = b.getLong(PARCEL_EXTRA_TIMESTAMP, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -117,10 +130,11 @@ public class BluetoothLeDevice implements Parcelable{
|
|||||||
public void writeToParcel(Parcel parcel, int arg1) {
|
public void writeToParcel(Parcel parcel, int arg1) {
|
||||||
final Bundle b = new Bundle(getClass().getClassLoader());
|
final Bundle b = new Bundle(getClass().getClassLoader());
|
||||||
|
|
||||||
b.putByteArray("device_scanrecord", mScanRecord);
|
b.putByteArray(PARCEL_EXTRA_DEVICE_SCANRECORD, mScanRecord);
|
||||||
b.putInt("device_rssi", mRssi);
|
b.putInt(PARCEL_EXTRA_DEVICE_RSSI, mRssi);
|
||||||
b.putParcelable("bluetooth_device", mDevice);
|
b.putLong(PARCEL_EXTRA_TIMESTAMP, mTimestamp);
|
||||||
b.putParcelable("device_scanrecord_store", mRecordStore);
|
b.putParcelable(PARCEL_EXTRA_BLUETOOTH_DEVICE, mDevice);
|
||||||
|
b.putParcelable(PARCEL_EXTRA_DEVICE_SCANRECORD_STORE, mRecordStore);
|
||||||
|
|
||||||
parcel.writeBundle(b);
|
parcel.writeBundle(b);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user