Port 6 upstream PRs (PR #939 was already ported): - #852: Complete HalPowerManager with RAII Lock class, WiFi check in setPowerSaving, skipLoopDelay overrides for ClearCache/OtaUpdate, and power lock in Activity render task loops - #965: Fix paragraph formatting inside list items by tracking listItemUntilDepth to prevent unwanted line breaks - #972: Micro-optimizations: std::move in insertFont, const ref for getDataFromBook parameter - #971: Remove redundant hasPrintableChars pre-rendering pass from EpdFont, EpdFontFamily, and GfxRenderer - #977: Skip unsupported image formats before extraction, add PARSE_BUFFER_SIZE constant and chapter parse timing - #975: Fix UITheme memory leak by replacing raw pointer with std::unique_ptr for currentTheme Co-authored-by: Cursor <cursoragent@cursor.com>
54 lines
1.4 KiB
C++
54 lines
1.4 KiB
C++
#include "ActivityWithSubactivity.h"
|
|
|
|
#include <HalPowerManager.h>
|
|
|
|
void ActivityWithSubactivity::renderTaskLoop() {
|
|
while (true) {
|
|
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
|
|
{
|
|
HalPowerManager::Lock powerLock;
|
|
RenderLock lock(*this);
|
|
if (!subActivity) {
|
|
render(std::move(lock));
|
|
}
|
|
// If subActivity is set, consume the notification but skip parent render
|
|
// Note: the sub-activity will call its render() from its own display task
|
|
}
|
|
}
|
|
}
|
|
|
|
void ActivityWithSubactivity::exitActivity() {
|
|
// No need to lock, since onExit() already acquires its own lock
|
|
if (subActivity) {
|
|
LOG_DBG("ACT", "Exiting subactivity...");
|
|
subActivity->onExit();
|
|
subActivity.reset();
|
|
}
|
|
}
|
|
|
|
void ActivityWithSubactivity::enterNewActivity(Activity* activity) {
|
|
// Acquire lock to avoid 2 activities rendering at the same time during transition
|
|
RenderLock lock(*this);
|
|
subActivity.reset(activity);
|
|
subActivity->onEnter();
|
|
}
|
|
|
|
void ActivityWithSubactivity::loop() {
|
|
if (subActivity) {
|
|
subActivity->loop();
|
|
}
|
|
}
|
|
|
|
void ActivityWithSubactivity::requestUpdate() {
|
|
if (!subActivity) {
|
|
Activity::requestUpdate();
|
|
}
|
|
// Sub-activity should call their own requestUpdate() from their loop() function
|
|
}
|
|
|
|
void ActivityWithSubactivity::onExit() {
|
|
// No need to lock, onExit() already acquires its own lock
|
|
exitActivity();
|
|
Activity::onExit();
|
|
}
|