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

サービス終了通知の処理を修正 #1169

Merged
5 commits merged into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public ExposureDetectionBackgroundService(
IServerConfigurationRepository serverConfigurationRepository,
ILocalPathService localPathService,
IDateTimeUtility dateTimeUtility,
ILocalNotificationService localNotificationService
ILocalNotificationService localNotificationService,
IEndOfServiceNotificationService endOfServiceNotificationService
) : base(
diagnosisKeyRepository,
exposureNotificationApiService,
Expand All @@ -48,7 +49,8 @@ ILocalNotificationService localNotificationService
serverConfigurationRepository,
localPathService,
dateTimeUtility,
localNotificationService
localNotificationService,
endOfServiceNotificationService
)
{
_loggerService = loggerService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ public async Task ShowEndOfServiceNoticationAsync()
.Builder(Platform.AppContext, NOTIFICATION_CHANNEL_ID)
.SetStyle(new NotificationCompat.BigTextStyle())
.SetSmallIcon(Resource.Drawable.ic_notification)
.SetContentTitle(AppResources.EndOfServiceNotificationTitle)
.SetContentText(AppResources.EndOfServiceNotificationContent)
.SetVisibility(NotificationCompat.VisibilitySecret)
.SetContentIntent(pendingIntent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public ExposureDetectionBackgroundService(
IServerConfigurationRepository serverConfigurationRepository,
ILocalPathService localPathService,
IDateTimeUtility dateTimeUtility,
ILocalNotificationService localNotificationService
ILocalNotificationService localNotificationService,
IEndOfServiceNotificationService endOfServiceNotificationService
) : base(
diagnosisKeyRepository,
exposureNotificationApiService,
Expand All @@ -47,7 +48,8 @@ ILocalNotificationService localNotificationService
serverConfigurationRepository,
localPathService,
dateTimeUtility,
localNotificationService
localNotificationService,
endOfServiceNotificationService
)
{
_loggerService = loggerService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ private async Task ScheduleEndOfServiceNoticationAsync()

var content = new UNMutableNotificationContent();

content.Title = AppResources.EndOfServiceNotificationTitle;
content.Body = AppResources.EndOfServiceNotificationContent;

var request = UNNotificationRequest.FromIdentifier(NOTIFICATION_ID, content, null);
Expand Down
1 change: 1 addition & 0 deletions Covid19Radar/Covid19Radar/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ private static void RegisterCommonTypes(IContainer container)
container.Register<IDeviceInfoUtility, DeviceInfoUtility>(Reuse.Singleton);

// End of service
container.Register<IEndOfServiceNotificationService, EndOfServiceNotificationService>(Reuse.Singleton);
container.Register<ISurveyService, SurveyService>(Reuse.Singleton);
}

Expand Down
6 changes: 6 additions & 0 deletions Covid19Radar/Covid19Radar/Common/AppConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ public static class AppConstants
public static readonly DateTime COCOA_FIRST_RELEASE_DATE
= DateTime.SpecifyKind(new DateTime(2020, 06, 19, 9, 0, 0), DateTimeKind.Utc);

/// <summary>
/// Survey end date. (2023/01/01 00:00 JST 以降は調査期間外)
/// </summary>
public static readonly DateTime SURVEY_END_DATE_UTC
= new DateTimeOffset(2022, 12, 31, 23, 59, 59, new TimeSpan(9, 0, 0)).UtcDateTime;

/// <summary>
/// Japan Standard Time (JST), UTC +9
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions Covid19Radar/Covid19Radar/Common/DateTimeUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ namespace Covid19Radar.Common
public interface IDateTimeUtility
{
public DateTime UtcNow { get; }
public DateTime JstNow { get; }
}

public class DateTimeUtility : IDateTimeUtility
{
public DateTime UtcNow => DateTime.UtcNow;
public DateTime JstNow => Utils.JstNow();
}
}
3 changes: 3 additions & 0 deletions Covid19Radar/Covid19Radar/Common/PreferenceKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public static class PreferenceKey
public const string DailySummaries = "DailySummaries";
public const string ExposureWindows = "ExposureWindows";

public const string EndOfServiceNotificationNextSchedule = "EndOfServiceNotificationNextSchedule";
public const string EndOfServiceNotificationCount = "EndOfServiceNotificationCount";

// for ExposureConfigurationRepository
public const string IsDiagnosisKeysDataMappingConfigurationUpdated = "IsDiagnosisKeysDataMappingConfigurationUpdated";
public const string ExposureConfigurationDownloadedEpoch = "ExposureConfigurationDownloadedEpoch";
Expand Down
63 changes: 63 additions & 0 deletions Covid19Radar/Covid19Radar/Repository/UserDataRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ public interface IUserDataRepository
Task<long> GetLastProcessDiagnosisKeyTimestampAsync(string region);
Task SetLastProcessDiagnosisKeyTimestampAsync(string region, long timestamp);
Task RemoveLastProcessDiagnosisKeyTimestampAsync();

// for End of service
void SetEndOfServiceNotificationNextSchedule(DateTime nextScheduleDateTime);
DateTime? GetEndOfServiceNotificationNextSchedule();

void SetEndOfServiceNotificationCount(int count);
int GetEndOfServiceNotificationCount();

void RemoveAllOfEndOfServiceInformation();

// Remove all
void RemoveAll();
}

