Implement SetOperationModeChangedNotification and SetAlbumImageTakenNotificationEnabled

These are typically set to true on application boot, these values determine whether an AppletMessage gets sent when certain actions are performed such as changing from docked to undocked, capturing a screenshot, etc.
This commit is contained in:
Morph
2019-10-27 02:49:58 -04:00
parent e3ee017e91
commit 11184fd433
4 changed files with 73 additions and 29 deletions

View File

@@ -290,7 +290,7 @@ ISelfController::ISelfController(Core::System& system,
{80, nullptr, "SetWirelessPriorityMode"}, {80, nullptr, "SetWirelessPriorityMode"},
{90, &ISelfController::GetAccumulatedSuspendedTickValue, "GetAccumulatedSuspendedTickValue"}, {90, &ISelfController::GetAccumulatedSuspendedTickValue, "GetAccumulatedSuspendedTickValue"},
{91, &ISelfController::GetAccumulatedSuspendedTickChangedEvent, "GetAccumulatedSuspendedTickChangedEvent"}, {91, &ISelfController::GetAccumulatedSuspendedTickChangedEvent, "GetAccumulatedSuspendedTickChangedEvent"},
{100, nullptr, "SetAlbumImageTakenNotificationEnabled"}, {100, &ISelfController::SetAlbumImageTakenNotificationEnabled, "SetAlbumImageTakenNotificationEnabled"},
{110, nullptr, "SetApplicationAlbumUserData"}, {110, nullptr, "SetApplicationAlbumUserData"},
{1000, nullptr, "GetDebugStorageChannel"}, {1000, nullptr, "GetDebugStorageChannel"},
}; };
@@ -315,7 +315,7 @@ ISelfController::ISelfController(Core::System& system,
ISelfController::~ISelfController() = default; ISelfController::~ISelfController() = default;
void ISelfController::Exit(Kernel::HLERequestContext& ctx) { void ISelfController::Exit(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "called"); LOG_DEBUG(Service_AM, "called.");
system.Shutdown(); system.Shutdown();
@@ -324,7 +324,7 @@ void ISelfController::Exit(Kernel::HLERequestContext& ctx) {
} }
void ISelfController::LockExit(Kernel::HLERequestContext& ctx) { void ISelfController::LockExit(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "called"); LOG_DEBUG(Service_AM, "called.");
system.SetExitLock(true); system.SetExitLock(true);
@@ -333,7 +333,7 @@ void ISelfController::LockExit(Kernel::HLERequestContext& ctx) {
} }
void ISelfController::UnlockExit(Kernel::HLERequestContext& ctx) { void ISelfController::UnlockExit(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "called"); LOG_DEBUG(Service_AM, "called.");
system.SetExitLock(false); system.SetExitLock(false);
@@ -366,7 +366,7 @@ void ISelfController::LeaveFatalSection(Kernel::HLERequestContext& ctx) {
} }
void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) { void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called"); LOG_WARNING(Service_AM, "(STUBBED) called.");
launchable_event.writable->Signal(); launchable_event.writable->Signal();
@@ -376,7 +376,7 @@ void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext&
} }
void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) { void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called"); LOG_WARNING(Service_AM, "(STUBBED) called.");
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
@@ -384,9 +384,10 @@ void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) {
void ISelfController::SetOperationModeChangedNotification(Kernel::HLERequestContext& ctx) { void ISelfController::SetOperationModeChangedNotification(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
operation_mode_changed_notification = rp.Pop<bool>();
bool flag = rp.Pop<bool>(); LOG_DEBUG(Service_AM, "called. operation_mode_changed_notification={}",
LOG_WARNING(Service_AM, "(STUBBED) called flag={}", flag); operation_mode_changed_notification);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
@@ -394,9 +395,10 @@ void ISelfController::SetOperationModeChangedNotification(Kernel::HLERequestCont
void ISelfController::SetPerformanceModeChangedNotification(Kernel::HLERequestContext& ctx) { void ISelfController::SetPerformanceModeChangedNotification(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
performance_mode_changed_notification = rp.Pop<bool>();
bool flag = rp.Pop<bool>(); LOG_WARNING(Service_AM, "(STUBBED) called. performance_mode_changed_notification={}",
LOG_WARNING(Service_AM, "(STUBBED) called flag={}", flag); performance_mode_changed_notification);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
@@ -422,33 +424,37 @@ void ISelfController::SetFocusHandlingMode(Kernel::HLERequestContext& ctx) {
} }
void ISelfController::SetRestartMessageEnabled(Kernel::HLERequestContext& ctx) { void ISelfController::SetRestartMessageEnabled(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called"); IPC::RequestParser rp{ctx};
restart_message_enabled = rp.Pop<bool>();
LOG_WARNING(Service_AM, "(STUBBED) called. restart_message_enabled={}",
restart_message_enabled);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
} }
void ISelfController::SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext& ctx) { void ISelfController::SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext& ctx) {
// Takes 3 input u8s with each field located immediately after the previous // Takes an input u8 bool flag. No output.
// u8, these are bool flags. No output.
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
out_of_focus_suspending_enabled = rp.Pop<bool>();
bool enabled = rp.Pop<bool>(); LOG_WARNING(Service_AM, "(STUBBED) called. out_of_focus_suspending_enabled={}",
LOG_WARNING(Service_AM, "(STUBBED) called enabled={}", enabled); out_of_focus_suspending_enabled);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
} }
void ISelfController::SetScreenShotImageOrientation(Kernel::HLERequestContext& ctx) { void ISelfController::SetScreenShotImageOrientation(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called"); LOG_WARNING(Service_AM, "(STUBBED) called.");
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
} }
void ISelfController::CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx) { void ISelfController::CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called"); LOG_WARNING(Service_AM, "(STUBBED) called.");
// TODO(Subv): Find out how AM determines the display to use, for now just // TODO(Subv): Find out how AM determines the display to use, for now just
// create the layer in the Default display. // create the layer in the Default display.
@@ -461,7 +467,7 @@ void ISelfController::CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx)
} }
void ISelfController::SetHandlesRequestToDisplay(Kernel::HLERequestContext& ctx) { void ISelfController::SetHandlesRequestToDisplay(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called"); LOG_WARNING(Service_AM, "(STUBBED) called.");
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
@@ -470,7 +476,7 @@ void ISelfController::SetHandlesRequestToDisplay(Kernel::HLERequestContext& ctx)
void ISelfController::SetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx) { void ISelfController::SetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
idle_time_detection_extension = rp.Pop<u32>(); idle_time_detection_extension = rp.Pop<u32>();
LOG_WARNING(Service_AM, "(STUBBED) called idle_time_detection_extension={}", LOG_WARNING(Service_AM, "(STUBBED) called. idle_time_detection_extension={}",
idle_time_detection_extension); idle_time_detection_extension);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
@@ -478,7 +484,7 @@ void ISelfController::SetIdleTimeDetectionExtension(Kernel::HLERequestContext& c
} }
void ISelfController::GetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx) { void ISelfController::GetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called"); LOG_WARNING(Service_AM, "(STUBBED) called.");
IPC::ResponseBuilder rb{ctx, 3}; IPC::ResponseBuilder rb{ctx, 3};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
@@ -532,16 +538,27 @@ void ISelfController::GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequest
rb.PushCopyObjects(accumulated_suspended_tick_changed_event.readable); rb.PushCopyObjects(accumulated_suspended_tick_changed_event.readable);
} }
void ISelfController::SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
album_image_taken_notification_enabled = rp.Pop<bool>();
LOG_DEBUG(Service_AM, "called. album_image_taken_notification_enabled={}",
album_image_taken_notification_enabled);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS);
}
AppletMessageQueue::AppletMessageQueue(Kernel::KernelCore& kernel) { AppletMessageQueue::AppletMessageQueue(Kernel::KernelCore& kernel) {
on_new_message = on_new_message =
Kernel::WritableEvent::CreateEventPair(kernel, "AMMessageQueue:OnMessageRecieved"); Kernel::WritableEvent::CreateEventPair(kernel, "AMMessageQueue:OnMessageReceived");
on_operation_mode_changed = on_operation_mode_changed =
Kernel::WritableEvent::CreateEventPair(kernel, "AMMessageQueue:OperationModeChanged"); Kernel::WritableEvent::CreateEventPair(kernel, "AMMessageQueue:OperationModeChanged");
} }
AppletMessageQueue::~AppletMessageQueue() = default; AppletMessageQueue::~AppletMessageQueue() = default;
const std::shared_ptr<Kernel::ReadableEvent>& AppletMessageQueue::GetMesssageRecieveEvent() const { const std::shared_ptr<Kernel::ReadableEvent>& AppletMessageQueue::GetMesssageReceiveEvent() const {
return on_new_message.readable; return on_new_message.readable;
} }
@@ -572,14 +589,18 @@ std::size_t AppletMessageQueue::GetMessageCount() const {
return messages.size(); return messages.size();
} }
void AppletMessageQueue::RequestExit() {
PushMessage(AppletMessage::ExitRequested);
}
void AppletMessageQueue::OperationModeChanged() { void AppletMessageQueue::OperationModeChanged() {
PushMessage(AppletMessage::OperationModeChanged); PushMessage(AppletMessage::OperationModeChanged);
PushMessage(AppletMessage::PerformanceModeChanged); PushMessage(AppletMessage::PerformanceModeChanged);
on_operation_mode_changed.writable->Signal(); on_operation_mode_changed.writable->Signal();
} }
void AppletMessageQueue::RequestExit() { void AppletMessageQueue::ScreenshotTaken() {
PushMessage(AppletMessage::ExitRequested); PushMessage(AppletMessage::ScreenshotTaken);
} }
ICommonStateGetter::ICommonStateGetter(Core::System& system, ICommonStateGetter::ICommonStateGetter(Core::System& system,
@@ -645,7 +666,7 @@ void ICommonStateGetter::GetEventHandle(Kernel::HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 2, 1}; IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
rb.PushCopyObjects(msg_queue->GetMesssageRecieveEvent()); rb.PushCopyObjects(msg_queue->GetMessageReceiveEvent());
} }
void ICommonStateGetter::ReceiveMessage(Kernel::HLERequestContext& ctx) { void ICommonStateGetter::ReceiveMessage(Kernel::HLERequestContext& ctx) {

View File

@@ -41,6 +41,13 @@ enum SystemLanguage {
TraditionalChinese = 16, TraditionalChinese = 16,
}; };
// Notification flags
bool operation_mode_changed_notification = false;
bool performance_mode_changed_notification = false;
bool restart_message_enabled = false;
bool out_of_focus_suspending_enabled = false;
bool album_image_taken_notification_enabled = false;
class AppletMessageQueue { class AppletMessageQueue {
public: public:
enum class AppletMessage : u32 { enum class AppletMessage : u32 {
@@ -49,18 +56,20 @@ public:
FocusStateChanged = 15, FocusStateChanged = 15,
OperationModeChanged = 30, OperationModeChanged = 30,
PerformanceModeChanged = 31, PerformanceModeChanged = 31,
ScreenshotTaken = 92,
}; };
explicit AppletMessageQueue(Kernel::KernelCore& kernel); explicit AppletMessageQueue(Kernel::KernelCore& kernel);
~AppletMessageQueue(); ~AppletMessageQueue();
const std::shared_ptr<Kernel::ReadableEvent>& GetMesssageRecieveEvent() const; const std::shared_ptr<Kernel::ReadableEvent>& GetMesssageReceiveEvent() const;
const std::shared_ptr<Kernel::ReadableEvent>& GetOperationModeChangedEvent() const; const std::shared_ptr<Kernel::ReadableEvent>& GetOperationModeChangedEvent() const;
void PushMessage(AppletMessage msg); void PushMessage(AppletMessage msg);
AppletMessage PopMessage(); AppletMessage PopMessage();
std::size_t GetMessageCount() const; std::size_t GetMessageCount() const;
void OperationModeChanged();
void RequestExit(); void RequestExit();
void OperationModeChanged();
void ScreenshotTaken();
private: private:
std::queue<AppletMessage> messages; std::queue<AppletMessage> messages;
@@ -146,6 +155,7 @@ private:
void IsAutoSleepDisabled(Kernel::HLERequestContext& ctx); void IsAutoSleepDisabled(Kernel::HLERequestContext& ctx);
void GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext& ctx); void GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext& ctx);
void GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequestContext& ctx); void GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequestContext& ctx);
void SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestContext& ctx);
Core::System& system; Core::System& system;
std::shared_ptr<NVFlinger::NVFlinger> nvflinger; std::shared_ptr<NVFlinger::NVFlinger> nvflinger;

