From ab5036fcabf7d16c6db0d1f4399df38f5e35bb26 Mon Sep 17 00:00:00 2001 From: aviralgarg05 Date: Thu, 23 Jul 2026 20:51:45 +0530 Subject: [PATCH] system/nxstore: Honor installed launch metadata. Use nxstore-owned framebuffer and input configuration symbols instead of relying on an unrelated LVGL demo configuration. Load the manifest for the installed version before launching it, validate that it matches the installed database entry, and pass its recorded arguments to posix_spawn(). Check spawn-attribute setup errors as well. Add the shared supervisor-bar height header to the nxstore change itself so the branch builds independently and framebuffer applications can follow the required reserved-strip contract. Assisted-by: Codex:gpt-5 Signed-off-by: aviralgarg05 --- include/system/nxstore_chrome.h | 37 +++++++++++++++++++ system/nxstore/nxstore_main.c | 65 ++++++++++++++++++++++++++++----- 2 files changed, 93 insertions(+), 9 deletions(-) create mode 100644 include/system/nxstore_chrome.h diff --git a/include/system/nxstore_chrome.h b/include/system/nxstore_chrome.h new file mode 100644 index 000000000..0ebb1b0e4 --- /dev/null +++ b/include/system/nxstore_chrome.h @@ -0,0 +1,37 @@ +/**************************************************************************** + * apps/include/system/nxstore_chrome.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __APPS_INCLUDE_SYSTEM_NXSTORE_CHROME_H +#define __APPS_INCLUDE_SYSTEM_NXSTORE_CHROME_H + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Full-screen applications launched by nxstore share the framebuffer with + * its supervisor bar. They must leave this top strip untouched so the + * Close control remains visible and usable. + */ + +#define NXSTORE_BAR_HEIGHT 36 + +#endif /* __APPS_INCLUDE_SYSTEM_NXSTORE_CHROME_H */ diff --git a/system/nxstore/nxstore_main.c b/system/nxstore/nxstore_main.c index b5308e810..51a254722 100644 --- a/system/nxstore/nxstore_main.c +++ b/system/nxstore/nxstore_main.c @@ -662,9 +662,11 @@ static int nxstore_launch(FAR const struct pkg_manifest_s *manifest, { FAR struct pkg_installed_db_s *db; FAR struct pkg_installed_entry_s *entry; + FAR struct pkg_manifest_s *installed; posix_spawnattr_t attr; char path[PATH_MAX]; - FAR char *argv[2]; + FAR char *argv[PKG_LAUNCH_ARGS_MAX + 2]; + size_t i; pid_t pid; int ret; @@ -681,10 +683,18 @@ static int nxstore_launch(FAR const struct pkg_manifest_s *manifest, return -ENOMEM; } + installed = pkg_zalloc(sizeof(*installed)); + if (installed == NULL) + { + pkg_free(db); + return -ENOMEM; + } + ret = pkg_metadata_load_installed(db); if (ret < 0) { pkg_error("nxstore: failed to load installed db: %d", ret); + pkg_free(installed); pkg_free(db); return ret; } @@ -693,26 +703,63 @@ static int nxstore_launch(FAR const struct pkg_manifest_s *manifest, if (entry == NULL) { pkg_error("nxstore: %s not found in installed db", manifest->name); + pkg_free(installed); pkg_free(db); return -ENOENT; } - ret = pkg_store_format_payload_path(path, sizeof(path), manifest->name, - entry->current, manifest->artifact); + ret = pkg_store_format_manifest_path(path, sizeof(path), manifest->name, + entry->current); + if (ret >= 0) + { + ret = pkg_metadata_load_manifest_path(path, installed); + } + + if (ret >= 0 && + (strcmp(installed->name, manifest->name) != 0 || + strcmp(installed->version, entry->current) != 0)) + { + ret = -EINVAL; + } + + if (ret >= 0) + { + ret = pkg_store_format_payload_path(path, sizeof(path), + installed->name, + installed->version, + installed->artifact); + } + pkg_free(db); if (ret < 0) { + pkg_free(installed); return ret; } argv[0] = path; - argv[1] = NULL; + for (i = 0; i < installed->launch_argc; i++) + { + argv[i + 1] = installed->launch_args[i]; + } - posix_spawnattr_init(&attr); - posix_spawnattr_setstacksize(&attr, NXSTORE_LAUNCH_STACKSIZE); + argv[i + 1] = NULL; + + ret = posix_spawnattr_init(&attr); + if (ret != 0) + { + pkg_free(installed); + return -ret; + } + + ret = posix_spawnattr_setstacksize(&attr, NXSTORE_LAUNCH_STACKSIZE); + if (ret == 0) + { + ret = posix_spawn(&pid, path, NULL, &attr, argv, NULL); + } - ret = posix_spawn(&pid, path, NULL, &attr, argv, NULL); posix_spawnattr_destroy(&attr); + pkg_free(installed); if (ret != 0) { pkg_error("nxstore: posix_spawn(%s) failed: %d", path, ret); @@ -1923,8 +1970,8 @@ int main(int argc, FAR char *argv[]) lv_init(); lv_nuttx_dsc_init(&info); - info.fb_path = CONFIG_EXAMPLES_LVGLDEMO_FBDEVPATH; - info.input_path = CONFIG_EXAMPLES_LVGLDEMO_INPUT_DEVPATH; + info.fb_path = CONFIG_SYSTEM_NXSTORE_FBDEVPATH; + info.input_path = CONFIG_SYSTEM_NXSTORE_INPUT_DEVPATH; lv_nuttx_init(&info, &result); if (result.disp == NULL)