Merge lp:~afrantzis/unity-system-compositor/voice-call-proximity-over-0.1 into lp:unity-system-compositor/ubuntu

Proposed by Alexandros Frantzis
Status: Rejected
Rejected by: Alexandros Frantzis
Proposed branch: lp:~afrantzis/unity-system-compositor/voice-call-proximity-over-0.1
Merge into: lp:unity-system-compositor/ubuntu
Diff against target: 587 lines (+362/-18) (has conflicts)
7 files modified
debian/changelog (+16/-3)
src/mir_screen.cpp (+47/-10)
src/mir_screen.h (+6/-2)
src/power_state_change_reason.h (+3/-1)
src/server.cpp (+6/-1)
src/server.h (+14/-0)
tests/unit-tests/test_mir_screen.cpp (+270/-1)
Text conflict in debian/changelog
To merge this branch: bzr merge lp:~afrantzis/unity-system-compositor/voice-call-proximity-over-0.1
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Unity System Compositor Development Team Pending
Review via email: mp+272381@code.launchpad.net

This proposal supersedes a proposal from 2015-09-25.

Commit message

Screen blanking/proximity handling improvements for voice calls.

Description of the change

Screen blanking/proximity handling improvements for voice calls.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
kevin gunn (kgunn72) wrote : Posted in a previous version of this proposal

so after testing, i get proximity blanking for the text messages.
but i do not get proximity blanking for the incoming voice call notification.
is that what i'm supposed to see ?
i'm on arale.

Revision history for this message
Alexandros Frantzis (afrantzis) wrote : Posted in a previous version of this proposal

> so after testing, i get proximity blanking for the text messages.
> but i do not get proximity blanking for the incoming voice call notification.
> is that what i'm supposed to see ?
> i'm on arale.

No, you should also get proximity blanking for voice call notifications. This used to work, so I figured something must have changed outside USC/powerd.

After some investigation I found that the problem is the new notification handling logic in Unity8. With the new logic Unity8 sends a "turn screen on" message with reason "unknown" when a snap decision prompt is shown. This confuses USC because it has already got a "call" notification from powerd.

Once again our distributed and uncoordinated power-management logic is making our lives difficult and is a constant source of bugs and fragility.

I need to think a bit more about how to solve this particular problem. Stay tuned.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
kevin gunn (kgunn72) wrote : Posted in a previous version of this proposal

