shill: Fix the cellular service storage identifier.

This CL fixes a few issues:

- It bases the default cellular service storage identifier on the friendly
  service name.

- If service is GSM and IMSI is available, use it instead of the friendly name.

- Fix a bug where all legal characters in the storage identifier were replaced
  by "_" (rather than all illegal characters).

BUG=chromium-os:24952
TEST=unit tests

Change-Id: Ie55cb2b4f2dafb73545ac285a57674063946ceb3
Reviewed-on: https://gerrit.chromium.org/gerrit/15151
Tested-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: Eric Shienbrood <ers@chromium.org>
Commit-Ready: Darin Petkov <petkov@chromium.org>
diff --git a/cellular_service.cc b/cellular_service.cc
index e7eaf6d..100c947 100644
--- a/cellular_service.cc
+++ b/cellular_service.cc
@@ -43,6 +43,7 @@
   store->RegisterConstString(flimflam::kUsageURLProperty, &usage_url_);
 
   set_friendly_name(device->CreateFriendlyServiceName());
+  SetStorageIdentifier("cellular_" + device->address() + "_" + friendly_name());
 }
 
 CellularService::~CellularService() { }
@@ -66,14 +67,15 @@
   return cellular_->TechnologyIs(type);
 }
 
+void CellularService::SetStorageIdentifier(const string &identifier) {
+  storage_identifier_ = identifier;
+  std::replace_if(storage_identifier_.begin(),
+                  storage_identifier_.end(),
+                  &Service::IllegalChar, '_');
+}
+
 string CellularService::GetStorageIdentifier() const {
-  // TODO(petkov): Fix the return value (crosbug.com/24952).
-  string id = base::StringPrintf("%s_%s_%s",
-                                 kServiceType,
-                                 cellular_->address().c_str(),
-                                 serving_operator_.GetName().c_str());
-  std::replace_if(id.begin(), id.end(), &Service::LegalChar, '_');
-  return id;
+  return storage_identifier_;
 }
 
 string CellularService::GetDeviceRpcId(Error */*error*/) {