public class UserDataRepository : IUserDataRepository
Expand Down Expand Up @@ -261,5 +273,56 @@ public void RemoveAllExposureNotificationStatus()
_preferencesService.RemoveValue(PreferenceKey.LastConfirmedDateTimeEpoch);
_loggerService.EndMethod();
}

public void SetEndOfServiceNotificationNextSchedule(DateTime nextSchedule)
{
_loggerService.StartMethod();
_preferencesService.SetLongValue(PreferenceKey.EndOfServiceNotificationNextSchedule, nextSchedule.ToUnixEpoch());
_loggerService.EndMethod();
}

public DateTime? GetEndOfServiceNotificationNextSchedule()
{
_loggerService.StartMethod();
DateTime? nextSchedule = null;
try
{
if (_preferencesService.ContainsKey(PreferenceKey.EndOfServiceNotificationNextSchedule))
{
long epoch = _preferencesService.GetLongValue(PreferenceKey.EndOfServiceNotificationNextSchedule, 0L);
nextSchedule = DateTime.UnixEpoch.AddSeconds(epoch);
}
}
finally
{
_loggerService.EndMethod();
}
return nextSchedule;
}

public void SetEndOfServiceNotificationCount(int count)
{
_preferencesService.SetIntValue(PreferenceKey.EndOfServiceNotificationCount, count);
}

public int GetEndOfServiceNotificationCount()
{
return _preferencesService.GetIntValue(PreferenceKey.EndOfServiceNotificationCount, 0); ;
}

public void RemoveAllOfEndOfServiceInformation()
{
_preferencesService.RemoveValue(PreferenceKey.EndOfServiceNotificationNextSchedule);
_preferencesService.RemoveValue(PreferenceKey.EndOfServiceNotificationCount);
}

