diff options
| author | 2023-10-11 18:41:56 -0600 | |
|---|---|---|
| committer | 2023-10-11 20:01:33 -0600 | |
| commit | fe04a7523a1f06f62fc1cb2337d7718664aaae2f (patch) | |
| tree | 0053f7c8db1dd62ea5d148ce21e531acdd595a21 | |
| parent | Merge pull request #11720 from lat9nq/dbg-syms (diff) | |
| download | yuzu-fe04a7523a1f06f62fc1cb2337d7718664aaae2f.tar.gz yuzu-fe04a7523a1f06f62fc1cb2337d7718664aaae2f.tar.xz yuzu-fe04a7523a1f06f62fc1cb2337d7718664aaae2f.zip | |
service: caps: Fix GetAlbumFileList3AaeAruid and GetAlbumFileList0AafeAruidDeprecated
| -rw-r--r-- | src/core/hle/service/caps/caps.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/caps/caps_manager.cpp | 86 | ||||
| -rw-r--r-- | src/core/hle/service/caps/caps_manager.h | 9 | ||||
| -rw-r--r-- | src/core/hle/service/caps/caps_types.h | 14 | ||||
| -rw-r--r-- | src/core/hle/service/caps/caps_u.cpp | 74 |
5 files changed, 134 insertions, 51 deletions
diff --git a/src/core/hle/service/caps/caps.cpp b/src/core/hle/service/caps/caps.cpp index 286f9fd10..31dd98140 100644 --- a/src/core/hle/service/caps/caps.cpp +++ b/src/core/hle/service/caps/caps.cpp | |||
| @@ -16,7 +16,7 @@ namespace Service::Capture { | |||
| 16 | 16 | ||
| 17 | void LoopProcess(Core::System& system) { | 17 | void LoopProcess(Core::System& system) { |
| 18 | auto server_manager = std::make_unique<ServerManager>(system); | 18 | auto server_manager = std::make_unique<ServerManager>(system); |
| 19 | auto album_manager = std::make_shared<AlbumManager>(); | 19 | auto album_manager = std::make_shared<AlbumManager>(system); |
| 20 | 20 | ||
| 21 | server_manager->RegisterNamedService( | 21 | server_manager->RegisterNamedService( |
| 22 | "caps:a", std::make_shared<IAlbumAccessorService>(system, album_manager)); | 22 | "caps:a", std::make_shared<IAlbumAccessorService>(system, album_manager)); |
diff --git a/src/core/hle/service/caps/caps_manager.cpp b/src/core/hle/service/caps/caps_manager.cpp index 2df6a930a..2b4e3f076 100644 --- a/src/core/hle/service/caps/caps_manager.cpp +++ b/src/core/hle/service/caps/caps_manager.cpp | |||
| @@ -8,12 +8,15 @@ | |||
| 8 | #include "common/fs/file.h" | 8 | #include "common/fs/file.h" |
| 9 | #include "common/fs/path_util.h" | 9 | #include "common/fs/path_util.h" |
| 10 | #include "common/logging/log.h" | 10 | #include "common/logging/log.h" |
| 11 | #include "core/core.h" | ||
| 11 | #include "core/hle/service/caps/caps_manager.h" | 12 | #include "core/hle/service/caps/caps_manager.h" |
| 12 | #include "core/hle/service/caps/caps_result.h" | 13 | #include "core/hle/service/caps/caps_result.h" |
| 14 | #include "core/hle/service/time/time_manager.h" | ||
| 15 | #include "core/hle/service/time/time_zone_content_manager.h" | ||
| 13 | 16 | ||
| 14 | namespace Service::Capture { | 17 | namespace Service::Capture { |
| 15 | 18 | ||
| 16 | AlbumManager::AlbumManager() {} | 19 | AlbumManager::AlbumManager(Core::System& system_) : system{system_} {} |
| 17 | 20 | ||
| 18 | AlbumManager::~AlbumManager() = default; | 21 | AlbumManager::~AlbumManager() = default; |
| 19 | 22 | ||
| @@ -83,6 +86,34 @@ Result AlbumManager::GetAlbumFileList(std::vector<AlbumEntry>& out_entries, Albu | |||
| 83 | } | 86 | } |
| 84 | 87 | ||
| 85 | Result AlbumManager::GetAlbumFileList(std::vector<ApplicationAlbumFileEntry>& out_entries, | 88 | Result AlbumManager::GetAlbumFileList(std::vector<ApplicationAlbumFileEntry>& out_entries, |
| 89 | ContentType contex_type, s64 start_posix_time, | ||
| 90 | s64 end_posix_time, u64 aruid) const { | ||
| 91 | if (!is_mounted) { | ||
| 92 | return ResultIsNotMounted; | ||
| 93 | } | ||
| 94 | |||
| 95 | std::vector<ApplicationAlbumEntry> album_entries; | ||
| 96 | const auto start_date = ConvertToAlbumDateTime(start_posix_time); | ||
| 97 | const auto end_date = ConvertToAlbumDateTime(end_posix_time); | ||
| 98 | const auto result = GetAlbumFileList(album_entries, contex_type, start_date, end_date, aruid); | ||
| 99 | |||
| 100 | if (result.IsError()) { | ||
| 101 | return result; | ||
| 102 | } | ||
| 103 | |||
| 104 | for (const auto& album_entry : album_entries) { | ||
| 105 | ApplicationAlbumFileEntry entry{ | ||
| 106 | .entry = album_entry, | ||
| 107 | .datetime = album_entry.datetime, | ||
| 108 | .unknown = {}, | ||
| 109 | }; | ||
| 110 | out_entries.push_back(entry); | ||
| 111 | } | ||
| 112 | |||
| 113 | return ResultSuccess; | ||
| 114 | } | ||
| 115 | |||
| 116 | Result AlbumManager::GetAlbumFileList(std::vector<ApplicationAlbumEntry>& out_entries, | ||
| 86 | ContentType contex_type, AlbumFileDateTime start_date, | 117 | ContentType contex_type, AlbumFileDateTime start_date, |
| 87 | AlbumFileDateTime end_date, u64 aruid) const { | 118 | AlbumFileDateTime end_date, u64 aruid) const { |
| 88 | if (!is_mounted) { | 119 | if (!is_mounted) { |
| @@ -93,31 +124,25 @@ Result AlbumManager::GetAlbumFileList(std::vector<ApplicationAlbumFileEntry>& ou | |||
| 93 | if (file_id.type != contex_type) { | 124 | if (file_id.type != contex_type) { |
| 94 | continue; | 125 | continue; |
| 95 | } | 126 | } |
| 96 | |||
| 97 | if (file_id.date > start_date) { | 127 | if (file_id.date > start_date) { |
| 98 | continue; | 128 | continue; |
| 99 | } | 129 | } |
| 100 | |||
| 101 | if (file_id.date < end_date) { | 130 | if (file_id.date < end_date) { |
| 102 | continue; | 131 | continue; |
| 103 | } | 132 | } |
| 104 | |||
| 105 | if (out_entries.size() >= SdAlbumFileLimit) { | 133 | if (out_entries.size() >= SdAlbumFileLimit) { |
| 106 | break; | 134 | break; |
| 107 | } | 135 | } |
| 108 | 136 | ||
| 109 | const auto entry_size = Common::FS::GetSize(path); | 137 | const auto entry_size = Common::FS::GetSize(path); |
| 110 | ApplicationAlbumFileEntry entry{.entry = | 138 | ApplicationAlbumEntry entry{ |
| 111 | { | 139 | .size = entry_size, |
| 112 | .size = entry_size, | 140 | .hash{}, |
| 113 | .hash{}, | 141 | .datetime = file_id.date, |
| 114 | .datetime = file_id.date, | 142 | .storage = file_id.storage, |
| 115 | .storage = file_id.storage, | 143 | .content = contex_type, |
| 116 | .content = contex_type, | 144 | .unknown = 1, |
| 117 | .unknown = 1, | 145 | }; |
| 118 | }, | ||
| 119 | .datetime = file_id.date, | ||
| 120 | .unknown = {}}; | ||
| 121 | out_entries.push_back(entry); | 146 | out_entries.push_back(entry); |
| 122 | } | 147 | } |
| 123 | 148 | ||
| @@ -274,12 +299,12 @@ Result AlbumManager::GetAlbumEntry(AlbumEntry& out_entry, const std::filesystem: | |||
| 274 | .application_id = static_cast<u64>(std::stoll(application, 0, 16)), | 299 | .application_id = static_cast<u64>(std::stoll(application, 0, 16)), |
| 275 | .date = | 300 | .date = |
| 276 | { | 301 | { |
| 277 | .year = static_cast<u16>(std::stoi(year)), | 302 | .year = static_cast<s16>(std::stoi(year)), |
| 278 | .month = static_cast<u8>(std::stoi(month)), | 303 | .month = static_cast<s8>(std::stoi(month)), |
| 279 | .day = static_cast<u8>(std::stoi(day)), | 304 | .day = static_cast<s8>(std::stoi(day)), |
| 280 | .hour = static_cast<u8>(std::stoi(hour)), | 305 | .hour = static_cast<s8>(std::stoi(hour)), |
| 281 | .minute = static_cast<u8>(std::stoi(minute)), | 306 | .minute = static_cast<s8>(std::stoi(minute)), |
| 282 | .second = static_cast<u8>(std::stoi(second)), | 307 | .second = static_cast<s8>(std::stoi(second)), |
| 283 | .unique_id = 0, | 308 | .unique_id = 0, |
| 284 | }, | 309 | }, |
| 285 | .storage = AlbumStorage::Sd, | 310 | .storage = AlbumStorage::Sd, |
| @@ -339,4 +364,23 @@ Result AlbumManager::LoadImage(std::span<u8> out_image, const std::filesystem::p | |||
| 339 | 364 | ||
| 340 | return ResultSuccess; | 365 | return ResultSuccess; |
| 341 | } | 366 | } |
| 367 | |||
| 368 | AlbumFileDateTime AlbumManager::ConvertToAlbumDateTime(u64 posix_time) const { | ||
| 369 | Time::TimeZone::CalendarInfo calendar_date{}; | ||
| 370 | const auto& time_zone_manager = | ||
| 371 | system.GetTimeManager().GetTimeZoneContentManager().GetTimeZoneManager(); | ||
| 372 | |||
| 373 | time_zone_manager.ToCalendarTimeWithMyRules(posix_time, calendar_date); | ||
| 374 | |||
| 375 | return { | ||
| 376 | .year = calendar_date.time.year, | ||
| 377 | .month = calendar_date.time.month, | ||
| 378 | .day = calendar_date.time.day, | ||
| 379 | .hour = calendar_date.time.hour, | ||
| 380 | .minute = calendar_date.time.minute, | ||
| 381 | .second = calendar_date.time.second, | ||
| 382 | .unique_id = 0, | ||
| 383 | }; | ||
| 384 | } | ||
| 385 | |||
| 342 | } // namespace Service::Capture | 386 | } // namespace Service::Capture |
diff --git a/src/core/hle/service/caps/caps_manager.h b/src/core/hle/service/caps/caps_manager.h index 8337c655c..f65eb12c1 100644 --- a/src/core/hle/service/caps/caps_manager.h +++ b/src/core/hle/service/caps/caps_manager.h | |||
| @@ -37,7 +37,7 @@ namespace Service::Capture { | |||
| 37 | 37 | ||
| 38 | class AlbumManager { | 38 | class AlbumManager { |
| 39 | public: | 39 | public: |
| 40 | explicit AlbumManager(); | 40 | explicit AlbumManager(Core::System& system_); |
| 41 | ~AlbumManager(); | 41 | ~AlbumManager(); |
| 42 | 42 | ||
| 43 | Result DeleteAlbumFile(const AlbumFileId& file_id); | 43 | Result DeleteAlbumFile(const AlbumFileId& file_id); |
| @@ -45,6 +45,9 @@ public: | |||
| 45 | Result GetAlbumFileList(std::vector<AlbumEntry>& out_entries, AlbumStorage storage, | 45 | Result GetAlbumFileList(std::vector<AlbumEntry>& out_entries, AlbumStorage storage, |
| 46 | u8 flags) const; | 46 | u8 flags) const; |
| 47 | Result GetAlbumFileList(std::vector<ApplicationAlbumFileEntry>& out_entries, | 47 | Result GetAlbumFileList(std::vector<ApplicationAlbumFileEntry>& out_entries, |
| 48 | ContentType contex_type, s64 start_posix_time, s64 end_posix_time, | ||
| 49 | u64 aruid) const; | ||
| 50 | Result GetAlbumFileList(std::vector<ApplicationAlbumEntry>& out_entries, | ||
| 48 | ContentType contex_type, AlbumFileDateTime start_date, | 51 | ContentType contex_type, AlbumFileDateTime start_date, |
| 49 | AlbumFileDateTime end_date, u64 aruid) const; | 52 | AlbumFileDateTime end_date, u64 aruid) const; |
| 50 | Result GetAutoSavingStorage(bool& out_is_autosaving) const; | 53 | Result GetAutoSavingStorage(bool& out_is_autosaving) const; |
| @@ -65,8 +68,12 @@ private: | |||
| 65 | Result LoadImage(std::span<u8> out_image, const std::filesystem::path& path, int width, | 68 | Result LoadImage(std::span<u8> out_image, const std::filesystem::path& path, int width, |
| 66 | int height, ScreenShotDecoderFlag flag) const; | 69 | int height, ScreenShotDecoderFlag flag) const; |
| 67 | 70 | ||
| 71 | AlbumFileDateTime ConvertToAlbumDateTime(u64 posix_time) const; | ||
| 72 | |||
| 68 | bool is_mounted{}; | 73 | bool is_mounted{}; |
| 69 | std::unordered_map<AlbumFileId, std::filesystem::path> album_files; | 74 | std::unordered_map<AlbumFileId, std::filesystem::path> album_files; |
| 75 | |||
| 76 | Core::System& system; | ||
| 70 | }; | 77 | }; |
| 71 | 78 | ||
| 72 | } // namespace Service::Capture | 79 | } // namespace Service::Capture |
diff --git a/src/core/hle/service/caps/caps_types.h b/src/core/hle/service/caps/caps_types.h index bf6061273..7fd357954 100644 --- a/src/core/hle/service/caps/caps_types.h +++ b/src/core/hle/service/caps/caps_types.h | |||
| @@ -41,13 +41,13 @@ enum class ScreenShotDecoderFlag : u64 { | |||
| 41 | 41 | ||
| 42 | // This is nn::capsrv::AlbumFileDateTime | 42 | // This is nn::capsrv::AlbumFileDateTime |
| 43 | struct AlbumFileDateTime { | 43 | struct AlbumFileDateTime { |
| 44 | u16 year{}; | 44 | s16 year{}; |
| 45 | u8 month{}; | 45 | s8 month{}; |
| 46 | u8 day{}; | 46 | s8 day{}; |
| 47 | u8 hour{}; | 47 | s8 hour{}; |
| 48 | u8 minute{}; | 48 | s8 minute{}; |
| 49 | u8 second{}; | 49 | s8 second{}; |
| 50 | u8 unique_id{}; | 50 | s8 unique_id{}; |
| 51 | 51 | ||
| 52 | friend constexpr bool operator==(const AlbumFileDateTime&, const AlbumFileDateTime&) = default; | 52 | friend constexpr bool operator==(const AlbumFileDateTime&, const AlbumFileDateTime&) = default; |
| 53 | friend constexpr bool operator>(const AlbumFileDateTime& a, const AlbumFileDateTime& b) { | 53 | friend constexpr bool operator>(const AlbumFileDateTime& a, const AlbumFileDateTime& b) { |
diff --git a/src/core/hle/service/caps/caps_u.cpp b/src/core/hle/service/caps/caps_u.cpp index 260f25490..b6b33fb2f 100644 --- a/src/core/hle/service/caps/caps_u.cpp +++ b/src/core/hle/service/caps/caps_u.cpp | |||
| @@ -50,22 +50,35 @@ void IAlbumApplicationService::SetShimLibraryVersion(HLERequestContext& ctx) { | |||
| 50 | 50 | ||
| 51 | void IAlbumApplicationService::GetAlbumFileList0AafeAruidDeprecated(HLERequestContext& ctx) { | 51 | void IAlbumApplicationService::GetAlbumFileList0AafeAruidDeprecated(HLERequestContext& ctx) { |
| 52 | IPC::RequestParser rp{ctx}; | 52 | IPC::RequestParser rp{ctx}; |
| 53 | const auto pid{rp.Pop<s32>()}; | 53 | struct Parameters { |
| 54 | const auto content_type{rp.PopEnum<ContentType>()}; | 54 | ContentType content_type; |
| 55 | const auto start_posix_time{rp.Pop<s64>()}; | 55 | INSERT_PADDING_BYTES(7); |
| 56 | const auto end_posix_time{rp.Pop<s64>()}; | 56 | s64 start_posix_time; |
| 57 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 57 | s64 end_posix_time; |
| 58 | u64 applet_resource_user_id; | ||
| 59 | }; | ||
| 60 | static_assert(sizeof(Parameters) == 0x20, "Parameters has incorrect size."); | ||
| 61 | |||
| 62 | const auto parameters{rp.PopRaw<Parameters>()}; | ||
| 58 | 63 | ||
| 59 | LOG_WARNING(Service_Capture, | 64 | LOG_WARNING(Service_Capture, |
| 60 | "(STUBBED) called. pid={}, content_type={}, start_posix_time={}, " | 65 | "(STUBBED) called. content_type={}, start_posix_time={}, end_posix_time={}, " |
| 61 | "end_posix_time={}, applet_resource_user_id={}", | 66 | "applet_resource_user_id={}", |
| 62 | pid, content_type, start_posix_time, end_posix_time, applet_resource_user_id); | 67 | parameters.content_type, parameters.start_posix_time, parameters.end_posix_time, |
| 68 | parameters.applet_resource_user_id); | ||
| 63 | 69 | ||
| 64 | // TODO: Translate posix to DateTime | 70 | Result result = ResultSuccess; |
| 71 | |||
| 72 | if (result.IsSuccess()) { | ||
| 73 | result = manager->IsAlbumMounted(AlbumStorage::Sd); | ||
| 74 | } | ||
| 65 | 75 | ||
| 66 | std::vector<ApplicationAlbumFileEntry> entries; | 76 | std::vector<ApplicationAlbumFileEntry> entries; |
| 67 | const Result result = | 77 | if (result.IsSuccess()) { |
| 68 | manager->GetAlbumFileList(entries, content_type, {}, {}, applet_resource_user_id); | 78 | result = manager->GetAlbumFileList(entries, parameters.content_type, |
| 79 | parameters.start_posix_time, parameters.end_posix_time, | ||
| 80 | parameters.applet_resource_user_id); | ||
| 81 | } | ||
| 69 | 82 | ||
| 70 | if (!entries.empty()) { | 83 | if (!entries.empty()) { |
| 71 | ctx.WriteBuffer(entries); | 84 | ctx.WriteBuffer(entries); |
| @@ -78,19 +91,38 @@ void IAlbumApplicationService::GetAlbumFileList0AafeAruidDeprecated(HLERequestCo | |||
| 78 | 91 | ||
| 79 | void IAlbumApplicationService::GetAlbumFileList3AaeAruid(HLERequestContext& ctx) { | 92 | void IAlbumApplicationService::GetAlbumFileList3AaeAruid(HLERequestContext& ctx) { |
| 80 | IPC::RequestParser rp{ctx}; | 93 | IPC::RequestParser rp{ctx}; |
| 81 | const auto pid{rp.Pop<s32>()}; | 94 | struct Parameters { |
| 82 | const auto content_type{rp.PopEnum<ContentType>()}; | 95 | ContentType content_type; |
| 83 | const auto start_date_time{rp.PopRaw<AlbumFileDateTime>()}; | 96 | INSERT_PADDING_BYTES(1); |
| 84 | const auto end_date_time{rp.PopRaw<AlbumFileDateTime>()}; | 97 | AlbumFileDateTime start_date_time; |
| 85 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 98 | AlbumFileDateTime end_date_time; |
| 99 | INSERT_PADDING_BYTES(6); | ||
| 100 | u64 applet_resource_user_id; | ||
| 101 | }; | ||
| 102 | static_assert(sizeof(Parameters) == 0x20, "Parameters has incorrect size."); | ||
| 103 | |||
| 104 | const auto parameters{rp.PopRaw<Parameters>()}; | ||
| 86 | 105 | ||
| 87 | LOG_WARNING(Service_Capture, | 106 | LOG_WARNING(Service_Capture, |
| 88 | "(STUBBED) called. pid={}, content_type={}, applet_resource_user_id={}", pid, | 107 | "(STUBBED) called. content_type={}, start_date={}/{}/{}, " |
| 89 | content_type, applet_resource_user_id); | 108 | "end_date={}/{}/{}, applet_resource_user_id={}", |
| 109 | parameters.content_type, parameters.start_date_time.year, | ||
| 110 | parameters.start_date_time.month, parameters.start_date_time.day, | ||
| 111 | parameters.end_date_time.year, parameters.end_date_time.month, | ||
| 112 | parameters.end_date_time.day, parameters.applet_resource_user_id); | ||
| 90 | 113 | ||
| 91 | std::vector<ApplicationAlbumFileEntry> entries; | 114 | Result result = ResultSuccess; |
| 92 | const Result result = manager->GetAlbumFileList(entries, content_type, start_date_time, | 115 | |
| 93 | end_date_time, applet_resource_user_id); | 116 | if (result.IsSuccess()) { |
| 117 | result = manager->IsAlbumMounted(AlbumStorage::Sd); | ||
| 118 | } | ||
| 119 | |||
| 120 | std::vector<ApplicationAlbumEntry> entries; | ||
| 121 | if (result.IsSuccess()) { | ||
| 122 | result = | ||
| 123 | manager->GetAlbumFileList(entries, parameters.content_type, parameters.start_date_time, | ||
| 124 | parameters.end_date_time, parameters.applet_resource_user_id); | ||
| 125 | } | ||
| 94 | 126 | ||
| 95 | if (!entries.empty()) { | 127 | if (!entries.empty()) { |
| 96 | ctx.WriteBuffer(entries); | 128 | ctx.WriteBuffer(entries); |