diff options
| -rw-r--r-- | src/core/hle/service/pctl/pctl_module.cpp | 152 |
1 files changed, 134 insertions, 18 deletions
diff --git a/src/core/hle/service/pctl/pctl_module.cpp b/src/core/hle/service/pctl/pctl_module.cpp index f966c5c8b..7c8a539b8 100644 --- a/src/core/hle/service/pctl/pctl_module.cpp +++ b/src/core/hle/service/pctl/pctl_module.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include "core/file_sys/control_metadata.h" | 6 | #include "core/file_sys/control_metadata.h" |
| 7 | #include "core/file_sys/patch_manager.h" | 7 | #include "core/file_sys/patch_manager.h" |
| 8 | #include "core/hle/service/ipc_helpers.h" | 8 | #include "core/hle/service/ipc_helpers.h" |
| 9 | #include "core/hle/service/kernel_helpers.h" | ||
| 9 | #include "core/hle/service/pctl/pctl.h" | 10 | #include "core/hle/service/pctl/pctl.h" |
| 10 | #include "core/hle/service/pctl/pctl_module.h" | 11 | #include "core/hle/service/pctl/pctl_module.h" |
| 11 | #include "core/hle/service/server_manager.h" | 12 | #include "core/hle/service/server_manager.h" |
| @@ -24,7 +25,8 @@ constexpr Result ResultNoRestrictionEnabled{ErrorModule::PCTL, 181}; | |||
| 24 | class IParentalControlService final : public ServiceFramework<IParentalControlService> { | 25 | class IParentalControlService final : public ServiceFramework<IParentalControlService> { |
| 25 | public: | 26 | public: |
| 26 | explicit IParentalControlService(Core::System& system_, Capability capability_) | 27 | explicit IParentalControlService(Core::System& system_, Capability capability_) |
| 27 | : ServiceFramework{system_, "IParentalControlService"}, capability{capability_} { | 28 | : ServiceFramework{system_, "IParentalControlService"}, capability{capability_}, |
| 29 | service_context{system_, "IParentalControlService"} { | ||
| 28 | // clang-format off | 30 | // clang-format off |
| 29 | static const FunctionInfo functions[] = { | 31 | static const FunctionInfo functions[] = { |
| 30 | {1, &IParentalControlService::Initialize, "Initialize"}, | 32 | {1, &IParentalControlService::Initialize, "Initialize"}, |
| @@ -33,7 +35,7 @@ public: | |||
| 33 | {1003, nullptr, "ConfirmResumeApplicationPermission"}, | 35 | {1003, nullptr, "ConfirmResumeApplicationPermission"}, |
| 34 | {1004, nullptr, "ConfirmSnsPostPermission"}, | 36 | {1004, nullptr, "ConfirmSnsPostPermission"}, |
| 35 | {1005, nullptr, "ConfirmSystemSettingsPermission"}, | 37 | {1005, nullptr, "ConfirmSystemSettingsPermission"}, |
| 36 | {1006, nullptr, "IsRestrictionTemporaryUnlocked"}, | 38 | {1006, &IParentalControlService::IsRestrictionTemporaryUnlocked, "IsRestrictionTemporaryUnlocked"}, |
| 37 | {1007, nullptr, "RevertRestrictionTemporaryUnlocked"}, | 39 | {1007, nullptr, "RevertRestrictionTemporaryUnlocked"}, |
| 38 | {1008, nullptr, "EnterRestrictedSystemSettings"}, | 40 | {1008, nullptr, "EnterRestrictedSystemSettings"}, |
| 39 | {1009, nullptr, "LeaveRestrictedSystemSettings"}, | 41 | {1009, nullptr, "LeaveRestrictedSystemSettings"}, |
| @@ -47,14 +49,14 @@ public: | |||
| 47 | {1017, &IParentalControlService::EndFreeCommunication, "EndFreeCommunication"}, | 49 | {1017, &IParentalControlService::EndFreeCommunication, "EndFreeCommunication"}, |
| 48 | {1018, &IParentalControlService::IsFreeCommunicationAvailable, "IsFreeCommunicationAvailable"}, | 50 | {1018, &IParentalControlService::IsFreeCommunicationAvailable, "IsFreeCommunicationAvailable"}, |
| 49 | {1031, &IParentalControlService::IsRestrictionEnabled, "IsRestrictionEnabled"}, | 51 | {1031, &IParentalControlService::IsRestrictionEnabled, "IsRestrictionEnabled"}, |
| 50 | {1032, nullptr, "GetSafetyLevel"}, | 52 | {1032, &IParentalControlService::GetSafetyLevel, "GetSafetyLevel"}, |
| 51 | {1033, nullptr, "SetSafetyLevel"}, | 53 | {1033, nullptr, "SetSafetyLevel"}, |
| 52 | {1034, nullptr, "GetSafetyLevelSettings"}, | 54 | {1034, nullptr, "GetSafetyLevelSettings"}, |
| 53 | {1035, nullptr, "GetCurrentSettings"}, | 55 | {1035, &IParentalControlService::GetCurrentSettings, "GetCurrentSettings"}, |
| 54 | {1036, nullptr, "SetCustomSafetyLevelSettings"}, | 56 | {1036, nullptr, "SetCustomSafetyLevelSettings"}, |
| 55 | {1037, nullptr, "GetDefaultRatingOrganization"}, | 57 | {1037, nullptr, "GetDefaultRatingOrganization"}, |
| 56 | {1038, nullptr, "SetDefaultRatingOrganization"}, | 58 | {1038, nullptr, "SetDefaultRatingOrganization"}, |
| 57 | {1039, nullptr, "GetFreeCommunicationApplicationListCount"}, | 59 | {1039, &IParentalControlService::GetFreeCommunicationApplicationListCount, "GetFreeCommunicationApplicationListCount"}, |
| 58 | {1042, nullptr, "AddToFreeCommunicationApplicationList"}, | 60 | {1042, nullptr, "AddToFreeCommunicationApplicationList"}, |
| 59 | {1043, nullptr, "DeleteSettings"}, | 61 | {1043, nullptr, "DeleteSettings"}, |
| 60 | {1044, nullptr, "GetFreeCommunicationApplicationList"}, | 62 | {1044, nullptr, "GetFreeCommunicationApplicationList"}, |
| @@ -76,7 +78,7 @@ public: | |||
| 76 | {1206, nullptr, "GetPinCodeLength"}, | 78 | {1206, nullptr, "GetPinCodeLength"}, |
| 77 | {1207, nullptr, "GetPinCodeChangedEvent"}, | 79 | {1207, nullptr, "GetPinCodeChangedEvent"}, |
| 78 | {1208, nullptr, "GetPinCode"}, | 80 | {1208, nullptr, "GetPinCode"}, |
| 79 | {1403, nullptr, "IsPairingActive"}, | 81 | {1403, &IParentalControlService::IsPairingActive, "IsPairingActive"}, |
| 80 | {1406, nullptr, "GetSettingsLastUpdated"}, | 82 | {1406, nullptr, "GetSettingsLastUpdated"}, |
| 81 | {1411, nullptr, "GetPairingAccountInfo"}, | 83 | {1411, nullptr, "GetPairingAccountInfo"}, |
| 82 | {1421, nullptr, "GetAccountNickname"}, | 84 | {1421, nullptr, "GetAccountNickname"}, |
| @@ -84,18 +86,18 @@ public: | |||
| 84 | {1425, nullptr, "RequestPostEvents"}, | 86 | {1425, nullptr, "RequestPostEvents"}, |
| 85 | {1426, nullptr, "GetPostEventInterval"}, | 87 | {1426, nullptr, "GetPostEventInterval"}, |
| 86 | {1427, nullptr, "SetPostEventInterval"}, | 88 | {1427, nullptr, "SetPostEventInterval"}, |
| 87 | {1432, nullptr, "GetSynchronizationEvent"}, | 89 | {1432, &IParentalControlService::GetSynchronizationEvent, "GetSynchronizationEvent"}, |
| 88 | {1451, nullptr, "StartPlayTimer"}, | 90 | {1451, nullptr, "StartPlayTimer"}, |
| 89 | {1452, nullptr, "StopPlayTimer"}, | 91 | {1452, nullptr, "StopPlayTimer"}, |
| 90 | {1453, nullptr, "IsPlayTimerEnabled"}, | 92 | {1453, nullptr, "IsPlayTimerEnabled"}, |
| 91 | {1454, nullptr, "GetPlayTimerRemainingTime"}, | 93 | {1454, nullptr, "GetPlayTimerRemainingTime"}, |
| 92 | {1455, nullptr, "IsRestrictedByPlayTimer"}, | 94 | {1455, nullptr, "IsRestrictedByPlayTimer"}, |
| 93 | {1456, nullptr, "GetPlayTimerSettings"}, | 95 | {1456, &IParentalControlService::GetPlayTimerSettings, "GetPlayTimerSettings"}, |
| 94 | {1457, nullptr, "GetPlayTimerEventToRequestSuspension"}, | 96 | {1457, &IParentalControlService::GetPlayTimerEventToRequestSuspension, "GetPlayTimerEventToRequestSuspension"}, |
| 95 | {1458, nullptr, "IsPlayTimerAlarmDisabled"}, | 97 | {1458, &IParentalControlService::IsPlayTimerAlarmDisabled, "IsPlayTimerAlarmDisabled"}, |
| 96 | {1471, nullptr, "NotifyWrongPinCodeInputManyTimes"}, | 98 | {1471, nullptr, "NotifyWrongPinCodeInputManyTimes"}, |
| 97 | {1472, nullptr, "CancelNetworkRequest"}, | 99 | {1472, nullptr, "CancelNetworkRequest"}, |
| 98 | {1473, nullptr, "GetUnlinkedEvent"}, | 100 | {1473, &IParentalControlService::GetUnlinkedEvent, "GetUnlinkedEvent"}, |
| 99 | {1474, nullptr, "ClearUnlinkedEvent"}, | 101 | {1474, nullptr, "ClearUnlinkedEvent"}, |
| 100 | {1601, nullptr, "DisableAllFeatures"}, | 102 | {1601, nullptr, "DisableAllFeatures"}, |
| 101 | {1602, nullptr, "PostEnableAllFeatures"}, | 103 | {1602, nullptr, "PostEnableAllFeatures"}, |
| @@ -131,6 +133,12 @@ public: | |||
| 131 | }; | 133 | }; |
| 132 | // clang-format on | 134 | // clang-format on |
| 133 | RegisterHandlers(functions); | 135 | RegisterHandlers(functions); |
| 136 | |||
| 137 | synchronization_event = | ||
| 138 | service_context.CreateEvent("IParentalControlService::SynchronizationEvent"); | ||
| 139 | unlinked_event = service_context.CreateEvent("IParentalControlService::UnlinkedEvent"); | ||
| 140 | request_suspension_event = | ||
| 141 | service_context.CreateEvent("IParentalControlService::RequestSuspensionEvent"); | ||
| 134 | } | 142 | } |
| 135 | 143 | ||
| 136 | private: | 144 | private: |
| @@ -144,7 +152,7 @@ private: | |||
| 144 | if (pin_code[0] == '\0') { | 152 | if (pin_code[0] == '\0') { |
| 145 | return true; | 153 | return true; |
| 146 | } | 154 | } |
| 147 | if (!settings.is_free_communication_default_on) { | 155 | if (!restriction_settings.is_free_communication_default_on) { |
| 148 | return true; | 156 | return true; |
| 149 | } | 157 | } |
| 150 | // TODO(ogniK): Check for blacklisted/exempted applications. Return false can happen here | 158 | // TODO(ogniK): Check for blacklisted/exempted applications. Return false can happen here |
| @@ -160,21 +168,21 @@ private: | |||
| 160 | if (pin_code[0] == '\0') { | 168 | if (pin_code[0] == '\0') { |
| 161 | return true; | 169 | return true; |
| 162 | } | 170 | } |
| 163 | if (!settings.is_stero_vision_restricted) { | 171 | if (!restriction_settings.is_stero_vision_restricted) { |
| 164 | return false; | 172 | return false; |
| 165 | } | 173 | } |
| 166 | return true; | 174 | return true; |
| 167 | } | 175 | } |
| 168 | 176 | ||
| 169 | void SetStereoVisionRestrictionImpl(bool is_restricted) { | 177 | void SetStereoVisionRestrictionImpl(bool is_restricted) { |
| 170 | if (settings.disabled) { | 178 | if (restriction_settings.disabled) { |
| 171 | return; | 179 | return; |
| 172 | } | 180 | } |
| 173 | 181 | ||
| 174 | if (pin_code[0] == '\0') { | 182 | if (pin_code[0] == '\0') { |
| 175 | return; | 183 | return; |
| 176 | } | 184 | } |
| 177 | settings.is_stero_vision_restricted = is_restricted; | 185 | restriction_settings.is_stero_vision_restricted = is_restricted; |
| 178 | } | 186 | } |
| 179 | 187 | ||
| 180 | void Initialize(HLERequestContext& ctx) { | 188 | void Initialize(HLERequestContext& ctx) { |
| @@ -228,6 +236,17 @@ private: | |||
| 228 | states.free_communication = true; | 236 | states.free_communication = true; |
| 229 | } | 237 | } |
| 230 | 238 | ||
| 239 | void IsRestrictionTemporaryUnlocked(HLERequestContext& ctx) { | ||
| 240 | const bool is_temporary_unlocked = false; | ||
| 241 | |||
| 242 | LOG_WARNING(Service_PCTL, "(STUBBED) called, is_temporary_unlocked={}", | ||
| 243 | is_temporary_unlocked); | ||
| 244 | |||
| 245 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 246 | rb.Push(ResultSuccess); | ||
| 247 | rb.Push<u8>(is_temporary_unlocked); | ||
| 248 | } | ||
| 249 | |||
| 231 | void ConfirmStereoVisionPermission(HLERequestContext& ctx) { | 250 | void ConfirmStereoVisionPermission(HLERequestContext& ctx) { |
| 232 | LOG_DEBUG(Service_PCTL, "called"); | 251 | LOG_DEBUG(Service_PCTL, "called"); |
| 233 | states.stereo_vision = true; | 252 | states.stereo_vision = true; |
| @@ -268,6 +287,34 @@ private: | |||
| 268 | rb.Push(pin_code[0] != '\0'); | 287 | rb.Push(pin_code[0] != '\0'); |
| 269 | } | 288 | } |
| 270 | 289 | ||
| 290 | void GetSafetyLevel(HLERequestContext& ctx) { | ||
| 291 | const u32 safety_level = 0; | ||
| 292 | |||
| 293 | LOG_WARNING(Service_PCTL, "(STUBBED) called, safety_level={}", safety_level); | ||
| 294 | |||
| 295 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 296 | rb.Push(ResultSuccess); | ||
| 297 | rb.Push(safety_level); | ||
| 298 | } | ||
| 299 | |||
| 300 | void GetCurrentSettings(HLERequestContext& ctx) { | ||
| 301 | LOG_INFO(Service_PCTL, "called"); | ||
| 302 | |||
| 303 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 304 | rb.Push(ResultSuccess); | ||
| 305 | rb.PushRaw(restriction_settings); | ||
| 306 | } | ||
| 307 | |||
| 308 | void GetFreeCommunicationApplicationListCount(HLERequestContext& ctx) { | ||
| 309 | const u32 count = 4; | ||
| 310 | |||
| 311 | LOG_WARNING(Service_PCTL, "(STUBBED) called, count={}", count); | ||
| 312 | |||
| 313 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 314 | rb.Push(ResultSuccess); | ||
| 315 | rb.Push(count); | ||
| 316 | } | ||
| 317 | |||
| 271 | void ConfirmStereoVisionRestrictionConfigurable(HLERequestContext& ctx) { | 318 | void ConfirmStereoVisionRestrictionConfigurable(HLERequestContext& ctx) { |
| 272 | LOG_DEBUG(Service_PCTL, "called"); | 319 | LOG_DEBUG(Service_PCTL, "called"); |
| 273 | 320 | ||
| @@ -300,6 +347,61 @@ private: | |||
| 300 | } | 347 | } |
| 301 | } | 348 | } |
| 302 | 349 | ||
| 350 | void IsPairingActive(HLERequestContext& ctx) { | ||
| 351 | const bool is_pairing_active = false; | ||
| 352 | |||
| 353 | LOG_WARNING(Service_PCTL, "(STUBBED) called, is_pairing_active={}", is_pairing_active); | ||
| 354 | |||
| 355 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 356 | rb.Push(ResultSuccess); | ||
| 357 | rb.Push<u8>(is_pairing_active); | ||
| 358 | } | ||
| 359 | |||
| 360 | void GetSynchronizationEvent(HLERequestContext& ctx) { | ||
| 361 | LOG_INFO(Service_PCTL, "called"); | ||
| 362 | |||
| 363 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 364 | rb.Push(ResultSuccess); | ||
| 365 | rb.PushCopyObjects(synchronization_event->GetReadableEvent()); | ||
| 366 | } | ||
| 367 | |||
| 368 | void GetPlayTimerSettings(HLERequestContext& ctx) { | ||
| 369 | LOG_WARNING(Service_PCTL, "(STUBBED) called"); | ||
| 370 | |||
| 371 | const PlayTimerSettings timer_settings{}; | ||
| 372 | |||
| 373 | IPC::ResponseBuilder rb{ctx, 15}; | ||
| 374 | rb.Push(ResultSuccess); | ||
| 375 | rb.PushRaw(timer_settings); | ||
| 376 | } | ||
| 377 | |||
| 378 | void GetPlayTimerEventToRequestSuspension(HLERequestContext& ctx) { | ||
| 379 | LOG_INFO(Service_PCTL, "called"); | ||
| 380 | |||
| 381 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 382 | rb.Push(ResultSuccess); | ||
| 383 | rb.PushCopyObjects(request_suspension_event->GetReadableEvent()); | ||
| 384 | } | ||
| 385 | |||
| 386 | void IsPlayTimerAlarmDisabled(HLERequestContext& ctx) { | ||
| 387 | const bool is_play_timer_alarm_disabled = false; | ||
| 388 | |||
| 389 | LOG_INFO(Service_PCTL, "called, is_play_timer_alarm_disabled={}", | ||
| 390 | is_play_timer_alarm_disabled); | ||
| 391 | |||
| 392 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 393 | rb.Push(ResultSuccess); | ||
| 394 | rb.Push<u8>(is_play_timer_alarm_disabled); | ||
| 395 | } | ||
| 396 | |||
| 397 | void GetUnlinkedEvent(HLERequestContext& ctx) { | ||
| 398 | LOG_INFO(Service_PCTL, "called"); | ||
| 399 | |||
| 400 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 401 | rb.Push(ResultSuccess); | ||
| 402 | rb.PushCopyObjects(unlinked_event->GetReadableEvent()); | ||
| 403 | } | ||
| 404 | |||
| 303 | void SetStereoVisionRestriction(HLERequestContext& ctx) { | 405 | void SetStereoVisionRestriction(HLERequestContext& ctx) { |
| 304 | IPC::RequestParser rp{ctx}; | 406 | IPC::RequestParser rp{ctx}; |
| 305 | const auto can_use = rp.Pop<bool>(); | 407 | const auto can_use = rp.Pop<bool>(); |
| @@ -328,7 +430,7 @@ private: | |||
| 328 | } | 430 | } |
| 329 | 431 | ||
| 330 | rb.Push(ResultSuccess); | 432 | rb.Push(ResultSuccess); |
| 331 | rb.Push(settings.is_stero_vision_restricted); | 433 | rb.Push(restriction_settings.is_stero_vision_restricted); |
| 332 | } | 434 | } |
| 333 | 435 | ||
| 334 | void ResetConfirmedStereoVisionPermission(HLERequestContext& ctx) { | 436 | void ResetConfirmedStereoVisionPermission(HLERequestContext& ctx) { |
| @@ -358,16 +460,30 @@ private: | |||
| 358 | bool stereo_vision{}; | 460 | bool stereo_vision{}; |
| 359 | }; | 461 | }; |
| 360 | 462 | ||
| 361 | struct ParentalControlSettings { | 463 | // This is nn::pctl::RestrictionSettings |
| 464 | struct RestrictionSettings { | ||
| 362 | bool is_stero_vision_restricted{}; | 465 | bool is_stero_vision_restricted{}; |
| 363 | bool is_free_communication_default_on{}; | 466 | bool is_free_communication_default_on{}; |
| 364 | bool disabled{}; | 467 | bool disabled{}; |
| 365 | }; | 468 | }; |
| 469 | static_assert(sizeof(RestrictionSettings) == 0x3, "RestrictionSettings has incorrect size."); | ||
| 470 | |||
| 471 | // This is nn::pctl::PlayTimerSettings | ||
| 472 | struct PlayTimerSettings { | ||
| 473 | // TODO: RE the actual contents of this struct | ||
| 474 | std::array<u8, 0x34> settings; | ||
| 475 | }; | ||
| 476 | static_assert(sizeof(PlayTimerSettings) == 0x34, "PlayTimerSettings has incorrect size."); | ||
| 366 | 477 | ||
| 367 | States states{}; | 478 | States states{}; |
| 368 | ParentalControlSettings settings{}; | 479 | RestrictionSettings restriction_settings{}; |
| 369 | std::array<char, 8> pin_code{}; | 480 | std::array<char, 8> pin_code{}; |
| 370 | Capability capability{}; | 481 | Capability capability{}; |
| 482 | |||
| 483 | Kernel::KEvent* synchronization_event; | ||
| 484 | Kernel::KEvent* unlinked_event; | ||
| 485 | Kernel::KEvent* request_suspension_event; | ||
| 486 | KernelHelpers::ServiceContext service_context; | ||
| 371 | }; | 487 | }; |
| 372 | 488 | ||
| 373 | void Module::Interface::CreateService(HLERequestContext& ctx) { | 489 | void Module::Interface::CreateService(HLERequestContext& ctx) { |