public void RemoveAll()
{
RemoveLastProcessDiagnosisKeyTimestampAsync();
RemoveStartDate();
RemoveAllUpdateDate();
RemoveAllExposureNotificationStatus();
RemoveAllOfEndOfServiceInformation();
}
}
}
11 changes: 1 addition & 10 deletions Covid19Radar/Covid19Radar/Resources/AppResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions Covid19Radar/Covid19Radar/Resources/AppResources.ja.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1007,13 +1007,9 @@
<value>新型コロナウイルス感染症の陽性登録者と接触した可能性があります。タップして詳細を確認してください。</value>
<comment>新型コロナウイルス感染症の陽性登録者と接触した可能性があります。タップして詳細を確認してください。</comment>
</data>
<data name="EndOfServiceNotificationTitle" xml:space="preserve">
<value>サービス終了のお知らせ</value>
<comment>サービス終了のお知らせ</comment>
</data>
<data name="EndOfServiceNotificationContent" xml:space="preserve">
<value>接触確認アプリ「COCOA」は2022年◯月◯日をもってサービスを終了します。</value>
<comment>接触確認アプリ「COCOA」は2022年◯月◯日をもってサービスを終了します。</comment>
<value>2022年◯月をもってCOCOAは機能を停止しました。アプリを開いて機能停止手続きを行ってください。</value>
<comment>2022年◯月をもってCOCOAは機能を停止しました。アプリを開いて機能停止手続きを行ってください。</comment>
</data>
<data name="WebAccessibilityPolicyPageTitle" xml:space="preserve">
<value>ウェブアクセシビリティ方針</value>
Expand Down
8 changes: 2 additions & 6 deletions Covid19Radar/Covid19Radar/Resources/AppResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1107,13 +1107,9 @@ You do not have to request it yourself.</value>
<value>It is possible you have been in close proximity to a user who tested positive for COVID-19. Tap for more details.</value>
<comment>新型コロナウイルス感染症の陽性登録者と接触した可能性があります。タップして詳細を確認してください。</comment>
</data>
<data name="EndOfServiceNotificationTitle" xml:space="preserve">
<value>TODO</value>
<comment>サービス終了のお知らせ</comment>
</data>
<data name="EndOfServiceNotificationContent" xml:space="preserve">
<value>TODO</value>
<comment>接触確認アプリ「COCOA」は2022年◯月◯日をもってサービスを終了します。</comment>
<value>COCOA service is no longer available since ○ 2022. Please open the app to complete the termination procedure.</value>
<comment>2022年◯月をもってCOCOAは機能を停止しました。アプリを開いて機能停止手続きを行ってください。</comment>
</data>
<data name="WebAccessibilityPolicyPageTitle" xml:space="preserve">
<value>Web accessibility policy</value>
Expand Down
8 changes: 2 additions & 6 deletions Covid19Radar/Covid19Radar/Resources/AppResources.zh-Hans.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1010,13 +1010,9 @@
<value>您可能接触过感染新型冠状病毒的阳性登记者。点击查看详细信息。</value>
<comment>新型コロナウイルス感染症の陽性登録者と接触した可能性があります。タップして詳細を確認してください。</comment>
</data>
<data name="EndOfServiceNotificationTitle" xml:space="preserve">
<value>TODO</value>
<comment>サービス終了のお知らせ</comment>
</data>
<data name="EndOfServiceNotificationContent" xml:space="preserve">
<value>TODO</value>
<comment>接触確認アプリ「COCOA」は2022年◯月◯日をもってサービスを終了します。</comment>
<value>COCOA已于2022年○月停止运作。请打开应用来完成功能终止手续。</value>
<comment>2022年◯月をもってCOCOAは機能を停止しました。アプリを開いて機能停止手続きを行ってください。</comment>
</data>
<data name="WebAccessibilityPolicyPageTitle" xml:space="preserve">
<value>网页无障碍访问政策</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public abstract class AbsExposureDetectionBackgroundService : IBackgroundService
private readonly ILocalPathService _localPathService;
private readonly IDateTimeUtility _dateTimeUtility;
private readonly ILocalNotificationService _localNotificationService;
private readonly IEndOfServiceNotificationService _endOfServiceNotificationService;

private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);

Expand All @@ -41,7 +42,8 @@ public AbsExposureDetectionBackgroundService(
IServerConfigurationRepository serverConfigurationRepository,
ILocalPathService localPathService,
IDateTimeUtility dateTimeUtility,
ILocalNotificationService localNotificationService
ILocalNotificationService localNotificationService,
IEndOfServiceNotificationService endOfServiceNotificationService
)
{
_diagnosisKeyRepository = diagnosisKeyRepository;
Expand All @@ -53,6 +55,7 @@ ILocalNotificationService localNotificationService
_localPathService = localPathService;
_dateTimeUtility = dateTimeUtility;
_localNotificationService = localNotificationService;
_endOfServiceNotificationService = endOfServiceNotificationService;
}

public abstract void Schedule();
Expand Down Expand Up @@ -243,13 +246,6 @@ private bool CheckMaxPerDayExposureDetectionAPILimitReached(ENException ex)
}

public virtual async Task ShowEndOfServiceNotificationAync(CancellationTokenSource cancellationTokenSource = null)
{
_loggerService.StartMethod();
if (_userDataRepository.IsAllAgreed())
{
await _localNotificationService.ShowEndOfServiceNoticationAsync();
}
_loggerService.EndMethod();
}
=> await _endOfServiceNotificationService.ShowNotificationAsync(cancellationTokenSource);
}
}
Loading