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

デバッグページの追加 #362

Merged
merged 59 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
18a443d
add debugpage
i-maruyama May 12, 2021
9fa6fac
StopAsyncの bug-fix #167
i-maruyama May 13, 2021
92fb986
new for issue#160
i-maruyama May 14, 2021
e64ffbe
Revert "add debugpage"
i-maruyama May 14, 2021
8ebb270
Merge branch 'master' of https://github.com/i-maruyama/cocoa
i-maruyama May 14, 2021
c22df7f
issue#160 (simple debugpage)
i-maruyama May 14, 2021
cc4b4a4
Merge remote-tracking branch 'origin/issue#167' into issue#179
i-maruyama May 14, 2021
47f32e3
Update Covid19Radar/Covid19Radar/ViewModels/HomePage/DebugPageViewMod…
i-maruyama May 14, 2021
baa112f
Update Covid19Radar/Covid19Radar/ViewModels/HomePage/DebugPageViewMod…
i-maruyama May 14, 2021
516d974
Update Covid19Radar/Covid19Radar/ViewModels/HomePage/DebugPageViewMod…
i-maruyama May 14, 2021
adc6bfe
Update Covid19Radar/Covid19Radar/ViewModels/HomePage/DebugPageViewMod…
i-maruyama May 14, 2021
77209c1
refactoring and delete unused services
i-maruyama May 14, 2021
e9bd943
change name of variables
i-maruyama May 14, 2021
239f33c
Update Covid19Radar/Covid19Radar/ViewModels/HomePage/DebugPageViewMod…
i-maruyama May 15, 2021
39e03a3
follow VisualStudio's advice. c.f.: https://github.com/cocoa-mhlw/coc…
i-maruyama May 15, 2021
1847252
comment on the issue#179
i-maruyama May 15, 2021
3857b4a
`Release` ビルド時にデバッグページを除外して容量を削減する
Takym May 16, 2021
b8f90a3
XAMLファイルが正しく除外されていなかったので修正した
Takym May 16, 2021
9273bcb
git mv HomePage/... Settings/ c.f.: https://github.com/cocoa-mhlw/co…
i-maruyama May 16, 2021
80128f5
Info への変更
i-maruyama May 16, 2021
b4e26e2
add diagnosis submittion test. (Note: ExposureNotificationHandler.cs …
i-maruyama May 16, 2021
7d64bc3
Update Covid19Radar/Covid19Radar/ViewModels/Settings/DebugPageViewMod…
i-maruyama May 16, 2021
4f594a2
Update Covid19Radar/Covid19Radar/ViewModels/Settings/DebugPageViewMod…
i-maruyama May 16, 2021
8fbbc10
Update Covid19Radar/Covid19Radar/ViewModels/Settings/DebugPageViewMod…
i-maruyama May 16, 2021
9836582
revert change for ExposureNotificationHandler.cs
i-maruyama May 16, 2021
f26eb3d
コードのクリンナップ
i-maruyama May 17, 2021
aad8f40
ready for PR
i-maruyama May 17, 2021
2185ec7
Merge pull request #1 from Takym/refactoring/issue-160
i-maruyama May 25, 2021
857bc1c
directory name fix
i-maruyama May 25, 2021
da3f2c1
Revert "directory name fix"
i-maruyama May 26, 2021
051ab33
commit only Covid19Radar.csproj
i-maruyama May 26, 2021
243a3d3
Merge branch 'cocoa-mhlw:develop' into issue#160
i-maruyama Jun 7, 2021
de97c2e
use GetExposureCountToDisplay.
i-maruyama Jun 7, 2021
0bda3cf
Merge branch 'cocoa-mhlw:develop' into issue#160
i-maruyama Jun 9, 2021
f1732f6
Merge branch 'cocoa-mhlw:develop' into issue#179
i-maruyama Jun 9, 2021
2cc27b2
Update Covid19Radar/Covid19Radar/Services/HttpDataServiceMock.cs
i-maruyama Jun 11, 2021
de4627c
Update Covid19Radar/Covid19Radar/Services/HttpDataServiceMock.cs
i-maruyama Jun 11, 2021
fef66ce
Update Covid19Radar/Covid19Radar/Services/HttpDataServiceMock.cs
i-maruyama Jun 11, 2021
8b7f5cd
Update Covid19Radar/Covid19Radar/Services/HttpDataServiceMock.cs
i-maruyama Jun 11, 2021
af2e8f0
Update Covid19Radar/Covid19Radar/Services/TestNativeImplementation.cs
i-maruyama Jun 11, 2021
54296fd
Update Covid19Radar/Covid19Radar/Services/TestNativeImplementation.cs
i-maruyama Jun 11, 2021
91b4e2b
Update Covid19Radar/Covid19Radar/Services/TestNativeImplementation.cs
i-maruyama Jun 11, 2021
d40ac67
changed for review (before making common class)
i-maruyama Jun 11, 2021
376bb93
add class MockCommonUtils
i-maruyama Jun 20, 2021
3fc9024
review by @keiji https://github.com/cocoa-mhlw/cocoa/pull/191#pullreq…
i-maruyama Jun 25, 2021
7badb06
remove static, etc. suggested by https://github.com/cocoa-mhlw/cocoa…
i-maruyama Jul 3, 2021
844b684
Merge pull request #191 from i-maruyama/issue#179
keiji Jul 5, 2021
489700c
Merge branch 'feature/debug_page' of github.com:cocoa-mhlw/cocoa into…
keiji Sep 2, 2021
24be80f
Merge pull request #2 from keiji/issue#160
i-maruyama Sep 2, 2021
5dbdf98
Merge pull request #178 from i-maruyama/issue#160
keiji Sep 2, 2021
934eea5
Merge branch 'develop' of github.com:cocoa-mhlw/cocoa into feature/de…
keiji Sep 2, 2021
912b7e7
Fix build.
keiji Sep 2, 2021
5ea906f
All lastProcessTekTimestamps will be shown.
keiji Sep 2, 2021
be61905
Refactoring.
keiji Sep 2, 2021
28a82e9
Fix NPE when offline.
keiji Sep 4, 2021
d1db43c
Refactoring.
keiji Sep 4, 2021
91ca179
Merge pull request #351 from keiji/refactoring_debug_page
keiji Sep 4, 2021
b387742
Support Hot-reload on build configuration DEBUG.
keiji Sep 7, 2021
7c72b47
Merge branch 'hot_reload_debug' into feature/debug_page
keiji Sep 8, 2021
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
5 changes: 3 additions & 2 deletions Covid19Radar/Covid19Radar.Android/Covid19Radar.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
<AndroidKeyStore>false</AndroidKeyStore>
<AndroidUseAapt2>true</AndroidUseAapt2>
<EmbedAssembliesIntoApk>false</EmbedAssembliesIntoApk>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<MandroidI18n>CJK</MandroidI18n>
<AndroidSupportedAbis>armeabi-v7a;x86;x86_64;arm64-v8a</AndroidSupportedAbis>
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
Expand Down Expand Up @@ -112,12 +112,13 @@
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<AndroidUseSharedRuntime>true</AndroidUseSharedRuntime>
<EmbedAssembliesIntoApk>false</EmbedAssembliesIntoApk>
<AndroidUseAapt2>true</AndroidUseAapt2>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<AndroidPackageFormat>apk</AndroidPackageFormat>
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
<MandroidI18n>CJK</MandroidI18n>
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
<AndroidLinkMode>None</AndroidLinkMode>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Android" />
Expand Down
3 changes: 3 additions & 0 deletions Covid19Radar/Covid19Radar/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry)
containerRegistry.RegisterForNavigation<NavigationPage>();
containerRegistry.RegisterForNavigation<MenuPage>();
containerRegistry.RegisterForNavigation<HomePage>();
#if DEBUG
containerRegistry.RegisterForNavigation<DebugPage>();
#endif

