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

Commit

Permalink
Merge branch 'develop' of github.com:cocoa-mhlw/cocoa into improve_lo…
Browse files Browse the repository at this point in the history
…g_share
  • Loading branch information
keiji committed Feb 17, 2022
2 parents 9f4894f + f6a5d98 commit 7881682
Show file tree
Hide file tree
Showing 160 changed files with 3,316 additions and 1,360 deletions.
23 changes: 5 additions & 18 deletions Covid19Radar/Covid19Radar.Android/Assets/license.html
Original file line number Diff line number Diff line change
Expand Up @@ -1167,25 +1167,12 @@ <h2>
SOFTWARE.</p>
<hr>
<h2>
<a id="user-content-xamarin-exposure-notification" class="anchor" href="#xamarin-exposure-notification" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Xamarin Exposure Notification</h2>
<a id="user-content-cappuccino" class="anchor" href="#cappuccino" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Cappuccino</h2>
<hr>
<p>MIT License</p>
<p>Copyright (c) Microsoft Corporation.</p>
<p>Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:</p>
<p>The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.</p>
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE</p>
<p>Copyright 2021 Cappuccino Authors</p>
<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
<hr>
<h2>
<a id="user-content-ffimageloading" class="anchor" href="#ffimageloading" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>FFImageLoading</h2>
Expand Down
6 changes: 0 additions & 6 deletions Covid19Radar/Covid19Radar.Android/Covid19Radar.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,6 @@
<ItemGroup>
<AndroidResource Include="Resources\drawable-xhdpi\TutorialPage40.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-xhdpi\TutorialPage50.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-xhdpi\TutorialPage60.png" />
</ItemGroup>
Expand Down Expand Up @@ -536,9 +533,6 @@
<ItemGroup>
<AndroidResource Include="Resources\drawable-xxhdpi\TutorialPage40.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-xxhdpi\TutorialPage50.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-xxhdpi\TutorialPage60.png" />
</ItemGroup>
Expand Down
14 changes: 12 additions & 2 deletions Covid19Radar/Covid19Radar.Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private void FireExposureNotificationEvent(int requestCode, bool isOk)
ExposureNotificationApiService.REQUEST_EN_START
=> new Action<IExposureNotificationEventCallback>(callback =>
{
if(isOk)
if (isOk)
{
callback.OnEnabled();
}
Expand All @@ -170,7 +170,17 @@ private void FireExposureNotificationEvent(int requestCode, bool isOk)
}
}),
ExposureNotificationApiService.REQUEST_GET_TEK_HISTORY
=> new Action<IExposureNotificationEventCallback>(callback => { callback.OnGetTekHistoryAllowed(); }),
=> new Action<IExposureNotificationEventCallback>(callback =>
{
if (isOk)
{
callback.OnGetTekHistoryAllowed();
}
else
{
callback.OnGetTekHistoryDecline();
}
}),
ExposureNotificationApiService.REQUEST_PREAUTHORIZE_KEYS
=> new Action<IExposureNotificationEventCallback>(callback => { callback.OnPreauthorizeAllowed(); }),
_ => new Action<IExposureNotificationEventCallback>(callback => { /* do nothing */ }),
Expand Down
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions Covid19Radar/Covid19Radar.Android/Resources/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,7 @@
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">@color/colorAccent</item>
<item name="android:colorAccent">@color/colorAccent</item>
<item name="android:colorControlActivated">@color/colorAccent</item>
</style>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Android.Content;
using Android.Runtime;
using AndroidX.Work;
Expand Down Expand Up @@ -83,9 +85,6 @@ private static PeriodicWorkRequest CreatePeriodicWorkRequest()
[Preserve]
public class BackgroundWorker : Worker
{
private readonly Lazy<AbsExposureNotificationApiService> _exposureNotificationApiService
= new Lazy<AbsExposureNotificationApiService>(() => ContainerLocator.Current.Resolve<AbsExposureNotificationApiService>());

private readonly Lazy<ILoggerService> _loggerService
= new Lazy<ILoggerService>(() => ContainerLocator.Current.Resolve<ILoggerService>());

Expand All @@ -99,19 +98,11 @@ public BackgroundWorker(Context context, WorkerParameters workerParameters)

public override Result DoWork()
{
var exposureNotificationApiService = _exposureNotificationApiService.Value;
var loggerService = _loggerService.Value;
var backgroundService = _backgroundService.Value;

loggerService.StartMethod();

if (!exposureNotificationApiService.IsEnabledAsync().GetAwaiter().GetResult())
{
loggerService.Debug($"EN API is not enabled." +
$" worker will start after {ExposureDetectionBackgroundService.INTERVAL_IN_MINUTES} minutes later.");
return Result.InvokeSuccess();
}

try
{
backgroundService.ExposureDetectionAsync().GetAwaiter().GetResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ public async Task ShowExposureNotificationAsync()
_loggerService.StartMethod();

Intent intent = MainActivity.NewIntent(Platform.AppContext, Destination.ContactedNotifyPage);
intent.AddFlags(ActivityFlags.ClearTask);

PendingIntent pendingIntent = PendingIntent.GetActivity(
Platform.AppContext,
REQUEST_CODE,
intent,
PendingIntentFlags.UpdateCurrent
PendingIntentFlags.CancelCurrent | PendingIntentFlags.Immutable
);

var notification = new NotificationCompat
Expand Down
6 changes: 0 additions & 6 deletions Covid19Radar/Covid19Radar.iOS/Covid19Radar.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -478,12 +478,6 @@
<ItemGroup>
<BundleResource Include="Resources\Base.lproj\TutorialPage40%403x.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\Base.lproj\TutorialPage50%402x.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\Base.lproj\TutorialPage50%403x.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\Base.lproj\TutorialPage60%402x.png" />
</ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion Covid19Radar/Covid19Radar.iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>APP_PACKAGE_NAME.exposure-notification</string>
<string>APP_PACKAGE_NAME.exposure-detection</string>
<string>APP_PACKAGE_NAME.delete-old-logs</string>
</array>
<key>UIAppFonts</key>
Expand Down
Binary file not shown.
Binary file not shown.
23 changes: 5 additions & 18 deletions Covid19Radar/Covid19Radar.iOS/Resources/license.html
Original file line number Diff line number Diff line change
Expand Up @@ -1167,25 +1167,12 @@ <h2>
SOFTWARE.</p>
<hr>
<h2>
<a id="user-content-xamarin-exposure-notification" class="anchor" href="#xamarin-exposure-notification" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Xamarin Exposure Notification</h2>
<a id="user-content-cappuccino" class="anchor" href="#cappuccino" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Cappuccino</h2>
<hr>
<p>MIT License</p>
<p>Copyright (c) Microsoft Corporation.</p>
<p>Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:</p>
<p>The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.</p>
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE</p>
<p>Copyright 2021 Cappuccino Authors</p>
<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
<hr>
<h2>
<a id="user-content-ffimageloading" class="anchor" href="#ffimageloading" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>FFImageLoading</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using BackgroundTasks;
using Chino;
using Covid19Radar.Common;
using Covid19Radar.Repository;
using Covid19Radar.Services;
Expand All @@ -20,14 +17,17 @@ namespace Covid19Radar.iOS.Services
{
public class ExposureDetectionBackgroundService : AbsExposureDetectionBackgroundService
{
private static string BGTASK_IDENTIFIER => AppInfo.PackageName + ".exposure-detection";
/*
* [IMPORTANT]
* From README.md( https://developer.apple.com/documentation/exposurenotification/building_an_app_to_notify_users_of_covid-19_exposure )
*
* The Background Task framework automatically detects apps that contain the Exposure Notification entitlement and a background task that ends in `exposure-notification`.
* The operating system automatically launches these apps when they aren't running and guarantees them more background time to ensure that the app can test and report results promptly.
*/
private static string BGTASK_IDENTIFIER => AppInfo.PackageName + ".exposure-notification";

private const int TIMEOUT_IN_MILLIS = 60 * 60 * 1000;

private readonly AbsExposureNotificationApiService _exposureNotificationApiService;
private readonly ILoggerService _loggerService;


public ExposureDetectionBackgroundService(
IDiagnosisKeyRepository diagnosisKeyRepository,
AbsExposureNotificationApiService exposureNotificationApiService,
Expand All @@ -48,7 +48,6 @@ IDateTimeUtility dateTimeUtility
dateTimeUtility
)
{
_exposureNotificationApiService = exposureNotificationApiService;
_loggerService = loggerService;
}

Expand All @@ -69,18 +68,6 @@ public override void Schedule()
{
try
{
IList<ExposureNotificationStatus> statuses = _exposureNotificationApiService.GetStatusesAsync()
.GetAwaiter().GetResult();

bool isUnauthorized = statuses
.Any(status => status.Code == ExposureNotificationStatus.Code_iOS.Unauthorized);
if (isUnauthorized)
{
_loggerService.Error("Exposure notification is not authorized.");
task.SetTaskCompleted(true);
return;
}

await ExposureDetectionAsync(cancellationTokenSource);
task.SetTaskCompleted(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -14,8 +15,9 @@ namespace Covid19Radar.iOS.Services
{
public class ExposureNotificationApiService : AbsExposureNotificationApiService
{
private ExposureNotificationClient _exposureNotificationClient = new ExposureNotificationClient();
private const int MILLISECONDS_TO_WAIT_DISMISSING_ANIMATION = 1000;

private ExposureNotificationClient _exposureNotificationClient = new ExposureNotificationClient();
public string UserExplanation
{
set => _exposureNotificationClient.UserExplanation = value;
Expand All @@ -30,8 +32,18 @@ ILoggerService loggerService
public override Task<IList<ExposureNotificationStatus>> GetStatusesAsync()
=> _exposureNotificationClient.GetStatusesAsync();

public override Task<List<TemporaryExposureKey>> GetTemporaryExposureKeyHistoryAsync()
=> _exposureNotificationClient.GetTemporaryExposureKeyHistoryAsync();
public override async Task<List<TemporaryExposureKey>> GetTemporaryExposureKeyHistoryAsync()
{
try
{
return await _exposureNotificationClient.GetTemporaryExposureKeyHistoryAsync();
}
finally
{
// [workaround] wait for dismissing en permission modal
await Task.Delay(MILLISECONDS_TO_WAIT_DISMISSING_ANIMATION);
}
}

public override Task<long> GetVersionAsync()
=> _exposureNotificationClient.GetVersionAsync();
Expand Down
11 changes: 7 additions & 4 deletions Covid19Radar/Covid19Radar/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry)
containerRegistry.RegisterForNavigation<TutorialPage3>();
containerRegistry.RegisterForNavigation<PrivacyPolicyPage>();
containerRegistry.RegisterForNavigation<TutorialPage4>();
containerRegistry.RegisterForNavigation<TutorialPage5>();
containerRegistry.RegisterForNavigation<TutorialPage6>();

// Help
Expand All @@ -162,7 +161,6 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry)
containerRegistry.RegisterForNavigation<PrivacyPolicyPage2>();
containerRegistry.RegisterForNavigation<InqueryPage>();
containerRegistry.RegisterForNavigation<TermsofservicePage>();
containerRegistry.RegisterForNavigation<ThankYouNotifyOtherPage>();
containerRegistry.RegisterForNavigation<NotifyOtherPage>();
containerRegistry.RegisterForNavigation<ExposureCheckPage>();
containerRegistry.RegisterForNavigation<ContactedNotifyPage>();
Expand Down Expand Up @@ -202,10 +200,10 @@ private static void RegisterCommonTypes(IContainer container)

#if DEBUG
container.Register<IServerConfigurationRepository, DebugServerConfigurationRepository>(Reuse.Singleton);
container.Register<IExposureDataCollectServer, DebugExposureDataCollectServer>(Reuse.Singleton);
container.Register<IDebugExposureDataCollectServer, DebugExposureDataCollectServer>(Reuse.Singleton);
#else
container.Register<IServerConfigurationRepository, ReleaseServerConfigurationRepository>(Reuse.Singleton);
container.Register<IExposureDataCollectServer, ReleaseExposureDataCollectServer>(Reuse.Singleton);
container.Register<IDebugExposureDataCollectServer, DebugExposureDataCollectServerNop>(Reuse.Singleton);
#endif

container.Register<IDiagnosisKeyRegisterServer, DiagnosisKeyRegisterServer>(Reuse.Singleton);
Expand All @@ -216,7 +214,12 @@ private static void RegisterCommonTypes(IContainer container)
container.Register<IDiagnosisKeyRepository, DiagnosisKeyRepository>(Reuse.Singleton);
container.Register<IExposureConfigurationRepository, ExposureConfigurationRepository>(Reuse.Singleton);
container.Register<IExposureRiskCalculationConfigurationRepository, ExposureRiskCalculationConfigurationRepository>(Reuse.Singleton);

#if EVENT_LOG_ENABLED
container.Register<IEventLogService, EventLogService>(Reuse.Singleton);
#else
container.Register<IEventLogService, EventLogServiceNop>(Reuse.Singleton);
#endif

// Utilities
container.Register<IDateTimeUtility, DateTimeUtility>(Reuse.Singleton);
Expand Down
5 changes: 0 additions & 5 deletions Covid19Radar/Covid19Radar/Common/AppConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,5 @@ public static class AppConstants
/// Delay for error in TEK re-registration.
/// </summary>
public const int DelayForRegistrationErrorMillis = 5000;

/// <summary>
///
/// </summary>
public const bool DEFAULT_SEND_EVENT_LOG_ENABLED = true;
}
}
3 changes: 2 additions & 1 deletion Covid19Radar/Covid19Radar/Common/AppUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public static async void CheckVersion(ILoggerService loggerService)
try
{
var json = await client.GetStringAsync(uri);
var versionString = JObject.Parse(json).Value<string>("version");
var key = Device.RuntimePlatform == Device.iOS ? "ios" : "android";
var versionString = JObject.Parse(json).Value<string>(key);

if (new Version(versionString).CompareTo(new Version(AppInfo.VersionString)) > 0)
{
Expand Down
Loading

0 comments on commit 7881682

Please sign in to comment.