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
1=== modified file 'src/mir_screen.cpp'
2--- src/mir_screen.cpp 2015-08-18 13:14:49 +0000
3+++ src/mir_screen.cpp 2015-08-21 23:58:15 +0000
4@@ -175,7 +175,7 @@
5 if (reason != PowerStateChangeReason::proximity)
6 {
7 screen_hardware->enable_proximity(false);
8- allow_proximity_to_turn_on_screen = false;
9+ allow_proximity_to_turn_on_screen = reason != PowerStateChangeReason::power_key;
10 }
11
12 if (current_power_mode == mode)
13@@ -226,7 +226,11 @@
14 void usc::MirScreen::cancel_timers_l(PowerStateChangeReason reason)
15 {
16 if (reason == PowerStateChangeReason::proximity)
17+ {
18+ next_power_off = {};
19+ next_dimming = {};
20 return;
21+ }
22
23 power_off_alarm->cancel();
24 dimmer_alarm->cancel();
25@@ -242,7 +246,7 @@
26
27 void usc::MirScreen::reset_timers_ignoring_power_mode_l(PowerStateChangeReason reason)
28 {
29- if (!restart_timers || reason == PowerStateChangeReason::proximity)
30+ if (!restart_timers)
31 return;
32
33 auto const timeouts = timeouts_for(reason);
34@@ -289,7 +293,7 @@
35
36 usc::MirScreen::Timeouts usc::MirScreen::timeouts_for(PowerStateChangeReason reason)
37 {
38- if (reason == PowerStateChangeReason::notification)
39+ if (reason == PowerStateChangeReason::notification || reason == PowerStateChangeReason::proximity)
40 return notification_timeouts;
41 else
42 return inactivity_timeouts;
43
44=== modified file 'tests/unit-tests/test_mir_screen.cpp'
45--- tests/unit-tests/test_mir_screen.cpp 2015-08-18 12:20:56 +0000
46+++ tests/unit-tests/test_mir_screen.cpp 2015-08-21 23:58:15 +0000
47@@ -584,7 +584,7 @@
48 verify_and_clear_expectations();
49 }
50
51-TEST_F(AMirScreen, proximity_requests_do_not_reset_timeouts)
52+TEST_F(AMirScreen, proximity_requests_use_short_timeouts)
53 {
54 // At T=0 we turn the screen on, and normal inactivity timeouts
55 // are reset
56@@ -603,16 +603,16 @@
57
58 verify_and_clear_expectations();
59
60- // At T=50 screen should be dimmed due to the inactivity
61+ // At T=52 screen should be dimmed due to the short inactivity
62 // dimming timeout
63 expect_screen_is_turned_dim();
64- timer->advance_by(ten_seconds);
65+ timer->advance_by(notification_dimmer_timeout);
66 verify_and_clear_expectations();
67
68- // At T=60 the screen should turn off due to the normal
69+ // At T=55 the screen should turn off due to the short
70 // inactivity timeout
71 expect_screen_is_turned_off();
72- timer->advance_by(ten_seconds);
73+ timer->advance_by(std::chrono::seconds{3});
74 }
75
76 TEST_F(AMirScreen, does_not_turn_on_screen_when_notification_arrives_with_phone_covered)
77@@ -779,3 +779,51 @@
78 timer->advance_by(ten_hours);
79 verify_and_clear_expectations();
80 }
81+
82+TEST_F(AMirScreen, proximity_can_turn_on_screen_after_power_off_timeout)
83+{
84+ mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_on,
85+ PowerStateChangeReason::power_key);
86+
87+ mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_off,
88+ PowerStateChangeReason::proximity);
89+
90+ timer->advance_by(power_off_timeout);
91+
92+ expect_screen_is_turned_on();
93+ mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_on,
94+ PowerStateChangeReason::proximity);
95+ verify_and_clear_expectations();
96+
97+ expect_screen_is_turned_off();
98+
99+ timer->advance_by(power_off_timeout);
100+}
101+
102+TEST_F(AMirScreen, proximity_cannot_turn_on_screen_if_power_key_was_used)
103+{
104+ mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_on,
105+ PowerStateChangeReason::power_key);
106+
107+ mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_off,
108+ PowerStateChangeReason::power_key);
109+
110+ //timer->advance_by(power_off_timeout);
111+
112+ expect_no_reconfiguration();
113+ mir_screen.set_screen_power_mode(
114+ MirPowerMode::mir_power_mode_on,
115+ PowerStateChangeReason::proximity);
116+ verify_and_clear_expectations();
117+
118+ expect_no_reconfiguration();
119+ mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_off,
120+ PowerStateChangeReason::proximity);
121+
122+ verify_and_clear_expectations();
123+
124+ expect_no_reconfiguration();
125+ mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_on,
126+ PowerStateChangeReason::proximity);
127+
128+}

Subscribers

People subscribed via source and target branches