summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2024-02-12 02:45:40 +0100
committerLiam <byteslice@airmail.cc>2024-02-12 15:17:25 +0100
commitbbb1ff6574b2e4e13b3aec68c20e62c622845859 (patch)
tree9436432f9913b8b3162f33c6c2130eadd7308e7e /src/core
parentam: rewrite ILockAccessor (diff)
downloadyuzu-bbb1ff6574b2e4e13b3aec68c20e62c622845859.tar
yuzu-bbb1ff6574b2e4e13b3aec68c20e62c622845859.tar.gz
yuzu-bbb1ff6574b2e4e13b3aec68c20e62c622845859.tar.bz2
yuzu-bbb1ff6574b2e4e13b3aec68c20e62c622845859.tar.lz
yuzu-bbb1ff6574b2e4e13b3aec68c20e62c622845859.tar.xz
yuzu-bbb1ff6574b2e4e13b3aec68c20e62c622845859.tar.zst
yuzu-bbb1ff6574b2e4e13b3aec68c20e62c622845859.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/hle/service/am/service/application_accessor.cpp138
-rw-r--r--src/core/hle/service/am/service/application_accessor.h40
3 files changed, 180 insertions, 0 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 073e42e00..db27e0f3e 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -441,6 +441,8 @@ add_library(core STATIC
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.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.h
hle/service/am/service/application_proxy_service.cpp
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 @@
+// 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
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 @@
+// 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