Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mismatched that ExposureInformation.AttenuationDuration unit #41

Merged
merged 1 commit into from
Jun 10, 2021
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
6 changes: 5 additions & 1 deletion Chino.Android/ExposureInformation.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using Newtonsoft.Json;
using AndroidExposureInformation = Android.Gms.Nearby.ExposureNotification.ExposureInformation;

Expand All @@ -16,7 +17,7 @@ public ExposureInformation(AndroidExposureInformation source)
Source = source;
}

public int[] AttenuationDurationsInMinutes => Source.GetAttenuationDurationsInMinutes();
public int[] AttenuationDurationsInMillis => ConvertToMillis(Source.GetAttenuationDurationsInMinutes());

public int AttenuationValue => Source.AttenuationValue;

Expand All @@ -27,5 +28,8 @@ public ExposureInformation(AndroidExposureInformation source)
public int TotalRiskScore => Source.TotalRiskScore;

public RiskLevel TransmissionRiskLevel => (RiskLevel)Enum.ToObject(typeof(RiskLevel), Source.TransmissionRiskLevel);

private static int[] ConvertToMillis(int[] attenuationDurationsInMinutes)
=> attenuationDurationsInMinutes.Select(d => d * 60 * 1000).ToArray();
}
}
4 changes: 2 additions & 2 deletions Chino.Common/IExposureInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
public interface IExposureInformation
{
/// <summary>
/// Array of durations in minutes at certain radio signal attenuations.
/// Array of durations in milliseconds at certain radio signal attenuations.
/// </summary>
public int[] AttenuationDurationsInMinutes { get; }
public int[] AttenuationDurationsInMillis { get; }

/// <summary>
/// The time-weighted signal strength attenuation value which goes into getTotalRiskScore().
Expand Down
6 changes: 5 additions & 1 deletion Chino.iOS/ExposureInformation.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using ExposureNotifications;
using Newtonsoft.Json;

Expand All @@ -15,7 +16,7 @@ public ExposureInformation(ENExposureInfo source)
Source = source;
}

public int[] AttenuationDurationsInMinutes => Source.AttenuationDurations;
public int[] AttenuationDurationsInMillis => ConvertToMillis(Source.AttenuationDurations);

public int AttenuationValue => Source.AttenuationValue;

Expand All @@ -26,5 +27,8 @@ public ExposureInformation(ENExposureInfo source)
public int TotalRiskScore => Source.TotalRiskScore;

public RiskLevel TransmissionRiskLevel => (RiskLevel)Enum.ToObject(typeof(RiskLevel), Source.TransmissionRiskLevel);

private static int[] ConvertToMillis(int[] attenuationDurations)
=> attenuationDurations.Select(d => d * 1000).ToArray();
}
}