Merge lp:~ted/ubuntu-app-launch/suspend-signal into lp:ubuntu-app-launch/15.04

Proposed by Ted Gould
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
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.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
196. By Ted Gould

Add in symbols

197. By Ted Gould

Attaching bug

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
198. By Ted Gould

Adding to the informational dbus xml file

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
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.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'data/com.canonical.UbuntuAppLaunch.xml'
--- data/com.canonical.UbuntuAppLaunch.xml 2014-04-30 15:45:23 +0000
+++ data/com.canonical.UbuntuAppLaunch.xml 2015-03-04 14:26:50 +0000
@@ -20,5 +20,13 @@
20 <arg type="s" name="appid" />20 <arg type="s" name="appid" />
21 <arg type="s" name="stage" />21 <arg type="s" name="stage" />
22 </signal>22 </signal>
23 <signal name="ApplicationPaused">
24 <arg type="s" name="appid" />
25 <arg type="at" name="pids" />
26 </signal>
27 <signal name="ApplicationResumed">
28 <arg type="s" name="appid" />
29 <arg type="at" name="pids" />
30 </signal>
23 </interface>31 </interface>
24</node>32</node>
2533
=== modified file 'debian/libubuntu-app-launch2.symbols'
--- debian/libubuntu-app-launch2.symbols 2014-09-15 19:40:14 +0000
+++ debian/libubuntu-app-launch2.symbols 2015-03-04 14:26:50 +0000
@@ -7,7 +7,9 @@
7 ubuntu_app_launch_list_running_apps@Base 0.47 ubuntu_app_launch_list_running_apps@Base 0.4
8 ubuntu_app_launch_observer_add_app_failed@Base 0.48 ubuntu_app_launch_observer_add_app_failed@Base 0.4
9 ubuntu_app_launch_observer_add_app_focus@Base 0.49 ubuntu_app_launch_observer_add_app_focus@Base 0.4
10 ubuntu_app_launch_observer_add_app_paused@Base 0replaceme
10 ubuntu_app_launch_observer_add_app_resume@Base 0.411 ubuntu_app_launch_observer_add_app_resume@Base 0.4
12 ubuntu_app_launch_observer_add_app_resumed@Base 0replaceme
11 ubuntu_app_launch_observer_add_app_started@Base 0.413 ubuntu_app_launch_observer_add_app_started@Base 0.4
12 ubuntu_app_launch_observer_add_app_starting@Base 0.414 ubuntu_app_launch_observer_add_app_starting@Base 0.4
13 ubuntu_app_launch_observer_add_app_stop@Base 0.415 ubuntu_app_launch_observer_add_app_stop@Base 0.4
@@ -15,7 +17,9 @@
15 ubuntu_app_launch_observer_add_helper_stop@Base 0.417 ubuntu_app_launch_observer_add_helper_stop@Base 0.4
16 ubuntu_app_launch_observer_delete_app_failed@Base 0.418 ubuntu_app_launch_observer_delete_app_failed@Base 0.4
17 ubuntu_app_launch_observer_delete_app_focus@Base 0.419 ubuntu_app_launch_observer_delete_app_focus@Base 0.4
20 ubuntu_app_launch_observer_delete_app_paused@Base 0replaceme
18 ubuntu_app_launch_observer_delete_app_resume@Base 0.421 ubuntu_app_launch_observer_delete_app_resume@Base 0.4
22 ubuntu_app_launch_observer_delete_app_resumed@Base 0replaceme
19 ubuntu_app_launch_observer_delete_app_started@Base 0.423 ubuntu_app_launch_observer_delete_app_started@Base 0.4
20 ubuntu_app_launch_observer_delete_app_starting@Base 0.424 ubuntu_app_launch_observer_delete_app_starting@Base 0.4
21 ubuntu_app_launch_observer_delete_app_stop@Base 0.425 ubuntu_app_launch_observer_delete_app_stop@Base 0.4
2226
=== modified file 'libubuntu-app-launch/ubuntu-app-launch.c'
--- libubuntu-app-launch/ubuntu-app-launch.c 2014-11-20 20:33:59 +0000
+++ libubuntu-app-launch/ubuntu-app-launch.c 2015-03-04 14:26:50 +0000
@@ -499,10 +499,61 @@
499 return FALSE;499 return FALSE;
500}500}
501501
502/* Throw out a DBus signal that we've signalled all of these processes. This
503 is the fun GVariant building part. */
504static void
505notify_signalling (GList * pids, const gchar * appid, const gchar * signal_name)
506{
507 GDBusConnection * conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
508 if (conn == NULL) {
509 return;
510 }
511
512 /* Pull together a PID array */
513 GVariant *pidarray = NULL;
514 if (pids == NULL) {
515 pidarray = g_variant_new_array(G_VARIANT_TYPE_UINT64, NULL, 0);
516 } else {
517 GList * i;
518 GVariantBuilder builder;
519 g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);
520
521 for (i = pids; i != NULL; i = g_list_next(i))
522 g_variant_builder_add_value(&builder, g_variant_new_uint64(GPOINTER_TO_INT(i->data)));
523
524 pidarray = g_variant_builder_end(&builder);
525 }
526
527 /* Combine into the wrapping tuple */
528 GVariantBuilder btuple;
529 g_variant_builder_init(&btuple, G_VARIANT_TYPE_TUPLE);
530 g_variant_builder_add_value(&btuple, g_variant_new_string(appid));
531 g_variant_builder_add_value(&btuple, pidarray);
532
533 /* Emit !!! */
534 GError * error = NULL;
535 g_dbus_connection_emit_signal(conn,
536 NULL, /* destination */
537 "/", /* path */
538 "com.canonical.UbuntuAppLaunch", /* interface */
539 signal_name, /* signal */
540 g_variant_builder_end(&btuple), /* params, the same */
541 &error);
542
543 if (error != NULL) {
544 g_warning("Unable to emit signal '%s' for appid '%s': %s", signal_name, appid, error->message);
545 g_error_free(error);
546 } else {
547 g_debug("Emmitted '%s' to DBus", signal_name);
548 }
549
550 g_object_unref(conn);
551}
552
502/* Gets all the pids for an appid and sends a signal to all of them. This also553/* Gets all the pids for an appid and sends a signal to all of them. This also
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 */
504static gboolean555static gboolean
505signal_to_cgroup (const gchar * appid, int signal, const gchar * oomscore)556signal_to_cgroup (const gchar * appid, int signal, const gchar * oomscore, const gchar * signal_name)
506{557{
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);
508 guint hash_table_size = 0;559 guint hash_table_size = 0;
@@ -543,6 +594,7 @@
543 /* If it grew, then try again */594 /* If it grew, then try again */
544 } while (hash_table_size != g_hash_table_size(pidssignaled));595 } while (hash_table_size != g_hash_table_size(pidssignaled));
545596
597 notify_signalling(g_hash_table_get_keys(pidssignaled), appid, signal_name);
546 g_hash_table_destroy(pidssignaled);598 g_hash_table_destroy(pidssignaled);
547599
548 return retval;600 return retval;
@@ -612,14 +664,14 @@
612ubuntu_app_launch_pause_application (const gchar * appid)664ubuntu_app_launch_pause_application (const gchar * appid)
613{665{
614 report_zg_event(appid, ZEITGEIST_ZG_LEAVE_EVENT);666 report_zg_event(appid, ZEITGEIST_ZG_LEAVE_EVENT);
615 return signal_to_cgroup(appid, SIGSTOP, "900");667 return signal_to_cgroup(appid, SIGSTOP, "900", "ApplicationPaused");
616}668}
617669
618gboolean670gboolean
619ubuntu_app_launch_resume_application (const gchar * appid)671ubuntu_app_launch_resume_application (const gchar * appid)
620{672{
621 report_zg_event(appid, ZEITGEIST_ZG_ACCESS_EVENT);673 report_zg_event(appid, ZEITGEIST_ZG_ACCESS_EVENT);
622 return signal_to_cgroup(appid, SIGCONT, "100");674 return signal_to_cgroup(appid, SIGCONT, "100", "ApplicationResumed");
623}675}
624676
625gchar *677gchar *
@@ -709,6 +761,16 @@
709 gpointer user_data;761 gpointer user_data;
710};762};
711763
764/* The data we keep for each failed observer */
765typedef struct _paused_resumed_observer_t paused_resumed_observer_t;
766struct _paused_resumed_observer_t {
767 GDBusConnection * conn;
768 guint sighandle;
769 UbuntuAppLaunchAppPausedResumedObserver func;
770 gpointer user_data;
771 const gchar * lttng_signal;
772};
773
712/* The lists of Observers */774/* The lists of Observers */
713static GList * starting_array = NULL;775static GList * starting_array = NULL;
714static GList * started_array = NULL;776static GList * started_array = NULL;
@@ -716,6 +778,8 @@
716static GList * focus_array = NULL;778static GList * focus_array = NULL;
717static GList * resume_array = NULL;779static GList * resume_array = NULL;
718static GList * failed_array = NULL;780static GList * failed_array = NULL;
781static GList * paused_array = NULL;
782static GList * resumed_array = NULL;
719783
720static void784static void
721observer_cb (GDBusConnection * conn, const gchar * sender, const gchar * object, const gchar * interface, const gchar * signal, GVariant * params, gpointer user_data)785observer_cb (GDBusConnection * conn, const gchar * sender, const gchar * object, const gchar * interface, const gchar * signal, GVariant * params, gpointer user_data)
@@ -994,6 +1058,81 @@
994 return TRUE;1058 return TRUE;
995}1059}
9961060
1061/* Handle the paused signal when it occurs, call the observer */
1062static void
1063paused_signal_cb (GDBusConnection * conn, const gchar * sender, const gchar * object, const gchar * interface, const gchar * signal, GVariant * params, gpointer user_data)
1064{
1065 paused_resumed_observer_t * observer = (paused_resumed_observer_t *)user_data;
1066
1067 ual_tracepoint(observer_start, observer->lttng_signal);
1068
1069 if (observer->func != NULL) {
1070 GArray * pidarray = g_array_new(TRUE, TRUE, sizeof(GPid));
1071 GVariant * appid = g_variant_get_child_value(params, 0);
1072 GVariant * pids = g_variant_get_child_value(params, 1);
1073 guint64 pid;
1074 GVariantIter thispid;
1075 g_variant_iter_init(&thispid, pids);
1076
1077 while (g_variant_iter_loop(&thispid, "t", &pid)) {
1078 GPid gpid = (GPid)pid; /* Should be a no-op for most architectures, but just in case */
1079 g_array_append_val(pidarray, gpid);
1080 }
1081
1082 observer->func(g_variant_get_string(appid, NULL), (GPid *)pidarray->data, observer->user_data);
1083
1084 g_array_free(pidarray, TRUE);
1085 g_variant_unref(appid);
1086 g_variant_unref(pids);
1087 }
1088
1089 ual_tracepoint(observer_finish, observer->lttng_signal);
1090}
1091
1092static gboolean
1093paused_resumed_generic (UbuntuAppLaunchAppPausedResumedObserver observer, gpointer user_data, GList ** queue, const gchar * signal_name, const gchar * lttng_signal)
1094{
1095 GDBusConnection * conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
1096
1097 if (conn == NULL) {
1098 return FALSE;
1099 }
1100
1101 paused_resumed_observer_t * observert = g_new0(paused_resumed_observer_t, 1);
1102
1103 observert->conn = conn;
1104 observert->func = observer;
1105 observert->user_data = user_data;
1106 observert->lttng_signal = lttng_signal;
1107
1108 *queue = g_list_prepend(*queue, observert);
1109
1110 observert->sighandle = g_dbus_connection_signal_subscribe(conn,
1111 NULL, /* sender */
1112 "com.canonical.UbuntuAppLaunch", /* interface */
1113 signal_name, /* signal */
1114 "/", /* path */
1115 NULL, /* arg0 */
1116 G_DBUS_SIGNAL_FLAGS_NONE,
1117 paused_signal_cb,
1118 observert,
1119 NULL); /* user data destroy */
1120
1121 return TRUE;
1122}
1123
1124gboolean
1125ubuntu_app_launch_observer_add_app_paused (UbuntuAppLaunchAppPausedResumedObserver observer, gpointer user_data)
1126{
1127 return paused_resumed_generic(observer, user_data, &paused_array, "ApplicationPaused", "paused");
1128}
1129
1130gboolean
1131ubuntu_app_launch_observer_add_app_resumed (UbuntuAppLaunchAppPausedResumedObserver observer, gpointer user_data)
1132{
1133 return paused_resumed_generic(observer, user_data, &resumed_array, "ApplicationResumed", "resumed");
1134}
1135
997static gboolean1136static gboolean
998delete_app_generic (UbuntuAppLaunchAppObserver observer, gpointer user_data, GList ** list)1137delete_app_generic (UbuntuAppLaunchAppObserver observer, gpointer user_data, GList ** list)
999{1138{
@@ -1078,6 +1217,45 @@
1078 return TRUE;1217 return TRUE;
1079}1218}
10801219
1220static gboolean
1221paused_resumed_delete (UbuntuAppLaunchAppPausedResumedObserver observer, gpointer user_data, GList ** list)
1222{
1223 paused_resumed_observer_t * observert = NULL;
1224 GList * look;
1225
1226 for (look = *list; look != NULL; look = g_list_next(look)) {
1227 observert = (paused_resumed_observer_t *)look->data;
1228
1229 if (observert->func == observer && observert->user_data == user_data) {
1230 break;
1231 }
1232 }
1233
1234 if (look == NULL) {
1235 return FALSE;
1236 }
1237
1238 g_dbus_connection_signal_unsubscribe(observert->conn, observert->sighandle);
1239 g_object_unref(observert->conn);
1240
1241 g_free(observert);
1242 *list = g_list_delete_link(*list, look);
1243
1244 return TRUE;
1245}
1246
1247gboolean
1248ubuntu_app_launch_observer_delete_app_paused (UbuntuAppLaunchAppPausedResumedObserver observer, gpointer user_data)
1249{
1250 return paused_resumed_delete(observer, user_data, &paused_array);
1251}
1252
1253gboolean
1254ubuntu_app_launch_observer_delete_app_resumed (UbuntuAppLaunchAppPausedResumedObserver observer, gpointer user_data)
1255{
1256 return paused_resumed_delete(observer, user_data, &resumed_array);
1257}
1258
1081typedef void (*per_instance_func_t) (GDBusConnection * con, GVariant * prop_dict, gpointer user_data);1259typedef void (*per_instance_func_t) (GDBusConnection * con, GVariant * prop_dict, gpointer user_data);
10821260
1083static void1261static void
10841262
=== modified file 'libubuntu-app-launch/ubuntu-app-launch.h'
--- libubuntu-app-launch/ubuntu-app-launch.h 2014-08-13 15:11:45 +0000
+++ libubuntu-app-launch/ubuntu-app-launch.h 2015-03-04 14:26:50 +0000
@@ -53,6 +53,15 @@
53typedef void (*UbuntuAppLaunchAppFailedObserver) (const gchar * appid, UbuntuAppLaunchAppFailed failure_type, gpointer user_data);53typedef void (*UbuntuAppLaunchAppFailedObserver) (const gchar * appid, UbuntuAppLaunchAppFailed failure_type, gpointer user_data);
5454
55/**55/**
56 * UbuntuAppLaunchAppPausedResumedObserver:
57 * @appid: App ID of the application being paused
58 * @pids: Zero terminated array of PIDs
59 *
60 * Function prototype for application paused and resumed observers.
61 */
62typedef void (*UbuntuAppLaunchAppPausedResumedObserver) (const gchar * appid, GPid * pids, gpointer user_data);
63
64/**
56 * UbuntuAppLaunchHelperObserver:65 * UbuntuAppLaunchHelperObserver:
57 *66 *
58 * Function to watch for helpers that are starting and stopping67 * Function to watch for helpers that are starting and stopping
@@ -210,6 +219,32 @@
210 gpointer user_data);219 gpointer user_data);
211220
212/**221/**
222 * ubuntu_app_launch_observer_add_app_paused:
223 * @observer: (scope notified): Callback when an application is paused
224 * @user_data: (allow-none) (closure): Data to pass to the observer
225 *
226 * Sets up a callback to get called each time an application
227 * is paused.
228 *
229 * Return value: Whether adding the observer was successful.
230 */
231gboolean ubuntu_app_launch_observer_add_app_paused (UbuntuAppLaunchAppPausedResumedObserver observer,
232 gpointer user_data);
233
234/**
235 * ubuntu_app_launch_observer_add_app_resumed:
236 * @observer: (scope notified): Callback when an application is resumed
237 * @user_data: (allow-none) (closure): Data to pass to the observer
238 *
239 * Sets up a callback to get called each time an application
240 * is resumed. Which is after the SIGCONT has been sent to the pids.
241 *
242 * Return value: Whether adding the observer was successful.
243 */
244gboolean ubuntu_app_launch_observer_add_app_resumed (UbuntuAppLaunchAppPausedResumedObserver observer,
245 gpointer user_data);
246
247/**
213 * ubuntu_app_launch_observer_delete_app_starting:248 * ubuntu_app_launch_observer_delete_app_starting:
214 * @observer: (scope notified): Callback to remove249 * @observer: (scope notified): Callback to remove
215 * @user_data: (closure) (allow-none): Data that was passed to the observer250 * @user_data: (closure) (allow-none): Data that was passed to the observer
@@ -221,6 +256,7 @@
221 */256 */
222gboolean ubuntu_app_launch_observer_delete_app_starting (UbuntuAppLaunchAppObserver observer,257gboolean ubuntu_app_launch_observer_delete_app_starting (UbuntuAppLaunchAppObserver observer,
223 gpointer user_data);258 gpointer user_data);
259
224/**260/**
225 * ubuntu_app_launch_observer_delete_app_started:261 * ubuntu_app_launch_observer_delete_app_started:
226 * @observer: (scope notified): Callback to remove262 * @observer: (scope notified): Callback to remove
@@ -284,6 +320,33 @@
284 */320 */
285gboolean ubuntu_app_launch_observer_delete_app_failed (UbuntuAppLaunchAppFailedObserver observer,321gboolean ubuntu_app_launch_observer_delete_app_failed (UbuntuAppLaunchAppFailedObserver observer,
286 gpointer user_data);322 gpointer user_data);
323
324/**
325 * ubuntu_app_launch_observer_delete_app_paused:
326 * @observer: (scope notified): Callback to remove
327 * @user_data: (closure) (allow-none): Data to pass to the observer
328 *
329 * Removes a previously registered callback to ensure it no longer
330 * gets signaled.
331 *
332 * Return value: Whether deleting the observer was successful.
333 */
334gboolean ubuntu_app_launch_observer_delete_app_paused (UbuntuAppLaunchAppPausedResumedObserver observer,
335 gpointer user_data);
336
337/**
338 * ubuntu_app_launch_observer_delete_app_resumed:
339 * @observer: (scope notified): Callback to remove
340 * @user_data: (closure) (allow-none): Data to pass to the observer
341 *
342 * Removes a previously registered callback to ensure it no longer
343 * gets signaled.
344 *
345 * Return value: Whether deleting the observer was successful.
346 */
347gboolean ubuntu_app_launch_observer_delete_app_resumed (UbuntuAppLaunchAppPausedResumedObserver observer,
348 gpointer user_data);
349
287/**350/**
288 * ubuntu_app_launch_list_running_apps:351 * ubuntu_app_launch_list_running_apps:
289 *352 *
290353
=== modified file 'tests/libual-test.cc'
--- tests/libual-test.cc 2014-10-28 12:43:11 +0000
+++ tests/libual-test.cc 2015-03-04 14:26:50 +0000
@@ -1272,6 +1272,14 @@
1272 return TRUE;1272 return TRUE;
1273}1273}
12741274
1275static void
1276signal_increment (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * signal, GVariant * params, gpointer user_data)
1277{
1278 guint * count = (guint *)user_data;
1279 g_debug("Count incremented to: %d", *count + 1);
1280 *count = *count + 1;
1281}
1282
1275TEST_F(LibUAL, PauseResume)1283TEST_F(LibUAL, PauseResume)
1276{1284{
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);
@@ -1342,8 +1350,33 @@
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 &&
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);
13441352
1353 /* Setup signal handling */
1354 guint paused_count = 0;
1355 guint resumed_count = 0;
1356 guint paused_signal = g_dbus_connection_signal_subscribe(bus,
1357 nullptr,
1358 "com.canonical.UbuntuAppLaunch",
1359 "ApplicationPaused",
1360 "/",
1361 nullptr,
1362 G_DBUS_SIGNAL_FLAGS_NONE,
1363 signal_increment,
1364 &paused_count,
1365 nullptr);
1366 guint resumed_signal = g_dbus_connection_signal_subscribe(bus,
1367 nullptr,
1368 "com.canonical.UbuntuAppLaunch",
1369 "ApplicationResumed",
1370 "/",
1371 nullptr,
1372 G_DBUS_SIGNAL_FLAGS_NONE,
1373 signal_increment,
1374 &resumed_count,
1375 nullptr);
1376
1345 /* Test it */1377 /* Test it */
1346 EXPECT_NE(0, datacnt);1378 EXPECT_NE(0, datacnt);
1379 paused_count = 0;
13471380
1348 /* Pause the app */1381 /* Pause the app */
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"));
@@ -1354,6 +1387,7 @@
1354 pause(200);1387 pause(200);
13551388
1356 /* Check data coming out */1389 /* Check data coming out */
1390 EXPECT_EQ(1, paused_count);
1357 EXPECT_EQ(0, datacnt);1391 EXPECT_EQ(0, datacnt);
13581392
1359 /* Check to make sure we sent the event to ZG */1393 /* Check to make sure we sent the event to ZG */
@@ -1370,6 +1404,7 @@
1370 ASSERT_TRUE(g_file_get_contents(oomadjfile, &pauseoomscore, NULL, NULL));1404 ASSERT_TRUE(g_file_get_contents(oomadjfile, &pauseoomscore, NULL, NULL));
1371 EXPECT_STREQ("900", pauseoomscore);1405 EXPECT_STREQ("900", pauseoomscore);
1372 g_free(pauseoomscore);1406 g_free(pauseoomscore);
1407 resumed_count = 0;
13731408
1374 /* Now Resume the App */1409 /* Now Resume the App */
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"));
@@ -1377,6 +1412,7 @@
1377 pause(200);1412 pause(200);
13781413
1379 EXPECT_NE(0, datacnt);1414 EXPECT_NE(0, datacnt);
1415 EXPECT_EQ(1, resumed_count);
13801416
1381 /* Check to make sure we sent the event to ZG */1417 /* Check to make sure we sent the event to ZG */
1382 numcalls = 0;1418 numcalls = 0;
@@ -1400,6 +1436,9 @@
14001436
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);
14021438
1439 g_dbus_connection_signal_unsubscribe(bus, paused_signal);
1440 g_dbus_connection_signal_unsubscribe(bus, resumed_signal);
1441
1403 /* Kill ZG default instance :-( */1442 /* Kill ZG default instance :-( */
1404 ZeitgeistLog * log = zeitgeist_log_get_default();1443 ZeitgeistLog * log = zeitgeist_log_get_default();
1405 g_object_unref(log);1444 g_object_unref(log);
14061445
=== modified file 'tools/ubuntu-app-watch.c'
--- tools/ubuntu-app-watch.c 2014-04-30 16:34:06 +0000
+++ tools/ubuntu-app-watch.c 2015-03-04 14:26:50 +0000
@@ -41,9 +41,16 @@
41}41}
4242
43void43void
44resume (const gchar * appid, gpointer user_data)44resumed (const gchar * appid, GPid * pids, gpointer user_data)
45{45{
46 g_print("Resume %s\n", appid);46 g_print("Resumed %s\n", appid);
47 return;
48}
49
50void
51paused (const gchar * appid, GPid * pids, gpointer user_data)
52{
53 g_print("Paused %s\n", appid);
47 return;54 return;
48}55}
4956
@@ -79,7 +86,8 @@
79 ubuntu_app_launch_observer_add_app_started(started, NULL);86 ubuntu_app_launch_observer_add_app_started(started, NULL);
80 ubuntu_app_launch_observer_add_app_stop(stopped, NULL);87 ubuntu_app_launch_observer_add_app_stop(stopped, NULL);
81 ubuntu_app_launch_observer_add_app_focus(focus, NULL);88 ubuntu_app_launch_observer_add_app_focus(focus, NULL);
82 ubuntu_app_launch_observer_add_app_resume(resume, NULL);89 ubuntu_app_launch_observer_add_app_resumed(resumed, NULL);
90 ubuntu_app_launch_observer_add_app_paused(paused, NULL);
83 ubuntu_app_launch_observer_add_app_failed(fail, NULL);91 ubuntu_app_launch_observer_add_app_failed(fail, NULL);
8492
85 GMainLoop * mainloop = g_main_loop_new(NULL, FALSE);93 GMainLoop * mainloop = g_main_loop_new(NULL, FALSE);
@@ -89,7 +97,8 @@
89 ubuntu_app_launch_observer_delete_app_started(started, NULL);97 ubuntu_app_launch_observer_delete_app_started(started, NULL);
90 ubuntu_app_launch_observer_delete_app_stop(stopped, NULL);98 ubuntu_app_launch_observer_delete_app_stop(stopped, NULL);
91 ubuntu_app_launch_observer_delete_app_focus(focus, NULL);99 ubuntu_app_launch_observer_delete_app_focus(focus, NULL);
92 ubuntu_app_launch_observer_delete_app_resume(resume, NULL);100 ubuntu_app_launch_observer_delete_app_resumed(resumed, NULL);
101 ubuntu_app_launch_observer_delete_app_paused(paused, NULL);
93 ubuntu_app_launch_observer_delete_app_failed(fail, NULL);102 ubuntu_app_launch_observer_delete_app_failed(fail, NULL);
94103
95 g_main_loop_unref(mainloop);104 g_main_loop_unref(mainloop);

Subscribers

People subscribed via source and target branches