// Settings
containerRegistry.RegisterForNavigation<SettingsPage>();
Expand Down
5 changes: 5 additions & 0 deletions Covid19Radar/Covid19Radar/Covid19Radar.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,9 @@
<ItemGroup>
<ProjectReference Include="..\Xamarin.ExposureNotification\Xamarin.ExposureNotification.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)'=='Release'">
<Compile Remove="ViewModels/Settings/DebugPageViewModel.cs" />
<Compile Remove="Views/Settings/DebugPage.xaml.cs" />
<EmbeddedResource Remove="Views/Settings/DebugPage.xaml" />
</ItemGroup>
</Project>
132 changes: 125 additions & 7 deletions Covid19Radar/Covid19Radar/Services/HttpDataServiceMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,43 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

using Covid19Radar.Model;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using System.Linq;
using System.Net.Http;
using Covid19Radar.Common;
using Newtonsoft.Json;

namespace Covid19Radar.Services
{
class HttpDataServiceMock : IHttpDataService
{
private readonly HttpClient downloadClient;
private readonly MockCommonUtils mockCommonUtils = new MockCommonUtils();

public HttpDataServiceMock(IHttpClientService httpClientService)
{
downloadClient = httpClientService.Create();
}

// copy from ./HttpDataService.cs
private async Task<string> GetCdnAsync(string url, CancellationToken cancellationToken)
{
HttpResponseMessage result = await downloadClient.GetAsync(url, cancellationToken);
await result.Content.ReadAsStringAsync();

if (result.StatusCode == System.Net.HttpStatusCode.OK)
{
return await result.Content.ReadAsStringAsync();
}
return null;
}

public Task MigrateFromUserData(UserDataModel userData)
{
return Task.CompletedTask;
Expand All @@ -37,27 +63,119 @@ Task<Stream> IHttpDataService.GetTemporaryExposureKey(string url, CancellationTo
});
}

Task<List<TemporaryExposureKeyExportFileModel>> IHttpDataService.GetTemporaryExposureKeyList(string region, CancellationToken cancellationToken)
private TemporaryExposureKeyExportFileModel CreateTestData(long created)
{
return Task.Factory.StartNew<List<TemporaryExposureKeyExportFileModel>>(() =>
return new TemporaryExposureKeyExportFileModel()
{
Debug.WriteLine("HttpDataServiceMock::GetTemporaryExposureKeyList called");
return new List<TemporaryExposureKeyExportFileModel>();
});
Region = "440",
Url = "testUrl",
Created = created
};
}

