IAccountServiceForApplication.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.HLE.HOS.Services.Account.Acc.AccountService;
  3. using Ryujinx.HLE.HOS.Services.Arp;
  4. namespace Ryujinx.HLE.HOS.Services.Account.Acc
  5. {
  6. [Service("acc:u0", AccountServiceFlag.Application)] // Max Sessions: 4
  7. class IAccountServiceForApplication : IpcService
  8. {
  9. private ApplicationServiceServer _applicationServiceServer;
  10. public IAccountServiceForApplication(ServiceCtx context, AccountServiceFlag serviceFlag)
  11. {
  12. _applicationServiceServer = new ApplicationServiceServer(serviceFlag);
  13. }
  14. [CommandHipc(0)]
  15. // GetUserCount() -> i32
  16. public ResultCode GetUserCount(ServiceCtx context)
  17. {
  18. return _applicationServiceServer.GetUserCountImpl(context);
  19. }
  20. [CommandHipc(1)]
  21. // GetUserExistence(nn::account::Uid) -> bool
  22. public ResultCode GetUserExistence(ServiceCtx context)
  23. {
  24. return _applicationServiceServer.GetUserExistenceImpl(context);
  25. }
  26. [CommandHipc(2)]
  27. // ListAllUsers() -> array<nn::account::Uid, 0xa>
  28. public ResultCode ListAllUsers(ServiceCtx context)
  29. {
  30. return _applicationServiceServer.ListAllUsers(context);
  31. }
  32. [CommandHipc(3)]
  33. // ListOpenUsers() -> array<nn::account::Uid, 0xa>
  34. public ResultCode ListOpenUsers(ServiceCtx context)
  35. {
  36. return _applicationServiceServer.ListOpenUsers(context);
  37. }
  38. [CommandHipc(4)]
  39. // GetLastOpenedUser() -> nn::account::Uid
  40. public ResultCode GetLastOpenedUser(ServiceCtx context)
  41. {
  42. return _applicationServiceServer.GetLastOpenedUser(context);
  43. }
  44. [CommandHipc(5)]
  45. // GetProfile(nn::account::Uid) -> object<nn::account::profile::IProfile>
  46. public ResultCode GetProfile(ServiceCtx context)
  47. {
  48. ResultCode resultCode = _applicationServiceServer.GetProfile(context, out IProfile iProfile);
  49. if (resultCode == ResultCode.Success)
  50. {
  51. MakeObject(context, iProfile);
  52. }
  53. return resultCode;
  54. }
  55. [CommandHipc(50)]
  56. // IsUserRegistrationRequestPermitted(pid) -> bool
  57. public ResultCode IsUserRegistrationRequestPermitted(ServiceCtx context)
  58. {
  59. // NOTE: pid is unused.
  60. return _applicationServiceServer.IsUserRegistrationRequestPermitted(context);
  61. }
  62. [CommandHipc(51)]
  63. // TrySelectUserWithoutInteraction(bool) -> nn::account::Uid
  64. public ResultCode TrySelectUserWithoutInteraction(ServiceCtx context)
  65. {
  66. return _applicationServiceServer.TrySelectUserWithoutInteraction(context);
  67. }
  68. [CommandHipc(100)]
  69. [CommandHipc(140)] // 6.0.0+
  70. [CommandHipc(160)] // 13.0.0+
  71. // InitializeApplicationInfo(u64 pid_placeholder, pid)
  72. public ResultCode InitializeApplicationInfo(ServiceCtx context)
  73. {
  74. // NOTE: In call 100, account service use the pid_placeholder instead of the real pid, which is wrong, call 140 fix that.
  75. /*
  76. // TODO: Account actually calls nn::arp::detail::IReader::GetApplicationLaunchProperty() with the current PID and store the result (ApplicationLaunchProperty) internally.
  77. // For now we can hardcode values, and fix it after GetApplicationLaunchProperty is implemented.
  78. if (nn::arp::detail::IReader::GetApplicationLaunchProperty() == 0xCC9D) // ResultCode.InvalidProcessId
  79. {
  80. return ResultCode.InvalidArgument;
  81. }
  82. */
  83. // TODO: Determine where ApplicationLaunchProperty is used.
  84. ApplicationLaunchProperty applicationLaunchProperty = ApplicationLaunchProperty.GetByPid(context);
  85. Logger.Stub?.PrintStub(LogClass.ServiceAcc, new { applicationLaunchProperty.TitleId });
  86. return ResultCode.Success;
  87. }
  88. [CommandHipc(101)]
  89. // GetBaasAccountManagerForApplication(nn::account::Uid) -> object<nn::account::baas::IManagerForApplication>
  90. public ResultCode GetBaasAccountManagerForApplication(ServiceCtx context)
  91. {
  92. ResultCode resultCode = _applicationServiceServer.CheckUserId(context, out UserId userId);
  93. if (resultCode != ResultCode.Success)
  94. {
  95. return resultCode;
  96. }
  97. MakeObject(context, new IManagerForApplication(userId));
  98. // Doesn't occur in our case.
  99. // return ResultCode.NullObject;
  100. return ResultCode.Success;
  101. }
  102. [CommandHipc(103)] // 4.0.0+
  103. // CheckNetworkServiceAvailabilityAsync() -> object<nn::account::detail::IAsyncContext>
  104. public ResultCode CheckNetworkServiceAvailabilityAsync(ServiceCtx context)
  105. {
  106. ResultCode resultCode = _applicationServiceServer.CheckNetworkServiceAvailabilityAsync(context, out IAsyncContext asyncContext);
  107. if (resultCode == ResultCode.Success)
  108. {
  109. MakeObject(context, asyncContext);
  110. }
  111. return resultCode;
  112. }
  113. [CommandHipc(110)]
  114. // StoreSaveDataThumbnail(nn::account::Uid, buffer<bytes, 5>)
  115. public ResultCode StoreSaveDataThumbnail(ServiceCtx context)
  116. {
  117. return _applicationServiceServer.StoreSaveDataThumbnail(context);
  118. }
  119. [CommandHipc(111)]
  120. // ClearSaveDataThumbnail(nn::account::Uid)
  121. public ResultCode ClearSaveDataThumbnail(ServiceCtx context)
  122. {
  123. return _applicationServiceServer.ClearSaveDataThumbnail(context);
  124. }
  125. [CommandHipc(130)] // 5.0.0+
  126. // LoadOpenContext(nn::account::Uid)
  127. public ResultCode LoadOpenContext(ServiceCtx context)
  128. {
  129. Logger.Stub?.PrintStub(LogClass.ServiceAcc);
  130. return ResultCode.Success;
  131. }
  132. [CommandHipc(60)] // 5.0.0-5.1.0
  133. [CommandHipc(131)] // 6.0.0+
  134. // ListOpenContextStoredUsers() -> array<nn::account::Uid, 0xa>
  135. public ResultCode ListOpenContextStoredUsers(ServiceCtx context)
  136. {
  137. return _applicationServiceServer.ListOpenContextStoredUsers(context);
  138. }
  139. [CommandHipc(141)] // 6.0.0+
  140. // ListQualifiedUsers() -> array<nn::account::Uid, 0xa>
  141. public ResultCode ListQualifiedUsers(ServiceCtx context)
  142. {
  143. return _applicationServiceServer.ListQualifiedUsers(context);
  144. }
  145. [CommandHipc(150)] // 6.0.0+
  146. // IsUserAccountSwitchLocked() -> bool
  147. public ResultCode IsUserAccountSwitchLocked(ServiceCtx context)
  148. {
  149. // TODO: Account actually calls nn::arp::detail::IReader::GetApplicationControlProperty() with the current Pid and store the result (NACP file) internally.
  150. // But since we use LibHac and we load one Application at a time, it's not necessary.
  151. context.ResponseData.Write((byte)context.Device.Application.ControlData.Value.UserAccountSwitchLock);
  152. Logger.Stub?.PrintStub(LogClass.ServiceAcc);
  153. return ResultCode.Success;
  154. }
  155. }
  156. }