Application Manager
Relevant source files
The following files were used as context for generating this wiki page:
The Application Manager (AppManager) is a core component of FlxOS responsible for the lifecycle management of user-facing applications. It provides a structured framework for starting, stopping, pausing, and resuming applications while managing their integration with the underlying Window Manager and UI systems. The AppManager ensures that applications adhere to a consistent interface, enabling features such as multi-window support and dynamic layouts.
Sources: ROADMAP.md:31, main/core/apps/AppManager.hpp
Architecture and Lifecycle Management
The Application Manager operates on a modular architecture where every application inherits from a base App class. This inheritance ensures that all apps implement standard lifecycle hooks required for system-level coordination. The AppManager maintains the state of these applications and coordinates transitions between active, paused, and stopped states.
Lifecycle States
Applications transition through several states managed by the AppManager:
- Start: Initial loading and resource allocation.
- Resume: Bringing the application to the foreground and refreshing data.
- Pause: Suspending active UI updates or background processing when the app is minimized or loses focus.
- Stop: Cleaning up resources and destroying UI components.
Sources: ROADMAP.md:31, main/core/apps/system_info/SystemInfoApp.cpp:25-46, main/core/apps/files/FilesApp.cpp:66-74
Component Relationship
The following diagram illustrates the relationship between the AppManager, the base App class, and specific application implementations like FilesApp and SystemInfoApp.
The diagram shows the central role of AppManager in orchestrating objects derived from the App base class.
Sources: main/core/apps/AppManager.hpp, main/core/apps/files/FilesApp.hpp:18-24, main/core/apps/system_info/SystemInfoApp.cpp:25-50
Application Integration
Applications in FlxOS are integrated into the build system and the UI environment through specific registration and package identification.
Build Configuration
Applications are conditionally included in the build process based on the system mode. In standard GUI mode, application sources are appended to the core source list, while they are excluded in HEADLESS_MODE.
| Application | Package Name | Source Files |
|---|---|---|
| Files | com.os.files | FilesApp.cpp, FilesApp.hpp |
| System Info | N/A | SystemInfoApp.cpp, SystemInfoApp.hpp |
| Settings (WiFi) | N/A | WiFiSettings.cpp |
| Settings (Hotspot) | N/A | HotspotSettings.cpp |
Sources: main/CMakeLists.txt:26-40, main/core/apps/files/FilesApp.cpp:33
UI Construction and Watchdog Feeding
The createUI method is a critical lifecycle hook where applications receive a parent container (typically an lv_obj_t* from LVGL) to build their interface. For long-running UI operations (like file copying in FilesApp), applications are responsible for feeding the system watchdog via the GuiTask to prevent system resets.
The sequence shows the interaction between the Manager, the Application, and the background Task responsible for system health.
Sources: main/core/apps/files/FilesApp.cpp:41-74, main/core/apps/files/FilesApp.cpp:76-88, main/core/apps/system_info/SystemInfoApp.cpp:61-75
Core Functions and API
The following table summarizes key virtual functions implemented by applications to interact with the Application Manager.
| Function | Description | Implementation Requirement |
|---|---|---|
getPackageName() | Returns a unique identifier for the app (e.g., com.os.files). | Required for identification. |
getAppName() | Returns the user-friendly name of the application. | Required for UI labels. |
getIcon() | Returns a pointer to the icon resource (e.g., LV_SYMBOL_DIRECTORY). | Required for launcher/dock. |
update() | Called periodically by the system for background logic or data refreshes. | Optional; used by SystemInfoApp for real-time stats. |
onStop() | Handles resource cleanup and nullifies UI pointers. | Required for memory safety. |
Sources: main/core/apps/files/FilesApp.hpp:20-29, main/core/apps/system_info/SystemInfoApp.cpp:52-60, main/core/apps/files/FilesApp.cpp:33-35
Conclusion
The Application Manager serves as the backbone for user interaction in FlxOS, providing a standardized environment for apps to operate. By decoupling the UI logic from the core system and providing clear lifecycle hooks, it allows for a scalable and robust desktop experience on ESP32 microcontrollers.
Sources: README.md:18, ROADMAP.md:31