service: am: Implement remaining am functions needed by Qlaunch

This commit is contained in:
Narr the Reg
2024-01-03 22:16:12 -06:00
committed by german77
parent 9052a9b8ee
commit 10e54243e3
12 changed files with 248 additions and 12 deletions

View File

@ -439,6 +439,8 @@ add_library(core STATIC
hle/service/am/audio_controller.h
hle/service/am/common_state_getter.cpp
hle/service/am/common_state_getter.h
hle/service/am/cradle_firmware_updater.cpp
hle/service/am/cradle_firmware_updater.h
hle/service/am/debug_functions.cpp
hle/service/am/debug_functions.h
hle/service/am/display_controller.cpp

View File

@ -206,6 +206,41 @@ void PushInShowSoftwareKeyboard(Core::System& system, AppletStorageChannel& chan
channel.Push(std::make_shared<IStorage>(system, std::move(work_buffer)));
}
void PushInShowMyPageData(Core::System& system, AppletStorageChannel& channel) {
const CommonArguments arguments{
.arguments_version = CommonArgumentVersion::Version3,
.size = CommonArgumentSize::Version3,
.library_version = 0,
.theme_color = ThemeColor::BasicBlack,
.play_startup_sound = true,
.system_tick = system.CoreTiming().GetClockTicks(),
};
std::vector<u8> argument_data(sizeof(arguments));
std::vector<u8> settings_data{0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCE,
0x9E, 0xF8, 0xAF, 0xB1, 0xE8, 0x95, 0x90, 0x33, 0x6C,
0x0B, 0x22, 0x70, 0x07, 0xF4, 0xBB, 0x00};
settings_data.resize(0x10a8);
std::memcpy(argument_data.data(), &arguments, sizeof(arguments));
channel.Push(std::make_shared<IStorage>(system, std::move(argument_data)));
channel.Push(std::make_shared<IStorage>(system, std::move(settings_data)));
}
void PushInShowQlaunch(Core::System& system, AppletStorageChannel& channel) {
const CommonArguments arguments{
.arguments_version = CommonArgumentVersion::Version3,
.size = CommonArgumentSize::Version3,
.library_version = 0,
.theme_color = ThemeColor::BasicBlack,
.play_startup_sound = true,
.system_tick = system.CoreTiming().GetClockTicks(),
};
std::vector<u8> argument_data(sizeof(arguments));
std::memcpy(argument_data.data(), &arguments, sizeof(arguments));
channel.Push(std::make_shared<IStorage>(system, std::move(argument_data)));
}
} // namespace
AppletManager::AppletManager(Core::System& system) : m_system(system) {}
@ -298,6 +333,12 @@ void AppletManager::CreateAndInsertByFrontendAppletParameters(
case AppletId::Controller:
PushInShowController(m_system, InitializeFakeCallerApplet(m_system, applet));
break;
case AppletId::MyPage:
PushInShowMyPageData(m_system, InitializeFakeCallerApplet(m_system, applet));
break;
case AppletId::QLaunch:
PushInShowQlaunch(m_system, InitializeFakeCallerApplet(m_system, applet));
break;
default:
break;
}

View File

