Skip to content

Config menu can be hidden permanently via Hide/Show Apps #2809

Description

@rEvsikov

Description

On the LilyGo T-Embed CC1101, it is possible to hide the Config menu item via:

Config → System Config → Hide/Show Apps

After disabling Config, the Config item disappears from the main menu. Since Hide/Show Apps itself is accessible only through Config, there is no way to enable it again from the UI.

The only way to restore access to Config is to reset/reflash the device configuration.

Steps to reproduce

Open Config.
Go to System Config → Hide/Show Apps.
Disable Config.
Return to the main menu.
The Config menu item is no longer available.
There is no way to access the settings and enable it again.
Expected behavior

The Config menu item should always remain accessible and should not be possible to disable through Hide/Show Apps.

Relevant code

The Hide/Show Apps list is generated in MainMenu::hideAppsMenu():

_currentIndex = loopOptions(options, MENU_TYPE_MAIN, "Main Menu", _currentIndex);
};
/*********************************************************************
** Function: hideAppsMenu
** Menu to Hide or show menus
**********************************************************************/
void MainMenu::hideAppsMenu() {
auto items = this->getItems();
int index = 0;
RESTART: // using gotos to avoid stackoverflow after many choices
options.clear();
for (auto item : items) {
String label = item->getName();

In this loop, all menu items are added to the list, including Config:

for (auto item : items) {
    String label = item->getName();

    std::vector<String> l = bruceConfig.disabledMenus;
    bool enabled = find(l.begin(), l.end(), label) == l.end();

    options.push_back(
        {label,
         [this, label, enabled]() {
             if (enabled) bruceConfig.addDisabledMenu(label);
             else bruceConfig.removeDisabledMenu(label);
         },
         enabled}
    );
}

Suggested fix

Exclude Config from the Hide/Show Apps list:

for (auto item : items) {
String label = item->getName();

// Config must always remain accessible
if (label == "Config") continue;

std::vector<String> l = bruceConfig.disabledMenus;
bool enabled = find(l.begin(), l.end(), label) == l.end();

options.push_back(
    {label,
     [this, label, enabled]() {
         if (enabled) bruceConfig.addDisabledMenu(label);
         else bruceConfig.removeDisabledMenu(label);
     },
     enabled}
);

}

Additionally, it may be worth ensuring that Config is always displayed even if "Config" is already present in disabledMenus from an existing configuration.

The relevant check when building the main menu is here:

returnToMenu = false;

Current code:

if (find(l.begin(), l.end(), itemName) == l.end()) {

Possible change:

if (itemName == "Config" || find(l.begin(), l.end(), itemName) == l.end()) {

This provides two safeguards:

  1. Config cannot be disabled through Hide/Show Apps.
  2. Config remains accessible for users who already have "Config" stored in disabledMenus.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions