I have made the following changes intended for : CE:MW:Shared / mce Please review and accept or decline. BOSS has already run some checks on this request. See the "Messages from BOSS" section below.
https://build.pub.meego.com//request/show/8108 Thank You, spiiroin [This message was auto-generated] --- Request # 8108: Messages from BOSS: State: review at 2013-02-18T16:09:46 by bossbot Reviews: accepted by bossbot : Prechecks succeeded. new for CE-maintainers : Please replace this text with a review and approve/reject the review (not the SR). BOSS will take care of the rest Changes: submit: home:spiiroin:branches:CE:MW:Shared / mce -> CE:MW:Shared / mce changes files: -------------- --- mce.changes +++ mce.changes @@ -0,0 +1,4 @@ +* Mon Feb 18 2013 Simo Piiroinen <[email protected]> - 1.12.7 +- Allow user processes to make get_config and set_config method calls +- Added configuration item for disabling automatic suspend + old: ---- mce-1.12.6.tar.bz2 new: ---- mce-1.12.7.tar.bz2 spec files: ----------- --- mce.spec +++ mce.spec @@ -1,6 +1,6 @@ Name: mce Summary: Mode Control Entity for Nokia mobile computers -Version: 1.12.6 +Version: 1.12.7 Release: 1 Group: System/System Control License: LGPLv2 other changes: -------------- ++++++ mce-1.12.6.tar.bz2 -> mce-1.12.7.tar.bz2 --- Makefile +++ Makefile @@ -43,7 +43,7 @@ # CONFIGURATION # ---------------------------------------------------------------------------- -VERSION := 1.12.6 +VERSION := 1.12.7 INSTALL_BIN := install --mode=755 INSTALL_DIR := install -d --- builtin-gconf.c +++ builtin-gconf.c @@ -1267,6 +1267,11 @@ }, #endif { + .key = "/system/osso/dsm/display/autosuspend_policy", + .type = "i", + .def = "1", + }, + { .key = NULL, } }; --- debian/changelog +++ debian/changelog @@ -1,3 +1,10 @@ +mce (1.12.7) unstable; urgency=low + + * Allow user processes to make get_config and set_config method calls + * Added configuration item for disabling automatic suspend + + -- Simo Piiroinen <[email protected]> Mon, 18 Feb 2013 17:42:46 +0200 + mce (1.12.6) unstable; urgency=low * Added evdev_trace utility to mce-tools package --- display.schemas +++ display.schemas @@ -171,5 +171,17 @@ <long>0 - Don't inhibit blanking; 1 - Inhibit dimming if charger is connected; 2 - Inhibit blanking if charger is connected; 3 - Inhibit dimming; 4 - Inhibit blanking</long> </locale> </schema> + + <schema> + <key>/schemas/system/osso/dsm/display/autosuspend_policy</key> + <applyto>/system/osso/dsm/display/autosuspend_policy</applyto> + <owner>mce</owner> + <type>int</type> + <default>1</default> + <locale name="C"> + <short>Automatic suspend mode</short> + <long>0 - Disabled; 1 - Enabled; 2 - Early suspend enabled</long> + </locale> + </schema> </schemalist> </gconfschemafile> --- mce.conf +++ mce.conf @@ -41,6 +41,17 @@ send_interface="com.nokia.mce.request" send_member="get_version"/> + <allow send_destination="com.nokia.mce" + send_interface="com.nokia.mce.request" + send_member="get_config"/> + <allow send_destination="com.nokia.mce" + send_interface="com.nokia.mce.request" + send_member="set_config"/> + + <allow send_destination="com.nokia.mce" + send_interface="com.nokia.mce.request" + send_member="get_color_profile"/> + <!-- Tighten this policy --> <allow send_destination="com.nokia.mce" send_interface="com.nokia.mce.request" --- modules/display.c +++ modules/display.c @@ -2802,6 +2802,29 @@ /** Still waiting for desktop ready ?*/ static guint suspend_timer_id = 0; +/** Automatic suspend policy modes */ +enum +{ + /** Always stay in on-mode */ + SUSPEND_POLICY_DISABLED = 0, + + /** Normal transitions between on, early suspend, and late suspend */ + SUSPEND_POLICY_ENABLED = 1, + + /** Allow on and early suspend, but never enter late suspend */ + SUSPEND_POLICY_EARLY_ONLY = 2, + + /** Default mode to use if no configuration exists */ + SUSPEND_POLICY_DEFAULT = SUSPEND_POLICY_ENABLED, +}; + +/** Automatic suspend policy */ +static gint suspend_policy = SUSPEND_POLICY_DEFAULT; + +/** GConf callback ID for automatic suspend policy changes */ +static guint suspend_policy_id = 0; + + /** Make suspend policy decision * * Unless we are still booting up or exiting mce, the policy @@ -2853,6 +2876,21 @@ wakelock_want = 0; } + /* adjust based on gconf setting */ + switch( suspend_policy ) { + case SUSPEND_POLICY_DISABLED: + suspend_want = 0; + break; + + case SUSPEND_POLICY_EARLY_ONLY: + wakelock_want = 1; + break; + + default: + case SUSPEND_POLICY_ENABLED: + break; + } + /* act if decision has changed */ if( wakelock_have != wakelock_want && wakelock_want ) wakelock_lock("mce_display_on", -1); @@ -2870,6 +2908,33 @@ wakelock_have = wakelock_want; } +/** Callback for handling changes to autosuspend policy configuration + * + * @param client (not used) + * @param id (not used) + * @param entry GConf entry that changed + * @param data (not used) + */ +static void suspend_policy_cb(GConfClient *const client, const guint id, + GConfEntry *const entry, gpointer const data) +{ + (void)client; (void)id; (void)data; + + gint policy = SUSPEND_POLICY_ENABLED; + const GConfValue *value = 0; + + if( entry && (value = gconf_entry_get_value(entry)) ) { + if( value->type == GCONF_VALUE_INT ) + policy = gconf_value_get_int(value); + } + if( suspend_policy != policy ) { + mce_log(LL_NOTICE, "suspend policy change: %d -> %d", + suspend_policy, policy); + suspend_policy = policy; + suspend_rethink(); + } +} + /** D-Bus callback for the shutdown notification signal * * @param msg The D-Bus message @@ -3347,6 +3412,14 @@ (void)get_display_type(); #ifdef ENABLE_WAKELOCKS + /* Get autosuspend policy configuration & track changes */ + mce_gconf_get_int(MCE_GCONF_USE_AUTOSUSPEND_PATH, + &suspend_policy); + mce_gconf_notifier_add(MCE_GCONF_DISPLAY_PATH, + MCE_GCONF_USE_AUTOSUSPEND_PATH, + suspend_policy_cb, + &suspend_policy_id); + /* Initialize suspend policy evaluator */ suspend_init(); #endif @@ -3698,6 +3771,11 @@ (void)module; #ifdef ENABLE_WAKELOCKS + /* Remove suspend policy change notifier */ + if( suspend_policy_id ) { + mce_gconf_notifier_remove(GINT_TO_POINTER(suspend_policy_id), 0); + } + /* Cleanup suspend policy evaluator */ suspend_quit(); #endif --- modules/display.h +++ modules/display.h @@ -135,6 +135,8 @@ #define MCE_GCONF_BLANKING_INHIBIT_MODE_PATH MCE_GCONF_DISPLAY_PATH "/inhibit_blank_mode" /** Path to the use Low Power Mode GConf setting */ #define MCE_GCONF_USE_LOW_POWER_MODE_PATH MCE_GCONF_DISPLAY_PATH "/use_low_power_mode" +/** Path to the use autosuspend GConf setting */ +#define MCE_GCONF_USE_AUTOSUSPEND_PATH MCE_GCONF_DISPLAY_PATH "/autosuspend_policy" /** Default display brightness on a scale from 1-5 */ #define DEFAULT_DISP_BRIGHTNESS 3 /* 60% */ --- tools/mcetool.c +++ tools/mcetool.c @@ -208,6 +208,9 @@ " -K, --set-autolock-mode=MODE\n" " set the autolock mode; valid modes are:\n" " \"enabled\" and \"disabled\"\n" + " -s, --set-suspend-policy=MODE\n" + " set the autosuspend mode; valid modes are:\n" + " \"enabled\", \"disabled\" and \"early\"\n" " -M, --set-doubletap-mode=MODE\n" " set the autolock mode; valid modes are:\n" " \"disabled\", \"show-unlock-screen\", \"unlock\"\n" @@ -1920,6 +1923,68 @@ } #endif // !defined(ENABLE_BUILTIN_GCONF) +/** Simple string key to integer value symbol */ +typedef struct +{ + /** Name of the symbol, or NULL to mark end of symbol table */ + const char *key; + + /** Value of the symbol */ + int val; +} symbol_t; + +/** Lookup symbol by name and return value + * + * @param stab array of symbol_t objects + * @param key name of the symbol to find + * + * @return Value matching the name. Or if not found, the + * value of the end-of-table marker symbol */ +static int lookup(const symbol_t *stab, const char *key) +{ + for( ; ; ++stab ) { + if( !stab->key || !strcmp(stab->key, key) ) + return stab->val; + } +} + +/** Lookup symbol by value and return name + * + * @param stab array of symbol_t objects + * @param val value of the symbol to find + * + * @return name of the first matching value, or NULL + */ +static const char *rlookup(const symbol_t *stab, int val) +{ + for( ; ; ++stab ) { + if( !stab->key || stab->val == val ) + return stab->key; + } +} + +/** Lookup table for doubletap gesture policies + * + * @note These must match the hardcoded values in mce itself. + */ +static const symbol_t doubletap_values[] = { + { "disabled", 0 }, + { "show-unlock-screen", 1 }, + { "unlock", 2 }, + { NULL, -1 } +}; + +/** Lookup table for autosuspend policies + * + * @note These must match the hardcoded values in mce itself. + */ +static const symbol_t suspendpol_values[] = { + { "disabled", 0 }, + { "enabled", 1 }, + { "early", 2 }, + { NULL, -1 } +}; + /** * Print mce related information * @@ -2346,48 +2411,20 @@ g_free(vec); } + /* Get autosuspend policy */ + { + gint policy; + retval = mcetool_gconf_get_int(MCE_GCONF_USE_AUTOSUSPEND_PATH, + &policy); + fprintf(stdout, " %-40s %s", "Autosuspend policy", + !retval ? "<unset>" : rlookup(suspendpol_values, policy) ?: "<unknown>"); + } EXIT: fprintf(stdout, "\n"); return status; } -/** Simple string key to integer value symbol */ -typedef struct -{ - /** Name of the symbol, or NULL to mark end of symbol table */ - const char *key; - - /** Value of the symbol */ - int val; -} symbol_t; - -/** Lookup symbol by name and return value - * - * @param stab array of symbol_t objects - * @param key name of the symbol to find - * - * @return Value matching the name. Or if not found, the - * value of the end-of-table marker symbol */ -static int lookup(const symbol_t *stab, const char *key) -{ - for( ; ; ++stab ) { - if( !stab->key || !strcmp(stab->key, key) ) - return stab->val; - } -} - -/** Lookup table for doubletap gesture policies - * - * @note These must match the hardcoded values in mce itself. - */ -static const symbol_t doubletap_values[] = { - { "disabled", 0 }, - { "show-unlock-screen", 1 }, - { "unlock", 2 }, - { NULL, -1 } -}; - /** Convert a comma separated string in to gint array * * @param text string to split @@ -2464,6 +2501,7 @@ gint newadaptthres = -1; gint newautolockena = -1; gint newdbltapgest = -1; + gint newsuspendpol = -1; gint *newdimtimeout_arr = 0; gint newdimtimeout_len = 0; gint newforcedpsm = -1; @@ -2536,6 +2574,7 @@ "K:" // --set-autolock-mode "M:" // --set-doubletap-mode "O:" // --set-dim-timeouts + "s:" // --set-suspend-policy ; struct option const options[] = { @@ -2576,6 +2615,7 @@ { "set-autolock-mode", required_argument, 0, 'K' }, { "set-doubletap-mode", required_argument, 0, 'M' }, { "set-dim-timeouts", required_argument, 0, 'O' }, + { "set-suspend-policy", required_argument, 0, 's' }, { 0, 0, 0, 0 } }; @@ -2764,6 +2804,15 @@ get_mce_status = FALSE; break; + case 's': + if( (newsuspendpol = lookup(suspendpol_values, optarg)) < 0 ) { + fprintf(stderr, "invalid suspend policy: %s\n", + optarg); + goto EXIT; + } + get_mce_status = FALSE; + break; + case 'O': newdimtimeout_arr = parse_gint_array(optarg, &newdimtimeout_len); @@ -3188,6 +3237,11 @@ newdbltapgest) == FALSE ) goto EXIT; } + if (newsuspendpol != -1) { + if (mcetool_gconf_set_int(MCE_GCONF_USE_AUTOSUSPEND_PATH, + newsuspendpol) == FALSE ) + goto EXIT; + } if( newdimtimeout_arr != 0 && newdimtimeout_len > 0 ) { if (mcetool_gconf_set_int_array(MCE_GCONF_DISPLAY_DIM_TIMEOUT_LIST_PATH, newdimtimeout_arr,