private long CalcTimeAddDays(int day)
=> new DateTimeOffset(DateTime.UtcNow.AddDays(day)).ToUnixTimeMilliseconds();

private long CalcMidnightTimeAddDays(int day)
{
DateTime d = DateTime.UtcNow.AddDays(day);
// set 0 hour,1 min,2 sec,3 millisecond for debug
return new DateTimeOffset(new DateTime(d.Year, d.Month, d.Day, 0, 1, 2, 3)).ToUnixTimeMilliseconds();
}

enum PresetTekListType // PresetTekListData for Tek List
{
Nothing = 0, //nothing (default for v1.2.3)
RealTime = 1, // real time
MidnightTime = 2, // last night
// please add "YourDataType = <int>"
}

private List<TemporaryExposureKeyExportFileModel> PresetTekListData(int dataVersion)
{
switch ((PresetTekListType)dataVersion)
{
case PresetTekListType.MidnightTime:
return new List<TemporaryExposureKeyExportFileModel> { CreateTestData(CalcMidnightTimeAddDays(-1)), CreateTestData(CalcMidnightTimeAddDays(0)) };
case PresetTekListType.RealTime:
return new List<TemporaryExposureKeyExportFileModel> { CreateTestData(CalcTimeAddDays(-1)), CreateTestData(CalcTimeAddDays(0)) };
case PresetTekListType.Nothing:
default:
return new List<TemporaryExposureKeyExportFileModel>();
}
}

async Task<List<TemporaryExposureKeyExportFileModel>> IHttpDataService.GetTemporaryExposureKeyList(string region, CancellationToken cancellationToken)
{
/* CdnUrlBase trick for Debug_Mock
"https://www.example.com/"(url with 2+ periods) -> download "url"+"c19r/440/list.json". IsDownloadRequired
"1598022036649,1598022036751,1598022036826" -> direct input timestamps. IsDirectInput
"https://CDN_URL_BASE/2" -> dataVersion = 2
"https://CDN_URL_BASE/" -> dataVersion = 0 (default)
*/
//string url = AppSettings.Instance.CdnUrlBase;
if (mockCommonUtils.IsDownloadRequired())
{
// copy from GetTemporaryExposureKeyList @ ./HttpDataService.cs and delete logger part
var container = AppSettings.Instance.BlobStorageContainerName;
var urlJson = AppSettings.Instance.CdnUrlBase + $"{container}/{region}/list.json";
var result = await GetCdnAsync(urlJson, cancellationToken);
if (result != null)
{
Debug.WriteLine("HttpDataServiceMock::GetTemporaryExposureKeyList downloaded");
return JsonConvert.DeserializeObject<List<TemporaryExposureKeyExportFileModel>>(result);
}
else
{
Debug.WriteLine("HttpDataServiceMock::GetTemporaryExposureKeyList download failed");
return new List<TemporaryExposureKeyExportFileModel>();
}
}
else if (mockCommonUtils.IsDirectInput())
{
Debug.WriteLine("HttpDataServiceMock::GetTemporaryExposureKeyList direct data called");
return (mockCommonUtils.GetCreatedTimes().Select(x => CreateTestData(Convert.ToInt64(x))).ToList());
}
else
{
Debug.WriteLine("HttpDataServiceMock::GetTemporaryExposureKeyList preset data called");
return PresetTekListData(mockCommonUtils.GetTekListDataType());
}
}


async Task<bool> IHttpDataService.PostRegisterUserAsync()
{
Debug.WriteLine("HttpDataServiceMock::PostRegisterUserAsync called");
return await Task.FromResult(true);
var result = mockCommonUtils.GetRegisterDataType() switch
{
1 => false,
_ => true
};
return await Task.FromResult(result);
}

Task<HttpStatusCode> IHttpDataService.PutSelfExposureKeysAsync(DiagnosisSubmissionParameter request)
{
var code = HttpStatusCode.OK; // default. for PutSelfExposureKeys NG
var dataType = mockCommonUtils.GetDiagnosisDataType();
if (dataType >= 100) // HttpStatusCode >=100 by RFC2616#section-10
{
code = (HttpStatusCode)dataType;
}
else
{
switch (dataType)
{
case 1:
code = HttpStatusCode.NoContent; // for Successful PutSelfExposureKeys
break;
}
}
return Task.Factory.StartNew<HttpStatusCode>(() =>
{
Debug.WriteLine("HttpDataServiceMock::PutSelfExposureKeysAsync called");
return HttpStatusCode.OK;
return code;
});
}

Expand Down
Loading