Merge lp:~ted/ubuntu-app-launch/suspend-signal into lp:ubuntu-app-launch/15.04
- suspend-signal
- Merge into trunk.15.04
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | dobey | ||||
Approved revision: | 198 | ||||
Merged at revision: | 187 | ||||
Proposed branch: | lp:~ted/ubuntu-app-launch/suspend-signal | ||||
Merge into: | lp:ubuntu-app-launch/15.04 | ||||
Diff against target: |
513 lines (+309/-8) 6 files modified
data/com.canonical.UbuntuAppLaunch.xml (+8/-0) debian/libubuntu-app-launch2.symbols (+4/-0) libubuntu-app-launch/ubuntu-app-launch.c (+181/-3) libubuntu-app-launch/ubuntu-app-launch.h (+63/-0) tests/libual-test.cc (+39/-0) tools/ubuntu-app-watch.c (+14/-5) |
||||
To merge this branch: | bzr merge lp:~ted/ubuntu-app-launch/suspend-signal | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
dobey (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+251510@code.launchpad.net |
Commit message
Emit a signal when applications are paused or resumed
Description of the change
This way services can respond appropriately whether they're getting the message.
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:197
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:197
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:198
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:198
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
dobey (dobey) wrote : | # |
I don't like the @replaceme as it means CI train ends up modifying the change set when it lands in trunk, but otherwise looks OK.
Preview Diff
1 | === modified file 'data/com.canonical.UbuntuAppLaunch.xml' | |||
2 | --- data/com.canonical.UbuntuAppLaunch.xml 2014-04-30 15:45:23 +0000 | |||
3 | +++ data/com.canonical.UbuntuAppLaunch.xml 2015-03-04 14:26:50 +0000 | |||
4 | @@ -20,5 +20,13 @@ | |||
5 | 20 | <arg type="s" name="appid" /> | 20 | <arg type="s" name="appid" /> |
6 | 21 | <arg type="s" name="stage" /> | 21 | <arg type="s" name="stage" /> |
7 | 22 | </signal> | 22 | </signal> |
8 | 23 | <signal name="ApplicationPaused"> | ||
9 | 24 | <arg type="s" name="appid" /> | ||
10 | 25 | <arg type="at" name="pids" /> | ||
11 | 26 | </signal> | ||
12 | 27 | <signal name="ApplicationResumed"> | ||
13 | 28 | <arg type="s" name="appid" /> | ||
14 | 29 | <arg type="at" name="pids" /> | ||
15 | 30 | </signal> | ||
16 | 23 | </interface> | 31 | </interface> |
17 | 24 | </node> | 32 | </node> |
18 | 25 | 33 | ||
19 | === modified file 'debian/libubuntu-app-launch2.symbols' | |||
20 | --- debian/libubuntu-app-launch2.symbols 2014-09-15 19:40:14 +0000 | |||
21 | +++ debian/libubuntu-app-launch2.symbols 2015-03-04 14:26:50 +0000 | |||
22 | @@ -7,7 +7,9 @@ | |||
23 | 7 | ubuntu_app_launch_list_running_apps@Base 0.4 | 7 | ubuntu_app_launch_list_running_apps@Base 0.4 |
24 | 8 | ubuntu_app_launch_observer_add_app_failed@Base 0.4 | 8 | ubuntu_app_launch_observer_add_app_failed@Base 0.4 |
25 | 9 | ubuntu_app_launch_observer_add_app_focus@Base 0.4 | 9 | ubuntu_app_launch_observer_add_app_focus@Base 0.4 |
26 | 10 | ubuntu_app_launch_observer_add_app_paused@Base 0replaceme | ||
27 | 10 | ubuntu_app_launch_observer_add_app_resume@Base 0.4 | 11 | ubuntu_app_launch_observer_add_app_resume@Base 0.4 |
28 | 12 | ubuntu_app_launch_observer_add_app_resumed@Base 0replaceme | ||
29 | 11 | ubuntu_app_launch_observer_add_app_started@Base 0.4 | 13 | ubuntu_app_launch_observer_add_app_started@Base 0.4 |
30 | 12 | ubuntu_app_launch_observer_add_app_starting@Base 0.4 | 14 | ubuntu_app_launch_observer_add_app_starting@Base 0.4 |
31 | 13 | ubuntu_app_launch_observer_add_app_stop@Base 0.4 | 15 | ubuntu_app_launch_observer_add_app_stop@Base 0.4 |
32 | @@ -15,7 +17,9 @@ | |||
33 | 15 | ubuntu_app_launch_observer_add_helper_stop@Base 0.4 | 17 | ubuntu_app_launch_observer_add_helper_stop@Base 0.4 |
34 | 16 | ubuntu_app_launch_observer_delete_app_failed@Base 0.4 | 18 | ubuntu_app_launch_observer_delete_app_failed@Base 0.4 |
35 | 17 | ubuntu_app_launch_observer_delete_app_focus@Base 0.4 | 19 | ubuntu_app_launch_observer_delete_app_focus@Base 0.4 |
36 | 20 | ubuntu_app_launch_observer_delete_app_paused@Base 0replaceme | ||
37 | 18 | ubuntu_app_launch_observer_delete_app_resume@Base 0.4 | 21 | ubuntu_app_launch_observer_delete_app_resume@Base 0.4 |
38 | 22 | ubuntu_app_launch_observer_delete_app_resumed@Base 0replaceme | ||
39 | 19 | ubuntu_app_launch_observer_delete_app_started@Base 0.4 | 23 | ubuntu_app_launch_observer_delete_app_started@Base 0.4 |
40 | 20 | ubuntu_app_launch_observer_delete_app_starting@Base 0.4 | 24 | ubuntu_app_launch_observer_delete_app_starting@Base 0.4 |
41 | 21 | ubuntu_app_launch_observer_delete_app_stop@Base 0.4 | 25 | ubuntu_app_launch_observer_delete_app_stop@Base 0.4 |
42 | 22 | 26 | ||
43 | === modified file 'libubuntu-app-launch/ubuntu-app-launch.c' | |||
44 | --- libubuntu-app-launch/ubuntu-app-launch.c 2014-11-20 20:33:59 +0000 | |||
45 | +++ libubuntu-app-launch/ubuntu-app-launch.c 2015-03-04 14:26:50 +0000 | |||
46 | @@ -499,10 +499,61 @@ | |||
47 | 499 | return FALSE; | 499 | return FALSE; |
48 | 500 | } | 500 | } |
49 | 501 | 501 | ||
50 | 502 | /* Throw out a DBus signal that we've signalled all of these processes. This | ||
51 | 503 | is the fun GVariant building part. */ | ||
52 | 504 | static void | ||
53 | 505 | notify_signalling (GList * pids, const gchar * appid, const gchar * signal_name) | ||
54 | 506 | { | ||
55 | 507 | GDBusConnection * conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); | ||
56 | 508 | if (conn == NULL) { | ||
57 | 509 | return; | ||
58 | 510 | } | ||
59 | 511 | |||
60 | 512 | /* Pull together a PID array */ | ||
61 | 513 | GVariant *pidarray = NULL; | ||
62 | 514 | if (pids == NULL) { | ||
63 | 515 | pidarray = g_variant_new_array(G_VARIANT_TYPE_UINT64, NULL, 0); | ||
64 | 516 | } else { | ||
65 | 517 | GList * i; | ||
66 | 518 | GVariantBuilder builder; | ||
67 | 519 | g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY); | ||
68 | 520 | |||
69 | 521 | for (i = pids; i != NULL; i = g_list_next(i)) | ||
70 | 522 | g_variant_builder_add_value(&builder, g_variant_new_uint64(GPOINTER_TO_INT(i->data))); | ||
71 | 523 | |||
72 | 524 | pidarray = g_variant_builder_end(&builder); | ||
73 | 525 | } | ||
74 | 526 | |||
75 | 527 | /* Combine into the wrapping tuple */ | ||
76 | 528 | GVariantBuilder btuple; | ||
77 | 529 | g_variant_builder_init(&btuple, G_VARIANT_TYPE_TUPLE); | ||
78 | 530 | g_variant_builder_add_value(&btuple, g_variant_new_string(appid)); | ||
79 | 531 | g_variant_builder_add_value(&btuple, pidarray); | ||
80 | 532 | |||
81 | 533 | /* Emit !!! */ | ||
82 | 534 | GError * error = NULL; | ||
83 | 535 | g_dbus_connection_emit_signal(conn, | ||
84 | 536 | NULL, /* destination */ | ||
85 | 537 | "/", /* path */ | ||
86 | 538 | "com.canonical.UbuntuAppLaunch", /* interface */ | ||
87 | 539 | signal_name, /* signal */ | ||
88 | 540 | g_variant_builder_end(&btuple), /* params, the same */ | ||
89 | 541 | &error); | ||
90 | 542 | |||
91 | 543 | if (error != NULL) { | ||
92 | 544 | g_warning("Unable to emit signal '%s' for appid '%s': %s", signal_name, appid, error->message); | ||
93 | 545 | g_error_free(error); | ||
94 | 546 | } else { | ||
95 | 547 | g_debug("Emmitted '%s' to DBus", signal_name); | ||
96 | 548 | } | ||
97 | 549 | |||
98 | 550 | g_object_unref(conn); | ||
99 | 551 | } | ||
100 | 552 | |||
101 | 502 | /* Gets all the pids for an appid and sends a signal to all of them. This also | 553 | /* Gets all the pids for an appid and sends a signal to all of them. This also |
102 | 503 | loops to ensure no new pids are added while we're signaling */ | 554 | loops to ensure no new pids are added while we're signaling */ |
103 | 504 | static gboolean | 555 | static gboolean |
105 | 505 | signal_to_cgroup (const gchar * appid, int signal, const gchar * oomscore) | 556 | signal_to_cgroup (const gchar * appid, int signal, const gchar * oomscore, const gchar * signal_name) |
106 | 506 | { | 557 | { |
107 | 507 | GHashTable * pidssignaled = g_hash_table_new(g_direct_hash, g_direct_equal); | 558 | GHashTable * pidssignaled = g_hash_table_new(g_direct_hash, g_direct_equal); |
108 | 508 | guint hash_table_size = 0; | 559 | guint hash_table_size = 0; |
109 | @@ -543,6 +594,7 @@ | |||
110 | 543 | /* If it grew, then try again */ | 594 | /* If it grew, then try again */ |
111 | 544 | } while (hash_table_size != g_hash_table_size(pidssignaled)); | 595 | } while (hash_table_size != g_hash_table_size(pidssignaled)); |
112 | 545 | 596 | ||
113 | 597 | notify_signalling(g_hash_table_get_keys(pidssignaled), appid, signal_name); | ||
114 | 546 | g_hash_table_destroy(pidssignaled); | 598 | g_hash_table_destroy(pidssignaled); |
115 | 547 | 599 | ||
116 | 548 | return retval; | 600 | return retval; |
117 | @@ -612,14 +664,14 @@ | |||
118 | 612 | ubuntu_app_launch_pause_application (const gchar * appid) | 664 | ubuntu_app_launch_pause_application (const gchar * appid) |
119 | 613 | { | 665 | { |
120 | 614 | report_zg_event(appid, ZEITGEIST_ZG_LEAVE_EVENT); | 666 | report_zg_event(appid, ZEITGEIST_ZG_LEAVE_EVENT); |
122 | 615 | return signal_to_cgroup(appid, SIGSTOP, "900"); | 667 | return signal_to_cgroup(appid, SIGSTOP, "900", "ApplicationPaused"); |
123 | 616 | } | 668 | } |
124 | 617 | 669 | ||
125 | 618 | gboolean | 670 | gboolean |
126 | 619 | ubuntu_app_launch_resume_application (const gchar * appid) | 671 | ubuntu_app_launch_resume_application (const gchar * appid) |
127 | 620 | { | 672 | { |
128 | 621 | report_zg_event(appid, ZEITGEIST_ZG_ACCESS_EVENT); | 673 | report_zg_event(appid, ZEITGEIST_ZG_ACCESS_EVENT); |
130 | 622 | return signal_to_cgroup(appid, SIGCONT, "100"); | 674 | return signal_to_cgroup(appid, SIGCONT, "100", "ApplicationResumed"); |
131 | 623 | } | 675 | } |
132 | 624 | 676 | ||
133 | 625 | gchar * | 677 | gchar * |
134 | @@ -709,6 +761,16 @@ | |||
135 | 709 | gpointer user_data; | 761 | gpointer user_data; |
136 | 710 | }; | 762 | }; |
137 | 711 | 763 | ||
138 | 764 | /* The data we keep for each failed observer */ | ||
139 | 765 | typedef struct _paused_resumed_observer_t paused_resumed_observer_t; | ||
140 | 766 | struct _paused_resumed_observer_t { | ||
141 | 767 | GDBusConnection * conn; | ||
142 | 768 | guint sighandle; | ||
143 | 769 | UbuntuAppLaunchAppPausedResumedObserver func; | ||
144 | 770 | gpointer user_data; | ||
145 | 771 | const gchar * lttng_signal; | ||
146 | 772 | }; | ||
147 | 773 | |||
148 | 712 | /* The lists of Observers */ | 774 | /* The lists of Observers */ |
149 | 713 | static GList * starting_array = NULL; | 775 | static GList * starting_array = NULL; |
150 | 714 | static GList * started_array = NULL; | 776 | static GList * started_array = NULL; |
151 | @@ -716,6 +778,8 @@ | |||
152 | 716 | static GList * focus_array = NULL; | 778 | static GList * focus_array = NULL; |
153 | 717 | static GList * resume_array = NULL; | 779 | static GList * resume_array = NULL; |
154 | 718 | static GList * failed_array = NULL; | 780 | static GList * failed_array = NULL; |
155 | 781 | static GList * paused_array = NULL; | ||
156 | 782 | static GList * resumed_array = NULL; | ||
157 | 719 | 783 | ||
158 | 720 | static void | 784 | static void |
159 | 721 | observer_cb (GDBusConnection * conn, const gchar * sender, const gchar * object, const gchar * interface, const gchar * signal, GVariant * params, gpointer user_data) | 785 | observer_cb (GDBusConnection * conn, const gchar * sender, const gchar * object, const gchar * interface, const gchar * signal, GVariant * params, gpointer user_data) |
160 | @@ -994,6 +1058,81 @@ | |||
161 | 994 | return TRUE; | 1058 | return TRUE; |
162 | 995 | } | 1059 | } |
163 | 996 | 1060 | ||
164 | 1061 | /* Handle the paused signal when it occurs, call the observer */ | ||
165 | 1062 | static void | ||
166 | 1063 | paused_signal_cb (GDBusConnection * conn, const gchar * sender, const gchar * object, const gchar * interface, const gchar * signal, GVariant * params, gpointer user_data) | ||
167 | 1064 | { | ||
168 | 1065 | paused_resumed_observer_t * observer = (paused_resumed_observer_t *)user_data; | ||
169 | 1066 | |||
170 | 1067 | ual_tracepoint(observer_start, observer->lttng_signal); | ||
171 | 1068 | |||
172 | 1069 | if (observer->func != NULL) { | ||
173 | 1070 | GArray * pidarray = g_array_new(TRUE, TRUE, sizeof(GPid)); | ||
174 | 1071 | GVariant * appid = g_variant_get_child_value(params, 0); | ||
175 | 1072 | GVariant * pids = g_variant_get_child_value(params, 1); | ||
176 | 1073 | guint64 pid; | ||
177 | 1074 | GVariantIter thispid; | ||
178 | 1075 | g_variant_iter_init(&thispid, pids); | ||
179 | 1076 | |||
180 | 1077 | while (g_variant_iter_loop(&thispid, "t", &pid)) { | ||
181 | 1078 | GPid gpid = (GPid)pid; /* Should be a no-op for most architectures, but just in case */ | ||
182 | 1079 | g_array_append_val(pidarray, gpid); | ||
183 | 1080 | } | ||
184 | 1081 | |||
185 | 1082 | observer->func(g_variant_get_string(appid, NULL), (GPid *)pidarray->data, observer->user_data); | ||
186 | 1083 | |||
187 | 1084 | g_array_free(pidarray, TRUE); | ||
188 | 1085 | g_variant_unref(appid); | ||
189 | 1086 | g_variant_unref(pids); | ||
190 | 1087 | } | ||
191 | 1088 | |||
192 | 1089 | ual_tracepoint(observer_finish, observer->lttng_signal); | ||
193 | 1090 | } | ||
194 | 1091 | |||
195 | 1092 | static gboolean | ||
196 | 1093 | paused_resumed_generic (UbuntuAppLaunchAppPausedResumedObserver observer, gpointer user_data, GList ** queue, const gchar * signal_name, const gchar * lttng_signal) | ||
197 | 1094 | { | ||
198 | 1095 | GDBusConnection * conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); | ||
199 | 1096 | |||
200 | 1097 | if (conn == NULL) { | ||
201 | 1098 | return FALSE; | ||
202 | 1099 | } | ||
203 | 1100 | |||
204 | 1101 | paused_resumed_observer_t * observert = g_new0(paused_resumed_observer_t, 1); | ||
205 | 1102 | |||
206 | 1103 | observert->conn = conn; | ||
207 | 1104 | observert->func = observer; | ||
208 | 1105 | observert->user_data = user_data; | ||
209 | 1106 | observert->lttng_signal = lttng_signal; | ||
210 | 1107 | |||
211 | 1108 | *queue = g_list_prepend(*queue, observert); | ||
212 | 1109 | |||
213 | 1110 | observert->sighandle = g_dbus_connection_signal_subscribe(conn, | ||
214 | 1111 | NULL, /* sender */ | ||
215 | 1112 | "com.canonical.UbuntuAppLaunch", /* interface */ | ||
216 | 1113 | signal_name, /* signal */ | ||
217 | 1114 | "/", /* path */ | ||
218 | 1115 | NULL, /* arg0 */ | ||
219 | 1116 | G_DBUS_SIGNAL_FLAGS_NONE, | ||
220 | 1117 | paused_signal_cb, | ||
221 | 1118 | observert, | ||
222 | 1119 | NULL); /* user data destroy */ | ||
223 | 1120 | |||
224 | 1121 | return TRUE; | ||
225 | 1122 | } | ||
226 | 1123 | |||
227 | 1124 | gboolean | ||
228 | 1125 | ubuntu_app_launch_observer_add_app_paused (UbuntuAppLaunchAppPausedResumedObserver observer, gpointer user_data) | ||
229 | 1126 | { | ||
230 | 1127 | return paused_resumed_generic(observer, user_data, &paused_array, "ApplicationPaused", "paused"); | ||
231 | 1128 | } | ||
232 | 1129 | |||
233 | 1130 | gboolean | ||
234 | 1131 | ubuntu_app_launch_observer_add_app_resumed (UbuntuAppLaunchAppPausedResumedObserver observer, gpointer user_data) | ||
235 | 1132 | { | ||
236 | 1133 | return paused_resumed_generic(observer, user_data, &resumed_array, "ApplicationResumed", "resumed"); | ||
237 | 1134 | } | ||
238 | 1135 | |||
239 | 997 | static gboolean | 1136 | static gboolean |
240 | 998 | delete_app_generic (UbuntuAppLaunchAppObserver observer, gpointer user_data, GList ** list) | 1137 | delete_app_generic (UbuntuAppLaunchAppObserver observer, gpointer user_data, GList ** list) |
241 | 999 | { | 1138 | { |
242 | @@ -1078,6 +1217,45 @@ | |||
243 | 1078 | return TRUE; | 1217 | return TRUE; |
244 | 1079 | } | 1218 | } |
245 | 1080 | 1219 | ||
246 | 1220 | static gboolean | ||
247 | 1221 | paused_resumed_delete (UbuntuAppLaunchAppPausedResumedObserver observer, gpointer user_data, GList ** list) | ||
248 | 1222 | { | ||
249 | 1223 | paused_resumed_observer_t * observert = NULL; | ||
250 | 1224 | GList * look; | ||
251 | 1225 | |||
252 | 1226 | for (look = *list; look != NULL; look = g_list_next(look)) { | ||
253 | 1227 | observert = (paused_resumed_observer_t *)look->data; | ||
254 | 1228 | |||
255 | 1229 | if (observert->func == observer && observert->user_data == user_data) { | ||
256 | 1230 | break; | ||
257 | 1231 | } | ||
258 | 1232 | } | ||
259 | 1233 | |||
260 | 1234 | if (look == NULL) { | ||
261 | 1235 | return FALSE; | ||
262 | 1236 | } | ||
263 | 1237 | |||
264 | 1238 | g_dbus_connection_signal_unsubscribe(observert->conn, observert->sighandle); | ||
265 | 1239 | g_object_unref(observert->conn); | ||
266 | 1240 | |||
267 | 1241 | g_free(observert); | ||
268 | 1242 | *list = g_list_delete_link(*list, look); | ||
269 | 1243 | |||
270 | 1244 | return TRUE; | ||
271 | 1245 | } | ||
272 | 1246 | |||
273 | 1247 | gboolean | ||
274 | 1248 | ubuntu_app_launch_observer_delete_app_paused (UbuntuAppLaunchAppPausedResumedObserver observer, gpointer user_data) | ||
275 | 1249 | { | ||
276 | 1250 | return paused_resumed_delete(observer, user_data, &paused_array); | ||
277 | 1251 | } | ||
278 | 1252 | |||
279 | 1253 | gboolean | ||
280 | 1254 | ubuntu_app_launch_observer_delete_app_resumed (UbuntuAppLaunchAppPausedResumedObserver observer, gpointer user_data) | ||
281 | 1255 | { | ||
282 | 1256 | return paused_resumed_delete(observer, user_data, &resumed_array); | ||
283 | 1257 | } | ||
284 | 1258 | |||
285 | 1081 | typedef void (*per_instance_func_t) (GDBusConnection * con, GVariant * prop_dict, gpointer user_data); | 1259 | typedef void (*per_instance_func_t) (GDBusConnection * con, GVariant * prop_dict, gpointer user_data); |
286 | 1082 | 1260 | ||
287 | 1083 | static void | 1261 | static void |
288 | 1084 | 1262 | ||
289 | === modified file 'libubuntu-app-launch/ubuntu-app-launch.h' | |||
290 | --- libubuntu-app-launch/ubuntu-app-launch.h 2014-08-13 15:11:45 +0000 | |||
291 | +++ libubuntu-app-launch/ubuntu-app-launch.h 2015-03-04 14:26:50 +0000 | |||
292 | @@ -53,6 +53,15 @@ | |||
293 | 53 | typedef void (*UbuntuAppLaunchAppFailedObserver) (const gchar * appid, UbuntuAppLaunchAppFailed failure_type, gpointer user_data); | 53 | typedef void (*UbuntuAppLaunchAppFailedObserver) (const gchar * appid, UbuntuAppLaunchAppFailed failure_type, gpointer user_data); |
294 | 54 | 54 | ||
295 | 55 | /** | 55 | /** |
296 | 56 | * UbuntuAppLaunchAppPausedResumedObserver: | ||
297 | 57 | * @appid: App ID of the application being paused | ||
298 | 58 | * @pids: Zero terminated array of PIDs | ||
299 | 59 | * | ||
300 | 60 | * Function prototype for application paused and resumed observers. | ||
301 | 61 | */ | ||
302 | 62 | typedef void (*UbuntuAppLaunchAppPausedResumedObserver) (const gchar * appid, GPid * pids, gpointer user_data); | ||
303 | 63 | |||
304 | 64 | /** | ||
305 | 56 | * UbuntuAppLaunchHelperObserver: | 65 | * UbuntuAppLaunchHelperObserver: |
306 | 57 | * | 66 | * |
307 | 58 | * Function to watch for helpers that are starting and stopping | 67 | * Function to watch for helpers that are starting and stopping |
308 | @@ -210,6 +219,32 @@ | |||
309 | 210 | gpointer user_data); | 219 | gpointer user_data); |
310 | 211 | 220 | ||
311 | 212 | /** | 221 | /** |
312 | 222 | * ubuntu_app_launch_observer_add_app_paused: | ||
313 | 223 | * @observer: (scope notified): Callback when an application is paused | ||
314 | 224 | * @user_data: (allow-none) (closure): Data to pass to the observer | ||
315 | 225 | * | ||
316 | 226 | * Sets up a callback to get called each time an application | ||
317 | 227 | * is paused. | ||
318 | 228 | * | ||
319 | 229 | * Return value: Whether adding the observer was successful. | ||
320 | 230 | */ | ||
321 | 231 | gboolean ubuntu_app_launch_observer_add_app_paused (UbuntuAppLaunchAppPausedResumedObserver observer, | ||
322 | 232 | gpointer user_data); | ||
323 | 233 | |||
324 | 234 | /** | ||
325 | 235 | * ubuntu_app_launch_observer_add_app_resumed: | ||
326 | 236 | * @observer: (scope notified): Callback when an application is resumed | ||
327 | 237 | * @user_data: (allow-none) (closure): Data to pass to the observer | ||
328 | 238 | * | ||
329 | 239 | * Sets up a callback to get called each time an application | ||
330 | 240 | * is resumed. Which is after the SIGCONT has been sent to the pids. | ||
331 | 241 | * | ||
332 | 242 | * Return value: Whether adding the observer was successful. | ||
333 | 243 | */ | ||
334 | 244 | gboolean ubuntu_app_launch_observer_add_app_resumed (UbuntuAppLaunchAppPausedResumedObserver observer, | ||
335 | 245 | gpointer user_data); | ||
336 | 246 | |||
337 | 247 | /** | ||
338 | 213 | * ubuntu_app_launch_observer_delete_app_starting: | 248 | * ubuntu_app_launch_observer_delete_app_starting: |
339 | 214 | * @observer: (scope notified): Callback to remove | 249 | * @observer: (scope notified): Callback to remove |
340 | 215 | * @user_data: (closure) (allow-none): Data that was passed to the observer | 250 | * @user_data: (closure) (allow-none): Data that was passed to the observer |
341 | @@ -221,6 +256,7 @@ | |||
342 | 221 | */ | 256 | */ |
343 | 222 | gboolean ubuntu_app_launch_observer_delete_app_starting (UbuntuAppLaunchAppObserver observer, | 257 | gboolean ubuntu_app_launch_observer_delete_app_starting (UbuntuAppLaunchAppObserver observer, |
344 | 223 | gpointer user_data); | 258 | gpointer user_data); |
345 | 259 | |||
346 | 224 | /** | 260 | /** |
347 | 225 | * ubuntu_app_launch_observer_delete_app_started: | 261 | * ubuntu_app_launch_observer_delete_app_started: |
348 | 226 | * @observer: (scope notified): Callback to remove | 262 | * @observer: (scope notified): Callback to remove |
349 | @@ -284,6 +320,33 @@ | |||
350 | 284 | */ | 320 | */ |
351 | 285 | gboolean ubuntu_app_launch_observer_delete_app_failed (UbuntuAppLaunchAppFailedObserver observer, | 321 | gboolean ubuntu_app_launch_observer_delete_app_failed (UbuntuAppLaunchAppFailedObserver observer, |
352 | 286 | gpointer user_data); | 322 | gpointer user_data); |
353 | 323 | |||
354 | 324 | /** | ||
355 | 325 | * ubuntu_app_launch_observer_delete_app_paused: | ||
356 | 326 | * @observer: (scope notified): Callback to remove | ||
357 | 327 | * @user_data: (closure) (allow-none): Data to pass to the observer | ||
358 | 328 | * | ||
359 | 329 | * Removes a previously registered callback to ensure it no longer | ||
360 | 330 | * gets signaled. | ||
361 | 331 | * | ||
362 | 332 | * Return value: Whether deleting the observer was successful. | ||
363 | 333 | */ | ||
364 | 334 | gboolean ubuntu_app_launch_observer_delete_app_paused (UbuntuAppLaunchAppPausedResumedObserver observer, | ||
365 | 335 | gpointer user_data); | ||
366 | 336 | |||
367 | 337 | /** | ||
368 | 338 | * ubuntu_app_launch_observer_delete_app_resumed: | ||
369 | 339 | * @observer: (scope notified): Callback to remove | ||
370 | 340 | * @user_data: (closure) (allow-none): Data to pass to the observer | ||
371 | 341 | * | ||
372 | 342 | * Removes a previously registered callback to ensure it no longer | ||
373 | 343 | * gets signaled. | ||
374 | 344 | * | ||
375 | 345 | * Return value: Whether deleting the observer was successful. | ||
376 | 346 | */ | ||
377 | 347 | gboolean ubuntu_app_launch_observer_delete_app_resumed (UbuntuAppLaunchAppPausedResumedObserver observer, | ||
378 | 348 | gpointer user_data); | ||
379 | 349 | |||
380 | 287 | /** | 350 | /** |
381 | 288 | * ubuntu_app_launch_list_running_apps: | 351 | * ubuntu_app_launch_list_running_apps: |
382 | 289 | * | 352 | * |
383 | 290 | 353 | ||
384 | === modified file 'tests/libual-test.cc' | |||
385 | --- tests/libual-test.cc 2014-10-28 12:43:11 +0000 | |||
386 | +++ tests/libual-test.cc 2015-03-04 14:26:50 +0000 | |||
387 | @@ -1272,6 +1272,14 @@ | |||
388 | 1272 | return TRUE; | 1272 | return TRUE; |
389 | 1273 | } | 1273 | } |
390 | 1274 | 1274 | ||
391 | 1275 | static void | ||
392 | 1276 | signal_increment (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * signal, GVariant * params, gpointer user_data) | ||
393 | 1277 | { | ||
394 | 1278 | guint * count = (guint *)user_data; | ||
395 | 1279 | g_debug("Count incremented to: %d", *count + 1); | ||
396 | 1280 | *count = *count + 1; | ||
397 | 1281 | } | ||
398 | 1282 | |||
399 | 1275 | TEST_F(LibUAL, PauseResume) | 1283 | TEST_F(LibUAL, PauseResume) |
400 | 1276 | { | 1284 | { |
401 | 1277 | g_setenv("UBUNTU_APP_LAUNCH_OOM_PROC_PATH", CMAKE_BINARY_DIR "/libual-proc" , 1); | 1285 | g_setenv("UBUNTU_APP_LAUNCH_OOM_PROC_PATH", CMAKE_BINARY_DIR "/libual-proc" , 1); |
402 | @@ -1342,8 +1350,33 @@ | |||
403 | 1342 | } while (dbus_test_task_get_state(DBUS_TEST_TASK(cgmock2)) != DBUS_TEST_TASK_STATE_RUNNING && | 1350 | } while (dbus_test_task_get_state(DBUS_TEST_TASK(cgmock2)) != DBUS_TEST_TASK_STATE_RUNNING && |
404 | 1343 | dbus_test_task_get_state(DBUS_TEST_TASK(zgmock)) != DBUS_TEST_TASK_STATE_RUNNING); | 1351 | dbus_test_task_get_state(DBUS_TEST_TASK(zgmock)) != DBUS_TEST_TASK_STATE_RUNNING); |
405 | 1344 | 1352 | ||
406 | 1353 | /* Setup signal handling */ | ||
407 | 1354 | guint paused_count = 0; | ||
408 | 1355 | guint resumed_count = 0; | ||
409 | 1356 | guint paused_signal = g_dbus_connection_signal_subscribe(bus, | ||
410 | 1357 | nullptr, | ||
411 | 1358 | "com.canonical.UbuntuAppLaunch", | ||
412 | 1359 | "ApplicationPaused", | ||
413 | 1360 | "/", | ||
414 | 1361 | nullptr, | ||
415 | 1362 | G_DBUS_SIGNAL_FLAGS_NONE, | ||
416 | 1363 | signal_increment, | ||
417 | 1364 | &paused_count, | ||
418 | 1365 | nullptr); | ||
419 | 1366 | guint resumed_signal = g_dbus_connection_signal_subscribe(bus, | ||
420 | 1367 | nullptr, | ||
421 | 1368 | "com.canonical.UbuntuAppLaunch", | ||
422 | 1369 | "ApplicationResumed", | ||
423 | 1370 | "/", | ||
424 | 1371 | nullptr, | ||
425 | 1372 | G_DBUS_SIGNAL_FLAGS_NONE, | ||
426 | 1373 | signal_increment, | ||
427 | 1374 | &resumed_count, | ||
428 | 1375 | nullptr); | ||
429 | 1376 | |||
430 | 1345 | /* Test it */ | 1377 | /* Test it */ |
431 | 1346 | EXPECT_NE(0, datacnt); | 1378 | EXPECT_NE(0, datacnt); |
432 | 1379 | paused_count = 0; | ||
433 | 1347 | 1380 | ||
434 | 1348 | /* Pause the app */ | 1381 | /* Pause the app */ |
435 | 1349 | EXPECT_TRUE(ubuntu_app_launch_pause_application("com.test.good_application_1.2.3")); | 1382 | EXPECT_TRUE(ubuntu_app_launch_pause_application("com.test.good_application_1.2.3")); |
436 | @@ -1354,6 +1387,7 @@ | |||
437 | 1354 | pause(200); | 1387 | pause(200); |
438 | 1355 | 1388 | ||
439 | 1356 | /* Check data coming out */ | 1389 | /* Check data coming out */ |
440 | 1390 | EXPECT_EQ(1, paused_count); | ||
441 | 1357 | EXPECT_EQ(0, datacnt); | 1391 | EXPECT_EQ(0, datacnt); |
442 | 1358 | 1392 | ||
443 | 1359 | /* Check to make sure we sent the event to ZG */ | 1393 | /* Check to make sure we sent the event to ZG */ |
444 | @@ -1370,6 +1404,7 @@ | |||
445 | 1370 | ASSERT_TRUE(g_file_get_contents(oomadjfile, &pauseoomscore, NULL, NULL)); | 1404 | ASSERT_TRUE(g_file_get_contents(oomadjfile, &pauseoomscore, NULL, NULL)); |
446 | 1371 | EXPECT_STREQ("900", pauseoomscore); | 1405 | EXPECT_STREQ("900", pauseoomscore); |
447 | 1372 | g_free(pauseoomscore); | 1406 | g_free(pauseoomscore); |
448 | 1407 | resumed_count = 0; | ||
449 | 1373 | 1408 | ||
450 | 1374 | /* Now Resume the App */ | 1409 | /* Now Resume the App */ |
451 | 1375 | EXPECT_TRUE(ubuntu_app_launch_resume_application("com.test.good_application_1.2.3")); | 1410 | EXPECT_TRUE(ubuntu_app_launch_resume_application("com.test.good_application_1.2.3")); |
452 | @@ -1377,6 +1412,7 @@ | |||
453 | 1377 | pause(200); | 1412 | pause(200); |
454 | 1378 | 1413 | ||
455 | 1379 | EXPECT_NE(0, datacnt); | 1414 | EXPECT_NE(0, datacnt); |
456 | 1415 | EXPECT_EQ(1, resumed_count); | ||
457 | 1380 | 1416 | ||
458 | 1381 | /* Check to make sure we sent the event to ZG */ | 1417 | /* Check to make sure we sent the event to ZG */ |
459 | 1382 | numcalls = 0; | 1418 | numcalls = 0; |
460 | @@ -1400,6 +1436,9 @@ | |||
461 | 1400 | 1436 | ||
462 | 1401 | g_spawn_command_line_sync("rm -rf " CMAKE_BINARY_DIR "/libual-proc", NULL, NULL, NULL, NULL); | 1437 | g_spawn_command_line_sync("rm -rf " CMAKE_BINARY_DIR "/libual-proc", NULL, NULL, NULL, NULL); |
463 | 1402 | 1438 | ||
464 | 1439 | g_dbus_connection_signal_unsubscribe(bus, paused_signal); | ||
465 | 1440 | g_dbus_connection_signal_unsubscribe(bus, resumed_signal); | ||
466 | 1441 | |||
467 | 1403 | /* Kill ZG default instance :-( */ | 1442 | /* Kill ZG default instance :-( */ |
468 | 1404 | ZeitgeistLog * log = zeitgeist_log_get_default(); | 1443 | ZeitgeistLog * log = zeitgeist_log_get_default(); |
469 | 1405 | g_object_unref(log); | 1444 | g_object_unref(log); |
470 | 1406 | 1445 | ||
471 | === modified file 'tools/ubuntu-app-watch.c' | |||
472 | --- tools/ubuntu-app-watch.c 2014-04-30 16:34:06 +0000 | |||
473 | +++ tools/ubuntu-app-watch.c 2015-03-04 14:26:50 +0000 | |||
474 | @@ -41,9 +41,16 @@ | |||
475 | 41 | } | 41 | } |
476 | 42 | 42 | ||
477 | 43 | void | 43 | void |
481 | 44 | resume (const gchar * appid, gpointer user_data) | 44 | resumed (const gchar * appid, GPid * pids, gpointer user_data) |
482 | 45 | { | 45 | { |
483 | 46 | g_print("Resume %s\n", appid); | 46 | g_print("Resumed %s\n", appid); |
484 | 47 | return; | ||
485 | 48 | } | ||
486 | 49 | |||
487 | 50 | void | ||
488 | 51 | paused (const gchar * appid, GPid * pids, gpointer user_data) | ||
489 | 52 | { | ||
490 | 53 | g_print("Paused %s\n", appid); | ||
491 | 47 | return; | 54 | return; |
492 | 48 | } | 55 | } |
493 | 49 | 56 | ||
494 | @@ -79,7 +86,8 @@ | |||
495 | 79 | ubuntu_app_launch_observer_add_app_started(started, NULL); | 86 | ubuntu_app_launch_observer_add_app_started(started, NULL); |
496 | 80 | ubuntu_app_launch_observer_add_app_stop(stopped, NULL); | 87 | ubuntu_app_launch_observer_add_app_stop(stopped, NULL); |
497 | 81 | ubuntu_app_launch_observer_add_app_focus(focus, NULL); | 88 | ubuntu_app_launch_observer_add_app_focus(focus, NULL); |
499 | 82 | ubuntu_app_launch_observer_add_app_resume(resume, NULL); | 89 | ubuntu_app_launch_observer_add_app_resumed(resumed, NULL); |
500 | 90 | ubuntu_app_launch_observer_add_app_paused(paused, NULL); | ||
501 | 83 | ubuntu_app_launch_observer_add_app_failed(fail, NULL); | 91 | ubuntu_app_launch_observer_add_app_failed(fail, NULL); |
502 | 84 | 92 | ||
503 | 85 | GMainLoop * mainloop = g_main_loop_new(NULL, FALSE); | 93 | GMainLoop * mainloop = g_main_loop_new(NULL, FALSE); |
504 | @@ -89,7 +97,8 @@ | |||
505 | 89 | ubuntu_app_launch_observer_delete_app_started(started, NULL); | 97 | ubuntu_app_launch_observer_delete_app_started(started, NULL); |
506 | 90 | ubuntu_app_launch_observer_delete_app_stop(stopped, NULL); | 98 | ubuntu_app_launch_observer_delete_app_stop(stopped, NULL); |
507 | 91 | ubuntu_app_launch_observer_delete_app_focus(focus, NULL); | 99 | ubuntu_app_launch_observer_delete_app_focus(focus, NULL); |
509 | 92 | ubuntu_app_launch_observer_delete_app_resume(resume, NULL); | 100 | ubuntu_app_launch_observer_delete_app_resumed(resumed, NULL); |
510 | 101 | ubuntu_app_launch_observer_delete_app_paused(paused, NULL); | ||
511 | 93 | ubuntu_app_launch_observer_delete_app_failed(fail, NULL); | 102 | ubuntu_app_launch_observer_delete_app_failed(fail, NULL); |
512 | 94 | 103 | ||
513 | 95 | g_main_loop_unref(mainloop); | 104 | g_main_loop_unref(mainloop); |
FAILED: Continuous integration, rev:195 jenkins. qa.ubuntu. com/job/ upstart- app-launch- ci/313/ jenkins. qa.ubuntu. com/job/ upstart- app-launch- vivid-amd64- ci/8/console jenkins. qa.ubuntu. com/job/ upstart- app-launch- vivid-armhf- ci/8/console jenkins. qa.ubuntu. com/job/ upstart- app-launch- vivid-i386- ci/8/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/upstart- app-launch- ci/313/ rebuild
http://