Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Fix/14954 Prevent presenting popup in EOL #5105

Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,12 @@ final class ENAExposureManager: NSObject, ExposureManager {
/// Asks user for permission to enable ExposureNotification and enables it, if the user grants permission
/// Expects the callee to invoke `ExposureManager.activate` prior to this function call
func enable(completion: @escaping CompletionHandler) {
changeEnabled(to: true, completion: completion)
if !CWAHibernationProvider.shared.isHibernationState {
changeEnabled(to: true, completion: completion)
} else {
// We do not return an error in Hibernation mode otherwise we show an error popup so we return nil instead
completion(nil)
}
}

/// Disables the ExposureNotification framework
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@ import ExposureNotification
@testable import ENA

class ExposureManagerTests: CWATestCase {

func testRequestEnableUserPermission_EOL_noError() {
// GIVEN
UserDefaults.standard.setValue(true, forKey: CWAHibernationProvider.isHibernationInUnitTest)
let managerSpy = ManagerSpy()
let exposureManager = ENAExposureManager(manager: managerSpy)
let expectation = expectation(description: "Risk permission in EOl should return nil")

// WHEN
exposureManager.enable { error in
UserDefaults.standard.setValue(false, forKey: CWAHibernationProvider.isHibernationInUnitTest)

// THEN
XCTAssertNil(error)
expectation.fulfill()
}
waitForExpectations(timeout: .medium)

}

func test_GIVEN_RunningDetection_When_StartNewDetection_Then_SameProgressReturned() {
let managerSpy = ManagerSpy()
Expand Down