mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-28 20:10:14 +00:00
a33dc2f491
* Logger class changes only Now compile-time checking is possible with the help of Nullable Value types. * Misc formatting * Manual optimizations PrintGuestLog PrintGuestStackTrace Surfaceflinger DequeueBuffer * Reduce SendVibrationXX log level to Debug * Add Notice log level This level is always enabled and used to print system info, etc... Also, rewrite LogColor to switch expression as colors are static * Unify unhandled exception event handlers * Print enabled LogLevels during init * Re-add App Exit disposes in proper order nit: switch case spacing * Revert PrintGuestStackTrace to Info logs due to #1407 PrintGuestStackTrace is now called in some critical error handlers so revert to old behavior as KThread isn't part of Guest. * Batch replace Logger statements
83 lines
No EOL
2.8 KiB
C#
83 lines
No EOL
2.8 KiB
C#
using Ryujinx.Common.Logging;
|
|
using Ryujinx.HLE.HOS.Services.Arp;
|
|
using System;
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Pctl.ParentalControlServiceFactory
|
|
{
|
|
class IParentalControlService : IpcService
|
|
{
|
|
private int _permissionFlag;
|
|
private ulong _titleId;
|
|
private bool _freeCommunicationEnabled;
|
|
private int[] _ratingAge;
|
|
|
|
public IParentalControlService(ServiceCtx context, bool withInitialize, int permissionFlag)
|
|
{
|
|
_permissionFlag = permissionFlag;
|
|
|
|
if (withInitialize)
|
|
{
|
|
Initialize(context);
|
|
}
|
|
}
|
|
|
|
[Command(1)] // 4.0.0+
|
|
// Initialize()
|
|
public ResultCode Initialize(ServiceCtx context)
|
|
{
|
|
if ((_permissionFlag & 0x8001) == 0)
|
|
{
|
|
return ResultCode.PermissionDenied;
|
|
}
|
|
|
|
ResultCode resultCode = ResultCode.InvalidPid;
|
|
|
|
if (context.Process.Pid != 0)
|
|
{
|
|
if ((_permissionFlag & 0x40) == 0)
|
|
{
|
|
ulong titleId = ApplicationLaunchProperty.GetByPid(context).TitleId;
|
|
|
|
if (titleId != 0)
|
|
{
|
|
_titleId = titleId;
|
|
|
|
// TODO: Call nn::arp::GetApplicationControlProperty here when implemented, if it return ResultCode.Success we assign fields.
|
|
_ratingAge = Array.ConvertAll(context.Device.Application.ControlData.Value.RatingAge.ToArray(), Convert.ToInt32);
|
|
_freeCommunicationEnabled = context.Device.Application.ControlData.Value.ParentalControl == LibHac.Ns.ParentalControlFlagValue.FreeCommunication;
|
|
}
|
|
}
|
|
|
|
if (_titleId != 0)
|
|
{
|
|
// TODO: Service store some private fields in another static object.
|
|
|
|
if ((_permissionFlag & 0x8040) == 0)
|
|
{
|
|
// TODO: Service store TitleId and FreeCommunicationEnabled in another static object.
|
|
// When it's done it signal an event in this static object.
|
|
Logger.Stub?.PrintStub(LogClass.ServicePctl);
|
|
}
|
|
}
|
|
|
|
resultCode = ResultCode.Success;
|
|
}
|
|
|
|
return resultCode;
|
|
}
|
|
|
|
[Command(1001)]
|
|
// CheckFreeCommunicationPermission()
|
|
public ResultCode CheckFreeCommunicationPermission(ServiceCtx context)
|
|
{
|
|
Logger.Stub?.PrintStub(LogClass.ServicePctl);
|
|
|
|
if (!_freeCommunicationEnabled)
|
|
{
|
|
return ResultCode.FreeCommunicationDisabled;
|
|
}
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
}
|
|
} |