mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-04-18 17:35:05 +00:00
Simplify app and service paths
This commit is contained in:
parent
9e9e6c0f18
commit
1f53302a2a
@ -51,11 +51,6 @@ public:
|
||||
*/
|
||||
virtual std::string getDataDirectory() const = 0;
|
||||
|
||||
/**
|
||||
* @see getDataDirectory(), but with LVGL prefix.
|
||||
*/
|
||||
virtual std::string getDataDirectoryLvgl() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the full path for an entry inside the data location for an app.
|
||||
* The data directory is intended to survive OS upgrades.
|
||||
@ -64,11 +59,6 @@ public:
|
||||
*/
|
||||
virtual std::string getDataPath(const std::string& childPath) const = 0;
|
||||
|
||||
/**
|
||||
* @see getDataPath(), but with LVGL prefix.
|
||||
*/
|
||||
virtual std::string getDataPathLvgl(const std::string& childPath) const = 0;
|
||||
|
||||
/**
|
||||
* Returns the directory path for the system location for an app.
|
||||
* The system directory is not intended to survive OS upgrades.
|
||||
@ -78,11 +68,6 @@ public:
|
||||
*/
|
||||
virtual std::string getSystemDirectory() const = 0;
|
||||
|
||||
/**
|
||||
* @see getSystemDirectory(), but with LVGL prefix.
|
||||
*/
|
||||
virtual std::string getSystemDirectoryLvgl() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the full path for an entry inside the system location for an app.
|
||||
* The data directory is not intended to survive OS upgrades.
|
||||
@ -91,11 +76,6 @@ public:
|
||||
* @param[in] childPath the path without a "/" prefix
|
||||
*/
|
||||
virtual std::string getSystemPath(const std::string& childPath) const = 0;
|
||||
|
||||
/**
|
||||
* @see getSystemPath(), but with LVGL prefix.
|
||||
*/
|
||||
virtual std::string getSystemPathLvgl(const std::string& childPath) const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -43,11 +43,6 @@ public:
|
||||
*/
|
||||
virtual std::string getDataDirectory() const = 0;
|
||||
|
||||
/**
|
||||
* @see getDataDirectory(), but with LVGL prefix.
|
||||
*/
|
||||
virtual std::string getDataDirectoryLvgl() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the full path for an entry inside the data location for a service.
|
||||
* The data directory is intended to survive OS upgrades.
|
||||
@ -56,11 +51,6 @@ public:
|
||||
*/
|
||||
virtual std::string getDataPath(const std::string& childPath) const = 0;
|
||||
|
||||
/**
|
||||
* @see getDataPath(), but with LVGL prefix.
|
||||
*/
|
||||
virtual std::string getDataPathLvgl(const std::string& childPath) const = 0;
|
||||
|
||||
/**
|
||||
* Returns the directory path for the system location for a service.
|
||||
* The system directory is not intended to survive OS upgrades.
|
||||
@ -70,11 +60,6 @@ public:
|
||||
*/
|
||||
virtual std::string getSystemDirectory() const = 0;
|
||||
|
||||
/**
|
||||
* @see getSystemDirectory(), but with LVGL prefix.
|
||||
*/
|
||||
virtual std::string getSystemDirectoryLvgl() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the full path for an entry inside the system location for an app.
|
||||
* The data directory is not intended to survive OS upgrades.
|
||||
@ -83,11 +68,6 @@ public:
|
||||
* @param[in] childPath the path without a "/" prefix
|
||||
*/
|
||||
virtual std::string getSystemPath(const std::string& childPath) const = 0;
|
||||
|
||||
/**
|
||||
* @see getSystemPath(), but with LVGL prefix.
|
||||
*/
|
||||
virtual std::string getSystemPathLvgl(const std::string& childPath) const = 0;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -14,13 +14,9 @@ public:
|
||||
~AppInstancePaths() override = default;
|
||||
|
||||
std::string getDataDirectory() const override;
|
||||
std::string getDataDirectoryLvgl() const override;
|
||||
std::string getDataPath(const std::string& childPath) const override;
|
||||
std::string getDataPathLvgl(const std::string& childPath) const override;
|
||||
std::string getSystemDirectory() const override;
|
||||
std::string getSystemDirectoryLvgl() const override;
|
||||
std::string getSystemPath(const std::string& childPath) const override;
|
||||
std::string getSystemPathLvgl(const std::string& childPath) const override;
|
||||
};
|
||||
|
||||
}
|
||||
@ -6,23 +6,17 @@ namespace tt::service {
|
||||
|
||||
class ServiceInstancePaths final : public Paths {
|
||||
|
||||
private:
|
||||
|
||||
std::shared_ptr<const ServiceManifest> manifest;
|
||||
|
||||
public:
|
||||
|
||||
explicit ServiceInstancePaths(std::shared_ptr<const ServiceManifest> manifest) : manifest(std::move(manifest)) {}
|
||||
~ServiceInstancePaths() final = default;
|
||||
~ServiceInstancePaths() override = default;
|
||||
|
||||
std::string getDataDirectory() const final;
|
||||
std::string getDataDirectoryLvgl() const final;
|
||||
std::string getDataPath(const std::string& childPath) const final;
|
||||
std::string getDataPathLvgl(const std::string& childPath) const final;
|
||||
std::string getSystemDirectory() const final;
|
||||
std::string getSystemDirectoryLvgl() const final;
|
||||
std::string getSystemPath(const std::string& childPath) const final;
|
||||
std::string getSystemPathLvgl(const std::string& childPath) const final;
|
||||
std::string getDataDirectory() const override;
|
||||
std::string getDataPath(const std::string& childPath) const override;
|
||||
std::string getSystemDirectory() const override;
|
||||
std::string getSystemPath(const std::string& childPath) const override;
|
||||
};
|
||||
|
||||
}
|
||||
@ -12,11 +12,10 @@
|
||||
namespace tt::app {
|
||||
|
||||
std::string AppInstancePaths::getDataDirectory() const {
|
||||
return PARTITION_PREFIX + file::DATA_PARTITION_NAME + "/app/" + manifest.appId;
|
||||
}
|
||||
if (manifest.appLocation.isInternal()) {
|
||||
|
||||
std::string AppInstancePaths::getDataDirectoryLvgl() const {
|
||||
return LVGL_PATH_PREFIX + file::DATA_PARTITION_NAME + "/app/" + manifest.appId;
|
||||
}
|
||||
return PARTITION_PREFIX + file::DATA_PARTITION_NAME + "/app/" + manifest.appId;
|
||||
}
|
||||
|
||||
std::string AppInstancePaths::getDataPath(const std::string& childPath) const {
|
||||
@ -24,26 +23,14 @@ std::string AppInstancePaths::getDataPath(const std::string& childPath) const {
|
||||
return PARTITION_PREFIX + file::DATA_PARTITION_NAME + "/app/" + manifest.appId + '/' + childPath;
|
||||
}
|
||||
|
||||
std::string AppInstancePaths::getDataPathLvgl(const std::string& childPath) const {
|
||||
assert(!childPath.starts_with('/'));
|
||||
return LVGL_PATH_PREFIX + file::DATA_PARTITION_NAME + "/app/" + manifest.appId + '/' + childPath;
|
||||
}
|
||||
|
||||
std::string AppInstancePaths::getSystemDirectory() const {
|
||||
return PARTITION_PREFIX + file::SYSTEM_PARTITION_NAME + "/app/" + manifest.appId;
|
||||
}
|
||||
|
||||
std::string AppInstancePaths::getSystemDirectoryLvgl() const {
|
||||
return LVGL_PATH_PREFIX + file::SYSTEM_PARTITION_NAME + "/app/" + manifest.appId;
|
||||
}
|
||||
|
||||
std::string AppInstancePaths::getSystemPath(const std::string& childPath) const {
|
||||
assert(!childPath.starts_with('/'));
|
||||
return PARTITION_PREFIX + file::SYSTEM_PARTITION_NAME + "/app/" + manifest.appId + '/' + childPath;
|
||||
}
|
||||
|
||||
std::string AppInstancePaths::getSystemPathLvgl(const std::string& childPath) const {
|
||||
return LVGL_PATH_PREFIX + file::SYSTEM_PARTITION_NAME + "/app/" + manifest.appId + '/' + childPath;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ public:
|
||||
} else {
|
||||
logo = hal::usb::isUsbBootMode() ? "assets/logo_usb.png" : "assets/logo.png";
|
||||
}
|
||||
const auto logo_path = paths->getSystemPathLvgl(logo);
|
||||
const auto logo_path = "A:" + paths->getSystemPath(logo);
|
||||
TT_LOG_I(TAG, "%s", logo_path.c_str());
|
||||
lv_image_set_src(image, logo_path.c_str());
|
||||
}
|
||||
|
||||
@ -112,9 +112,9 @@ public:
|
||||
const int32_t margin = is_landscape_display ? std::min<int32_t>(available_width / 16, button_size) : 0;
|
||||
|
||||
const auto paths = app.getPaths();
|
||||
const auto apps_icon_path = paths->getSystemPathLvgl("assets/icon_apps.png");
|
||||
const auto files_icon_path = paths->getSystemPathLvgl("assets/icon_files.png");
|
||||
const auto settings_icon_path = paths->getSystemPathLvgl("assets/icon_settings.png");
|
||||
const auto apps_icon_path = "A:" + paths->getSystemPath("assets/icon_apps.png");
|
||||
const auto files_icon_path = "A:" + paths->getSystemPath("assets/icon_files.png");
|
||||
const auto settings_icon_path = "A:" + paths->getSystemPath("assets/icon_settings.png");
|
||||
|
||||
createAppButton(buttons_wrapper, ui_scale, apps_icon_path.c_str(), "AppList", margin);
|
||||
createAppButton(buttons_wrapper, ui_scale, files_icon_path.c_str(), "Files", margin);
|
||||
|
||||
@ -200,7 +200,7 @@ public:
|
||||
lv_obj_set_style_image_recolor_opa(icon, 255, 0);
|
||||
lv_obj_set_style_image_recolor(icon, lv_theme_get_color_primary(parent), 0);
|
||||
|
||||
std::string icon_path = app.getPaths()->getSystemPathLvgl("search.png");
|
||||
std::string icon_path = "A:" + app.getPaths()->getSystemPath("search.png");
|
||||
lv_image_set_src(icon, icon_path.c_str());
|
||||
lv_obj_set_style_image_recolor(icon, lv_theme_get_color_primary(parent), 0);
|
||||
|
||||
|
||||
@ -16,35 +16,18 @@ std::string ServiceInstancePaths::getDataDirectory() const {
|
||||
return PARTITION_PREFIX + file::DATA_PARTITION_NAME + "/service/" + manifest->id;
|
||||
}
|
||||
|
||||
std::string ServiceInstancePaths::getDataDirectoryLvgl() const {
|
||||
return LVGL_PATH_PREFIX + file::DATA_PARTITION_NAME + "/service/" + manifest->id;
|
||||
}
|
||||
|
||||
std::string ServiceInstancePaths::getDataPath(const std::string& childPath) const {
|
||||
assert(!childPath.starts_with('/'));
|
||||
return PARTITION_PREFIX + file::DATA_PARTITION_NAME + "/service/" + manifest->id + '/' + childPath;
|
||||
}
|
||||
|
||||
std::string ServiceInstancePaths::getDataPathLvgl(const std::string& childPath) const {
|
||||
assert(!childPath.starts_with('/'));
|
||||
return LVGL_PATH_PREFIX + file::DATA_PARTITION_NAME + "/service/" + manifest->id + '/' + childPath;
|
||||
}
|
||||
|
||||
std::string ServiceInstancePaths::getSystemDirectory() const {
|
||||
return PARTITION_PREFIX + file::SYSTEM_PARTITION_NAME + "/service/" + manifest->id;
|
||||
}
|
||||
|
||||
std::string ServiceInstancePaths::getSystemDirectoryLvgl() const {
|
||||
return LVGL_PATH_PREFIX + file::SYSTEM_PARTITION_NAME + "/service/" + manifest->id;
|
||||
}
|
||||
|
||||
std::string ServiceInstancePaths::getSystemPath(const std::string& childPath) const {
|
||||
assert(!childPath.starts_with('/'));
|
||||
return PARTITION_PREFIX + file::SYSTEM_PARTITION_NAME + "/service/" + manifest->id + '/' + childPath;
|
||||
}
|
||||
|
||||
std::string ServiceInstancePaths::getSystemPathLvgl(const std::string& childPath) const {
|
||||
return LVGL_PATH_PREFIX + file::SYSTEM_PARTITION_NAME + "/service/" + manifest->id + '/' + childPath;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ class StatusbarService final : public Service {
|
||||
bool show_icon = (gps_state == gps::State::OnPending) || (gps_state == gps::State::On);
|
||||
if (gps_last_state != show_icon) {
|
||||
if (show_icon) {
|
||||
auto icon_path = paths->getSystemPathLvgl(STATUSBAR_ICON_GPS);
|
||||
auto icon_path = "A:" + paths->getSystemPath(STATUSBAR_ICON_GPS);
|
||||
lvgl::statusbar_icon_set_image(gps_icon_id, icon_path);
|
||||
lvgl::statusbar_icon_set_visibility(gps_icon_id, true);
|
||||
} else {
|
||||
@ -179,7 +179,7 @@ class StatusbarService final : public Service {
|
||||
const char* desired_icon = getWifiStatusIcon(radio_state, is_secure);
|
||||
if (wifi_last_icon != desired_icon) {
|
||||
if (desired_icon != nullptr) {
|
||||
auto icon_path = paths->getSystemPathLvgl(desired_icon);
|
||||
auto icon_path = "A:" + paths->getSystemPath(desired_icon);
|
||||
lvgl::statusbar_icon_set_image(wifi_icon_id, icon_path);
|
||||
lvgl::statusbar_icon_set_visibility(wifi_icon_id, true);
|
||||
} else {
|
||||
@ -193,7 +193,7 @@ class StatusbarService final : public Service {
|
||||
const char* desired_icon = getPowerStatusIcon();
|
||||
if (power_last_icon != desired_icon) {
|
||||
if (desired_icon != nullptr) {
|
||||
auto icon_path = paths->getSystemPathLvgl(desired_icon);
|
||||
auto icon_path = "A:" + paths->getSystemPath(desired_icon);
|
||||
lvgl::statusbar_icon_set_image(power_icon_id, icon_path);
|
||||
lvgl::statusbar_icon_set_visibility(power_icon_id, true);
|
||||
} else {
|
||||
@ -212,7 +212,7 @@ class StatusbarService final : public Service {
|
||||
if (state != hal::sdcard::SdCardDevice::State::Timeout) {
|
||||
auto* desired_icon = getSdCardStatusIcon(state);
|
||||
if (sdcard_last_icon != desired_icon) {
|
||||
auto icon_path = paths->getSystemPathLvgl(desired_icon);
|
||||
auto icon_path = "A:" + paths->getSystemPath(desired_icon);
|
||||
lvgl::statusbar_icon_set_image(sdcard_icon_id, icon_path);
|
||||
lvgl::statusbar_icon_set_visibility(sdcard_icon_id, true);
|
||||
sdcard_last_icon = desired_icon;
|
||||
|
||||
@ -31,14 +31,6 @@ bool tt_app_has_result(AppHandle handle);
|
||||
*/
|
||||
void tt_app_get_data_directory(AppPathsHandle handle, char* buffer, size_t* size);
|
||||
|
||||
/** Get the path to the data directory of this app, with LVGL drive letter prefix applied.
|
||||
* The recommended buffer size is 256 bytes.
|
||||
* @param[in] handle the app handle
|
||||
* @param[out] buffer the output buffer (recommended size is 256 bytes)
|
||||
* @param[inout] size used as input for maximum buffer size (including null terminator) and is set with the path string length by this function
|
||||
*/
|
||||
void tt_app_get_data_directory_lvgl(AppPathsHandle handle, char* buffer, size_t* size);
|
||||
|
||||
/**
|
||||
* Start an app by id.
|
||||
* @param[in] appId the app manifest id
|
||||
|
||||
@ -51,22 +51,4 @@ void tt_app_get_data_directory(AppPathsHandle handle, char* buffer, size_t* size
|
||||
*size = data_path.length();
|
||||
}
|
||||
|
||||
void tt_app_get_data_directory_lvgl(AppPathsHandle handle, char* buffer, size_t* size) {
|
||||
assert(buffer != nullptr);
|
||||
assert(size != nullptr);
|
||||
assert(*size > 0);
|
||||
auto paths = HANDLE_AS_APP_CONTEXT(handle)->getPaths();
|
||||
auto data_path = paths->getDataDirectoryLvgl();
|
||||
auto expected_length = data_path.length() + 1;
|
||||
if (*size < expected_length) {
|
||||
TT_LOG_E(TAG, "Path buffer not large enough (%d < %d)", *size, expected_length);
|
||||
*size = 0;
|
||||
buffer[0] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
strcpy(buffer, data_path.c_str());
|
||||
*size = data_path.length();
|
||||
}
|
||||
|
||||
}
|
||||
@ -185,7 +185,6 @@ const esp_elfsym elf_symbols[] {
|
||||
ESP_ELFSYM_EXPORT(tt_app_alertdialog_start),
|
||||
ESP_ELFSYM_EXPORT(tt_app_alertdialog_get_result_index),
|
||||
ESP_ELFSYM_EXPORT(tt_app_get_data_directory),
|
||||
ESP_ELFSYM_EXPORT(tt_app_get_data_directory_lvgl),
|
||||
ESP_ELFSYM_EXPORT(tt_bundle_alloc),
|
||||
ESP_ELFSYM_EXPORT(tt_bundle_free),
|
||||
ESP_ELFSYM_EXPORT(tt_bundle_opt_bool),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user