early-access version 4078

This commit is contained in:
pineappleEA
2024-01-21 22:19:44 +01:00
parent d8a053b53a
commit 5ebb2d002d
27 changed files with 2115 additions and 355 deletions

View File

@@ -7,6 +7,7 @@
#include "core/core_timing.h"
#include "common/settings.h"
#include "common/time_zone.h"
#include "core/file_sys/vfs.h"
#include "core/hle/kernel/svc.h"
#include "core/hle/service/glue/time/manager.h"
@@ -73,6 +74,26 @@ s64 GetEpochTimeFromInitialYear(std::shared_ptr<Service::Set::ISystemSettingsSer
};
return CalendarTimeToEpoch(calendar);
}
Service::PSC::Time::LocationName GetTimeZoneString(Service::PSC::Time::LocationName& in_name) {
auto configured_zone = Settings::GetTimeZoneString(Settings::values.time_zone_index.GetValue());
Service::PSC::Time::LocationName configured_name{};
std::memcpy(configured_name.name.data(), configured_zone.data(),
std::min(configured_name.name.size(), configured_zone.size()));
if (!IsTimeZoneBinaryValid(configured_name)) {
configured_zone = Common::TimeZone::FindSystemTimeZone();
configured_name = {};
std::memcpy(configured_name.name.data(), configured_zone.data(),
std::min(configured_name.name.size(), configured_zone.size()));
}
ASSERT_MSG(IsTimeZoneBinaryValid(configured_name), "Invalid time zone!");
return configured_name;
}
} // namespace
TimeManager::TimeManager(Core::System& system)
@@ -87,7 +108,6 @@ TimeManager::TimeManager(Core::System& system)
m_set_sys =
system.ServiceManager().GetService<Service::Set::ISystemSettingsServer>("set:sys", true);
ResetTimeZoneBinary();
res = MountTimeZoneBinary(system);
ASSERT(res == ResultSuccess);
@@ -220,13 +240,11 @@ Result TimeManager::SetupTimeZoneServiceCore() {
auto res = m_set_sys->GetDeviceTimeZoneLocationName(name);
ASSERT(res == ResultSuccess);
auto configured_zone = Settings::GetTimeZoneString(Settings::values.time_zone_index.GetValue());
Service::PSC::Time::LocationName new_name{};
std::memcpy(new_name.name.data(), configured_zone.data(),
std::min(new_name.name.size(), configured_zone.size()));
if (new_name.name != name.name) {
m_set_sys->SetDeviceTimeZoneLocationName(new_name);
name = new_name;
auto configured_zone = GetTimeZoneString(name);
if (configured_zone.name != name.name) {
m_set_sys->SetDeviceTimeZoneLocationName(configured_zone);
name = configured_zone;
std::shared_ptr<Service::PSC::Time::SystemClock> local_clock;
m_time_sm->GetStandardLocalSystemClock(local_clock);

View File

@@ -46,6 +46,8 @@ void ResetTimeZoneBinary() {
}
Result MountTimeZoneBinary(Core::System& system) {
ResetTimeZoneBinary();
auto& fsc{system.GetFileSystemController()};
std::unique_ptr<FileSys::NCA> nca{};
@@ -99,6 +101,9 @@ bool IsTimeZoneBinaryValid(Service::PSC::Time::LocationName& name) {
GetTimeZoneZonePath(path, name);
auto vfs_file{g_time_zone_binary_romfs->GetFileRelative(path)};
if (!vfs_file) {
return false;
}
return vfs_file->GetSize() != 0;
}

View File

@@ -11,8 +11,6 @@ SystemClock::SystemClock(Core::System& system_, SystemClockCore& clock_core, boo
: ServiceFramework{system_, "ISystemClock"}, m_system{system}, m_clock_core{clock_core},
m_can_write_clock{can_write_clock}, m_can_write_uninitialized_clock{
can_write_uninitialized_clock} {
SystemClockContext ctx{};
m_clock_core.GetContext(ctx);
// clang-format off
static const FunctionInfo functions[] = {
{0, &SystemClock::Handle_GetCurrentTime, "GetCurrentTime"},
@@ -115,12 +113,12 @@ Result SystemClock::SetSystemClockContext(SystemClockContext& context) {
}
Result SystemClock::GetOperationEventReadableHandle(Kernel::KEvent** out_event) {
R_SUCCEED_IF(m_operation_event != nullptr);
if (!m_operation_event) {
m_operation_event = std::make_unique<OperationEvent>(m_system);
R_UNLESS(m_operation_event != nullptr, ResultFailed);
m_operation_event = std::make_unique<OperationEvent>(m_system);
R_UNLESS(m_operation_event != nullptr, ResultFailed);
m_clock_core.LinkOperationEvent(*m_operation_event);
m_clock_core.LinkOperationEvent(*m_operation_event);
}
*out_event = m_operation_event->m_event;
R_SUCCEED();

View File

@@ -1036,6 +1036,11 @@ void ISystemSettingsServer::SetBluetoothEnableFlag(HLERequestContext& ctx) {
}
void ISystemSettingsServer::GetMiiAuthorId(HLERequestContext& ctx) {
if (m_system_settings.mii_author_id.IsInvalid()) {
m_system_settings.mii_author_id = Common::UUID::MakeDefault();
SetSaveNeeded();
}
LOG_INFO(Service_SET, "called, author_id={}",
m_system_settings.mii_author_id.FormattedString());