fix: use RAII render lock everywhere (#916)

Follow-up to
https://github.com/crosspoint-reader/crosspoint-reader/pull/774

---

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? **NO**

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

* **Refactor**
* Modernized internal synchronization mechanisms across multiple
components to improve code reliability and maintainability. All
functionality remains unchanged.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Xuan-Son Nguyen
2026-02-16 13:53:00 +01:00
committed by cottongin
parent ed8a0feac1
commit ebcd3a8b94
7 changed files with 153 additions and 128 deletions

View File

@@ -20,33 +20,37 @@ void OtaUpdateActivity::onWifiSelectionComplete(const bool success) {
LOG_DBG("OTA", "WiFi connected, checking for update");
xSemaphoreTake(renderingMutex, portMAX_DELAY);
state = CHECKING_FOR_UPDATE;
xSemaphoreGive(renderingMutex);
{
RenderLock lock(*this);
state = CHECKING_FOR_UPDATE;
}
requestUpdateAndWait();
const auto res = updater.checkForUpdate();
if (res != OtaUpdater::OK) {
LOG_DBG("OTA", "Update check failed: %d", res);
xSemaphoreTake(renderingMutex, portMAX_DELAY);
state = FAILED;
xSemaphoreGive(renderingMutex);
{
RenderLock lock(*this);
state = FAILED;
}
requestUpdate();
return;
}
if (!updater.isUpdateNewer()) {
LOG_DBG("OTA", "No new update available");
xSemaphoreTake(renderingMutex, portMAX_DELAY);
state = NO_UPDATE;
xSemaphoreGive(renderingMutex);
{
RenderLock lock(*this);
state = NO_UPDATE;
}
requestUpdate();
return;
}
xSemaphoreTake(renderingMutex, portMAX_DELAY);
state = WAITING_CONFIRMATION;
xSemaphoreGive(renderingMutex);
{
RenderLock lock(*this);
state = WAITING_CONFIRMATION;
}
requestUpdate();
}