Remove suspend-related code from GobiModem.

cromo no longer registers for suspend delays, since the
corresponding functionality has been moved into shill.  This
change removes code from GobiModem that attempts to avoid
connecting when the system is about to suspend -- this code
looks like it's never triggered due to cromo's suspend-delay
code being disabled.

BUG=chromium-os:30587,chromium-os:36980
TEST=manual: modem still works after suspending and resuming
CQ-DEPEND=I2b9edfd46124dcd5386f96dd67cea43478ee2a1b

Change-Id: I65e01df5b9e2b9234098e98315e5eb6f583d0169
Reviewed-on: https://gerrit.chromium.org/gerrit/41027
Tested-by: Daniel Erat <derat@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
Commit-Queue: Daniel Erat <derat@chromium.org>
diff --git a/gobi_modem.cc b/gobi_modem.cc
index bd67d07..cf26b5f 100644
--- a/gobi_modem.cc
+++ b/gobi_modem.cc
@@ -322,23 +322,6 @@
   return !modem->is_connecting_or_connected();
 }
 
-bool SuspendOkTrampoline(void *arg) {
-  GobiModem *modem = static_cast<GobiModem*>(arg);
-  return !modem->is_connecting_or_connected();
-}
-
-bool OnSuspendedTrampoline(void *arg) {
-  GobiModem *modem = static_cast<GobiModem*>(arg);
-  modem->OnSuspended();
-  return true;
-}
-
-bool OnResumedTrampoline(void *arg) {
-  GobiModem *modem = static_cast<GobiModem*>(arg);
-  modem->OnResumed();
-  return true;
-}
-
 GobiModem::GobiModem(DBus::Connection& connection,
                      const DBus::Path& path,
                      const gobi::DeviceElement& device,
@@ -351,7 +334,6 @@
       mm_state_(MM_MODEM_STATE_UNKNOWN),
       session_id_(0),
       signal_available_(false),
-      suspending_(false),
       exiting_(false),
       device_resetting_(false),
       getting_deallocated_(false),
@@ -385,14 +367,6 @@
   handler_->server().start_exit_hooks().Add(hooks_name_, StartExitTrampoline,
                                             this);
   handler_->server().exit_ok_hooks().Add(hooks_name_, ExitOkTrampoline, this);
-  RegisterStartSuspend(hooks_name_);
-  handler_->server().suspend_ok_hooks().Add(hooks_name_, SuspendOkTrampoline,
-                                            this);
-  handler_->server().on_suspended_hooks().Add(hooks_name_,
-                                              OnSuspendedTrampoline,
-                                              this);
-  handler_->server().on_resumed_hooks().Add(hooks_name_, OnResumedTrampoline,
-                                            this);
 }
 
 GobiModem::~GobiModem() {
@@ -407,10 +381,6 @@
   }
   handler_->server().start_exit_hooks().Del(hooks_name_);
   handler_->server().exit_ok_hooks().Del(hooks_name_);
-  handler_->server().UnregisterStartSuspend(hooks_name_);
-  handler_->server().suspend_ok_hooks().Del(hooks_name_);
-  handler_->server().on_suspended_hooks().Del(hooks_name_);
-  handler_->server().on_resumed_hooks().Del(hooks_name_);
 
   ApiDisconnect();
 }
@@ -690,11 +660,6 @@
     error.set(kConnectError, "Cromo is exiting");
     return;
   }
-  if (suspending_) {
-    LOG(WARNING) << "Connect operation is ignored when suspending";
-    error.set(kConnectError, "Connect operation is ignored when suspending");
-    return;
-  }
   if (session_starter_in_flight_) {
     LOG(WARNING) << "Session start already in flight";
     error.set(kConnectError, "Connect already in progress");
@@ -1603,8 +1568,6 @@
     disconnect_time_.Stop();
     session_id_ = 0;
     unsigned int reason = QMIReasonToMMReason(session_end_reason);
-    if (reason == MM_MODEM_STATE_CHANGED_REASON_USER_REQUESTED && suspending_)
-      reason = MM_MODEM_STATE_CHANGED_REASON_SUSPEND;
     if (pending_enable_ != NULL)
       PerformDeferredDisable();
     else
@@ -1764,35 +1727,6 @@
   return rc;
 }
 
-bool GobiModem::StartSuspend() {
-  LOG(INFO) << "StartSuspend";
-  suspending_ = true;
-  return (ForceDisconnect() == 0);
-}
-
-bool StartSuspendTrampoline(void *arg) {
-  GobiModem *modem = static_cast<GobiModem*>(arg);
-  return modem->StartSuspend();
-}
-
-void GobiModem::OnSuspended() {
-  LOG(INFO) << "OnSuspended";
-}
-
-void GobiModem::OnResumed() {
-  // cromo always call this method after OnSuspended either due to a resume
-  // event or due to a suspend completion timeout.
-  LOG(INFO) << "OnResumed";
-  suspending_ = false;
-}
-
-void GobiModem::RegisterStartSuspend(const std::string &name) {
-  // TODO(ellyjones): Get maxdelay_ms from the carrier plugin
-  static const int maxdelay_ms = 10000;
-  handler_->server().RegisterStartSuspend(name, StartSuspendTrampoline, this,
-                                          maxdelay_ms);
-}
-
 // Tokenizes a string of the form (<[+-]ident>)* into a list of strings of the
 // form [+-]ident.
 static std::vector<std::string> TokenizeRequest(const std::string& req) {
@@ -1868,10 +1802,6 @@
 
 void GobiModem::ExitAndResetDevice(ULONG reason) {
   ApiDisconnect();
-  if (suspending_) {
-    LOG(ERROR) << "Already suspending " << static_cast<std::string>(path());
-    return;
-  }
   if (reason)
     RecordResetReason(reason);
 
diff --git a/gobi_modem.h b/gobi_modem.h
index fea637e..bc2bd38 100644
--- a/gobi_modem.h
+++ b/gobi_modem.h
@@ -455,7 +455,6 @@
   static GobiModem *connected_modem_;
   static mutex_wrapper_ modem_mutex_;
 
-  bool suspending_;
   bool exiting_;
   bool device_resetting_;
   bool getting_deallocated_;
@@ -490,11 +489,6 @@
   ULONG ForceDisconnect();
   bool StartExit();
   bool ExitOk();
-  bool StartSuspend();
-  bool SuspendOk();
-  void OnSuspended();
-  void OnResumed();
-  void RegisterStartSuspend(const std::string& name);
 
   // Resets the device by kicking it off the USB and allowing it back
   // on.  Reason is a QCWWAN error code for logging/metrics, or 0 for
@@ -509,10 +503,6 @@
 
   friend bool StartExitTrampoline(void *arg);
   friend bool ExitOkTrampoline(void *arg);
-  friend bool StartSuspendTrampoline(void *arg);
-  friend bool SuspendOkTrampoline(void *arg);
-  friend bool OnSuspendedTrampoline(void *arg);
-  friend bool OnResumedTrampoline(void *arg);
 
   scoped_ptr<MetricsLibraryInterface> metrics_lib_;