2018-10-17 17:15:50 +00:00
using Ryujinx.Common.Logging ;
2021-01-02 22:34:28 +00:00
using Ryujinx.HLE.HOS.Services.Account.Acc.AccountService ;
2019-09-19 00:45:11 +00:00
using Ryujinx.HLE.HOS.Services.Arp ;
2018-02-25 04:34:16 +00:00
2019-09-19 00:45:11 +00:00
namespace Ryujinx.HLE.HOS.Services.Account.Acc
2018-02-25 04:34:16 +00:00
{
2021-01-02 22:34:28 +00:00
[Service("acc:u0", AccountServiceFlag.Application)] // Max Sessions: 4
2019-09-19 00:45:11 +00:00
class IAccountServiceForApplication : IpcService
2018-02-25 04:34:16 +00:00
{
2021-01-02 22:34:28 +00:00
private ApplicationServiceServer _applicationServiceServer ;
2019-06-15 22:35:38 +00:00
2021-01-02 22:34:28 +00:00
public IAccountServiceForApplication ( ServiceCtx context , AccountServiceFlag serviceFlag )
{
_applicationServiceServer = new ApplicationServiceServer ( serviceFlag ) ;
}
2018-02-25 04:34:16 +00:00
2023-04-14 23:00:34 +00:00
[CommandCmif(0)]
2018-10-13 23:16:02 +00:00
// GetUserCount() -> i32
2019-07-14 19:04:38 +00:00
public ResultCode GetUserCount ( ServiceCtx context )
2018-04-17 16:41:14 +00:00
{
2021-01-02 22:34:28 +00:00
return _applicationServiceServer . GetUserCountImpl ( context ) ;
2018-04-17 16:41:14 +00:00
}
2018-06-11 00:46:42 +00:00
2023-04-14 23:00:34 +00:00
[CommandCmif(1)]
2018-10-13 23:16:02 +00:00
// GetUserExistence(nn::account::Uid) -> bool
2019-07-14 19:04:38 +00:00
public ResultCode GetUserExistence ( ServiceCtx context )
2018-06-10 04:36:07 +00:00
{
2021-01-02 22:34:28 +00:00
return _applicationServiceServer . GetUserExistenceImpl ( context ) ;
2018-06-10 04:36:07 +00:00
}
2018-04-17 16:41:14 +00:00
2023-04-14 23:00:34 +00:00
[CommandCmif(2)]
2018-10-13 23:16:02 +00:00
// ListAllUsers() -> array<nn::account::Uid, 0xa>
2019-07-14 19:04:38 +00:00
public ResultCode ListAllUsers ( ServiceCtx context )
2018-06-10 04:36:07 +00:00
{
2021-01-02 22:34:28 +00:00
return _applicationServiceServer . ListAllUsers ( context ) ;
2018-06-10 04:36:07 +00:00
}
2018-06-11 00:46:42 +00:00
2023-04-14 23:00:34 +00:00
[CommandCmif(3)]
2018-10-13 23:16:02 +00:00
// ListOpenUsers() -> array<nn::account::Uid, 0xa>
2019-07-14 19:04:38 +00:00
public ResultCode ListOpenUsers ( ServiceCtx context )
2018-02-25 04:34:16 +00:00
{
2021-01-02 22:34:28 +00:00
return _applicationServiceServer . ListOpenUsers ( context ) ;
2018-02-25 04:34:16 +00:00
}
2023-04-14 23:00:34 +00:00
[CommandCmif(4)]
2018-10-13 23:16:02 +00:00
// GetLastOpenedUser() -> nn::account::Uid
2019-07-14 19:04:38 +00:00
public ResultCode GetLastOpenedUser ( ServiceCtx context )
2018-06-02 22:46:09 +00:00
{
2021-01-02 22:34:28 +00:00
return _applicationServiceServer . GetLastOpenedUser ( context ) ;
2018-06-02 22:46:09 +00:00
}
2023-04-14 23:00:34 +00:00
[CommandCmif(5)]
2018-10-13 23:16:02 +00:00
// GetProfile(nn::account::Uid) -> object<nn::account::profile::IProfile>
2019-07-14 19:04:38 +00:00
public ResultCode GetProfile ( ServiceCtx context )
2018-02-25 04:34:16 +00:00
{
2021-01-02 22:34:28 +00:00
ResultCode resultCode = _applicationServiceServer . GetProfile ( context , out IProfile iProfile ) ;
2018-08-14 22:02:42 +00:00
2021-01-02 22:34:28 +00:00
if ( resultCode = = ResultCode . Success )
2018-08-14 22:02:42 +00:00
{
2021-01-02 22:34:28 +00:00
MakeObject ( context , iProfile ) ;
2018-08-14 22:02:42 +00:00
}
2021-01-02 22:34:28 +00:00
return resultCode ;
2018-02-25 04:34:16 +00:00
}
2023-04-14 23:00:34 +00:00
[CommandCmif(50)]
2021-01-02 22:34:28 +00:00
// IsUserRegistrationRequestPermitted(pid) -> bool
2019-07-14 19:04:38 +00:00
public ResultCode IsUserRegistrationRequestPermitted ( ServiceCtx context )
2018-10-13 23:16:02 +00:00
{
2021-01-02 22:34:28 +00:00
// NOTE: pid is unused.
return _applicationServiceServer . IsUserRegistrationRequestPermitted ( context ) ;
2018-10-13 23:16:02 +00:00
}
2023-04-14 23:00:34 +00:00
[CommandCmif(51)]
2018-10-13 23:16:02 +00:00
// TrySelectUserWithoutInteraction(bool) -> nn::account::Uid
2019-07-14 19:04:38 +00:00
public ResultCode TrySelectUserWithoutInteraction ( ServiceCtx context )
2018-10-13 23:16:02 +00:00
{
2021-01-02 22:34:28 +00:00
return _applicationServiceServer . TrySelectUserWithoutInteraction ( context ) ;
2018-10-13 23:16:02 +00:00
}
2023-04-14 23:00:34 +00:00
[CommandCmif(100)]
[CommandCmif(140)] // 6.0.0+
[CommandCmif(160)] // 13.0.0+
2021-01-02 22:34:28 +00:00
// InitializeApplicationInfo(u64 pid_placeholder, pid)
2019-07-14 19:04:38 +00:00
public ResultCode InitializeApplicationInfo ( ServiceCtx context )
2018-02-25 04:34:16 +00:00
{
2021-01-02 22:34:28 +00:00
// NOTE: In call 100, account service use the pid_placeholder instead of the real pid, which is wrong, call 140 fix that.
2019-06-15 22:35:38 +00:00
2021-01-02 22:34:28 +00:00
/ *
2018-10-13 23:16:02 +00:00
2019-06-15 22:35:38 +00:00
// TODO: Account actually calls nn::arp::detail::IReader::GetApplicationLaunchProperty() with the current PID and store the result (ApplicationLaunchProperty) internally.
// For now we can hardcode values, and fix it after GetApplicationLaunchProperty is implemented.
2021-01-02 22:34:28 +00:00
if ( nn : : arp : : detail : : IReader : : GetApplicationLaunchProperty ( ) = = 0xCC9D ) // ResultCode.InvalidProcessId
2019-06-15 22:35:38 +00:00
{
2019-07-14 19:04:38 +00:00
return ResultCode . InvalidArgument ;
2019-06-15 22:35:38 +00:00
}
2021-01-02 22:34:28 +00:00
2019-06-15 22:35:38 +00:00
* /
2021-01-02 22:34:28 +00:00
// TODO: Determine where ApplicationLaunchProperty is used.
ApplicationLaunchProperty applicationLaunchProperty = ApplicationLaunchProperty . GetByPid ( context ) ;
Logger . Stub ? . PrintStub ( LogClass . ServiceAcc , new { applicationLaunchProperty . TitleId } ) ;
2018-04-17 00:24:42 +00:00
2019-07-14 19:04:38 +00:00
return ResultCode . Success ;
2018-02-25 04:34:16 +00:00
}
2023-04-14 23:00:34 +00:00
[CommandCmif(101)]
2019-06-15 22:35:38 +00:00
// GetBaasAccountManagerForApplication(nn::account::Uid) -> object<nn::account::baas::IManagerForApplication>
2019-07-14 19:04:38 +00:00
public ResultCode GetBaasAccountManagerForApplication ( ServiceCtx context )
2018-02-25 04:34:16 +00:00
{
2021-01-02 22:34:28 +00:00
ResultCode resultCode = _applicationServiceServer . CheckUserId ( context , out UserId userId ) ;
2019-06-15 22:35:38 +00:00
2021-01-02 22:34:28 +00:00
if ( resultCode ! = ResultCode . Success )
2019-06-15 22:35:38 +00:00
{
2021-01-02 22:34:28 +00:00
return resultCode ;
2019-06-15 22:35:38 +00:00
}
2021-01-02 22:34:28 +00:00
MakeObject ( context , new IManagerForApplication ( userId ) ) ;
2019-06-15 22:35:38 +00:00
// Doesn't occur in our case.
2019-07-14 19:04:38 +00:00
// return ResultCode.NullObject;
2019-06-15 22:35:38 +00:00
2019-07-14 19:04:38 +00:00
return ResultCode . Success ;
2019-06-15 22:35:38 +00:00
}
2023-04-14 23:00:34 +00:00
[CommandCmif(103)] // 4.0.0+
2022-12-07 22:19:22 +00:00
// CheckNetworkServiceAvailabilityAsync() -> object<nn::account::detail::IAsyncContext>
public ResultCode CheckNetworkServiceAvailabilityAsync ( ServiceCtx context )
{
ResultCode resultCode = _applicationServiceServer . CheckNetworkServiceAvailabilityAsync ( context , out IAsyncContext asyncContext ) ;
if ( resultCode = = ResultCode . Success )
{
MakeObject ( context , asyncContext ) ;
}
return resultCode ;
}
2023-02-01 15:52:36 +00:00
2023-04-14 23:00:34 +00:00
[CommandCmif(110)]
2019-06-15 22:35:38 +00:00
// StoreSaveDataThumbnail(nn::account::Uid, buffer<bytes, 5>)
2019-07-14 19:04:38 +00:00
public ResultCode StoreSaveDataThumbnail ( ServiceCtx context )
2019-06-15 22:35:38 +00:00
{
2021-01-02 22:34:28 +00:00
return _applicationServiceServer . StoreSaveDataThumbnail ( context ) ;
2019-06-15 22:35:38 +00:00
}
2023-04-14 23:00:34 +00:00
[CommandCmif(111)]
2019-06-15 22:35:38 +00:00
// ClearSaveDataThumbnail(nn::account::Uid)
2019-07-14 19:04:38 +00:00
public ResultCode ClearSaveDataThumbnail ( ServiceCtx context )
2019-06-15 22:35:38 +00:00
{
2021-01-02 22:34:28 +00:00
return _applicationServiceServer . ClearSaveDataThumbnail ( context ) ;
2019-06-15 22:35:38 +00:00
}
2023-04-14 23:00:34 +00:00
[CommandCmif(130)] // 5.0.0+
2023-02-01 15:52:36 +00:00
// LoadOpenContext(nn::account::Uid) -> object<nn::account::baas::IManagerForApplication>
2022-09-28 00:24:52 +00:00
public ResultCode LoadOpenContext ( ServiceCtx context )
2020-09-20 04:32:58 +00:00
{
2023-02-01 15:52:36 +00:00
ResultCode resultCode = _applicationServiceServer . CheckUserId ( context , out UserId userId ) ;
if ( resultCode ! = ResultCode . Success )
{
return resultCode ;
}
MakeObject ( context , new IManagerForApplication ( userId ) ) ;
2020-09-20 04:32:58 +00:00
return ResultCode . Success ;
}
2023-04-14 23:00:34 +00:00
[CommandCmif(60)] // 5.0.0-5.1.0
[CommandCmif(131)] // 6.0.0+
2022-09-28 00:24:52 +00:00
// ListOpenContextStoredUsers() -> array<nn::account::Uid, 0xa>
public ResultCode ListOpenContextStoredUsers ( ServiceCtx context )
{
return _applicationServiceServer . ListOpenContextStoredUsers ( context ) ;
}
2023-04-14 23:00:34 +00:00
[CommandCmif(141)] // 6.0.0+
2020-09-20 04:32:58 +00:00
// ListQualifiedUsers() -> array<nn::account::Uid, 0xa>
public ResultCode ListQualifiedUsers ( ServiceCtx context )
{
2021-01-02 22:34:28 +00:00
return _applicationServiceServer . ListQualifiedUsers ( context ) ;
2020-09-20 04:32:58 +00:00
}
2023-04-14 23:00:34 +00:00
[CommandCmif(150)] // 6.0.0+
2019-06-15 22:35:38 +00:00
// IsUserAccountSwitchLocked() -> bool
2019-07-14 19:04:38 +00:00
public ResultCode IsUserAccountSwitchLocked ( ServiceCtx context )
2019-06-15 22:35:38 +00:00
{
2021-01-02 22:34:28 +00:00
// TODO: Account actually calls nn::arp::detail::IReader::GetApplicationControlProperty() with the current Pid and store the result (NACP file) internally.
// But since we use LibHac and we load one Application at a time, it's not necessary.
2019-06-15 22:35:38 +00:00
2023-03-31 19:16:46 +00:00
context . ResponseData . Write ( ( byte ) context . Device . Processes . ActiveApplication . ApplicationControlProperties . UserAccountSwitchLock ) ;
2018-10-13 23:16:02 +00:00
2020-08-03 23:32:53 +00:00
Logger . Stub ? . PrintStub ( LogClass . ServiceAcc ) ;
2018-02-25 04:34:16 +00:00
2019-07-14 19:04:38 +00:00
return ResultCode . Success ;
2018-02-25 04:34:16 +00:00
}
}
2021-01-02 22:34:28 +00:00
}