app-module events & callstack config, crash diagnostics (#630)
- Apps can specify task stack depth and preferred memory placement in their manifests. - App identifiers are validated against length and character requirements. - Crash diagnostics now show the crash cause, reason, fault address, call stack, and program-counter details, with logs saved for review. - App closing is more consistent across built-in screens. There's now a dedicated function, and the old _emit() function is made private. - Crash diagnostics no longer display a QR code without a call stack. - Improved memory allocation for unrestricted requests.
This commit is contained in:
committed by
GitHub
parent
c656ee9ffd
commit
92ca046681
@@ -20,7 +20,9 @@ namespace tt::app::applist {
|
||||
|
||||
namespace {
|
||||
|
||||
uint32_t appListInstanceId = 0;
|
||||
struct Context {
|
||||
uint32_t appInstanceId;
|
||||
};
|
||||
|
||||
void onAppPressed(lv_event_t* e) {
|
||||
// Fire-and-forget top-level navigation, same as Launcher's own app-launch buttons.
|
||||
@@ -29,15 +31,9 @@ void onAppPressed(lv_event_t* e) {
|
||||
app_manager_start(manifest->id, &instanceId);
|
||||
}
|
||||
|
||||
void onBackPressed(lv_event_t*) {
|
||||
// The global toolbar nav callback (ToolbarConfig.nav_action_callback, set once in
|
||||
// Tactility.cpp) only knows how to stop old-model apps, so this new-model app overrides
|
||||
// its own toolbar's nav action to close itself instead. Async, non-blocking - must NOT
|
||||
// call app_manager_stop() directly here: that bound-waits (thread_join) for this app's
|
||||
// own thread to finish, which needs the LVGL lock (window_manager_remove()) - but this
|
||||
// callback runs ON the LVGL task, which would deadlock against itself.
|
||||
AppEvent event { .type = APP_EVENT_CLOSE, .timestamp = 0, .result = {} };
|
||||
app_event_emit(appListInstanceId, &event);
|
||||
void onBackPressed(lv_event_t* event) {
|
||||
auto* ctx = static_cast<Context*>(lv_event_get_user_data(event));
|
||||
app_event_emit_close(ctx->appInstanceId);
|
||||
}
|
||||
|
||||
void createAppWidget(const ::AppManifest* manifest, lv_obj_t* list) {
|
||||
@@ -54,9 +50,11 @@ void collectManifest(const ::AppManifest* manifest, void* context) {
|
||||
manifests->push_back(manifest);
|
||||
}
|
||||
|
||||
void createWidgets(lv_obj_t* parent, void*) {
|
||||
void createWidgets(lv_obj_t* parent, void* userData) {
|
||||
auto* ctx = static_cast<Context*>(userData);
|
||||
|
||||
auto* toolbar = lvgl_toolbar_create(parent, "Apps");
|
||||
lvgl_toolbar_set_nav_action(toolbar, LV_SYMBOL_CLOSE, onBackPressed, nullptr);
|
||||
lvgl_toolbar_set_nav_action(toolbar, LV_SYMBOL_CLOSE, onBackPressed, ctx);
|
||||
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
|
||||
|
||||
lv_obj_t* list = lv_list_create(parent);
|
||||
@@ -83,7 +81,7 @@ void createWidgets(lv_obj_t* parent, void*) {
|
||||
|
||||
int32_t appMain(int argc, char* argv[]) {
|
||||
uint32_t appInstanceId = app_scheduler_current_app_id();
|
||||
appListInstanceId = appInstanceId;
|
||||
Context ctx { appInstanceId };
|
||||
|
||||
TaskEventGroup event_group {};
|
||||
task_event_group_construct(&event_group);
|
||||
@@ -91,7 +89,7 @@ int32_t appMain(int argc, char* argv[]) {
|
||||
AppEventSubscription sub {};
|
||||
check(app_event_subscribe(&sub, &event_group) == ERROR_NONE);
|
||||
|
||||
WindowId window = window_manager_create(appInstanceId, createWidgets, nullptr);
|
||||
WindowId window = window_manager_create(appInstanceId, createWidgets, &ctx);
|
||||
|
||||
while (true) {
|
||||
task_event_group_wait_any(&event_group, nullptr, portMAX_DELAY);
|
||||
@@ -119,8 +117,9 @@ extern const ::AppManifest manifest = {
|
||||
.id = "tactility.applist",
|
||||
.name = "Apps",
|
||||
.category = APP_CATEGORY_SYSTEM,
|
||||
.location = { APP_LOCATION_MEMORY, reinterpret_cast<void*>(appMain) },
|
||||
.location = { .type = APP_LOCATION_MEMORY, .location = reinterpret_cast<void*>(appMain) },
|
||||
.flags = APP_MANIFEST_FLAG_HIDDEN,
|
||||
.stack = { .depth = 2400, .desired_memory_capability = 0 },
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user