diff --git a/dev/PowerNotifications/PowerNotifications.cpp b/dev/PowerNotifications/PowerNotifications.cpp index 047b8a003a..5376de2c5f 100644 --- a/dev/PowerNotifications/PowerNotifications.cpp +++ b/dev/PowerNotifications/PowerNotifications.cpp @@ -136,10 +136,6 @@ namespace winrt::Microsoft::Windows::System::Power::implementation } // PowerSourceKind Functions - EventType& PowerSourceKind_Event() - { - return Factory()->m_powerSourceKindChangedEvent; - } void PowerSourceKind_Register() { @@ -204,44 +200,9 @@ namespace winrt::Microsoft::Windows::System::Power::implementation Factory()->m_systemIdleStatusHandle)); } - ULONG GetEffectivePowerModeVersion() - { - // We check for the version supported by checking if the feature is supported - // Using NULL as an indicator for uninitialized cache value - auto& version{ Factory()->m_powerModeVersion }; - if (!version) - { - void* handle{}; - auto hr{ PowerRegisterForEffectivePowerModeNotifications( - EFFECTIVE_POWER_MODE_V2, [](EFFECTIVE_POWER_MODE, void*) {}, nullptr, &handle) }; - version = SUCCEEDED(hr) ? EFFECTIVE_POWER_MODE_V2 : EFFECTIVE_POWER_MODE_V1; - THROW_IF_FAILED(PowerUnregisterFromEffectivePowerModeNotifications(handle)); - } - return version; - } - EventType& EffectivePowerMode_Event() - { - return Factory()->m_powerModeChangedEvent; - } - void EffectivePowerMode_Register() - { - ULONG version{ GetEffectivePowerModeVersion() }; - auto& powerModeHandle{ Factory()->m_powerModeHandle }; - THROW_IF_FAILED(PowerRegisterForEffectivePowerModeNotifications( - version, [](EFFECTIVE_POWER_MODE mode, void*) - { - PowerManager::EffectivePowerModeChanged_Callback(mode); - }, nullptr, &powerModeHandle)); - } - void EffectivePowerMode_Unregister() - { - auto& powerModeHandle{ Factory()->m_powerModeHandle }; - THROW_IF_FAILED(PowerUnregisterFromEffectivePowerModeNotifications(powerModeHandle)); - powerModeHandle = nullptr; - } void EffectivePowerMode_Update() { diff --git a/dev/PowerNotifications/PowerNotifications.h b/dev/PowerNotifications/PowerNotifications.h index 82d753d6f3..9fa6176c2f 100644 --- a/dev/PowerNotifications/PowerNotifications.h +++ b/dev/PowerNotifications/PowerNotifications.h @@ -72,10 +72,6 @@ namespace winrt::Microsoft::Windows::System::Power void SystemIdleStatus_Register(); void SystemIdleStatus_Unregister(); - EventType& EffectivePowerMode_Event(); - void EffectivePowerMode_Register(); - void EffectivePowerMode_Unregister(); - void EffectivePowerMode_Update(); EventType& UserPresenceStatus_Event(); void UserPresenceStatus_Register(); @@ -202,12 +198,6 @@ namespace winrt::Microsoft::Windows::System::Power &Power::implementation::NoOperation, L"SystemIdleStatus" }; - PowerFunctionDetails effectivePowerModeFunc{ - &Power::implementation::EffectivePowerMode_Event, - &Power::implementation::EffectivePowerMode_Register, - &Power::implementation::EffectivePowerMode_Unregister, - &Power::implementation::EffectivePowerMode_Update, - L"EffectivePowerMode" }; PowerFunctionDetails userPresenceStatusFunc{ &Power::implementation::UserPresenceStatus_Event, @@ -539,14 +529,6 @@ namespace winrt::Microsoft::Windows::System::Power } - // EffectivePowerMode Functions - winrt::Windows::Foundation::IAsyncOperation EffectivePowerMode() - { - co_await resume_background(); - UpdateValuesIfNecessary(effectivePowerModeFunc); - auto res{ static_cast(m_cachedPowerMode) }; - co_return res; - } Power::EffectivePowerMode EffectivePowerMode2() { diff --git a/dev/PowerNotifications/PowerNotifications.idl b/dev/PowerNotifications/PowerNotifications.idl index 97ea4344bc..c2030f8370 100644 --- a/dev/PowerNotifications/PowerNotifications.idl +++ b/dev/PowerNotifications/PowerNotifications.idl @@ -107,7 +107,6 @@ namespace Microsoft.Windows.System.Power static event Windows.Foundation.EventHandler SystemIdleStatusChanged; - static Windows.Foundation.IAsyncOperation EffectivePowerMode{ get; }; static event Windows.Foundation.EventHandler EffectivePowerModeChanged; [contract(PowerNotificationsContract, 2)] diff --git a/test/PowerNotifications/APITests.cpp b/test/PowerNotifications/APITests.cpp index d2346eb87e..d0638d9ab5 100644 --- a/test/PowerNotifications/APITests.cpp +++ b/test/PowerNotifications/APITests.cpp @@ -231,5 +231,11 @@ namespace Test::PowerNotifications VERIFY_IS_NOT_NULL(token); PowerManager::SystemSuspendStatusChanged(token); } + + TEST_METHOD(GetEffectivePowerMode) + { + auto value = PowerManager::EffectivePowerMode2(); + VERIFY_ARE_EQUAL(value, EffectivePowerMode::Balanced); + } }; }