View File

@@ -36,14 +36,15 @@ void OnDockedModeChanged(bool last_state, bool new_state) {
// change to one and it will handle both automatically // change to one and it will handle both automatically
auto applet_oe = sm.GetService<Service::AM::AppletOE>("appletOE"); auto applet_oe = sm.GetService<Service::AM::AppletOE>("appletOE");
auto applet_ae = sm.GetService<Service::AM::AppletAE>("appletAE"); auto applet_ae = sm.GetService<Service::AM::AppletAE>("appletAE");
bool is_notification_enabled = Service::AM::operation_mode_changed_notification;
bool has_signalled = false; bool has_signalled = false;
if (applet_oe != nullptr) { if (applet_oe != nullptr && is_notification_enabled) {
applet_oe->GetMessageQueue()->OperationModeChanged(); applet_oe->GetMessageQueue()->OperationModeChanged();
has_signalled = true; has_signalled = true;
} }
if (applet_ae != nullptr && !has_signalled) { if (applet_ae != nullptr && !has_signalled && is_notification_enabled) {
applet_ae->GetMessageQueue()->OperationModeChanged(); applet_ae->GetMessageQueue()->OperationModeChanged();
} }
} }

View File

@@ -1911,6 +1911,18 @@ void GMainWindow::OnCaptureScreenshot() {
} }
} }
OnStartGame(); OnStartGame();
auto& sm{Core::System::GetInstance().ServiceManager()};
auto applet_oe = sm.GetService<Service::AM::AppletOE>("appletOE");
auto applet_ae = sm.GetService<Service::AM::AppletAE>("appletAE");
bool is_notification_enabled = Service::AM::album_image_taken_notification_enabled;
bool has_signalled = false;
if (applet_oe != nullptr && is_notification_enabled) {
applet_oe->GetMessageQueue()->ScreenshotTaken();
has_signalled = true;
}
if (applet_ae != nullptr && !has_signalled && is_notification_enabled) {
applet_ae->GetMessageQueue()->ScreenshotTaken();
}
} }
void GMainWindow::UpdateWindowTitle(const QString& title_name) { void GMainWindow::UpdateWindowTitle(const QString& title_name) {