From 2cb1f12c3315dff8af110af53036b4611567b820 Mon Sep 17 00:00:00 2001 From: JPikachu Date: Sun, 13 Apr 2025 22:42:28 +0100 Subject: [PATCH] Service: am: enhance UnpopInData, GetHdcpAuthenticationState and GetHdcpAuthenticationStateChangeEvent Thanks to Sudachi and Torzu for some help and referance. --- src/core/hle/service/am/lifecycle_manager.cpp | 6 +++++- src/core/hle/service/am/lifecycle_manager.h | 3 +++ .../service/am/service/common_state_getter.cpp | 17 +++++++++++++++-- .../service/am/service/common_state_getter.h | 2 ++ .../am/service/library_applet_self_accessor.cpp | 7 ++++++- .../am/service/library_applet_self_accessor.h | 1 + 6 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/core/hle/service/am/lifecycle_manager.cpp b/src/core/hle/service/am/lifecycle_manager.cpp index 0dac27ed08..fbb9ad611f 100644 --- a/src/core/hle/service/am/lifecycle_manager.cpp +++ b/src/core/hle/service/am/lifecycle_manager.cpp @@ -9,7 +9,7 @@ namespace Service::AM { LifecycleManager::LifecycleManager(Core::System& system, KernelHelpers::ServiceContext& context, bool is_application) : m_system_event(context), m_operation_mode_changed_system_event(context), - m_is_application(is_application) {} + m_hdcp_state_changed_event(context), m_is_application(is_application) {} LifecycleManager::~LifecycleManager() = default; @@ -21,6 +21,10 @@ Event& LifecycleManager::GetOperationModeChangedSystemEvent() { return m_operation_mode_changed_system_event; } +Event& LifecycleManager::GetHDCPStateChangedEvent() { + return m_hdcp_state_changed_event; +} + void LifecycleManager::PushUnorderedMessage(AppletMessage message) { m_unordered_messages.push_back(message); this->SignalSystemEventIfNeeded(); diff --git a/src/core/hle/service/am/lifecycle_manager.h b/src/core/hle/service/am/lifecycle_manager.h index 7c70434a18..a1ddb9e2df 100644 --- a/src/core/hle/service/am/lifecycle_manager.h +++ b/src/core/hle/service/am/lifecycle_manager.h @@ -42,6 +42,7 @@ public: public: Event& GetSystemEvent(); Event& GetOperationModeChangedSystemEvent(); + Event& GetHDCPStateChangedEvent(); public: bool IsApplication() { @@ -145,12 +146,14 @@ private: private: Event m_system_event; Event m_operation_mode_changed_system_event; + Event m_hdcp_state_changed_event; std::list m_unordered_messages{}; bool m_is_application{}; bool m_focus_state_changed_notification_enabled{true}; bool m_operation_mode_changed_notification_enabled{true}; + bool m_hdcp_state_changed_notification_enabled{true}; bool m_performance_mode_changed_notification_enabled{true}; bool m_resume_notification_enabled{}; diff --git a/src/core/hle/service/am/service/common_state_getter.cpp b/src/core/hle/service/am/service/common_state_getter.cpp index f20071156e..c445e5e776 100644 --- a/src/core/hle/service/am/service/common_state_getter.cpp +++ b/src/core/hle/service/am/service/common_state_getter.cpp @@ -48,8 +48,8 @@ ICommonStateGetter::ICommonStateGetter(Core::System& system_, std::shared_ptr, "GetDefaultDisplayResolution"}, {61, D<&ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent>, "GetDefaultDisplayResolutionChangeEvent"}, - {62, nullptr, "GetHdcpAuthenticationState"}, - {63, nullptr, "GetHdcpAuthenticationStateChangeEvent"}, + {62, D<&ICommonStateGetter::GetHdcpAuthenticationState>, "GetHdcpAuthenticationState"}, + {63, D<&ICommonStateGetter::GetHdcpAuthenticationStateChangeEvent>, "GetHdcpAuthenticationStateChangeEvent"}, {64, nullptr, "SetTvPowerStateMatchingMode"}, {65, nullptr, "GetApplicationIdByContentActionName"}, {66, &ICommonStateGetter::SetCpuBoostMode, "SetCpuBoostMode"}, @@ -140,6 +140,19 @@ Result ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent( R_SUCCEED(); } +Result ICommonStateGetter::GetHdcpAuthenticationState(Out out_state) { + LOG_DEBUG(Service_AM, "called"); + *out_state = 1; + R_SUCCEED(); +} + +Result ICommonStateGetter::GetHdcpAuthenticationStateChangeEvent( + OutCopyHandle out_event) { + LOG_DEBUG(Service_AM, "called"); + *out_event = m_applet->lifecycle_manager.GetHDCPStateChangedEvent().GetHandle(); + R_SUCCEED(); +} + Result ICommonStateGetter::GetOperationMode(Out out_operation_mode) { const bool use_docked_mode{Settings::IsDockedMode()}; LOG_DEBUG(Service_AM, "called, use_docked_mode={}", use_docked_mode); diff --git a/src/core/hle/service/am/service/common_state_getter.h b/src/core/hle/service/am/service/common_state_getter.h index 2043a38ac6..a326e11053 100644 --- a/src/core/hle/service/am/service/common_state_getter.h +++ b/src/core/hle/service/am/service/common_state_getter.h @@ -35,6 +35,8 @@ private: Result GetWriterLockAccessorEx(Out> out_lock_accessor, u32 button_type); Result GetDefaultDisplayResolutionChangeEvent(OutCopyHandle out_event); + Result GetHdcpAuthenticationState(Out out_state); + Result GetHdcpAuthenticationStateChangeEvent(OutCopyHandle out_event); Result GetOperationMode(Out out_operation_mode); Result GetPerformanceMode(Out out_performance_mode); Result GetCradleFwVersion(OutArray out_version); diff --git a/src/core/hle/service/am/service/library_applet_self_accessor.cpp b/src/core/hle/service/am/service/library_applet_self_accessor.cpp index 3fe36b8997..cbe45189f8 100644 --- a/src/core/hle/service/am/service/library_applet_self_accessor.cpp +++ b/src/core/hle/service/am/service/library_applet_self_accessor.cpp @@ -63,7 +63,7 @@ ILibraryAppletSelfAccessor::ILibraryAppletSelfAccessor(Core::System& system_, {19, D<&ILibraryAppletSelfAccessor::GetDesirableKeyboardLayout>, "GetDesirableKeyboardLayout"}, {20, nullptr, "PopExtraStorage"}, {25, nullptr, "GetPopExtraStorageEvent"}, - {30, nullptr, "UnpopInData"}, + {30, D<&ILibraryAppletSelfAccessor::UnpopInData>, "UnpopInData"}, {31, nullptr, "UnpopExtraStorage"}, {40, nullptr, "GetIndirectLayerProducerHandle"}, {50, D<&ILibraryAppletSelfAccessor::ReportVisibleError>, "ReportVisibleError"}, @@ -223,6 +223,11 @@ Result ILibraryAppletSelfAccessor::ReportVisibleErrorWithErrorContext( R_SUCCEED(); } +Result ILibraryAppletSelfAccessor::UnpopInData() { + LOG_WARNING(Service_AM, "(STUBBED) called"); + R_SUCCEED(); +} + Result ILibraryAppletSelfAccessor::GetMainAppletApplicationDesiredLanguage( Out out_desired_language) { // FIXME: this is copied from IApplicationFunctions::GetDesiredLanguage diff --git a/src/core/hle/service/am/service/library_applet_self_accessor.h b/src/core/hle/service/am/service/library_applet_self_accessor.h index 3e60393c27..8c850faa8e 100644 --- a/src/core/hle/service/am/service/library_applet_self_accessor.h +++ b/src/core/hle/service/am/service/library_applet_self_accessor.h @@ -69,6 +69,7 @@ private: Result ReportVisibleError(ErrorCode error_code); Result ReportVisibleErrorWithErrorContext( ErrorCode error_code, InLargeData error_context); + Result UnpopInData(); Result GetMainAppletApplicationDesiredLanguage(Out out_desired_language); Result GetCurrentApplicationId(Out out_application_id); Result GetMainAppletAvailableUsers(Out out_can_select_any_user, Out out_users_count,