shill: logging improvements
BUG=None
TEST=unit tests
Change-Id: I0b91fc7c2b44a0866d0bb53d546a7a87bb7ccccd
Reviewed-on: https://gerrit.chromium.org/gerrit/17743
Commit-Ready: mukesh agrawal <quiche@chromium.org>
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Tested-by: mukesh agrawal <quiche@chromium.org>
diff --git a/wifi_service.cc b/wifi_service.cc
index 8b9250f..7da9d16 100644
--- a/wifi_service.cc
+++ b/wifi_service.cc
@@ -34,6 +34,9 @@
namespace shill {
+const char WiFiService::kAutoConnBusy[] = "busy";
+const char WiFiService::kAutoConnNoEndpoint[] = "no endpoints";
+
const char WiFiService::kStorageHiddenSSID[] = "WiFi.HiddenSSID";
const char WiFiService::kStorageMode[] = "WiFi.Mode";
const char WiFiService::kStoragePassphrase[] = "Passphrase";
@@ -114,7 +117,8 @@
}
void WiFiService::AutoConnect() {
- if (IsAutoConnectable()) {
+ const char *reason;
+ if (IsAutoConnectable(&reason)) {
// Execute immediately, for two reasons:
//
// 1. We need IsAutoConnectable to return the correct value for
@@ -127,7 +131,8 @@
// more timely work.
ConnectTask();
} else {
- LOG(INFO) << "Suppressed autoconnect to " << friendly_name();
+ LOG(INFO) << "Suppressed autoconnect to " << friendly_name() << " "
+ << "(" << reason << ")";
}
}
@@ -152,15 +157,27 @@
return wifi_->TechnologyIs(type);
}
-bool WiFiService::IsAutoConnectable() const {
- return Service::IsAutoConnectable() &&
- // Only auto-connect to Services which have visible Endpoints.
- // (Needed because hidden Services may remain registered with
- // Manager even without visible Endpoints.)
- HasEndpoints() &&
- // Do not preempt an existing connection (whether pending, or
- // connected, and whether to this service, or another).
- wifi_->IsIdle();
+bool WiFiService::IsAutoConnectable(const char **reason) const {
+ if (!Service::IsAutoConnectable(reason)) {
+ return false;
+ }
+
+ // Only auto-connect to Services which have visible Endpoints.
+ // (Needed because hidden Services may remain registered with
+ // Manager even without visible Endpoints.)
+ if (!HasEndpoints()) {
+ *reason = kAutoConnNoEndpoint;
+ return false;
+ }
+
+ // Do not preempt an existing connection (whether pending, or
+ // connected, and whether to this service, or another).
+ if (!wifi_->IsIdle()) {
+ *reason = kAutoConnBusy;
+ return false;
+ }
+
+ return true;
}
bool WiFiService::IsConnecting() const {