aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2015-03-31 20:25:34 +0000
committerCI Train Bot <ci-train-bot@canonical.com>2015-03-31 20:25:34 +0000
commit6805440001a674e2700f344bc0113f11ee394a82 (patch)
tree94f6104d71d25f2c000d4fa67880b895ab71c90e
parent3c5eda144d9d83be1aef24afaa307999975ec617 (diff)
parent845067b3f37ff48eab3b612d52518e529559b738 (diff)
downloadayatana-indicator-datetime-6805440001a674e2700f344bc0113f11ee394a82.tar.gz
ayatana-indicator-datetime-6805440001a674e2700f344bc0113f11ee394a82.tar.bz2
ayatana-indicator-datetime-6805440001a674e2700f344bc0113f11ee394a82.zip
Reduce the forced screen-on time for alarms to reduce battery consumption. Also, lower the default alarm duration from 30 minutes to 10 minutes. Fixes: #1434637
Approved by: Ted Gould, PS Jenkins bot
-rw-r--r--data/com.canonical.indicator.datetime.gschema.xml.in2
-rw-r--r--src/awake.cpp63
-rw-r--r--tests/test-exporter.cpp2
3 files changed, 50 insertions, 17 deletions
diff --git a/data/com.canonical.indicator.datetime.gschema.xml.in b/data/com.canonical.indicator.datetime.gschema.xml.in
index edcede2..044f694 100644
--- a/data/com.canonical.indicator.datetime.gschema.xml.in
+++ b/data/com.canonical.indicator.datetime.gschema.xml.in
@@ -148,7 +148,7 @@
</key>
<key name="alarm-duration-minutes" type="u">
<range min="1" max="60"/>
- <default>30</default>
+ <default>10</default>
<_summary>The alarm's duration.</_summary>
<_description>
How long the alarm's sound will be looped if its snap decision is not dismissed by the user.
diff --git a/src/awake.cpp b/src/awake.cpp
index 57358ab..e1bec6c 100644
--- a/src/awake.cpp
+++ b/src/awake.cpp
@@ -48,10 +48,16 @@ public:
g_cancellable_cancel (m_cancellable);
g_object_unref (m_cancellable);
+ if (m_display_on_timer)
+ {
+ g_source_remove (m_display_on_timer);
+ m_display_on_timer = 0;
+ }
+
if (m_system_bus != nullptr)
{
unforce_awake ();
- unforce_screen ();
+ remove_display_on_request ();
g_object_unref (m_system_bus);
}
}
@@ -106,7 +112,7 @@ private:
G_DBUS_CALL_FLAGS_NONE,
-1,
self->m_cancellable,
- on_force_screen_response,
+ on_keep_display_on_response,
self);
g_object_unref (system_bus);
@@ -146,9 +152,9 @@ private:
}
}
- static void on_force_screen_response (GObject * connection,
- GAsyncResult * res,
- gpointer gself)
+ static void on_keep_display_on_response (GObject * connection,
+ GAsyncResult * res,
+ gpointer gself)
{
GError * error;
GVariant * args;
@@ -171,14 +177,29 @@ private:
{
auto self = static_cast<Impl*>(gself);
- self->m_screen_cookie = NO_SCREEN_COOKIE;
- g_variant_get (args, "(i)", &self->m_screen_cookie);
- g_debug ("m_screen_cookie is now '%d'", self->m_screen_cookie);
+ self->m_display_on_cookie = NO_DISPLAY_ON_COOKIE;
+ g_variant_get (args, "(i)", &self->m_display_on_cookie);
+ g_debug ("m_display_on_cookie is now '%d'", self->m_display_on_cookie);
+
+ self->m_display_on_timer = g_timeout_add_seconds (self->m_display_on_seconds,
+ on_display_on_timer,
+ gself);
g_variant_unref (args);
}
}
+ static gboolean on_display_on_timer (gpointer gself)
+ {
+ auto self = static_cast<Impl*>(gself);
+
+ self->m_display_on_timer = 0;
+ self->remove_display_on_request();
+
+ return G_SOURCE_REMOVE;
+ }
+
+
void unforce_awake ()
{
g_return_if_fail (G_IS_DBUS_CONNECTION(m_system_bus));
@@ -202,18 +223,18 @@ private:
}
}
- void unforce_screen ()
+ void remove_display_on_request ()
{
g_return_if_fail (G_IS_DBUS_CONNECTION(m_system_bus));
- if (m_screen_cookie != NO_SCREEN_COOKIE)
+ if (m_display_on_cookie != NO_DISPLAY_ON_COOKIE)
{
g_dbus_connection_call (m_system_bus,
BUS_SCREEN_NAME,
BUS_SCREEN_PATH,
BUS_SCREEN_INTERFACE,
"removeDisplayOnRequest",
- g_variant_new("(i)", m_screen_cookie),
+ g_variant_new("(i)", m_display_on_cookie),
nullptr,
G_DBUS_CALL_FLAGS_NONE,
-1,
@@ -221,7 +242,7 @@ private:
nullptr,
nullptr);
- m_screen_cookie = NO_SCREEN_COOKIE;
+ m_display_on_cookie = NO_DISPLAY_ON_COOKIE;
}
}
@@ -229,9 +250,21 @@ private:
GCancellable * m_cancellable = nullptr;
GDBusConnection * m_system_bus = nullptr;
char * m_awake_cookie = nullptr;
- int32_t m_screen_cookie = NO_SCREEN_COOKIE;
- static constexpr int32_t NO_SCREEN_COOKIE { std::numeric_limits<int32_t>::min() };
+ /**
+ * As described by bug #1434637, alarms should have the display turn on,
+ * dim, and turn off "just like it would if you'd woken it up yourself".
+ * USC may be adding an intent-based bus API to handle this use case,
+ * e.g. turnDisplayOnTemporarily(intent), but there's no timeframe for it.
+ *
+ * Until that's avaialble, we can get close to Design's specs by
+ * requesting a display-on cookie and then releasing the cookie
+ * a moment later. */
+ const guint m_display_on_seconds = 1;
+ guint m_display_on_timer = 0;
+ int32_t m_display_on_cookie = NO_DISPLAY_ON_COOKIE;
+
+ static constexpr int32_t NO_DISPLAY_ON_COOKIE { std::numeric_limits<int32_t>::min() };
};
/***
@@ -239,7 +272,7 @@ private:
***/
Awake::Awake(const std::string& app_name):
- impl(new Impl (app_name))
+ impl(new Impl(app_name))
{
}
diff --git a/tests/test-exporter.cpp b/tests/test-exporter.cpp
index be8fcc3..d5118ac 100644
--- a/tests/test-exporter.cpp
+++ b/tests/test-exporter.cpp
@@ -222,7 +222,7 @@ TEST_F(ExporterFixture, AlarmProperties)
g_clear_pointer (&haptic, g_free);
/***
- **** Try chaning the DBus properties -- do the Settings change to match it?
+ **** Try changing the DBus properties -- do the Settings change to match it?
***/
expected_volume = 100;