diff options
author | rkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-25 15:39:52 +0000 |
---|---|---|
committer | rkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-25 15:39:52 +0000 |
commit | 6f2f1c1c12c052590d204650533240de0d7a5f1a (patch) | |
tree | 4130f8ac22a72141e002cbf6022242f05bef5a72 | |
parent | 74d74897fceb4ff3c24f9aa7273eab4568e92577 (diff) | |
download | chromium_src-6f2f1c1c12c052590d204650533240de0d7a5f1a.zip chromium_src-6f2f1c1c12c052590d204650533240de0d7a5f1a.tar.gz chromium_src-6f2f1c1c12c052590d204650533240de0d7a5f1a.tar.bz2 |
Add ResetModem method and call it once non_cellular activation is done.
Once non_cellular activation is done, the modem needs to be reset to get into the new activated state.
R=stevenjb@chromium.org,benchan@chromium.org
BUG=171535
Review URL: https://chromiumcodereview.appspot.com/12041029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178823 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/cros/mock_network_library.h | 1 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/network_library.h | 4 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/network_library_impl_base.h | 1 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/network_library_impl_cros.cc | 9 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/network_library_impl_cros.h | 1 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/network_library_impl_stub.cc | 3 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/network_library_impl_stub.h | 1 | ||||
-rw-r--r-- | chrome/browser/chromeos/mobile/mobile_activator.cc | 2 | ||||
-rw-r--r-- | chromeos/dbus/mock_shill_device_client.h | 3 | ||||
-rw-r--r-- | chromeos/dbus/shill_device_client.cc | 17 | ||||
-rw-r--r-- | chromeos/dbus/shill_device_client.h | 6 | ||||
-rw-r--r-- | chromeos/dbus/shill_device_client_unittest.cc | 19 | ||||
-rw-r--r-- | chromeos/network/cros_network_functions.cc | 8 | ||||
-rw-r--r-- | chromeos/network/cros_network_functions.h | 3 |
14 files changed, 78 insertions, 0 deletions
diff --git a/chrome/browser/chromeos/cros/mock_network_library.h b/chrome/browser/chromeos/cros/mock_network_library.h index 453b592..ae93618 100644 --- a/chrome/browser/chromeos/cros/mock_network_library.h +++ b/chrome/browser/chromeos/cros/mock_network_library.h @@ -110,6 +110,7 @@ class MockNetworkLibrary : public NetworkLibrary { MOCK_METHOD1(SetCellularDataRoamingAllowed, void(bool)); MOCK_METHOD2(SetCarrier, void(const std::string&, const NetworkOperationCallback&)); + MOCK_METHOD0(ResetModem, void()); MOCK_METHOD0(IsCellularAlwaysInRoaming, bool()); MOCK_METHOD0(RequestNetworkScan, void(void)); diff --git a/chrome/browser/chromeos/cros/network_library.h b/chrome/browser/chromeos/cros/network_library.h index fe07b3c..f0c3b0b 100644 --- a/chrome/browser/chromeos/cros/network_library.h +++ b/chrome/browser/chromeos/cros/network_library.h @@ -1566,6 +1566,10 @@ class NetworkLibrary { virtual void SetCarrier(const std::string& carrier, const NetworkOperationCallback& completed) = 0; + // Resets the cellular device, calls the closure once the transition is + // complete. + virtual void ResetModem() = 0; + // Return true if GSM SIM card can work only with enabled roaming. virtual bool IsCellularAlwaysInRoaming() = 0; diff --git a/chrome/browser/chromeos/cros/network_library_impl_base.h b/chrome/browser/chromeos/cros/network_library_impl_base.h index 587c057..4708d32 100644 --- a/chrome/browser/chromeos/cros/network_library_impl_base.h +++ b/chrome/browser/chromeos/cros/network_library_impl_base.h @@ -193,6 +193,7 @@ class NetworkLibraryImplBase : public NetworkLibrary { // virtual RequestCellularRegister implemented in derived classes. // virtual SetCellularDataRoamingAllowed implemented in derived classes. // virtual SetCarrier implemented in derived classes. + // virtual ResetModem implemented in derived classes. // virtual IsCellularAlwaysInRoaming implemented in derived classes. // virtual RequestNetworkScan implemented in derived classes. diff --git a/chrome/browser/chromeos/cros/network_library_impl_cros.cc b/chrome/browser/chromeos/cros/network_library_impl_cros.cc index c0b7c55..450f881 100644 --- a/chrome/browser/chromeos/cros/network_library_impl_cros.cc +++ b/chrome/browser/chromeos/cros/network_library_impl_cros.cc @@ -439,6 +439,15 @@ void NetworkLibraryImplCros::SetCarrier( CrosSetCarrier(cellular->device_path(), carrier, completed); } +void NetworkLibraryImplCros::ResetModem() { + const NetworkDevice* cellular = FindCellularDevice(); + if (!cellular) { + NOTREACHED() << "Calling ResetModem method w/o cellular device."; + return; + } + CrosReset(cellular->device_path()); +} + bool NetworkLibraryImplCros::IsCellularAlwaysInRoaming() { const NetworkDevice* cellular = FindCellularDevice(); if (!cellular) { diff --git a/chrome/browser/chromeos/cros/network_library_impl_cros.h b/chrome/browser/chromeos/cros/network_library_impl_cros.h index a869822..b8fa17d 100644 --- a/chrome/browser/chromeos/cros/network_library_impl_cros.h +++ b/chrome/browser/chromeos/cros/network_library_impl_cros.h @@ -61,6 +61,7 @@ class NetworkLibraryImplCros : public NetworkLibraryImplBase { virtual void SetCellularDataRoamingAllowed(bool new_value) OVERRIDE; virtual void SetCarrier(const std::string& carrier, const NetworkOperationCallback& completed) OVERRIDE; + virtual void ResetModem() OVERRIDE; virtual bool IsCellularAlwaysInRoaming() OVERRIDE; virtual void RequestNetworkScan() OVERRIDE; diff --git a/chrome/browser/chromeos/cros/network_library_impl_stub.cc b/chrome/browser/chromeos/cros/network_library_impl_stub.cc index 476f627..94eee73 100644 --- a/chrome/browser/chromeos/cros/network_library_impl_stub.cc +++ b/chrome/browser/chromeos/cros/network_library_impl_stub.cc @@ -687,6 +687,9 @@ void NetworkLibraryImplStub::SetCarrier( base::TimeDelta::FromMilliseconds(10000)); } +void NetworkLibraryImplStub::ResetModem() { +} + bool NetworkLibraryImplStub::IsCellularAlwaysInRoaming() { return false; } diff --git a/chrome/browser/chromeos/cros/network_library_impl_stub.h b/chrome/browser/chromeos/cros/network_library_impl_stub.h index f5fa6a8..b4f4b98 100644 --- a/chrome/browser/chromeos/cros/network_library_impl_stub.h +++ b/chrome/browser/chromeos/cros/network_library_impl_stub.h @@ -64,6 +64,7 @@ class NetworkLibraryImplStub : public NetworkLibraryImplBase { virtual void SetCellularDataRoamingAllowed(bool new_value) OVERRIDE; virtual void SetCarrier(const std::string& carrier, const NetworkOperationCallback& completed) OVERRIDE; + virtual void ResetModem() OVERRIDE; virtual bool IsCellularAlwaysInRoaming() OVERRIDE; virtual void RequestNetworkScan() OVERRIDE; diff --git a/chrome/browser/chromeos/mobile/mobile_activator.cc b/chrome/browser/chromeos/mobile/mobile_activator.cc index 3fa1a4d..71cb8f3 100644 --- a/chrome/browser/chromeos/mobile/mobile_activator.cc +++ b/chrome/browser/chromeos/mobile/mobile_activator.cc @@ -279,6 +279,8 @@ void MobileActivator::HandleSetTransactionStatus(bool success) { CellularNetwork* network = FindMatchingCellularNetwork(true); if (network && network->activate_over_non_cellular_network()) { state_ = PLAN_ACTIVATION_DONE; + // We're done with activation, reset the cellular device. + lib->ResetModem(); EvaluateCellularNetwork(network); } else { StartOTASP(); diff --git a/chromeos/dbus/mock_shill_device_client.h b/chromeos/dbus/mock_shill_device_client.h index 26b8032..3f2a2db 100644 --- a/chromeos/dbus/mock_shill_device_client.h +++ b/chromeos/dbus/mock_shill_device_client.h @@ -71,6 +71,9 @@ class MockShillDeviceClient : public ShillDeviceClient { const std::string& carrier, const base::Closure& callback, const ErrorCallback& error_callback)); + MOCK_METHOD3(Reset, void(const dbus::ObjectPath& device_path, + const base::Closure& callback, + const ErrorCallback& error_callback)); MOCK_METHOD0(GetTestInterface, TestInterface*()); }; diff --git a/chromeos/dbus/shill_device_client.cc b/chromeos/dbus/shill_device_client.cc index e44eca1..92f67a8 100644 --- a/chromeos/dbus/shill_device_client.cc +++ b/chromeos/dbus/shill_device_client.cc @@ -178,6 +178,15 @@ class ShillDeviceClientImpl : public ShillDeviceClient { &method_call, callback, error_callback); } + virtual void Reset(const dbus::ObjectPath& device_path, + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { + dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface, + shill::kResetFunction); + GetHelper(device_path)->CallVoidMethodWithErrorCallback( + &method_call, callback, error_callback); + } + virtual TestInterface* GetTestInterface() OVERRIDE { return NULL; } @@ -367,6 +376,14 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient, MessageLoop::current()->PostTask(FROM_HERE, callback); } + virtual void Reset(const dbus::ObjectPath& device_path, + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { + if (callback.is_null()) + return; + MessageLoop::current()->PostTask(FROM_HERE, callback); + } + virtual ShillDeviceClient::TestInterface* GetTestInterface() OVERRIDE { return this; } diff --git a/chromeos/dbus/shill_device_client.h b/chromeos/dbus/shill_device_client.h index 5f7b64d..e7490f5 100644 --- a/chromeos/dbus/shill_device_client.h +++ b/chromeos/dbus/shill_device_client.h @@ -158,6 +158,12 @@ class CHROMEOS_EXPORT ShillDeviceClient { const base::Closure& callback, const ErrorCallback& error_callback) = 0; + // Calls the Reset method. + // |callback| is called after the method call finishes. + virtual void Reset(const dbus::ObjectPath& device_path, + const base::Closure& callback, + const ErrorCallback& error_callback) = 0; + // Returns an interface for testing (stub only), or returns NULL. virtual TestInterface* GetTestInterface() = 0; diff --git a/chromeos/dbus/shill_device_client_unittest.cc b/chromeos/dbus/shill_device_client_unittest.cc index 2a40a1f..d8f127a 100644 --- a/chromeos/dbus/shill_device_client_unittest.cc +++ b/chromeos/dbus/shill_device_client_unittest.cc @@ -392,4 +392,23 @@ TEST_F(ShillDeviceClientTest, SetCarrier) { message_loop_.RunUntilIdle(); } +TEST_F(ShillDeviceClientTest, Reset) { + // Create response. + scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); + + // Set expectations. + MockClosure mock_closure; + MockErrorCallback mock_error_callback; + PrepareForMethodCall(shill::kResetFunction, + base::Bind(&ExpectNoArgument), + response.get()); + EXPECT_CALL(mock_closure, Run()).Times(1); + // Call method. + client_->Reset(dbus::ObjectPath(kExampleDevicePath), + mock_closure.GetCallback(), + mock_error_callback.GetCallback()); + // Run the message loop. + message_loop_.RunUntilIdle(); +} + } // namespace chromeos diff --git a/chromeos/network/cros_network_functions.cc b/chromeos/network/cros_network_functions.cc index c7d02b1..350b837 100644 --- a/chromeos/network/cros_network_functions.cc +++ b/chromeos/network/cros_network_functions.cc @@ -666,4 +666,12 @@ void CrosSetCarrier(const std::string& device_path, base::Bind(&OnNetworkActionError, callback, device_path)); } +// Resets the device. +void CrosReset(const std::string& device_path) { + DBusThreadManager::Get()->GetShillDeviceClient()->Reset( + dbus::ObjectPath(device_path), + base::Bind(&DoNothing), + base::Bind(&IgnoreErrors)); +} + } // namespace chromeos diff --git a/chromeos/network/cros_network_functions.h b/chromeos/network/cros_network_functions.h index 5ff93be..ddc4481 100644 --- a/chromeos/network/cros_network_functions.h +++ b/chromeos/network/cros_network_functions.h @@ -262,6 +262,9 @@ CHROMEOS_EXPORT void CrosSetCarrier(const std::string& device_path, const std::string& carrier, const NetworkOperationCallback& callback); +// Resets the device. +CHROMEOS_EXPORT void CrosReset(const std::string& device_path); + } // namespace chromeos #endif // CHROMEOS_NETWORK_CROS_NETWORK_FUNCTIONS_H_ |