Skip to content

Commit

Permalink
fix isconnectable for sdk < 26
Browse files Browse the repository at this point in the history
  • Loading branch information
Trup3s committed Jan 13, 2022
1 parent cf65623 commit f9fa38a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.seemoo.at_tracking_detection.database.tables

import android.bluetooth.le.ScanResult
import android.os.Build
import androidx.room.*
import de.seemoo.at_tracking_detection.ATTrackingDetectionApplication
import de.seemoo.at_tracking_detection.R
Expand Down Expand Up @@ -51,7 +52,13 @@ data class Device(
scanResult.device.address,
scanResult.scanRecord?.deviceName,
false,
scanResult.isConnectable,
scanResult.let {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
scanResult.isConnectable
} else {
false
}
},
scanResult.scanRecord?.getManufacturerSpecificData(76)?.get(2),
LocalDateTime.now(), LocalDateTime.now(), false, null
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,9 @@ class ScanBluetoothWorker @AssistedInject constructor(
longitude: Double?,
discoveryDate: LocalDateTime
) {
val payloadData = scanResult.scanRecord?.manufacturerSpecificData?.get(76)?.get(2)
var device = deviceRepository.getDevice(scanResult.device.address)
if (device == null) {
device = Device(
scanResult.device.address,
false,
scanResult.isConnectable,
payloadData,
discoveryDate,
discoveryDate
)
device = Device(scanResult)
deviceRepository.insert(device)
} else {
Timber.d("Device already in the database... Updating the last seen date!")
Expand Down

0 comments on commit f9fa38a

Please sign in to comment.