Răsfoiți Sursa

prevent device from sleeping (otherwise, transfer will abort)

B. Petersen 2 ani în urmă
părinte
comite
ead2e8b7a9

+ 3 - 0
deltachat-ios/Controller/AccountSetup/WelcomeViewController.swift

@@ -289,6 +289,7 @@ class WelcomeViewController: UIViewController, ProgressAlertHandler {
 
     private func addProgressHudBackupListener() {
         let nc = NotificationCenter.default
+        UIApplication.shared.isIdleTimerDisabled = true
         backupProgressObserver = nc.addObserver(
             forName: dcNotificationImexProgress,
             object: nil,
@@ -297,6 +298,7 @@ class WelcomeViewController: UIViewController, ProgressAlertHandler {
             guard let self = self else { return }
             if let ui = notification.userInfo {
                 if let error = ui["error"] as? Bool, error {
+                    UIApplication.shared.isIdleTimerDisabled = false
                     if self.dcContext.isConfigured() {
                         let accountId = self.dcContext.id
                         _ = self.dcAccounts.remove(id: accountId)
@@ -313,6 +315,7 @@ class WelcomeViewController: UIViewController, ProgressAlertHandler {
                     self.stopAccessingSecurityScopedResource()
                     self.removeBackupProgressObserver()
                 } else if let done = ui["done"] as? Bool, done {
+                    UIApplication.shared.isIdleTimerDisabled = false
                     self.dcAccounts.startIo()
                     self.updateProgressAlertSuccess(completion: self.handleBackupRestoreSuccess)
                     self.stopAccessingSecurityScopedResource()

+ 2 - 0
deltachat-ios/Controller/BackupTransferViewController.swift

@@ -88,7 +88,9 @@ class BackupTransferViewController: UIViewController {
                 dcBackupProvider = nil
             }
             dcAccounts.startIo()
+            UIApplication.shared.isIdleTimerDisabled = false
         } else {
+            UIApplication.shared.isIdleTimerDisabled = true
             imexObserver = NotificationCenter.default.addObserver(forName: dcNotificationImexProgress, object: nil, queue: nil) { [weak self] notification in
                 guard let self = self, let ui = notification.userInfo, let permille = ui["progress"] as? Int else { return }
                 var statusLineText = ""