From 80512a0b8aadd9f3bd3f1b56123320bd29842147 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Wed, 28 Dec 2022 11:02:02 -0500 Subject: [PATCH] Shift app background check to resumeSessionTimer to make isAppInSession and revalidateSessionTimestamp background safe. --- MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m b/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m index 0ab40c8..84dbc0f 100644 --- a/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m +++ b/MVMCore/MVMCore/Session/MVMCoreSessionTimeHandler.m @@ -124,11 +124,7 @@ if (!fequal(0, self.secondsUntilTimeout)) { self.sessionBeingTimed = YES; [self markStartTime]; - - // Only start physical timer if active, otherwise will begin once entering foreground. FaceId prompt is considered UIApplicationStateInactive. - if ([UIApplication sharedApplication].applicationState != UIApplicationStateBackground) { - [self resumeSessionTimer]; - } + [self resumeSessionTimer]; } } }); @@ -137,6 +133,11 @@ /// Resume the session timers if they are stopped. - (void)resumeSessionTimer { dispatch_async(dispatch_get_main_queue(), ^(void) { + // Only start physical timer if active, otherwise will begin once entering foreground. FaceId prompt is considered UIApplicationStateInactive. + if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) { + return; + } + if (!fequal(0, self.secondsUntilWarning) && ![self.sessionWarningTimer isValid]) { self.sessionWarningTimer = [NSTimer scheduledTimerWithTimeInterval:[self remainingTimeUntilWarning] target:self selector:@selector(sessionTimeoutWarning) userInfo:nil repeats:NO]; MVMCoreLog(@"Session warning will fire at: %@", self.sessionWarningTimer.fireDate);