diff --git a/datapipe.c b/datapipe.c index bf23df4c..918c444a 100644 --- a/datapipe.c +++ b/datapipe.c @@ -3,9 +3,9 @@ * This file implements the sinmple datapipe framework; * this can be used to filter data and to setup data triggers *

- * Copyright © 2007-2008 Nokia Corporation and/or its subsidiary(-ies). - * Copyright (C) 2014-2019 Jolla Ltd. - * Copyright (c) 2019 Open Mobile Platform LLC. + * Copyright (c) 2007 - 2008 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (c) 2014 - 2020 Jolla Ltd. + * Copyright (c) 2019 - 2020 Open Mobile Platform LLC. *

* @author David Weinehall * @author Simo Piiroinen @@ -744,7 +744,7 @@ datapipe_t battery_status_pipe = DATAPIPE_INIT(battery_status, datapipe_t battery_state_pipe = DATAPIPE_INIT(battery_state, battery_state, BATTERY_STATE_UNKNOWN, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT); /** Battery charge level; read only */ -datapipe_t battery_level_pipe = DATAPIPE_INIT(battery_level, int, BATTERY_LEVEL_INITIAL, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT); +datapipe_t battery_level_pipe = DATAPIPE_INIT(battery_level, int, MCE_BATTERY_LEVEL_UNKNOWN, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT); /** Topmost window PID; read only */ datapipe_t topmost_window_pid_pipe = DATAPIPE_INIT(topmost_window_pid, int, -1, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT); diff --git a/mce-common.c b/mce-common.c index 1a3c2db8..4ceccb83 100644 --- a/mce-common.c +++ b/mce-common.c @@ -2,8 +2,8 @@ * @file mce-common.c * Common state logic for Mode Control Entity *

- * Copyright (C) 2017-2019 Jolla Ltd. - * Copyright (c) 2019 Open Mobile Platform LLC. + * Copyright (c) 2017 - 2020 Jolla Ltd. + * Copyright (c) 2019 - 2020 Open Mobile Platform LLC. *

* @author Simo Piiroinen * @@ -133,8 +133,8 @@ static battery_status_t battery_status = BATTERY_STATUS_UNDEF; /** Battery state; assume unknown */ static battery_state_t battery_state = BATTERY_STATE_UNKNOWN; -/** Battery charge level: assume 100% */ -static gint battery_level = BATTERY_LEVEL_INITIAL; +/** Battery charge level: assume unknown */ +static gint battery_level = MCE_BATTERY_LEVEL_UNKNOWN; /** Cached (raw) proximity sensor state */ static cover_state_t proximity_sensor_actual = COVER_UNDEF; diff --git a/mce.h b/mce.h index 2ae68b96..cb63467c 100644 --- a/mce.h +++ b/mce.h @@ -2,9 +2,9 @@ * @file mce.h * Generic headers for Mode Control Entity *

- * Copyright © 2004-2011 Nokia Corporation and/or its subsidiary(-ies). - * Copyright (C) 2012-2019 Jolla Ltd. - * Copyright (c) 2019 Open Mobile Platform LLC. + * Copyright (c) 2004 - 2011 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (c) 2012 - 2020 Jolla Ltd. + * Copyright (c) 2019 - 2020 Open Mobile Platform LLC. *

* @author David Weinehall * @author Irina Bezruk @@ -310,9 +310,6 @@ const char *tklock_request_repr(tklock_request_t state); const char *tklock_status_repr(int status); -/** Assumed initial battery level */ -#define BATTERY_LEVEL_INITIAL 100 - /** Raw udev battery status */ typedef enum { diff --git a/modules/battery-udev.c b/modules/battery-udev.c index ba2c5e98..09ca56aa 100644 --- a/modules/battery-udev.c +++ b/modules/battery-udev.c @@ -2,8 +2,8 @@ * @file battery-udev.c * Battery module -- this implements battery and charger logic for MCE *

- * Copyright (C) 2018-2019 Jolla Ltd. - * Copyright (c) 2019 Open Mobile Platform LLC. + * Copyright (c) 2018 - 2020 Jolla Ltd. + * Copyright (c) 2019 - 2020 Open Mobile Platform LLC. *

* @author Simo Piiroinen *

@@ -296,7 +296,7 @@ G_MODULE_EXPORT module_info_struct module_info = * sync with default values held in the relevant datapipes. */ static mcebat_t mcebat_datapipe = { - .battery_level = BATTERY_LEVEL_INITIAL, + .battery_level = MCE_BATTERY_LEVEL_UNKNOWN, .battery_status = BATTERY_STATUS_UNDEF, .battery_state = BATTERY_STATE_UNKNOWN, .charger_state = CHARGER_STATE_UNDEF, @@ -306,7 +306,7 @@ static mcebat_t mcebat_datapipe = { /** Cached battery state as derived from udev */ static mcebat_t mcebat_actual = { - .battery_level = BATTERY_LEVEL_INITIAL, + .battery_level = MCE_BATTERY_LEVEL_UNKNOWN, .battery_status = BATTERY_STATUS_UNDEF, .battery_state = BATTERY_STATE_UNKNOWN, .charger_state = CHARGER_STATE_UNDEF, diff --git a/modules/led.c b/modules/led.c index be380289..916e7995 100644 --- a/modules/led.c +++ b/modules/led.c @@ -2,8 +2,9 @@ * @file led.c * LED module -- this handles the LED logic for MCE *

- * Copyright © 2006-2011 Nokia Corporation and/or its subsidiary(-ies). - * Copyright (C) 2012-2019 Jolla Ltd. + * Copyright (c) 2006 - 2011 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (c) 2012 - 2020 Jolla Ltd. + * Copyright (c) 2020 Open Mobile Platform LLC. *

* @author David Weinehall * @author Tapio Rantala @@ -57,6 +58,7 @@ #include #include +#include #include @@ -2888,8 +2890,8 @@ static gboolean init_patterns(void) /** Flag for: charger connected */ static charger_state_t charger_state = CHARGER_STATE_UNDEF; -/** Current battery percent level */ -static int battery_level = 0; +/** Current battery percent level: assume unknown */ +static int battery_level = MCE_BATTERY_LEVEL_UNKNOWN; /** Setting: sw breathing allowed */ static gboolean sw_breathing_enabled = MCE_DEFAULT_LED_SW_BREATH_ENABLED; diff --git a/modules/powersavemode.c b/modules/powersavemode.c index 3b846b0b..59088175 100644 --- a/modules/powersavemode.c +++ b/modules/powersavemode.c @@ -3,8 +3,9 @@ * Power saving mode module -- this handles the power saving mode * for MCE *

- * Copyright © 2010-2011 Nokia Corporation and/or its subsidiary(-ies). - * Copyright (C) 2014-2019 Jolla Ltd. + * Copyright (c) 2010 - 2011 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (c) 2014 - 2020 Jolla Ltd. + * Copyright (c) 2020 Open Mobile Platform LLC. *

* @author David Weinehall * @author Tapio Rantala @@ -32,6 +33,7 @@ #include "../mce-dbus.h" #include +#include #include @@ -51,8 +53,9 @@ G_MODULE_EXPORT module_info_struct module_info = { .priority = 250 }; -/** Battery charge level */ -static gint battery_level = 100; +/** Battery charge level: assume unknown == -1 */ +static gint battery_level = MCE_BATTERY_LEVEL_UNKNOWN; + /** Charger state */ static charger_state_t charger_state = CHARGER_STATE_UNDEF; @@ -138,9 +141,12 @@ static void update_power_saving_mode(void) * of other settings and states. */ activate = true; } + else if ( battery_level <= MCE_BATTERY_LEVEL_UNKNOWN ) { + /* Ignore triggers based on charger and battery + * info until battery level becomes known. */ + } else if( charger_state == CHARGER_STATE_ON ) { /* If charger is connected, PSM should be deactivated. */ - activate = false; } else if( force_psm ) { /* Forced PSM is triggered when no charger is connected. */ diff --git a/tools/mcetool.c b/tools/mcetool.c index ac7c74f5..6f8671c3 100644 --- a/tools/mcetool.c +++ b/tools/mcetool.c @@ -1,9 +1,9 @@ /** @file mcetool.c * Tool to test and remote control the Mode Control Entity *

- * Copyright © 2005-2011 Nokia Corporation and/or its subsidiary(-ies). - * Copyright (C) 2012-2019 Jolla Ltd. - * Copyright (c) 2019 Open Mobile Platform LLC. + * Copyright (c) 2005 - 2011 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (c) 2012 - 2020 Jolla Ltd. + * Copyright (c) 2019 - 2020 Open Mobile Platform LLC. *

* @author David Weinehall * @author Santtu Lakkala @@ -2727,7 +2727,7 @@ static bool mcetool_do_set_charger_state(const char *arg) static bool mcetool_do_set_battery_level(const char *arg) { int level = xmce_parse_integer(arg); - if( level < 0 || level > 100 ) { + if( level < -1 || level > 100 ) { errorf("%s: invalid battery level\n", arg); return false; } @@ -7999,7 +7999,9 @@ static const char version_text[] = PROG_NAME" v"G_STRINGIFY(PRG_VERSION)"\n" "Written by David Weinehall.\n" "\n" -"Copyright (C) 2005-2011 Nokia Corporation. All rights reserved.\n" +"Copyright (c) 2005 - 2011 Nokia Corporation. All rights reserved.\n" +"Copyright (c) 2012 - 2020 Jolla Ltd.\n" +"Copyright (c) 2019 - 2020 Open Mobile Platform LLC.\n" ; static __attribute__((__noreturn__)) bool mcetool_do_version(const char *arg)