Skip to content

Xbox Cloud Gaming app for PS5 Homebrew

C

Clock notice: count refusals, notify only on in-use screens

Rafael Abud Ferreira6ea39b64f885
diff --git a/src/app/cli_main.cpp b/src/app/cli_main.cpp
index 928fd58..3710eba 100644
--- a/src/app/cli_main.cpp
+++ b/src/app/cli_main.cpp
@@ -614,7 +614,7 @@ int main(int argc, char** argv) {
auto r = net::perform(req);
static const char* kProblems[] = {"none", "clock", "untrusted", "name mismatch", "other"};
std::printf("status %d, problem: %s, clock problem seen: %s, date %s\nerror: %s\n", r.status,
- kProblems[static_cast<int>(net::lastTlsProblem())], net::clockProblemSeen() ? "yes" : "no",
+ kProblems[static_cast<int>(net::lastTlsProblem())], net::clockRefusals() ? "yes" : "no",
net::todayText().c_str(), r.error.c_str());
return 0;
} else if (cmd == "ui-tls" && argi < argc) {
diff --git a/src/app/ps5_main.cpp b/src/app/ps5_main.cpp
index 2af4e4c..99248b2 100644
--- a/src/app/ps5_main.cpp
+++ b/src/app/ps5_main.cpp
@@ -285,13 +285,19 @@ int main(int argc, char** argv) {
}
}
// A Microsoft service refused for the console's clock: said once, even
- // if signing in worked (only some content then fails to load).
+ // if signing in worked (only some content then fails to load). Only
+ // for refusals while the app is in use: those of the sign-in (its
+ // error already says it, and the date may be fixed before Retry) are
+ // left behind; prices and images ask again on the home screen.
static bool clockTold = false;
- if (!clockTold && net::clockProblemSeen()) {
- clockTold = true;
- // Not over the sign-in error that already says it.
- if (g_ui->screen() != ui::Screen::Error)
+ static unsigned clockSeen = 0;
+ if (!clockTold && net::clockRefusals() != clockSeen) {
+ clockSeen = net::clockRefusals();
+ ui::Screen now = g_ui->screen();
+ if (now == ui::Screen::Home || now == ui::Screen::Details || now == ui::Screen::Settings) {
+ clockTold = true;
platform::notify(ui::trf(ui::Str::ClockWrongNotice, net::todayText()), "the console's clock looks wrong (notification)");
+ }
}
if (g_restartWanted) {
// After an update: the new version, started in place of this one.
diff --git a/src/net/http.cpp b/src/net/http.cpp
index af36825..1c75195 100644
--- a/src/net/http.cpp
+++ b/src/net/http.cpp
@@ -204,10 +204,10 @@ bool g_builtinCa = false;
std::atomic<int> g_tlsProblem{0}; // TlsProblem
-std::atomic<bool> g_clockSeen{false};
+std::atomic<unsigned> g_clockRefusals{0};
TlsProblem lastTlsProblem() { return static_cast<TlsProblem>(g_tlsProblem.load()); }
-bool clockProblemSeen() { return g_clockSeen; }
+unsigned clockRefusals() { return g_clockRefusals; }
bool microsoftHost(const std::string& host) {
for (const char* domain : {"xboxlive.com", "microsoft.com", "s-microsoft.com", "live.com", "xbox.com", "gamepass.com"}) {
@@ -357,7 +357,7 @@ Response performOnce(const Request& req) {
: flags & MBEDTLS_X509_BADCERT_NOT_TRUSTED ? TlsProblem::Untrusted
: TlsProblem::Other;
g_tlsProblem = static_cast<int>(problem);
- if (problem == TlsProblem::Clock && microsoftHost(url.host)) g_clockSeen = true;
+ if (problem == TlsProblem::Clock && microsoftHost(url.host)) ++g_clockRefusals;
char info[512];
int n = mbedtls_x509_crt_verify_info(info, sizeof info, "", flags);
std::string why = n > 0 ? std::string(info, static_cast<size_t>(n)) : "flags " + std::to_string(flags);
diff --git a/src/net/http.h b/src/net/http.h
index bcc23ce..005cd44 100644
--- a/src/net/http.h
+++ b/src/net/http.h
@@ -68,13 +68,14 @@ bool usingBuiltinCa();
// site), or another reason.
enum class TlsProblem { None, Clock, Untrusted, NameMismatch, Other };
TlsProblem lastTlsProblem();
-// Since start, a Microsoft service (xboxlive.com, (s-)microsoft.com, live.com,
-// xbox.com, gamepass.com) refused for the clock: the console's date is
-// surely wrong, even when signing in still works (certificates renewed after
-// that date fail: prices, images, the user's consoles...). Kept for the whole
-// session.
-bool clockProblemSeen();
-// The hosts that count for clockProblemSeen().
+// How many times a Microsoft service (xboxlive.com, (s-)microsoft.com,
+// live.com, xbox.com, gamepass.com) refused for the clock since start: the
+// console's date is surely wrong, even when signing in still works
+// (certificates renewed after that date fail: prices, images, the user's
+// consoles...). A count, so a caller can tell new refusals from old ones (the
+// date may be fixed meanwhile).
+unsigned clockRefusals();
+// The hosts that count for clockRefusals().
bool microsoftHost(const std::string& host);
// The console's date, "2026-10-14" (for the messages about its clock).
std::string todayText();