Merge lp:~charlesk/indicator-datetime/lp-1434637-make-alarms-use-less-battery into lp:indicator-datetime/15.04

Proposed by Charles Kerr
Status: Merged
Approved by: Ted Gould
Approved revision: 409
Merged at revision: 406
Proposed branch: lp:~charlesk/indicator-datetime/lp-1434637-make-alarms-use-less-battery
Merge into: lp:indicator-datetime/15.04
Diff against target: 167 lines (+51/-18)
3 files modified
data/com.canonical.indicator.datetime.gschema.xml.in (+1/-1)
src/awake.cpp (+49/-16)
tests/test-exporter.cpp (+1/-1)
To merge this branch: bzr merge lp:~charlesk/indicator-datetime/lp-1434637-make-alarms-use-less-battery
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Ted Gould (community) Approve
Review via email: mp+254823@code.launchpad.net

Commit message

Reduce the forced screen-on time for alarms to reduce battery consumption. Also, lower the default alarm duration from 30 minutes to 10 minutes.

Description of the change

== Description of change

1. Change the default alarm duration from 30 minutes to 10 minutes.

2. Force the screen on when an alarm goes off, but release the force so that, if the phone is not touched, it will dim after 30 seconds and turn off after 60 seconds, just like it would if you'd woken it up yourself.

== Checklist

> Are there any related MPs required for this MP to build/function as expected? Please list.

No

> Is your branch in sync with latest trunk? (e.g. bzr pull lp:trunk -> no changes)

Yes

> Did the code build without warnings?

Yes

> Did the tests run successfully?

Yes

> Did you perform an exploratory manual test run of your code change and any related functionality?

Yes

> If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?

N/A

> What device (or emulator) has your component test plan been executed successfully on?

mako vivid r150

> What manual tests are relevant for this MP?

indicator-datetime/new-alarm-wakeup

> Did you include a link to the MR Review Checklist Template to make your reviewer's life easier?

https://wiki.ubuntu.com/Process/Merges/Checklists/indicator-datetime

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

