Files
eden/src/core/hle/service/am/applet.cpp
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

83 lines
3.0 KiB
C++
Raw Normal View History

// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator
// Project// SPDX-License-Identifier: GPL-2.0-or-later
2024-01-02 19:22:02 -05:00
#include "core/core.h"
2024-01-02 19:22:02 -05:00
#include "core/hle/service/am/applet.h"
#include "core/hle/service/am/applet_manager.h"
2024-01-02 19:22:02 -05:00
namespace Service::AM {
2024-03-03 13:02:50 +00:00
Applet::Applet(Core::System& system, std::unique_ptr<Process> process_, bool is_application)
: context(system, "Applet"), lifecycle_manager(system, context, is_application),
process(std::move(process_)), hid_registration(system, *process), overlay_event(context),
2024-03-03 13:02:50 +00:00
gpu_error_detected_event(context), friend_invitation_storage_channel_event(context),
notification_storage_channel_event(context), health_warning_disappeared_system_event(context),
unknown_event(context), acquired_sleep_lock_event(context), pop_from_general_channel_event(context),
2024-03-03 13:02:50 +00:00
library_applet_launchable_event(context), accumulated_suspended_tick_changed_event(context),
sleep_lock_event(context), state_changed_event(context) {
2024-01-02 19:22:02 -05:00
2024-03-03 13:02:50 +00:00
aruid.pid = process->GetProcessId();
2024-01-02 19:22:02 -05:00
program_id = process->GetProgramId();
}
Applet::~Applet() = default;
2024-03-03 13:02:50 +00:00
void Applet::UpdateSuspensionStateLocked(bool force_message) {
// Remove any forced resumption.
lifecycle_manager.RemoveForceResumeIfPossible();
const bool update_requested_focus_state = lifecycle_manager.UpdateRequestedFocusState();
2024-03-03 13:02:50 +00:00
const bool curr_activity_runnable = lifecycle_manager.IsRunnable();
const bool prev_activity_runnable = is_activity_runnable;
const bool was_changed = curr_activity_runnable != prev_activity_runnable;
2025-05-28 11:50:15 +00:00
2024-03-03 13:02:50 +00:00
if (was_changed) {
if (curr_activity_runnable) {
process->Suspend(false);
} else {
process->Suspend(true);
lifecycle_manager.RequestResumeNotification();
2024-03-03 13:02:50 +00:00
}
is_activity_runnable = curr_activity_runnable;
}
if (lifecycle_manager.GetForcedSuspend()) {
// TODO: why is this allowed?
return;
}
// Signal if the focus state was changed or the process state was changed.
if (update_requested_focus_state || was_changed || force_message) {
2024-03-03 13:02:50 +00:00
lifecycle_manager.SignalSystemEventIfNeeded();
}
}
void Applet::SetInteractibleLocked(bool interactible) {
if (is_interactible == interactible) {
return;
}
is_interactible = interactible;
const bool exit_requested = lifecycle_manager.GetExitRequested();
const bool input_enabled = interactible && !exit_requested;
if (applet_id == AppletId::OverlayDisplay || applet_id == AppletId::Application) {
LOG_DEBUG(Service_AM, "called, applet={} interactible={} exit_requested={} input_enabled={} overlay_in_foreground={}",
static_cast<u32>(applet_id), interactible, exit_requested, input_enabled, overlay_in_foreground);
}
hid_registration.EnableAppletToGetInput(input_enabled);
2024-03-03 13:02:50 +00:00
}
void Applet::OnProcessTerminatedLocked() {
is_completed = true;
state_changed_event.Signal();
}
2024-01-02 19:22:02 -05:00
} // namespace Service::AM