@ -37,7 +37,7 @@ ICommonStateGetter::ICommonStateGetter(Core::System& system_, std::shared_ptr<Ap
{20, nullptr, "PushToGeneralChannel"},
{30, nullptr, "GetHomeButtonReaderLockAccessor"},
{31, &ICommonStateGetter::GetReaderLockAccessorEx, "GetReaderLockAccessorEx"},
{32, nullptr, "GetWriterLockAccessorEx"},
{32, &ICommonStateGetter::GetWriterLockAccessorEx, "GetWriterLockAccessorEx"},
{40, nullptr, "GetCradleFwVersion"},
{50, &ICommonStateGetter::IsVrModeEnabled, "IsVrModeEnabled"},
{51, &ICommonStateGetter::SetVrModeEnabled, "SetVrModeEnabled"},
@ -61,7 +61,7 @@ ICommonStateGetter::ICommonStateGetter(Core::System& system_, std::shared_ptr<Ap
{100, nullptr, "SetHandlingHomeButtonShortPressedEnabled"},
{110, nullptr, "OpenMyGpuErrorHandler"},
{120, &ICommonStateGetter::GetAppletLaunchedHistory, "GetAppletLaunchedHistory"},
{200, nullptr, "GetOperationModeSystemInfo"},
{200, &ICommonStateGetter::GetOperationModeSystemInfo, "GetOperationModeSystemInfo"},
{300, &ICommonStateGetter::GetSettingsPlatformRegion, "GetSettingsPlatformRegion"},
{400, nullptr, "ActivateMigrationService"},
{401, nullptr, "DeactivateMigrationService"},
@ -160,6 +160,15 @@ void ICommonStateGetter::GetReaderLockAccessorEx(HLERequestContext& ctx) {
rb.PushIpcInterface<ILockAccessor>(system);
}
void ICommonStateGetter::GetWriterLockAccessorEx(HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "called");
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(ResultSuccess);
rb.PushIpcInterface<ILockAccessor>(system);
}
void ICommonStateGetter::GetAcquiredSleepLockEvent(HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "called");
@ -271,6 +280,14 @@ void ICommonStateGetter::PerformSystemButtonPressingIfInFocus(HLERequestContext&
rb.Push(ResultSuccess);
}
void ICommonStateGetter::GetOperationModeSystemInfo(HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push(0);
}
void ICommonStateGetter::GetAppletLaunchedHistory(HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");

View File

@ -54,6 +54,7 @@ private:
void RequestToAcquireSleepLock(HLERequestContext& ctx);
void GetAcquiredSleepLockEvent(HLERequestContext& ctx);
void GetReaderLockAccessorEx(HLERequestContext& ctx);
void GetWriterLockAccessorEx(HLERequestContext& ctx);
void GetDefaultDisplayResolutionChangeEvent(HLERequestContext& ctx);
void GetOperationMode(HLERequestContext& ctx);
void GetPerformanceMode(HLERequestContext& ctx);
@ -68,6 +69,7 @@ private:
void GetBuiltInDisplayType(HLERequestContext& ctx);
void PerformSystemButtonPressingIfInFocus(HLERequestContext& ctx);
void GetAppletLaunchedHistory(HLERequestContext& ctx);
void GetOperationModeSystemInfo(HLERequestContext& ctx);
void GetSettingsPlatformRegion(HLERequestContext& ctx);
void SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled(HLERequestContext& ctx);

View File

@ -0,0 +1,57 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/service/am/cradle_firmware_updater.h"
#include "core/hle/service/ipc_helpers.h"
namespace Service::AM {
ICradleFirmwareUpdater::ICradleFirmwareUpdater(Core::System& system_)
: ServiceFramework{system_, "ICradleFirmwareUpdater"},
service_context{system, "IHomeMenuFunctions"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "StartUpdate"},
{1, &ICradleFirmwareUpdater::FinishUpdate, "FinishUpdate"},
{2, &ICradleFirmwareUpdater::GetCradleDeviceInfo, "GetCradleDeviceInfo"},
{3, &ICradleFirmwareUpdater::GetCradleDeviceInfoChangeEvent, "GetCradleDeviceInfoChangeEvent"},
{4, nullptr, "GetUpdateProgressInfo"},
{5, nullptr, "GetLastInternalResult"},
};
// clang-format on
RegisterHandlers(functions);
cradle_device_info_event =
service_context.CreateEvent("IHomeMenuFunctions:PopFromGeneralChannelEvent");
}
ICradleFirmwareUpdater::~ICradleFirmwareUpdater() {
service_context.CloseEvent(cradle_device_info_event);
}
void ICradleFirmwareUpdater::FinishUpdate(HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void ICradleFirmwareUpdater::GetCradleDeviceInfo(HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 5};
rb.Push(ResultSuccess);
rb.Push<u64>(0);
rb.Push<u32>(0);
}
void ICradleFirmwareUpdater::GetCradleDeviceInfoChangeEvent(HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(ResultSuccess);
rb.PushCopyObjects(cradle_device_info_event->GetReadableEvent());
}
} // namespace Service::AM

View File

@ -0,0 +1,25 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "core/hle/service/kernel_helpers.h"
#include "core/hle/service/service.h"
namespace Service::AM {
class ICradleFirmwareUpdater final : public ServiceFramework<ICradleFirmwareUpdater> {
public:
explicit ICradleFirmwareUpdater(Core::System& system_);
~ICradleFirmwareUpdater() override;
private:
void FinishUpdate(HLERequestContext& ctx);
void GetCradleDeviceInfo(HLERequestContext& ctx);
void GetCradleDeviceInfoChangeEvent(HLERequestContext& ctx);
Kernel::KEvent* cradle_device_info_event;
KernelHelpers::ServiceContext service_context;
};
} // namespace Service::AM

View File

