@@ -36,13 +36,12 @@ enum ENAPIVersion { case V1, V2 }
3636
3737@objc ( ExposureManager)
3838/**
39- This class wrapps [ENManager](https://developer.apple.com/documentation/exposurenotification/enmanager) and acts like a controller and entry point of the different flows
39+ This class wraps [ENManager](https://developer.apple.com/documentation/exposurenotification/enmanager) and acts like a controller and entry point of the different flows
4040 */
4141
4242final class ExposureManager : NSObject {
4343
44- private static let backgroundTaskIdentifier = " \( Bundle . main. bundleIdentifier!) .exposure-notification "
45- private static let chaffBackgroundTaskIdentifier = " \( Bundle . main. bundleIdentifier!) .chaff "
44+ private static let exposureDetectionBackgroundTaskIdentifier = " \( Bundle . main. bundleIdentifier!) .exposure-notification "
4645 private static let deleteOldExposuresBackgroundTaskIdentifier = " \( Bundle . main. bundleIdentifier!) .delete-old-exposures "
4746
4847 @objc private( set) static var shared : ExposureManager ?
@@ -86,20 +85,13 @@ final class ExposureManager: NSObject {
8685 self ? . activateSuccess ( )
8786 }
8887 }
89- // Schedule background tasks if needed whenever EN authorization status changes
88+ // Schedule background task if needed whenever EN authorization status changes
9089 notificationCenter. addObserver (
9190 self ,
9291 selector: #selector( scheduleExposureDetectionBackgroundTaskIfNeeded) ,
9392 name: . ExposureNotificationStatusDidChange,
9493 object: nil
9594 )
96-
97- notificationCenter. addObserver (
98- self ,
99- selector: #selector( scheduleChaffBackgroundTaskIfNeeded) ,
100- name: . ChaffRequestTriggered,
101- object: nil
102- )
10395 }
10496
10597 deinit {
@@ -216,12 +208,6 @@ final class ExposureManager: NSObject {
216208 } , callback: callback)
217209 }
218210
219- @objc func fetchChaffKeys( callback: @escaping ( ExposureKeysDictionaryArray ? , ExposureManagerError ? ) -> Void ) {
220- getDiagnosisKeys ( transform: { ( keys) -> ExposureKeysDictionaryArray in
221- ( keys ?? [ ] ) . map { $0. chaffRepresentation }
222- } , callback: callback)
223- }
224-
225211
226212 // MARK: == Exposure Detection ==
227213
@@ -230,7 +216,7 @@ final class ExposureManager: NSObject {
230216 All launch handlers must be registered before application finishes launching
231217 */
232218 @objc func registerExposureDetectionBackgroundTask( ) {
233- bgTaskScheduler. register ( forTaskWithIdentifier: ExposureManager . backgroundTaskIdentifier ,
219+ bgTaskScheduler. register ( forTaskWithIdentifier: ExposureManager . exposureDetectionBackgroundTaskIdentifier ,
234220 using: . main) { [ weak self] task in
235221 guard let strongSelf = self else { return }
236222 // Notify the user if bluetooth is off
@@ -256,27 +242,7 @@ final class ExposureManager: NSObject {
256242 self ? . scheduleExposureDetectionBackgroundTaskIfNeeded ( )
257243 }
258244 }
259-
260- /**
261- Registers the background task of sending chaff requests
262- All launch handlers must be registered before application finishes launching
263- */
264- @objc func registerChaffBackgroundTask( ) {
265- bgTaskScheduler. register ( forTaskWithIdentifier: ExposureManager . chaffBackgroundTaskIdentifier,
266- using: . main) { [ weak self] task in
267-
268- // Perform the chaff request
269- let currentHour = Calendar . current. dateComponents ( [ . hour] , from: Date ( ) ) . hour ?? 0
270-
271- if ( currentHour > 8 && currentHour < 19 ) {
272- self ? . performChaffRequest ( )
273- }
274-
275- // Schedule the next background task
276- self ? . scheduleChaffBackgroundTaskIfNeeded ( )
277- }
278- }
279-
245+
280246 /**
281247 Registers the background task of deleting exposures > 14 days old
282248 from the local database
@@ -294,18 +260,7 @@ final class ExposureManager: NSObject {
294260
295261 @objc func scheduleExposureDetectionBackgroundTaskIfNeeded( ) {
296262 guard manager. exposureNotificationStatus == . active else { return }
297- let taskRequest = BGProcessingTaskRequest ( identifier: ExposureManager . backgroundTaskIdentifier)
298- taskRequest. requiresNetworkConnectivity = true
299- do {
300- try bgTaskScheduler. submit ( taskRequest)
301- } catch {
302- print ( " Unable to schedule background task: \( error) " )
303- }
304- }
305-
306- @objc func scheduleChaffBackgroundTaskIfNeeded( ) {
307- guard manager. exposureNotificationStatus == . active else { return }
308- let taskRequest = BGProcessingTaskRequest ( identifier: ExposureManager . chaffBackgroundTaskIdentifier)
263+ let taskRequest = BGProcessingTaskRequest ( identifier: ExposureManager . exposureDetectionBackgroundTaskIdentifier)
309264 taskRequest. requiresNetworkConnectivity = true
310265 do {
311266 try bgTaskScheduler. submit ( taskRequest)
@@ -661,18 +616,6 @@ private extension ExposureManager {
661616 ) )
662617 }
663618
664- func performChaffRequest( ) {
665- fetchChaffKeys { [ weak self] ( keyArray, error) in
666- if error != nil {
667- print ( " error: \( error. debugDescription) " )
668- }
669- self ? . notificationCenter. post ( Notification (
670- name: . ChaffRequestTriggered,
671- object: keyArray
672- ) )
673- }
674- }
675-
676619 func getDiagnosisKeys< T> ( transform: @escaping ( [ ENTemporaryExposureKey ] ? ) -> T ,
677620 callback: @escaping ( T ? , ExposureManagerError ? ) -> Void ) {
678621 manager. getDiagnosisKeys { ( keys, error) in
0 commit comments