Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

AndroidのAlarmServiceの廃止 #1085

Merged
1 commit merged into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Covid19Radar/Covid19Radar.Android/Covid19Radar.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\CloseApplicationService.cs" />
<Compile Include="Services\DeviceCheckService.cs" />
<Compile Include="Services\Logs\LogPeriodicDeleteService.cs" />
<Compile Include="Renderers\CustomDatePickerRenderer.cs" />
<Compile Include="Services\PreferencesService.cs" />
<Compile Include="Services\SecureStorageService.cs" />
Expand Down Expand Up @@ -611,7 +610,6 @@
<ItemGroup>
<Folder Include="Renderers\" />
<Folder Include="Resources\xml\" />
<Folder Include="Services\Logs\" />
<Folder Include="Resources\drawable-zh-xxhdpi\" />
<Folder Include="Resources\drawable-zh-xhdpi\" />
<Folder Include="Services\Migration\" />
Expand Down
1 change: 0 additions & 1 deletion Covid19Radar/Covid19Radar.Android/MainApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ private void RegisterPlatformTypes(IContainer container)
// Services
container.Register<IBackupAttributeService, BackupAttributeService>(Reuse.Singleton);
container.Register<ILocalPathService, LocalPathService>(Reuse.Singleton);
container.Register<ILogPeriodicDeleteService, LogPeriodicDeleteService>(Reuse.Singleton);
container.Register<ISecureStorageDependencyService, Services.SecureStorageService>(Reuse.Singleton);
container.Register<IPreferencesService, PreferencesService>(Reuse.Singleton);
container.Register<IApplicationPropertyService, ApplicationPropertyService>(Reuse.Singleton);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ public class DataMaintainanceBackgroundService : AbsDataMaintainanceBackgroundSe

public DataMaintainanceBackgroundService(
ILoggerService loggerService,
ILogFileService logFileService,
IEventLogRepository eventLogRepository
) : base(loggerService, eventLogRepository)
) : base(loggerService, logFileService, eventLogRepository)
{
// do nothing
}
Expand All @@ -49,7 +50,7 @@ public override void Schedule()
private PeriodicWorkRequest CreatePeriodicWorkRequest()
{
var workRequestBuilder = new PeriodicWorkRequest.Builder(
typeof(DataMaintainanceBackgroundWorker),
typeof(BackgroundWorker),
INTERVAL_IN_HOURS, TimeUnit.Hours
)
.SetConstraints(new Constraints.Builder()
Expand All @@ -58,49 +59,49 @@ private PeriodicWorkRequest CreatePeriodicWorkRequest()
.SetBackoffCriteria(BackoffPolicy.Linear, BACKOFF_DELAY_IN_MINUTES, TimeUnit.Minutes);
return workRequestBuilder.Build();
}
}

