Skip to content

Commit

Permalink
Merge pull request #96 from keiji/add_exception_occurred_callback
Browse files Browse the repository at this point in the history
Add ExceptionOccurred callback to ExposureNotificationHandler.
  • Loading branch information
keiji authored Aug 12, 2021
2 parents 73048c0 + 30149bb commit 1e3d181
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 23 deletions.
19 changes: 15 additions & 4 deletions Chino.Android/ExposureStateBroadcastReceiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,15 @@ public override bool OnStartJob(JobParameters @params)
{
if (exception.IsENException())
{
throw exception.ToENException();
var enException = exception.ToENException();
handler.ExceptionOccurred(enException);
throw enException;
}
else
{
handler.ExceptionOccurred(exception);
throw exception;
}
throw exception;
}
finally
{
Expand Down Expand Up @@ -281,9 +287,14 @@ public override bool OnStartJob(JobParameters @params)
{
if (exception.IsENException())
{
throw exception.ToENException();
var enException = exception.ToENException();
handler.ExceptionOccurred(enException);
throw enException;
} else
{
handler.ExceptionOccurred(exception);
throw exception;
}
throw exception;
}
finally
{
Expand Down
29 changes: 25 additions & 4 deletions Chino.Common/IExposureNotificationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface IExposureNotificationHandler
/// <param name="temporaryExposureKeys">List of Temporary Exposure Keys</param>
public void TemporaryExposureKeyReleased(IList<TemporaryExposureKey> temporaryExposureKeys)
{
throw new NotImplementedException();
// do nothing
}

/// <summary>
Expand All @@ -34,7 +34,7 @@ public void PreExposureDetected()
/// <param name="exposureWindows">List of duration of up to 30 minutes during which beacons from a TEK were observed.</param>
public void ExposureDetected(IList<DailySummary> dailySummaries, IList<ExposureWindow> exposureWindows)
{
throw new NotImplementedException();
// do nothing
}

/// <summary>
Expand All @@ -44,12 +44,33 @@ public void ExposureDetected(IList<DailySummary> dailySummaries, IList<ExposureW
/// <param name="exposureInformations">List of information about an exposure.</param>
public void ExposureDetected(ExposureSummary exposureSummary, IList<ExposureInformation> exposureInformations)
{
throw new NotImplementedException();
// do nothing
}

/// <summary>
/// An event of Exposure is not detected.
/// </summary>
public void ExposureNotDetected();
public void ExposureNotDetected()
{
// do nothing
}

/// <summary>
/// An event of Exception is occurred.
/// </summary>
/// <param name="exception">Exception of Exposure Notifications API</param>
public void ExceptionOccurred(ENException exception)
{
// do nothing
}

/// <summary>
/// An event of Exception is occurred.
/// </summary>
/// <param name="exception">General exception</param>
public void ExceptionOccurred(Exception exception)
{
// do nothing
}
}
}
23 changes: 8 additions & 15 deletions Chino.iOS/ExposureNotificationClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,15 @@ public async override Task ProvideDiagnosisKeysAsync(List<string> zippedKeyFiles
{
if (exception.IsENException())
{
throw exception.ToENException();
var enException = exception.ToENException();
Handler.ExceptionOccurred(enException);
throw enException;
}
else
{
Handler.ExceptionOccurred(exception);
throw exception;
}
throw exception;
}
finally
{
Expand All @@ -329,19 +335,6 @@ public async override Task ProvideDiagnosisKeysAsync(List<string> zippedKeyFiles
}
}

private void Print(ENExposureSummaryItem daySummary)
{
if (daySummary == null)
{
return;
}

Logger.D($"ENExposureSummaryItem");
Logger.D($"MaximumScore: {daySummary.MaximumScore}");
Logger.D($"ScoreSum: {daySummary.ScoreSum}");
Logger.D($"WeightedDurationSum: {daySummary.WeightedDurationSum}");
}

[Obsolete]
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member
public override async Task ProvideDiagnosisKeysAsync(List<string> keyFiles, ExposureConfiguration configuration, string token)
Expand Down

0 comments on commit 1e3d181

Please sign in to comment.