shill: Set the cellular service friendly name.
BUG=chromium-os:24897
TEST=unit tests, tested on device with GSM
Change-Id: I2fe803822f2ddc5c52daddcf625b3327f95563ad
Reviewed-on: https://gerrit.chromium.org/gerrit/13933
Commit-Ready: Darin Petkov <petkov@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Darin Petkov <petkov@chromium.org>
diff --git a/cellular_capability_gsm.cc b/cellular_capability_gsm.cc
index 6fb10aa..99ef442 100644
--- a/cellular_capability_gsm.cc
+++ b/cellular_capability_gsm.cc
@@ -7,6 +7,7 @@
#include <base/logging.h>
#include <base/stl_util-inl.h>
#include <base/string_number_conversions.h>
+#include <base/stringprintf.h>
#include <chromeos/dbus/service_constants.h>
#include <mm/mm-modem.h>
#include <mobile_provider.h>
@@ -21,6 +22,9 @@
namespace shill {
+// static
+unsigned int CellularCapabilityGSM::friendly_service_name_id_ = 0;
+
const char CellularCapabilityGSM::kNetworkPropertyAccessTechnology[] =
"access-tech";
const char CellularCapabilityGSM::kNetworkPropertyID[] = "operator-num";
@@ -179,6 +183,24 @@
VLOG(2) << "GSM AccessTechnology: " << tech;
}
+string CellularCapabilityGSM::CreateFriendlyServiceName() {
+ VLOG(2) << __func__;
+ if (registration_state_ == MM_MODEM_GSM_NETWORK_REG_STATUS_HOME &&
+ !cellular()->home_provider().GetName().empty()) {
+ return cellular()->home_provider().GetName();
+ }
+ if (!serving_operator_.GetName().empty()) {
+ return serving_operator_.GetName();
+ }
+ if (!cellular()->carrier().empty()) {
+ return cellular()->carrier();
+ }
+ if (!serving_operator_.GetCode().empty()) {
+ return "cellular_" + serving_operator_.GetCode();
+ }
+ return base::StringPrintf("GSMNetwork%u", friendly_service_name_id_++);
+}
+
void CellularCapabilityGSM::SetHomeProvider() {
VLOG(2) << __func__ << "(IMSI: " << cellular()->imsi()
<< " SPN: " << spn_ << ")";