[Preserve]
public class DataMaintainanceBackgroundWorker : Worker
{
private Lazy<AbsDataMaintainanceBackgroundService> _dataMaintainanceBackgroundService
=> new Lazy<AbsDataMaintainanceBackgroundService>(() => ContainerLocator.Current.Resolve<AbsDataMaintainanceBackgroundService>());
private Lazy<ILoggerService> _loggerService => new Lazy<ILoggerService>(() => ContainerLocator.Current.Resolve<ILoggerService>());

public DataMaintainanceBackgroundWorker(Context context, WorkerParameters workerParameters)
: base(context, workerParameters)
{
// do nothing
}

public override Result DoWork()
[Preserve]
public class BackgroundWorker : Worker
{
var dataMaintainanceBackgroundService = _dataMaintainanceBackgroundService.Value;
var loggerService = _loggerService.Value;

loggerService.StartMethod();
private Lazy<AbsDataMaintainanceBackgroundService> _dataMaintainanceBackgroundService
=> new Lazy<AbsDataMaintainanceBackgroundService>(() => ContainerLocator.Current.Resolve<AbsDataMaintainanceBackgroundService>());
private Lazy<ILoggerService> _loggerService => new Lazy<ILoggerService>(() => ContainerLocator.Current.Resolve<ILoggerService>());

try
public BackgroundWorker(Context context, WorkerParameters workerParameters)
: base(context, workerParameters)
{
dataMaintainanceBackgroundService.ExecuteAsync().GetAwaiter().GetResult();
return Result.InvokeSuccess();
// do nothing
}
catch (Exception exception)
{
loggerService.Exception("Exception", exception);
return Result.InvokeFailure();
}
finally

public override Result DoWork()
{
loggerService.EndMethod();
var dataMaintainanceBackgroundService = _dataMaintainanceBackgroundService.Value;
var loggerService = _loggerService.Value;

loggerService.StartMethod();

try
{
dataMaintainanceBackgroundService.ExecuteAsync().GetAwaiter().GetResult();
return Result.InvokeSuccess();
}
catch (Exception exception)
{
loggerService.Exception("Exception", exception);
return Result.InvokeFailure();
}
finally
{
loggerService.EndMethod();
}
}
}

public override void OnStopped()
{
base.OnStopped();
public override void OnStopped()
{
base.OnStopped();

_loggerService.Value.Warning("OnStopped");
_loggerService.Value.Warning("OnStopped");
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Covid19Radar.Droid.Services
{
public class EventLogSubmissionBackgroundService : AbsEventLogSubmissionBackgroundService
{
private const string CURRENT_WORK_NAME = "eventlog_submission_worker_20220112";
private const string CURRENT_WORK_NAME = "eventlog_submission_worker_20220628";

private const long INTERVAL_IN_HOURS = 24;
private const long BACKOFF_DELAY_IN_MINUTES = 60;
Expand All @@ -42,14 +42,14 @@ public override void Schedule()
PeriodicWorkRequest periodicWorkRequest = CreatePeriodicWorkRequest();
workManager.EnqueueUniquePeriodicWork(
CURRENT_WORK_NAME,
ExistingPeriodicWorkPolicy.Replace,
ExistingPeriodicWorkPolicy.Keep,
periodicWorkRequest
);

_loggerService.EndMethod();
}

private static PeriodicWorkRequest CreatePeriodicWorkRequest()
private PeriodicWorkRequest CreatePeriodicWorkRequest()
{
var workRequestBuilder = new PeriodicWorkRequest.Builder(
typeof(BackgroundWorker),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,20 @@ public class MigrationProccessService : IMigrationProcessService
{
private readonly AbsExposureDetectionBackgroundService _exposureDetectionBackgroundService;
private readonly AbsDataMaintainanceBackgroundService _dataMaintainanceBackgroundService;
private readonly AbsEventLogSubmissionBackgroundService _eventLogSubmissionBackgroundService;

private readonly ILoggerService _loggerService;

public MigrationProccessService(
AbsExposureDetectionBackgroundService exposureDetectionBackgroundService,
AbsDataMaintainanceBackgroundService dataMaintainanceBackgroundService,
AbsEventLogSubmissionBackgroundService eventLogSubmissionBackgroundService,
ILoggerService loggerService
)
{
_exposureDetectionBackgroundService = exposureDetectionBackgroundService;
_dataMaintainanceBackgroundService = dataMaintainanceBackgroundService;
_eventLogSubmissionBackgroundService = eventLogSubmissionBackgroundService;
_loggerService = loggerService;
}

Expand All @@ -91,6 +94,7 @@ public async Task SetupAsync()
await new WorkManagerMigrator(
_exposureDetectionBackgroundService,
_dataMaintainanceBackgroundService,
_eventLogSubmissionBackgroundService,
_loggerService
).ExecuteAsync();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,20 @@ internal class WorkManagerMigrator

private readonly AbsExposureDetectionBackgroundService _exposureDetectionBackgroundService;
private readonly AbsDataMaintainanceBackgroundService _dataMaintainanceBackgroundService;
private readonly AbsEventLogSubmissionBackgroundService _eventLogSubmissionBackgroundService;

private readonly ILoggerService _loggerService;

public WorkManagerMigrator(
AbsExposureDetectionBackgroundService exposureDetectionBackgroundService,
AbsDataMaintainanceBackgroundService dataMaintainanceBackgroundService,
AbsEventLogSubmissionBackgroundService eventLogSubmissionBackgroundService,
ILoggerService loggerService
)
{
_exposureDetectionBackgroundService = exposureDetectionBackgroundService;
_dataMaintainanceBackgroundService = dataMaintainanceBackgroundService;
_eventLogSubmissionBackgroundService = eventLogSubmissionBackgroundService;
_loggerService = loggerService;
}

Expand All @@ -43,6 +46,7 @@ internal Task ExecuteAsync()

_exposureDetectionBackgroundService.Schedule();
_dataMaintainanceBackgroundService.Schedule();
_eventLogSubmissionBackgroundService.Schedule();

_loggerService.EndMethod();

Expand Down
5 changes: 2 additions & 3 deletions Covid19Radar/Covid19Radar.iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ public override bool FinishedLaunching(UIApplication app, NSDictionary launchOpt

UIApplication.SharedApplication.SetMinimumBackgroundFetchInterval(UIApplication.BackgroundFetchIntervalMinimum);

ScheduleBackgroundTask();
ScheduleBackgroundTasks();

return base.FinishedLaunching(app, launchOptions);
}

private void ScheduleBackgroundTask()
private void ScheduleBackgroundTasks()
{
try
{
Expand Down Expand Up @@ -269,7 +269,6 @@ private void RegisterPlatformTypes(IContainer container)
// Services
container.Register<IBackupAttributeService, BackupAttributeService>(Reuse.Singleton);
container.Register<ILocalPathService, LocalPathService>(Reuse.Singleton);
container.Register<ILogPeriodicDeleteService, LogPeriodicDeleteService>(Reuse.Singleton);
container.Register<ISecureStorageDependencyService, Services.SecureStorageService>(Reuse.Singleton);
container.Register<IPreferencesService, PreferencesService>(Reuse.Singleton);
container.Register<IApplicationPropertyService, ApplicationPropertyService>(Reuse.Singleton);
Expand Down
2 changes: 0 additions & 2 deletions Covid19Radar/Covid19Radar.iOS/Covid19Radar.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@
<Compile Include="Extensions\AlignmentExtensions.cs" />
<Compile Include="Extensions\Extensions.cs" />
<Compile Include="Extensions\FormattedStringExtensions.cs" />
<Compile Include="Services\Logs\LogPeriodicDeleteService.cs" />
<Compile Include="Renderers\CustomDatePickerRenderer.cs" />
<Compile Include="Services\PreferencesService.cs" />
<Compile Include="Services\SecureStorageService.cs" />
Expand Down Expand Up @@ -546,7 +545,6 @@
<BundleResource Include="Resources\Base.lproj\HeaderLogo%403x.png" />
</ItemGroup>
<ItemGroup>
<Folder Include="Services\Logs\" />
<Folder Include="Renderers\" />
<Folder Include="Resources\zh-Hans.lproj\" />
<Folder Include="Services\Migration\" />
Expand Down
2 changes: 0 additions & 2 deletions Covid19Radar/Covid19Radar.iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,13 @@
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>APP_PACKAGE_NAME.exposure-notification</string>
<string>APP_PACKAGE_NAME.delete-old-logs</string>
<string>APP_PACKAGE_NAME.eventlog-submission</string>
<string>APP_PACKAGE_NAME.data-maintainance</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>processing</string>
</array>
<key>UIUserInterfaceStyle</key>
Expand Down
Loading