mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-13 07:35:41 +08:00
Ref T295, based on bug report of RP (no WIFI detected) creating a network report
* network report when starting swift * also ignore inactive configs when checking for "the bearer bug" references: https://stackoverflow.com/questions/51824242/disable-qt-bearer-management-at-runtime https://swift-project.slack.com/archives/G7GD2UP9C/p1534181224000115 https://swift-project.slack.com/archives/G96QTUBEG/p1534162173000320
This commit is contained in:
@@ -1093,22 +1093,9 @@ namespace BlackCore
|
||||
|
||||
void CApplication::onNetworkConfigurationsUpdateCompleted()
|
||||
{
|
||||
Q_ASSERT_X(m_networkConfigManager, Q_FUNC_INFO, "Need network config manager");
|
||||
const QNetworkConfiguration config = m_networkConfigManager->defaultConfiguration();
|
||||
const QList<QNetworkConfiguration> allConfigurations = m_networkConfigManager->allConfigurations();
|
||||
|
||||
/** testing only
|
||||
for (const QNetworkConfiguration &config : allConfigurations)
|
||||
{
|
||||
const QString cs = CNetworkUtils::networkConfigurationToString(config);
|
||||
CLogMessage(this).info("Network config: '%1'") << cs;
|
||||
}
|
||||
if (m_accessManager)
|
||||
{
|
||||
const QString cs = CNetworkUtils::networkConfigurationToString(m_accessManager->configuration());
|
||||
CLogMessage(this).info("Network access manager config: '%1'") << cs;
|
||||
}
|
||||
**/
|
||||
|
||||
if (allConfigurations.isEmpty())
|
||||
{
|
||||
// this is an odd situation we cannot handle, network check will be disabled
|
||||
@@ -1121,14 +1108,25 @@ namespace BlackCore
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool isOnline = m_networkConfigManager->isOnline();
|
||||
int active = 0;
|
||||
int valid = 0;
|
||||
for (const QNetworkConfiguration &config : allConfigurations)
|
||||
{
|
||||
if (config.state() == QNetworkConfiguration::Active) { active++; }
|
||||
if (config.isValid()) { valid++; }
|
||||
}
|
||||
Q_UNUSED(valid);
|
||||
|
||||
// const bool isOnline = m_networkConfigManager->isOnline();
|
||||
const bool canStartIAP = (m_networkConfigManager->capabilities() & QNetworkConfigurationManager::CanStartAndStopInterfaces);
|
||||
m_networkWatchDog->disableNetworkAccessibilityCheck(!isOnline);
|
||||
const bool disable = active < 1; // only inactive
|
||||
if (disable) { CLogMessage(this).warning("Disabling network accessibility check in watchdog"); }
|
||||
m_networkWatchDog->disableNetworkAccessibilityCheck(disable);
|
||||
|
||||
// Is there default access point, use it
|
||||
if (!config.isValid() || (!canStartIAP && config.state() != QNetworkConfiguration::Active))
|
||||
{
|
||||
CLogMessage(this).error("No network access point found");
|
||||
CLogMessage(this).warning("No network access point found for swift");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1171,6 +1169,15 @@ namespace BlackCore
|
||||
// enable by setting accessible
|
||||
// http://doc.qt.io/qt-5/qnetworkaccessmanager.html#setNetworkAccessible
|
||||
m_accessManager->setNetworkAccessible(QNetworkAccessManager::Accessible);
|
||||
|
||||
|
||||
// create a network report in the log
|
||||
QTimer::singleShot(4000, this, [ = ]
|
||||
{
|
||||
if (!sApp || sApp->isShuttingDown()) { return; }
|
||||
const QString r = CNetworkUtils::createNetworkConfigurationReport(m_networkConfigManager, m_accessManager);
|
||||
CLogMessage(this).info("Network report:\n%1") << r;
|
||||
});
|
||||
}
|
||||
|
||||
CStatusMessageList CApplication::asyncWebAndContextStart()
|
||||
|
||||
@@ -426,6 +426,10 @@ namespace BlackCore
|
||||
//! \remark supposed to be used only in special cases
|
||||
const QNetworkAccessManager *getNetworkAccessManager() const { return m_accessManager; }
|
||||
|
||||
//! Access to configuration manager
|
||||
//! \remark supposed to be used only in special cases
|
||||
const QNetworkConfigurationManager *getNetworkConfigurationManager() const { return m_networkConfigManager; }
|
||||
|
||||
//! Web data services available?
|
||||
//! \threadsafe
|
||||
bool hasWebDataServices() const;
|
||||
|
||||
@@ -94,11 +94,11 @@ namespace BlackCore
|
||||
|
||||
QString CNetworkWatchdog::getCheckInfo() const
|
||||
{
|
||||
static const QString info("Internet accessible: %1 (good: %2 / bad: %3), swift DB accessible: %4 (good: %5 / bad: %6) DB last ping URL: '%7' canConnect: %8ms");
|
||||
static const QString info("Network accessibility check: %1 | Internet accessible: %2 (good: %3 / bad: %4), swift DB accessible: %5 (good: %6 / bad: %7) DB last ping URL: '%8' canConnect: %9ms");
|
||||
const QString pUrl(this->getLastPingDbUrl());
|
||||
static const QString cct = QString::number(CanConnectTimeMs);
|
||||
return info.
|
||||
arg(boolToYesNo(this->isInternetAccessible())).arg(m_totalGoodCountInternet).arg(m_totalBadCountInternet).
|
||||
arg(boolToEnabledDisabled(!this->isNetworkAccessibilityCheckDisabled()), boolToYesNo(this->isInternetAccessible())).arg(m_totalGoodCountInternet).arg(m_totalBadCountInternet).
|
||||
arg(boolToYesNo(this->isSwiftDbAccessible())).arg(m_totalGoodCountDb).arg(m_totalBadCountDb).
|
||||
arg(pUrl, cct); // cct has to be string, otherwise the % in the URL will be replaced
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user