shill: cellular: improve handling of CellularService state
As noted in crbug.com/246456#c1, when using a PPP dongle,
we don't let the Cellular object SelectService on the CellularService.
That avoids potential conflicts where both Cellular and PPPDevice
are trying to manage the IP configuration of the Service. However,
there are some state change events that need to be propagated to
the Service. In particular, when the modem disconnects, we need to
move the Service to the idle state.
Fix this by overriding the various service-state-setting methods
with versions that punt over to PPPDevice, when appropriate.
While there:
- mark Cellular::OnNoNetworkRouting as override-ing
- move cleanup of MockCellularService to CellularTest:TearDown
(instead of being the responsibility of individual tests)
BUG=chromium:252067
TEST=new unit tests, manual (see below)
Manual testing
--------------
1. plug in ppp dongle
2. wait for dongle to connect
3. chrome://settings -> Mobile data -> <provider> -> Disconnect
4. wait for disconnect to complete
5. "Mobile data" should show "Not connected"
6. chrome://network should show the Cellular service in "idle" state.
7. ifconfig should not show any ppp device (e.g. ppp0, ppp1)
8. Mobile data -> <provider> -> Connect
9. connect should succeed
Change-Id: I512c98ef8cc187fa039e58ad66da604ff1739063
Reviewed-on: https://gerrit.chromium.org/gerrit/61625
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Queue: mukesh agrawal <quiche@chromium.org>
Tested-by: mukesh agrawal <quiche@chromium.org>
diff --git a/cellular.cc b/cellular.cc
index c090baf..37661aa 100644
--- a/cellular.cc
+++ b/cellular.cc
@@ -373,6 +373,30 @@
}
}
+void Cellular::SetServiceState(Service::ConnectState state) {
+ if (ppp_device_) {
+ ppp_device_->SetServiceState(state);
+ } else {
+ Device::SetServiceState(state);
+ }
+}
+
+void Cellular::SetServiceFailure(Service::ConnectFailure failure_state) {
+ if (ppp_device_) {
+ ppp_device_->SetServiceFailure(failure_state);
+ } else {
+ Device::SetServiceFailure(failure_state);
+ }
+}
+
+void Cellular::SetServiceFailureSilent(Service::ConnectFailure failure_state) {
+ if (ppp_device_) {
+ ppp_device_->SetServiceFailureSilent(failure_state);
+ } else {
+ Device::SetServiceFailureSilent(failure_state);
+ }
+}
+
void Cellular::OnNoNetworkRouting() {
SLOG(Cellular, 2) << __func__;
Device::OnNoNetworkRouting();