bmc_state: Update last update time after timesync

Currently the lastRebootTime is updated at service boot up and reuses
the values on future requests. This can cause incorrect values like

```
$ busctl get-property xyz.openbmc_project.State.BMC /xyz/openbmc_project/state/bmc0 xyz.openbmc_project.State.BMC LastRebootTime
t 1680555476000
$ uptime
 11:23:05 up 1 day, 24 min,  load average: 3.08, 2.89, 2.84
```

1680555476000 -> Mon Apr 03 2023 20:57:56 GMT+0000
which is more than 1 day and 24 minutes ago.

The change will detect property changes to `time-sync.target` which
would be activated after timesync happens. It will then deactivate the
matcher after update the lastReboot time once.

Tested:
After bootup and timesync, the lastReboot time is now correct.

Change-Id: Iee8a0bc9f0c5b22d5010f1a677011e44b5d425d3
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/bmc_state_manager.cpp b/bmc_state_manager.cpp
index 9f67a31..efaa0a2 100644
--- a/bmc_state_manager.cpp
+++ b/bmc_state_manager.cpp
@@ -242,6 +242,20 @@
     return server::BMC::lastRebootCause(value);
 }
 
+void BMC::updateLastRebootTime()
+{
+    using namespace std::chrono;
+    struct sysinfo info;
+
+    auto rc = sysinfo(&info);
+    assert(rc == 0);
+    // Since uptime is in seconds, also get the current time in seconds.
+    auto now = time_point_cast<seconds>(system_clock::now());
+    auto rebootTimeTs = now - seconds(info.uptime);
+    rebootTime =
+        duration_cast<milliseconds>(rebootTimeTs.time_since_epoch()).count();
+}
+
 uint64_t BMC::lastRebootTime() const
 {
     return rebootTime;