Merge lp:~albaguirre/unity-system-compositor/fix-1483127 into lp:unity-system-compositor

Proposed by Alberto Aguirre
Status: Merged
Approved by: Alexandros Frantzis
Approved revision: 245
Merged at revision: 246
Proposed branch: lp:~albaguirre/unity-system-compositor/fix-1483127
Merge into: lp:unity-system-compositor
Diff against target: 128 lines (+60/-8)
2 files modified
src/mir_screen.cpp (+7/-3)
tests/unit-tests/test_mir_screen.cpp (+53/-5)
To merge this branch: bzr merge lp:~albaguirre/unity-system-compositor/fix-1483127
Reviewer Review Type Date Requested Status
Alexandros Frantzis (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+268819@code.launchpad.net

Commit message

Allow proximity to turn on screen.

Allow proximity events to turn on screen only if the power key has not turned off the screen. A user may be on a call that is longer that the screen timeout but at the end of the call a far proximity event should still be able to turn the screen on.

Description of the change

Allow proximity to turn on screen.

Allow proximity events to turn on screen only if the power key has not turned off the screen. A user may be on a call that is longer that the screen timeout but at the end of the call a far proximity event should still be able to turn the screen on.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/mir_screen.cpp'
--- src/mir_screen.cpp 2015-08-18 13:14:49 +0000
+++ src/mir_screen.cpp 2015-08-21 23:58:15 +0000
@@ -175,7 +175,7 @@
175 if (reason != PowerStateChangeReason::proximity)175 if (reason != PowerStateChangeReason::proximity)
176 {176 {
177 screen_hardware->enable_proximity(false);177 screen_hardware->enable_proximity(false);
178 allow_proximity_to_turn_on_screen = false;178 allow_proximity_to_turn_on_screen = reason != PowerStateChangeReason::power_key;
179 }179 }
180180
181 if (current_power_mode == mode)181 if (current_power_mode == mode)
@@ -226,7 +226,11 @@
226void usc::MirScreen::cancel_timers_l(PowerStateChangeReason reason)226void usc::MirScreen::cancel_timers_l(PowerStateChangeReason reason)
227{227{
228 if (reason == PowerStateChangeReason::proximity)228 if (reason == PowerStateChangeReason::proximity)
229 {
230 next_power_off = {};
231 next_dimming = {};
229 return;232 return;
233 }
230234
231 power_off_alarm->cancel();235 power_off_alarm->cancel();
232 dimmer_alarm->cancel();236 dimmer_alarm->cancel();
@@ -242,7 +246,7 @@
242246
243void usc::MirScreen::reset_timers_ignoring_power_mode_l(PowerStateChangeReason reason)247void usc::MirScreen::reset_timers_ignoring_power_mode_l(PowerStateChangeReason reason)
244{248{
245 if (!restart_timers || reason == PowerStateChangeReason::proximity)249 if (!restart_timers)
246 return;250 return;
247251
248 auto const timeouts = timeouts_for(reason);252 auto const timeouts = timeouts_for(reason);
@@ -289,7 +293,7 @@
289293
290usc::MirScreen::Timeouts usc::MirScreen::timeouts_for(PowerStateChangeReason reason)294usc::MirScreen::Timeouts usc::MirScreen::timeouts_for(PowerStateChangeReason reason)
291{295{
292 if (reason == PowerStateChangeReason::notification)296 if (reason == PowerStateChangeReason::notification || reason == PowerStateChangeReason::proximity)
293 return notification_timeouts;297 return notification_timeouts;
294 else298 else
295 return inactivity_timeouts;299 return inactivity_timeouts;
296300
=== modified file 'tests/unit-tests/test_mir_screen.cpp'
--- tests/unit-tests/test_mir_screen.cpp 2015-08-18 12:20:56 +0000
+++ tests/unit-tests/test_mir_screen.cpp 2015-08-21 23:58:15 +0000
@@ -584,7 +584,7 @@
584 verify_and_clear_expectations();584 verify_and_clear_expectations();
585}585}
586586
587TEST_F(AMirScreen, proximity_requests_do_not_reset_timeouts)587TEST_F(AMirScreen, proximity_requests_use_short_timeouts)
588{588{
589 // At T=0 we turn the screen on, and normal inactivity timeouts589 // At T=0 we turn the screen on, and normal inactivity timeouts
590 // are reset590 // are reset
@@ -603,16 +603,16 @@
603603
604 verify_and_clear_expectations();604 verify_and_clear_expectations();
605605
606 // At T=50 screen should be dimmed due to the inactivity606 // At T=52 screen should be dimmed due to the short inactivity
607 // dimming timeout607 // dimming timeout
608 expect_screen_is_turned_dim();608 expect_screen_is_turned_dim();
609 timer->advance_by(ten_seconds);609 timer->advance_by(notification_dimmer_timeout);
610 verify_and_clear_expectations();610 verify_and_clear_expectations();
611611
612 // At T=60 the screen should turn off due to the normal612 // At T=55 the screen should turn off due to the short
613 // inactivity timeout613 // inactivity timeout
614 expect_screen_is_turned_off();614 expect_screen_is_turned_off();
615 timer->advance_by(ten_seconds);615 timer->advance_by(std::chrono::seconds{3});
616}616}
617617
618TEST_F(AMirScreen, does_not_turn_on_screen_when_notification_arrives_with_phone_covered)618TEST_F(AMirScreen, does_not_turn_on_screen_when_notification_arrives_with_phone_covered)
@@ -779,3 +779,51 @@
779 timer->advance_by(ten_hours);779 timer->advance_by(ten_hours);
780 verify_and_clear_expectations();780 verify_and_clear_expectations();
781}781}
782
783TEST_F(AMirScreen, proximity_can_turn_on_screen_after_power_off_timeout)
784{
785 mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_on,
786 PowerStateChangeReason::power_key);
787
788 mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_off,
789 PowerStateChangeReason::proximity);
790
791 timer->advance_by(power_off_timeout);
792
793 expect_screen_is_turned_on();
794 mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_on,
795 PowerStateChangeReason::proximity);
796 verify_and_clear_expectations();
797
798 expect_screen_is_turned_off();
799
800 timer->advance_by(power_off_timeout);
801}
802
803TEST_F(AMirScreen, proximity_cannot_turn_on_screen_if_power_key_was_used)
804{
805 mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_on,
806 PowerStateChangeReason::power_key);
807
808 mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_off,
809 PowerStateChangeReason::power_key);
810
811 //timer->advance_by(power_off_timeout);
812
813 expect_no_reconfiguration();
814 mir_screen.set_screen_power_mode(
815 MirPowerMode::mir_power_mode_on,
816 PowerStateChangeReason::proximity);
817 verify_and_clear_expectations();
818
819 expect_no_reconfiguration();
820 mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_off,
821 PowerStateChangeReason::proximity);
822
823 verify_and_clear_expectations();
824
825 expect_no_reconfiguration();
826 mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_on,
827 PowerStateChangeReason::proximity);
828
829}

Subscribers

People subscribed via source and target branches