From bdc47693f154ffe41f16a452f65d9bd609a72683 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Fri, 17 May 2019 21:47:07 -0400 Subject: applets: Save report on stubbed applet This also reworks the applet data storage to be peekable. --- src/core/hle/service/am/applets/applets.cpp | 33 ++++++++++++++++------ src/core/hle/service/am/applets/applets.h | 16 ++++++++--- .../hle/service/am/applets/general_backend.cpp | 10 ++++++- src/core/hle/service/am/applets/general_backend.h | 5 +++- 4 files changed, 49 insertions(+), 15 deletions(-) diff --git a/src/core/hle/service/am/applets/applets.cpp b/src/core/hle/service/am/applets/applets.cpp index e812c66e9..2a945bc7b 100644 --- a/src/core/hle/service/am/applets/applets.cpp +++ b/src/core/hle/service/am/applets/applets.cpp @@ -35,12 +35,27 @@ AppletDataBroker::AppletDataBroker() { AppletDataBroker::~AppletDataBroker() = default; +AppletDataBroker::RawChannelData AppletDataBroker::PeekDataToAppletForDebug() const { + std::vector> out_normal; + std::vector> out_interactive; + + for (const auto& storage : in_channel) { + out_normal.push_back(storage->GetData()); + } + + for (const auto& storage : in_interactive_channel) { + out_interactive.push_back(storage->GetData()); + } + + return {out_normal, out_interactive}; +} + std::unique_ptr AppletDataBroker::PopNormalDataToGame() { if (out_channel.empty()) return nullptr; auto out = std::move(out_channel.front()); - out_channel.pop(); + out_channel.pop_front(); return out; } @@ -49,7 +64,7 @@ std::unique_ptr AppletDataBroker::PopNormalDataToApplet() { return nullptr; auto out = std::move(in_channel.front()); - in_channel.pop(); + in_channel.pop_front(); return out; } @@ -58,7 +73,7 @@ std::unique_ptr AppletDataBroker::PopInteractiveDataToGame() { return nullptr; auto out = std::move(out_interactive_channel.front()); - out_interactive_channel.pop(); + out_interactive_channel.pop_front(); return out; } @@ -67,25 +82,25 @@ std::unique_ptr AppletDataBroker::PopInteractiveDataToApplet() { return nullptr; auto out = std::move(in_interactive_channel.front()); - in_interactive_channel.pop(); + in_interactive_channel.pop_front(); return out; } void AppletDataBroker::PushNormalDataFromGame(IStorage storage) { - in_channel.push(std::make_unique(storage)); + in_channel.push_back(std::make_unique(storage)); } void AppletDataBroker::PushNormalDataFromApplet(IStorage storage) { - out_channel.push(std::make_unique(storage)); + out_channel.push_back(std::make_unique(storage)); pop_out_data_event.writable->Signal(); } void AppletDataBroker::PushInteractiveDataFromGame(IStorage storage) { - in_interactive_channel.push(std::make_unique(storage)); + in_interactive_channel.push_back(std::make_unique(storage)); } void AppletDataBroker::PushInteractiveDataFromApplet(IStorage storage) { - out_interactive_channel.push(std::make_unique(storage)); + out_interactive_channel.push_back(std::make_unique(storage)); pop_interactive_out_data_event.writable->Signal(); } @@ -189,7 +204,7 @@ std::shared_ptr AppletManager::GetApplet(AppletId id) const { UNIMPLEMENTED_MSG( "No backend implementation exists for applet_id={:02X}! Falling back to stub applet.", static_cast(id)); - return std::make_shared(); + return std::make_shared(id); } } diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h index 7f932672c..8c2c15968 100644 --- a/src/core/hle/service/am/applets/applets.h +++ b/src/core/hle/service/am/applets/applets.h @@ -54,6 +54,14 @@ public: AppletDataBroker(); ~AppletDataBroker(); + struct RawChannelData { + std::vector> normal; + std::vector> interactive; + }; + + // Retrieves but does not pop the data sent to applet. + RawChannelData PeekDataToAppletForDebug() const; + std::unique_ptr PopNormalDataToGame(); std::unique_ptr PopNormalDataToApplet(); @@ -76,16 +84,16 @@ private: // Queues are named from applet's perspective // PopNormalDataToApplet and PushNormalDataFromGame - std::queue> in_channel; + std::deque> in_channel; // PopNormalDataToGame and PushNormalDataFromApplet - std::queue> out_channel; + std::deque> out_channel; // PopInteractiveDataToApplet and PushInteractiveDataFromGame - std::queue> in_interactive_channel; + std::deque> in_interactive_channel; // PopInteractiveDataToGame and PushInteractiveDataFromApplet - std::queue> out_interactive_channel; + std::deque> out_interactive_channel; Kernel::EventPair state_changed_event; diff --git a/src/core/hle/service/am/applets/general_backend.cpp b/src/core/hle/service/am/applets/general_backend.cpp index c591b9ac2..55865176c 100644 --- a/src/core/hle/service/am/applets/general_backend.cpp +++ b/src/core/hle/service/am/applets/general_backend.cpp @@ -13,6 +13,7 @@ #include "core/hle/result.h" #include "core/hle/service/am/am.h" #include "core/hle/service/am/applets/general_backend.h" +#include "core/reporter.h" namespace Service::AM::Applets { @@ -83,13 +84,20 @@ void PhotoViewer::ViewFinished() { broker.SignalStateChanged(); } -StubApplet::StubApplet() = default; +StubApplet::StubApplet(AppletId id) : id(id) {} StubApplet::~StubApplet() = default; void StubApplet::Initialize() { LOG_WARNING(Service_AM, "called (STUBBED)"); Applet::Initialize(); + + const auto data = broker.PeekDataToAppletForDebug(); + Core::System::GetInstance().GetReporter().SaveUnimplementedAppletReport( + static_cast(id), common_args.arguments_version, common_args.library_version, + common_args.theme_color, common_args.play_startup_sound, common_args.system_tick, + data.normal, data.interactive); + LogCurrentStorage(broker, "Initialize"); } diff --git a/src/core/hle/service/am/applets/general_backend.h b/src/core/hle/service/am/applets/general_backend.h index 2dd255d7c..bc919a8dd 100644 --- a/src/core/hle/service/am/applets/general_backend.h +++ b/src/core/hle/service/am/applets/general_backend.h @@ -34,7 +34,7 @@ private: class StubApplet final : public Applet { public: - StubApplet(); + StubApplet(AppletId id); ~StubApplet() override; void Initialize() override; @@ -43,6 +43,9 @@ public: ResultCode GetStatus() const override; void ExecuteInteractive() override; void Execute() override; + +private: + AppletId id; }; } // namespace Service::AM::Applets -- cgit v1.2.3