From ed9185a17451dfc731547e73faca46a88debd6aa Mon Sep 17 00:00:00 2001 From: Tom Schmiedlechner Date: Wed, 4 Sep 2024 17:50:11 +0200 Subject: [PATCH 1/2] Acquire wakelock when hosting Swissbit SCUs --- .../Services/MiddlewareLauncher.cs | 15 +++++++++++++-- .../Properties/AndroidManifest.xml | 1 + .../Properties/AndroidManifest.xml | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/fiskaltrust.AndroidLauncher.Common/Services/MiddlewareLauncher.cs b/src/fiskaltrust.AndroidLauncher.Common/Services/MiddlewareLauncher.cs index c6795eb9..d50f65dc 100644 --- a/src/fiskaltrust.AndroidLauncher.Common/Services/MiddlewareLauncher.cs +++ b/src/fiskaltrust.AndroidLauncher.Common/Services/MiddlewareLauncher.cs @@ -7,8 +7,6 @@ using fiskaltrust.AndroidLauncher.Common.Services.SCU; using fiskaltrust.AndroidLauncher.Common.Signing; using fiskaltrust.ifPOS.v1; -using fiskaltrust.ifPOS.v1.de; -using fiskaltrust.ifPOS.v1.it; using fiskaltrust.Middleware.Abstractions; using fiskaltrust.storage.serialization.V0; using Microsoft.Extensions.Logging; @@ -39,6 +37,7 @@ internal class MiddlewareLauncher private readonly Dictionary _scuParams; private readonly LogLevel _logLevel; + private Android.OS.PowerManager.WakeLock _wakeLock; private List _helpers; private List _poss; private AbstractScuList _scus; @@ -87,6 +86,9 @@ public async Task StartAsync() switch (scuConfig.Package) { case PACKAGE_NAME_DE_SWISSBIT: + // On some (payment) devices, the CPU is turned off as soon as the device becomes remotely idle (i.e. right after processing a receipt) - this seems to also stop the internal clock of the Swissbit TSE. + // To prevent this, we acquire a partial wake lock to keep the CPU running. As this is only required with hardware TSEs, we only acquire the wake lock for the Swissbit SCU for now. + AcquireCpuWakeLock(); await InitializeDESwissbitScuAsync(scuConfig); break; case PACKAGE_NAME_DE_FISKALY_CERTIFIED: @@ -130,6 +132,8 @@ public async Task StopAsync() helper.StopEnd(); } + _wakeLock?.Release(); + IsRunning = false; } @@ -194,5 +198,12 @@ private static string GetPrimaryUriForSignaturCreationUnit(PackageConfiguration var grpcUrl = scuConfiguration.Url.FirstOrDefault(x => x.StartsWith("grpc://", StringComparison.InvariantCulture)); return new Uri(grpcUrl ?? scuConfiguration.Url.First()).ToString(); } + + private void AcquireCpuWakeLock() + { + var pm = (Android.OS.PowerManager)Android.App.Application.Context.GetSystemService(Android.Content.Context.PowerService); + _wakeLock = pm.NewWakeLock(Android.OS.WakeLockFlags.Partial, "fiskaltrust.AndroidLauncher::KeepAliveWakeLock"); + _wakeLock.Acquire(); + } } } \ No newline at end of file diff --git a/src/fiskaltrust.AndroidLauncher.Grpc/Properties/AndroidManifest.xml b/src/fiskaltrust.AndroidLauncher.Grpc/Properties/AndroidManifest.xml index ddfbea46..5f426bc3 100644 --- a/src/fiskaltrust.AndroidLauncher.Grpc/Properties/AndroidManifest.xml +++ b/src/fiskaltrust.AndroidLauncher.Grpc/Properties/AndroidManifest.xml @@ -10,4 +10,5 @@ + \ No newline at end of file diff --git a/src/fiskaltrust.AndroidLauncher.Http/Properties/AndroidManifest.xml b/src/fiskaltrust.AndroidLauncher.Http/Properties/AndroidManifest.xml index 6e8581aa..9473cfeb 100644 --- a/src/fiskaltrust.AndroidLauncher.Http/Properties/AndroidManifest.xml +++ b/src/fiskaltrust.AndroidLauncher.Http/Properties/AndroidManifest.xml @@ -9,4 +9,5 @@ + \ No newline at end of file From 48b4def7260ae533e9d4f9e0635b8c22c07c8c3b Mon Sep 17 00:00:00 2001 From: Tom Schmiedlechner Date: Thu, 5 Sep 2024 13:30:31 +0200 Subject: [PATCH 2/2] Updated to Swissbit SCU 1.3.62 --- .../fiskaltrust.AndroidLauncher.Common.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fiskaltrust.AndroidLauncher.Common/fiskaltrust.AndroidLauncher.Common.csproj b/src/fiskaltrust.AndroidLauncher.Common/fiskaltrust.AndroidLauncher.Common.csproj index dcbc07ce..d92218ac 100644 --- a/src/fiskaltrust.AndroidLauncher.Common/fiskaltrust.AndroidLauncher.Common.csproj +++ b/src/fiskaltrust.AndroidLauncher.Common/fiskaltrust.AndroidLauncher.Common.csproj @@ -144,10 +144,10 @@ 1.3.59 - 1.3.48 + 1.3.62 - 1.3.48 + 1.3.62 2.2.0