From c609f486b6a7b568b3dfd142ab25149ce483a03c Mon Sep 17 00:00:00 2001 From: cocoa-dev004 <66989461+cocoa-dev004@users.noreply.github.com> Date: Tue, 19 Jul 2022 09:48:09 +0900 Subject: [PATCH 1/2] Add rotate when sending --- .../EventLogSubmissionBackgroundService.cs | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Covid19Radar/Covid19Radar.Android/Services/EventLogSubmissionBackgroundService.cs b/Covid19Radar/Covid19Radar.Android/Services/EventLogSubmissionBackgroundService.cs index 11daf9f39..efcfbeabd 100644 --- a/Covid19Radar/Covid19Radar.Android/Services/EventLogSubmissionBackgroundService.cs +++ b/Covid19Radar/Covid19Radar.Android/Services/EventLogSubmissionBackgroundService.cs @@ -3,10 +3,12 @@ // file, You can obtain one at https://mozilla.org/MPL/2.0/. using System; +using System.Threading.Tasks; using Android.Content; using Android.Runtime; using AndroidX.Work; using Covid19Radar.Common; +using Covid19Radar.Repository; using Covid19Radar.Services; using Covid19Radar.Services.Logs; using Java.Util.Concurrent; @@ -66,6 +68,7 @@ public class BackgroundWorker : Worker { private Lazy _loggerService => new Lazy(() => ContainerLocator.Current.Resolve()); private Lazy _eventLogService => new Lazy(() => ContainerLocator.Current.Resolve()); + private Lazy _eventLogRepository => new Lazy(() => ContainerLocator.Current.Resolve()); public BackgroundWorker(Context context, WorkerParameters workerParams) : base(context, workerParams) { @@ -76,14 +79,25 @@ public override Result DoWork() { var loggerService = _loggerService.Value; var eventLogService = _eventLogService.Value; + var eventLogRepository = _eventLogRepository.Value; loggerService.StartMethod(); try { - eventLogService.SendAllAsync( - AppConstants.EventLogMaxRequestSizeInBytes, - AppConstants.EventLogMaxRetry); + _ = Task.Run(async () => + { + loggerService.Info("Start event log submission background work."); + + await eventLogRepository.RotateAsync( + AppConstants.EventLogFileExpiredSeconds); + + await eventLogService.SendAllAsync( + AppConstants.EventLogMaxRequestSizeInBytes, + AppConstants.EventLogMaxRetry); + + loggerService.Info("Start event log submission background work."); + }); return Result.InvokeSuccess(); } catch (Exception exception) From 765f2112878ad6a9726958a0e050b6f1809cc3f0 Mon Sep 17 00:00:00 2001 From: cocoa-dev004 <66989461+cocoa-dev004@users.noreply.github.com> Date: Tue, 19 Jul 2022 10:26:59 +0900 Subject: [PATCH 2/2] Fixed log message --- .../Services/EventLogSubmissionBackgroundService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Covid19Radar/Covid19Radar.Android/Services/EventLogSubmissionBackgroundService.cs b/Covid19Radar/Covid19Radar.Android/Services/EventLogSubmissionBackgroundService.cs index efcfbeabd..774fe5966 100644 --- a/Covid19Radar/Covid19Radar.Android/Services/EventLogSubmissionBackgroundService.cs +++ b/Covid19Radar/Covid19Radar.Android/Services/EventLogSubmissionBackgroundService.cs @@ -96,7 +96,7 @@ await eventLogService.SendAllAsync( AppConstants.EventLogMaxRequestSizeInBytes, AppConstants.EventLogMaxRetry); - loggerService.Info("Start event log submission background work."); + loggerService.Info("Complete event log submission background work."); }); return Result.InvokeSuccess(); }