shill: suppress spurioius notifications
Suppress spurioius notifications of the Cellular.Family when
ModemManager reports changes in AccessTechnology that do not cause
changes to the Cellular.Family.
BUG=chromium-os:31114
TEST=use dbus-monitor --system to watch signals
Change-Id: I4404093575e3fb81ad6b609809a1554396230750
Reviewed-on: https://gerrit.chromium.org/gerrit/23144
Tested-by: Jason Glasgow <jglasgow@chromium.org>
Reviewed-by: Gary Morain <gmorain@chromium.org>
Commit-Ready: Jason Glasgow <jglasgow@chromium.org>
diff --git a/cellular_capability_universal.cc b/cellular_capability_universal.cc
index 975f639..475cf48 100644
--- a/cellular_capability_universal.cc
+++ b/cellular_capability_universal.cc
@@ -1036,12 +1036,15 @@
void CellularCapabilityUniversal::OnAccessTechnologiesChanged(
uint32 access_technologies) {
if (access_technologies_ != access_technologies) {
+ const string old_type_string(GetTypeString());
access_technologies_ = access_technologies;
- // TODO(jglasgow): address layering violation of emitting change
- // signal here for a property owned by Cellular.
- cellular()->adaptor()->EmitStringChanged(
- flimflam::kTechnologyFamilyProperty,
- GetTypeString());
+ const string new_type_string(GetTypeString());
+ if (new_type_string != old_type_string) {
+ // TODO(jglasgow): address layering violation of emitting change
+ // signal here for a property owned by Cellular.
+ cellular()->adaptor()->EmitStringChanged(
+ flimflam::kTechnologyFamilyProperty, new_type_string);
+ }
if (cellular()->service().get()) {
cellular()->service()->SetNetworkTechnology(GetNetworkTechnologyString());
}
diff --git a/cellular_capability_universal_unittest.cc b/cellular_capability_universal_unittest.cc
index b504943..7a8d3df 100644
--- a/cellular_capability_universal_unittest.cc
+++ b/cellular_capability_universal_unittest.cc
@@ -371,6 +371,8 @@
EXPECT_EQ(MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN,
capability_->access_technologies_);
EXPECT_FALSE(capability_->sim_proxy_.get());
+ EXPECT_CALL(*device_adaptor_, EmitStringChanged(
+ flimflam::kTechnologyFamilyProperty, flimflam::kTechnologyFamilyGsm));
capability_->OnDBusPropertiesChanged(MM_DBUS_INTERFACE_MODEM,
modem_properties, vector<string>());
EXPECT_EQ(kAccessTechnologies, capability_->access_technologies_);
@@ -389,6 +391,37 @@
modem3gpp_properties,
vector<string>());
EXPECT_EQ(kImei, capability_->imei_);
+
+ // Expect to see changes when the family changes
+ modem_properties.clear();
+ modem_properties[MM_MODEM_PROPERTY_ACCESSTECHNOLOGIES].
+ writer().append_uint32(MM_MODEM_ACCESS_TECHNOLOGY_1XRTT);
+ EXPECT_CALL(*device_adaptor_, EmitStringChanged(
+ flimflam::kTechnologyFamilyProperty, flimflam::kTechnologyFamilyCdma)).
+ Times(1);
+ capability_->OnDBusPropertiesChanged(MM_DBUS_INTERFACE_MODEM,
+ modem_properties,
+ vector<string>());
+ // Back to LTE
+ modem_properties.clear();
+ modem_properties[MM_MODEM_PROPERTY_ACCESSTECHNOLOGIES].
+ writer().append_uint32(MM_MODEM_ACCESS_TECHNOLOGY_LTE);
+ EXPECT_CALL(*device_adaptor_, EmitStringChanged(
+ flimflam::kTechnologyFamilyProperty, flimflam::kTechnologyFamilyGsm)).
+ Times(1);
+ capability_->OnDBusPropertiesChanged(MM_DBUS_INTERFACE_MODEM,
+ modem_properties,
+ vector<string>());
+
+ // LTE & CDMA - the device adaptor should not be called!
+ modem_properties.clear();
+ modem_properties[MM_MODEM_PROPERTY_ACCESSTECHNOLOGIES].
+ writer().append_uint32(MM_MODEM_ACCESS_TECHNOLOGY_LTE |
+ MM_MODEM_ACCESS_TECHNOLOGY_1XRTT);
+ EXPECT_CALL(*device_adaptor_, EmitStringChanged(_, _)).Times(0);
+ capability_->OnDBusPropertiesChanged(MM_DBUS_INTERFACE_MODEM,
+ modem_properties,
+ vector<string>());
}
TEST_F(CellularCapabilityUniversalTest, SimPropertiesChanged) {