Files
tactility/Tactility/Source/settings/BootSettings.cpp
T
Ken Van Hoeylandt f620255c41 New logging and more (#446)
- `TT_LOG_*` macros are replaced by `Logger` via `#include<Tactility/Logger.h>`
- Changed default timezone to Europe/Amsterdam
- Fix for logic bug in unPhone hardware
- Fix for init/deinit in DRV2605 driver
- Other fixes
- Removed optimization that broke unPhone (disabled the moving of heap-related functions to flash)
2026-01-06 22:35:39 +01:00

48 lines
1.5 KiB
C++

#include <Tactility/MountPoints.h>
#include <Tactility/file/File.h>
#include <Tactility/file/PropertiesFile.h>
#include <Tactility/hal/sdcard/SdCardDevice.h>
#include <Tactility/Logger.h>
#include <Tactility/settings/BootSettings.h>
#include <format>
#include <string>
#include <vector>
namespace tt::settings {
static const auto LOGGER = Logger("BootSettings");
constexpr auto* PROPERTIES_FILE_FORMAT = "{}/settings/boot.properties";
constexpr auto* PROPERTIES_KEY_LAUNCHER_APP_ID = "launcherAppId";
constexpr auto* PROPERTIES_KEY_AUTO_START_APP_ID = "autoStartAppId";
static std::string getPropertiesFilePath() {
const auto sdcards = hal::findDevices<hal::sdcard::SdCardDevice>(hal::Device::Type::SdCard);
for (auto& sdcard : sdcards) {
std::string path = std::format(PROPERTIES_FILE_FORMAT, sdcard->getMountPath());
if (file::isFile(path)) {
return path;
}
}
return std::format(PROPERTIES_FILE_FORMAT, file::MOUNT_POINT_DATA);
}
bool loadBootSettings(BootSettings& properties) {
const std::string path = getPropertiesFilePath();
if (!file::loadPropertiesFile(path, [&properties](auto& key, auto& value) {
if (key == PROPERTIES_KEY_AUTO_START_APP_ID) {
properties.autoStartAppId = value;
} else if (key == PROPERTIES_KEY_LAUNCHER_APP_ID) {
properties.launcherAppId = value;
}
})) {
LOGGER.error("Failed to load {}", path);
return false;
}
return !properties.launcherAppId.empty();
}
}