Looks Good. Got a bit confused on the C++ object being called self :-)

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/com.canonical.indicator.datetime.gschema.xml.in'
2--- data/com.canonical.indicator.datetime.gschema.xml.in 2014-09-02 15:37:03 +0000
3+++ data/com.canonical.indicator.datetime.gschema.xml.in 2015-03-31 19:43:30 +0000
4@@ -148,7 +148,7 @@
5 </key>
6 <key name="alarm-duration-minutes" type="u">
7 <range min="1" max="60"/>
8- <default>30</default>
9+ <default>10</default>
10 <_summary>The alarm's duration.</_summary>
11 <_description>
12 How long the alarm's sound will be looped if its snap decision is not dismissed by the user.
13
14=== modified file 'src/awake.cpp'
15--- src/awake.cpp 2014-07-27 16:01:30 +0000
16+++ src/awake.cpp 2015-03-31 19:43:30 +0000
17@@ -48,10 +48,16 @@
18 g_cancellable_cancel (m_cancellable);
19 g_object_unref (m_cancellable);
20
21+ if (m_display_on_timer)
22+ {
23+ g_source_remove (m_display_on_timer);
24+ m_display_on_timer = 0;
25+ }
26+
27 if (m_system_bus != nullptr)
28 {
29 unforce_awake ();
30- unforce_screen ();
31+ remove_display_on_request ();
32 g_object_unref (m_system_bus);
33 }
34 }
35@@ -106,7 +112,7 @@
36 G_DBUS_CALL_FLAGS_NONE,
37 -1,
38 self->m_cancellable,
39- on_force_screen_response,
40+ on_keep_display_on_response,
41 self);
42
43 g_object_unref (system_bus);
44@@ -146,9 +152,9 @@
45 }
46 }
47
48- static void on_force_screen_response (GObject * connection,
49- GAsyncResult * res,
50- gpointer gself)
51+ static void on_keep_display_on_response (GObject * connection,
52+ GAsyncResult * res,
53+ gpointer gself)
54 {
55 GError * error;
56 GVariant * args;
57@@ -171,14 +177,29 @@
58 {
59 auto self = static_cast<Impl*>(gself);
60
61- self->m_screen_cookie = NO_SCREEN_COOKIE;
62- g_variant_get (args, "(i)", &self->m_screen_cookie);
63- g_debug ("m_screen_cookie is now '%d'", self->m_screen_cookie);
64+ self->m_display_on_cookie = NO_DISPLAY_ON_COOKIE;
65+ g_variant_get (args, "(i)", &self->m_display_on_cookie);
66+ g_debug ("m_display_on_cookie is now '%d'", self->m_display_on_cookie);
67+
68+ self->m_display_on_timer = g_timeout_add_seconds (self->m_display_on_seconds,
69+ on_display_on_timer,
70+ gself);
71
72 g_variant_unref (args);
73 }
74 }
75
76+ static gboolean on_display_on_timer (gpointer gself)
77+ {
78+ auto self = static_cast<Impl*>(gself);
79+
80+ self->m_display_on_timer = 0;
81+ self->remove_display_on_request();
82+
83+ return G_SOURCE_REMOVE;
84+ }
85+
86+
87 void unforce_awake ()
88 {
89 g_return_if_fail (G_IS_DBUS_CONNECTION(m_system_bus));
90@@ -202,18 +223,18 @@
91 }
92 }
93
94- void unforce_screen ()
95+ void remove_display_on_request ()
96 {
97 g_return_if_fail (G_IS_DBUS_CONNECTION(m_system_bus));
98
99- if (m_screen_cookie != NO_SCREEN_COOKIE)
100+ if (m_display_on_cookie != NO_DISPLAY_ON_COOKIE)
101 {
102 g_dbus_connection_call (m_system_bus,
103 BUS_SCREEN_NAME,
104 BUS_SCREEN_PATH,
105 BUS_SCREEN_INTERFACE,
106 "removeDisplayOnRequest",
107- g_variant_new("(i)", m_screen_cookie),
108+ g_variant_new("(i)", m_display_on_cookie),
109 nullptr,
110 G_DBUS_CALL_FLAGS_NONE,
111 -1,
112@@ -221,7 +242,7 @@
113 nullptr,
114 nullptr);
115
116- m_screen_cookie = NO_SCREEN_COOKIE;
117+ m_display_on_cookie = NO_DISPLAY_ON_COOKIE;
118 }
119 }
120
121@@ -229,9 +250,21 @@
122 GCancellable * m_cancellable = nullptr;
123 GDBusConnection * m_system_bus = nullptr;
124 char * m_awake_cookie = nullptr;
125- int32_t m_screen_cookie = NO_SCREEN_COOKIE;
126-
127- static constexpr int32_t NO_SCREEN_COOKIE { std::numeric_limits<int32_t>::min() };
128+
129+ /**
130+ * As described by bug #1434637, alarms should have the display turn on,
131+ * dim, and turn off "just like it would if you'd woken it up yourself".
132+ * USC may be adding an intent-based bus API to handle this use case,
133+ * e.g. turnDisplayOnTemporarily(intent), but there's no timeframe for it.
134+ *
135+ * Until that's avaialble, we can get close to Design's specs by
136+ * requesting a display-on cookie and then releasing the cookie
137+ * a moment later. */
138+ const guint m_display_on_seconds = 1;
139+ guint m_display_on_timer = 0;
140+ int32_t m_display_on_cookie = NO_DISPLAY_ON_COOKIE;
141+
142+ static constexpr int32_t NO_DISPLAY_ON_COOKIE { std::numeric_limits<int32_t>::min() };
143 };
144
145 /***
146@@ -239,7 +272,7 @@
147 ***/
148
149 Awake::Awake(const std::string& app_name):
150- impl(new Impl (app_name))
151+ impl(new Impl(app_name))
152 {
153 }
154
155
156=== modified file 'tests/test-exporter.cpp'
157--- tests/test-exporter.cpp 2014-09-17 16:51:51 +0000
158+++ tests/test-exporter.cpp 2015-03-31 19:43:30 +0000
159@@ -222,7 +222,7 @@
160 g_clear_pointer (&haptic, g_free);
161
162 /***
163- **** Try chaning the DBus properties -- do the Settings change to match it?
164+ **** Try changing the DBus properties -- do the Settings change to match it?
165 ***/
166
167 expected_volume = 100;

Subscribers

People subscribed via source and target branches