Add keepsBluetoothAlive hook to Activity base class

Introduces a virtual method allowing activities to indicate whether they need the BLE stack to remain active. This enables selective teardown of Bluetooth to free heap memory, with the Bluetooth settings screen being able to override this for pairing and scanning functionality.
This commit is contained in:
Justin Mitchell
2026-06-24 17:00:52 -04:00
parent d30fde2f4d
commit d6f5be6b7a
15 changed files with 112 additions and 39 deletions
+11
View File
@@ -254,6 +254,17 @@ bool ActivityManager::isReaderActivity() const {
(currentActivity && currentActivity->isReaderActivity());
}
void ActivityManager::requestGhostCleanup() {
if (currentActivity) currentActivity->requestGhostCleanup();
}
bool ActivityManager::bluetoothShouldBeActive() const {
const auto wants = [](const auto& activity) {
return activity && (activity->isReaderActivity() || activity->keepsBluetoothAlive());
};
return std::any_of(stackActivities.begin(), stackActivities.end(), wants) || wants(currentActivity);
}
bool ActivityManager::skipLoopDelay() const { return currentActivity && currentActivity->skipLoopDelay(); }
ScreenshotInfo ActivityManager::getScreenshotInfo() const {