From 5a41e3b73c12dd984514ff067a2d446982994a03 Mon Sep 17 00:00:00 2001 From: satkh <167398920+satkh@users.noreply.github.com> Date: Fri, 22 Nov 2024 19:54:26 +0530 Subject: [PATCH] Interfaces for "Enhanced UX Notification for Video and Audio Call Feature" (#4783) --- dev/AppNotifications/AppNotification.cpp | 13 +++ dev/AppNotifications/AppNotification.h | 5 ++ .../AppNotificationBuilder.cpp | 20 ++++- .../AppNotificationBuilder.h | 6 +- .../AppNotificationBuilder.idl | 21 ++++- .../AppNotificationButton.cpp | 28 ++++++- .../AppNotificationButton.h | 6 +- .../AppNotificationConferencingConfig.cpp | 50 ++++++++++++ .../AppNotificationConferencingConfig.h | 37 +++++++++ .../AppNotificationManager.cpp | 3 +- .../AppNotificationTelemetry.h | 8 +- dev/AppNotifications/AppNotifications.idl | 29 ++++++- .../AppNotifications.vcxitems | 4 + .../NotificationConferencingConfig.cpp | 41 ++++++++++ .../NotificationConferencingConfig.h | 31 ++++++++ .../NotificationProperties.cpp | 19 ++++- dev/AppNotifications/NotificationProperties.h | 7 +- ...minalVelocityFeatures-AppNotifications.xml | 11 +++ ...alVelocityFeatures-CallingPreviewSupport.h | 40 ++++++++++ test/AppNotificationBuilderTests/APITests.cpp | 79 ++++++++++++++++++- test/AppNotificationTests/BaseTestSuite.cpp | 64 ++++++++++++++- test/AppNotificationTests/BaseTestSuite.h | 7 +- test/AppNotificationTests/PackagedTests.cpp | 22 +++++- test/AppNotificationTests/PackagedTests.h | 6 +- .../appxmanifest.xml | 3 +- .../appxmanifest.xml | 1 + 26 files changed, 537 insertions(+), 24 deletions(-) create mode 100644 dev/AppNotifications/AppNotificationConferencingConfig.cpp create mode 100644 dev/AppNotifications/AppNotificationConferencingConfig.h create mode 100644 dev/AppNotifications/NotificationConferencingConfig.cpp create mode 100644 dev/AppNotifications/NotificationConferencingConfig.h create mode 100644 dev/Common/TerminalVelocityFeatures-CallingPreviewSupport.h diff --git a/dev/AppNotifications/AppNotification.cpp b/dev/AppNotifications/AppNotification.cpp index 74269f5eb2..d1a15aec90 100644 --- a/dev/AppNotifications/AppNotification.cpp +++ b/dev/AppNotifications/AppNotification.cpp @@ -119,4 +119,17 @@ namespace winrt::Microsoft::Windows::AppNotifications::implementation auto lock{ m_lock.lock_exclusive() }; m_notificationId = id; } + + winrt::Microsoft::Windows::AppNotifications::AppNotificationConferencingConfig AppNotification::ConferencingConfig() + { + auto lock{ m_lock.lock_shared() }; + return m_conferencingConfig; + } + + void AppNotification::ConferencingConfig(winrt::Microsoft::Windows::AppNotifications::AppNotificationConferencingConfig const& conferencingConfig) + { + THROW_HR_IF(E_NOTIMPL, !AppNotificationConferencingConfig::IsCallingPreviewSupported()); + auto lock{ m_lock.lock_exclusive() }; + m_conferencingConfig = conferencingConfig; + } } diff --git a/dev/AppNotifications/AppNotification.h b/dev/AppNotifications/AppNotification.h index cd53f20fb8..e48c0fa6e4 100644 --- a/dev/AppNotifications/AppNotification.h +++ b/dev/AppNotifications/AppNotification.h @@ -37,6 +37,9 @@ namespace winrt::Microsoft::Windows::AppNotifications::implementation // IAppNotificationInternal void SetNotificationId(uint32_t id); + winrt::Microsoft::Windows::AppNotifications::AppNotificationConferencingConfig ConferencingConfig(); + void ConferencingConfig(winrt::Microsoft::Windows::AppNotifications::AppNotificationConferencingConfig const& value); + private: winrt::hstring m_tag{}; winrt::hstring m_group{}; @@ -49,6 +52,8 @@ namespace winrt::Microsoft::Windows::AppNotifications::implementation { winrt::Microsoft::Windows::AppNotifications::AppNotificationPriority::Default }; bool m_suppressDisplay{ false }; wil::srwlock m_lock; + + winrt::Microsoft::Windows::AppNotifications::AppNotificationConferencingConfig m_conferencingConfig{ nullptr }; }; } namespace winrt::Microsoft::Windows::AppNotifications::factory_implementation diff --git a/dev/AppNotifications/AppNotificationBuilder/AppNotificationBuilder.cpp b/dev/AppNotifications/AppNotificationBuilder/AppNotificationBuilder.cpp index 35e72c6db8..d74afdf2e9 100644 --- a/dev/AppNotifications/AppNotificationBuilder/AppNotificationBuilder.cpp +++ b/dev/AppNotifications/AppNotificationBuilder/AppNotificationBuilder.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation and Contributors. +// Copyright (c) Microsoft Corporation and Contributors. // Licensed under the MIT License. #include "pch.h" @@ -376,7 +376,7 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation // Build the actions string and fill m_useButtonStyle std::wstring actions{ GetActions() }; - auto xmlResult{ wil::str_printf(L"%ls%ls%ls%ls%ls%ls", + auto xmlResult{ wil::str_printf(L"%ls%ls%ls%ls%ls%ls%ls", m_timeStamp.c_str(), GetDuration().c_str(), GetScenario().c_str(), @@ -384,6 +384,7 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation GetButtonStyle().c_str(), GetText().c_str(), m_attributionText.c_str(), + GetCameraPreview().c_str(), GetImages().c_str(), GetProgressBars().c_str(), m_audio.c_str(), @@ -399,4 +400,19 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation return appNotification; } + + winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::AddCameraPreview() + { + THROW_HR_IF(E_NOTIMPL, !AppNotificationConferencingConfig::IsCallingPreviewSupported()); + + THROW_HR_IF_MSG(E_INVALIDARG, m_useCameraPreview, "CameraPreview element is already added, only one is allowed"); + + m_useCameraPreview = true; + return *this; + } + + std::wstring AppNotificationBuilder::GetCameraPreview() + { + return m_useCameraPreview ? L"" : L""; + } } diff --git a/dev/AppNotifications/AppNotificationBuilder/AppNotificationBuilder.h b/dev/AppNotifications/AppNotificationBuilder/AppNotificationBuilder.h index 8433aceac6..a6ae76957d 100644 --- a/dev/AppNotifications/AppNotificationBuilder/AppNotificationBuilder.h +++ b/dev/AppNotifications/AppNotificationBuilder/AppNotificationBuilder.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. #pragma once @@ -65,6 +65,8 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation static bool IsUrgentScenarioSupported(); + winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AddCameraPreview(); + private: void ThrowIfMaxInputItemsExceeded(); std::wstring GetDuration(); @@ -75,6 +77,7 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation std::wstring GetImages(); std::wstring GetActions(); std::wstring GetProgressBars(); + std::wstring GetCameraPreview(); std::wstring m_timeStamp{}; AppNotificationDuration m_duration{ AppNotificationDuration::Default }; @@ -93,6 +96,7 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation std::vector m_comboBoxList{}; winrt::hstring m_tag{}; winrt::hstring m_group{}; + bool m_useCameraPreview{false}; }; } namespace winrt::Microsoft::Windows::AppNotifications::Builder::factory_implementation diff --git a/dev/AppNotifications/AppNotificationBuilder/AppNotificationBuilder.idl b/dev/AppNotifications/AppNotificationBuilder/AppNotificationBuilder.idl index 8e5334bc00..9a3de320a8 100644 --- a/dev/AppNotifications/AppNotificationBuilder/AppNotificationBuilder.idl +++ b/dev/AppNotifications/AppNotificationBuilder/AppNotificationBuilder.idl @@ -1,11 +1,12 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. import "..\AppNotifications\AppNotifications.idl"; +#include namespace Microsoft.Windows.AppNotifications.Builder { - [contractversion(1)] + [contractversion(2)] apicontract AppNotificationBuilderContract {} [contract(AppNotificationBuilderContract, 1)] @@ -31,6 +32,14 @@ namespace Microsoft.Windows.AppNotifications.Builder Critical, }; + [contract(AppNotificationBuilderContract, 2), feature(Feature_CallingPreviewSupport)] + enum AppNotificationButtonSettingStyle + { + None, + VideoCallConfig, + AudioCallConfig, + }; + [contract(AppNotificationBuilderContract, 1)] runtimeclass AppNotificationButton { @@ -69,6 +78,10 @@ namespace Microsoft.Windows.AppNotifications.Builder // Launches the URI passed into the button when activated. AppNotificationButton SetInvokeUri(Windows.Foundation.Uri protocolUri); AppNotificationButton SetInvokeUri(Windows.Foundation.Uri protocolUri, String targetAppId); + + // Sets the setting type for the button. + [contract(AppNotificationBuilderContract, 2), feature(Feature_CallingPreviewSupport)] + AppNotificationButton SetSettingStyle(AppNotificationButtonSettingStyle value); }; [contract(AppNotificationBuilderContract, 1)] @@ -242,5 +255,9 @@ namespace Microsoft.Windows.AppNotifications.Builder // AppNotification properties AppNotificationBuilder SetTag(String value); AppNotificationBuilder SetGroup(String group); + + // Adds a camera preview to the AppNotification + [contract(AppNotificationBuilderContract, 2), feature(Feature_CallingPreviewSupport)] + AppNotificationBuilder AddCameraPreview(); }; } diff --git a/dev/AppNotifications/AppNotificationBuilder/AppNotificationButton.cpp b/dev/AppNotifications/AppNotificationBuilder/AppNotificationButton.cpp index 0f27917617..b78e592841 100644 --- a/dev/AppNotifications/AppNotificationBuilder/AppNotificationButton.cpp +++ b/dev/AppNotifications/AppNotificationBuilder/AppNotificationButton.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation and Contributors. +// Copyright (c) Microsoft Corporation and Contributors. // Licensed under the MIT License. #include "pch.h" @@ -121,17 +121,39 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation { auto logTelemetry{ AppNotificationBuilderTelemetry::ButtonToString::Start(g_telemetryHelper) }; - std::wstring xmlResult{ wil::str_printf(L"", + std::wstring xmlResult{ wil::str_printf(L"", m_content.c_str(), GetActivationArguments().c_str(), m_useContextMenuPlacement ? L" placement='contextMenu'" : L"", m_iconUri ? wil::str_printf(L" imageUri='%ls'", m_iconUri.ToString().c_str()).c_str() : L"", !m_inputId.empty() ? wil::str_printf(L" hint-inputId='%ls'", m_inputId.c_str()).c_str() : L"", GetButtonStyle().c_str(), - !m_toolTip.empty() ? wil::str_printf(L" hint-toolTip='%ls'", m_toolTip.c_str()).c_str() : L"") }; + !m_toolTip.empty() ? wil::str_printf(L" hint-toolTip='%ls'", m_toolTip.c_str()).c_str() : L"", + GetSettingStyle().c_str()) }; logTelemetry.Stop(); return xmlResult.c_str(); } + + winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationButton AppNotificationButton::SetSettingStyle(AppNotificationButtonSettingStyle const& value) + { + THROW_HR_IF(E_NOTIMPL, !AppNotificationConferencingConfig::IsCallingPreviewSupported()); + + m_settingType = value; + return *this; + } + + std::wstring AppNotificationButton::GetSettingStyle() + { + switch (m_settingType) + { + case AppNotificationButtonSettingStyle::VideoCallConfig: + return L" settingType='videoDevices'"; + case AppNotificationButtonSettingStyle::AudioCallConfig: + return L" settingType='audioDevices'"; + default: // AppNotificationButtonSettingStyle::None + return L""; + } + } } diff --git a/dev/AppNotifications/AppNotificationBuilder/AppNotificationButton.h b/dev/AppNotifications/AppNotificationBuilder/AppNotificationButton.h index 556375b78c..b35d5c2d74 100644 --- a/dev/AppNotifications/AppNotificationBuilder/AppNotificationButton.h +++ b/dev/AppNotifications/AppNotificationBuilder/AppNotificationButton.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation and Contributors. +// Copyright (c) Microsoft Corporation and Contributors. // Licensed under the MIT License. #pragma once @@ -60,9 +60,12 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation winrt::hstring ToString(); + winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationButton SetSettingStyle(AppNotificationButtonSettingStyle const& value); + private: std::wstring GetActivationArguments(); std::wstring GetButtonStyle(); + std::wstring GetSettingStyle(); winrt::hstring m_content{}; winrt::Windows::Foundation::Collections::IMap m_arguments { winrt::single_threaded_map() }; @@ -73,6 +76,7 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation winrt::hstring m_inputId{}; bool m_useContextMenuPlacement{}; AppNotificationButtonStyle m_buttonStyle { AppNotificationButtonStyle::Default }; + AppNotificationButtonSettingStyle m_settingType{ AppNotificationButtonSettingStyle::None }; }; } namespace winrt::Microsoft::Windows::AppNotifications::Builder::factory_implementation diff --git a/dev/AppNotifications/AppNotificationConferencingConfig.cpp b/dev/AppNotifications/AppNotificationConferencingConfig.cpp new file mode 100644 index 0000000000..b89f302129 --- /dev/null +++ b/dev/AppNotifications/AppNotificationConferencingConfig.cpp @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include "pch.h" +#include "AppNotificationConferencingConfig.h" +#include "Microsoft.Windows.AppNotifications.AppNotificationConferencingConfig.g.cpp" +#include + +namespace winrt::Microsoft::Windows::AppNotifications::implementation +{ + hstring AppNotificationConferencingConfig::VideoDeviceId() + { + return m_videoDeviceId; + } + + void AppNotificationConferencingConfig::VideoDeviceId(hstring const& value) + { + THROW_HR_IF(E_NOTIMPL, !IsCallingPreviewSupported()); + m_videoDeviceId = value; + } + + hstring AppNotificationConferencingConfig::AudioInputDeviceId() + { + return m_audioInputDeviceId; + } + + void AppNotificationConferencingConfig::AudioInputDeviceId(hstring const& value) + { + THROW_HR_IF(E_NOTIMPL, !IsCallingPreviewSupported()); + m_audioInputDeviceId = value; + } + + hstring AppNotificationConferencingConfig::AudioOutputDeviceId() + { + return m_audioOutputDeviceId; + } + + void AppNotificationConferencingConfig::AudioOutputDeviceId(hstring const& value) + { + THROW_HR_IF(E_NOTIMPL, !IsCallingPreviewSupported()); + m_audioOutputDeviceId = value; + } + + ///Checks if the calling preview feature is supported on the current OS version + ///TO DO - This method needs implementation on framework UDK, for now it always returns false + bool AppNotificationConferencingConfig::IsCallingPreviewSupported() + { + return false; + } +} diff --git a/dev/AppNotifications/AppNotificationConferencingConfig.h b/dev/AppNotifications/AppNotificationConferencingConfig.h new file mode 100644 index 0000000000..ceb04dcad8 --- /dev/null +++ b/dev/AppNotifications/AppNotificationConferencingConfig.h @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#pragma once +#include "Microsoft.Windows.AppNotifications.AppNotificationConferencingConfig.g.h" + +namespace winrt::Microsoft::Windows::AppNotifications::implementation +{ + struct AppNotificationConferencingConfig : AppNotificationConferencingConfigT + { + AppNotificationConferencingConfig() = default; + + // Getters + hstring VideoDeviceId(); + hstring AudioInputDeviceId(); + hstring AudioOutputDeviceId(); + + // Setters + void VideoDeviceId(hstring const& value); + void AudioInputDeviceId(hstring const& value); + void AudioOutputDeviceId(hstring const& value); + + static bool IsCallingPreviewSupported(); + + private: + + hstring m_videoDeviceId{}; + hstring m_audioInputDeviceId{}; + hstring m_audioOutputDeviceId{}; + }; +} +namespace winrt::Microsoft::Windows::AppNotifications::factory_implementation +{ + struct AppNotificationConferencingConfig : AppNotificationConferencingConfigT + { + }; +} diff --git a/dev/AppNotifications/AppNotificationManager.cpp b/dev/AppNotifications/AppNotificationManager.cpp index 293d9e7a20..bcee2ddfc5 100644 --- a/dev/AppNotifications/AppNotificationManager.cpp +++ b/dev/AppNotifications/AppNotificationManager.cpp @@ -433,7 +433,8 @@ namespace winrt::Microsoft::Windows::AppNotifications::implementation m_appId, notification.Payload(), notification.Tag(), - notification.Group()) }; + notification.Group(), + winrt::AppNotificationConferencingConfig::IsCallingPreviewSupported()) }; THROW_HR_IF(WPN_E_NOTIFICATION_POSTED, notification.Id() != 0); diff --git a/dev/AppNotifications/AppNotificationTelemetry.h b/dev/AppNotifications/AppNotificationTelemetry.h index df215896d9..c74fa5922e 100644 --- a/dev/AppNotifications/AppNotificationTelemetry.h +++ b/dev/AppNotifications/AppNotificationTelemetry.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation and Contributors. +// Copyright (c) Microsoft Corporation and Contributors. // Licensed under the MIT license. #pragma once @@ -62,7 +62,8 @@ class AppNotificationTelemetry : public wil::TraceLoggingProvider std::wstring const& appId, winrt::hstring const& payload, winrt::hstring const& tag, - winrt::hstring const& group) noexcept try + winrt::hstring const& group, + bool isCallingPreviewSupported) noexcept try { TraceLoggingClassWriteStart( Show, @@ -72,7 +73,8 @@ class AppNotificationTelemetry : public wil::TraceLoggingProvider TraceLoggingUInt32(tag.size(), "TagSize"), TraceLoggingUInt32(group.size(), "GroupSize"), TraceLoggingBool(notificationTelemetryHelper.IsPackagedApp(), "IsAppPackaged"), - TraceLoggingWideString(notificationTelemetryHelper.GetAppName().c_str(), "AppName")); + TraceLoggingWideString(notificationTelemetryHelper.GetAppName().c_str(), "AppName"), + TraceLoggingBool(isCallingPreviewSupported, "IsCallingPreviewSupported")); } CATCH_LOG() END_ACTIVITY_CLASS(); diff --git a/dev/AppNotifications/AppNotifications.idl b/dev/AppNotifications/AppNotifications.idl index 703ba734e4..b712384af8 100644 --- a/dev/AppNotifications/AppNotifications.idl +++ b/dev/AppNotifications/AppNotifications.idl @@ -1,10 +1,11 @@ -// Copyright (c) Microsoft Corporation and Contributors. +// Copyright (c) Microsoft Corporation and Contributors. // Licensed under the MIT License. import "..\AppLifecycle\AppLifecycle.idl"; +#include namespace Microsoft.Windows.AppNotifications { - [contractversion(3)] + [contractversion(4)] apicontract AppNotificationsContract {} // Event args for the Notification Activation @@ -111,6 +112,30 @@ namespace Microsoft.Windows.AppNotifications // Gets or sets whether a Notification's pop-up UI is displayed on the user's screen. Boolean SuppressDisplay; + + // Gets or sets the Notification Conferencing Config + [contract(AppNotificationsContract, 4), feature(Feature_CallingPreviewSupport)] + AppNotificationConferencingConfig ConferencingConfig; + } + + // The Notification Conferencing Config + [contract(AppNotificationsContract, 4), feature(Feature_CallingPreviewSupport)] + runtimeclass AppNotificationConferencingConfig + { + // Initializes a new Instance of AppNotificationConferencingConfig + AppNotificationConferencingConfig(); + + // Checks if Video or Audio Calling is supported + static Boolean IsCallingPreviewSupported(); + + // Gets or sets the Video Device Id + String VideoDeviceId; + + // Gets or sets the Microphone Device Id + String AudioInputDeviceId; + + // Gets or sets the Speaker Device Id + String AudioOutputDeviceId; } // The manager class which encompasses all App Notification API Functionality diff --git a/dev/AppNotifications/AppNotifications.vcxitems b/dev/AppNotifications/AppNotifications.vcxitems index 72a89d2640..b278e43c69 100644 --- a/dev/AppNotifications/AppNotifications.vcxitems +++ b/dev/AppNotifications/AppNotifications.vcxitems @@ -24,6 +24,8 @@ + + @@ -35,6 +37,8 @@ + + diff --git a/dev/AppNotifications/NotificationConferencingConfig.cpp b/dev/AppNotifications/NotificationConferencingConfig.cpp new file mode 100644 index 0000000000..d8ef87aa00 --- /dev/null +++ b/dev/AppNotifications/NotificationConferencingConfig.cpp @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include "pch.h" + +#include "AppNotificationConferencingConfig.h" +#include "NotificationConferencingConfig.h" +#include "AppNotificationUtility.h" + +using namespace Microsoft::Windows::AppNotifications::Helpers; + +NotificationConferencingConfig::NotificationConferencingConfig(winrt::AppNotificationConferencingConfig const& conferencingConfig) + : m_conferencingConfig(conferencingConfig) +{ +} + +STDMETHODIMP NotificationConferencingConfig::get_VideoDeviceId(_Out_ HSTRING* value) noexcept try +{ + winrt::copy_to_abi(m_conferencingConfig.VideoDeviceId(), reinterpret_cast(value)); + return S_OK; +} +CATCH_RETURN() + +STDMETHODIMP NotificationConferencingConfig::get_AudioInputDeviceId(_Out_ HSTRING* value) noexcept try +{ + winrt::copy_to_abi(m_conferencingConfig.AudioInputDeviceId(), reinterpret_cast(value)); + return S_OK; +} +CATCH_RETURN() + + +STDMETHODIMP NotificationConferencingConfig::get_AudioOutputDeviceId(_Out_ HSTRING* value) noexcept try +{ + winrt::copy_to_abi(m_conferencingConfig.AudioOutputDeviceId(), reinterpret_cast(value)); + return S_OK; +} +CATCH_RETURN() + + + + diff --git a/dev/AppNotifications/NotificationConferencingConfig.h b/dev/AppNotifications/NotificationConferencingConfig.h new file mode 100644 index 0000000000..67c8d3d256 --- /dev/null +++ b/dev/AppNotifications/NotificationConferencingConfig.h @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#pragma once + +#include + +namespace winrt +{ + using namespace winrt::Microsoft::Windows::AppNotifications; +} + +namespace ToastABI +{ + using namespace ::ABI::Microsoft::Internal::ToastNotifications; +} + +struct NotificationConferencingConfig : winrt::implements +{ + NotificationConferencingConfig(winrt::AppNotificationConferencingConfig const& conferencingConfig); + + STDMETHOD(get_VideoDeviceId)(_Out_ HSTRING* value) noexcept; + + STDMETHOD(get_AudioInputDeviceId)(_Out_ HSTRING* value) noexcept; + + STDMETHOD(get_AudioOutputDeviceId)(_Out_ HSTRING* value) noexcept; + +private: + + winrt::AppNotificationConferencingConfig m_conferencingConfig; +}; diff --git a/dev/AppNotifications/NotificationProperties.cpp b/dev/AppNotifications/NotificationProperties.cpp index ec6f37f474..c06167106c 100644 --- a/dev/AppNotifications/NotificationProperties.cpp +++ b/dev/AppNotifications/NotificationProperties.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation and Contributors. +// Copyright (c) Microsoft Corporation and Contributors. // Licensed under the MIT License. #include "pch.h" @@ -8,6 +8,8 @@ #include "AppNotificationUtility.h" #include "../PushNotifications/PushNotificationUtility.h" #include "NotificationProgressData.h" +#include "NotificationConferencingConfig.h" +#include "AppNotificationConferencingConfig.h" namespace winrt { @@ -47,6 +49,14 @@ NotificationProperties::NotificationProperties(winrt::AppNotification const& toa { m_toastProgressData = winrt::make_self(toastNotification.Progress()); } + + if (winrt::AppNotificationConferencingConfig::IsCallingPreviewSupported()) + { + if (auto config = toastNotification.ConferencingConfig()) + { + m_toastConferencingConfig = winrt::make_self(config); + } + } } STDMETHODIMP_(HRESULT __stdcall) NotificationProperties::get_NotificationId(_Out_ unsigned int* notificationId) noexcept @@ -147,3 +157,10 @@ STDMETHODIMP_(HRESULT __stdcall) NotificationProperties::get_ActivityId(_Out_ GU *activityId = GUID_NULL; return S_OK; } + +STDMETHODIMP_(HRESULT __stdcall) NotificationProperties::get_ToastConferencingConfig(_Out_ ToastABI::IToastConferencingConfig** conferencingConfig) noexcept +{ + auto lock{ m_lock.lock_shared() }; + m_toastConferencingConfig.copy_to(conferencingConfig); + return S_OK; +} diff --git a/dev/AppNotifications/NotificationProperties.h b/dev/AppNotifications/NotificationProperties.h index 82eaebea08..ec6aaffae9 100644 --- a/dev/AppNotifications/NotificationProperties.h +++ b/dev/AppNotifications/NotificationProperties.h @@ -1,11 +1,11 @@ -// Copyright (c) Microsoft Corporation and Contributors. +// Copyright (c) Microsoft Corporation and Contributors. // Licensed under the MIT License. #pragma once #include -struct NotificationProperties : winrt::implements +struct NotificationProperties : winrt::implements { NotificationProperties(winrt::Microsoft::Windows::AppNotifications::AppNotification const& toastNotification); @@ -31,6 +31,8 @@ struct NotificationProperties : winrt::implements m_toastProgressData{ nullptr }; + winrt::com_ptr m_toastConferencingConfig{ nullptr }; }; diff --git a/dev/Common/TerminalVelocityFeatures-AppNotifications.xml b/dev/Common/TerminalVelocityFeatures-AppNotifications.xml index 7596d4e9a2..1e4ac22c1a 100644 --- a/dev/Common/TerminalVelocityFeatures-AppNotifications.xml +++ b/dev/Common/TerminalVelocityFeatures-AppNotifications.xml @@ -13,4 +13,15 @@ Enables Local App sourced Notifications on the device AlwaysEnabled + + + Feature_CallingPreviewSupport + Apis for Calling preview feature + AlwaysEnabled + + Preview + Stable + + + diff --git a/dev/Common/TerminalVelocityFeatures-CallingPreviewSupport.h b/dev/Common/TerminalVelocityFeatures-CallingPreviewSupport.h new file mode 100644 index 0000000000..3d6069327d --- /dev/null +++ b/dev/Common/TerminalVelocityFeatures-CallingPreviewSupport.h @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +// THIS FILE IS AUTOMATICALLY GENERATED; DO NOT EDIT IT + +// INPUT FILE: C:\code\WinAppSdk\dev\Common\TerminalVelocityFeatures-AppNotifications.xml +// OPTIONS: -Channel Experimental -Language C++ -Namespace Microsoft.Windows.CallingPreviewSupport -Path C:\code\WinAppSdk\dev\Common\TerminalVelocityFeatures-AppNotifications.xml -Output C:\code\WinAppSdk\dev\Common\TerminalVelocityFeatures-CallingPreviewSupport.h + +#if defined(__midlrt) +namespace features +{ + feature_name Feature_AppNotifications = { DisabledByDefault, FALSE }; + feature_name Feature_CallingPreviewSupport = { DisabledByDefault, FALSE }; +} +#endif // defined(__midlrt) + +// Feature constants +#define WINDOWSAPPRUNTIME_MICROSOFT_WINDOWS_CALLINGPREVIEWSUPPORT_FEATURE_APPNOTIFICATIONS_ENABLED 1 +#define WINDOWSAPPRUNTIME_MICROSOFT_WINDOWS_CALLINGPREVIEWSUPPORT_FEATURE_CALLINGPREVIEWSUPPORT_ENABLED 1 + +#if defined(__cplusplus) + +namespace Microsoft::Windows::CallingPreviewSupport +{ + +__pragma(detect_mismatch("ODR_violation_WINDOWSAPPRUNTIME_MICROSOFT_WINDOWS_CALLINGPREVIEWSUPPORT_FEATURE_APPNOTIFICATIONS_ENABLED_mismatch", "AlwaysEnabled")) +struct Feature_AppNotifications +{ + static constexpr bool IsEnabled() { return WINDOWSAPPRUNTIME_MICROSOFT_WINDOWS_CALLINGPREVIEWSUPPORT_FEATURE_APPNOTIFICATIONS_ENABLED == 1; } +}; + +__pragma(detect_mismatch("ODR_violation_WINDOWSAPPRUNTIME_MICROSOFT_WINDOWS_CALLINGPREVIEWSUPPORT_FEATURE_CALLINGPREVIEWSUPPORT_ENABLED_mismatch", "AlwaysEnabled")) +struct Feature_CallingPreviewSupport +{ + static constexpr bool IsEnabled() { return WINDOWSAPPRUNTIME_MICROSOFT_WINDOWS_CALLINGPREVIEWSUPPORT_FEATURE_CALLINGPREVIEWSUPPORT_ENABLED == 1; } +}; + +} // namespace Microsoft.Windows.CallingPreviewSupport + +#endif // defined(__cplusplus) diff --git a/test/AppNotificationBuilderTests/APITests.cpp b/test/AppNotificationBuilderTests/APITests.cpp index 9946fcaf02..08b7feaf7f 100644 --- a/test/AppNotificationBuilderTests/APITests.cpp +++ b/test/AppNotificationBuilderTests/APITests.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. #include "pch.h" @@ -6,6 +6,7 @@ namespace winrt { using namespace winrt::Microsoft::Windows::AppNotifications::Builder; + using namespace winrt::Microsoft::Windows::AppNotifications; } namespace Test::AppNotification::Builder @@ -666,5 +667,81 @@ namespace Test::AppNotification::Builder VERIFY_ARE_EQUAL(Decode(LR"(&%3B"%3D'%25<>)"), LR"(&;"='%<>)"); VERIFY_ARE_EQUAL(Decode(L"%3B%3D%25"), L";=%"); } + + TEST_METHOD(AppNotificationBuilderWithCameraPreview) + { + if (!winrt::AppNotificationConferencingConfig::IsCallingPreviewSupported()) + { + return; + } + + auto builder{ winrt::AppNotificationBuilder() + .AddCameraPreview() + .AddButton(winrt::AppNotificationButton(L"content") + .AddArgument(L"key", L"value") + .SetButtonStyle(winrt::AppNotificationButtonStyle::Success) + .SetIcon(c_sampleUri) + .SetInputId(L"inputId") + .SetToolTip(L"toolTip")) + }; + + auto expected{ L"" }; + VERIFY_ARE_EQUAL(builder.BuildNotification().Payload(), expected); + } + + TEST_METHOD(AppNotificationBuilderWithCameraPreviewAndVideoCallSettingsButton) + { + if (!winrt::AppNotificationConferencingConfig::IsCallingPreviewSupported()) + { + return; + } + + auto builder{ winrt::AppNotificationBuilder() + .AddCameraPreview() + .AddButton(winrt::AppNotificationButton(L"content") + .AddArgument(L"key", L"value") + .SetButtonStyle(winrt::AppNotificationButtonStyle::Success) + .SetIcon(c_sampleUri) + .SetInputId(L"inputId") + .SetToolTip(L"toolTip") + .SetSettingStyle(winrt::AppNotificationButtonSettingStyle::VideoCallConfig)) + }; + + auto expected{ L"" }; + VERIFY_ARE_EQUAL(builder.BuildNotification().Payload(), expected); + } + + TEST_METHOD(AppNotificationBuilderWithCameraPreviewAndAudioCallSettingsButton) + { + if (!winrt::AppNotificationConferencingConfig::IsCallingPreviewSupported()) + { + return; + } + + auto builder{ winrt::AppNotificationBuilder() + .AddCameraPreview() + .AddButton(winrt::AppNotificationButton(L"content") + .AddArgument(L"key", L"value") + .SetButtonStyle(winrt::AppNotificationButtonStyle::Success) + .SetIcon(c_sampleUri) + .SetInputId(L"inputId") + .SetToolTip(L"toolTip") + .SetSettingStyle(winrt::AppNotificationButtonSettingStyle::AudioCallConfig)) + }; + + auto expected{ L"" }; + VERIFY_ARE_EQUAL(builder.BuildNotification().Payload(), expected); + } + + TEST_METHOD(AppNotificationBuilderWithIsCallingPreviewSupportedIsFalse) + { + if (!winrt::AppNotificationConferencingConfig::IsCallingPreviewSupported()) + { + VERIFY_THROWS_HR(winrt::AppNotificationBuilder().AddCameraPreview(), E_NOTIMPL); + + VERIFY_THROWS_HR(winrt::AppNotificationBuilder().AddButton(winrt::AppNotificationButton(L"content") + .SetSettingStyle(winrt::AppNotificationButtonSettingStyle::AudioCallConfig)), E_NOTIMPL); + } + } }; } diff --git a/test/AppNotificationTests/BaseTestSuite.cpp b/test/AppNotificationTests/BaseTestSuite.cpp index bc7076b20f..ab66a3842b 100644 --- a/test/AppNotificationTests/BaseTestSuite.cpp +++ b/test/AppNotificationTests/BaseTestSuite.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. #include "pch.h" @@ -598,3 +598,65 @@ void BaseTestSuite::VerifyExplicitAppId() RegisterWithAppNotificationManager(); AppNotificationManager::Default().Unregister(); } + +void BaseTestSuite::VerifyToastConferencingConfigAllDevicesSet() +{ + if (!AppNotificationConferencingConfig::IsCallingPreviewSupported()) + { + return; + } + + AppNotification toast{ CreateToastNotification() }; + + AppNotificationConferencingConfig conferencingConfig{}; + conferencingConfig.VideoDeviceId(L"CameraDeviceId"); + conferencingConfig.AudioInputDeviceId(L"MicrophoneDeviceId"); + conferencingConfig.AudioOutputDeviceId(L"SpeakerDeviceId"); + + toast.ConferencingConfig(conferencingConfig); + + VERIFY_ARE_EQUAL(toast.ConferencingConfig().VideoDeviceId(), L"CameraDeviceId"); + VERIFY_ARE_EQUAL(toast.ConferencingConfig().AudioInputDeviceId(), L"MicrophoneDeviceId"); + VERIFY_ARE_EQUAL(toast.ConferencingConfig().AudioOutputDeviceId(), L"SpeakerDeviceId"); +} + +void BaseTestSuite::VerifyToastConferencingConfigNoDevicesSet() +{ + AppNotification toast{ CreateToastNotification() }; + + VERIFY_ARE_EQUAL(toast.ConferencingConfig(), nullptr); +} + +void BaseTestSuite::VerifyToastConferencingConfigNotAllDevicesSet() +{ + if (!AppNotificationConferencingConfig::IsCallingPreviewSupported()) + { + return; + } + + AppNotification toast{ CreateToastNotification() }; + + AppNotificationConferencingConfig conferencingConfig{ }; + conferencingConfig.VideoDeviceId(L"CameraDeviceId"); + + toast.ConferencingConfig(conferencingConfig); + + VERIFY_ARE_EQUAL(toast.ConferencingConfig().VideoDeviceId(), L"CameraDeviceId"); + VERIFY_ARE_EQUAL(toast.ConferencingConfig().AudioInputDeviceId(), L""); + VERIFY_ARE_EQUAL(toast.ConferencingConfig().AudioOutputDeviceId(), L""); +} + +void BaseTestSuite::VerifyToastConferencingConfigWithIsCallingPreviewSupportedFalse() +{ + AppNotification toast{ CreateToastNotification() }; + AppNotificationConferencingConfig conferencingConfig{ }; + + if (!AppNotificationConferencingConfig::IsCallingPreviewSupported()) + { + VERIFY_THROWS_HR(conferencingConfig.VideoDeviceId(L"CameraDeviceId"), E_NOTIMPL); + VERIFY_THROWS_HR(conferencingConfig.AudioInputDeviceId(L"MicrophoneDeviceId"), E_NOTIMPL); + VERIFY_THROWS_HR(conferencingConfig.AudioOutputDeviceId(L"SpeakerDeviceId"), E_NOTIMPL); + + VERIFY_THROWS_HR(toast.ConferencingConfig(conferencingConfig), E_NOTIMPL); + } +} diff --git a/test/AppNotificationTests/BaseTestSuite.h b/test/AppNotificationTests/BaseTestSuite.h index 479c20c755..bede46a40f 100644 --- a/test/AppNotificationTests/BaseTestSuite.h +++ b/test/AppNotificationTests/BaseTestSuite.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. #include "pch.h" @@ -54,6 +54,11 @@ class BaseTestSuite void VerifyToastProgressDataSequence0Fail(); void VerifyIconPathExists(); void VerifyExplicitAppId(); + void VerifyToastConferencingConfigAllDevicesSet(); + void VerifyToastConferencingConfigNotAllDevicesSet(); + void VerifyToastConferencingConfigNoDevicesSet(); + void VerifyToastConferencingConfigWithIsCallingPreviewSupportedFalse(); + private: void RegisterWithAppNotificationManager(); void UnregisterAllWithAppNotificationManager(); diff --git a/test/AppNotificationTests/PackagedTests.cpp b/test/AppNotificationTests/PackagedTests.cpp index 0230458e46..f6d299e7bb 100644 --- a/test/AppNotificationTests/PackagedTests.cpp +++ b/test/AppNotificationTests/PackagedTests.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. #include "pch.h" #include "PackagedTests.h" @@ -192,3 +192,23 @@ void PackagedTests::VerifyRemoveAllAsync() { BaseTestSuite::VerifyRemoveAllAsync(); } + +void PackagedTests::VerifyToastConferencingConfigAllDevicesSet() +{ + BaseTestSuite::VerifyToastConferencingConfigAllDevicesSet(); +} + +void PackagedTests::VerifyToastConferencingConfigNotAllDevicesSet() +{ + BaseTestSuite::VerifyToastConferencingConfigNotAllDevicesSet(); +} + +void PackagedTests::VerifyToastConferencingConfigNoDevicesSet() +{ + BaseTestSuite::VerifyToastConferencingConfigNoDevicesSet(); +} + +void PackagedTests::VerifyToastConferencingConfigWithIsCallingPreviewSupportedFalse() +{ + BaseTestSuite::VerifyToastConferencingConfigWithIsCallingPreviewSupportedFalse(); +} diff --git a/test/AppNotificationTests/PackagedTests.h b/test/AppNotificationTests/PackagedTests.h index 87d8e0ea4a..8c04e1eb89 100644 --- a/test/AppNotificationTests/PackagedTests.h +++ b/test/AppNotificationTests/PackagedTests.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. #include "pch.h" @@ -82,5 +82,9 @@ class PackagedTests : BaseTestSuite TEST_METHOD(VerifyRemoveGroupAsync); TEST_METHOD(VerifyRemoveAllAsyncWithNoActiveToastDoesNotThrow); TEST_METHOD(VerifyRemoveAllAsync); + TEST_METHOD(VerifyToastConferencingConfigAllDevicesSet); + TEST_METHOD(VerifyToastConferencingConfigNotAllDevicesSet); + TEST_METHOD(VerifyToastConferencingConfigNoDevicesSet); + TEST_METHOD(VerifyToastConferencingConfigWithIsCallingPreviewSupportedFalse); }; diff --git a/test/Deployment/data/WindowsAppRuntime.Test.Framework/appxmanifest.xml b/test/Deployment/data/WindowsAppRuntime.Test.Framework/appxmanifest.xml index a3c742d4a2..bda7721f1b 100644 --- a/test/Deployment/data/WindowsAppRuntime.Test.Framework/appxmanifest.xml +++ b/test/Deployment/data/WindowsAppRuntime.Test.Framework/appxmanifest.xml @@ -1,4 +1,4 @@ - + + diff --git a/test/DynamicDependency/data/Microsoft.WindowsAppRuntime.Framework/appxmanifest.xml b/test/DynamicDependency/data/Microsoft.WindowsAppRuntime.Framework/appxmanifest.xml index aed4d038b8..a4f395306f 100644 --- a/test/DynamicDependency/data/Microsoft.WindowsAppRuntime.Framework/appxmanifest.xml +++ b/test/DynamicDependency/data/Microsoft.WindowsAppRuntime.Framework/appxmanifest.xml @@ -75,6 +75,7 @@ +