applet.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <deque>
  5. #include <mutex>
  6. #include "common/math_util.h"
  7. #include "core/hle/service/apm/apm_controller.h"
  8. #include "core/hle/service/caps/caps_types.h"
  9. #include "core/hle/service/cmif_types.h"
  10. #include "core/hle/service/kernel_helpers.h"
  11. #include "core/hle/service/os/event.h"
  12. #include "core/hle/service/os/process.h"
  13. #include "core/hle/service/service.h"
  14. #include "core/hle/service/am/am_types.h"
  15. #include "core/hle/service/am/display_layer_manager.h"
  16. #include "core/hle/service/am/hid_registration.h"
  17. #include "core/hle/service/am/lifecycle_manager.h"
  18. #include "core/hle/service/am/process_holder.h"
  19. namespace Service::AM {
  20. struct Applet {
  21. explicit Applet(Core::System& system, std::unique_ptr<Process> process_, bool is_application);
  22. ~Applet();
  23. // Lock
  24. std::mutex lock{};
  25. // Event creation helper
  26. KernelHelpers::ServiceContext context;
  27. // Lifecycle manager
  28. LifecycleManager lifecycle_manager;
  29. // Process
  30. std::unique_ptr<Process> process;
  31. std::optional<ProcessHolder> process_holder;
  32. bool is_process_running{};
  33. // Creation state
  34. AppletId applet_id{};
  35. AppletResourceUserId aruid{};
  36. AppletProcessLaunchReason launch_reason{};
  37. AppletType type{};
  38. ProgramId program_id{};
  39. LibraryAppletMode library_applet_mode{};
  40. s32 previous_program_index{-1};
  41. ScreenshotPermission previous_screenshot_permission{ScreenshotPermission::Enable};
  42. // TODO: some fields above can be AppletIdentityInfo
  43. AppletIdentityInfo screen_shot_identity;
  44. // hid state
  45. HidRegistration hid_registration;
  46. // vi state
  47. DisplayLayerManager display_layer_manager{};
  48. // Applet common functions
  49. Result terminate_result{};
  50. s32 display_logical_width{};
  51. s32 display_logical_height{};
  52. Common::Rectangle<f32> display_magnification{0, 0, 1, 1};
  53. bool home_button_double_click_enabled{};
  54. bool home_button_short_pressed_blocked{};
  55. bool home_button_long_pressed_blocked{};
  56. bool vr_mode_curtain_required{};
  57. bool sleep_required_by_high_temperature{};
  58. bool sleep_required_by_low_battery{};
  59. s32 cpu_boost_request_priority{-1};
  60. bool handling_capture_button_short_pressed_message_enabled_for_applet{};
  61. bool handling_capture_button_long_pressed_message_enabled_for_applet{};
  62. u32 application_core_usage_mode{};
  63. // Application functions
  64. bool game_play_recording_supported{};
  65. GamePlayRecordingState game_play_recording_state{GamePlayRecordingState::Disabled};
  66. bool jit_service_launched{};
  67. bool application_crash_report_enabled{};
  68. // Common state
  69. bool sleep_lock_enabled{};
  70. bool vr_mode_enabled{};
  71. bool lcd_backlight_off_enabled{};
  72. APM::CpuBoostMode boost_mode{};
  73. bool request_exit_to_library_applet_at_execute_next_program_enabled{};
  74. // Channels
  75. std::deque<std::vector<u8>> user_channel_launch_parameter{};
  76. std::deque<std::vector<u8>> preselected_user_launch_parameter{};
  77. // Caller applet
  78. std::weak_ptr<Applet> caller_applet{};
  79. std::shared_ptr<AppletDataBroker> caller_applet_broker{};
  80. std::list<std::shared_ptr<Applet>> child_applets{};
  81. bool is_completed{};
  82. // Self state
  83. bool exit_locked{};
  84. s32 fatal_section_count{};
  85. Capture::AlbumImageOrientation album_image_orientation{};
  86. bool handles_request_to_display{};
  87. ScreenshotPermission screenshot_permission{};
  88. IdleTimeDetectionExtension idle_time_detection_extension{};
  89. bool auto_sleep_disabled{};
  90. u64 suspended_ticks{};
  91. bool album_image_taken_notification_enabled{};
  92. bool record_volume_muted{};
  93. bool is_activity_runnable{};
  94. bool is_interactible{true};
  95. bool window_visible{true};
  96. // Events
  97. Event gpu_error_detected_event;
  98. Event friend_invitation_storage_channel_event;
  99. Event notification_storage_channel_event;
  100. Event health_warning_disappeared_system_event;
  101. Event acquired_sleep_lock_event;
  102. Event pop_from_general_channel_event;
  103. Event library_applet_launchable_event;
  104. Event accumulated_suspended_tick_changed_event;
  105. Event sleep_lock_event;
  106. Event state_changed_event;
  107. // Frontend state
  108. std::shared_ptr<Frontend::FrontendApplet> frontend{};
  109. // Process state management
  110. void UpdateSuspensionStateLocked(bool force_message);
  111. void SetInteractibleLocked(bool interactible);
  112. void OnProcessTerminatedLocked();
  113. };
  114. } // namespace Service::AM