@ -1,13 +1,15 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/service/am/cradle_firmware_updater.h"
#include "core/hle/service/am/global_state_controller.h"
#include "core/hle/service/ipc_helpers.h"
namespace Service::AM {
IGlobalStateController::IGlobalStateController(Core::System& system_)
: ServiceFramework{system_, "IGlobalStateController"} {
: ServiceFramework{system_, "IGlobalStateController"},
service_context{system_, "IGlobalStateController"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "RequestToEnterSleep"},
@ -16,19 +18,53 @@ IGlobalStateController::IGlobalStateController(Core::System& system_)
{3, nullptr, "StartShutdownSequence"},
{4, nullptr, "StartRebootSequence"},
{9, nullptr, "IsAutoPowerDownRequested"},
{10, nullptr, "LoadAndApplyIdlePolicySettings"},
{10, &IGlobalStateController::LoadAndApplyIdlePolicySettings, "LoadAndApplyIdlePolicySettings"},
{11, nullptr, "NotifyCecSettingsChanged"},
{12, nullptr, "SetDefaultHomeButtonLongPressTime"},
{13, nullptr, "UpdateDefaultDisplayResolution"},
{14, nullptr, "ShouldSleepOnBoot"},
{15, nullptr, "GetHdcpAuthenticationFailedEvent"},
{30, nullptr, "OpenCradleFirmwareUpdater"},
{14, &IGlobalStateController::ShouldSleepOnBoot, "ShouldSleepOnBoot"},
{15, &IGlobalStateController::GetHdcpAuthenticationFailedEvent, "GetHdcpAuthenticationFailedEvent"},
{30, &IGlobalStateController::OpenCradleFirmwareUpdater, "OpenCradleFirmwareUpdater"},
};
// clang-format on
RegisterHandlers(functions);
hdcp_authentification_failed_event =
service_context.CreateEvent("IGlobalStateController::HdcpAuthenticationFailedEvent");
}
IGlobalStateController::~IGlobalStateController() = default;
void IGlobalStateController::LoadAndApplyIdlePolicySettings(HLERequestContext& ctx) {
LOG_ERROR(Service_AM, "called");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void IGlobalStateController::ShouldSleepOnBoot(HLERequestContext& ctx) {
LOG_ERROR(Service_AM, "called");
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push(0);
}
void IGlobalStateController::GetHdcpAuthenticationFailedEvent(HLERequestContext& ctx) {
LOG_ERROR(Service_AM, "called");
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(ResultSuccess);
rb.PushCopyObjects(hdcp_authentification_failed_event->GetReadableEvent());
}
void IGlobalStateController::OpenCradleFirmwareUpdater(HLERequestContext& ctx) {
LOG_ERROR(Service_AM, "called");
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(ResultSuccess);
rb.PushIpcInterface<ICradleFirmwareUpdater>(system);
}
} // namespace Service::AM

View File

@ -3,6 +3,7 @@
#pragma once
#include "core/hle/service/kernel_helpers.h"
#include "core/hle/service/service.h"
namespace Service::AM {
@ -11,6 +12,15 @@ class IGlobalStateController final : public ServiceFramework<IGlobalStateControl
public:
explicit IGlobalStateController(Core::System& system_);
~IGlobalStateController() override;
private:
void LoadAndApplyIdlePolicySettings(HLERequestContext& ctx);
void ShouldSleepOnBoot(HLERequestContext& ctx);
void GetHdcpAuthenticationFailedEvent(HLERequestContext& ctx);
void OpenCradleFirmwareUpdater(HLERequestContext& ctx);
Kernel::KEvent* hdcp_authentification_failed_event;
KernelHelpers::ServiceContext service_context;
};
} // namespace Service::AM

View File