retested with https://code.launchpad.net/~afrantzis/unity8/power-state-change-reason-snap-decision
it matched what i expected, I hammered on this pretty good.
I found only 2 cosmetic issues, and 1 issue that should likely be addressed (unless it's already a bug)

cosmetic issue 1: if a text or call occurs, screen is lit, no interaction it will dim. getting a call or text at that moment will not brighten the screen.

cosmetic issue 2: incoming call, cover and uncover proximity sensor quickly/rapidly and every now and then you will hear the audio stutter only very slightly

issue to fix: if you are on an active call and hit power button to blank screen, generate a second incoming call - as a user you have no idea this has occured, there is no vibra nor does the screen light. At least with a text the vibra will activate, but no lighting screen. The screen should probably light up in both these instances.

Revision history for this message
kevin gunn (kgunn72) wrote : Posted in a previous version of this proposal

cosmetic issues mentioned above should not prevent landing

Revision history for this message
kevin gunn (kgunn72) wrote : Posted in a previous version of this proposal

sorry for comments galore, i meant to also add if the last issue is already a bug, then I wouldn't consider it a blocker for landing this as this is a huge improvement.

Revision history for this message
Alexandros Frantzis (afrantzis) wrote : Posted in a previous version of this proposal

> retested with https://code.launchpad.net/~afrantzis/unity8/power-state-change-
> reason-snap-decision
> it matched what i expected, I hammered on this pretty good.

Thanks for testing!

> I found only 2 cosmetic issues, and 1 issue that should likely be addressed
> (unless it's already a bug)

> cosmetic issue 1: if a text or call occurs, screen is lit, no interaction it
> will dim. getting a call or text at that moment will not brighten the screen.

From a quick look at the related USC code, this should be easily fixable (Famous last words? Let's see... :) )

> cosmetic issue 2: incoming call, cover and uncover proximity sensor
> quickly/rapidly and every now and then you will hear the audio stutter only
> very slightly

Covering/uncovering the proximity sensor is an intensive task that involves cross process communication and the teardown and setup of our input and graphics subsystems in USC/Mir. I can't really see anything simple (i.e. as a bugfix) we can do to improve this on the USC side.

> issue to fix: if you are on an active call and hit power button to blank
> screen, generate a second incoming call - as a user you have no idea this has
> occured, there is no vibra nor does the screen light. At least with a text the
> vibra will activate, but no lighting screen. The screen should probably light
> up in both these instances.

This is indeed a regression. With the new code, when a call arrives, USC enables proximity handling and expects a proximity event with the initial proximity state. This is done in order to avoid turning on the screen for a moment if the proximity is "near". However, if proximity handling is already enabled (in this case because the dialer-app has enabled it) USC won't receive a proximity event with the initial state and won't turn on the screen. I am confident there is a way to improve this within our current architecture, but it will probably involve more communication between powerd and USC and more state keeping. I will experiment with a few approaches.

Note that when a second call arrives the users get a beeping noise in the call audio output, so they do get some notification.

Stay tuned!

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Silo 14 now contains fixes for "cosmetic issue 1" and "issue to fix". Let me know how the changes work for you.

Unmerged revisions

257. By Alexandros Frantzis

Sync with lp:mir/0.1

256. By Alexandros Frantzis

Set normal backlight when call or notifications arrive while the screen is on

255. By Alexandros Frantzis

Sync with lp:mir/0.1

254. By Alexandros Frantzis

Rename PowerStateChangeReason::call to PowerStateChangeReason::snap_decision

253. By Alexandros Frantzis

Update files for 0.1.2 release

252. By Alexandros Frantzis

Introduce a separate, fixed timeout pair for reason 'call'

251. By Alexandros Frantzis

Improve proximity handling during voice calls

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-09-22 16:44:54 +0000
3+++ debian/changelog 2015-09-25 12:02:53 +0000
4@@ -1,6 +1,19 @@
5-unity-system-compositor (0.1.2+15.10.20150922-0ubuntu1) wily; urgency=medium
6-
7- [ Cemil Azizoglu ]
8+<<<<<<< TREE
9+unity-system-compositor (0.1.2+15.10.20150922-0ubuntu1) wily; urgency=medium
10+
11+ [ Cemil Azizoglu ]
12+=======
13+unity-system-compositor (0.1.3) UNRELEASED; urgency=medium
14+
15+ * Introduce reasons 'snap_decision' and 'call_done' for turning on
16+ the screen when a call arrives and finishes, respectively (LP: #1291455)
17+
18+ -- Alexandros Frantzis <alexandros.frantzis@canonical.com> Fri, 11 Sep 2015 11:38:31 +0300
19+
20+unity-system-compositor (0.1.2+15.10.20150922-0ubuntu1) wily; urgency=medium
21+
22+ [ Cemil Azizoglu ]
23+>>>>>>> MERGE-SOURCE
24 * Rebuild for Mir 0.16
25
26 [ CI Train Bot ]
27
28=== modified file 'src/mir_screen.cpp'
29--- src/mir_screen.cpp 2015-08-24 18:14:36 +0000
30+++ src/mir_screen.cpp 2015-09-25 12:02:53 +0000
31@@ -40,7 +40,8 @@
32 std::shared_ptr<mir::time::AlarmFactory> const& alarm_factory,
33 std::shared_ptr<usc::Clock> const& clock,
34 Timeouts inactivity_timeouts,
35- Timeouts notification_timeouts)
36+ Timeouts notification_timeouts,
37+ Timeouts call_timeouts)
38 : screen_hardware{screen_hardware},
39 compositor{compositor},
40 display{display},
41@@ -53,10 +54,12 @@
42 std::bind(&usc::MirScreen::dimmer_alarm_notification, this))},
43 inactivity_timeouts(inactivity_timeouts),
44 notification_timeouts(notification_timeouts),
45+ call_timeouts(call_timeouts),
46 current_power_mode{MirPowerMode::mir_power_mode_on},
47 restart_timers{true},
48 power_state_change_handler{[](MirPowerMode,PowerStateChangeReason){}},
49- allow_proximity_to_turn_on_screen{false}
50+ allow_proximity_to_turn_on_screen{false},
51+ turned_on_by_user{true}
52 {
53 /*
54 * Make sure the compositor is running as certain conditions can
55@@ -144,14 +147,30 @@
56
57 // Notifications don't turn on the screen directly, they rely on proximity events
58 if (mode == MirPowerMode::mir_power_mode_on &&
59- reason == PowerStateChangeReason::notification)
60+ (reason == PowerStateChangeReason::notification ||
61+ reason == PowerStateChangeReason::snap_decision ||
62+ reason == PowerStateChangeReason::call_done))
63 {
64 if (current_power_mode != MirPowerMode::mir_power_mode_on)
65 {
66 allow_proximity_to_turn_on_screen = true;
67 screen_hardware->enable_proximity(true);
68 }
69- reset_timers_ignoring_power_mode_l(reason);
70+ else
71+ {
72+ screen_hardware->set_normal_backlight();
73+ }
74+
75+ if (reason == PowerStateChangeReason::call_done &&
76+ !turned_on_by_user)
77+ {
78+ reset_timers_ignoring_power_mode_l(reason, ForceResetTimers::yes);
79+ }
80+ else
81+ {
82+ reset_timers_ignoring_power_mode_l(reason, ForceResetTimers::no);
83+ }
84+
85 return;
86 }
87
88@@ -185,6 +204,12 @@
89 mode == mir_power_mode_off &&
90 reason != PowerStateChangeReason::power_key;
91
92+ if (mode == mir_power_mode_on)
93+ {
94+ turned_on_by_user =
95+ reason == PowerStateChangeReason::power_key;
96+ }
97+
98 std::shared_ptr<mg::DisplayConfiguration> displayConfig = display->configuration();
99
100 displayConfig->for_each_output(
101@@ -241,10 +266,11 @@
102 void usc::MirScreen::reset_timers_l(PowerStateChangeReason reason)
103 {
104 if (current_power_mode != MirPowerMode::mir_power_mode_off)
105- reset_timers_ignoring_power_mode_l(reason);
106+ reset_timers_ignoring_power_mode_l(reason, ForceResetTimers::no);
107 }
108
109-void usc::MirScreen::reset_timers_ignoring_power_mode_l(PowerStateChangeReason reason)
110+void usc::MirScreen::reset_timers_ignoring_power_mode_l(
111+ PowerStateChangeReason reason, ForceResetTimers force)
112 {
113 if (!restart_timers)
114 return;
115@@ -255,7 +281,7 @@
116 if (timeouts.power_off_timeout.count() > 0)
117 {
118 auto const new_next_power_off = now + timeouts.power_off_timeout;
119- if (new_next_power_off > next_power_off)
120+ if (new_next_power_off > next_power_off || force == ForceResetTimers::yes)
121 {
122 power_off_alarm->reschedule_in(timeouts.power_off_timeout);
123 next_power_off = new_next_power_off;
124@@ -270,7 +296,7 @@
125 if (timeouts.dimming_timeout.count() > 0)
126 {
127 auto const new_next_dimming = now + timeouts.dimming_timeout;
128- if (new_next_dimming > next_dimming)
129+ if (new_next_dimming > next_dimming || force == ForceResetTimers::yes)
130 {
131 dimmer_alarm->reschedule_in(timeouts.dimming_timeout);
132 next_dimming = new_next_dimming;
133@@ -293,10 +319,20 @@
134
135 usc::MirScreen::Timeouts usc::MirScreen::timeouts_for(PowerStateChangeReason reason)
136 {
137- if (reason == PowerStateChangeReason::notification || reason == PowerStateChangeReason::proximity)
138+ if (reason == PowerStateChangeReason::notification ||
139+ reason == PowerStateChangeReason::proximity ||
140+ reason == PowerStateChangeReason::call_done)
141+ {
142 return notification_timeouts;
143+ }
144+ else if (reason == PowerStateChangeReason::snap_decision)
145+ {
146+ return call_timeouts;
147+ }
148 else
149+ {
150 return inactivity_timeouts;
151+ }
152 }
153
154 bool usc::MirScreen::is_screen_change_allowed(MirPowerMode mode, PowerStateChangeReason reason)
155@@ -321,7 +357,8 @@
156 void usc::MirScreen::dimmer_alarm_notification()
157 {
158 std::lock_guard<std::mutex> lock{guard};
159- screen_hardware->set_dim_backlight();
160+ if (current_power_mode != MirPowerMode::mir_power_mode_off)
161+ screen_hardware->set_dim_backlight();
162 next_dimming = {};
163 }
164
165
166=== modified file 'src/mir_screen.h'
167--- src/mir_screen.h 2015-07-17 12:43:46 +0000
168+++ src/mir_screen.h 2015-09-25 12:02:53 +0000
169@@ -56,7 +56,8 @@
170 std::shared_ptr<mir::time::AlarmFactory> const& alarm_factory,
171 std::shared_ptr<usc::Clock> const& clock,
172 Timeouts inactivity_timeouts,
173- Timeouts notification_timeouts);
174+ Timeouts notification_timeouts,
175+ Timeouts call_timeouts);
176 ~MirScreen();
177
178 void enable_inactivity_timers(bool enable) override;
179@@ -74,12 +75,13 @@
180 PowerStateChangeHandler const& power_state_change_handler) override;
181
182 private:
183+ enum class ForceResetTimers { no, yes };
184 void set_screen_power_mode_l(MirPowerMode mode, PowerStateChangeReason reason);
185 void configure_display_l(MirPowerMode mode, PowerStateChangeReason reason);
186
187 void cancel_timers_l(PowerStateChangeReason reason);
188 void reset_timers_l(PowerStateChangeReason reason);
189- void reset_timers_ignoring_power_mode_l(PowerStateChangeReason reason);
190+ void reset_timers_ignoring_power_mode_l(PowerStateChangeReason reason, ForceResetTimers force);
191 void enable_inactivity_timers_l(bool flag);
192 Timeouts timeouts_for(PowerStateChangeReason reason);
193 bool is_screen_change_allowed(MirPowerMode mode, PowerStateChangeReason reason);
194@@ -100,12 +102,14 @@
195 std::mutex guard;
196 Timeouts inactivity_timeouts;
197 Timeouts notification_timeouts;
198+ Timeouts call_timeouts;
199 mir::time::Timestamp next_power_off{};
200 mir::time::Timestamp next_dimming{};
201 MirPowerMode current_power_mode;
202 bool restart_timers;
203 PowerStateChangeHandler power_state_change_handler;
204 bool allow_proximity_to_turn_on_screen;
205+ bool turned_on_by_user;
206 };
207
208 }
209
210=== modified file 'src/power_state_change_reason.h'
211--- src/power_state_change_reason.h 2015-07-15 13:48:29 +0000
212+++ src/power_state_change_reason.h 2015-09-25 12:02:53 +0000
213@@ -23,7 +23,9 @@
214 inactivity = 1,
215 power_key = 2,
216 proximity = 3,
217- notification = 4
218+ notification = 4,
219+ snap_decision = 5,
220+ call_done = 6
221 };
222
223 #endif
224
225=== modified file 'src/server.cpp'
226--- src/server.cpp 2015-08-28 09:56:00 +0000
227+++ src/server.cpp 2015-09-25 12:02:53 +0000
228@@ -125,6 +125,8 @@
229 add_display_configuration_options_to(*this);
230 add_configuration_option("notification-display-off-timeout", "The time in seconds before the screen is turned off after a notification arrives", mir::OptionType::integer);
231 add_configuration_option("notification-display-dim-timeout", "The time in seconds before the screen is dimmed after a notification arrives", mir::OptionType::integer);
232+ add_configuration_option("call-display-off-timeout", "The time in seconds before the screen is turned off during a call", mir::OptionType::integer);
233+ add_configuration_option("call-display-dim-timeout", "The time in seconds before the screen is dimmed during a call", mir::OptionType::integer);
234
235 set_command_line(argc, const_cast<char const **>(argv));
236
237@@ -260,7 +262,10 @@
238 inactivity_display_dim_timeout()},
239 MirScreen::Timeouts{
240 notification_display_off_timeout(),
241- notification_display_dim_timeout()});
242+ notification_display_dim_timeout()},
243+ MirScreen::Timeouts{
244+ call_display_off_timeout(),
245+ call_display_dim_timeout()});
246 });
247 }
248
249
250=== modified file 'src/server.h'
251--- src/server.h 2015-08-26 08:26:35 +0000
252+++ src/server.h 2015-09-25 12:02:53 +0000
253@@ -132,6 +132,20 @@
254 seconds{the_options()->get("notification-display-dim-timeout", 12)});
255 }
256
257+ std::chrono::milliseconds call_display_off_timeout()
258+ {
259+ using namespace std::chrono;
260+ return duration_cast<milliseconds>(
261+ seconds{the_options()->get("call-display-off-timeout", 60)});
262+ }
263+
264+ std::chrono::milliseconds call_display_dim_timeout()
265+ {
266+ using namespace std::chrono;
267+ return duration_cast<milliseconds>(
268+ seconds{the_options()->get("call-display-dim-timeout", 50)});
269+ }
270+
271 std::chrono::milliseconds shutdown_timeout()
272 {
273 return std::chrono::milliseconds{
274
275=== modified file 'tests/unit-tests/test_mir_screen.cpp'
276--- tests/unit-tests/test_mir_screen.cpp 2015-08-24 18:18:21 +0000
277+++ tests/unit-tests/test_mir_screen.cpp 2015-09-25 12:02:53 +0000
278@@ -182,6 +182,8 @@
279 std::chrono::seconds const dimmer_timeout{50};
280 std::chrono::seconds const notification_power_off_timeout{15};
281 std::chrono::seconds const notification_dimmer_timeout{12};
282+ std::chrono::seconds const call_power_off_timeout{30};
283+ std::chrono::seconds const call_dimmer_timeout{25};
284
285 std::chrono::seconds const five_seconds{5};
286 std::chrono::seconds const ten_seconds{10};
287@@ -224,6 +226,45 @@
288 EXPECT_CALL(*screen_hardware, set_dim_backlight()).Times(0);
289 }
290
291+ void verify_proximity_enabled()
292+ {
293+ verify_and_clear_expectations();
294+
295+ if (screen_hardware->current_proximity == MockScreenHardware::Proximity::far)
296+ {
297+ expect_screen_is_turned_off();
298+ cover_screen();
299+ verify_and_clear_expectations();
300+
301+ expect_screen_is_turned_on();
302+ uncover_screen();
303+ verify_and_clear_expectations();
304+ }
305+
306+ if (screen_hardware->current_proximity == MockScreenHardware::Proximity::near)
307+ {
308+ expect_screen_is_turned_on();
309+ uncover_screen();
310+ verify_and_clear_expectations();
311+
312+ expect_screen_is_turned_off();
313+ cover_screen();
314+ verify_and_clear_expectations();
315+ }
316+ }
317+
318+ void verify_proximity_disabled()
319+ {
320+ verify_and_clear_expectations();
321+
322+ expect_no_reconfiguration();
323+ uncover_screen();
324+ cover_screen();
325+ uncover_screen();
326+
327+ verify_and_clear_expectations();
328+ }
329+
330 void turn_screen_off()
331 {
332 using namespace testing;
333@@ -234,6 +275,16 @@
334 verify_and_clear_expectations();
335 }
336
337+ void turn_screen_on()
338+ {
339+ using namespace testing;
340+ mir_screen.set_screen_power_mode(
341+ MirPowerMode::mir_power_mode_on,
342+ PowerStateChangeReason::power_key);
343+
344+ verify_and_clear_expectations();
345+ }
346+
347 void receive_notification()
348 {
349 mir_screen.set_screen_power_mode(
350@@ -242,6 +293,22 @@
351 process_deferred_actions();
352 }
353
354+ void receive_call()
355+ {
356+ mir_screen.set_screen_power_mode(
357+ MirPowerMode::mir_power_mode_on,
358+ PowerStateChangeReason::snap_decision);
359+ process_deferred_actions();
360+ }
361+
362+ void receive_call_done()
363+ {
364+ mir_screen.set_screen_power_mode(
365+ MirPowerMode::mir_power_mode_on,
366+ PowerStateChangeReason::call_done);
367+ process_deferred_actions();
368+ }
369+
370 void cover_screen()
371 {
372 screen_hardware->set_proximity(MockScreenHardware::Proximity::near);
373@@ -281,7 +348,8 @@
374 timer,
375 timer,
376 {power_off_timeout, dimmer_timeout},
377- {notification_power_off_timeout, notification_dimmer_timeout}};
378+ {notification_power_off_timeout, notification_dimmer_timeout},
379+ {call_power_off_timeout, call_dimmer_timeout}};
380 };
381
382 }
383@@ -848,3 +916,204 @@
384 PowerStateChangeReason::proximity);
385
386 }
387+
388+TEST_F(AMirScreen, turns_screen_off_after_call_timeout)
389+{
390+ turn_screen_off();
391+
392+ expect_screen_is_turned_on();
393+ receive_call();
394+ verify_and_clear_expectations();
395+
396+ expect_screen_is_turned_off();
397+ timer->advance_by(call_power_off_timeout);
398+}
399+
400+TEST_F(AMirScreen, keep_display_on_temporarily_overrides_call_timeout)
401+{
402+ turn_screen_off();
403+
404+ expect_screen_is_turned_on();
405+ receive_call();
406+ verify_and_clear_expectations();
407+
408+ // At T=20 we request a temporary keep display on (e.g. user has touched
409+ // the screen)
410+ timer->advance_by(ten_seconds);
411+ timer->advance_by(ten_seconds);
412+ mir_screen.keep_display_on_temporarily();
413+
414+ // At T=30 nothing should happen since keep display on temporarily
415+ // has reset the timers (so the call timeout is overriden).
416+ expect_no_reconfiguration();
417+ timer->advance_by(ten_seconds);
418+ verify_and_clear_expectations();
419+
420+ // At T=110 (50 + 60) the screen should turn off due to the normal
421+ // inactivity timeout
422+ expect_screen_is_turned_off();
423+ timer->advance_by(fifty_seconds);
424+}
425+
426+TEST_F(AMirScreen, does_not_turn_on_screen_when_call_arrives_with_phone_covered)
427+{
428+ turn_screen_off();
429+ cover_screen();
430+
431+ expect_no_reconfiguration();
432+ receive_call();
433+}
434+
435+TEST_F(AMirScreen, enables_proximity_when_call_arrives)
436+{
437+ turn_screen_off();
438+ cover_screen();
439+
440+ expect_no_reconfiguration();
441+ receive_call();
442+ verify_and_clear_expectations();
443+
444+ verify_proximity_enabled();
445+}
446+
447+TEST_F(AMirScreen, cancels_proximity_handling_when_screen_is_turned_off_by_call_timeout)
448+{
449+ turn_screen_off();
450+ cover_screen();
451+
452+ receive_call();
453+ timer->advance_by(call_power_off_timeout);
454+
455+ verify_proximity_disabled();
456+}
457+
458+TEST_F(AMirScreen, cancels_proximity_handling_when_screen_is_touched_after_call)
459+{
460+ turn_screen_off();
461+
462+ receive_call();
463+ mir_screen.keep_display_on_temporarily();
464+
465+ verify_proximity_disabled();
466+}
467+
468+TEST_F(AMirScreen, does_not_enable_proximity_handling_for_call_when_screen_is_already_on)
469+{
470+ expect_no_reconfiguration();
471+ receive_call();
472+ verify_and_clear_expectations();
473+
474+ verify_proximity_disabled();
475+}
476+
477+TEST_F(AMirScreen, retains_proximity_handling_when_call_done_arrives_when_screen_is_off_after_call)
478+{
479+ turn_screen_off();
480+ cover_screen();
481+ receive_call();
482+ receive_call_done();
483+
484+ verify_proximity_enabled();
485+}
486+
487+TEST_F(AMirScreen,
488+ turns_off_screen_and_proximity_soon_after_call_when_screen_not_covered)
489+{
490+ turn_screen_off();
491+
492+ // Call
493+ receive_call();
494+ timer->advance_by(ten_seconds);
495+ receive_call_done();
496+
497+ verify_and_clear_expectations();
498+
499+ // After the notification timeout the screen should be off
500+ // and proximity should be disabled
501+ expect_screen_is_turned_off();
502+ timer->advance_by(notification_power_off_timeout);
503+
504+ verify_proximity_disabled();
505+}
506+
507+TEST_F(AMirScreen,
508+ turns_proximity_off_soon_after_call_when_screen_covered)
509+{
510+ turn_screen_off();
511+ cover_screen();
512+
513+ expect_no_reconfiguration();
514+
515+ // call
516+ receive_call();
517+ timer->advance_by(ten_seconds);
518+ receive_call_done();
519+ timer->advance_by(notification_power_off_timeout);
520+
521+ verify_and_clear_expectations();
522+
523+ verify_proximity_disabled();
524+}
525+
526+TEST_F(AMirScreen,
527+ turns_off_screen_and_proximity_soon_after_call_when_screen_uncovered_after_call_is_received)
528+{
529+ turn_screen_off();
530+ cover_screen();
531+
532+ // Uncover screen while in call
533+ receive_call();
534+ timer->advance_by(five_seconds);
535+ uncover_screen();
536+ timer->advance_by(five_seconds);
537+ receive_call_done();
538+
539+ verify_and_clear_expectations();
540+
541+ // After the notification timeout the screen should be off
542+ // and proximity should be disabled
543+ expect_screen_is_turned_off();
544+ timer->advance_by(notification_power_off_timeout);
545+
546+ verify_proximity_disabled();
547+}
548+
549+TEST_F(AMirScreen,
550+ keeps_screen_on_for_full_timeout_after_call_received_when_screen_was_turned_on_manually)
551+{
552+ // Turn screen on manually (i.e. with power key)
553+ turn_screen_off();
554+ turn_screen_on();
555+
556+ expect_no_reconfiguration();
557+
558+ // call
559+ receive_call();
560+ timer->advance_by(ten_seconds);
561+ receive_call_done();
562+ // Call done notification timeout should be ignored since
563+ // user had turned on the screen manually
564+ timer->advance_by(notification_power_off_timeout);
565+
566+ verify_and_clear_expectations();
567+
568+ verify_proximity_disabled();
569+}
570+
571+TEST_F(AMirScreen,
572+ sets_normal_backlight_when_notification_arrives_while_screen_already_on)
573+{
574+ turn_screen_on();
575+
576+ EXPECT_CALL(*screen_hardware, set_normal_backlight());
577+ receive_notification();
578+}
579+
580+TEST_F(AMirScreen,
581+ sets_normal_backlight_when_call_arrives_while_screen_already_on)
582+{
583+ turn_screen_on();
584+
585+ EXPECT_CALL(*screen_hardware, set_normal_backlight());
586+ receive_call();
587+}

Subscribers

People subscribed via source and target branches