## Summary * **What is the goal of this PR?** * Make manual clock sync work even when the device is not already connected to Wi-Fi, so the user can start the sync flow directly from settings instead of being blocked by connection state. * **What changes are included?** * `ClockSyncActivity` now launches the normal Wi-Fi selection flow before syncing when the device is offline. * After Wi-Fi selection succeeds, clock sync resumes automatically and performs the existing forced NTP sync. * If clock sync had to bring Wi-Fi up, the activity disconnects and uses the existing silent restart cleanup path to avoid leaving the device in a fragmented post-Wi-Fi heap state. * The completion UI now only advertises Back, matching the updated input handling. ## Additional Context * Existing behavior is unchanged when Wi-Fi is already connected: the activity syncs immediately. * Cancelling Wi-Fi selection exits the clock sync flow. --- ### AI Usage 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? _**< YES >**_
29 lines
891 B
C++
29 lines
891 B
C++
#pragma once
|
|
|
|
#include "activities/Activity.h"
|
|
|
|
// Manual NTP resync action. Runs a forced sync (bypassing the once-per-device debounce),
|
|
// reports success/failure, then waits for Back. If WiFi is not connected yet, it reuses the
|
|
// normal WiFi selection flow first.
|
|
class ClockSyncActivity final : public Activity {
|
|
public:
|
|
explicit ClockSyncActivity(GfxRenderer& renderer, MappedInputManager& mappedInput)
|
|
: Activity("ClockSync", renderer, mappedInput) {}
|
|
|
|
void onEnter() override;
|
|
void onExit() override;
|
|
void loop() override;
|
|
bool skipLoopDelay() override { return true; }
|
|
void render(RenderLock&&) override;
|
|
|
|
private:
|
|
enum State { SYNCING, SUCCESS, NO_WIFI, FAILED };
|
|
State state = SYNCING;
|
|
char syncedTime[16] = {0};
|
|
bool shouldTearDownWifiOnExit = false;
|
|
|
|
void runSync();
|
|
void launchWifiSelection();
|
|
void onWifiSelectionComplete(bool connected);
|
|
};
|