From 0f2afa1bfad8d820105381c5a6c0833865c464ab Mon Sep 17 00:00:00 2001 From: Josh Heald Date: Mon, 23 Sep 2024 14:24:29 +0100 Subject: [PATCH 1/2] Prevent sleep during Card Reader software updates --- .../CardReader/StripeCardReader/StripeCardReaderService.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Hardware/Hardware/CardReader/StripeCardReader/StripeCardReaderService.swift b/Hardware/Hardware/CardReader/StripeCardReader/StripeCardReaderService.swift index fc8644ae50f..aefdb859dc1 100644 --- a/Hardware/Hardware/CardReader/StripeCardReader/StripeCardReaderService.swift +++ b/Hardware/Hardware/CardReader/StripeCardReader/StripeCardReaderService.swift @@ -2,6 +2,7 @@ import Combine import StripeTerminal import CoreBluetooth +import class UIKit.UIApplication /// The adapter wrapping the Stripe Terminal SDK public final class StripeCardReaderService: NSObject { @@ -866,6 +867,7 @@ extension StripeCardReaderService: BluetoothReaderDelegate { } public func reader(_ reader: Reader, didStartInstallingUpdate update: ReaderSoftwareUpdate, cancelable: StripeTerminal.Cancelable?) { + UIApplication.shared.isIdleTimerDisabled = true softwareUpdateSubject.send(.started(cancelable: cancelable.map(StripeCancelable.init(cancelable:)))) } @@ -874,6 +876,8 @@ extension StripeCardReaderService: BluetoothReaderDelegate { } public func reader(_ reader: Reader, didFinishInstallingUpdate update: ReaderSoftwareUpdate?, error: Error?) { + // Note that this function is called with an error when updates are cancelled, so this is enough to ensure we re-enable sleep. + UIApplication.shared.isIdleTimerDisabled = false if let error = error { let underlyingError = Self.logAndDecodeError(error) softwareUpdateSubject.send(.failed( From 39750d11b9115cf66c5f624c378b67c5aabc665e Mon Sep 17 00:00:00 2001 From: Josh Heald Date: Mon, 23 Sep 2024 15:02:27 +0100 Subject: [PATCH 2/2] Add reader update sleep prevention to 20.6 release --- RELEASE-NOTES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 5e311cd4509..8c423dd91d9 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -6,6 +6,7 @@ - [*] Jetpack setup: fixed issue checking site info after activating Jetpack for sites with Jetpack connection package. [https://github.com/woocommerce/woocommerce-ios/pull/13993] - [*] Blaze: Campaign status is now updated immediately after being canceled. [https://github.com/woocommerce/woocommerce-ios/pull/13992] - [internal] Logging for app storage size added in Core Data crash logs [https://github.com/woocommerce/woocommerce-ios/pull/14008] +- [*] Payments: Prevent phone from sleeping during card reader updates [https://github.com/woocommerce/woocommerce-ios/pull/14021] 20.5 -----