diff options
| author | 2024-02-11 20:45:40 -0500 | |
|---|---|---|
| committer | 2024-02-12 09:17:25 -0500 | |
| commit | bbb1ff6574b2e4e13b3aec68c20e62c622845859 (patch) | |
| tree | 9436432f9913b8b3162f33c6c2130eadd7308e7e /src/core/hle/service/am | |
| parent | am: rewrite ILockAccessor (diff) | |
| download | yuzu-bbb1ff6574b2e4e13b3aec68c20e62c622845859.tar.gz yuzu-bbb1ff6574b2e4e13b3aec68c20e62c622845859.tar.xz yuzu-bbb1ff6574b2e4e13b3aec68c20e62c622845859.zip | |
am: add IApplicationAccessor
Diffstat (limited to 'src/core/hle/service/am')
| -rw-r--r-- | src/core/hle/service/am/service/application_accessor.cpp | 138 | ||||
| -rw-r--r-- | src/core/hle/service/am/service/application_accessor.h | 40 |
2 files changed, 178 insertions, 0 deletions
diff --git a/src/core/hle/service/am/service/application_accessor.cpp b/src/core/hle/service/am/service/application_accessor.cpp new file mode 100644 index 000000000..6e7d110e8 --- /dev/null +++ b/src/core/hle/service/am/service/application_accessor.cpp | |||
| @@ -0,0 +1,138 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "core/hle/result.h" | ||
| 5 | #include "core/hle/service/am/am_types.h" | ||
| 6 | #include "core/hle/service/am/applet.h" | ||
| 7 | #include "core/hle/service/am/applet_data_broker.h" | ||
| 8 | #include "core/hle/service/am/applet_manager.h" | ||
| 9 | #include "core/hle/service/am/service/application_accessor.h" | ||
| 10 | #include "core/hle/service/am/service/library_applet_accessor.h" | ||
| 11 | #include "core/hle/service/am/service/storage.h" | ||
| 12 | #include "core/hle/service/cmif_serialization.h" | ||
| 13 | |||
| 14 | namespace Service::AM { | ||
| 15 | |||
| 16 | IApplicationAccessor::IApplicationAccessor(Core::System& system_, std::shared_ptr<Applet> applet) | ||
| 17 | : ServiceFramework{system_, "IApplicationAccessor"}, m_applet(std::move(applet)) { | ||
| 18 | // clang-format off | ||
| 19 | static const FunctionInfo functions[] = { | ||
| 20 | {0, D<&IApplicationAccessor::GetAppletStateChangedEvent>, "GetAppletStateChangedEvent"}, | ||
| 21 | {1, nullptr, "IsCompleted"}, | ||
| 22 | {10, D<&IApplicationAccessor::Start>, "Start"}, | ||
| 23 | {20, D<&IApplicationAccessor::RequestExit>, "RequestExit"}, | ||
| 24 | {25, D<&IApplicationAccessor::Terminate>, "Terminate"}, | ||
| 25 | {30, D<&IApplicationAccessor::GetResult>, "GetResult"}, | ||
| 26 | {101, D<&IApplicationAccessor::RequestForApplicationToGetForeground>, "RequestForApplicationToGetForeground"}, | ||
| 27 | {110, nullptr, "TerminateAllLibraryApplets"}, | ||
| 28 | {111, nullptr, "AreAnyLibraryAppletsLeft"}, | ||
| 29 | {112, D<&IApplicationAccessor::GetCurrentLibraryApplet>, "GetCurrentLibraryApplet"}, | ||
| 30 | {120, nullptr, "GetApplicationId"}, | ||
| 31 | {121, D<&IApplicationAccessor::PushLaunchParameter>, "PushLaunchParameter"}, | ||
| 32 | {122, D<&IApplicationAccessor::GetApplicationControlProperty>, "GetApplicationControlProperty"}, | ||
| 33 | {123, nullptr, "GetApplicationLaunchProperty"}, | ||
| 34 | {124, nullptr, "GetApplicationLaunchRequestInfo"}, | ||
| 35 | {130, D<&IApplicationAccessor::SetUsers>, "SetUsers"}, | ||
| 36 | {131, D<&IApplicationAccessor::CheckRightsEnvironmentAvailable>, "CheckRightsEnvironmentAvailable"}, | ||
| 37 | {132, D<&IApplicationAccessor::GetNsRightsEnvironmentHandle>, "GetNsRightsEnvironmentHandle"}, | ||
| 38 | {140, nullptr, "GetDesirableUids"}, | ||
| 39 | {150, D<&IApplicationAccessor::ReportApplicationExitTimeout>, "ReportApplicationExitTimeout"}, | ||
| 40 | {160, nullptr, "SetApplicationAttribute"}, | ||
| 41 | {170, nullptr, "HasSaveDataAccessPermission"}, | ||
| 42 | {180, nullptr, "PushToFriendInvitationStorageChannel"}, | ||
| 43 | {190, nullptr, "PushToNotificationStorageChannel"}, | ||
| 44 | {200, nullptr, "RequestApplicationSoftReset"}, | ||
| 45 | {201, nullptr, "RestartApplicationTimer"}, | ||
| 46 | }; | ||
| 47 | // clang-format on | ||
| 48 | |||
| 49 | RegisterHandlers(functions); | ||
| 50 | } | ||
| 51 | |||
| 52 | IApplicationAccessor::~IApplicationAccessor() = default; | ||
| 53 | |||
| 54 | Result IApplicationAccessor::Start() { | ||
| 55 | LOG_INFO(Service_AM, "called"); | ||
| 56 | m_applet->process->Run(); | ||
| 57 | R_SUCCEED(); | ||
| 58 | } | ||
| 59 | |||
| 60 | Result IApplicationAccessor::RequestExit() { | ||
| 61 | LOG_INFO(Service_AM, "called"); | ||
| 62 | m_applet->message_queue.RequestExit(); | ||
| 63 | R_SUCCEED(); | ||
| 64 | } | ||
| 65 | |||
| 66 | Result IApplicationAccessor::Terminate() { | ||
| 67 | LOG_INFO(Service_AM, "called"); | ||
| 68 | m_applet->process->Terminate(); | ||
| 69 | R_SUCCEED(); | ||
| 70 | } | ||
| 71 | |||
| 72 | Result IApplicationAccessor::GetResult() { | ||
| 73 | LOG_INFO(Service_AM, "called"); | ||
| 74 | R_SUCCEED(); | ||
| 75 | } | ||
| 76 | |||
| 77 | Result IApplicationAccessor::GetAppletStateChangedEvent( | ||
| 78 | OutCopyHandle<Kernel::KReadableEvent> out_event) { | ||
| 79 | LOG_INFO(Service_AM, "called"); | ||
| 80 | *out_event = m_applet->caller_applet_broker->GetStateChangedEvent().GetHandle(); | ||
| 81 | R_SUCCEED(); | ||
| 82 | } | ||
| 83 | |||
| 84 | Result IApplicationAccessor::PushLaunchParameter(LaunchParameterKind kind, | ||
| 85 | SharedPointer<IStorage> storage) { | ||
| 86 | LOG_INFO(Service_AM, "called, kind={}", kind); | ||
| 87 | |||
| 88 | switch (kind) { | ||
| 89 | case LaunchParameterKind::AccountPreselectedUser: | ||
| 90 | m_applet->preselected_user_launch_parameter.push_back(storage->GetData()); | ||
| 91 | R_SUCCEED(); | ||
| 92 | default: | ||
| 93 | R_THROW(ResultUnknown); | ||
| 94 | } | ||
| 95 | } | ||
| 96 | |||
| 97 | Result IApplicationAccessor::GetApplicationControlProperty( | ||
| 98 | OutBuffer<BufferAttr_HipcMapAlias> out_control_property) { | ||
| 99 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 100 | R_THROW(ResultUnknown); | ||
| 101 | } | ||
| 102 | |||
| 103 | Result IApplicationAccessor::SetUsers(bool enable, | ||
| 104 | InArray<Common::UUID, BufferAttr_HipcMapAlias> user_ids) { | ||
| 105 | LOG_INFO(Service_AM, "called, enable={} user_id_count={}", enable, user_ids.size()); | ||
| 106 | R_SUCCEED(); | ||
| 107 | } | ||
| 108 | |||
| 109 | Result IApplicationAccessor::GetCurrentLibraryApplet( | ||
| 110 | Out<SharedPointer<ILibraryAppletAccessor>> out_accessor) { | ||
| 111 | LOG_INFO(Service_AM, "(STUBBED) called"); | ||
| 112 | *out_accessor = nullptr; | ||
| 113 | R_SUCCEED(); | ||
| 114 | } | ||
| 115 | |||
| 116 | Result IApplicationAccessor::RequestForApplicationToGetForeground() { | ||
| 117 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 118 | R_THROW(ResultUnknown); | ||
| 119 | } | ||
| 120 | |||
| 121 | Result IApplicationAccessor::CheckRightsEnvironmentAvailable(Out<bool> out_is_available) { | ||
| 122 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 123 | *out_is_available = true; | ||
| 124 | R_SUCCEED(); | ||
| 125 | } | ||
| 126 | |||
| 127 | Result IApplicationAccessor::GetNsRightsEnvironmentHandle(Out<u64> out_handle) { | ||
| 128 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 129 | *out_handle = 0xdeadbeef; | ||
| 130 | R_SUCCEED(); | ||
| 131 | } | ||
| 132 | |||
| 133 | Result IApplicationAccessor::ReportApplicationExitTimeout() { | ||
| 134 | LOG_ERROR(Service_AM, "called"); | ||
| 135 | R_SUCCEED(); | ||
| 136 | } | ||
| 137 | |||
| 138 | } // namespace Service::AM | ||
diff --git a/src/core/hle/service/am/service/application_accessor.h b/src/core/hle/service/am/service/application_accessor.h new file mode 100644 index 000000000..39a9b2153 --- /dev/null +++ b/src/core/hle/service/am/service/application_accessor.h | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "common/uuid.h" | ||
| 7 | #include "core/hle/service/am/am_types.h" | ||
| 8 | #include "core/hle/service/cmif_types.h" | ||
| 9 | #include "core/hle/service/service.h" | ||
| 10 | |||
| 11 | namespace Service::AM { | ||
| 12 | |||
| 13 | struct Applet; | ||
| 14 | class ILibraryAppletAccessor; | ||
| 15 | class IStorage; | ||
| 16 | |||
| 17 | class IApplicationAccessor final : public ServiceFramework<IApplicationAccessor> { | ||
| 18 | public: | ||
| 19 | explicit IApplicationAccessor(Core::System& system_, std::shared_ptr<Applet> applet); | ||
| 20 | ~IApplicationAccessor() override; | ||
| 21 | |||
| 22 | private: | ||
| 23 | Result Start(); | ||
| 24 | Result RequestExit(); | ||
| 25 | Result Terminate(); | ||
| 26 | Result GetResult(); | ||
| 27 | Result GetAppletStateChangedEvent(OutCopyHandle<Kernel::KReadableEvent> out_event); | ||
| 28 | Result PushLaunchParameter(LaunchParameterKind kind, SharedPointer<IStorage> storage); | ||
| 29 | Result GetApplicationControlProperty(OutBuffer<BufferAttr_HipcMapAlias> out_control_property); | ||
| 30 | Result SetUsers(bool enable, InArray<Common::UUID, BufferAttr_HipcMapAlias> user_ids); | ||
| 31 | Result GetCurrentLibraryApplet(Out<SharedPointer<ILibraryAppletAccessor>> out_accessor); | ||
| 32 | Result RequestForApplicationToGetForeground(); | ||
| 33 | Result CheckRightsEnvironmentAvailable(Out<bool> out_is_available); | ||
| 34 | Result GetNsRightsEnvironmentHandle(Out<u64> out_handle); | ||
| 35 | Result ReportApplicationExitTimeout(); | ||
| 36 | |||
| 37 | const std::shared_ptr<Applet> m_applet; | ||
| 38 | }; | ||
| 39 | |||
| 40 | } // namespace Service::AM | ||