shill: cellular: Update storage identifier based on SID for CDMA.

BUG=chromium:297396
TEST=Build and run unit tests.

Change-Id: Id463eb819b2778a91945eb9987532bb338ebdbbc
Reviewed-on: https://chromium-review.googlesource.com/170422
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Arman Uguray <armansito@chromium.org>
Commit-Queue: Arman Uguray <armansito@chromium.org>
diff --git a/cellular_capability_universal_cdma.cc b/cellular_capability_universal_cdma.cc
index cdb93d9..273abff 100644
--- a/cellular_capability_universal_cdma.cc
+++ b/cellular_capability_universal_cdma.cc
@@ -188,10 +188,28 @@
   return (activation_state_ == MM_MODEM_CDMA_ACTIVATION_STATE_ACTIVATED);
 }
 
+void CellularCapabilityUniversalCDMA::UpdateStorageIdentifier() {
+  if (!cellular()->service().get())
+    return;
+
+  // Lookup the unique identifier assigned to the current network and base the
+  // service's storage identifier on it.
+  const CellularOperatorInfo::CellularOperator *provider =
+      modem_info()->cellular_operator_info()->GetCellularOperatorBySID(
+          UintToString(sid_));
+  if (!provider || provider->identifier().empty())
+    // Don't update the identifier if a better one could not be built. The
+    // default identifier initialized in cellular_service.cc still applies
+    // here.
+    return;
+  cellular()->service()->SetStorageIdentifier(
+      string(shill::kTypeCellular) + "_" + cellular()->address() +
+      "_" + provider->identifier());
+}
+
 void CellularCapabilityUniversalCDMA::OnServiceCreated() {
   SLOG(Cellular, 2) << __func__;
-  // TODO (armansito): Set storage identifier here  based on the superclass
-  // implementation.
+  UpdateStorageIdentifier();
   UpdateServiceActivationStateProperty();
   UpdateServingOperator();
   HandleNewActivationStatus(MM_CDMA_ACTIVATION_ERROR_NONE);