yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

am: add IApplicationAccessor

This commit is contained in:
Liam 2024-02-11 20:45:40 -05:00
parent 927fa532e5
commit bbb1ff6574
3 changed files with 180 additions and 0 deletions

View File

@ -441,6 +441,8 @@ add_library(core STATIC
hle/service/am/service/all_system_applet_proxies_service.h hle/service/am/service/all_system_applet_proxies_service.h
hle/service/am/service/applet_common_functions.cpp hle/service/am/service/applet_common_functions.cpp
hle/service/am/service/applet_common_functions.h hle/service/am/service/applet_common_functions.h
hle/service/am/service/application_accessor.cpp
hle/service/am/service/application_accessor.h
hle/service/am/service/application_functions.cpp hle/service/am/service/application_functions.cpp
hle/service/am/service/application_functions.h hle/service/am/service/application_functions.h
hle/service/am/service/application_proxy_service.cpp hle/service/am/service/application_proxy_service.cpp

View File

@ -0,0 +1,138 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/result.h"
#include "core/hle/service/am/am_types.h"
#include "core/hle/service/am/applet.h"
#include "core/hle/service/am/applet_data_broker.h"
#include "core/hle/service/am/applet_manager.h"
#include "core/hle/service/am/service/application_accessor.h"
#include "core/hle/service/am/service/library_applet_accessor.h"
#include "core/hle/service/am/service/storage.h"
#include "core/hle/service/cmif_serialization.h"
namespace Service::AM {
IApplicationAccessor::IApplicationAccessor(Core::System& system_, std::shared_ptr<Applet> applet)
: ServiceFramework{system_, "IApplicationAccessor"}, m_applet(std::move(applet)) {
// clang-format off
static const FunctionInfo functions[] = {
{0, D<&IApplicationAccessor::GetAppletStateChangedEvent>, "GetAppletStateChangedEvent"},
{1, nullptr, "IsCompleted"},
{10, D<&IApplicationAccessor::Start>, "Start"},
{20, D<&IApplicationAccessor::RequestExit>, "RequestExit"},
{25, D<&IApplicationAccessor::Terminate>, "Terminate"},
{30, D<&IApplicationAccessor::GetResult>, "GetResult"},
{101, D<&IApplicationAccessor::RequestForApplicationToGetForeground>, "RequestForApplicationToGetForeground"},
{110, nullptr, "TerminateAllLibraryApplets"},
{111, nullptr, "AreAnyLibraryAppletsLeft"},
{112, D<&IApplicationAccessor::GetCurrentLibraryApplet>, "GetCurrentLibraryApplet"},
{120, nullptr, "GetApplicationId"},
{121, D<&IApplicationAccessor::PushLaunchParameter>, "PushLaunchParameter"},
{122, D<&IApplicationAccessor::GetApplicationControlProperty>, "GetApplicationControlProperty"},
{123, nullptr, "GetApplicationLaunchProperty"},
{124, nullptr, "GetApplicationLaunchRequestInfo"},
{130, D<&IApplicationAccessor::SetUsers>, "SetUsers"},
{131, D<&IApplicationAccessor::CheckRightsEnvironmentAvailable>, "CheckRightsEnvironmentAvailable"},
{132, D<&IApplicationAccessor::GetNsRightsEnvironmentHandle>, "GetNsRightsEnvironmentHandle"},
{140, nullptr, "GetDesirableUids"},
{150, D<&IApplicationAccessor::ReportApplicationExitTimeout>, "ReportApplicationExitTimeout"},
{160, nullptr, "SetApplicationAttribute"},
{170, nullptr, "HasSaveDataAccessPermission"},
{180, nullptr, "PushToFriendInvitationStorageChannel"},
{190, nullptr, "PushToNotificationStorageChannel"},
{200, nullptr, "RequestApplicationSoftReset"},
{201, nullptr, "RestartApplicationTimer"},
};
// clang-format on
RegisterHandlers(functions);
}
IApplicationAccessor::~IApplicationAccessor() = default;
Result IApplicationAccessor::Start() {
LOG_INFO(Service_AM, "called");
m_applet->process->Run();
R_SUCCEED();
}
Result IApplicationAccessor::RequestExit() {
LOG_INFO(Service_AM, "called");
m_applet->message_queue.RequestExit();
R_SUCCEED();
}
Result IApplicationAccessor::Terminate() {
LOG_INFO(Service_AM, "called");
m_applet->process->Terminate();
R_SUCCEED();
}
Result IApplicationAccessor::GetResult() {
LOG_INFO(Service_AM, "called");
R_SUCCEED();
}
Result IApplicationAccessor::GetAppletStateChangedEvent(
OutCopyHandle<Kernel::KReadableEvent> out_event) {
LOG_INFO(Service_AM, "called");
*out_event = m_applet->caller_applet_broker->GetStateChangedEvent().GetHandle();
R_SUCCEED();
}
Result IApplicationAccessor::PushLaunchParameter(LaunchParameterKind kind,
SharedPointer<IStorage> storage) {
LOG_INFO(Service_AM, "called, kind={}", kind);
switch (kind) {
case LaunchParameterKind::AccountPreselectedUser:
m_applet->preselected_user_launch_parameter.push_back(storage->GetData());
R_SUCCEED();
default:
R_THROW(ResultUnknown);
}
}
Result IApplicationAccessor::GetApplicationControlProperty(
OutBuffer<BufferAttr_HipcMapAlias> out_control_property) {
LOG_WARNING(Service_AM, "(STUBBED) called");
R_THROW(ResultUnknown);
}
Result IApplicationAccessor::SetUsers(bool enable,
InArray<Common::UUID, BufferAttr_HipcMapAlias> user_ids) {
LOG_INFO(Service_AM, "called, enable={} user_id_count={}", enable, user_ids.size());
R_SUCCEED();
}
Result IApplicationAccessor::GetCurrentLibraryApplet(
Out<SharedPointer<ILibraryAppletAccessor>> out_accessor) {
LOG_INFO(Service_AM, "(STUBBED) called");
*out_accessor = nullptr;
R_SUCCEED();
}
Result IApplicationAccessor::RequestForApplicationToGetForeground() {
LOG_WARNING(Service_AM, "(STUBBED) called");
R_THROW(ResultUnknown);
}
Result IApplicationAccessor::CheckRightsEnvironmentAvailable(Out<bool> out_is_available) {
LOG_WARNING(Service_AM, "(STUBBED) called");
*out_is_available = true;
R_SUCCEED();
}
Result IApplicationAccessor::GetNsRightsEnvironmentHandle(Out<u64> out_handle) {
LOG_WARNING(Service_AM, "(STUBBED) called");
*out_handle = 0xdeadbeef;
R_SUCCEED();
}
Result IApplicationAccessor::ReportApplicationExitTimeout() {
LOG_ERROR(Service_AM, "called");
R_SUCCEED();
}
} // namespace Service::AM

View File

@ -0,0 +1,40 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/uuid.h"
#include "core/hle/service/am/am_types.h"
#include "core/hle/service/cmif_types.h"
#include "core/hle/service/service.h"
namespace Service::AM {
struct Applet;
class ILibraryAppletAccessor;
class IStorage;
class IApplicationAccessor final : public ServiceFramework<IApplicationAccessor> {
public:
explicit IApplicationAccessor(Core::System& system_, std::shared_ptr<Applet> applet);
~IApplicationAccessor() override;
private:
Result Start();
Result RequestExit();
Result Terminate();
Result GetResult();
Result GetAppletStateChangedEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
Result PushLaunchParameter(LaunchParameterKind kind, SharedPointer<IStorage> storage);
Result GetApplicationControlProperty(OutBuffer<BufferAttr_HipcMapAlias> out_control_property);
Result SetUsers(bool enable, InArray<Common::UUID, BufferAttr_HipcMapAlias> user_ids);
Result GetCurrentLibraryApplet(Out<SharedPointer<ILibraryAppletAccessor>> out_accessor);
Result RequestForApplicationToGetForeground();
Result CheckRightsEnvironmentAvailable(Out<bool> out_is_available);
Result GetNsRightsEnvironmentHandle(Out<u64> out_handle);
Result ReportApplicationExitTimeout();
const std::shared_ptr<Applet> m_applet;
};
} // namespace Service::AM