shill: cellular: Root path for the SIM path should be regarded as no SIM.
According to the ModemManager1 spec, the root path ("/"), as a value for
the SIM path means that no SIM is present. CellularCapabilityUniversal
will now set the Cellular.SIMPresent property to |false| if it observes
that the SIM path has changed to "/".
BUG=chromium-os:38496
TEST=1. Build and run unit tests.
2. Remove SIM. Check 'connectivity show Devices' and verify that
Cellular.SIMPresent property is set to |false|.
Change-Id: I29dcfb7788da04d211f6886495e8e78438fbce40
Reviewed-on: https://gerrit.chromium.org/gerrit/43140
Commit-Queue: Arman Uguray <armansito@chromium.org>
Reviewed-by: Arman Uguray <armansito@chromium.org>
Tested-by: Arman Uguray <armansito@chromium.org>
diff --git a/cellular_capability_universal.cc b/cellular_capability_universal.cc
index 445606a..4db03a0 100644
--- a/cellular_capability_universal.cc
+++ b/cellular_capability_universal.cc
@@ -56,6 +56,7 @@
60000;
const char CellularCapabilityUniversal::kGenericServiceNamePrefix[] =
"Mobile Network";
+const char CellularCapabilityUniversal::kRootPath[] = "/";
const char CellularCapabilityUniversal::kStatusProperty[] = "status";
const char CellularCapabilityUniversal::kOperatorLongProperty[] =
"operator-long";
@@ -1268,19 +1269,23 @@
NOTIMPLEMENTED();
}
+bool CellularCapabilityUniversal::IsValidSimPath(const string &sim_path) const {
+ return !sim_path.empty() && sim_path != kRootPath;
+}
+
void CellularCapabilityUniversal::OnSimPathChanged(
const string &sim_path) {
if (sim_path == sim_path_)
return;
mm1::SimProxyInterface *proxy = NULL;
- if (!sim_path.empty())
+ if (IsValidSimPath(sim_path))
proxy = proxy_factory()->CreateSimProxy(sim_path,
cellular()->dbus_owner());
sim_path_ = sim_path;
sim_proxy_.reset(proxy);
- if (sim_path.empty()) {
+ if (!IsValidSimPath(sim_path)) {
// Clear all data about the sim
imsi_ = "";
spn_ = "";