Merge lp:~ricmm/powerd/support-mir-toggled into lp:powerd

Proposed by Ricardo Mendoza
Status: Merged
Approved by: Ricardo Salveti
Approved revision: 96
Merged at revision: 94
Proposed branch: lp:~ricmm/powerd/support-mir-toggled
Merge into: lp:powerd
Diff against target: 154 lines (+62/-5)
4 files modified
debian/control (+1/-1)
src/display.c (+56/-2)
src/powerd-internal.h (+1/-0)
src/powerd.cpp (+4/-2)
To merge this branch: bzr merge lp:~ricmm/powerd/support-mir-toggled
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ricardo Salveti (community) Approve
Seth Forshee (community) Approve
Gerry Boland (community) Approve
Review via email: mp+187238@code.launchpad.net

Commit message

Allow powerd to work with unity-mir's DBus API for screen power control, selective using the backend available according to the running display server.

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
Seth Forshee (sforshee) wrote :

16 + if (stat("/home/phablet/.display-mir", &stats) == -1 && errno == ENOENT) {

How about caching the result of this in a variable so it doesn't have to be done each time?

17 + if (power_mode == "off")

Should be a strcmp.

29 + while ((read(fd, &c, sizeof(char))) != 0) {

You should add protection against writing past the end of the buffer.

36 + seteuid(32011); /* phablet user */
37 + setegid(32011); /* phablet group */

Hard coded? Is there no way to get the uid/gid at run time?

38 + setenv("DBUS_SESSION_BUS_ADDRESS", strstr(buf, "unix"));

Is it okay to leave this set after you're done here?

50 + if (error != NULL) {
51 + powerd_warn("could not connect to Unity: %s", error->message);
52 + g_error_free(error);
53 + seteuid(0);
54 + setegid(0);
55 + close(fd);

You could restructure this to avoid having to code this cleanup twice, your call.

review: Needs Fixing
Revision history for this message
Matt Fischer (mfisch) wrote :

You can get getpwent to read the phablet user's uid/gid I think, but should we have a registration feature that lets unity register users so we can support multiple users? For example:

registerSession(uid,gid) or equivalent

What about a bridge service that listens on the system bus and talks on the session bus and runs as every user? powerd could signal that and it would signal up to the session bus. I think this is doable, but you could ask ted.

Revision history for this message
Matt Fischer (mfisch) wrote :

"Runs as every user" above means every user has an instance of it running!

Revision history for this message
Seth Forshee (sforshee) wrote :

I like this better. One question though: is it really necessary to reallocate the dbus proxy each time? Or can it just be done when we don't have a proxy or else the one we have doesn't work anymore (i.e. if unity restarted)?

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

Works well on device

review: Approve
Revision history for this message
Seth Forshee (sforshee) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
http://jenkins.qa.ubuntu.com/job/powerd-autolanding/70/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/powerd-saucy-armhf-autolanding/46/console

review: Needs Fixing (continuous-integration)
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

Looks fine, and works fine as well.

Just pushed libhybris 28 to the archive, once in we can top approve and ping the CI team to land it.

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

FAILED: Autolanding.
More details in the following jenkins job:
http://jenkins.qa.ubuntu.com/job/powerd-autolanding/71/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/powerd-saucy-armhf-autolanding/47/console

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2013-08-27 16:59:34 +0000
3+++ debian/control 2013-09-25 21:29:25 +0000
4@@ -5,7 +5,7 @@
5 Build-Depends: debhelper (>= 9),
6 cmake,
7 libglib2.0-dev,
8- libhybris-dev,
9+ libhybris-dev (>= 0.1.0+git20130606+c5d897a-0ubuntu28),
10 libudev-dev,
11 python,
12 libandroid-properties-dev,
13
14=== modified file 'src/display.c'
15--- src/display.c 2013-08-29 16:23:09 +0000
16+++ src/display.c 2013-09-25 21:29:25 +0000
17@@ -39,6 +39,9 @@
18 #include "device-config.h"
19 #include "log.h"
20
21+/* Mir usage hint file path */
22+#define MIR_HINT_PATH "/home/phablet/.display-mir"
23+
24 /* Treat "don't care" display state as off */
25 #define DISPLAY_STATE_OFF POWERD_DISPLAY_STATE_DONT_CARE
26
27@@ -50,6 +53,7 @@
28 static gint saved_brightness = 255;
29 static gint target_brightness;
30 static gint dim_brightness;
31+static gboolean running_mir = FALSE;
32
33 /* Assume screen is off to start; we will force it on */
34 static uuid_t internal_request_cookie;
35@@ -103,9 +107,54 @@
36 return (flags & AB_ENABLED_MASK) == AB_ENABLED;
37 }
38
39+void display_set_power_mode(int display, char *power_mode)
40+{
41+ GError *error = NULL;
42+ GDBusProxy *unity_proxy = NULL;
43+
44+ powerd_debug("display_set_power_mode(%s)", power_mode);
45+
46+ if (!running_mir) {
47+ if (strcmp(power_mode, "off") == 0)
48+ sf_blank(display);
49+ else
50+ sf_unblank(display);
51+ } else {
52+ unity_proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
53+ G_DBUS_PROXY_FLAGS_NONE,
54+ NULL,
55+ "com.canonical.Unity.Screen",
56+ "/com/canonical/Unity/Screen",
57+ "com.canonical.Unity.Screen",
58+ NULL,
59+ &error);
60+
61+ if (error != NULL) {
62+ powerd_warn("could not connect to Unity: %s", error->message);
63+ g_error_free(error);
64+ return;
65+ }
66+
67+ GVariant *ret = g_dbus_proxy_call_sync(unity_proxy,
68+ "setScreenPowerMode",
69+ g_variant_new("(s)", power_mode),
70+ G_DBUS_CALL_FLAGS_NONE,
71+ -1,
72+ NULL,
73+ &error);
74+
75+ if (ret == NULL) {
76+ powerd_warn("screen power setting failed: %s", error->message);
77+ g_error_free(error);
78+ }
79+
80+ g_object_unref(unity_proxy);
81+ }
82+}
83+
84 static void turn_on_display(gboolean autobrightness) {
85 powerd_debug("turning on display");
86- sf_unblank(0);
87+ display_set_power_mode(0, "on");
88 if (autobrightness)
89 powerd_autobrightness_enable();
90 else
91@@ -174,7 +223,7 @@
92 if (using_ab)
93 powerd_autobrightness_disable();
94 powerd_set_brightness(0);
95- sf_blank(0);
96+ display_set_power_mode(0, "off");
97
98 powerd_debug("Releasing internal active state request");
99 ret = clear_sys_state_internal(internal_request_cookie);
100@@ -382,6 +431,7 @@
101 GError *error;
102 GValue v = G_VALUE_INIT;
103 int brightness, max_brightness;
104+ struct stat stats;
105
106 /*
107 * Warning: much hand waving follows
108@@ -423,6 +473,10 @@
109
110 target_brightness = saved_brightness;
111
112+ /* decide whether we are running on Mir or SF */
113+ if (stat(MIR_HINT_PATH, &stats) == 0)
114+ running_mir = TRUE;
115+
116 /* If kernel supports earlysuspend, start thread to monitor fb state */
117 if (!access(fb_file_names[FB_SLEEP], F_OK))
118 g_thread_new("powerd_fb_wake_monitor", wait_for_fb_thread, &error);
119
120=== modified file 'src/powerd-internal.h'
121--- src/powerd-internal.h 2013-09-03 14:10:41 +0000
122+++ src/powerd-internal.h 2013-09-25 21:29:25 +0000
123@@ -74,6 +74,7 @@
124 /* Display functions */
125 void powerd_brightness_set_value(gint value);
126 gboolean powerd_display_enabled(void);
127+void display_set_power_mode(int display, char *powerd_mode);
128 void powerd_set_display_state(struct powerd_display_request *req);
129 int powerd_display_init(void);
130 void powerd_proximity_event(gboolean near);
131
132=== modified file 'src/powerd.cpp'
133--- src/powerd.cpp 2013-08-29 16:23:09 +0000
134+++ src/powerd.cpp 2013-09-25 21:29:25 +0000
135@@ -125,7 +125,7 @@
136 if (button_state == BUTTON_DOWN) {
137 button_state = SHUTDOWN;
138 powerd_set_brightness(0);
139- sf_blank(0);
140+ display_set_power_mode(0, "off");
141 powerd_shutdown();
142 }
143
144@@ -496,7 +496,9 @@
145
146 InputStackConfiguration config = {
147 enable_touch_point_visualization : false,
148- default_layer_for_touch_point_visualization : 10000
149+ default_layer_for_touch_point_visualization : 10000,
150+ input_area_width : 2048,
151+ input_area_height : 2048
152 };
153
154 android_input_stack_initialize(&listener, &config);

Subscribers

People subscribed via source and target branches