Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[proximity] On-demand proximity sensor activation. Fixes JB#34789 MER…
…#1562

MCE code has built-in assumption that proximity sensor is either not used at
all, or it is constantly powered on. The former basically means that in-call
proximity blanking is not available. And the latter can cause direct (the
sensor itself) or indirect (might block suspend) power drain, or make it
more likely for lower level sensor handling glitches to surface.

Make it possible to select on-demand proximity sensor activation.

When selected, proximity sensor is powered up:
- While the device in a state where it might be needed (calls, alarms, etc).
- When events that could lead to display wakeup are received (powerkey
  presses, doubletaps, etc).

As the sensor state is not available immediately after requesting
sensor powerup, implement on-proximity action queue which can be used
to schedule actions to be taken when the sensor has reached a stable
state.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Mar 15, 2019
1 parent 4b25492 commit d9c917b
Show file tree
Hide file tree
Showing 10 changed files with 927 additions and 171 deletions.
6 changes: 6 additions & 0 deletions .depend
Expand Up @@ -41,13 +41,15 @@ builtin-gconf.pic.o:\
datapipe.o:\
datapipe.c\
datapipe.h\
evdev.h\
mce-lib.h\
mce-log.h\
mce.h\

datapipe.pic.o:\
datapipe.c\
datapipe.h\
evdev.h\
mce-lib.h\
mce-log.h\
mce.h\
Expand Down Expand Up @@ -142,6 +144,7 @@ mce-common.o:\
datapipe.h\
mce-common.h\
mce-dbus.h\
mce-lib.h\
mce-log.h\
mce.h\

Expand All @@ -151,6 +154,7 @@ mce-common.pic.o:\
datapipe.h\
mce-common.h\
mce-dbus.h\
mce-lib.h\
mce-log.h\
mce.h\

Expand Down Expand Up @@ -928,6 +932,7 @@ modules/proximity.o:\
modules/proximity.c\
builtin-gconf.h\
datapipe.h\
mce-lib.h\
mce-log.h\
mce-sensorfw.h\
mce-setting.h\
Expand All @@ -938,6 +943,7 @@ modules/proximity.pic.o:\
modules/proximity.c\
builtin-gconf.h\
datapipe.h\
mce-lib.h\
mce-log.h\
mce-sensorfw.h\
mce-setting.h\
Expand Down
30 changes: 25 additions & 5 deletions builtin-gconf.c
@@ -1,8 +1,23 @@
/* ------------------------------------------------------------------------- *
* Copyright (C) 2012-2014 Jolla Ltd.
* Contact: Simo Piiroinen <simo.piiroinen@jollamobile.com>
* License: LGPLv2
* ------------------------------------------------------------------------- */
/**
* @file builtin-gconf.c
* GConf compatibility module - for dynamic mce settings
* <p>
* Copyright (C) 2012-2019 Jolla Ltd.
* <p>
* @author Simo Piiroinen <simo.piiroinen@jollamobile.com>
*
* mce is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* mce 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with mce. If not, see <http://www.gnu.org/licenses/>.
*/

/* ------------------------------------------------------------------------- *
* NOTE: This module implements just enough of the GConf API to allow us
Expand Down Expand Up @@ -1592,6 +1607,11 @@ static const setting_t gconf_defaults[] =
.type = "b",
.def = G_STRINGIFY(MCE_DEFAULT_PROXIMITY_PS_ENABLED),
},
{
.key = MCE_SETTING_PROXIMITY_ON_DEMAND,
.type = "b",
.def = G_STRINGIFY(MCE_DEFAULT_PROXIMITY_ON_DEMAND),
},
{
.key = MCE_SETTING_PROXIMITY_PS_ACTS_AS_LID,
.type = "b",
Expand Down
34 changes: 29 additions & 5 deletions datapipe.c
Expand Up @@ -4,7 +4,7 @@
* this can be used to filter data and to setup data triggers
* <p>
* Copyright © 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
* Copyright (C) 2014-2017 Jolla Ltd.
* Copyright (C) 2014-2019 Jolla Ltd.
* <p>
* @author David Weinehall <david.weinehall@nokia.com>
* @author Simo Piiroinen <simo.piiroinen@jollamobile.com>
Expand Down Expand Up @@ -630,6 +630,31 @@ datapipe_t lens_cover_state_pipe = DATAPIPE_INIT(lens_cover_state
/** Proximity sensor; read only */
datapipe_t proximity_sensor_actual_pipe = DATAPIPE_INIT(proximity_sensor_actual, cover_state, COVER_OPEN, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT);

/** Proximity sensor; read only */
datapipe_t proximity_sensor_effective_pipe = DATAPIPE_INIT(proximity_sensor_effective, cover_state, COVER_UNDEF, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT);

