From 1dddedf3eba50639100724867448c750bdddaf27 Mon Sep 17 00:00:00 2001 From: Ryan ZHAO <> Date: Mon, 2 Dec 2024 15:42:55 +1100 Subject: [PATCH] add logs and fix a case when the call is going with CallKit but the app state is not in background --- Session.xcodeproj/project.pbxproj | 4 ++-- Session/Calls/Call Management/SessionCallManager.swift | 1 + Session/Home/HomeVC.swift | 2 +- SessionUtilitiesKit/General/AppContext.swift | 4 +++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index fd6ec0b96..50cfb2fdb 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -7778,7 +7778,7 @@ CODE_SIGN_ENTITLEMENTS = Session/Meta/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 502; + CURRENT_PROJECT_VERSION = 503; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -7849,7 +7849,7 @@ CODE_SIGN_ENTITLEMENTS = Session/Meta/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 502; + CURRENT_PROJECT_VERSION = 503; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", diff --git a/Session/Calls/Call Management/SessionCallManager.swift b/Session/Calls/Call Management/SessionCallManager.swift index f7c710a2b..045e9eb4c 100644 --- a/Session/Calls/Call Management/SessionCallManager.swift +++ b/Session/Calls/Call Management/SessionCallManager.swift @@ -199,6 +199,7 @@ public final class SessionCallManager: NSObject, CallManagerProtocol { } public static func suspendDatabaseIfCallEndedInBackground() { + SNLog("[Calls] suspendDatabaseIfCallEndedInBackground.") if Singleton.hasAppContext && Singleton.appContext.isInBackground { // FIXME: Initialise the `SessionCallManager` with a dependencies instance let dependencies: Dependencies = Dependencies() diff --git a/Session/Home/HomeVC.swift b/Session/Home/HomeVC.swift index ad34563e6..600200e64 100644 --- a/Session/Home/HomeVC.swift +++ b/Session/Home/HomeVC.swift @@ -354,7 +354,7 @@ final class HomeVC: BaseVC, LibSessionRespondingViewController, UITableViewDataS // Start polling if needed (i.e. if the user just created or restored their Session ID) if Identity.userExists(), let appDelegate: AppDelegate = UIApplication.shared.delegate as? AppDelegate, Singleton.appContext.isInBackground == false { - SNLog("[HomeVC]: Starting pollers... \(Singleton.appContext.reportedApplicationState)") + SNLog("[HomeVC]: Starting pollers...") appDelegate.startPollersIfNeeded() } diff --git a/SessionUtilitiesKit/General/AppContext.swift b/SessionUtilitiesKit/General/AppContext.swift index 423e8f5de..6e0bb9f46 100644 --- a/SessionUtilitiesKit/General/AppContext.swift +++ b/SessionUtilitiesKit/General/AppContext.swift @@ -46,7 +46,9 @@ public extension AppContext { var frontmostViewController: UIViewController? { nil } var backgroundTimeRemaining: TimeInterval { 0 } - var isInBackground: Bool { reportedApplicationState == .background } + // Note: .inactive is a strange state, if the app is activated by VOIP and CallKit is up in the front, + // the app will report .inactive state + var isInBackground: Bool { reportedApplicationState == .background || reportedApplicationState == .inactive } var isAppForegroundAndActive: Bool { reportedApplicationState == .active } // MARK: - Paths