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

Commit

Permalink
Fixed configuration instructed by apple
Browse files Browse the repository at this point in the history
Fixed to call getExposureInfo when HighestRiskScore is greater than or equal to MinimumRiskScore

Added unit test project

Removed code-sign and provisioning setting for development
  • Loading branch information
cocoa-dev committed Sep 18, 2020
1 parent 868e291 commit 20f3e8c
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 15 deletions.
33 changes: 33 additions & 0 deletions Covid19Radar.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Covid19Radar.UITest", "Covi
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xamarin.ExposureNotification", "Covid19Radar\Xamarin.ExposureNotification\Xamarin.ExposureNotification.csproj", "{83AF4C2E-22F8-4DAB-B993-BE6ABB3E56A1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Covid19Radar.UnitTests", "Covid19Radar\Tests\Covid19Radar.UnitTests\Covid19Radar.UnitTests.csproj", "{464E6973-C26D-45DF-808D-D89F9F7BFCA7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
Expand Down Expand Up @@ -197,12 +199,43 @@ Global
{83AF4C2E-22F8-4DAB-B993-BE6ABB3E56A1}.Release|iPhone.Build.0 = Release|Any CPU
{83AF4C2E-22F8-4DAB-B993-BE6ABB3E56A1}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{83AF4C2E-22F8-4DAB-B993-BE6ABB3E56A1}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.AppStore|iPhone.Build.0 = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Debug_Mock|Any CPU.ActiveCfg = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Debug_Mock|Any CPU.Build.0 = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Debug_Mock|iPhone.ActiveCfg = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Debug_Mock|iPhone.Build.0 = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Debug_Mock|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Debug_Mock|iPhoneSimulator.Build.0 = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Debug|iPhone.Build.0 = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Release|Any CPU.Build.0 = Release|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Release|iPhone.ActiveCfg = Release|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Release|iPhone.Build.0 = Release|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{464E6973-C26D-45DF-808D-D89F9F7BFCA7}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{4223EE63-A661-4465-BBB0-08DD80DB2256} = {460BECFC-7B47-437D-9CD5-BE798977C454}
{464E6973-C26D-45DF-808D-D89F9F7BFCA7} = {460BECFC-7B47-437D-9CD5-BE798977C454}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CC497516-FC1C-4A98-B519-9BB1F37D84DA}
Expand Down
6 changes: 2 additions & 4 deletions Covid19Radar/Covid19Radar.iOS/Covid19Radar.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
<MtouchArch>x86_64</MtouchArch>
<MtouchLink>SdkOnly</MtouchLink>
<MtouchDebug>true</MtouchDebug>
<CodesignKey>Apple Development: Hirose Kazumi (B5NUWQDLW4)</CodesignKey>
<CodesignProvision>Covid19radar</CodesignProvision>
<CodesignKey>iPhone Developer</CodesignKey>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<LangVersion>latest</LangVersion>
<MtouchExtraArgs>--optimize=experimental-xforms-product-type --weak-framework=ExposureNotification</MtouchExtraArgs>
Expand Down Expand Up @@ -59,12 +58,11 @@
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<MtouchArch>ARM64</MtouchArch>
<CodesignKey>Apple Development: Hirose Kazumi (B5NUWQDLW4)</CodesignKey>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchDebug>true</MtouchDebug>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<IOSDebugOverWiFi>true</IOSDebugOverWiFi>
<IOSDebugOverWiFi>true</IOSDebugOverWiFi>
<CodesignProvision>Covid19radar</CodesignProvision>
<MtouchExtraArgs>--optimize=experimental-xforms-product-type --weak-framework=ExposureNotification</MtouchExtraArgs>
<MtouchEnableSGenConc>true</MtouchEnableSGenConc>
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
Expand Down
29 changes: 18 additions & 11 deletions Covid19Radar/Covid19Radar/Services/ExposureNotificationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ public Task<Configuration> GetConfigurationAsync()

configuration = new Configuration
{
MinimumRiskScore = 1,
MinimumRiskScore = 21,
AttenuationWeight = 50,
TransmissionWeight = 50,
DurationWeight = 50,
DaysSinceLastExposureWeight = 50,
TransmissionRiskScores = new int[] { 7, 7, 7, 7, 7, 7, 7, 7 },
AttenuationScores = new[] { 0, 0, 0, 0, 1, 1, 1, 1 },
AttenuationScores = new[] { 1, 2, 3, 4, 5, 6, 7, 8 },
DurationScores = new[] { 0, 0, 0, 0, 1, 1, 1, 1 },
DaysSinceLastExposureScores = new[] { 1, 1, 1, 1, 1, 1, 1, 1 },
DurationAtAttenuationThresholds = new[] { 50, 70 }
Expand All @@ -72,19 +72,26 @@ public async Task ExposureDetectedAsync(ExposureDetectionSummary summary, Func<T

UserExposureSummary userExposureSummary = new UserExposureSummary(summary.DaysSinceLastExposure, summary.MatchedKeyCount, summary.HighestRiskScore, summary.AttenuationDurations, summary.SummationRiskScore);
userData.ExposureSummary = userExposureSummary;
var exposureInfo = await getExposureInfo();

// Add these on main thread in case the UI is visible so it can update
await Device.InvokeOnMainThreadAsync(() =>
var config = await GetConfigurationAsync();

if (userData.ExposureSummary.HighestRiskScore >= config.MinimumRiskScore)
{
foreach (var exposure in exposureInfo)
var exposureInfo = await getExposureInfo();

// Add these on main thread in case the UI is visible so it can update
await Device.InvokeOnMainThreadAsync(() =>
{
Debug.WriteLine($"C19R found exposure {exposure.Timestamp}");
foreach (var exposure in exposureInfo)
{
Debug.WriteLine($"C19R found exposure {exposure.Timestamp}");
UserExposureInfo userExposureInfo = new UserExposureInfo(exposure.Timestamp, exposure.Duration, exposure.AttenuationValue, exposure.TotalRiskScore, (Covid19Radar.Model.UserRiskLevel)exposure.TransmissionRiskLevel);
userData.ExposureInformation.Add(userExposureInfo);
}
});
}

UserExposureInfo userExposureInfo = new UserExposureInfo(exposure.Timestamp, exposure.Duration, exposure.AttenuationValue, exposure.TotalRiskScore, (Covid19Radar.Model.UserRiskLevel)exposure.TransmissionRiskLevel);
userData.ExposureInformation.Add(userExposureInfo);
}
});
await userDataService.SetAsync(userData);

// If Enabled Local Notifications
Expand Down
25 changes: 25 additions & 0 deletions Covid19Radar/Tests/Covid19Radar.UnitTests/AppSettingsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Xunit;

namespace Covid19Radar.UnitTests
{
public class AppSettingsTests
{
[Fact]
public void SettingsTests()
{
var settings = new AppSettings();
Assert.Equal("APP_VERSION", settings.AppVersion);
Assert.Equal("API_SECRET", settings.ApiSecret);
Assert.Equal("https://API_URL_BASE/api", settings.ApiUrlBase);
Assert.Single(settings.SupportedRegions);
Assert.Equal("440", settings.SupportedRegions[0]);
Assert.Equal("c19r", settings.BlobStorageContainerName);
Assert.Equal("ANDROID_SAFETYNETKEY", settings.AndroidSafetyNetApiKey);
Assert.Equal("https://CDN_URL_BASE/", settings.CdnUrlBase);
Assert.Equal("https://covid19radarjpnprod.z11.web.core.windows.net/license.html", settings.LicenseUrl);
Assert.Equal("https://itunes.apple.com/jp/app/id1516764458?mt=8", settings.AppStoreUrl);
Assert.Equal("https://play.google.com/store/apps/details?id=jp.go.mhlw.covid19radar", settings.GooglePlayUrl);
Assert.Equal("SUPPORT_EMAIL", settings.SupportEmail);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.2.0" />
<PackageReference Include="Moq" Version="4.14.5" />
<PackageReference Include="Microsoft.CodeCoverage" Version="16.7.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Covid19Radar\Covid19Radar.csproj" />
</ItemGroup>
</Project>

0 comments on commit 20f3e8c

Please sign in to comment.