diff --git a/Wino.BackgroundTasks/SessionConnectedTask.cs b/Wino.BackgroundTasks/SessionConnectedTask.cs deleted file mode 100644 index cf583956..00000000 --- a/Wino.BackgroundTasks/SessionConnectedTask.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using Windows.ApplicationModel; -using Windows.ApplicationModel.Background; - -namespace Wino.BackgroundTasks -{ - public sealed class SessionConnectedTask : IBackgroundTask - { - public async void Run(IBackgroundTaskInstance taskInstance) - { - var def = taskInstance.GetDeferral(); - - // Run server on session connected by launching the Full Thrust process. - await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync(); - - def.Complete(); - } - } -} diff --git a/Wino.BackgroundTasks/Wino.BackgroundTasks.csproj b/Wino.BackgroundTasks/Wino.BackgroundTasks.csproj index 7f5790f8..27f9ce6e 100644 --- a/Wino.BackgroundTasks/Wino.BackgroundTasks.csproj +++ b/Wino.BackgroundTasks/Wino.BackgroundTasks.csproj @@ -104,7 +104,6 @@ - diff --git a/Wino.Core.Domain/Interfaces/IBackgroundTaskService.cs b/Wino.Core.Domain/Interfaces/IBackgroundTaskService.cs index b6411b32..67142e69 100644 --- a/Wino.Core.Domain/Interfaces/IBackgroundTaskService.cs +++ b/Wino.Core.Domain/Interfaces/IBackgroundTaskService.cs @@ -1,16 +1,7 @@ -using System.Threading.Tasks; - -namespace Wino.Core.Domain.Interfaces +namespace Wino.Core.Domain.Interfaces { public interface IBackgroundTaskService { - /// - /// Manages background task registrations, requests access if needed, checks the statusses of them etc. - /// - /// If the access request is denied for some reason. - /// If one of the requires background tasks are failed during registration. - Task HandleBackgroundTaskRegistrations(); - /// /// Unregisters all existing background tasks. Useful for migrations. /// diff --git a/Wino.Core.UWP/Services/BackgroundTaskService.cs b/Wino.Core.UWP/Services/BackgroundTaskService.cs index 7c9aaee3..990ce40b 100644 --- a/Wino.Core.UWP/Services/BackgroundTaskService.cs +++ b/Wino.Core.UWP/Services/BackgroundTaskService.cs @@ -1,6 +1,4 @@ -using System; -using System.Threading.Tasks; -using Serilog; +using Serilog; using Windows.ApplicationModel.Background; using Wino.Core.Domain.Interfaces; @@ -8,12 +6,7 @@ namespace Wino.Core.UWP.Services { public class BackgroundTaskService : IBackgroundTaskService { - private const string Is180BackgroundTasksRegisteredKey = nameof(Is180BackgroundTasksRegisteredKey); - - public const string ToastActivationTaskEx = nameof(ToastActivationTaskEx); - - private const string SessionConnectedTaskEntryPoint = "Wino.BackgroundTasks.SessionConnectedTask"; - private const string SessionConnectedTaskName = "SessionConnectedTask"; + private const string IsBackgroundTasksUnregisteredKey = nameof(IsBackgroundTasksUnregisteredKey); private readonly IConfigurationService _configurationService; @@ -22,48 +15,17 @@ namespace Wino.Core.UWP.Services _configurationService = configurationService; } - public async Task HandleBackgroundTaskRegistrations() - { - bool is180BackgroundTaskRegistered = _configurationService.Get(Is180BackgroundTasksRegisteredKey); - - // Don't re-register tasks. - if (is180BackgroundTaskRegistered) return; - - var response = await BackgroundExecutionManager.RequestAccessAsync(); - - if (response != BackgroundAccessStatus.DeniedBySystemPolicy || - response != BackgroundAccessStatus.DeniedByUser) - { - // Unregister all tasks and register new ones. - - UnregisterAllBackgroundTask(); - RegisterSessionConnectedTask(); - - _configurationService.Set(Is180BackgroundTasksRegisteredKey, true); - } - } - public void UnregisterAllBackgroundTask() { - foreach (var task in BackgroundTaskRegistration.AllTasks) + if (_configurationService.Get(IsBackgroundTasksUnregisteredKey, false)) { - task.Value.Unregister(true); + foreach (var task in BackgroundTaskRegistration.AllTasks) + { + task.Value.Unregister(true); + } + + Log.Information("Unregistered all background tasks."); } - - Log.Information("Unregistered all background tasks."); - } - - private BackgroundTaskRegistration RegisterSessionConnectedTask() - { - var builder = new BackgroundTaskBuilder - { - Name = SessionConnectedTaskName, - TaskEntryPoint = SessionConnectedTaskEntryPoint - }; - - builder.SetTrigger(new SystemTrigger(SystemTriggerType.SessionConnected, false)); - - return builder.Register(); } } } diff --git a/Wino.Mail.ViewModels/AppShellViewModel.cs b/Wino.Mail.ViewModels/AppShellViewModel.cs index f40fbd16..5ae4b34a 100644 --- a/Wino.Mail.ViewModels/AppShellViewModel.cs +++ b/Wino.Mail.ViewModels/AppShellViewModel.cs @@ -236,14 +236,14 @@ namespace Wino.Mail.ViewModels await ProcessLaunchOptionsAsync(); await ForceAllAccountSynchronizationsAsync(); - await ConfigureBackgroundTasksAsync(); + ConfigureBackgroundTasks(); } - private async Task ConfigureBackgroundTasksAsync() + private void ConfigureBackgroundTasks() { try { - await _backgroundTaskService.HandleBackgroundTaskRegistrations(); + _backgroundTaskService.UnregisterAllBackgroundTask(); } catch (Exception ex) { diff --git a/Wino.Packaging/Package.appxmanifest b/Wino.Packaging/Package.appxmanifest index a459f815..fee01b18 100644 --- a/Wino.Packaging/Package.appxmanifest +++ b/Wino.Packaging/Package.appxmanifest @@ -55,13 +55,6 @@ - - - - - - -