[Merge] lp:~albaguirre/powerd/remove-input-inactivity-handling into lp:powerd
Alberto Aguirre
alberto.aguirre at canonical.com
Wed Jun 18 16:52:58 UTC 2014
Diff comments:
> === modified file 'CMakeLists.txt'
> --- CMakeLists.txt 2014-01-14 03:14:22 +0000
> +++ CMakeLists.txt 2014-06-17 03:45:55 +0000
> @@ -21,8 +21,6 @@
>
> find_package(PkgConfig)
> pkg_check_modules(ANDROID_HEADERS android-headers)
> -pkg_check_modules(HYBRIS_IS libis)
> -pkg_check_modules(HYBRIS_SF libsf)
> pkg_check_modules(GLIB glib-2.0)
> pkg_check_modules(GIO gio-2.0)
> pkg_check_modules(GIO-UNIX gio-unix-2.0)
> @@ -45,11 +43,10 @@
> SRCS
>
> src/powerd.cpp
> + src/display.c
> src/autobrightness.c
> src/backlight.c
> src/device-config.c
> - src/display.c
> - src/display-request.c
> src/log.c
> src/power-request.c
> src/power-source.c
> @@ -85,10 +82,6 @@
> add_subdirectory(src)
> add_subdirectory(cli)
>
> -include(UseGSettings)
> -SET (POWERD_SCHEMAS "data/com.canonical.powerd.gschema.xml")
> -add_schema(${POWERD_SCHEMAS})
> -
> add_executable(
> powerd
>
> @@ -99,7 +92,6 @@
> powerd
>
> dbus_bindings
> - ${POWERD_SCHEMAS}
> )
>
> target_link_libraries(
> @@ -107,8 +99,6 @@
> suspend
>
> ${CMAKE_THREAD_LIBS_INIT}
> - ${HYBRIS_IS_LIBRARIES}
> - ${HYBRIS_SF_LIBRARIES}
> ${GLIB_LIBRARIES}
> ${GIO_LIBRARIES}
> ${GIO-UNIX_LIBRARIES}
>
> === modified file 'cli/powerd-cli.c'
> --- cli/powerd-cli.c 2014-04-23 02:21:33 +0000
> +++ cli/powerd-cli.c 2014-06-17 03:45:55 +0000
> @@ -41,6 +41,7 @@
> gboolean silent_errors = FALSE;
>
> GDBusProxy *powerd_proxy = NULL;
> +GDBusProxy *uscreen_proxy = NULL;
> char test_dbusname[128] = "";
>
> /* For tests */
> @@ -53,13 +54,6 @@
> int state;
> };
>
> -struct PublicDispRequest {
> - const char *name;
> - const char *owner;
> - enum powerd_display_state state;
> - guint32 flags;
> -};
> -
> struct SysRequestStats {
> const char *owner;
> const char *name;
> @@ -69,19 +63,6 @@
> guint64 active_since;
> };
>
> -struct DispRequestStats {
> - const char *owner;
> - const char *name;
> - unsigned active_count;
> - guint64 active_time;
> - guint64 max_active_time;
> - guint64 active_since;
> - guint64 disp_on_time;
> - guint64 disp_on_since;
> - guint64 flag_on_time[POWERD_NUM_DISPLAY_FLAGS];
> - guint64 flag_on_since[POWERD_NUM_DISPLAY_FLAGS];
> -};
> -
> static GMainLoop *main_loop = NULL;
> static powerd_cookie_t main_cookie;
> static gboolean checkForDbusName(const char *dbusname, int count,
> @@ -160,22 +141,20 @@
> }
>
> static gboolean
> -requestDisplayState(struct PublicDispRequest pdr, const char *name,
> - powerd_cookie_t *cookie)
> +requestDisplayState(int *cookie)
> {
> GVariant *ret = NULL;
> GError *error = NULL;
> - const char *cookie_ptr;
> gboolean success = TRUE;
>
> if (cookie == NULL) {
> - cli_warn("NULL cookie passed to %s", __func__);
> + cli_warn("NULL cookie store passed to %s", __func__);
> return FALSE;
> }
>
> - ret = g_dbus_proxy_call_sync(powerd_proxy,
> - "requestDisplayState",
> - g_variant_new("(siu)", name, pdr.state, pdr.flags),
> + ret = g_dbus_proxy_call_sync(uscreen_proxy,
> + "keepDisplayOn",
> + NULL,
> G_DBUS_CALL_FLAGS_NONE,
> -1,
> NULL,
> @@ -186,44 +165,8 @@
> return FALSE;
> }
>
> - g_variant_get(ret, "(&s)", &cookie_ptr);
> - if (strlen(cookie_ptr) != sizeof(powerd_cookie_t) - 1) {
> - cli_warn("Returned cookie has incorrect size");
> - success = FALSE;
> - } else {
> - strncpy(*cookie, cookie_ptr, sizeof(powerd_cookie_t));
> - cli_debug("Got cookie: %s", *cookie);
> - }
> -
> - g_variant_unref(ret);
> - return success;
> -}
> -
> -static gboolean
> -updateDisplayState(struct PublicDispRequest pdr,
> - powerd_cookie_t cookie)
> -{
> - GVariant *ret = NULL;
> - GError *error = NULL;
> - gboolean success = TRUE;
> -
> - if (cookie == NULL) {
> - cli_warn("NULL cookie passed to %s", __func__);
> - return FALSE;
> - }
> -
> - ret = g_dbus_proxy_call_sync(powerd_proxy,
> - "updateDisplayState",
> - g_variant_new("(siu)", cookie, pdr.state, pdr.flags),
> - G_DBUS_CALL_FLAGS_NONE,
> - -1,
> - NULL,
> - &error);
> - if (!ret) {
> - cli_warn("updateDisplayState failed: %s", error->message);
> - g_error_free(error);
> - return FALSE;
> - }
> + g_variant_get(ret, "(i)", cookie);
> + cli_debug("Got cookie: %d", *cookie);
>
> g_variant_unref(ret);
> return success;
> @@ -280,58 +223,6 @@
> }
> }
>
> -static GArray*
> -listDisplayRequests()
> -{
> - GVariant *ret, *item = NULL;
> - GVariantIter *iter = NULL;
> - GArray *retarray = g_array_new(FALSE, FALSE, sizeof(struct PublicDispRequest));
> - GError *error = NULL;
> - struct PublicDispRequest pdr;
> -
> - ret = g_dbus_proxy_call_sync(powerd_proxy,
> - "listDisplayRequests",
> - NULL,
> - G_DBUS_CALL_FLAGS_NONE,
> - -1,
> - NULL,
> - &error);
> - if (ret == NULL) {
> - cli_warn("listDisplayRequests failed: %s", error->message);
> - g_error_free(error);
> - }
> - else {
> - g_variant_get(ret, "(a(ssiu))", &iter);
> - while ((item = g_variant_iter_next_value (iter))) {
> - g_variant_get_child(item, 0, "s", &pdr.name);
> - g_variant_get_child(item, 1, "s", &pdr.owner);
> - g_variant_get_child(item, 2, "i", &pdr.state);
> - g_variant_get_child(item, 3, "u", &pdr.flags);
> - g_array_append_val(retarray, pdr);
> - g_variant_unref(item);
> - }
> - g_variant_unref(ret);
> - }
> - return retarray;
> -}
> -
> -static void
> -printDisplayRequests(GArray *requests)
> -{
> - int i;
> - struct PublicDispRequest *pdr;
> - printf("Display State Requests:\n");
> - if (requests->len == 0) {
> - printf(" None\n");
> - } else {
> - for (i = 0; i < requests->len; i++) {
> - pdr = &g_array_index(requests, struct PublicDispRequest, i);
> - printf(" Name: %s, Owner: %s, State: %d, Flags: %#08x\n",
> - pdr->name, pdr->owner, pdr->state, pdr->flags);
> - }
> - }
> -}
> -
> static GArray *
> getSysRequestStats(void)
> {
> @@ -395,108 +286,6 @@
> }
> }
>
> -static GArray *
> -getDispRequestStats(void)
> -{
> - GVariant *ret, *item;
> - GVariantIter *iter;
> - GArray *retarray;
> - GError *error;
> -
> - retarray = g_array_new(FALSE, FALSE, sizeof(struct DispRequestStats));
> -
> - error = NULL;
> - ret = g_dbus_proxy_call_sync(powerd_proxy,
> - "getDispRequestStats",
> - NULL,
> - G_DBUS_CALL_FLAGS_NONE,
> - -1,
> - NULL,
> - &error);
> - if (ret == NULL) {
> - cli_warn("getDispRequestStats failed: %s", error->message);
> - g_error_free(error);
> - } else {
> - g_variant_get(ret, "(a(ssutttttatat))", &iter);
> - while ((item = g_variant_iter_next_value (iter))) {
> - struct DispRequestStats stats;
> - GVariantIter *array_iter;
> - guint64 val;
> - int i;
> -
> - g_variant_get_child(item, 0, "s", &stats.owner);
> - g_variant_get_child(item, 1, "s", &stats.name);
> - g_variant_get_child(item, 2, "u", &stats.active_count);
> - g_variant_get_child(item, 3, "t", &stats.active_time);
> - g_variant_get_child(item, 4, "t", &stats.max_active_time);
> - g_variant_get_child(item, 5, "t", &stats.active_since);
> - g_variant_get_child(item, 6, "t", &stats.disp_on_time);
> - g_variant_get_child(item, 7, "t", &stats.disp_on_since);
> -
> - g_variant_get_child(item, 8, "at", &array_iter);
> - i = 0;
> - while (g_variant_iter_loop(array_iter, "t", &val)) {
> - if (i >= POWERD_NUM_DISPLAY_FLAGS)
> - break;
> - stats.flag_on_time[i++] = val;
> - }
> - g_variant_iter_free(array_iter);
> -
> - g_variant_get_child(item, 9, "at", &array_iter);
> - i = 0;
> - while (g_variant_iter_loop(array_iter, "t", &val)) {
> - if (i >= POWERD_NUM_DISPLAY_FLAGS)
> - break;
> - stats.flag_on_since[i++] = val;
> - }
> - g_variant_iter_free(array_iter);
> -
> - g_array_append_val(retarray, stats);
> - g_variant_unref(item);
> - }
> - g_variant_unref(ret);
> - }
> - return retarray;
> -}
> -
> -static void
> -printDispRequestStats(GArray *stats)
> -{
> - int i, j;
> - struct DispRequestStats *stat;
> - printf("Display Request Statistics:\n");
> - if (stats->len == 0) {
> - printf(" None\n");
> - } else {
> - printf(" %-16.16s %-20.20s %-8.8s %-16.16s %-16.16s %-16.16s %-16.16s %-16.16s",
> - "", "", "Active", "", "Max Active", "", "Display On",
> - "Display On");
> - for (i = 0; i < POWERD_NUM_DISPLAY_FLAGS; i++)
> - printf(" Flag %-2d Flag %-2d ", i, i);
> - printf("\n %-16.16s %-20.20s %-8.8s %-16.16s %-16.16s %-16.16s %-16.16s %-16.16s",
> - "Owner", "Name", "Count", "Active Time", "Time", "Active Since",
> - "Time", "Since");
> - for (i = 0; i < POWERD_NUM_DISPLAY_FLAGS; i++)
> - printf(" On Time On Since ");
> - printf("\n");
> - for (i = 0; i < stats->len; i++) {
> - stat = &g_array_index(stats, struct DispRequestStats, i);
> - printf(" %-16.16s %-20.20s %-8u %-16.6f %-16.6f %-16.6f %-16.6f %-16.6f",
> - stat->owner, stat->name, stat->active_count,
> - (double)stat->active_time / 1000000.0f,
> - (double)stat->max_active_time / 1000000.0f,
> - (double)stat->active_since / 1000000.0f,
> - (double)stat->disp_on_time / 1000000.0f,
> - (double)stat->disp_on_since / 1000000.0f);
> - for (j = 0; j < POWERD_NUM_DISPLAY_FLAGS; j++) {
> - printf(" %-16.6f", (double)stat->flag_on_time[j] / 1000000.0f);
> - printf(" %-16.6f", (double)stat->flag_on_since[j] / 1000000.0f);
> - }
> - printf("\n");
> - }
> - }
> -}
> -
> gboolean
> clearSysState(powerd_cookie_t cookie)
> {
> @@ -520,14 +309,14 @@
> }
>
> static gboolean
> -clearDisplayState(powerd_cookie_t cookie)
> +clearDisplayState(int cookie)
> {
> GVariant *ret = NULL;
> GError *error = NULL;
>
> - ret = g_dbus_proxy_call_sync(powerd_proxy,
> - "clearDisplayState",
> - g_variant_new("(s)", cookie),
> + ret = g_dbus_proxy_call_sync(uscreen_proxy,
> + "removeDisplayOnRequest",
> + g_variant_new("(i)", cookie),
> G_DBUS_CALL_FLAGS_NONE,
> -1,
> NULL,
> @@ -567,9 +356,6 @@
> requests = listSysRequests();
> do_test(checkForDbusName(test_dbusname, 0, requests, TRUE));
> g_array_free(requests, TRUE);
> - requests = listDisplayRequests();
> - do_test(checkForDbusName(test_dbusname, 0, requests, TRUE));
> - g_array_free(requests, TRUE);
> }
> else {
> printf("Did not find child's dbus name\n");
> @@ -712,102 +498,6 @@
> silence_errors(FALSE);
> }
>
> -static void
> -runDisplayTests()
> -{
> - int i;
> - int state = 0;
> - gboolean bright = FALSE;
> - powerd_cookie_t cookie, cookies[TEST_NUM_DISP_REQUESTS];
> - GArray *requests = NULL;
> - struct PublicDispRequest pdr = {0,};
> -
> - silence_errors(TRUE);
> -
> - // Hold active state request as long we're running tests
> - requestSysState("main-req", POWERD_SYS_STATE_ACTIVE, &main_cookie);
> -
> - for (i = 0; i < TEST_NUM_DISP_REQUESTS; i++) {
> - char name[16];
> - snprintf(name, sizeof(name), "disp-test-%d", i);
> - pdr.state = state++;
> - pdr.flags = 0;
> - if (bright) {
> - pdr.flags |= POWERD_DISPLAY_FLAG_BRIGHT;
> - }
> - do_test(requestDisplayState(pdr, name, &cookies[i]) == TRUE);
> - if (state >= POWERD_NUM_DISPLAY_STATES) {
> - state = 0;
> - }
> - bright = !bright;
> - }
> -
> - // Make sure we have at least NUM_REQUESTS
> - requests = listDisplayRequests();
> - do_test(requests->len >= TEST_NUM_DISP_REQUESTS);
> - // We should see our PID NUM_REQUESTS times
> - do_test(checkForDbusName(powerd_cli_bus_name, TEST_NUM_DISP_REQUESTS, requests, FALSE));
> - g_array_free(requests, TRUE);
> -
> - for (i = 0; i < TEST_NUM_DISP_REQUESTS; i++)
> - do_test(clearDisplayState(cookies[i]) == TRUE);
> -
> - requests = listDisplayRequests();
> - // We aren't holding anymore with this PID
> - do_test(checkForDbusName(powerd_cli_bus_name, 0, requests, FALSE));
> - g_array_free(requests, TRUE);
> -
> - // Now try and freeing the same cookies again. They should all be
> - // invalid and thus the request fails.
> - for (i = 0; i < TEST_NUM_DISP_REQUESTS; i++)
> - do_test(clearDisplayState(cookies[i]) == FALSE);
> -
> - // Test releasing an invalid cookie format
> - do_test(clearDisplayState("bad cookie") == FALSE);
> -
> - //invalid values
> - pdr.state = -1;
> - do_test(requestDisplayState(pdr, "disp-test", &cookie) == FALSE);
> -
> - pdr.state = POWERD_NUM_DISPLAY_STATES;
> - do_test(requestDisplayState(pdr, "disp-test", &cookie) == FALSE);
> -
> - pdr.state = POWERD_DISPLAY_STATE_ON;
> - pdr.flags = 0xdeadbeef;
> - do_test(requestDisplayState(pdr, "disp-test", &cookie) == FALSE);
> -
> - // updateDisplayState tests
> - pdr.state = POWERD_DISPLAY_STATE_ON;
> - pdr.flags = 0;
> - do_test(requestDisplayState(pdr, "disp-test", &cookie) == TRUE);
> -
> - // update with same state should be okay
> - do_test(updateDisplayState(pdr, cookie) == TRUE);
> -
> - pdr.state = POWERD_DISPLAY_STATE_DONT_CARE;
> - do_test(updateDisplayState(pdr, cookie) == TRUE);
> -
> - pdr.flags = POWERD_DISPLAY_FLAG_DISABLE_AUTOBRIGHTNESS;
> - do_test(updateDisplayState(pdr, cookie) == TRUE);
> -
> - pdr.state = -1;
> - do_test(updateDisplayState(pdr, cookie) == FALSE);
> -
> - do_test(clearDisplayState(cookie) == TRUE);
> -
> - // update with same cookie after clear should fail
> - do_test(updateDisplayState(pdr, cookie) == FALSE);
> -
> - // update with garbage cookie should faile
> - do_test(updateDisplayState(pdr, "bad cookie") == FALSE);
> -
> - //cleanup
> - do_test(clearSysState(main_cookie) == TRUE);
> - do_test(checkForDbusName(powerd_cli_bus_name, 0, requests, TRUE));
> -
> - silence_errors(FALSE);
> -}
> -
> // Check that dbus owner appears count times in a list of sys/disp requests
> static gboolean
> checkForDbusName(const char *dbusname,
> @@ -818,7 +508,6 @@
> int i;
> int found = 0;
> struct PublicSysRequest *psr;
> - struct PublicDispRequest *pdr;
>
> if (requests == NULL) {
> cli_warn("NULL requests passed to %s", __func__);
> @@ -833,12 +522,6 @@
> found++;
> }
> }
> - else {
> - pdr = &g_array_index(requests, struct PublicDispRequest, i);
> - if (!(strcmp(pdr->owner, dbusname))) {
> - found++;
> - }
> - }
> }
>
> if (found != count) {
> @@ -855,47 +538,6 @@
> g_main_loop_quit(main_loop);
> }
>
> -/* Caller ensures that we have at least 4 arguments in argv */
> -static gboolean
> -buildDisplayRequest(char **argv,
> - int argc,
> - struct PublicDispRequest *pdr)
> -{
> - int i;
> -
> - if (!strcasecmp(argv[2],"on")) {
> - pdr->state = POWERD_DISPLAY_STATE_ON;
> - cli_debug("Requesting Display On");
> - }
> - else if (!strcasecmp(argv[2],"dc")) {
> - pdr->state = POWERD_DISPLAY_STATE_DONT_CARE;
> - cli_debug("Requesting Display Don't Care");
> - }
> - else {
> - fprintf(stderr,"invalid state %s, must be either on or dc\n",
> - argv[2]);
> - return FALSE;
> - }
> -
> - pdr->flags = 0;
> - for (i=3; i<argc; i++) {
> - if (!strcmp(argv[i],"proximity")) {
> - pdr->flags |= POWERD_DISPLAY_FLAG_USE_PROXIMITY;
> - cli_debug("Requesting Proximity Sensor Enabled");
> - }
> - else if (!strcmp(argv[i],"disableab")) {
> - pdr->flags |= POWERD_DISPLAY_FLAG_DISABLE_AUTOBRIGHTNESS;
> - cli_debug("Requesting Proximity Disable AutoBrightness");
> - }
> - else if (!strcasecmp(argv[i],"bright")) {
> - pdr->flags |= POWERD_DISPLAY_FLAG_BRIGHT;
> - cli_debug("Requesting Bright");
> - }
> - }
> -
> - return TRUE;
> -}
> -
> static void
> setUserAutobrightness(gboolean enable)
> {
> @@ -968,16 +610,9 @@
> printf("brightness <brightness> - set user screen brightness.\n");
> printf("brightness-params - get brightness parameters (dim, min, max, etc.)\n");
> printf("clear-sys <cookie> - clear a System state request given a cookie.\n");
> - printf("clear-disp <cookie> - clear a Display state request given a cookie.\n");
> printf("client-test - test powerd registration / ack API.\n");
> - printf("display <on|dc> [bright] [proximity] [disableab]\n"\
> - "\tMake a display state request with the input parameters.\n"\
> - "\tThe first argument represents the state of the display:\n"\
> - "\tOn (on) or Don't Care (dc),\n"\
> - "\tThe final optional arguments respectively:\n"\
> - "\t * make the screen bright [bright]\n"\
> - "\t * enable the proximity sensor [proximity]\n"\
> - "\t * disable autobrightness [disableab]\n");
> + printf("display <on>\n"\
> + "\tMake the display stay on\n");
> printf("help\t- display this usage information.\n");
> printf("list\t- list outstanding requests.\n");
> printf("listen\t- listen for signals from powerd. This runs a\n"\
> @@ -997,7 +632,6 @@
> GError *error = NULL;
> uid_t myeuid;
> GArray *requests = NULL;
> - struct PublicDispRequest pdr;
> GDBusConnection *bus = NULL;
> const char *bus_name = NULL;
> powerd_cookie_t cookie;
> @@ -1017,7 +651,6 @@
> (strcmp(argv[1],"listen")) &&
> (strcmp(argv[1],"display")) &&
> (strcmp(argv[1],"help")) &&
> - (strcmp(argv[1],"clear-disp")) &&
> (strcmp(argv[1],"clear-sys")) &&
> (strcmp(argv[1],"client-test")) &&
> (strcmp(argv[1], "autobrightness")) &&
> @@ -1055,22 +688,30 @@
> return -1;
> }
>
> + uscreen_proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
> + G_DBUS_PROXY_FLAGS_NONE,
> + NULL,
> + "com.canonical.Unity.Screen",
> + "/com/canonical/Unity/Screen",
> + "com.canonical.Unity.Screen",
> + NULL,
> + &error);
> +
> + if (error != NULL) {
> + cli_warn("could not connect to unity screen: %s", error->message);
> + g_error_free(error);
> + return -1;
> + }
> +
> if (!strcmp(argv[1],"list")) {
> requests = listSysRequests();
> printSysRequests(requests);
> g_array_free(requests, TRUE);
> - requests = listDisplayRequests();
> - printDisplayRequests(requests);
> - g_array_free(requests, TRUE);
> }
> else if (!strcmp(argv[1], "stats")) {
> requests = getSysRequestStats();
> printSysRequestStats(requests);
> g_array_free(requests, TRUE);
> -
> - requests = getDispRequestStats();
> - printDispRequestStats(requests);
> - g_array_free(requests, TRUE);
> }
> else if (!strcmp(argv[1],"active-nc")) {
> requestSysState("active-nc", POWERD_SYS_STATE_ACTIVE,&cookie);
> @@ -1086,20 +727,16 @@
> return 0;
> }
> else if (!strcmp(argv[1],"display")) {
> - if (argc < 3) {
> - fprintf(stderr,"display requires other arguments\n");
> - usage(argv[0]);
> - return -1;
> - }
> - if (buildDisplayRequest(argv,argc,&pdr) == FALSE) {
> - usage(argv[0]);
> - return -1;
> - }
> - requestDisplayState(pdr, "disp-test", &cookie);
> - printf("Display State requested, cookie is %s.\nPress ctrl-c to exit.\n",
> - cookie);
> + int disp_cookie;
> + cli_debug("Requesting Display On");
> + if (requestDisplayState(&disp_cookie) == FALSE) {
> + fprintf(stderr,"failed display request\n");
> + return -1;
> + }
> + printf("Display State requested, cookie is %d.\nPress ctrl-c to exit.\n",
> + disp_cookie);
> pause(); /* wait for SIGINT */
> - clearDisplayState(cookie);
> + clearDisplayState(disp_cookie);
> return 0;
> }
> else if (!strncmp(argv[1],"clear",strlen("clear"))) {
> @@ -1114,9 +751,6 @@
> if (!strcmp(argv[1],"clear-sys")) {
> clearSysState(argv[2]);
> }
> - else if (!strcmp(argv[1],"clear-disp")) {
> - clearDisplayState(argv[2]);
> - }
> else {
> // Note: We should never get here due to earlier checks
> fprintf(stderr,"Invalid option %s\n",argv[1]);
> @@ -1144,7 +778,6 @@
>
> runDbusNameVanishTests(argv[0]);
> runSysTests();
> - runDisplayTests();
>
> g_object_unref(powerd_cli_bus);
> powerd_cli_bus = NULL;
> @@ -1163,11 +796,6 @@
> requestSysState("dbusnametest1", POWERD_SYS_STATE_ACTIVE,&cookie);
> requestSysState("dbusnametest2", POWERD_SYS_STATE_ACTIVE,&cookie);
> requestSysState("dbusnametest3", POWERD_SYS_STATE_ACTIVE,&cookie);
> - pdr.state = POWERD_DISPLAY_STATE_DONT_CARE;
> - pdr.flags = 0;
> - requestDisplayState(pdr, "dbusnametest1", &cookie);
> - requestDisplayState(pdr, "dbusnametest2", &cookie);
> - requestDisplayState(pdr, "dbusnametest3", &cookie);
> g_object_unref(bus);
> // Exit here without cleanup
> return 0;
>
> === removed file 'data/com.canonical.powerd.gschema.xml'
> --- data/com.canonical.powerd.gschema.xml 2013-10-04 14:43:05 +0000
> +++ data/com.canonical.powerd.gschema.xml 1970-01-01 00:00:00 +0000
> @@ -1,15 +0,0 @@
> -<?xml version="1.0" encoding="UTF-8"?>
> -<schemalist gettext-domain="powerd">
> - <schema id="com.canonical.powerd" path="/com/canonical/powerd/">
> - <key name="activity-timeout" type="u">
> - <range min="5" max="3600"/>
> - <default>60</default>
> - <summary>Timeout in seconds for turning off the screen if there is no user activity</summary>
> - </key>
> - <key name="dim-timeout" type="u">
> - <range min="0" max="3600"/>
> - <default>45</default>
> - <summary>Timeout in seconds for dimming the screen if there is no user activity. A value of 0 disables auto-dimming.</summary>
> - </key>
> - </schema>
> -</schemalist>
>
> === modified file 'data/com.canonical.powerd.xml'
> --- data/com.canonical.powerd.xml 2014-04-23 02:08:02 +0000
> +++ data/com.canonical.powerd.xml 2014-06-17 03:45:55 +0000
> @@ -14,23 +14,6 @@
> <arg type="s" name="cookie" direction="in" />
> </method>
>
> - <method name="requestDisplayState">
> - <arg type="s" name="name" direction="in" />
> - <arg type="i" name="state" direction="in" />
> - <arg type="u" name="flags" direction="in" />
> - <arg type="s" name="cookie" direction="out" />
> - </method>
> -
> - <method name="updateDisplayState">
> - <arg type="s" name="cookie" direction="in" />
> - <arg type="i" name="state" direction="in" />
> - <arg type="u" name="flags" direction="in" />
> - </method>
> -
> - <method name="clearDisplayState">
> - <arg type="s" name="cookie" direction="in" />
> - </method>
> -
> <method name="registerClient">
> <arg type="s" name="name" direction="in" />
> </method>
> @@ -63,25 +46,14 @@
> <arg type="a(ssi)" name="requestList" direction="out" />
> </method>
>
> - <method name="listDisplayRequests">
> - <arg type="a(ssiu)" name="requestList" direction="out" />
> - </method>
> -
> <method name="getSysRequestStats">
> <arg type="a(ssuttt)" name="requestStats" direction="out" />
> </method>
>
> - <method name="getDispRequestStats">
> - <arg type="a(ssutttttatat)" name="requestStats" direction="out" />
> - </method>
> -
> <!-- Signals -->
> <signal name="SysPowerStateChange">
> <arg type="i" name="sysState" direction="out" />
> </signal>
>
> - <signal name="DisplayPowerStateChange">
> - <arg type="(iu)" name="displayState" direction="out" />
> - </signal>
> </interface>
> </node>
>
> === modified file 'debian/control'
> --- debian/control 2014-05-29 06:53:15 +0000
> +++ debian/control 2014-06-17 03:45:55 +0000
> @@ -23,8 +23,7 @@
> Architecture: any
> Depends: ${misc:Depends}, ${shlibs:Depends}, upower
> Recommends: ofono
> -Description: Power daemon to monitor and control system and display power state
> - This daemon monitors and controls system and display power states for Ubuntu
> +Description: Power daemon to monitor and control system power state
> + This daemon monitors and controls system power states for Ubuntu
> phone and tablet. It provides a dbus interface for system services to request
> - a power state, essentially allowing services to block suspend. Additionally
> - it monitors user activity and power button presses.
> + a power state, essentially allowing services to block suspend.
>
> === modified file 'debian/powerd.conf'
> --- debian/powerd.conf 2014-03-28 10:10:28 +0000
> +++ debian/powerd.conf 2014-06-17 03:45:55 +0000
> @@ -42,16 +42,10 @@
> <allow send_destination="com.canonical.powerd"
> send_interface="com.canonical.powerd"
> send_type="method_call" send_member="listSysRequests" />
> - <allow send_destination="com.canonical.powerd"
> - send_interface="com.canonical.powerd"
> - send_type="method_call" send_member="listDisplayRequests" />
>
> <allow send_destination="com.canonical.powerd"
> send_interface="com.canonical.powerd"
> send_type="method_call" send_member="getSysRequestStats" />
> - <allow send_destination="com.canonical.powerd"
> - send_interface="com.canonical.powerd"
> - send_type="method_call" send_member="getDispRequestStats" />
>
> <allow send_destination="com.canonical.powerd"
> send_interface="com.canonical.powerd"
>
> === modified file 'src/backlight.c'
> --- src/backlight.c 2014-04-23 02:08:02 +0000
> +++ src/backlight.c 2014-06-17 03:45:55 +0000
> @@ -33,6 +33,14 @@
>
> struct light_device_t *light_dev;
>
> +enum bl_state {
> + BL_OFF,
> + BL_ON,
> + BL_AUTO,
> +
> + NUM_BL_STATES
> +};
> +
> /*
> * Defaults are Android default settings. They may not work if we
> * can't read the per-device values, but they're as good as
> @@ -44,6 +52,8 @@
> int dim_brightness = 10;
> int current_brightness = -1;
>
> +static int user_brightness;
> +
> int powerd_get_brightness(void)
> {
> return current_brightness;
> @@ -91,11 +101,6 @@
> min_user_brightness : brightness);
> }
>
> -void powerd_dim_screen(void)
> -{
> - powerd_set_brightness(dim_brightness);
> -}
> -
> int powerd_backlight_init(void)
> {
> GValue v = G_VALUE_INIT;
> @@ -144,6 +149,7 @@
> * Unfortunately the HAL provides no way for us to read the
> * current brightness when we start. */
> powerd_set_brightness(default_brightness);
> + user_brightness = default_brightness;
>
> return 0;
> }
> @@ -153,6 +159,58 @@
> light_dev = NULL;
> }
>
> +static void set_user_brightness(int brightness)
> +{
> + int max = powerd_get_max_brightness();
> + if (brightness > max)
> + brightness = max;
> + user_brightness = brightness;
> +}
> +
> +static void set_backlight(enum bl_state state)
> +{
> + static enum bl_state current_state = BL_ON;
> + static int restore_brightness = 0;
> +
> + if (state >= NUM_BL_STATES) {
> + powerd_warn("Unknown backlight state %d\n", state);
> + return;
> + }
> +
> + if (state != BL_AUTO)
> + powerd_autobrightness_disable();
> +
> + /*
> + * When autobrightness is enabled, it takes a second to
> + * settle on a brightness level after enabling. This delay
> + * becomes very noticeable when going from the dim to bright
> + * state. To avoid this lag, save off the current brightness
> + * and restore it when transitioning to AUTO mode again.
> + */
> + if (current_state != BL_OFF && state == BL_OFF)
> + restore_brightness = powerd_get_brightness();
> +
> + switch (state) {
> + case BL_OFF:
> + powerd_set_brightness(0);
> + break;
> + case BL_ON:
> + powerd_set_user_brightness(user_brightness);
> + break;
> + case BL_AUTO:
> + if (current_state == BL_OFF && restore_brightness > 0)
> + powerd_set_brightness(restore_brightness);
> + powerd_autobrightness_enable();
> + break;
> + default:
> + /* default case is to satisfy static analysis tools, should
> + * never actually get here */
> + powerd_error("Unknwown backlight state %d\n", state);
> + return;
> + }
> + current_state = state;
> +}
> +
>
> /** dbus interfaces **/
>
> @@ -169,3 +227,33 @@
> ab_available));
> return TRUE;
> }
> +
> +gboolean handle_user_autobrightness_enable(PowerdSource *obj,
> + GDBusMethodInvocation *invocation,
> + gboolean enable)
> +{
> + if (powerd_autobrightness_available() && enable)
> + set_backlight(BL_AUTO);
> + else
> + set_backlight(BL_ON);
> +
> + g_dbus_method_invocation_return_value(invocation, NULL);
> + return TRUE;
> +}
> +
> +gboolean handle_set_user_brightness(PowerdSource *obj,
> + GDBusMethodInvocation *invocation,
> + gint brightness)
> +{
> + if (brightness == 0)
> + {
> + set_backlight(BL_OFF);
> + }
> + else
> + {
> + set_user_brightness(brightness);
> + set_backlight(BL_ON);
> + }
> + g_dbus_method_invocation_return_value(invocation, NULL);
> + return TRUE;
> +}
>
> === removed file 'src/display-request.c'
> --- src/display-request.c 2014-04-14 21:17:04 +0000
> +++ src/display-request.c 1970-01-01 00:00:00 +0000
> @@ -1,458 +0,0 @@
> -/*
> - * Copyright 2013 Canonical Ltd.
> - *
> - * Authors:
> - * Michael Frey: michael.frey at canonical.com
> - * Matthew Fischer: matthew.fischer at canonical.com
> - * Seth Forshee: seth.forshee at canonical.com
> - *
> - * This file is part of powerd.
> - *
> - * powerd is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; version 3.
> - *
> - * powerd is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program. If not, see <http://www.gnu.org/licenses/>.
> - */
> -
> -#include <string.h>
> -#include <errno.h>
> -#include <uuid/uuid.h>
> -
> -#include <glib.h>
> -#include <glib-object.h>
> -#include <gio/gio.h>
> -
> -#include "powerd.h"
> -#include "powerd-internal.h"
> -#include "log.h"
> -
> -struct display_request_internal {
> - struct powerd_display_request req;
> - const char *name;
> - const char *owner;
> -};
> -
> -static struct {
> - unsigned int state[POWERD_NUM_DISPLAY_STATES];
> - unsigned int flags[POWERD_NUM_DISPLAY_FLAGS];
> -} display_state_count;
> -
> -static struct powerd_display_request internal_state = {
> - .state = POWERD_DISPLAY_STATE_DONT_CARE,
> - .flags = 0,
> -};
> -
> -static GHashTable *display_request_hash;
> -
> -static void update_internal_state(void)
> -{
> - struct powerd_display_request new_state;
> - int i;
> -
> - memset(&new_state, 0, sizeof(new_state));
> -
> - /* Default to off if no request for display to be on */
> - if (display_state_count.state[POWERD_DISPLAY_STATE_ON] > 0)
> - new_state.state = POWERD_DISPLAY_STATE_ON;
> - else
> - new_state.state = POWERD_DISPLAY_STATE_DONT_CARE;
> -
> - for (i = 0; i < POWERD_NUM_DISPLAY_FLAGS; i++) {
> - if (display_state_count.flags[i] > 0)
> - new_state.flags |= (1U << i);
> - }
> -
> - if (!memcmp(&internal_state, &new_state, sizeof(new_state))) {
> - powerd_debug("display state not changed");
> - return;
> - }
> -
> - powerd_debug("Internal state updated: state %d flags 0x%08x",
> - new_state.state, new_state.flags);
> - internal_state = new_state;
> - powerd_set_display_state(&internal_state);
> -}
> -
> -static void __add_request(struct powerd_display_request *req)
> -{
> - unsigned int flags;
> - int i;
> -
> - display_state_count.state[req->state]++;
> -
> - flags = req->flags;
> - for (i = 0; flags && i < POWERD_NUM_DISPLAY_FLAGS; flags >>= 1, i++) {
> - if (flags & 1)
> - display_state_count.flags[i]++;
> - }
> -}
> -
> -static void __remove_request(struct powerd_display_request *req)
> -{
> - unsigned int flags;
> - int i;
> -
> - if (display_state_count.state[req->state] > 0)
> - display_state_count.state[req->state]--;
> -
> - flags = req->flags;
> - for (i = 0; flags && i < POWERD_NUM_DISPLAY_FLAGS; flags >>= 1, i++) {
> - if ((flags & 1) && display_state_count.flags[i] > 0)
> - display_state_count.flags[i]--;
> - }
> -}
> -
> -static void add_request(struct display_request_internal *request)
> -{
> - g_hash_table_insert(display_request_hash, request->req.cookie, request);
> - powerd_dbus_name_watch_add(request->owner);
> - __add_request(&request->req);
> - update_internal_state();
> - powerd_account_add_display_req(request->owner, request->name,
> - &request->req);
> -}
> -
> -static gboolean update_request(struct powerd_display_request *new_req)
> -{
> - struct display_request_internal *ireq;
> -
> - ireq = g_hash_table_lookup(display_request_hash, new_req->cookie);
> - if (!ireq) {
> - powerd_debug("Display request to update not found");
> - return FALSE;
> - }
> -
> - __remove_request(&ireq->req);
> - __add_request(new_req);
> -
> - ireq->req.state = new_req->state;
> - ireq->req.flags = new_req->flags;
> -
> - update_internal_state();
> - powerd_account_update_display_req(ireq->owner, ireq->name, &ireq->req);
> - return TRUE;
> -}
> -
> -static gboolean remove_request(uuid_t cookie)
> -{
> - struct display_request_internal *ireq;
> - struct powerd_display_request req;
> - gboolean found = FALSE;
> -
> - /*
> - * This involves two lookups into the hash, one to find the
> - * request so we can retrieve the state and another to remove
> - * it. GHashTable doesn't seem to provide any more efficient
> - * way to do this; too bad g_hash_table_steal() doesn't return
> - * a pointer to the data.
> - */
> - ireq = g_hash_table_lookup(display_request_hash, cookie);
> - if (ireq) {
> - req = ireq->req;
> - /* We need to remove it from our watch hash and do accounting
> - * before we remove it from the state hash or the ireq->owner
> - * memory will be freed before we try to use it.
> - */
> - powerd_dbus_name_watch_remove(ireq->owner);
> - powerd_account_clear_display_req(ireq->owner, ireq->name);
> - found = g_hash_table_remove(display_request_hash, cookie);
> - if (!found)
> - powerd_warn("Display request found on lookup but not on remove");
> - }
> -
> - if (found) {
> - __remove_request(&req);
> - update_internal_state();
> - }
> -
> - return found;
> -}
> -
> -static gboolean request_valid(struct powerd_display_request *request)
> -{
> - if ((unsigned)request->state >= POWERD_NUM_DISPLAY_STATES) {
> - powerd_warn("Invalid display state requested: %d", request->state);
> - return FALSE;
> - }
> -
> - /*
> - * XXX: This will warn if we get up to 32 flags, but in that
> - * case the check should just be removed.
> - */
> - if (request->flags & (-1U << POWERD_NUM_DISPLAY_FLAGS)) {
> - powerd_warn("Invalid display flags requested: 0x%08x", request->flags);
> - return FALSE;
> - }
> -
> - return TRUE;
> -}
> -
> -static int add_request_worker(gpointer data)
> -{
> - struct display_request_internal *req = data;
> - add_request(req);
> - return 0;
> -}
> -
> -/*
> - * @request need not refer to persistent memory, as the data from
> - * the struct will be copied into internally-managed storage.
> - */
> -static int __powerd_add_display_request(struct powerd_display_request *request,
> - const char *name, const char *owner)
> -{
> - struct display_request_internal *hash_req;
> -
> - if (!request_valid(request))
> - return -EINVAL;
> -
> - uuid_generate(request->cookie);
> - hash_req = g_new(struct display_request_internal, 1);
> - hash_req->req = *request;
> - hash_req->name = g_strdup(name);
> - hash_req->owner = g_strdup(owner);
> - powerd_run_mainloop_sync(add_request_worker, hash_req);
> - return 0;
> -}
> -
> -/*
> - * @request need not refer to persistent memory, as the data from
> - * the struct will be copied into internally-managed storage.
> - */
> -int powerd_add_display_request(struct powerd_display_request *request,
> - const char *name)
> -{
> - if (!request || !name) {
> - powerd_warn("powerd_add_display_request() called with invalid args");
> - return -EINVAL;
> - }
> - return __powerd_add_display_request(request, name, "internal");
> -}
> -
> -static int update_request_worker(gpointer data)
> -{
> - struct powerd_display_request *req = data;
> - return update_request(req);
> -}
> -
> -int powerd_update_display_request(struct powerd_display_request *request)
> -{
> - gboolean found;
> -
> - if (!request_valid(request))
> - return -EINVAL;
> -
> - found = powerd_run_mainloop_sync(update_request_worker, request);
> - return found ? 0 : -EINVAL;
> -}
> -
> -static int remove_request_worker(gpointer data)
> -{
> - unsigned char *uuid = data;
> - return remove_request(uuid);
> -}
> -
> -int powerd_remove_display_request(uuid_t cookie)
> -{
> - gboolean found;
> -
> - found = powerd_run_mainloop_sync(remove_request_worker, cookie);
> - return found ? 0 : -EINVAL;
> -}
> -
> -/** dbus method handling **/
> -
> -gboolean handle_add_display_request(PowerdSource *obj,
> - GDBusMethodInvocation *invocation,
> - const char *name, int state, guint32 flags)
> -{
> - struct powerd_display_request req;
> - const char *owner;
> - char ext_cookie[UUID_STR_LEN];
> - int ret;
> -
> - memset(&req, 0, sizeof(req));
> -
> - owner = g_dbus_method_invocation_get_sender(invocation);
> - powerd_debug("%s from %s: state %d flags %#08x",
> - __func__, owner, state, flags);
> -
> - req.state = state;
> - req.flags = flags;
> -
> - ret = __powerd_add_display_request(&req, name, owner);
> - if (ret) {
> - g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR,
> - G_DBUS_ERROR_INVALID_ARGS,
> - "Invalid display request");
> - } else {
> - powerd_debug("%s: SUCCESS", __func__);
> - uuid_unparse(req.cookie, ext_cookie);
> - g_dbus_method_invocation_return_value(invocation,
> - g_variant_new("(s)", ext_cookie));
> - }
> -
> - return TRUE;
> -}
> -
> -gboolean handle_update_display_request(PowerdSource *obj,
> - GDBusMethodInvocation *invocation,
> - const gchar *ext_cookie, int state,
> - guint32 flags)
> -{
> - struct powerd_display_request req;
> - uuid_t cookie;
> - int ret;
> -
> - memset(&req, 0, sizeof(req));
> -
> - powerd_debug("%s from %s: cookie: %s state %d flags %#08x",
> - __func__, g_dbus_method_invocation_get_sender(invocation),
> - ext_cookie, state, flags);
> -
> - if (uuid_parse(ext_cookie, cookie)) {
> - g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR,
> - G_DBUS_ERROR_INVALID_ARGS,
> - "Invalid cookie: %s",
> - ext_cookie);
> - return TRUE;
> - }
> -
> - memcpy(req.cookie, cookie, sizeof(uuid_t));
> - req.state = state;
> - req.flags = flags;
> -
> - ret = powerd_update_display_request(&req);
> - if (ret) {
> - g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR,
> - G_DBUS_ERROR_INVALID_ARGS,
> - "Invalid display request");
> - } else {
> - powerd_debug("%s: SUCCESS", __func__);
> - g_dbus_method_invocation_return_value(invocation, NULL);
> - }
> -
> - return TRUE;
> -}
> -
> -gboolean handle_clear_display_request(PowerdSource *obj,
> - GDBusMethodInvocation *invocation,
> - const gchar *ext_cookie)
> -{
> - int ret;
> - uuid_t cookie;
> -
> - powerd_debug("%s from %s, cookie: %s", __func__,
> - g_dbus_method_invocation_get_sender(invocation), ext_cookie);
> -
> - if (uuid_parse(ext_cookie, cookie)) {
> - g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR,
> - G_DBUS_ERROR_INVALID_ARGS,
> - "Invalid cookie: %s",
> - ext_cookie);
> - return TRUE;
> - }
> -
> - ret = powerd_remove_display_request(cookie);
> - if (ret) {
> - g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR,
> - G_DBUS_ERROR_INVALID_ARGS,
> - "Invalid cookie: %s", ext_cookie);
> - } else {
> - g_dbus_method_invocation_return_value(invocation, NULL);
> - }
> -
> - return TRUE;
> -}
> -
> -static int build_display_request_list(GVariantBuilder *builder)
> -{
> - GHashTableIter iter;
> - gpointer key, value;
> - int count = 0;
> -
> - g_hash_table_iter_init(&iter, display_request_hash);
> - while (g_hash_table_iter_next(&iter, &key, &value)) {
> - struct display_request_internal *ireq = value;
> - struct powerd_display_request *req = &ireq->req;
> - g_variant_builder_add(builder, "(ssiu)", ireq->name, ireq->owner,
> - req->state, req->flags);
> - count++;
> - }
> - return count;
> -}
> -
> -gboolean handle_list_display_requests(PowerdSource *obj,
> - GDBusMethodInvocation *invocation)
> -{
> - GVariant *list, *tuple;
> - GVariantBuilder *builder;
> - int count;
> -
> - builder = g_variant_builder_new(G_VARIANT_TYPE("a(ssiu)"));
> - count = build_display_request_list(builder);
> - if (count > 0) {
> - list = g_variant_builder_end(builder);
> - } else {
> - g_variant_builder_clear(builder);
> - list = g_variant_new_array(G_VARIANT_TYPE("(ssiu)"), NULL, 0);
> - }
> -
> - tuple = g_variant_new_tuple(&list, 1);
> - g_dbus_method_invocation_return_value(invocation, tuple);
> - g_variant_builder_unref(builder);
> -
> - return TRUE;
> -}
> -
> -/* Destructor for hash table */
> -static void display_request_destroy(gpointer data)
> -{
> - struct display_request_internal *req = data;
> -
> - g_free((gpointer)req->name);
> - g_free((gpointer)req->owner);
> - g_free(req);
> -}
> -
> -void display_request_init(void)
> -{
> - display_request_hash = g_hash_table_new_full(powerd_uuid_hash,
> - powerd_uuid_equal,
> - NULL, display_request_destroy);
> -}
> -
> -void display_request_deinit(void)
> -{
> - g_hash_table_destroy(display_request_hash);
> -}
> -
> -/*
> - * Callers may use this to clear all requests that the specified owner
> - * is holding. This is used when the owner drops off of dbus
> - */
> -void
> -clear_disp_state_by_owner(const char *owner)
> -{
> - GHashTableIter iter;
> - gpointer key, value;
> -
> - g_hash_table_iter_init(&iter, display_request_hash);
> - while (g_hash_table_iter_next(&iter, &key, &value)) {
> - struct display_request_internal *ireq = value;
> - if (!strcmp(owner, ireq->owner)) {
> - powerd_account_clear_display_req(ireq->owner, ireq->name);
> - __remove_request(&ireq->req);
> - powerd_dbus_name_watch_remove(ireq->owner);
> - g_hash_table_iter_remove(&iter);
> - }
> - }
> - update_internal_state();
> -}
>
> === added file 'src/display.c'
> --- src/display.c 1970-01-01 00:00:00 +0000
> +++ src/display.c 2014-06-17 03:45:55 +0000
> @@ -0,0 +1,69 @@
> +/*
> + * Copyright 2013-2014 Canonical Ltd.
> + *
> + * Authors:
> + * Michael Frey: michael.frey at canonical.com
> + * Matthew Fischer: matthew.fischer at canonical.com
> + * Seth Forshee: seth.forshee at canonical.com
> + *
> + * This file is part of powerd.
> + *
> + * powerd is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; version 3.
> + *
> + * powerd is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program. If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <string.h>
> +
> +#include <glib.h>
> +#include <gio/gio.h>
> +
> +#include "powerd-internal.h"
> +#include "log.h"
> +
> +gboolean turn_display_on(gboolean on, enum DisplayStateChangeReason reason)
> +{
> + GError *error = NULL;
> + GDBusProxy *unity_proxy = NULL;
> +
> + powerd_debug("turn_display_on(%d)", on);
> +
> + if (on)
> + powerd_hal_signal_activity();
> +
> + unity_proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
> + G_DBUS_PROXY_FLAGS_NONE,
> + NULL,
> + "com.canonical.Unity.Screen",
> + "/com/canonical/Unity/Screen",
> + "com.canonical.Unity.Screen",
> + NULL,
> + &error);
> +
> + if (error != NULL) {
> + powerd_warn("could not connect to Unity: %s", error->message);
> + g_error_free(error);
> + return FALSE;
> + }
> +
> + g_dbus_proxy_call(unity_proxy,
> + "setScreenPowerMode",
> + g_variant_new("(si)", (on ? "on" : "off"), reason),
> + G_DBUS_CALL_FLAGS_NONE,
> + -1,
> + NULL,
> + NULL,
> + NULL);
> +
> + g_object_unref(unity_proxy);
> +
> + return TRUE;
> +}
>
> === removed file 'src/display.c'
> --- src/display.c 2014-04-14 21:17:04 +0000
> +++ src/display.c 1970-01-01 00:00:00 +0000
> @@ -1,438 +0,0 @@
> -/*
> - * Copyright 2013 Canonical Ltd.
> - *
> - * Authors:
> - * Michael Frey: michael.frey at canonical.com
> - * Matthew Fischer: matthew.fischer at canonical.com
> - * Seth Forshee: seth.forshee at canonical.com
> - *
> - * This file is part of powerd.
> - *
> - * powerd is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; version 3.
> - *
> - * powerd is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program. If not, see <http://www.gnu.org/licenses/>.
> - */
> -
> -#include <stdio.h>
> -#include <string.h>
> -#include <errno.h>
> -#include <unistd.h>
> -#include <sys/types.h>
> -#include <sys/stat.h>
> -#include <fcntl.h>
> -
> -#include <glib.h>
> -#include <glib-object.h>
> -
> -#include "powerd.h"
> -#include "powerd-internal.h"
> -#include "log.h"
> -
> -enum bl_state {
> - BL_OFF,
> - BL_DIM,
> - BL_BRIGHT,
> - BL_AUTO,
> -
> - NUM_BL_STATES
> -};
> -static enum bl_state target_bl_state = BL_BRIGHT;
> -
> -/* Treat "don't care" display state as off */
> -#define DISPLAY_STATE_OFF POWERD_DISPLAY_STATE_DONT_CARE
> -
> -/* Autobrightness only enabled when bright && !disabled */
> -#define AB_ENABLED_MASK (POWERD_DISPLAY_FLAG_BRIGHT | \
> - POWERD_DISPLAY_FLAG_DISABLE_AUTOBRIGHTNESS)
> -#define AB_ENABLED POWERD_DISPLAY_FLAG_BRIGHT
> -
> -static int user_brightness;
> -static gboolean user_ab_enabled;
> -
> -/* Assume screen is off to start; we will force it on */
> -static uuid_t internal_request_cookie;
> -
> -/* Currently requested state of the display */
> -struct powerd_display_request internal_state = {
> - .state = DISPLAY_STATE_OFF,
> - .flags = 0,
> -};
> -
> -/*
> - * When using the proximity sensor, our actual state of the screen
> - * may not match the requested state in internal_state. Therefore
> - * this variable keeps track of the actual state of the screen.
> - */
> -enum powerd_display_state actual_screen_state = DISPLAY_STATE_OFF;
> -
> -/*
> - * Screen state overrides. These are used when powerd needs to force
> - * the screen off regardless of the requested display state.
> - */
> -static unsigned screen_off_overrides;
> -
> -static const char *display_state_strs[POWERD_NUM_DISPLAY_STATES] = {
> - [POWERD_DISPLAY_STATE_DONT_CARE] = "off",
> - [POWERD_DISPLAY_STATE_ON] = "on",
> -};
> -
> -static const char *display_state_to_str(enum powerd_display_state state)
> -{
> - if (state >= POWERD_NUM_DISPLAY_STATES)
> - return "invalid";
> - return display_state_strs[state];
> -}
> -
> -static gboolean ab_enabled(guint32 flags)
> -{
> - if (!powerd_autobrightness_available())
> - return FALSE;
> - if (!user_ab_enabled)
> - return FALSE;
> - return (flags & AB_ENABLED_MASK) == AB_ENABLED;
> -}
> -
> -static void set_backlight(enum bl_state state)
> -{
> - static enum bl_state current_state = BL_BRIGHT;
> - static int restore_brightness = 0;
> -
> - if (state >= NUM_BL_STATES) {
> - powerd_warn("Unknown backlight state %d\n", state);
> - return;
> - }
> - if (state != BL_AUTO)
> - powerd_autobrightness_disable();
> -
> - /*
> - * When we're enabling autobrightness it takes a second to
> - * settle on a brightness level after enabling. This delay
> - * becomes very noticible when going from the dim to bright
> - * state. To avoid this lag, save off the current brightness
> - * any time the state goes from BRIGHT or AUTO and restore
> - * it if transitioning back to AUTO.
> - */
> - if (current_state >= BL_BRIGHT && state < BL_BRIGHT)
> - restore_brightness = powerd_get_brightness();
> -
> - switch (state) {
> - case BL_OFF:
> - powerd_set_brightness(0);
> - break;
> - case BL_DIM:
> - powerd_dim_screen();
> - break;
> - case BL_BRIGHT:
> - powerd_set_user_brightness(user_brightness);
> - break;
> - case BL_AUTO:
> - if (current_state < BL_BRIGHT && restore_brightness > 0)
> - powerd_set_brightness(restore_brightness);
> - powerd_autobrightness_enable();
> - break;
> - default:
> - /* default case is to satisfy static analysis tools, should
> - * never actually get here */
> - powerd_error("Unknwown backlight state %d\n", state);
> - return;
> - }
> - current_state = state;
> -}
> -
> -gboolean display_set_power_mode(int display, const char *power_mode)
> -{
> - GError *error = NULL;
> - GDBusProxy *unity_proxy = NULL;
> -
> - powerd_debug("display_set_power_mode(%s)", power_mode);
> -
> - if (strcmp(power_mode, "on") == 0)
> - powerd_hal_signal_activity();
> -
> - unity_proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
> - G_DBUS_PROXY_FLAGS_NONE,
> - NULL,
> - "com.canonical.Unity.Screen",
> - "/com/canonical/Unity/Screen",
> - "com.canonical.Unity.Screen",
> - NULL,
> - &error);
> -
> - if (error != NULL) {
> - powerd_warn("could not connect to Unity: %s", error->message);
> - g_error_free(error);
> - return FALSE;
> - }
> -
> - GVariant *ret = g_dbus_proxy_call_sync(unity_proxy,
> - "setScreenPowerMode",
> - g_variant_new("(s)", power_mode),
> - G_DBUS_CALL_FLAGS_NONE,
> - -1,
> - NULL,
> - &error);
> -
> - if (ret == NULL) {
> - powerd_warn("screen power setting failed: %s", error->message);
> - g_error_free(error);
> - g_object_unref(unity_proxy);
> - return FALSE;
> - }
> -
> - g_object_unref(unity_proxy);
> -
> - return TRUE;
> -}
> -
> -static void turn_on_display(void)
> -{
> - powerd_debug("turning on display");
> - display_set_power_mode(0, "on");
> - set_backlight(target_bl_state);
> -}
> -
> -gboolean powerd_display_enabled(void)
> -{
> - return actual_screen_state == POWERD_DISPLAY_STATE_ON;
> -}
> -
> -static void update_display_state(struct powerd_display_request *req)
> -{
> - enum powerd_display_state state = req->state;
> - int applied_state;
> - int ret;
> -
> - applied_state = screen_off_overrides ? DISPLAY_STATE_OFF : state;
> -
> - switch (applied_state) {
> - case DISPLAY_STATE_OFF:
> - if (actual_screen_state == DISPLAY_STATE_OFF) {
> - /* Nothing to do */
> - return;
> - }
> -
> - powerd_debug("turning off display");
> - set_backlight(BL_OFF);
> - if (!display_set_power_mode(0, "off")) {
> - powerd_warn("failed to set display power mode, not clearing state");
> - return;
> - }
> -
> - powerd_debug("Releasing internal active state request");
> - ret = clear_sys_state_internal(internal_request_cookie);
> - if (!ret) {
> - char cookie_str[UUID_STR_LEN];
> - uuid_unparse(internal_request_cookie, cookie_str);
> - powerd_warn("Internal system state request cookie invalid: %s",
> - cookie_str);
> - }
> - break;
> - case POWERD_DISPLAY_STATE_ON:
> - if (ab_enabled(req->flags))
> - target_bl_state = BL_AUTO;
> - else if (req->flags & POWERD_DISPLAY_FLAG_BRIGHT)
> - target_bl_state = BL_BRIGHT;
> - else
> - target_bl_state = BL_DIM;
> -
> - if (actual_screen_state != POWERD_DISPLAY_STATE_ON) {
> - powerd_debug("Requesting active state internally");
> - ret = request_sys_state_internal("display-request",
> - POWERD_SYS_STATE_ACTIVE,
> - &internal_request_cookie, NULL);
> - if (!ret)
> - powerd_warn("Request for active state failed");
> -
> - /*
> - * If currently in the suspend state we need to wait for
> - * notification of entering the active state, otherwise the
> - * screen may fail to turn on for devices using earlysuspend.
> - * Otherwise we can turn on the screen right away.
> - */
> - if (!powerd_suspend_active())
> - turn_on_display();
> - } else {
> - /* Only updating backlight state */
> - set_backlight(target_bl_state);
> - }
> - break;
> - default:
> - powerd_warn("Invalid display state %d", applied_state);
> - return;
> - }
> -
> - actual_screen_state = applied_state;
> -
> - powerd_display_state_signal_emit(actual_screen_state, req->flags);
> -}
> -
> -static void update_flags(guint32 flags)
> -{
> - int prox_enabled, internal_prox_enabled;
> -
> - prox_enabled = (flags & POWERD_DISPLAY_FLAG_USE_PROXIMITY);
> - internal_prox_enabled = (internal_state.flags & POWERD_DISPLAY_FLAG_USE_PROXIMITY);
> -
> - if (prox_enabled != internal_prox_enabled) {
> - if (prox_enabled) {
> - powerd_sensors_proximity_enable();
> - } else {
> - powerd_sensors_proximity_disable();
> - powerd_display_clear_override(POWERD_OVERRIDE_REASON_PROXIMITY);
> - }
> - }
> -}
> -
> -/*
> - * *** WARNING ***
> - *
> - * This should now only be called by display request code. Everyone
> - * else must use powerd_{add,remove}_display_request()!!!
> - */
> -void powerd_set_display_state(struct powerd_display_request *req)
> -{
> - powerd_debug("powerd_set_display_state: %s -> %s, 0x%x -> 0x%x",
> - display_state_to_str(internal_state.state),
> - display_state_to_str(req->state),
> - internal_state.flags, req->flags);
> -
> - /* Update flags before display state to ensure proximity flag is
> - * taken into account */
> - update_flags(req->flags);
> - update_display_state(req);
> -
> - internal_state = *req;
> -}
> -
> -static void user_ab_enable(gboolean enable)
> -{
> - user_ab_enabled = enable;
> - update_display_state(&internal_state);
> -}
> -
> -static gboolean prox_update_worker(gpointer data)
> -{
> - unsigned long near = (unsigned long)data;
> - if (near)
> - powerd_display_set_override(POWERD_OVERRIDE_REASON_PROXIMITY);
> - else
> - powerd_display_clear_override(POWERD_OVERRIDE_REASON_PROXIMITY);
> - return FALSE;
> -}
> -
> -void powerd_proximity_event(gboolean near)
> -{
> - unsigned long data = (unsigned long)near;
> - g_timeout_add(0, prox_update_worker, (gpointer)data);
> -}
> -
> -struct apply_override_data {
> - enum powerd_override_reason reason;
> - int set;
> -};
> -
> -static int apply_override_worker(gpointer data)
> -{
> - struct apply_override_data *ovr_data = data;
> - unsigned orig_overrides = screen_off_overrides;
> - unsigned mask;
> -
> - mask = 1 << ovr_data->reason;
> - if (ovr_data->set)
> - screen_off_overrides |= mask;
> - else
> - screen_off_overrides &= ~mask;
> -
> - if (orig_overrides != screen_off_overrides)
> - update_display_state(&internal_state);
> - return 0;
> -}
> -
> -void powerd_display_set_override(enum powerd_override_reason reason)
> -{
> - struct apply_override_data ovr_data;
> -
> - if (reason >= POWERD_NUM_OVERRIDE_REASONS) {
> - powerd_debug("Refusing to set invalid override reason (%d)", reason);
> - return;
> - }
> -
> - ovr_data.reason = reason;
> - ovr_data.set = 1;
> - powerd_run_mainloop_sync(apply_override_worker, &ovr_data);
> -}
> -
> -void powerd_display_clear_override(enum powerd_override_reason reason)
> -{
> - struct apply_override_data ovr_data;
> -
> - if (reason >= POWERD_NUM_OVERRIDE_REASONS) {
> - powerd_debug("Refusing to clear invalid override reason (%d)", reason);
> - return;
> - }
> -
> - ovr_data.reason = reason;
> - ovr_data.set = 0;
> - powerd_run_mainloop_sync(apply_override_worker, &ovr_data);
> -}
> -
> -static void set_user_brightness(int brightness)
> -{
> - int max = powerd_get_max_brightness();
> - if (brightness > max)
> - brightness = max;
> - user_brightness = brightness;
> - update_display_state(&internal_state);
> -}
> -
> -static gboolean exit_suspend_worker(gpointer unused)
> -{
> - /* Make sure suspend is still disabled */
> - if (!powerd_suspend_active() && powerd_display_enabled())
> - turn_on_display();
> - return FALSE;
> -}
> -
> -void powerd_display_exit_suspend(void)
> -{
> - g_timeout_add(0, exit_suspend_worker, NULL);
> -}
> -
> -int powerd_display_init(void)
> -{
> - struct stat stats;
> -
> - /* Use the current brightness until we're told another value */
> - user_brightness = powerd_get_brightness();
> -
> - return 0;
> -}
> -
> -
> -/** dbus interfaces **/
> -
> -gboolean handle_user_autobrightness_enable(PowerdSource *obj,
> - GDBusMethodInvocation *invocation,
> - gboolean enable)
> -{
> - user_ab_enable(enable);
> - g_dbus_method_invocation_return_value(invocation, NULL);
> - return TRUE;
> -}
> -
> -gboolean handle_set_user_brightness(PowerdSource *obj,
> - GDBusMethodInvocation *invocation,
> - gint brightness)
> -{
> - set_user_brightness(brightness);
> - g_dbus_method_invocation_return_value(invocation, NULL);
> - return TRUE;
> -}
>
> === modified file 'src/power-request.c'
> --- src/power-request.c 2014-01-03 15:23:38 +0000
> +++ src/power-request.c 2014-06-17 03:45:55 +0000
> @@ -372,7 +372,6 @@
> int ret = libsuspend_exit_suspend();
> if (!ret) {
> suspend_active = FALSE;
> - powerd_display_exit_suspend();
> }
> return ret;
> }
>
> === modified file 'src/powerd-internal.h'
> --- src/powerd-internal.h 2014-04-14 21:17:04 +0000
> +++ src/powerd-internal.h 2014-06-17 03:45:55 +0000
> @@ -33,17 +33,10 @@
> /* Length of a UUID string, including trailing nul */
> #define UUID_STR_LEN 37
>
> -struct powerd_display_request {
> - uuid_t cookie;
> - enum powerd_display_state state;
> - guint32 flags;
> -};
> -
> -enum powerd_override_reason {
> - POWERD_OVERRIDE_REASON_POWER_BUTTON,
> - POWERD_OVERRIDE_REASON_PROXIMITY,
> -
> - POWERD_NUM_OVERRIDE_REASONS
> +enum DisplayStateChangeReason
> +{
> + UNITY_SCREEN_REASON_NORMAL = 0,
> + UNITY_SCREEN_REASON_PROXIMITY = 3,
> };
>
> struct DbusNameWatch {
> @@ -64,6 +57,9 @@
> void powerd_dbus_init_complete(void);
> int powerd_is_mainloop(void);
>
> +/* Display functions */
> +gboolean turn_display_on(gboolean on, enum DisplayStateChangeReason reason);
> +
> /* Autobrightness functions */
> void powerd_new_als_event(double lux);
> void powerd_autobrightness_enable(void);
> @@ -79,19 +75,11 @@
> int powerd_get_max_brightness(void);
> int powerd_set_brightness(int brightness);
> int powerd_set_user_brightness(int brightness);
> -void powerd_dim_screen(void);
> gboolean handle_get_brightness_params(PowerdSource *obj,
> GDBusMethodInvocation *invocation);
>
> -/* Display functions */
> void powerd_brightness_set_value(gint value);
> -gboolean powerd_display_enabled(void);
> -gboolean display_set_power_mode(int display, const char *powerd_mode);
> -void powerd_set_display_state(struct powerd_display_request *req);
> -int powerd_display_init(void);
> void powerd_proximity_event(gboolean near);
> -void powerd_display_set_override(enum powerd_override_reason reason);
> -void powerd_display_clear_override(enum powerd_override_reason reason);
> gboolean handle_user_autobrightness_enable(PowerdSource *obj,
> GDBusMethodInvocation *invocation,
> gboolean enable);
> @@ -99,28 +87,6 @@
> GDBusMethodInvocation *invocation,
> gint brightness);
>
> -/* Display request functions */
> -int powerd_add_display_request(struct powerd_display_request *request,
> - const char *name);
> -int powerd_update_display_request(struct powerd_display_request *request);
> -int powerd_remove_display_request(uuid_t cookie);
> -void display_request_init(void);
> -void display_request_deinit(void);
> -gboolean handle_add_display_request(PowerdSource *obj,
> - GDBusMethodInvocation *invocation,
> - const char *name, int state, guint32 flags);
> -gboolean handle_update_display_request(PowerdSource *obj,
> - GDBusMethodInvocation *invocation,
> - const gchar *ext_cookie, int state,
> - guint32 flags);
> -gboolean handle_clear_display_request(PowerdSource *obj,
> - GDBusMethodInvocation *invocation,
> - const gchar *ext_cookie);
> -gboolean handle_list_display_requests(PowerdSource *obj,
> - GDBusMethodInvocation *invocation);
> -void clear_disp_state_by_owner(const char *owner);
> -void powerd_display_exit_suspend(void);
> -
> /* System power state requests */
> gboolean handle_list_sys_requests(PowerdSource *obj,
> GDBusMethodInvocation *invocation);
> @@ -140,8 +106,6 @@
> enum SysPowerStates current_system_power_state(void);
> const gchar * state_to_string(int state);
> void powerd_sys_state_signal_emit(enum SysPowerStates state);
> -void powerd_display_state_signal_emit(enum powerd_display_state state,
> - guint32 flags);
> void clear_sys_state_by_owner(const char *owner);
> gboolean powerd_suspend_active(void);
>
> @@ -207,19 +171,11 @@
> /* Statistics functions */
> void powerd_account_request_sys_state(const char *dbus_name, const char *name);
> void powerd_account_clear_sys_state(const char *dbus_name, const char *name);
> -void powerd_account_add_display_req(const char *dbus_name, const char *name,
> - const struct powerd_display_request *req);
> -void powerd_account_update_display_req(const char *dbus_name,
> - const char *name,
> - const struct powerd_display_request *req);
> -void powerd_account_clear_display_req(const char *dbus_name, const char *name);
> void powerd_log_stats(void);
> int powerd_stats_init(void);
> void powerd_stats_deinit(void);
> gboolean handle_get_sys_request_stats(PowerdSource *obj,
> GDBusMethodInvocation *invocation);
> -gboolean handle_get_disp_request_stats(PowerdSource *obj,
> - GDBusMethodInvocation *invocation);
>
> /* Utility functions */
> int powerd_run_mainloop_sync(int (*func)(gpointer), gpointer data);
>
> === modified file 'src/powerd-object.c'
> --- src/powerd-object.c 2014-04-14 21:17:04 +0000
> +++ src/powerd-object.c 2014-06-17 03:45:55 +0000
> @@ -163,24 +163,14 @@
> g_signal_connect(G_OBJECT(powerd_source->priv->skel), "handle-list-sys-requests",
> G_CALLBACK(handle_list_sys_requests), powerd_source);
>
> - g_signal_connect(G_OBJECT(powerd_source->priv->skel), "handle-request-display-state",
> - G_CALLBACK(handle_add_display_request), powerd_source);
> - g_signal_connect(G_OBJECT(powerd_source->priv->skel), "handle-update-display-state",
> - G_CALLBACK(handle_update_display_request), powerd_source);
> - g_signal_connect(G_OBJECT(powerd_source->priv->skel), "handle-clear-display-state",
> - G_CALLBACK(handle_clear_display_request), powerd_source);
> g_signal_connect(G_OBJECT(powerd_source->priv->skel), "handle-register-client",
> G_CALLBACK(handle_register_client), powerd_source);
> g_signal_connect(G_OBJECT(powerd_source->priv->skel), "handle-unregister-client",
> G_CALLBACK(handle_unregister_client), powerd_source);
> g_signal_connect(G_OBJECT(powerd_source->priv->skel), "handle-ack-state-change",
> G_CALLBACK(handle_ack_state_change), powerd_source);
> - g_signal_connect(G_OBJECT(powerd_source->priv->skel), "handle-list-display-requests",
> - G_CALLBACK(handle_list_display_requests), powerd_source);
> g_signal_connect(G_OBJECT(powerd_source->priv->skel), "handle-get-sys-request-stats",
> G_CALLBACK(handle_get_sys_request_stats), powerd_source);
> - g_signal_connect(G_OBJECT(powerd_source->priv->skel), "handle-get-disp-request-stats",
> - G_CALLBACK(handle_get_disp_request_stats), powerd_source);
> g_signal_connect(G_OBJECT(powerd_source->priv->skel), "handle-user-autobrightness-enable",
> G_CALLBACK(handle_user_autobrightness_enable), powerd_source);
> g_signal_connect(G_OBJECT(powerd_source->priv->skel), "handle-get-brightness-params",
> @@ -234,32 +224,6 @@
> }
>
> void
> -powerd_display_state_signal_emit(enum powerd_display_state state,
> - guint32 flags)
> -{
> - GError *error = NULL;
> -
> - /* Make sure dbus has been set up */
> - if (!powerd_source)
> - return;
> -
> - powerd_debug("Emitting signal for display state change: state=%d flags=0x%08x",
> - state, flags);
> - g_dbus_connection_emit_signal(
> - POWERD_SOURCE_GET_PRIVATE(powerd_source)->system_bus,
> - NULL, /* destination */
> - "/com/canonical/powerd",
> - "com.canonical.powerd",
> - "DisplayPowerStateChange",
> - g_variant_new("(iu)", state, flags),
> - &error);
> - if (error) {
> - powerd_warn("Unable to signal a state change update: %s", error->message);
> - g_error_free(error);
> - }
> -}
> -
> -void
> ofono_manager_proxy_connect_cb(GObject *source_object,
> GAsyncResult *res,
> gpointer user_data)
> @@ -355,8 +319,6 @@
> gpointer user_data)
> {
> powerd_warn("%s vanished from dbus, clearing associated requests", name);
> - clear_sys_state_by_owner(name);
> - clear_disp_state_by_owner(name);
> powerd_client_unregister(name);
> // This can return false if the hash entry was removed because the
> // last request was dropped, in other words, this call will fail
>
> === modified file 'src/powerd.cpp'
> --- src/powerd.cpp 2014-03-28 08:00:33 +0000
> +++ src/powerd.cpp 2014-06-17 03:45:55 +0000
> @@ -44,10 +44,6 @@
> #include "log.h"
>
> #include <hybris/properties/properties.h>
> -#include <hybris/input/input_stack_compatibility_layer.h>
> -#include <hybris/input/input_stack_compatibility_layer_codes_key.h>
> -
> -#include <hybris/surface_flinger/surface_flinger_compatibility_layer.h>
>
> #include "libsuspend.h"
>
> @@ -57,74 +53,11 @@
>
> namespace
> {
> -
> -#define SHUTDOWN_HOLD_SECS 2
> -
> -static uint button_timer = 0;
> -
> -/*
> - * Do not modify activity_timer directly. Instead, call
> - * reset_activity_timer();
> - */
> -static uint activity_timer = 0;
> -GMutex activity_timer_mutex;
> -
> -static time_t curtime;
> -static int lasttime;
> -struct tm *tm;
> -
> -/* The real default for this is set in the gschema file, but set 60 here
> - * as a sanity check */
> -static const int activity_timeout = 60;
> -static const int dim_timeout = 45;
> -
> static GMainLoop *main_loop = NULL;
> static guint name_id;
>
> -enum state {
> - BUTTON_DOWN,
> - BUTTON_UP,
> - SHUTDOWN
> -};
> -
> -static state button_state = BUTTON_UP;
> -
> -enum {
> - SCREEN_STATE_OFF = 0,
> - SCREEN_STATE_DIM,
> - SCREEN_STATE_BRIGHT
> -};
> -
> -/* Assume screen starts off when powerd starts */
> -int activity_timer_screen_state = SCREEN_STATE_OFF;
> -
> static int g_exit_code = 0;
>
> -/*
> - * Display request for activity timer
> - *
> - * Stupid C++ compiler won't let me use designated initializers ...
> - */
> -static struct powerd_display_request activity_timer_req = {
> - {0,}, /* cookie */
> - POWERD_DISPLAY_STATE_ON, /* state */
> - POWERD_DISPLAY_FLAG_BRIGHT /* flags */
> -};
> -
> -/* Display request for use of proximity sensor during phone calls */
> -static struct powerd_display_request prox_sensor_req = {
> - {0,}, /* cookie */
> - POWERD_DISPLAY_STATE_ON, /* state */
> - POWERD_DISPLAY_FLAG_USE_PROXIMITY /* flags */
> -};
> -
> -/* Default display request in case running in emulator */
> -static struct powerd_display_request emulator_req = {
> - {0,}, /* cookie */
> - POWERD_DISPLAY_STATE_ON, /* state */
> - POWERD_DISPLAY_FLAG_BRIGHT /* flags */
> -};
> -
> /* List with detected modems */
> static GSList *g_modems = NULL;
>
> @@ -150,86 +83,8 @@
> /* Flag set when proximity sensor is on */
> static gboolean g_proximity_on = FALSE;
>
> -gboolean activity_monitor(gpointer data);
> -void update_screen_state(int state);
> -
> -gboolean call_shutdown(gpointer data)
> -{
> - if (button_state == BUTTON_DOWN) {
> - button_state = SHUTDOWN;
> - powerd_set_brightness(0);
> - display_set_power_mode(0, "off");
> - powerd_shutdown();
> - }
> -
> - return FALSE;
> -}
> -
> -gboolean activity_monitor(gpointer data)
> -{
> - int new_state;
> -
> - g_mutex_lock(&activity_timer_mutex);
> -
> - if (activity_timer_screen_state > SCREEN_STATE_OFF) {
> - if (dim_timeout > 0 && activity_timeout > dim_timeout)
> - new_state = activity_timer_screen_state - 1;
> - else
> - new_state = SCREEN_STATE_OFF;
> -
> - update_screen_state(new_state);
> - if (new_state != SCREEN_STATE_OFF && activity_timer > 0)
> - activity_timer = g_timeout_add_seconds(activity_timeout - dim_timeout,
> - activity_monitor, NULL);
> - }
> -
> - g_mutex_unlock(&activity_timer_mutex);
> - return FALSE;
> -}
> -
> static struct power_module* _power_module;
>
> -void on_new_event(Event* event, void* context)
> -{
> - switch(event->type)
> - {
> - case KEY_EVENT_TYPE:
> - if (event->details.key.key_code == ISCL_KEYCODE_POWER && button_state != SHUTDOWN) {
> - if (event->action == 1) {
> - powerd_debug("power button pressed");
> - button_state = BUTTON_UP;
> - curtime = time(0);
> - tm = localtime (&curtime);
> - if (tm->tm_sec - lasttime < SHUTDOWN_HOLD_SECS) {
> - gboolean enabled = powerd_display_enabled();
> - if (enabled)
> - powerd_display_set_override(POWERD_OVERRIDE_REASON_POWER_BUTTON);
> - else
> - powerd_display_clear_override(POWERD_OVERRIDE_REASON_POWER_BUTTON);
> - powerd_reset_activity_timer(!enabled);
> - }
> - } else if (event->action == 0) {
> - button_state = BUTTON_DOWN;
> - curtime = time(0);
> - tm = localtime (&curtime);
> - lasttime = tm->tm_sec;
> - if (button_timer > 0)
> - {
> - g_source_remove(button_timer);
> - button_timer = 0;
> - }
> - button_timer = g_timeout_add_seconds(SHUTDOWN_HOLD_SECS,
> - call_shutdown, NULL);
> - }
> - }
> - break;
> - default:
> - if (powerd_display_enabled())
> - powerd_reset_activity_timer(1);
> - break;
> - }
> -}
> -
> static void
> sigterm_quit(int signal)
> {
> @@ -237,43 +92,6 @@
> powerd_exit(0);
> }
>
> -int update_screen_state_worker(gpointer data)
> -{
> - long new_state = (long)data;
> - int ret;
> -
> - if (new_state == activity_timer_screen_state)
> - return 0;
> -
> - if (new_state == SCREEN_STATE_OFF) {
> - powerd_remove_display_request(activity_timer_req.cookie);
> - } else {
> - if (new_state == SCREEN_STATE_DIM)
> - activity_timer_req.flags &= ~POWERD_DISPLAY_FLAG_BRIGHT;
> - else
> - activity_timer_req.flags |= POWERD_DISPLAY_FLAG_BRIGHT;
> -
> - if (activity_timer_screen_state == SCREEN_STATE_OFF)
> - ret = powerd_add_display_request(&activity_timer_req,
> - "activity-timer");
> - else
> - ret = powerd_update_display_request(&activity_timer_req);
> -
> - if (ret)
> - powerd_warn("Error adding display state request for activity timer");
> - }
> -
> - activity_timer_screen_state = new_state;
> - return 0;
> -}
> -
> -void update_screen_state(int new_state)
> -{
> - long data = new_state;
> - if (new_state < SCREEN_STATE_OFF || new_state > SCREEN_STATE_BRIGHT)
> - return;
> - powerd_run_mainloop_sync(update_screen_state_worker, (gpointer)data);
> -}
>
> } //namespace
>
> @@ -284,39 +102,12 @@
> _power_module->powerHint(_power_module, POWER_HINT_INTERACTION, NULL);
> }
>
> -void powerd_reset_activity_timer(int add)
> -{
> - int timeout;
> -
> - g_mutex_lock(&activity_timer_mutex);
> -
> - if (activity_timer > 0) {
> - g_source_remove(activity_timer);
> - activity_timer = 0;
> - }
> -
> - if (add) {
> - if (dim_timeout > 0 && dim_timeout < activity_timeout)
> - timeout = dim_timeout;
> - else
> - timeout = activity_timeout;
> -
> - update_screen_state(SCREEN_STATE_BRIGHT);
> - activity_timer = g_timeout_add_seconds(timeout, activity_monitor, NULL);
> - } else {
> - update_screen_state(SCREEN_STATE_OFF);
> - }
> -
> - g_mutex_unlock(&activity_timer_mutex);
> -}
> -
> /*
> * Once dbus is ready, force the screen on to make the system state
> * match the powerd iternal state
> */
> void powerd_dbus_init_complete(void)
> {
> - powerd_reset_activity_timer(1);
> }
>
> static void watch_modem(const char *modem)
> @@ -411,8 +202,7 @@
>
> if (strcmp("active", call_state) == 0
> || strcmp("dialing", call_state) == 0) {
> - if (powerd_add_display_request(&prox_sensor_req, "prox-sensor"))
> - powerd_warn("Request to use proximity sensor failed");
> + powerd_sensors_proximity_enable();
> g_proximity_on = TRUE;
> }
> }
> @@ -422,10 +212,19 @@
> if (!g_proximity_on)
> return;
>
> - powerd_remove_display_request(prox_sensor_req.cookie);
> + powerd_sensors_proximity_disable();
> g_proximity_on = FALSE;
> }
>
> +
> +void powerd_proximity_event(gboolean near)
> +{
> + if (near)
> + turn_display_on(FALSE, UNITY_SCREEN_REASON_PROXIMITY);
> + else
> + turn_display_on(TRUE, UNITY_SCREEN_REASON_PROXIMITY);
> +}
> +
> void
> ofono_voicecall_get_props_cb(GObject *source_object, GAsyncResult *res,
> gpointer user_data)
> @@ -509,8 +308,7 @@
> if (!strcmp(signal_name, "CallAdded")) {
> struct call_data *call;
>
> - powerd_display_clear_override(POWERD_OVERRIDE_REASON_POWER_BUTTON);
> - powerd_reset_activity_timer(1);
> + turn_display_on(TRUE, UNITY_SCREEN_REASON_NORMAL);
>
> call = (struct call_data *) calloc(1, sizeof(*call));
> tmp = g_variant_get_child_value(parameters, 0);
> @@ -589,8 +387,7 @@
> if ((!strcmp(signal_name, "IncomingMessage")) ||
> (!strcmp(signal_name, "ImmediateMessage"))) {
> powerd_debug("Waking up the device - Incoming SMS");
> - powerd_display_clear_override(POWERD_OVERRIDE_REASON_POWER_BUTTON);
> - powerd_reset_activity_timer(1);
> + turn_display_on(TRUE, UNITY_SCREEN_REASON_NORMAL);
> }
> }
>
> @@ -605,8 +402,7 @@
> if ((!strcmp(signal_name, "NotificationReceived")) ||
> (!strcmp(signal_name, "RequestReceived"))) {
> powerd_debug("Waking up the device - Incoming USSD");
> - powerd_display_clear_override(POWERD_OVERRIDE_REASON_POWER_BUTTON);
> - powerd_reset_activity_timer(1);
> + turn_display_on(TRUE, UNITY_SCREEN_REASON_NORMAL);
> }
> }
>
> @@ -632,9 +428,6 @@
>
> if (property_get("ro.kernel.qemu", propbuf, NULL) > 0) {
> powerd_info("Running in emulator, forcing display, blocking suspend.");
> - /* Request screen to be always on */
> - if (powerd_add_display_request(&emulator_req, "emulator-display"))
> - powerd_warn("Request to force screen on for emulator failed");
No you are right, I'll fix it.
> /* Block suspend */
> request_sys_state_internal("emulator-request",
> POWERD_SYS_STATE_ACTIVE,
> @@ -686,45 +479,21 @@
> powerd_stats_init();
> powerd_client_init();
> power_request_init();
> - display_request_init();
> dbus_name_watch_init();
> powerd_backlight_init();
> powerd_autobrightness_init();
> - powerd_display_init();
> powerd_sensors_init();
> powerd_ps_init();
>
> main_loop = g_main_loop_new (NULL, FALSE);
> signal(SIGTERM, sigterm_quit);
>
> - AndroidEventListener listener;
> - listener.on_new_event = on_new_event;
> - listener.context = NULL;
> -
> - InputStackConfiguration config = {
> - enable_touch_point_visualization : false,
> - default_layer_for_touch_point_visualization : 10000,
> - input_area_width : 2048,
> - input_area_height : 2048
> - };
> -
> int err = hw_get_module(POWER_HARDWARE_MODULE_ID,
> (hw_module_t const**)&_power_module);
>
> if (!err)
> _power_module->init(_power_module);
>
> - /* Compat input is needed otherwise there's no way to know when
> - * the user is actively using the system */
> - if (!android_input_check_availability()) {
> - powerd_error("Android compat input library not found, aborting");
> - g_exit_code = -1;
> - goto fail_compat_init;
> - }
> -
> - android_input_stack_initialize(&listener, &config);
> - android_input_stack_start();
> -
> /* Config use should be done during init, okay to free now */
> device_config_deinit();
>
> @@ -736,15 +505,10 @@
> g_bus_unown_name(name_id);
> g_main_loop_unref(main_loop);
>
> - android_input_stack_stop();
> - android_input_stack_shutdown();
> -
> -fail_compat_init:
> powerd_ps_deinit();
> dbus_name_watch_deinit();
> powerd_autobrightness_deinit();
> powerd_backlight_deinit();
> - display_request_deinit();
> power_request_deinit();
> powerd_client_deinit();
> powerd_stats_deinit();
>
> === modified file 'src/powerd.h'
> --- src/powerd.h 2013-07-18 21:08:49 +0000
> +++ src/powerd.h 2014-06-17 03:45:55 +0000
> @@ -34,24 +34,6 @@
> POWERD_NUM_POWER_STATES
> };
>
> -enum powerd_display_state {
> - POWERD_DISPLAY_STATE_DONT_CARE = 0,
> - POWERD_DISPLAY_STATE_ON,
> -
> - /* Keep last */
> - POWERD_NUM_DISPLAY_STATES
> -};
> -
> -/* Use proximity sensor to override screen state */
> -#define POWERD_DISPLAY_FLAG_USE_PROXIMITY (1 << 0)
> -/* Force autobrightness to be disabled */
> -#define POWERD_DISPLAY_FLAG_DISABLE_AUTOBRIGHTNESS (1 << 1)
> -/* Request the screen to stay bright */
> -#define POWERD_DISPLAY_FLAG_BRIGHT (1 << 2)
> -
> -/* Must be updated when new flags are added */
> -#define POWERD_NUM_DISPLAY_FLAGS 3
> -
> /*
> * Clients should treat this as an opaque type. Though this isn't really
> * possible until the client library is written.
>
> === modified file 'src/stats.c'
> --- src/stats.c 2013-09-03 14:10:41 +0000
> +++ src/stats.c 2014-06-17 03:45:55 +0000
> @@ -48,19 +48,6 @@
> guint64 active_since;
> };
>
> -struct disp_request_stats {
> - const char *name;
> - unsigned active_count;
> - guint64 active_time;
> - guint64 max_active_time;
> - guint64 active_since;
> - guint64 disp_on_time;
> - guint64 disp_on_since;
> - guint64 flag_on_time[POWERD_NUM_DISPLAY_FLAGS];
> - guint64 flag_on_since[POWERD_NUM_DISPLAY_FLAGS];
> - struct powerd_display_request last_req;
> -};
> -
> GHashTable *stats_hash;
>
> static guint64 get_usecs(void)
> @@ -111,24 +98,6 @@
> return stats;
> }
>
> -static struct disp_request_stats *alloc_disp_stats(const char *name)
> -{
> - struct disp_request_stats *stats = calloc(1, sizeof(*stats));
> - if (!stats) {
> - powerd_error("Error allocating memory for display request statistics");
> - return NULL;
> - }
> -
> - stats->name = strdup(name);
> - if (!stats->name) {
> - powerd_error("Error duplicating request name for statistics");
> - free(stats);
> - return NULL;
> - }
> -
> - return stats;
> -}
> -
> static gint sys_stats_comp(gconstpointer a, gconstpointer b)
> {
> const struct sys_request_stats *stats = a;
> @@ -136,13 +105,6 @@
> return strcmp(stats->name, name);
> }
>
> -static gint disp_stats_comp(gconstpointer a, gconstpointer b)
> -{
> - const struct disp_request_stats *stats = a;
> - const char *name = b;
> - return strcmp(stats->name, name);
> -}
> -
> static struct client_stats *lookup_client(const char *dbus_name,
> gboolean alloc)
> {
> @@ -210,122 +172,6 @@
> stats->max_active_time = duration;
> }
>
> -static void aggregate_disp_stats(struct disp_request_stats *stats,
> - const struct powerd_display_request *new)
> -{
> - guint64 us;
> - int i;
> -
> - us = get_usecs();
> - if (new->state != stats->last_req.state) {
> - if (new->state == POWERD_DISPLAY_STATE_ON) {
> - stats->disp_on_since = us;
> - } else {
> - stats->disp_on_time += us - stats->disp_on_since;
> - stats->disp_on_since = 0;
> - }
> - }
> - for (i = 0; i < POWERD_NUM_DISPLAY_FLAGS; i++) {
> - guint32 mask = 1 << i;
> - if ((new->flags & mask) != (stats->last_req.flags & mask)) {
> - if (new->flags & mask) {
> - stats->flag_on_since[i] = us;
> - } else {
> - stats->flag_on_time[i] += us - stats->flag_on_since[i];
> - stats->flag_on_since[i] = 0;
> - }
> - }
> - }
> -}
> -
> -void powerd_account_add_display_req(const char *dbus_name, const char *name,
> - const struct powerd_display_request *req)
> -{
> - struct client_stats *client;
> - struct disp_request_stats *stats;
> - GSList *item;
> - guint64 us;
> - int i;
> -
> - if (!stats_hash)
> - return;
> -
> - client = lookup_client(dbus_name, TRUE);
> - if (!client)
> - return;
> -
> - item = g_slist_find_custom(client->disp_stats, name, disp_stats_comp);
> - if (item) {
> - stats = item->data;
> - } else {
> - stats = alloc_disp_stats(name);
> - if (!stats)
> - return;
> - client->disp_stats = g_slist_prepend(client->disp_stats, stats);
> - }
> -
> - us = get_usecs();
> - stats->active_count++;
> - stats->active_since = us;
> - if (req->state == POWERD_DISPLAY_STATE_ON)
> - stats->disp_on_since = us;
> - for (i = 0; i < POWERD_NUM_DISPLAY_FLAGS; i++) {
> - if (req->flags & (1 << i))
> - stats->flag_on_since[i] = us;
> - }
> - stats->last_req = *req;
> -}
> -
> -void powerd_account_update_display_req(const char *dbus_name,
> - const char *name,
> - const struct powerd_display_request *req)
> -{
> - struct client_stats *client;
> - struct disp_request_stats *stats;
> - GSList *item;
> -
> - client = lookup_client(dbus_name, FALSE);
> - if (!client)
> - return;
> -
> - item = g_slist_find_custom(client->disp_stats, name, disp_stats_comp);
> - if (!item)
> - return;
> - stats = item->data;
> -
> - aggregate_disp_stats(stats, req);
> - stats->last_req = *req;
> -}
> -
> -void powerd_account_clear_display_req(const char *dbus_name, const char *name)
> -{
> - struct client_stats *client;
> - struct disp_request_stats *stats;
> - GSList *item;
> - struct powerd_display_request req;
> - guint64 duration;
> -
> - client = lookup_client(dbus_name, FALSE);
> - if (!client)
> - return;
> -
> - item = g_slist_find_custom(client->disp_stats, name, disp_stats_comp);
> - if (!item)
> - return;
> - stats = item->data;
> -
> - memset(&req, 0, sizeof(req));
> - aggregate_disp_stats(stats, &req);
> -
> - duration = get_usecs() - stats->active_since;
> - stats->active_time += duration;
> - stats->active_since = 0;
> - if (duration > stats->max_active_time)
> - stats->max_active_time = duration;
> -
> - stats->last_req = req;
> -}
> -
> static void log_sys_req_stats(struct client_stats *client)
> {
> const char *dbus_name = client->dbus_name;
> @@ -361,56 +207,6 @@
> }
> }
>
> -static void log_disp_req_stats(struct client_stats *client)
> -{
> - const char *dbus_name = client->dbus_name;
> - GSList *cur;
> - guint64 us;
> -
> - us = get_usecs();
> - for (cur = client->disp_stats; cur; cur = g_slist_next(cur)) {
> - struct disp_request_stats *stats = cur->data;
> - guint64 active_time, max_active_time;
> - guint64 disp_on_time;
> - int i;
> -
> - active_time = stats->active_time;
> - max_active_time = stats->max_active_time;
> - if (stats->active_since != 0) {
> - guint64 duration = us - stats->active_since;
> - active_time += duration;
> - if (duration > max_active_time)
> - max_active_time = duration;
> - }
> -
> - disp_on_time = stats->disp_on_time;
> - if (stats->disp_on_since != 0)
> - disp_on_time += us - stats->disp_on_since;
> -
> - powerd_info(" Name: %s", stats->name);
> - powerd_info(" Owner: %s", dbus_name);
> - powerd_info(" Active Count: %u", stats->active_count);
> - powerd_info(" Active Time: %f", (double)active_time / 1000000.0f);
> - powerd_info(" Max Active Time: %f",
> - (double)max_active_time / 1000000.0f);
> - powerd_info(" Active Since: %f",
> - (double)stats->active_since / 1000000.0f);
> - powerd_info(" Display On Time: %f",
> - (double)disp_on_time / 1000000.0f);
> - powerd_info(" Display On Since: %f",
> - (double)stats->disp_on_since / 1000000.0f);
> - for (i = 0; i < POWERD_NUM_DISPLAY_FLAGS; i++) {
> - guint64 on_time = stats->flag_on_time[i];
> - if (stats->flag_on_since[i] != 0)
> - on_time += us - stats->flag_on_since[i];
> - powerd_info(" Flag %d On Time: %f", i,
> - (double)on_time / 1000000.0f);
> - powerd_info(" Flag %d On Since: %f", i,
> - (double)stats->flag_on_since[i] / 1000000.0f);
> - }
> - }
> -}
> -
> void powerd_log_stats(void)
> {
> struct sysinfo si;
> @@ -425,11 +221,6 @@
> g_hash_table_iter_init(&iter, stats_hash);
> while (g_hash_table_iter_next(&iter, &key, &value))
> log_sys_req_stats(value);
> -
> - powerd_info("Display Request Statistics:");
> - g_hash_table_iter_init(&iter, stats_hash);
> - while (g_hash_table_iter_next(&iter, &key, &value))
> - log_disp_req_stats(value);
> }
> }
>
> @@ -440,18 +231,10 @@
> free(stats);
> }
>
> -static void disp_stats_list_destroy(gpointer data)
> -{
> - struct disp_request_stats *stats = data;
> - free((void *)stats->name);
> - free(stats);
> -}
> -
> static void stats_hash_destroy(gpointer data)
> {
> struct client_stats *client = data;
> g_slist_free_full(client->sys_stats, sys_stats_list_destroy);
> - g_slist_free_full(client->disp_stats, disp_stats_list_destroy);
> free((void *)client->dbus_name);
> free(client);
> }
> @@ -538,81 +321,3 @@
> return TRUE;
> }
>
> -static int build_disp_request_list(GVariantBuilder *builder,
> - struct client_stats *client)
> -{
> - const char *dbus_name = client->dbus_name;
> - GSList *cur;
> - guint64 us;
> - int count = 0;
> -
> - us = get_usecs();
> - for (cur = client->disp_stats; cur; cur = g_slist_next(cur)) {
> - struct disp_request_stats *stats = cur->data;
> - guint64 active_time, max_active_time;
> - guint64 disp_on_time;
> - GVariantBuilder *fot_builder, *fos_builder;
> - int i;
> -
> - active_time = stats->active_time;
> - max_active_time = stats->max_active_time;
> - if (stats->active_since != 0) {
> - guint64 duration = us - stats->active_since;
> - active_time += duration;
> - if (duration > max_active_time)
> - max_active_time = duration;
> - }
> -
> - disp_on_time = stats->disp_on_time;
> - if (stats->disp_on_since != 0)
> - disp_on_time += us - stats->disp_on_since;
> -
> - fot_builder = g_variant_builder_new(G_VARIANT_TYPE("at"));
> - fos_builder = g_variant_builder_new(G_VARIANT_TYPE("at"));
> - for (i = 0; i < POWERD_NUM_DISPLAY_FLAGS; i++) {
> - guint64 flag_on_time = stats->flag_on_time[i];
> - if (stats->flag_on_since[i] != 0)
> - flag_on_time += us - stats->flag_on_since[i];
> - g_variant_builder_add(fot_builder, "t", flag_on_time);
> - g_variant_builder_add(fos_builder, "t", stats->flag_on_since[i]);
> - }
> - g_variant_builder_add(builder, "(ssutttttatat)", dbus_name,
> - stats->name, stats->active_count, active_time,
> - max_active_time, stats->active_since,
> - disp_on_time, stats->disp_on_since,
> - fot_builder, fos_builder);
> - g_variant_builder_unref(fot_builder);
> - g_variant_builder_unref(fos_builder);
> - count++;
> - }
> - return count;
> -}
> -
> -gboolean handle_get_disp_request_stats(PowerdSource *obj,
> - GDBusMethodInvocation *invocation)
> -{
> - GVariantBuilder *builder;
> - GVariant *list, *tuple;
> - GHashTableIter iter;
> - gpointer key, value;
> - int count = 0;
> -
> - builder = g_variant_builder_new(G_VARIANT_TYPE("a(ssutttttatat)"));
> - if (stats_hash) {
> - g_hash_table_iter_init(&iter, stats_hash);
> - while (g_hash_table_iter_next(&iter, &key, &value))
> - count += build_disp_request_list(builder, value);
> - }
> -
> - if (count == 0) {
> - g_variant_builder_clear(builder);
> - list = g_variant_new_array(G_VARIANT_TYPE("a(ssutttttatat)"), NULL, 0);
> - } else {
> - list = g_variant_builder_end(builder);
> - }
> - tuple = g_variant_new_tuple(&list, 1);
> - g_dbus_method_invocation_return_value(invocation, tuple);
> - g_variant_builder_unref(builder);
> -
> - return TRUE;
> -}
>
--
https://code.launchpad.net/~albaguirre/powerd/remove-input-inactivity-handling/+merge/219449
Your team Ubuntu Phablet Team is subscribed to branch lp:powerd.
More information about the Ubuntu-reviews
mailing list