@ -12,14 +12,14 @@ IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_)
// clang-format off
static const FunctionInfo functions[] = {
{10, &IHomeMenuFunctions::RequestToGetForeground, "RequestToGetForeground"},
{11, nullptr, "LockForeground"},
{12, nullptr, "UnlockForeground"},
{11, &IHomeMenuFunctions::LockForeground, "LockForeground"},
{12, &IHomeMenuFunctions::UnlockForeground, "UnlockForeground"},
{20, nullptr, "PopFromGeneralChannel"},
{21, &IHomeMenuFunctions::GetPopFromGeneralChannelEvent, "GetPopFromGeneralChannelEvent"},
{30, nullptr, "GetHomeButtonWriterLockAccessor"},
{31, nullptr, "GetWriterLockAccessorEx"},
{40, nullptr, "IsSleepEnabled"},
{41, nullptr, "IsRebootEnabled"},
{41, &IHomeMenuFunctions::IsRebootEnabled, "IsRebootEnabled"},
{50, nullptr, "LaunchSystemApplet"},
{51, nullptr, "LaunchStarter"},
{100, nullptr, "PopRequestLaunchApplicationForDebug"},
@ -46,6 +46,20 @@ void IHomeMenuFunctions::RequestToGetForeground(HLERequestContext& ctx) {
rb.Push(ResultSuccess);
}
void IHomeMenuFunctions::LockForeground(HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void IHomeMenuFunctions::UnlockForeground(HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void IHomeMenuFunctions::GetPopFromGeneralChannelEvent(HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
@ -54,4 +68,12 @@ void IHomeMenuFunctions::GetPopFromGeneralChannelEvent(HLERequestContext& ctx) {
rb.PushCopyObjects(pop_from_general_channel_event->GetReadableEvent());
}
void IHomeMenuFunctions::IsRebootEnabled(HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push<u8>(true);
}
} // namespace Service::AM

View File

@ -15,7 +15,10 @@ public:
private:
void RequestToGetForeground(HLERequestContext& ctx);
void LockForeground(HLERequestContext& ctx);
void UnlockForeground(HLERequestContext& ctx);
void GetPopFromGeneralChannelEvent(HLERequestContext& ctx);
void IsRebootEnabled(HLERequestContext& ctx);
KernelHelpers::ServiceContext service_context;

View File

@ -49,7 +49,7 @@ ISelfController::ISelfController(Core::System& system_, std::shared_ptr<Applet>
{46, nullptr, "SetRecordingLayerCompositionEnabled"},
{50, &ISelfController::SetHandlesRequestToDisplay, "SetHandlesRequestToDisplay"},
{51, &ISelfController::ApproveToDisplay, "ApproveToDisplay"},
{60, nullptr, "OverrideAutoSleepTimeAndDimmingTime"},
{60, &ISelfController::OverrideAutoSleepTimeAndDimmingTime, "OverrideAutoSleepTimeAndDimmingTime"},
{61, &ISelfController::SetMediaPlaybackState, "SetMediaPlaybackState"},
{62, &ISelfController::SetIdleTimeDetectionExtension, "SetIdleTimeDetectionExtension"},
{63, &ISelfController::GetIdleTimeDetectionExtension, "GetIdleTimeDetectionExtension"},
@ -61,7 +61,7 @@ ISelfController::ISelfController(Core::System& system_, std::shared_ptr<Applet>
{69, &ISelfController::IsAutoSleepDisabled, "IsAutoSleepDisabled"},
{70, nullptr, "ReportMultimediaError"},
{71, nullptr, "GetCurrentIlluminanceEx"},
{72, nullptr, "SetInputDetectionPolicy"},
{72, &ISelfController::SetInputDetectionPolicy, "SetInputDetectionPolicy"},
{80, nullptr, "SetWirelessPriorityMode"},
{90, &ISelfController::GetAccumulatedSuspendedTickValue, "GetAccumulatedSuspendedTickValue"},
{91, &ISelfController::GetAccumulatedSuspendedTickChangedEvent, "GetAccumulatedSuspendedTickChangedEvent"},
@ -327,6 +327,18 @@ void ISelfController::ApproveToDisplay(HLERequestContext& ctx) {
rb.Push(ResultSuccess);
}
void ISelfController::OverrideAutoSleepTimeAndDimmingTime(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto a = rp.Pop<u32>();
const auto b = rp.Pop<u32>();
const auto c = rp.Pop<u32>();
const auto d = rp.Pop<u32>();
LOG_WARNING(Service_AM, "(STUBBED) called, a={}, b={}, c={}, d={}", a, b, c, d);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void ISelfController::SetMediaPlaybackState(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const u8 state = rp.Pop<u8>();
@ -399,6 +411,13 @@ void ISelfController::IsAutoSleepDisabled(HLERequestContext& ctx) {
rb.Push(applet->auto_sleep_disabled);
}
void ISelfController::SetInputDetectionPolicy(HLERequestContext& ctx) {
LOG_ERROR(Service_AM, "called.");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void ISelfController::GetAccumulatedSuspendedTickValue(HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "called.");

View File

@ -39,12 +39,14 @@ private:
void CreateManagedDisplaySeparableLayer(HLERequestContext& ctx);
void SetHandlesRequestToDisplay(HLERequestContext& ctx);
void ApproveToDisplay(HLERequestContext& ctx);
void OverrideAutoSleepTimeAndDimmingTime(HLERequestContext& ctx);
void SetMediaPlaybackState(HLERequestContext& ctx);
void SetIdleTimeDetectionExtension(HLERequestContext& ctx);
void GetIdleTimeDetectionExtension(HLERequestContext& ctx);
void ReportUserIsActive(HLERequestContext& ctx);
void SetAutoSleepDisabled(HLERequestContext& ctx);
void IsAutoSleepDisabled(HLERequestContext& ctx);
void SetInputDetectionPolicy(HLERequestContext& ctx);
void GetAccumulatedSuspendedTickValue(HLERequestContext& ctx);
void GetAccumulatedSuspendedTickChangedEvent(HLERequestContext& ctx);
void SetAlbumImageTakenNotificationEnabled(HLERequestContext& ctx);