/** Proximity sensor on-demand control; write only
*
* The data fed into proximity_sensor_required_pipe needs to
* be a statically allocated const string with format like:
*
* "<PREFIX><NAME>"
*
* Where <PREFIX> is one of:
*
* - PROXIMITY_SENSOR_REQUIRED_ADD: <NAME> is added to the
* list of resons to keep on-demand proximity sensor mode
* active.
*
* - PROXIMITY_SENSOR_REQUIRED_REM: <NAME> is from the the
* list of resons to keep on-demand proximity sensor mode
* active.
*/
datapipe_t proximity_sensor_required_pipe = DATAPIPE_INIT(proximity_sensor_required, string, 0, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_NOTHING);

/** proximity blanking; read only */
datapipe_t proximity_blanked_pipe = DATAPIPE_INIT(proximity_blanked, boolean, false, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT);

/** Ambient light sensor; read only */
datapipe_t light_sensor_actual_pipe = DATAPIPE_INIT(light_sensor_actual, int, 400, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT);

Expand Down Expand Up @@ -766,9 +791,6 @@ datapipe_t keypad_grab_active_pipe = DATAPIPE_INIT(keypad_grab_acti
/** music playback active; read only */
datapipe_t music_playback_ongoing_pipe = DATAPIPE_INIT(music_playback_ongoing, boolean, false, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT);

/** proximity blanking; read only */
datapipe_t proximity_blanked_pipe = DATAPIPE_INIT(proximity_blanked, boolean, false, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT);

/** fingerprint daemon availability; read only */
datapipe_t fpd_service_state_pipe = DATAPIPE_INIT(fpd_service_state, service_state, SERVICE_STATE_UNDEF, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT);

Expand Down Expand Up @@ -1265,6 +1287,9 @@ void mce_datapipe_quit(void)
datapipe_free(&interaction_expected_pipe);
datapipe_free(&tklock_request_pipe);
datapipe_free(&proximity_sensor_actual_pipe);
datapipe_free(&proximity_sensor_effective_pipe);
datapipe_free(&proximity_sensor_required_pipe);
datapipe_free(&proximity_blanked_pipe);
datapipe_free(&light_sensor_actual_pipe);
datapipe_free(&light_sensor_filtered_pipe);
datapipe_free(&light_sensor_poll_request_pipe);
Expand Down Expand Up @@ -1320,7 +1345,6 @@ void mce_datapipe_quit(void)
datapipe_free(&keypad_grab_active_pipe);
datapipe_free(&keypad_grab_wanted_pipe);
datapipe_free(&music_playback_ongoing_pipe);
datapipe_free(&proximity_blanked_pipe);
datapipe_free(&fpd_service_state_pipe);
datapipe_free(&fpstate_pipe);
datapipe_free(&enroll_in_progress_pipe);
Expand Down
18 changes: 17 additions & 1 deletion datapipe.h
Expand Up @@ -3,8 +3,10 @@
* Headers for the simple filter framework
* <p>
* Copyright © 2007 Nokia Corporation and/or its subsidiary(-ies).
* Copyright (C) 2014-2019 Jolla Ltd.
* <p>
* @author David Weinehall <david.weinehall@nokia.com>
* @author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
*
* mce is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
Expand Down Expand Up @@ -193,6 +195,18 @@ void mce_datapipe_generate_inactivity (void);
GINT_TO_POINTER(tklock_request));\
}while(0)

/** Add reason -prefix for executing proximity_sensor_required_pipe request
*
* See #proximity_sensor_required_pipe for details.
*/
#define PROXIMITY_SENSOR_REQUIRED_ADD "+"

/** Remove reason -prefix for executing proximity_sensor_required_pipe request
*
* See #proximity_sensor_required_pipe for details.
*/
#define PROXIMITY_SENSOR_REQUIRED_REM "-"

/* ========================================================================= *
* Datapipes
* ========================================================================= */
Expand Down Expand Up @@ -223,6 +237,9 @@ extern datapipe_t lid_sensor_actual_pipe;
extern datapipe_t lid_sensor_filtered_pipe;
extern datapipe_t lens_cover_state_pipe;
extern datapipe_t proximity_sensor_actual_pipe;
extern datapipe_t proximity_sensor_effective_pipe;
extern datapipe_t proximity_sensor_required_pipe;
extern datapipe_t proximity_blanked_pipe;
extern datapipe_t light_sensor_actual_pipe;
extern datapipe_t light_sensor_filtered_pipe;
extern datapipe_t light_sensor_poll_request_pipe;
Expand Down Expand Up @@ -267,7 +284,6 @@ extern datapipe_t touch_grab_active_pipe;
extern datapipe_t keypad_grab_wanted_pipe;
extern datapipe_t keypad_grab_active_pipe;
extern datapipe_t music_playback_ongoing_pipe;
extern datapipe_t proximity_blanked_pipe;
extern datapipe_t fpd_service_state_pipe;
extern datapipe_t fpstate_pipe;
extern datapipe_t enroll_in_progress_pipe;
Expand Down

0 comments on commit d9c917b

Please sign in to comment.