diff --git a/src/xcode/ENA/ENA/Source/Models/Exposure/ExposureManager.swift b/src/xcode/ENA/ENA/Source/Models/Exposure/ExposureManager.swift index 28566e3a91a..ccb8fd75599 100644 --- a/src/xcode/ENA/ENA/Source/Models/Exposure/ExposureManager.swift +++ b/src/xcode/ENA/ENA/Source/Models/Exposure/ExposureManager.swift @@ -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 diff --git a/src/xcode/ENA/ENA/Source/Models/Exposure/__tests__/ExposureManagerTests.swift b/src/xcode/ENA/ENA/Source/Models/Exposure/__tests__/ExposureManagerTests.swift index adb2467bdbc..a87ae6d5458 100644 --- a/src/xcode/ENA/ENA/Source/Models/Exposure/__tests__/ExposureManagerTests.swift +++ b/src/xcode/ENA/ENA/Source/Models/Exposure/__tests__/ExposureManagerTests.swift @@ -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()