Various improvements (#547)

- Fixed crash when returning to Setup app (from any of the steps)
- Fixed crash when returning to TimeDateSettings app (after locale selection)
- Fixed GuiService inconsistent behaviour: now always perform operations async (e.g. to show/hide apps). This fixes crashes in some onHide() calls where onHide() might be called before onShow() was called.
- Fix for incorrect WebServService path
- Remove CYD-4848S040C SD card functionality, but added a GPIO fix for releasing 3-wire SPI pin sharing.
- Fix for saving/loading settings for various apps
This commit is contained in:
Ken Van Hoeylandt
2026-07-04 21:26:43 +02:00
committed by GitHub
parent a323f8e148
commit ecad2248d9
33 changed files with 278 additions and 146 deletions
+18 -3
View File
@@ -8,6 +8,7 @@
#include <Tactility/app/chat/ChatProtocol.h>
#include <Tactility/crypt/Crypt.h>
#include <Tactility/file/File.h>
#include <Tactility/file/PropertiesFile.h>
#include <Tactility/Logger.h>
#include <Tactility/Paths.h>
@@ -34,6 +35,8 @@ constexpr auto* KEY_NICKNAME = "nickname";
constexpr auto* KEY_ENCRYPTION_KEY = "encryptionKey";
constexpr auto* KEY_CHAT_CHANNEL = "chatChannel";
uint32_t defaultSenderId = 0;
// IV_SEED provides basic obfuscation for stored encryption keys, not strong encryption.
// The device master key (from crypt::getIv) provides the actual security.
static constexpr auto* IV_SEED = "chat_key";
@@ -112,8 +115,9 @@ static uint32_t generateSenderId() {
}
ChatSettingsData getDefaultSettings() {
if (defaultSenderId == 0) defaultSenderId = generateSenderId();
return ChatSettingsData{
.senderId = 0,
.senderId = defaultSenderId,
.nickname = "Device",
.encryptionKey = {},
.hasEncryptionKey = false,
@@ -124,8 +128,14 @@ ChatSettingsData getDefaultSettings() {
ChatSettingsData loadSettings() {
ChatSettingsData settings = getDefaultSettings();
auto settings_path = getSettingsFilePath();
if (!file::isFile(settings_path)) {
settings.senderId = generateSenderId();
return settings;
}
std::map<std::string, std::string> map;
if (!file::loadPropertiesFile(getSettingsFilePath(), map)) {
if (!file::loadPropertiesFile(settings_path, map)) {
settings.senderId = generateSenderId();
return settings;
}
@@ -176,7 +186,12 @@ bool saveSettings(const ChatSettingsData& settings) {
map[KEY_ENCRYPTION_KEY] = "";
}
return file::savePropertiesFile(getSettingsFilePath(), map);
auto settings_path = getSettingsFilePath();
if (!file::findOrCreateParentDirectory(settings_path, 0755)) {
LOGGER.error("Failed to create parent dir for {}", settings_path);
return false;
}
return file::savePropertiesFile(settings_path, map);
}
bool settingsFileExists() {
+12 -1
View File
@@ -53,6 +53,7 @@ class SetupApp final : public App {
Phase phase = Phase::Welcome;
size_t stepIndex = 0;
std::vector<StepConfiguration> steps;
bool isShown = false;
lv_obj_t* titleLabel = nullptr;
lv_obj_t* descriptionLabel = nullptr;
@@ -105,7 +106,12 @@ class SetupApp final : public App {
phase = Phase::Done;
}
renderCurrent();
// Widgets may not exist yet: onShow() runs asynchronously on the GUI task and
// may not have (re)created them by the time onResult() advances the state.
// onShow() calls renderCurrent() itself once the widgets are ready.
if (isShown) {
renderCurrent();
}
}
void onSkipClicked() {
@@ -180,9 +186,14 @@ public:
lv_obj_align(continueButton, LV_ALIGN_BOTTOM_RIGHT, -12, -12);
lv_obj_add_event_cb(continueButton, onContinueClickedCallback, LV_EVENT_SHORT_CLICKED, this);
isShown = true;
renderCurrent();
}
void onHide(AppContext& app) override {
isShown = false;
}
void onResult(AppContext& app, LaunchId launchId, Result result, std::unique_ptr<Bundle> bundle) override {
lvgl_lock();
advanceTo(stepIndex + 1);
@@ -1,12 +1,15 @@
#include "tactility/lvgl_module.h"
#include <Tactility/Logger.h>
#include <Tactility/RecursiveMutex.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/app/timezone/TimeZone.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/RecursiveMutex.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/settings/Time.h>
#include <Tactility/settings/SystemSettings.h>
#include <Tactility/settings/Time.h>
#include <lvgl.h>
@@ -23,6 +26,7 @@ class TimeDateSettingsApp final : public App {
RecursiveMutex mutex;
lv_obj_t* timeZoneLabel = nullptr;
lv_obj_t* dateFormatDropdown = nullptr;
bool isShown = false;
static void onTimeFormatChanged(lv_event_t* event) {
auto* widget = lv_event_get_target_obj(event);
@@ -133,6 +137,12 @@ public:
}
lv_obj_center(timeZoneLabel);
lv_label_set_text(timeZoneLabel, timeZoneName.c_str());
isShown = true;
}
void onHide(AppContext& app) override {
isShown = false;
}
void onResult(AppContext& app, LaunchId launchId, Result result, std::unique_ptr<Bundle> bundle) override {
@@ -141,11 +151,13 @@ public:
const auto code = timezone::getResultCode(*bundle);
LOGGER.info("Result name={} code={}", name, code);
if (!name.empty()) {
if (lvgl::lock(100 / portTICK_PERIOD_MS)) {
// onShow() may not have (re)created the widgets yet: onResult() runs synchronously
// on the loader thread and can race ahead of the async gui-task redraw.
if (!name.empty() && lvgl_try_lock(100 / portTICK_PERIOD_MS)) {
if (isShown) {
lv_label_set_text(timeZoneLabel, name.c_str());
lvgl::unlock();
}
lvgl_unlock();
}
}
}