COVIDSafe code from version 1.10 (#20)

This commit is contained in:
COVIDSafe Support 2020-08-18 10:52:17 +10:00 committed by GitHub
parent 3b1d8fa3f4
commit 4ddb77535e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 2681 additions and 328 deletions

View file

@ -43,13 +43,16 @@ class CentralController: NSObject {
public init(queue: DispatchQueue) {
self.queue = queue
super.init()
NotificationCenter.default.addObserver(
forName: UIApplication.didReceiveMemoryWarningNotification,
object: nil,
queue: .main) { [weak self] notification in
self?.cleanupScannedPeripherals()
self?.queue.async {
self?.cleanupScannedPeripherals()
}
}
}
@ -185,11 +188,11 @@ extension CentralController: CBCentralManagerDelegate {
central.connect(recoveredPeripheral)
}
// cant cancel peripheral when BL OFF
for cleanupPeripheral in cleanupPeripherals {
// can't cancel peripheral when BL OFF
for cleanupPeripheral in self.cleanupPeripherals {
central.cancelPeripheralConnection(cleanupPeripheral)
}
cleanupPeripherals = []
self.cleanupPeripherals = []
central.scanForPeripherals(withServices: [BluetraceConfig.BluetoothServiceID], options:nil)
logPeripheralsCount(description: "Update state powerOn")
@ -482,7 +485,7 @@ extension CentralController: CBPeripheralDelegate {
// regularly cleanup and close pending connections
if (abs(lastCleanedScannedPeripherals.timeIntervalSince(Date())) > BluetraceConfig.CentralScanInterval) {
cleanupScannedPeripherals()
cleanupScannedPeripherals()
}
}