Merge develop into main (#312)
- Move various settings to `/data/settings` and `/sdcard/settings` - Fix for `Gui` and `Statusbar` errors on startup (LVGL start) - Implement Development service settings as properties file - Rename `service::findManifestId()` to `service::findManifestById()` - Renamed various classes like `BootProperties` to `BootSettings` - Renamed `settings.properties` to `system.properties`. Code was moved to `settings` namespace/folder - `DevelopmentSettings` is now in `settings` namespace/folder (moved from service)
This commit is contained in:
committed by
GitHub
parent
5dfc6d70da
commit
5cc5b50694
@@ -0,0 +1,46 @@
|
||||
#include <Tactility/MountPoints.h>
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/file/PropertiesFile.h>
|
||||
#include <Tactility/hal/sdcard/SdCardDevice.h>
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/settings/BootSettings.h>
|
||||
|
||||
#include <format>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace tt::settings {
|
||||
|
||||
constexpr auto* TAG = "BootProperties";
|
||||
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;
|
||||
}
|
||||
})) {
|
||||
TT_LOG_E(TAG, "Failed to load %s", path.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
return !properties.launcherAppId.empty();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user