aboutsummaryrefslogtreecommitdiffstats
path: root/src/displayapp/screens/settings
diff options
context:
space:
mode:
authorDāvis Mošenkovs <davikovs@gmail.com>2025-09-03 21:50:13 +0300
committerGitHub <noreply@github.com>2025-09-03 20:50:13 +0200
commite03414ce6d96c3acdc6bb56be59c50fb6a1721fc (patch)
treefb36f10fc657c821d1bdb4fd4476a1f41f71d179 /src/displayapp/screens/settings
parent9afc23cba9bcf938d8c49d6e15e7662ee8e6385d (diff)
Setting to disable DFU and FS access (#1891)
* Expose SystemTask dependency controllers Expose NotificationManager and Settings for use by the feature in next commit. This is a memory efficient way for accessing SystemTask dependencies from controllers that have SystemTask injected as a dependency. Looks like each direct dependency injection uses 4 bytes RAM. As InfiniTime is close to running out of RAM (using 16 more bytes causes build to fail with "ld: region RAM overflowed with stack") it might be helpful to use this approach more. * Add setting to disable DFU and FS access
Diffstat (limited to 'src/displayapp/screens/settings')
-rw-r--r--src/displayapp/screens/settings/SettingOTA.cpp58
-rw-r--r--src/displayapp/screens/settings/SettingOTA.h28
-rw-r--r--src/displayapp/screens/settings/Settings.h3
3 files changed, 88 insertions, 1 deletions
diff --git a/src/displayapp/screens/settings/SettingOTA.cpp b/src/displayapp/screens/settings/SettingOTA.cpp
new file mode 100644
index 00000000..ad123dec
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingOTA.cpp
@@ -0,0 +1,58 @@
+#include "displayapp/screens/settings/SettingOTA.h"
+#include <lvgl/lvgl.h>
+#include "displayapp/DisplayApp.h"
+#include "displayapp/Messages.h"
+#include "displayapp/screens/Styles.h"
+#include "displayapp/screens/Screen.h"
+#include "displayapp/screens/Symbols.h"
+
+using namespace Pinetime::Applications::Screens;
+
+namespace {
+ struct Option {
+ const char* name;
+ Pinetime::Controllers::Settings::DfuAndFsMode mode;
+ };
+
+ constexpr std::array<Option, 3> options = {{
+ {"Enabled", Pinetime::Controllers::Settings::DfuAndFsMode::Enabled},
+ {"Disabled", Pinetime::Controllers::Settings::DfuAndFsMode::Disabled},
+ {"Till reboot", Pinetime::Controllers::Settings::DfuAndFsMode::EnabledTillReboot},
+ }};
+
+ std::array<CheckboxList::Item, CheckboxList::MaxItems> CreateOptionArray() {
+ std::array<Pinetime::Applications::Screens::CheckboxList::Item, CheckboxList::MaxItems> optionArray;
+ for (size_t i = 0; i < CheckboxList::MaxItems; i++) {
+ if (i >= options.size()) {
+ optionArray[i].name = "";
+ optionArray[i].enabled = false;
+ } else {
+ optionArray[i].name = options[i].name;
+ optionArray[i].enabled = true;
+ }
+ }
+ return optionArray;
+ };
+}
+
+SettingOTA::SettingOTA(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
+ : app {app},
+ settingsController {settingsController},
+ checkboxList(
+ 0,
+ 1,
+ "Firmware & files",
+ Symbols::shieldAlt,
+ settingsController.GetDfuAndFsMode() == Pinetime::Controllers::Settings::DfuAndFsMode::Enabled ? 0
+ : settingsController.GetDfuAndFsMode() == Pinetime::Controllers::Settings::DfuAndFsMode::EnabledTillReboot ? 2
+ : 1,
+ [&settings = settingsController](uint32_t index) {
+ settings.SetDfuAndFsMode(options[index].mode);
+ },
+ CreateOptionArray()) {
+}
+
+SettingOTA::~SettingOTA() {
+ lv_obj_clean(lv_scr_act());
+ settingsController.SaveSettings();
+}
diff --git a/src/displayapp/screens/settings/SettingOTA.h b/src/displayapp/screens/settings/SettingOTA.h
new file mode 100644
index 00000000..13c9a33d
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingOTA.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include <array>
+#include <cstdint>
+#include <lvgl/lvgl.h>
+
+#include "components/settings/Settings.h"
+#include "displayapp/screens/Screen.h"
+#include "displayapp/screens/CheckboxList.h"
+
+namespace Pinetime {
+
+ namespace Applications {
+ namespace Screens {
+
+ class SettingOTA : public Screen {
+ public:
+ SettingOTA(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
+ ~SettingOTA() override;
+
+ private:
+ DisplayApp* app;
+ Pinetime::Controllers::Settings& settingsController;
+ CheckboxList checkboxList;
+ };
+ }
+ }
+}
diff --git a/src/displayapp/screens/settings/Settings.h b/src/displayapp/screens/settings/Settings.h
index 3722c2be..370e83f4 100644
--- a/src/displayapp/screens/settings/Settings.h
+++ b/src/displayapp/screens/settings/Settings.h
@@ -45,8 +45,9 @@ namespace Pinetime {
{Symbols::clock, "Chimes", Apps::SettingChimes},
{Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold},
{Symbols::check, "Firmware", Apps::FirmwareValidation},
- {Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth},
+ {Symbols::shieldAlt, "Over-the-air", Apps::SettingOTA},
+ {Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth},
{Symbols::list, "About", Apps::SysInfo},
// {Symbols::none, "None", Apps::None},