Fixes and improvements (#617)
This commit is contained in:
committed by
GitHub
parent
b03759a111
commit
0ff1627385
@@ -15,7 +15,7 @@ FileSystem* findSdcardFileSystem(bool mustBeMounted);
|
||||
|
||||
std::string getUserDataRootPath();
|
||||
|
||||
std::string getUserDataPath();
|
||||
std::string getDataPath();
|
||||
|
||||
std::string getTempPath();
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ std::string getUserDataRootPath() {
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string getUserDataPath() {
|
||||
std::string getDataPath() {
|
||||
#ifdef ESP_PLATFORM
|
||||
return getUserDataRootPath() + "/tactility";
|
||||
#else
|
||||
@@ -60,15 +60,15 @@ std::string getUserDataPath() {
|
||||
}
|
||||
|
||||
std::string getTempPath() {
|
||||
return getUserDataPath() + "/tmp";
|
||||
return getDataPath() + "/tmp";
|
||||
}
|
||||
|
||||
std::string getAppInstallPath() {
|
||||
return getUserDataPath() + "/app";
|
||||
return getDataPath() + "/app";
|
||||
}
|
||||
|
||||
std::string getUserHomePath() {
|
||||
return getUserDataPath() + "/user";
|
||||
return getDataPath() + "/user";
|
||||
}
|
||||
|
||||
std::string getAppInstallPath(const std::string& appId) {
|
||||
|
||||
@@ -318,7 +318,7 @@ static void registerAndStartServices() {
|
||||
}
|
||||
|
||||
void createTempDirectory() {
|
||||
auto data_path = getUserDataPath();
|
||||
auto data_path = getDataPath();
|
||||
auto temp_path = std::format("{}/tmp", data_path);
|
||||
if (!file::isDirectory(temp_path)) {
|
||||
FileMutex mutex;
|
||||
|
||||
@@ -152,27 +152,19 @@ void updateApp(Context* ctx) {
|
||||
void updateViews(Context* ctx) {
|
||||
lvgl_toolbar_clear_actions(ctx->toolbar);
|
||||
auto app_id = ctx->entry.appId.c_str();
|
||||
AppManifest manifest;
|
||||
bool is_installed = app_manager_find_manifest(app_id, &manifest) == ERROR_NONE;
|
||||
ctx->spinner = lvgl_toolbar_add_spinner_action(ctx->toolbar);
|
||||
lv_obj_add_flag(ctx->spinner, LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_add_flag(ctx->updateLabel, LV_OBJ_FLAG_HIDDEN);
|
||||
|
||||
char install_path[128];
|
||||
if (app_get_install_path(app_id, install_path, sizeof(install_path)) != ERROR_NONE) {
|
||||
LOG_E(TAG, "Install path not found for %s", app_id);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string metadata_path = std::string(install_path) + "/manifest.properties";
|
||||
AppMetadata metadata;
|
||||
if (app_metadata_parse(metadata_path.c_str(), &metadata) != ERROR_NONE) {
|
||||
LOG_E(TAG, "Failed to parse metadata at %s", metadata_path.c_str());
|
||||
return;
|
||||
}
|
||||
bool is_installed = app_get_install_path(app_id, install_path, sizeof(install_path)) == ERROR_NONE
|
||||
&& file::isFile(std::string(install_path) + "/manifest.properties");
|
||||
|
||||
if (is_installed) {
|
||||
if (metadata.app_version_code < ctx->entry.appVersionCode) {
|
||||
std::string metadata_path = std::string(install_path) + "/manifest.properties";
|
||||
AppMetadata metadata;
|
||||
if (app_metadata_parse(metadata_path.c_str(), &metadata) == ERROR_NONE
|
||||
&& metadata.app_version_code < ctx->entry.appVersionCode) {
|
||||
ctx->updateButton = lvgl_toolbar_add_image_button_action(ctx->toolbar, LV_SYMBOL_DOWNLOAD, onUpdatePressed, ctx);
|
||||
lv_obj_remove_flag(ctx->updateLabel, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
#include <Tactility/app/i2cscanner/I2cHelpers.h>
|
||||
#include <Tactility/app/i2cscanner/I2cScannerPrivate.h>
|
||||
|
||||
#include <Tactility/LogMessages.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/Timer.h>
|
||||
#include <Tactility/app/i2cscanner/I2cHelpers.h>
|
||||
#include <Tactility/app/i2cscanner/I2cScannerPrivate.h>
|
||||
|
||||
#include <app/event.h>
|
||||
#include <app/manager.h>
|
||||
#include <app/manifest.h>
|
||||
#include <app/paths.h>
|
||||
|
||||
#include <lvgl_window_manager/window_manager.h>
|
||||
|
||||
#include <tactility/drivers/i2c_controller.h>
|
||||
#include <tactility/log.h>
|
||||
#include <tactility/paths.h>
|
||||
#include <tactility/preferences.h>
|
||||
|
||||
#include <cassert>
|
||||
@@ -55,7 +56,7 @@ struct Context {
|
||||
|
||||
bool getPreferencesPath(std::string& outPath) {
|
||||
char root[128];
|
||||
if (paths_get_user_data_path(root, sizeof(root)) != ERROR_NONE) {
|
||||
if (app_paths_get_user_data_directory(manifest.id, root, sizeof(root)) != ERROR_NONE) {
|
||||
return false;
|
||||
}
|
||||
outPath = std::string(root) + "/i2c_scanner.properties";
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include <Tactility/app/setup/Setup.h>
|
||||
|
||||
#include <tactility/paths.h>
|
||||
|
||||
#include <Tactility/StringUtils.h>
|
||||
#include <Tactility/app/timezone/TimeZone.h>
|
||||
#include <Tactility/app/wifimanage/WifiManage.h>
|
||||
@@ -13,7 +15,6 @@
|
||||
#include <lvgl_window_manager/window_manager.h>
|
||||
|
||||
#include <tactility/log.h>
|
||||
#include <tactility/paths.h>
|
||||
|
||||
#include <lvgl/fonts.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
@@ -39,11 +40,11 @@ constexpr auto* TAG = "setup";
|
||||
namespace {
|
||||
|
||||
bool getCompletedMarkerPath(std::string& outPath) {
|
||||
char root[128];
|
||||
if (paths_get_user_data_path(root, sizeof(root)) != ERROR_NONE) {
|
||||
char path[128];
|
||||
if (paths_get_data_path(path, sizeof(path)) != ERROR_NONE) {
|
||||
return false;
|
||||
}
|
||||
outPath = std::string(root) + "/.setup_complete";
|
||||
outPath = std::string(path) + "/.setup_complete";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ constexpr auto* KEY_AUTO_CONNECT = "autoConnect";
|
||||
constexpr auto* KEY_PROFILE_ID = "profileId";
|
||||
|
||||
static std::string getSettingsFilePath() {
|
||||
return getUserDataPath() + "/service/bluetooth";
|
||||
return getDataPath() + "/service/bluetooth";
|
||||
}
|
||||
|
||||
std::string addrToHex(const std::array<uint8_t, 6>& addr) {
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace tt::bluetooth::settings {
|
||||
constexpr auto* TAG = "BluetoothSettings";
|
||||
|
||||
static std::string getSettingsPath() {
|
||||
return getUserDataPath() + "/settings/bluetooth.settings";
|
||||
return getDataPath() + "/settings/bluetooth.properties";
|
||||
}
|
||||
|
||||
constexpr auto* KEY_ENABLE_ON_BOOT = "enableOnBoot";
|
||||
|
||||
@@ -3,12 +3,11 @@
|
||||
#include <tactility/log.h>
|
||||
#include <tactility/paths.h>
|
||||
#include <tactility/preferences.h>
|
||||
#include <tactility/system_event.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include <Tactility/TactilityCore.h>
|
||||
#include <tactility/system_event.h>
|
||||
#include <esp_netif_sntp.h>
|
||||
#include <esp_sntp.h>
|
||||
#endif
|
||||
@@ -23,10 +22,10 @@ static bool processedSyncEvent = false;
|
||||
|
||||
static bool getPreferencesPath(std::string& outPath) {
|
||||
char root[128];
|
||||
if (paths_get_user_data_path(root, sizeof(root)) != ERROR_NONE) {
|
||||
if (paths_get_data_path(root, sizeof(root)) != ERROR_NONE) {
|
||||
return false;
|
||||
}
|
||||
outPath = std::string(root) + "/time.properties";
|
||||
outPath = std::string(root) + "/settings/ntp.properties";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1450,7 +1450,7 @@ esp_err_t WebServerService::handleApiScreenshot(httpd_req_t* request) {
|
||||
|
||||
#if TT_FEATURE_SCREENSHOT_ENABLED
|
||||
// Determine save location: prefer SD card root if mounted, otherwise /data
|
||||
std::string save_path = getUserDataPath();
|
||||
std::string save_path = getDataPath();
|
||||
|
||||
// Find next available filename with incrementing number
|
||||
std::string screenshot_path;
|
||||
|
||||
@@ -126,7 +126,7 @@ void bootSplashInit() {
|
||||
getMainDispatcher().dispatch([] {
|
||||
LOG_I(TAG, "bootSplashInit dispatch begin");
|
||||
// Import any provisioning files placed on the system data partition.
|
||||
const std::string provisioning_path = file::getChildPath(getUserDataPath(), "provisioning");
|
||||
const std::string provisioning_path = file::getChildPath(getDataPath(), "provisioning");
|
||||
if (file::isDirectory(provisioning_path)) {
|
||||
importWifiApSettingsFromDir(provisioning_path);
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include <Tactility/settings/AudioSettings.h>
|
||||
|
||||
#include "tactility/paths.h"
|
||||
|
||||
#include <Tactility/DeprecatedPaths.h>
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/file/PropertiesFile.h>
|
||||
@@ -12,8 +14,14 @@
|
||||
|
||||
namespace tt::settings::audio {
|
||||
|
||||
static std::string getSettingsFilePath() {
|
||||
return getUserDataPath() + "/settings/audio.properties";
|
||||
static bool getSettingsFilePath(std::string& outPath) {
|
||||
char root[128];
|
||||
// Not really a service, but this is the best way of organising it for now
|
||||
if (paths_get_data_path(root, sizeof(root)) != ERROR_NONE) {
|
||||
return false;
|
||||
}
|
||||
outPath = std::string(root) + "/settings/audio.properties";
|
||||
return true;
|
||||
}
|
||||
|
||||
constexpr auto* SETTINGS_KEY_INPUT_ENABLED = "inputEnabled";
|
||||
@@ -56,7 +64,11 @@ static std::string toString(float value) {
|
||||
}
|
||||
|
||||
bool load(AudioSettings& settings) {
|
||||
auto settings_path = getSettingsFilePath();
|
||||
std::string settings_path;
|
||||
if (!getSettingsFilePath(settings_path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!file::isFile(settings_path)) {
|
||||
return false;
|
||||
}
|
||||
@@ -103,10 +115,16 @@ bool save(const AudioSettings& settings) {
|
||||
map[SETTINGS_KEY_OUTPUT_MUTED] = toString(settings.outputMuted);
|
||||
map[SETTINGS_KEY_INPUT_VOLUME] = toString(settings.inputVolume);
|
||||
map[SETTINGS_KEY_OUTPUT_VOLUME] = toString(settings.outputVolume);
|
||||
auto settings_path = getSettingsFilePath();
|
||||
|
||||
std::string settings_path;
|
||||
if (getSettingsFilePath(settings_path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!file::findOrCreateParentDirectory(settings_path, 0755)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return file::savePropertiesFile(settings_path, map);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ constexpr auto* PROPERTIES_KEY_LAUNCHER_APP_ID = "launcherAppId";
|
||||
constexpr auto* PROPERTIES_KEY_AUTO_START_APP_ID = "autoStartAppId";
|
||||
|
||||
static std::string getPropertiesFilePath() {
|
||||
return std::format(PROPERTIES_FILE_FORMAT, getUserDataPath());
|
||||
return std::format(PROPERTIES_FILE_FORMAT, getDataPath());
|
||||
}
|
||||
|
||||
bool loadBootSettings(BootSettings& properties) {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
namespace tt::settings::keyboard {
|
||||
|
||||
static std::string getSettingsFilePath() {
|
||||
return getUserDataPath() + "/settings/keyboard.properties";
|
||||
return getDataPath() + "/settings/keyboard.properties";
|
||||
}
|
||||
|
||||
constexpr auto* KEY_BACKLIGHT_ENABLED = "backlightEnabled";
|
||||
|
||||
@@ -21,12 +21,12 @@ static bool cached = false;
|
||||
static SystemSettings cachedSettings;
|
||||
|
||||
static bool hasSystemSettingsFile() {
|
||||
auto file_path = std::format(FILE_PATH_FORMAT, getUserDataPath());
|
||||
auto file_path = std::format(FILE_PATH_FORMAT, getDataPath());
|
||||
return file::isFile(file_path);
|
||||
}
|
||||
|
||||
static bool loadSystemSettingsFromFile(SystemSettings& properties) {
|
||||
auto file_path = std::format(FILE_PATH_FORMAT, getUserDataPath());
|
||||
auto file_path = std::format(FILE_PATH_FORMAT, getDataPath());
|
||||
LOG_I(TAG, "System settings loading from %s", file_path.c_str());
|
||||
std::map<std::string, std::string> map;
|
||||
if (!file::loadPropertiesFile(file_path, map)) {
|
||||
@@ -75,7 +75,7 @@ bool loadSystemSettings(SystemSettings& properties) {
|
||||
}
|
||||
|
||||
bool saveSystemSettings(const SystemSettings& properties) {
|
||||
auto file_path = std::format(FILE_PATH_FORMAT, getUserDataPath());
|
||||
auto file_path = std::format(FILE_PATH_FORMAT, getDataPath());
|
||||
std::map<std::string, std::string> map;
|
||||
map["language"] = toString(properties.language);
|
||||
map["timeFormat24h"] = properties.timeFormat24h ? "true" : "false";
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
namespace tt::settings::touch {
|
||||
|
||||
static std::string getSettingsFilePath() {
|
||||
return getUserDataPath() + "/settings/touch-calibration.properties";
|
||||
return getDataPath() + "/settings/touch-calibration.properties";
|
||||
}
|
||||
|
||||
constexpr auto* SETTINGS_KEY_ENABLED = "enabled";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <Tactility/settings/Time.h>
|
||||
#include <service/paths.h>
|
||||
|
||||
#include <Tactility/settings/Time.h>
|
||||
#include <Tactility/settings/SystemSettings.h>
|
||||
|
||||
#include <tactility/paths.h>
|
||||
@@ -12,8 +13,6 @@
|
||||
|
||||
namespace tt::settings {
|
||||
|
||||
constexpr auto* TIME_SETTINGS_NAMESPACE = "time";
|
||||
|
||||
constexpr auto* TIMEZONE_PREFERENCES_KEY_NAME = "tz_name";
|
||||
constexpr auto* TIMEZONE_PREFERENCES_KEY_CODE = "tz_code";
|
||||
constexpr auto* TIMEZONE_PREFERENCES_KEY_TIME24 = "tz_time24";
|
||||
@@ -24,10 +23,11 @@ namespace {
|
||||
// "syncTime" - matches the shared NVS namespace this used to be.
|
||||
bool getPreferencesPath(std::string& outPath) {
|
||||
char root[128];
|
||||
if (paths_get_user_data_path(root, sizeof(root)) != ERROR_NONE) {
|
||||
// Not really a service, but this is the best way of organising it for now
|
||||
if (paths_get_data_path(root, sizeof(root)) != ERROR_NONE) {
|
||||
return false;
|
||||
}
|
||||
outPath = std::string(root) + "/" + TIME_SETTINGS_NAMESPACE + ".properties";
|
||||
outPath = std::string(root) + "/settings/time.properties";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user