From 8ba01029102b6bee945b463e6a0c7950269610cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Martin?= Date: Sun, 11 Oct 2026 17:49:09 +0200 Subject: [PATCH] Settings: Install updates, when asked or by itself Off by default: what runs on the device changes only when its owner said it may (issue #52). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0162FokPdvY2KsS4NBfwyWPk --- lib/apps_model/src/settings_menu.cpp | 3 +++ lib/apps_model/src/settings_menu.h | 2 +- lib/services/src/settings.cpp | 1 + lib/services/src/settings.h | 1 + test/test_settings_menu/test_settings_menu.cpp | 13 ++++++++++++- 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/apps_model/src/settings_menu.cpp b/lib/apps_model/src/settings_menu.cpp index 88623ca..8006cf8 100644 --- a/lib/apps_model/src/settings_menu.cpp +++ b/lib/apps_model/src/settings_menu.cpp @@ -48,6 +48,7 @@ const Member kRows[] = { {3, {Row::Wifi, Kind::Page, "Wi-Fi"}}, {3, {Row::Vpn, Kind::Page, "VPN"}}, {4, {Row::CheckUpdates, Kind::Toggle, "Check for updates"}}, + {4, {Row::InstallUpdates, Kind::Toggle, "Install updates"}}, {4, {Row::Firmware, Kind::Page, "Firmware"}}, {4, {Row::DebugConsole, Kind::Page, "Debug Console"}}, {4, {Row::About, Kind::Page, "About"}}, @@ -152,6 +153,7 @@ std::string SettingsMenu::value(int i) const { case Row::Gnss: return settings_.getBool(Setting::GnssEnabled) ? "On" : "Off"; case Row::GnssQuiet: return settings_.getBool(Setting::GnssQuietForLora) ? "On" : "Off"; case Row::CheckUpdates: return settings_.getBool(Setting::CheckUpdates) ? "Daily" : "Off"; + case Row::InstallUpdates: return settings_.getBool(Setting::InstallUpdates) ? "By itself" : "When asked"; case Row::Coordinates: return settings_.getBool(Setting::CoordinatesDms) ? "Deg min sec" : "Decimal"; case Row::ProbeMacs: return settings_.getBool(Setting::ProbeMacRaw) ? "Raw" : "Pseudonymised"; case Row::Wifi: return settings_.getBool(Setting::WifiEnabled) ? "On" : "Off"; @@ -210,6 +212,7 @@ void SettingsMenu::toggle(int i) { if (row(i) == Row::Gnss) settings_.setBool(Setting::GnssEnabled, !settings_.getBool(Setting::GnssEnabled)); if (row(i) == Row::GnssQuiet) settings_.setBool(Setting::GnssQuietForLora, !settings_.getBool(Setting::GnssQuietForLora)); if (row(i) == Row::CheckUpdates) settings_.setBool(Setting::CheckUpdates, !settings_.getBool(Setting::CheckUpdates)); + if (row(i) == Row::InstallUpdates) settings_.setBool(Setting::InstallUpdates, !settings_.getBool(Setting::InstallUpdates)); if (row(i) == Row::Coordinates) settings_.setBool(Setting::CoordinatesDms, !settings_.getBool(Setting::CoordinatesDms)); if (row(i) == Row::ProbeMacs) settings_.setBool(Setting::ProbeMacRaw, !settings_.getBool(Setting::ProbeMacRaw)); } diff --git a/lib/apps_model/src/settings_menu.h b/lib/apps_model/src/settings_menu.h index 9350d92..fc22f6d 100644 --- a/lib/apps_model/src/settings_menu.h +++ b/lib/apps_model/src/settings_menu.h @@ -12,7 +12,7 @@ namespace roro { // Rendering and navigation live in the App. Every index is into what is listed now. class SettingsMenu { public: - enum class Row { LongName, ShortName, Region, Timezone, Brightness, DimTimeout, OffTimeout, Launcher, Theme, ThemeLight, Sound, Gnss, GnssQuiet, Coordinates, ProbeMacs, Wifi, CheckUpdates, Firmware, Vpn, DebugConsole, About, + enum class Row { LongName, ShortName, Region, Timezone, Brightness, DimTimeout, OffTimeout, Launcher, Theme, ThemeLight, Sound, Gnss, GnssQuiet, Coordinates, ProbeMacs, Wifi, CheckUpdates, InstallUpdates, Firmware, Vpn, DebugConsole, About, GroupDevice, GroupDisplay, GroupPosition, GroupNetwork, GroupSystem }; enum class Kind { Text, Choice, Toggle, Slider, Page, Group }; diff --git a/lib/services/src/settings.cpp b/lib/services/src/settings.cpp index 648a62c..950df49 100644 --- a/lib/services/src/settings.cpp +++ b/lib/services/src/settings.cpp @@ -56,6 +56,7 @@ const Definition kDefinitions[] = { {"launcher_list", Kind::Bool, 0, nullptr, 0, 1}, // off: the grid {"theme", Kind::Int, 0, nullptr, 0, 6}, // roro9stack's own; ui::kThemeCount of them {"theme_light", Kind::Bool, 0, nullptr, 0, 1}, + {"auto_install", Kind::Bool, 0, nullptr, 0, 1}, // off: what runs here changes only when someone says so }; static_assert(sizeof(kDefinitions) / sizeof(kDefinitions[0]) == static_cast(Setting::Count), "every Setting needs a definition"); diff --git a/lib/services/src/settings.h b/lib/services/src/settings.h index 4638da7..e23cf4f 100644 --- a/lib/services/src/settings.h +++ b/lib/services/src/settings.h @@ -44,6 +44,7 @@ enum class Setting : uint8_t { LauncherList, // bool: the Launcher is a list of names instead of a grid of icons (issue #9) Theme, // int: the colour theme, an index into ui::palette (issue #10) ThemeLight, // bool: its light side instead of its dark one + InstallUpdates, // bool: a newer release found by the daily check is installed without being asked for (issue #52) Count }; diff --git a/test/test_settings_menu/test_settings_menu.cpp b/test/test_settings_menu/test_settings_menu.cpp index d8bb710..f38f559 100644 --- a/test/test_settings_menu/test_settings_menu.cpp +++ b/test/test_settings_menu/test_settings_menu.cpp @@ -67,7 +67,7 @@ void test_every_setting_is_in_one_group() { total += f.menu.count(); f.menu.close(); } - TEST_ASSERT_EQUAL(21, total); + TEST_ASSERT_EQUAL(22, total); int i = -1; TEST_ASSERT_TRUE(f.menu.reveal(SettingsMenu::Row::Vpn, i)); TEST_ASSERT_EQUAL_STRING("Network", f.menu.title().c_str()); @@ -204,6 +204,16 @@ void test_pause_gnss_for_lora_is_off_by_default() { // R1, Q165: the device looks for a newer release once a day. It installs nothing by itself, so it // is on unless switched off. +void test_installing_updates_by_itself_is_off_by_default() { + Fixture f; + int row = f.row(SettingsMenu::Row::InstallUpdates); + TEST_ASSERT_EQUAL_STRING("Install updates", f.menu.label(row).c_str()); + TEST_ASSERT_EQUAL_STRING("When asked", f.menu.value(row).c_str()); + f.menu.toggle(row); + TEST_ASSERT_TRUE(f.settings.getBool(Setting::InstallUpdates)); + TEST_ASSERT_EQUAL_STRING("By itself", f.menu.value(row).c_str()); +} + void test_check_for_updates_is_on_by_default() { Fixture f; int row = f.row(SettingsMenu::Row::CheckUpdates); @@ -245,6 +255,7 @@ int main() { RUN_TEST(test_names_are_text_rows_with_their_byte_limits); RUN_TEST(test_pause_gnss_for_lora_is_off_by_default); RUN_TEST(test_check_for_updates_is_on_by_default); + RUN_TEST(test_installing_updates_by_itself_is_off_by_default); RUN_TEST(test_gnss_and_coordinate_rows_toggle); RUN_TEST(test_the_debug_console_is_a_page_that_says_off); return UNITY_END();