PM: Shift to signal-based inference of network connection.
Instead of making DBus calls to shill on-demand, and estimating the time
a connection has changed, the RealShillProvider now listens to the
appropriate DBus signal and update its internal state accordingly. Note
that checking for the connection type still requires a DBus call, if the
connection has changed since its type was last checked.
In order to pass all unit tests (including those of PolicyManager and
RealState), there's a substantial portion of DBus mock set up code that
was added. This code will be removed very soon, once we begin injecting
providers into RealState, instead of low-level DBus and/or clock
interfaces.
BUG=chromium:338585
TEST=Unit tests.
Change-Id: Ia7a2f9db18f905f1b7a2cc1234acb31eaa60009e
Reviewed-on: https://chromium-review.googlesource.com/189692
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
diff --git a/real_dbus_wrapper.h b/real_dbus_wrapper.h
index ab7a969..4d31651 100644
--- a/real_dbus_wrapper.h
+++ b/real_dbus_wrapper.h
@@ -56,6 +56,29 @@
G_TYPE_INVALID, G_TYPE_INVALID);
}
+ virtual void ProxyAddSignal_2(DBusGProxy* proxy,
+ const char* signal_name,
+ GType type1,
+ GType type2) {
+ dbus_g_proxy_add_signal(proxy, signal_name, type1, type2, G_TYPE_INVALID);
+ }
+
+ virtual void ProxyConnectSignal(DBusGProxy* proxy,
+ const char* signal_name,
+ GCallback handler,
+ void* data,
+ GClosureNotify free_data_func) {
+ dbus_g_proxy_connect_signal(proxy, signal_name, handler, data,
+ free_data_func);
+ }
+
+ virtual void ProxyDisconnectSignal(DBusGProxy* proxy,
+ const char* signal_name,
+ GCallback handler,
+ void* data) {
+ dbus_g_proxy_disconnect_signal(proxy, signal_name, handler, data);
+ }
+
virtual DBusConnection* ConnectionGetConnection(DBusGConnection* gbus) {
return dbus_g_connection_get_connection(gbus);
}