shill: Register the modem, create service and obtain signal strength.

Also, listen for registration info and signal quality change notifications.

BUG=chromium-os:18315
TEST=unit tests, tested on device

Change-Id: I19e5e97257bc53f2004d6b7f0606da2553be4b5d
Reviewed-on: http://gerrit.chromium.org/gerrit/5328
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Darin Petkov <petkov@chromium.org>
diff --git a/cellular.h b/cellular.h
index a88cb09..4f8efbf 100644
--- a/cellular.h
+++ b/cellular.h
@@ -11,16 +11,17 @@
 #include <gtest/gtest_prod.h>  // for FRIEND_TEST
 
 #include "shill/device.h"
+#include "shill/modem_cdma_proxy_interface.h"
 #include "shill/refptr_types.h"
 #include "shill/shill_event.h"
 
 namespace shill {
 
-class ModemCDMAProxyInterface;
 class ModemProxyInterface;
 class ModemSimpleProxyInterface;
 
-class Cellular : public Device {
+class Cellular : public Device,
+                 public ModemCDMAProxyListener {
  public:
   enum Type {
     kTypeGSM,
@@ -98,6 +99,7 @@
 
  private:
   FRIEND_TEST(CellularTest, GetCDMARegistrationState);
+  FRIEND_TEST(CellularTest, GetCDMASignalQuality);
   FRIEND_TEST(CellularTest, GetModemInfo);
   FRIEND_TEST(CellularTest, GetModemStatus);
   FRIEND_TEST(CellularTest, GetStateString);
@@ -124,19 +126,40 @@
   void GetModemStatus();
   void GetGSMProperties();
   void RegisterGSMModem();
-  void ReportEnabled();
 
   // Obtains the modem identifiers: MEID for CDMA; IMEI, IMSI, SPN and MSISDN
   // for GSM.
   void GetModemIdentifiers();
 
-  // Obtain modem's manufacturer, model ID, and hardware revision.
+  // Obtains modem's manufacturer, model ID, and hardware revision.
   void GetModemInfo();
 
   void GetModemRegistrationState();
   void GetCDMARegistrationState();
   void GetGSMRegistrationState();
 
+  // Processes a change in the modem registration state, possibly creating,
+  // destroying or updating the CellularService.
+  void HandleNewRegistrationState();
+
+  void CreateService();
+
+  void GetModemSignalQuality();
+  uint32 GetCDMASignalQuality();
+  uint32 GetGSMSignalQuality();
+
+  void HandleNewSignalQuality(uint32 strength);
+
+  // Returns true if the modem is registered. Note that this method looks at the
+  // latest CDMA/GSM registration info obtained from the modem rather than the
+  // device |state_|.
+  bool IsModemRegistered();
+
+  // Signal callbacks from ModemCDMAProxyListener.
+  virtual void OnCDMARegistrationStateChanged(uint32 state_1x,
+                                              uint32 state_evdo);
+  virtual void OnCDMASignalQualityChanged(uint32 strength);
+
   Type type_;
   State state_;
 
@@ -148,7 +171,7 @@
 
   CDMA cdma_;
 
-  ServiceRefPtr service_;
+  CellularServiceRefPtr service_;
   bool service_registered_;
 
   // Properties