shill: LTE: handle connect completion message after service gone
Fine tune the logging, supressing some meaningless logs, and adding
logging where it is helpful in reconstructing what happened.
CellularCapabilityUniversal::OnConnectReply() may be called when there
are no cellular service. This CL checks to make sure the service is
valid before using it. See also
https://gerrit.chromium.org/gerrit/23042
TEST=network_3GModemControl and network_3GPseudoModemControl
BUG=none
Change-Id: Ie81e9df42270045cde0aeb0a975f8412cc3e7a25
Reviewed-on: https://gerrit.chromium.org/gerrit/23389
Tested-by: Jason Glasgow <jglasgow@chromium.org>
Reviewed-by: Thieu Le <thieule@chromium.org>
Commit-Ready: Jason Glasgow <jglasgow@chromium.org>
diff --git a/cellular_capability_universal_unittest.cc b/cellular_capability_universal_unittest.cc
index 7a8d3df..c3b1330 100644
--- a/cellular_capability_universal_unittest.cc
+++ b/cellular_capability_universal_unittest.cc
@@ -619,6 +619,19 @@
EXPECT_TRUE(error.IsSuccess());
EXPECT_CALL(*this, TestCallback(IsSuccess()));
connect_callback_.Run(bearer, Error(Error::kSuccess));
+
+ // Test connect failures without a service. Make sure that shill
+ // does not crash if the connect failed and there is no
+ // CellularService object. This can happen if the modem is enabled
+ // and then quickly disabled.
+ cellular_->service_ = NULL;
+ EXPECT_FALSE(capability_->cellular()->service());
+ EXPECT_CALL(*modem_simple_proxy, Connect(_, _, _, _))
+ .WillOnce(SaveArg<2>(&connect_callback_));
+ capability_->Connect(properties, &error, callback);
+ EXPECT_TRUE(error.IsSuccess());
+ EXPECT_CALL(*this, TestCallback(IsFailure()));
+ connect_callback_.Run(bearer, Error(Error::kOperationFailed));
}
// Validates Connect iterates over APNs