Skip to content

Latest commit

 

History

History
7470 lines (6148 loc) · 225 KB

tklock.c

File metadata and controls

7470 lines (6148 loc) · 225 KB
 
Dec 16, 2010
Dec 16, 2010
1
2
3
4
5
/**
* @file tklock.c
* This file implements the touchscreen/keypad lock component
* of the Mode Control Entity
* <p>
May 12, 2011
May 12, 2011
6
* Copyright © 2004-2011 Nokia Corporation and/or its subsidiary(-ies).
Mar 15, 2019
Mar 15, 2019
7
* Copyright (C) 2012-2019 Jolla Ltd.
Dec 16, 2010
Dec 16, 2010
8
9
* <p>
* @author David Weinehall <david.weinehall@nokia.com>
Mar 15, 2019
Mar 15, 2019
10
11
12
13
14
15
16
* @author Tapio Rantala <ext-tapio.rantala@nokia.com>
* @author Santtu Lakkala <ext-santtu.1.lakkala@nokia.com>
* @author Jukka Turunen <ext-jukka.t.turunen@nokia.com>
* @author Irina Bezruk <ext-irina.bezruk@nokia.com>
* @author Kalle Jokiniemi <kalle.jokiniemi@jolla.com>
* @author Mika Laitio <lamikr@pilppa.org>
* @author Markus Lehtonen <markus.lehtonen@iki.fi>
Jan 14, 2014
Jan 14, 2014
17
* @author Simo Piiroinen <simo.piiroinen@jollamobile.com>
Mar 15, 2019
Mar 15, 2019
18
19
* @author Vesa Halttunen <vesa.halttunen@jollamobile.com>
* @author Andrew den Exter <andrew.den.exter@jolla.com>
Dec 16, 2010
Dec 16, 2010
20
21
22
23
24
25
26
27
28
29
30
31
32
33
*
* 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/>.
*/
May 27, 2014
May 27, 2014
34
#include "tklock.h"
Dec 16, 2010
Dec 16, 2010
35
Mar 15, 2019
Mar 15, 2019
36
#include "mce-common.h"
Jan 14, 2014
Jan 14, 2014
37
#include "mce-log.h"
Sep 22, 2015
Sep 22, 2015
38
#include "mce-lib.h"
May 27, 2014
May 27, 2014
39
#include "mce-io.h"
Mar 31, 2016
Mar 31, 2016
40
#include "mce-setting.h"
May 27, 2014
May 27, 2014
41
#include "mce-dbus.h"
May 19, 2015
May 19, 2015
42
#include "mce-hbtimer.h"
May 27, 2014
May 27, 2014
43
#include "evdev.h"
Jan 14, 2014
Jan 14, 2014
44
Mar 11, 2014
Mar 11, 2014
45
46
47
48
#ifdef ENABLE_WAKELOCKS
# include "libwakelock.h"
#endif
Mar 11, 2014
Mar 11, 2014
49
#include "modules/doubletap.h"
Jun 16, 2015
Jun 16, 2015
50
#include "modules/display.h"
Mar 11, 2014
Mar 11, 2014
51
May 27, 2014
May 27, 2014
52
53
54
55
56
57
58
#include "systemui/dbus-names.h"
#include "systemui/tklock-dbus-names.h"
#include <linux/input.h>
#include <unistd.h>
#include <string.h>
Jun 11, 2015
Jun 11, 2015
59
60
#include <fcntl.h>
#include <errno.h>
May 27, 2014
May 27, 2014
61
62
63
64
65
66
#include <mce/dbus-names.h>
#include <mce/mode-names.h>
#include <glib/gstdio.h>
Dec 12, 2014
Dec 12, 2014
67
68
69
70
71
72
73
74
75
76
77
typedef enum
{
/** No autorelock triggers */
AUTORELOCK_NO_TRIGGERS,
/** Autorelock on keyboard slide closed */
AUTORELOCK_KBD_SLIDE,
/** Autorelock on lens cover */
AUTORELOCK_LENS_COVER,
} autorelock_t;
Jan 14, 2014
Jan 14, 2014
78
May 8, 2014
May 8, 2014
79
80
81
/** Helper for evaluation number of items in an array */
#define numof(a) (sizeof(a)/sizeof*(a))
Jan 14, 2014
Jan 14, 2014
82
83
84
85
/* ========================================================================= *
* CONSTANTS
* ========================================================================= */
Mar 15, 2019
Mar 15, 2019
86
87
#define MODULE_NAME "tklock"
Jan 14, 2014
Jan 14, 2014
88
89
90
91
92
93
/** Max valid time_t value in milliseconds */
#define MAX_TICK (INT_MAX * (int64_t)1000)
/** Min valid time_t value in milliseconds */
#define MIN_TICK 0
Apr 15, 2014
Apr 15, 2014
94
95
96
/** Maximum number of concurrent notification ui exceptions */
#define TKLOCK_NOTIF_SLOTS 32
Oct 15, 2015
Oct 15, 2015
97
98
99
100
101
102
103
104
105
/** How long to wait for lid close after low lux [ms] */
#define TKLOCK_LIDFILTER_SET_WAIT_FOR_CLOSE_DELAY 1500
/** How long to wait for low lux after lid close [ms] */
#define TKLOCK_LIDFILTER_SET_WAIT_FOR_DARK_DELAY 1200
/** How long to wait for high lux after lid open [ms] */
#define TKLOCK_LIDFILTER_SET_WAIT_FOR_LIGHT_DELAY 1200
Jan 14, 2014
Jan 14, 2014
106
107
108
109
/* ========================================================================= *
* DATATYPES
* ========================================================================= */
Apr 15, 2014
Apr 15, 2014
110
111
112
113
114
115
116
117
typedef struct
{
/** BOOTTIME tick when notification autostops */
int64_t ns_until;
/** Amount of ms autostop extends from user input */
int64_t ns_renew;
Apr 15, 2014
Apr 15, 2014
118
119
120
/** Private D-Bus name of the slot owner */
gchar *ns_owner;
Apr 15, 2014
Apr 15, 2014
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/** Assumed unique identification string */
gchar *ns_name;
} tklock_notif_slot_t;
typedef struct
{
/** Array of notification slots */
tklock_notif_slot_t tn_slot[TKLOCK_NOTIF_SLOTS];
/** BOOTTIME linger tick from deactivated slots */
int64_t tn_linger;
/** Timer id for autostopping notification slots */
guint tn_autostop_id;
Apr 15, 2014
Apr 15, 2014
137
138
139
/** Slot owner D-Bus name monitoring list */
GSList *tn_monitor_list;
Apr 15, 2014
Apr 15, 2014
140
141
} tklock_notif_state_t;
May 8, 2014
May 8, 2014
142
143
144
145
146
147
148
149
150
151
152
/** Proximity sensor history */
typedef struct
{
/** Monotonic timestamp, ms resolution */
int64_t tick;
/** Proximity sensor state */
cover_state_t state;
} ps_history_t;
Oct 15, 2015
Oct 15, 2015
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/** Ambient light lux value mapped into enumerated states
*
* In case the lid sensor can't be trusted for some reason, data from
* ambient light sensor heuristics can be used for avoiding incorrect
* blank/unblank actions.
*
* For this purpose the raw data from ambient light sensor is tracked
* and mapped in to three states:
*
* - TKLOCK_LIDLIGHT_NA: The data from als is not applicable for filtering.
* - TKLOCK_LIDLIGHT_LO: The als indicates darkness.
* - TKLOCK_LIDLIGHT_HI: The als indicates some amount of light.
*/
typedef enum
{
/* Light level is not applicable for state evaluation */
TKLOCK_LIDLIGHT_NA,
/* Light level equals complete darkness */
TKLOCK_LIDLIGHT_LO,
/* Light level equals at least some light */
TKLOCK_LIDLIGHT_HI,
} tklock_lidlight_t;
Jan 14, 2014
Jan 14, 2014
178
179
180
/* ========================================================================= *
* PROTOTYPES
* ========================================================================= */
Dec 16, 2010
Dec 16, 2010
181
Jan 14, 2014
Jan 14, 2014
182
183
184
// datapipe values and triggers
static void tklock_datapipe_system_state_cb(gconstpointer data);
Feb 28, 2018
Feb 28, 2018
185
static void tklock_datapipe_devicelock_state_cb(gconstpointer data);
Mar 15, 2019
Mar 15, 2019
186
static void tklock_datapipe_devicelock_state_cb2(gpointer aptr);
Feb 28, 2018
Feb 28, 2018
187
static void tklock_datapipe_resume_detected_event_cb(gconstpointer data);
Mar 28, 2019
Mar 28, 2019
188
static void tklock_datapipe_devicelock_service_state_cb(gconstpointer data);
Feb 28, 2018
Feb 28, 2018
189
190
static void tklock_datapipe_lipstick_service_state_cb(gconstpointer data);
static void tklock_datapipe_osupdate_running_cb(gconstpointer data);
May 13, 2015
May 13, 2015
191
static void tklock_datapipe_shutting_down_cb(gconstpointer data);
Feb 28, 2018
Feb 28, 2018
192
static void tklock_datapipe_display_state_curr_cb(gconstpointer data);
Mar 28, 2019
Mar 28, 2019
193
194
static void tklock_datapipe_display_state_next_cb(gconstpointer data);
static void tklock_datapipe_proximity_eval_led(void);
Mar 11, 2014
Mar 11, 2014
195
196
197
198
static void tklock_datapipe_proximity_update(void);
static gboolean tklock_datapipe_proximity_uncover_cb(gpointer data);
static void tklock_datapipe_proximity_uncover_cancel(void);
static void tklock_datapipe_proximity_uncover_schedule(void);
Feb 28, 2018
Feb 28, 2018
199
static void tklock_datapipe_proximity_sensor_actual_cb(gconstpointer data);
Jan 14, 2014
Jan 14, 2014
200
static void tklock_datapipe_call_state_cb(gconstpointer data);
Mar 28, 2019
Mar 28, 2019
201
static void tklock_datapipe_music_playback_ongoing_cb(gconstpointer data);
Jan 14, 2014
Jan 14, 2014
202
203
204
static void tklock_datapipe_alarm_ui_state_cb(gconstpointer data);
static void tklock_datapipe_charger_state_cb(gconstpointer data);
static void tklock_datapipe_battery_status_cb(gconstpointer data);
Feb 28, 2018
Feb 28, 2018
205
206
207
208
209
static void tklock_datapipe_usb_cable_state_cb(gconstpointer data);
static void tklock_datapipe_jack_sense_state_cb(gconstpointer data);
static void tklock_datapipe_camera_button_state_cb(gconstpointer const data);
static void tklock_datapipe_keypress_event_cb(gconstpointer const data);
static void tklock_datapipe_uiexception_type_cb(gconstpointer data);
Jan 14, 2014
Jan 14, 2014
210
static void tklock_datapipe_audio_route_cb(gconstpointer data);
Feb 28, 2018
Feb 28, 2018
211
static void tklock_datapipe_tklock_request_cb(gconstpointer data);
Jun 2, 2017
Jun 2, 2017
212
static void tklock_datapipe_interaction_expected_cb(gconstpointer data);
Mar 28, 2019
Mar 28, 2019
213
static gpointer tklock_datapipe_submode_filter_cb(gpointer data);
Jan 14, 2014
Jan 14, 2014
214
static void tklock_datapipe_submode_cb(gconstpointer data);
Feb 28, 2018
Feb 28, 2018
215
216
217
218
219
static void tklock_datapipe_lockkey_state_cb(gconstpointer const data);
static void tklock_datapipe_heartbeat_event_cb(gconstpointer data);
static void tklock_datapipe_keyboard_slide_input_state_cb(gconstpointer const data);
static void tklock_datapipe_keyboard_slide_output_state_cb(gconstpointer const data);
static void tklock_datapipe_keyboard_available_state_cb(gconstpointer const data);
Oct 25, 2021
Oct 25, 2021
220
static void tklock_datapipe_mouse_available_state_cb(gconstpointer const data);
Feb 28, 2018
Feb 28, 2018
221
static void tklock_datapipe_light_sensor_poll_request_cb(gconstpointer const data);
Mar 28, 2019
Mar 28, 2019
222
static void tklock_datapipe_topmost_window_pid_cb(gconstpointer data);
Feb 28, 2018
Feb 28, 2018
223
static void tklock_datapipe_light_sensor_actual_cb(gconstpointer data);
Jun 11, 2015
Jun 11, 2015
224
static void tklock_datapipe_lid_sensor_is_working_cb(gconstpointer data);
Feb 28, 2018
Feb 28, 2018
225
226
227
static void tklock_datapipe_lid_sensor_actual_cb(gconstpointer data);
static void tklock_datapipe_lid_sensor_filtered_cb(gconstpointer data);
static void tklock_datapipe_lens_cover_state_cb(gconstpointer data);
Mar 28, 2019
Mar 28, 2019
228
static bool tklock_touch_activity_event_p(const struct input_event *ev);
Feb 28, 2018
Feb 28, 2018
229
static void tklock_datapipe_user_activity_event_cb(gconstpointer data);
Mar 21, 2018
Mar 21, 2018
230
static void tklock_datapipe_init_done_cb(gconstpointer data);
Jan 14, 2014
Jan 14, 2014
231
Sep 18, 2018
Sep 18, 2018
232
233
static bool tklock_datapipe_in_tklock_submode(void);
static void tklock_datapipe_set_tklock_submode(bool lock);
Feb 28, 2018
Feb 28, 2018
234
static void tklock_datapipe_set_devicelock_state(devicelock_state_t state);
Mar 28, 2019
Mar 28, 2019
235
236
static void tklock_datapipe_rethink_interaction_expected(void);
static void tklock_datapipe_update_interaction_expected(bool expected);
Jan 14, 2014
Jan 14, 2014
237
238
239
240
static void tklock_datapipe_init(void);
static void tklock_datapipe_quit(void);
Oct 15, 2015
Oct 15, 2015
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
// LID_SENSOR
static bool tklock_lidsensor_is_enabled (void);
static void tklock_lidsensor_init (void);
// LID_LIGHT
static const char *tklock_lidlight_repr (tklock_lidlight_t state);
static tklock_lidlight_t tklock_lidlight_from_lux (int lux);
// LID_FILTER
static bool tklock_lidfilter_is_enabled (void);
static void tklock_lidfilter_set_allow_close (bool allow);
Apr 24, 2015
Apr 24, 2015
256
Oct 15, 2015
Oct 15, 2015
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
static tklock_lidlight_t tklock_lidfilter_map_als_state (void);
static void tklock_lidfilter_set_als_state (tklock_lidlight_t state);
static gboolean tklock_lidfilter_wait_for_close_cb (gpointer aptr);
static bool tklock_lidfilter_get_wait_for_close (void);
static void tklock_lidfilter_set_wait_for_close (bool state);
static gboolean tklock_lidfilter_wait_for_dark_cb (gpointer aptr);
static bool tklock_lidfilter_get_wait_for_dark (void);
static void tklock_lidfilter_set_wait_for_dark (bool state);
static gboolean tklock_lidfilter_wait_for_light_cb (gpointer aptr);
static bool tklock_lidfilter_get_wait_for_light (void);
static void tklock_lidfilter_set_wait_for_light (bool state);
static void tklock_lidfilter_rethink_als_poll (void);
static void tklock_lidfilter_rethink_allow_close (void);
static void tklock_lidfilter_rethink_als_state (void);
static void tklock_lidfilter_rethink_lid_state (void);
// LID_POLICY
static void tklock_lidpolicy_rethink (void);
Apr 24, 2015
Apr 24, 2015
280
Jun 11, 2015
Jun 11, 2015
281
282
// keyboard slide state machine
Mar 28, 2019
Mar 28, 2019
283
284
285
static void tklock_keyboard_slide_opened(void);
static void tklock_keyboard_slide_opened_cb(gpointer aptr);
static void tklock_keyboard_slide_closed(void);
Jun 11, 2015
Jun 11, 2015
286
287
static void tklock_keyboard_slide_rethink(void);
Jan 14, 2014
Jan 14, 2014
288
289
290
// autolock state machine
static gboolean tklock_autolock_cb(gpointer aptr);
Mar 18, 2015
Mar 18, 2015
291
292
293
static void tklock_autolock_evaluate(void);
static void tklock_autolock_enable(void);
static void tklock_autolock_disable(void);
Jan 14, 2014
Jan 14, 2014
294
static void tklock_autolock_rethink(void);
May 19, 2015
May 19, 2015
295
296
static void tklock_autolock_init(void);
static void tklock_autolock_quit(void);
Jan 14, 2014
Jan 14, 2014
297
298
299
300
// proximity locking state machine
static gboolean tklock_proxlock_cb(gpointer aptr);
Mar 18, 2015
Mar 18, 2015
301
302
303
304
static void tklock_proxlock_resume(void);
static void tklock_proxlock_evaluate(void);
static void tklock_proxlock_enable(void);
static void tklock_proxlock_disable(void);
Jan 14, 2014
Jan 14, 2014
305
306
static void tklock_proxlock_rethink(void);
Oct 28, 2014
Oct 28, 2014
307
308
// autolock based on device lock changes
Dec 3, 2014
Dec 3, 2014
309
static void tklock_autolock_on_devlock_block(int duration_ms);
Oct 28, 2014
Oct 28, 2014
310
311
312
static void tklock_autolock_on_devlock_prime(void);
static void tklock_autolock_on_devlock_trigger(void);
Jan 14, 2014
Jan 14, 2014
313
314
// ui exception handling state machine
Feb 28, 2018
Feb 28, 2018
315
316
317
318
319
320
321
322
323
324
static uiexception_type_t topmost_active(uiexception_type_t mask);
static void tklock_uiexception_sync_to_datapipe(void);
static gboolean tklock_uiexception_linger_cb(gpointer aptr);
static void tklock_uiexception_begin(uiexception_type_t type, int64_t linger);
static void tklock_uiexception_end(uiexception_type_t type, int64_t linger);
static void tklock_uiexception_cancel(void);
static void tklock_uiexception_finish(void);
static bool tklock_uiexception_deny_state_restore(bool force, const char *cause);
static void tklock_uiexception_rethink(void);
Jan 14, 2014
Jan 14, 2014
325
May 8, 2014
May 8, 2014
326
327
328
329
330
331
332
333
334
335
336
// low power mode ui state machine
static void tklock_lpmui_set_state(bool enable);
static void tklock_lpmui_reset_history(void);
static void tklock_lpmui_update_history(cover_state_t state);
static bool tklock_lpmui_probe_from_pocket(void);
static bool tklock_lpmui_probe_on_table(void);
static bool tklock_lpmui_probe(void);
static void tklock_lpmui_rethink(void);
static void tklock_lpmui_pre_transition_actions(void);
Jan 14, 2014
Jan 14, 2014
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
// legacy hw event input enable/disable state machine
static void tklock_evctrl_set_state(output_state_t *output, bool enable);
static void tklock_evctrl_set_kp_state(bool enable);
static void tklock_evctrl_set_ts_state(bool enable);
static void tklock_evctrl_set_dt_state(bool enable);
static void tklock_evctrl_rethink(void);
// legacy hw double tap calibration
static void tklock_dtcalib_now(void);
static void tklock_dtcalib_from_heartbeat(void);
static gboolean tklock_dtcalib_cb(gpointer data);
static void tklock_dtcalib_start(void);
static void tklock_dtcalib_stop(void);
Mar 31, 2016
Mar 31, 2016
354
// DYNAMIC_SETTINGS
Jan 14, 2014
Jan 14, 2014
355
Mar 31, 2016
Mar 31, 2016
356
357
static void tklock_setting_sanitize_lid_open_actions(void);
static void tklock_setting_sanitize_lid_close_actions(void);
Mar 28, 2019
Mar 28, 2019
358
359
360
361
static void tklock_setting_sanitize_kbd_open_trigger(void);
static void tklock_setting_sanitize_kbd_open_actions(void);
static void tklock_setting_sanitize_kbd_close_trigger(void);
static void tklock_setting_sanitize_kbd_close_actions(void);
Oct 24, 2014
Oct 24, 2014
362
Mar 31, 2016
Mar 31, 2016
363
static void tklock_setting_cb(GConfClient *const gcc, const guint id, GConfEntry *const entry, gpointer const data);
Jan 14, 2014
Jan 14, 2014
364
Mar 31, 2016
Mar 31, 2016
365
366
static void tklock_setting_init(void);
static void tklock_setting_quit(void);
May 12, 2011
May 12, 2011
367
Jan 14, 2014
Jan 14, 2014
368
// sysfs probing
Dec 16, 2010
Dec 16, 2010
369
Jan 14, 2014
Jan 14, 2014
370
static void tklock_sysfs_probe(void);
Dec 16, 2010
Dec 16, 2010
371
Jan 14, 2014
Jan 14, 2014
372
// dbus ipc with systemui
Dec 16, 2010
Dec 16, 2010
373
May 29, 2015
May 29, 2015
374
static void tklock_ui_send_tklock_signal(void);
May 29, 2015
May 29, 2015
375
376
377
378
379
static void tklock_ui_notify_rethink_wakelock(void);
static bool tklock_ui_notify_must_be_delayed(void);
static gboolean tklock_ui_notify_end_cb(gpointer data);
static gboolean tklock_ui_notify_beg_cb(gpointer data);
static void tklock_ui_notify_schdule(void);
Mar 28, 2019
Mar 28, 2019
380
static gboolean tklock_ui_sync_cb(gpointer aptr);
May 29, 2015
May 29, 2015
381
382
static void tklock_ui_notify_cancel(void);
Jan 14, 2014
Jan 14, 2014
383
384
385
static void tklock_ui_eat_event(void);
static void tklock_ui_open(void);
static void tklock_ui_close(void);
Sep 18, 2018
Sep 18, 2018
386
387
static bool tklock_ui_is_enabled(void);
static void tklock_ui_set_enabled(bool enable);
May 12, 2011
May 12, 2011
388
Feb 28, 2018
Feb 28, 2018
389
390
static void tklock_ui_get_devicelock_cb(DBusPendingCall *pc, void *aptr);
static void tklock_ui_get_devicelock(void);
Feb 6, 2014
Feb 6, 2014
391
May 29, 2015
May 29, 2015
392
static void tklock_ui_send_lpm_signal(void);
May 8, 2014
May 8, 2014
393
394
static void tklock_ui_enable_lpm(void);
static void tklock_ui_disable_lpm(void);
Sep 16, 2015
Sep 16, 2015
395
static void tklock_ui_show_device_unlock(void);;
May 8, 2014
May 8, 2014
396
Jan 14, 2014
Jan 14, 2014
397
398
// dbus ipc
Jun 18, 2015
Jun 18, 2015
399
400
401
static void tklock_dbus_send_display_blanking_policy(DBusMessage *const req);
static gboolean tklock_dbus_display_blanking_policy_get_cb(DBusMessage *const msg);
Jan 8, 2015
Jan 8, 2015
402
403
static void tklock_dbus_send_keyboard_slide_state(DBusMessage *const req);
static gboolean tklock_dbus_keyboard_slide_state_get_req_cb(DBusMessage *const msg);
Dec 23, 2014
Dec 23, 2014
404
Jan 8, 2015
Jan 8, 2015
405
406
static void tklock_dbus_send_keyboard_available_state(DBusMessage *const req);
static gboolean tklock_dbus_keyboard_available_state_get_req_cb(DBusMessage *const msg);
Dec 23, 2014
Dec 23, 2014
407
Oct 25, 2021
Oct 25, 2021
408
409
410
static void tklock_dbus_send_mouse_available_state(DBusMessage *const req);
static gboolean tklock_dbus_mouse_available_state_get_req_cb(DBusMessage *const msg);
Jan 14, 2014
Jan 14, 2014
411
412
413
static gboolean tklock_dbus_send_tklock_mode(DBusMessage *const method_call);
static gboolean tklock_dbus_mode_get_req_cb(DBusMessage *const msg);
Mar 28, 2019
Mar 28, 2019
414
415
static tklock_request_t tklock_dbus_sanitize_requested_mode(tklock_request_t state);
Jan 14, 2014
Jan 14, 2014
416
static gboolean tklock_dbus_mode_change_req_cb(DBusMessage *const msg);
Jun 2, 2017
Jun 2, 2017
417
static gboolean tklock_dbus_interaction_expected_cb(DBusMessage *const msg);
Jan 14, 2014
Jan 14, 2014
418
419
static gboolean tklock_dbus_systemui_callback_cb(DBusMessage *const msg);
Feb 28, 2018
Feb 28, 2018
420
static gboolean tklock_dbus_devicelock_changed_cb(DBusMessage *const msg);
Feb 6, 2014
Feb 6, 2014
421
Apr 15, 2014
Apr 15, 2014
422
423
424
static gboolean tklock_dbus_notification_beg_cb(DBusMessage *const msg);
static gboolean tklock_dbus_notification_end_cb(DBusMessage *const msg);
Jan 14, 2014
Jan 14, 2014
425
426
427
static void mce_tklock_init_dbus(void);
static void mce_tklock_quit_dbus(void);
Apr 15, 2014
Apr 15, 2014
428
429
430
431
// NOTIFICATION_SLOTS
static void tklock_notif_slot_init(tklock_notif_slot_t *self);
static void tklock_notif_slot_free(tklock_notif_slot_t *self);
Apr 15, 2014
Apr 15, 2014
432
static void tklock_notif_slot_set(tklock_notif_slot_t *self, const char *owner, const char *name, int64_t until, int64_t renew);
Apr 15, 2014
Apr 15, 2014
433
434
435
436
static bool tklock_notif_slot_is_free(const tklock_notif_slot_t *self);
static bool tklock_notif_slot_has_name(const tklock_notif_slot_t *self, const char *name);
static bool tklock_notif_slot_validate(tklock_notif_slot_t *self, int64_t now);
static bool tklock_notif_slot_renew(tklock_notif_slot_t *self, int64_t now);
Apr 15, 2014
Apr 15, 2014
437
438
static bool tklock_notif_slot_has_owner(const tklock_notif_slot_t *self, const char *owner);
static gchar *tklock_notif_slot_steal_owner(tklock_notif_slot_t *self);
Apr 15, 2014
Apr 15, 2014
439
440
441
442
443
444
445
446
447
448
// NOTIFICATION_API
static void tklock_notif_init(void);
static void tklock_notif_quit(void);
static gboolean tklock_notif_autostop_cb(gpointer aptr);
static void tklock_notif_cancel_autostop(void);
static void tklock_notif_schedule_autostop(gint delay);
static void tklock_notif_update_state(void);
static void tklock_notif_extend_by_renew(void);
Apr 15, 2014
Apr 15, 2014
449
450
451
452
453
454
455
456
static void tklock_notif_vacate_slot(const char *owner, const char *name, int64_t linger);
static void tklock_notif_reserve_slot(const char *owner, const char *name, int64_t length, int64_t renew);
static void tklock_notif_vacate_slots_from(const char *owner);
static size_t tklock_notif_count_slots_from(const char *owner);
static gboolean tklock_notif_owner_dropped_cb(DBusMessage *const msg);
static void tklock_notif_add_owner_monitor(const char *owner);
static void tklock_notif_remove_owner_monitor(const char *owner);
Apr 15, 2014
Apr 15, 2014
457
Apr 15, 2014
Apr 15, 2014
458
459
static void mce_tklock_begin_notification(const char *owner, const char *name, int64_t length, int64_t renew);
static void mce_tklock_end_notification(const char *owner, const char *name, int64_t linger);
Apr 15, 2014
Apr 15, 2014
460
Jan 14, 2014
Jan 14, 2014
461
462
463
// "module" load/unload
extern gboolean mce_tklock_init(void);
extern void mce_tklock_exit(void);
Sep 30, 2015
Sep 30, 2015
464
extern void mce_tklock_unblank(display_state_t to_state);
Jan 14, 2014
Jan 14, 2014
465
466
/* ========================================================================= *
Mar 31, 2016
Mar 31, 2016
467
* DYNAMIC_SETTINGS
Jan 14, 2014
Jan 14, 2014
468
469
* ========================================================================= */
Mar 15, 2015
Mar 15, 2015
470
/** Flag: Devicelock is handled in lockscreen */
Mar 31, 2016
Mar 31, 2016
471
static gboolean tklock_devicelock_in_lockscreen = MCE_DEFAULT_TK_DEVICELOCK_IN_LOCKSCREEN;
Mar 31, 2016
Mar 31, 2016
472
static guint tklock_devicelock_in_lockscreen_setting_id = 0;
Mar 15, 2015
Mar 15, 2015
473
Sep 16, 2015
Sep 16, 2015
474
475
476
/** Flag: Convert denied tklock removal attempt to: show device unlock view */
static bool tklock_devicelock_want_to_unlock = false;
Jan 14, 2014
Jan 14, 2014
477
/** Flag: Automatically lock (after ON->DIM->OFF cycle) */
Mar 31, 2016
Mar 31, 2016
478
static gboolean tk_autolock_enabled = MCE_DEFAULT_TK_AUTOLOCK_ENABLED;
Mar 31, 2016
Mar 31, 2016
479
static guint tk_autolock_enabled_setting_id = 0;
Jan 14, 2014
Jan 14, 2014
480
Aug 19, 2015
Aug 19, 2015
481
/** Flag: Grabbing input devices is allowed */
Mar 31, 2016
Mar 31, 2016
482
static gboolean tk_input_policy_enabled = MCE_DEFAULT_TK_INPUT_POLICY_ENABLED;
Mar 31, 2016
Mar 31, 2016
483
static guint tk_input_policy_enabled_setting_id = 0;
Aug 19, 2015
Aug 19, 2015
484
Mar 16, 2015
Mar 16, 2015
485
/** Delay for automatick locking (after ON->DIM->OFF cycle) */
Mar 31, 2016
Mar 31, 2016
486
static gint tklock_autolock_delay = MCE_DEFAULT_TK_AUTOLOCK_DELAY;
Mar 31, 2016
Mar 31, 2016
487
static guint tklock_autolock_delay_setting_id = 0;
Mar 16, 2015
Mar 16, 2015
488
Jan 30, 2015
Jan 30, 2015
489
/** Flag: Proximity sensor can block touch input */
Mar 31, 2016
Mar 31, 2016
490
static gboolean proximity_blocks_touch = MCE_DEFAULT_TK_PROXIMITY_BLOCKS_TOUCH;
Mar 31, 2016
Mar 31, 2016
491
static guint proximity_blocks_touch_setting_id = 0;
Jan 30, 2015
Jan 30, 2015
492
Sep 30, 2015
Sep 30, 2015
493
/** Volume key input policy */
Mar 31, 2016
Mar 31, 2016
494
static gint volkey_policy = MCE_DEFAULT_TK_VOLKEY_POLICY;
Mar 31, 2016
Mar 31, 2016
495
static guint volkey_policy_setting_id = 0;
Sep 30, 2015
Sep 30, 2015
496
Mar 7, 2016
Mar 7, 2016
497
/** Touchscreen gesture (doubletap etc) enable mode */
Mar 31, 2016
Mar 31, 2016
498
static gint touchscreen_gesture_enable_mode = MCE_DEFAULT_DOUBLETAP_MODE;
Mar 31, 2016
Mar 31, 2016
499
static guint touchscreen_gesture_enable_mode_setting_id = 0;
Mar 11, 2014
Mar 11, 2014
500
Aug 5, 2015
Aug 5, 2015
501
/** Lid sensor open actions */
Mar 31, 2016
Mar 31, 2016
502
503
static gint tklock_lid_open_actions = MCE_DEFAULT_TK_LID_OPEN_ACTIONS;
static guint tklock_lid_open_actions_setting_id = 0;
Aug 5, 2015
Aug 5, 2015
504
505
/** Lid sensor close actions */
Mar 31, 2016
Mar 31, 2016
506
507
static gint tklock_lid_close_actions = MCE_DEFAULT_TK_LID_CLOSE_ACTIONS;
static guint tklock_lid_close_actions_setting_id = 0;
Aug 5, 2015
Aug 5, 2015
508
Apr 24, 2015
Apr 24, 2015
509
/** Flag: Is the lid sensor used for display blanking */
Mar 31, 2016
Mar 31, 2016
510
static gboolean lid_sensor_enabled = MCE_DEFAULT_TK_LID_SENSOR_ENABLED;
Mar 31, 2016
Mar 31, 2016
511
static guint lid_sensor_enabled_setting_id = 0;
Apr 24, 2015
Apr 24, 2015
512
Sep 25, 2015
Sep 25, 2015
513
/** When to react to keyboard open */
Mar 31, 2016
Mar 31, 2016
514
515
static gint tklock_kbd_open_trigger = MCE_DEFAULT_TK_KBD_OPEN_TRIGGER;
static guint tklock_kbd_open_trigger_setting_id = 0;
Sep 25, 2015
Sep 25, 2015
516
517
/** How to react to keyboard open */
Mar 31, 2016
Mar 31, 2016
518
519
static gint tklock_kbd_open_actions = MCE_DEFAULT_TK_KBD_OPEN_ACTIONS;
static guint tklock_kbd_open_actions_setting_id = 0;
Sep 25, 2015
Sep 25, 2015
520
521
/** When to react to keyboard close */
Mar 31, 2016
Mar 31, 2016
522
523
static gint tklock_kbd_close_trigger = MCE_DEFAULT_TK_KBD_CLOSE_TRIGGER;
static guint tklock_kbd_close_trigger_setting_id = 0;
Sep 25, 2015
Sep 25, 2015
524
525
/** How to react to keyboard close */
Mar 31, 2016
Mar 31, 2016
526
527
static gint tklock_kbd_close_actions = MCE_DEFAULT_TK_KBD_CLOSE_ACTIONS;
static guint tklock_kbd_close_actions_setting_id = 0;
Sep 25, 2015
Sep 25, 2015
528
Jun 16, 2015
Jun 16, 2015
529
/** Flag for: Using ALS is allowed */
Mar 31, 2016
Mar 31, 2016
530
static gboolean als_enabled = MCE_DEFAULT_DISPLAY_ALS_ENABLED;
Mar 31, 2016
Mar 31, 2016
531
static guint als_enabled_setting_id = 0;
Jun 16, 2015
Jun 16, 2015
532
533
/** Flag: Use ALS for lid close filtering */
Mar 31, 2016
Mar 31, 2016
534
static gboolean filter_lid_with_als = MCE_DEFAULT_TK_FILTER_LID_WITH_ALS;
Mar 31, 2016
Mar 31, 2016
535
static guint filter_lid_with_als_setting_id = 0;
Jun 16, 2015
Jun 16, 2015
536
Nov 11, 2015
Nov 11, 2015
537
/** Maximum amount of light ALS should report when LID is closed */
Mar 31, 2016
Mar 31, 2016
538
539
static gint filter_lid_als_limit = MCE_DEFAULT_TK_FILTER_LID_ALS_LIMIT;
static guint filter_lid_als_limit_setting_id = 0;
Nov 11, 2015
Nov 11, 2015
540
May 12, 2015
May 12, 2015
541
/** How long to keep display on after incoming call ends [ms] */
Mar 31, 2016
Mar 31, 2016
542
543
static gint exception_length_call_in = MCE_DEFAULT_TK_EXCEPT_LEN_CALL_IN;
static guint exception_length_call_in_setting_id = 0;
May 12, 2015
May 12, 2015
544
545
/** How long to keep display on after outgoing call ends [ms] */
Mar 31, 2016
Mar 31, 2016
546
547
static gint exception_length_call_out = MCE_DEFAULT_TK_EXCEPT_LEN_CALL_OUT;
static guint exception_length_call_out_setting_id = 0;
May 12, 2015
May 12, 2015
548
549
/** How long to keep display on after alarm is handled [ms] */
Mar 31, 2016
Mar 31, 2016
550
551
static gint exception_length_alarm = MCE_DEFAULT_TK_EXCEPT_LEN_ALARM;
static guint exception_length_alarm_setting_id = 0;
May 12, 2015
May 12, 2015
552
553
/** How long to keep display on when usb cable is connected [ms] */
Mar 31, 2016
Mar 31, 2016
554
555
static gint exception_length_usb_connect = MCE_DEFAULT_TK_EXCEPT_LEN_USB_CONNECT;
static guint exception_length_usb_connect_setting_id = 0;
May 12, 2015
May 12, 2015
556
557
/** How long to keep display on when usb mode dialog is shown [ms] */
Mar 31, 2016
Mar 31, 2016
558
559
static gint exception_length_usb_dialog = MCE_DEFAULT_TK_EXCEPT_LEN_USB_DIALOG;
static guint exception_length_usb_dialog_setting_id = 0;
May 12, 2015
May 12, 2015
560
561
/** How long to keep display on when charging starts [ms] */
Mar 31, 2016
Mar 31, 2016
562
563
static gint exception_length_charger = MCE_DEFAULT_TK_EXCEPT_LEN_CHARGER;
static guint exception_length_charger_setting_id = 0;
May 12, 2015
May 12, 2015
564
565
/** How long to keep display on after battery full [ms] */
Mar 31, 2016
Mar 31, 2016
566
567
static gint exception_length_battery = MCE_DEFAULT_TK_EXCEPT_LEN_BATTERY;
static guint exception_length_battery_setting_id = 0;
May 12, 2015
May 12, 2015
568
569
/** How long to keep display on when audio jack is inserted [ms] */
Mar 31, 2016
Mar 31, 2016
570
571
static gint exception_length_jack_in = MCE_DEFAULT_TK_EXCEPT_LEN_JACK_IN;
static guint exception_length_jack_in_setting_id = 0;
May 12, 2015
May 12, 2015
572
573
/** How long to keep display on when audio jack is removed [ms] */
Mar 31, 2016
Mar 31, 2016
574
575
static gint exception_length_jack_out = MCE_DEFAULT_TK_EXCEPT_LEN_JACK_OUT;
static guint exception_length_jack_out_setting_id = 0;
May 12, 2015
May 12, 2015
576
577
/** How long to keep display on when camera button is pressed [ms] */
Mar 31, 2016
Mar 31, 2016
578
579
static gint exception_length_camera = MCE_DEFAULT_TK_EXCEPT_LEN_CAMERA;
static guint exception_length_camera_setting_id = 0;
May 12, 2015
May 12, 2015
580
581
/** How long to keep display on when volume button is pressed [ms] */
Mar 31, 2016
Mar 31, 2016
582
583
static gint exception_length_volume = MCE_DEFAULT_TK_EXCEPT_LEN_VOLUME;
static guint exception_length_volume_setting_id = 0;
May 12, 2015
May 12, 2015
584
585
/** How long to extend display on when there is user activity [ms] */
Mar 31, 2016
Mar 31, 2016
586
587
static gint exception_length_activity = MCE_DEFAULT_TK_EXCEPT_LEN_ACTIVITY;
static guint exception_length_activity_setting_id = 0;
May 12, 2015
May 12, 2015
588
Sep 30, 2015
Sep 30, 2015
589
/** Flag for: Allow lockscreen animation during unblanking */
Mar 31, 2016
Mar 31, 2016
590
static gboolean lockscreen_anim_enabled = MCE_DEFAULT_TK_LOCKSCREEN_ANIM_ENABLED;
Mar 31, 2016
Mar 31, 2016
591
static guint lockscreen_anim_enabled_setting_id = 0;
Sep 30, 2015
Sep 30, 2015
592
Feb 23, 2018
Feb 23, 2018
593
594
595
596
597
598
599
600
/** Default delay for delaying proximity uncovered handling [ms] */
static gint tklock_proximity_delay_default = MCE_DEFAULT_TK_PROXIMITY_DELAY_DEFAULT;
static guint tklock_proximity_delay_default_setting_id = 0;
/** Delay for delaying proximity uncovered handling during calls [ms] */
static gint tklock_proximity_delay_incall = MCE_DEFAULT_TK_PROXIMITY_DELAY_INCALL;
static guint tklock_proximity_delay_incall_setting_id = 0;
Jan 14, 2014
Jan 14, 2014
601
602
603
604
/* ========================================================================= *
* probed control file paths
* ========================================================================= */
Dec 16, 2010
Dec 16, 2010
605
/** SysFS path to touchscreen event disable */
Nov 15, 2012
Nov 15, 2012
606
607
static output_state_t mce_touchscreen_sysfs_disable_output =
{
May 13, 2014
May 13, 2014
608
609
610
.context = "touchscreen_disable",
.truncate_file = TRUE,
.close_on_exit = TRUE,
Nov 15, 2012
Nov 15, 2012
611
};
Dec 16, 2010
Dec 16, 2010
612
May 12, 2011
May 12, 2011
613
/** SysFS path to touchscreen double-tap gesture control */
Mar 7, 2016
Mar 7, 2016
614
static const gchar *mce_touchscreen_gesture_enable_path = NULL;
May 12, 2011
May 12, 2011
615
Nov 21, 2011
Nov 21, 2011
616
617
618
/** SysFS path to touchscreen recalibration control */
static const gchar *mce_touchscreen_calibration_control_path = NULL;
Dec 16, 2010
Dec 16, 2010
619
/** SysFS path to keypad event disable */
Nov 15, 2012
Nov 15, 2012
620
621
static output_state_t mce_keypad_sysfs_disable_output =
{
May 13, 2014
May 13, 2014
622
623
624
.context = "keypad_disable",
.truncate_file = TRUE,
.close_on_exit = TRUE,
Nov 15, 2012
Nov 15, 2012
625
};
Dec 16, 2010
Dec 16, 2010
626
Jan 14, 2014
Jan 14, 2014
627
628
629
/* ========================================================================= *
* DATAPIPE VALUES AND TRIGGERS
* ========================================================================= */
Dec 16, 2010
Dec 16, 2010
630
Mar 28, 2019
Mar 28, 2019
631
632
633
634
635
636
/** Cached submode_pipe state; assume invalid */
static submode_t submode = MCE_SUBMODE_INVALID;
/** Cached PID of process owning the topmost window on UI */
static int topmost_window_pid = -1;
Mar 21, 2018
Mar 21, 2018
637
638
639
/** Cached init_done state; assume unknown */
static tristate_t init_done = TRISTATE_UNKNOWN;
May 8, 2014
May 8, 2014
640
641
642
/** Proximity state history for triggering low power mode ui */
static ps_history_t tklock_lpmui_hist[8];
Sep 18, 2018
Sep 18, 2018
643
644
645
646
647
/** Current tklock ui state
*
* Access only via tklock_ui_is_enabled() / tklock_ui_set_enabled().
*/
static bool tklock_ui_enabled_pvt = false;
Dec 16, 2010
Dec 16, 2010
648
Jan 14, 2014
Jan 14, 2014
649
/** Current tklock ui state that has been sent to lipstick */
Oct 28, 2014
Oct 28, 2014
650
static int tklock_ui_notified = -1; // does not match bool values
Dec 16, 2010
Dec 16, 2010
651
Jan 16, 2014
Jan 16, 2014
652
/** System state; is undefined at bootup, can't assume anything */
Feb 28, 2018
Feb 28, 2018
653
static system_state_t system_state = MCE_SYSTEM_STATE_UNDEF;
Aug 11, 2011
Aug 11, 2011
654
Aug 15, 2018
Aug 15, 2018
655
656
657
658
659
660
/** Display state; undefined initially, can't assume anything */
static display_state_t display_state_curr = MCE_DISPLAY_UNDEF;
/** Next Display state; undefined initially, can't assume anything */
static display_state_t display_state_next = MCE_DISPLAY_UNDEF;
Sep 18, 2018
Sep 18, 2018
661
662
663
664
/** Call state; assume no active calls */
static call_state_t call_state = CALL_STATE_NONE;
/** Actual proximity state; assume not covered */
Mar 15, 2019
Mar 15, 2019
665
static cover_state_t proximity_sensor_actual = COVER_UNDEF;
Sep 18, 2018
Sep 18, 2018
666
667
/** Effective proximity state; assume not covered */
Mar 15, 2019
Mar 15, 2019
668
static cover_state_t proximity_sensor_effective = COVER_UNDEF;
Sep 18, 2018
Sep 18, 2018
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
/** Lid cover sensor state; assume unkown
*
* When in covered state, it is assumed that it is not physically
* possible to see/interact with the display and thus it should
* stay powered off.
*
* Originally was used to track Nokia N770 slidable cover. Now
* it is used also for things like the hammerhead magnetic lid
* sensor.
*/
static cover_state_t lid_sensor_actual = COVER_UNDEF;
/** Lid cover policy state; assume unknown */
static cover_state_t lid_sensor_filtered = COVER_UNDEF;
Jan 14, 2014
Jan 14, 2014
685
/** Change notifications for system_state
Dec 16, 2010
Dec 16, 2010
686
*/
Jan 14, 2014
Jan 14, 2014
687
static void tklock_datapipe_system_state_cb(gconstpointer data)
Dec 16, 2010
Dec 16, 2010
688
{
Jan 14, 2014
Jan 14, 2014
689
690
system_state_t prev = system_state;
system_state = GPOINTER_TO_INT(data);
Dec 16, 2010
Dec 16, 2010
691
Jan 14, 2014
Jan 14, 2014
692
693
if( prev == system_state )
goto EXIT;
Dec 16, 2010
Dec 16, 2010
694
Mar 1, 2018
Mar 1, 2018
695
696
697
mce_log(LL_DEBUG, "system_state: %s -> %s",
system_state_repr(prev),
system_state_repr(system_state));
Jan 16, 2014
Jan 16, 2014
698
Sep 18, 2018
Sep 18, 2018
699
tklock_ui_set_enabled(false);
Jan 14, 2014
Jan 14, 2014
700
701
702
EXIT:
return;
May 25, 2011
May 25, 2011
703
704
}
Dec 3, 2014
Dec 3, 2014
705
/** Device lock state; assume undefined */
Feb 28, 2018
Feb 28, 2018
706
static devicelock_state_t devicelock_state = DEVICELOCK_STATE_UNDEFINED;
Feb 6, 2014
Feb 6, 2014
707
Feb 28, 2018
Feb 28, 2018
708
/** Push device lock state value into devicelock_state_pipe datapipe
Feb 6, 2014
Feb 6, 2014
709
*/
Feb 28, 2018
Feb 28, 2018
710
static void tklock_datapipe_set_devicelock_state(devicelock_state_t state)
Feb 6, 2014
Feb 6, 2014
711
{
Oct 31, 2014
Oct 31, 2014
712
switch( state ) {
Feb 28, 2018
Feb 28, 2018
713
714
715
case DEVICELOCK_STATE_UNLOCKED:
case DEVICELOCK_STATE_UNDEFINED:
case DEVICELOCK_STATE_LOCKED:
Oct 31, 2014
Oct 31, 2014
716
717
718
719
720
break;
default:
mce_log(LL_WARN, "unknown device lock state=%d; assuming locked",
state);
Feb 28, 2018
Feb 28, 2018
721
state = DEVICELOCK_STATE_LOCKED;
Oct 31, 2014
Oct 31, 2014
722
723
break;
}
Feb 6, 2014
Feb 6, 2014
724
Feb 28, 2018
Feb 28, 2018
725
726
if( devicelock_state != state ) {
datapipe_exec_full(&devicelock_state_pipe,
Sep 19, 2018
Sep 19, 2018
727
GINT_TO_POINTER(state));
Feb 6, 2014
Feb 6, 2014
728
729
730
}
}
Feb 28, 2018
Feb 28, 2018
731
/** Change notifications for devicelock_state
Feb 6, 2014
Feb 6, 2014
732
*/
Feb 28, 2018
Feb 28, 2018
733
static void tklock_datapipe_devicelock_state_cb(gconstpointer data)
Feb 6, 2014
Feb 6, 2014
734
{
Feb 28, 2018
Feb 28, 2018
735
736
devicelock_state_t prev = devicelock_state;
devicelock_state = GPOINTER_TO_INT(data);
Feb 6, 2014
Feb 6, 2014
737
Feb 28, 2018
Feb 28, 2018
738
if( devicelock_state == prev )
Feb 6, 2014
Feb 6, 2014
739
740
goto EXIT;
Feb 28, 2018
Feb 28, 2018
741
742
743
mce_log(LL_DEVEL, "devicelock_state = %s -> %s",
devicelock_state_repr(prev),
devicelock_state_repr(devicelock_state));
Feb 6, 2014
Feb 6, 2014
744
Feb 28, 2018
Feb 28, 2018
745
tklock_uiexception_rethink();
Sep 17, 2014
Sep 17, 2014
746
Feb 7, 2014
Feb 7, 2014
747
748
tklock_autolock_rethink();
Dec 3, 2014
Dec 3, 2014
749
750
751
752
753
/* When lipstick is starting up we see device lock
* going through undefined -> locked/unlocked change.
* We must not trigger autolock due to these initial
* device lock transitions */
switch( prev ) {
Feb 28, 2018
Feb 28, 2018
754
case DEVICELOCK_STATE_UNDEFINED:
Dec 3, 2014
Dec 3, 2014
755
756
757
758
759
/* Block autolock for 60 seconds when leaving
* undefined state (= lipstick startup) */
tklock_autolock_on_devlock_block(60 * 1000);
break;
Feb 28, 2018
Feb 28, 2018
760
case DEVICELOCK_STATE_LOCKED:
Dec 3, 2014
Dec 3, 2014
761
762
763
764
765
766
767
768
769
/* Unblock autolock earlier if we see transition
* away from locked state (=unlocked by user) */
tklock_autolock_on_devlock_block(0);
break;
default:
break;
}
Aug 15, 2018
Aug 15, 2018
770
771
switch( devicelock_state ) {
case DEVICELOCK_STATE_LOCKED:
Oct 28, 2014
Oct 28, 2014
772
tklock_autolock_on_devlock_trigger();
Aug 15, 2018
Aug 15, 2018
773
774
break;
case DEVICELOCK_STATE_UNLOCKED:
Sep 18, 2018
Sep 18, 2018
775
776
777
778
779
780
781
782
783
784
785
switch( display_state_next ) {
case MCE_DISPLAY_OFF:
case MCE_DISPLAY_LPM_OFF:
case MCE_DISPLAY_LPM_ON:
/* Transitions from undefined -> unlocked state occur
* during device bootup / mce restart and should not
* cause any actions.
*/
if( prev == DEVICELOCK_STATE_UNDEFINED )
break;
Aug 15, 2018
Aug 15, 2018
786
787
788
789
/* Devicelock ui keeps fingerprint scanner active in LPM state
* and unlocks device on identify, but omits unlock feedback
* and leaves the display state as-is.
*
Sep 18, 2018
Sep 18, 2018
790
791
792
793
794
795
796
797
798
* As a workaround, execute unlock feedback from mce. Then
* exit from LPM by requesting display power up and removal
* of tklock submode.
*
* While this is mostly relevant to LPM, apply the same logic
* also when in actually powered off display states to guard
* against timing glitches (getting fingerprint identification
* when already decided to exit LPM, etc) and changes in device
* lock ui side logic.
Aug 15, 2018
Aug 15, 2018
799
*/
Sep 18, 2018
Sep 18, 2018
800
801
mce_log(LL_WARN, "device got unlocked while display is off; "
"assume fingerprint authentication occurred");
Sep 19, 2018
Sep 19, 2018
802
803
datapipe_exec_full(&ngfd_event_request_pipe,
"unlock_device");
Sep 18, 2018
Sep 18, 2018
804
Mar 15, 2019
Mar 15, 2019
805
806
807
808
809
/* Delay display state / tklock processing until proximity
* sensor state is known */
common_on_proximity_schedule(MODULE_NAME,
tklock_datapipe_devicelock_state_cb2,
0);
Sep 18, 2018
Sep 18, 2018
810
811
812
break;
default:
break;
Aug 15, 2018
Aug 15, 2018
813
814
815
816
817
}
break;
default:
break;
}
Oct 28, 2014
Oct 28, 2014
818
Feb 6, 2014
Feb 6, 2014
819
820
821
822
EXIT:
return;
}
Mar 15, 2019
Mar 15, 2019
823
/** Wait for proximity sensor -callback for fingerprint unlock handling
Mar 15, 2019
Mar 15, 2019
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
*
* @param aptr unused
*/
static void tklock_datapipe_devicelock_state_cb2(gpointer aptr)
{
(void)aptr;
/* Still unlocked ? */
if( devicelock_state == DEVICELOCK_STATE_UNLOCKED ) {
if( proximity_sensor_actual != COVER_OPEN ) {
mce_log(LL_WARN, "unblank skipped due to proximity sensor");
}
else {
mce_datapipe_request_display_state(MCE_DISPLAY_ON);
mce_datapipe_request_tklock(TKLOCK_REQUEST_OFF);
}
}
}
Oct 28, 2014
Oct 28, 2014
844
/** Resumed from suspend notification */
Feb 28, 2018
Feb 28, 2018
845
static void tklock_datapipe_resume_detected_event_cb(gconstpointer data)
Oct 28, 2014
Oct 28, 2014
846
{
Mar 18, 2015
Mar 18, 2015
847
848
(void) data;
May 19, 2015
May 19, 2015
849
850
/* Re-evaluate proximity locking after resuming from
* suspend. */
Mar 18, 2015
Mar 18, 2015
851
tklock_proxlock_resume();
Oct 28, 2014
Oct 28, 2014
852
853
}
Apr 20, 2017
Apr 20, 2017
854
/** devicelock dbus name is reserved; assume unknown */
Feb 28, 2018
Feb 28, 2018
855
static service_state_t devicelock_service_state = SERVICE_STATE_UNDEF;
Apr 20, 2017
Apr 20, 2017
856
Feb 28, 2018
Feb 28, 2018
857
/** Change notifications for devicelock_service_state
Apr 20, 2017
Apr 20, 2017
858
*/
Feb 28, 2018
Feb 28, 2018
859
static void tklock_datapipe_devicelock_service_state_cb(gconstpointer data)
Apr 20, 2017
Apr 20, 2017
860
{
Feb 28, 2018
Feb 28, 2018
861
862
service_state_t prev = devicelock_service_state;
devicelock_service_state = GPOINTER_TO_INT(data);
Apr 20, 2017
Apr 20, 2017
863
Feb 28, 2018
Feb 28, 2018
864
if( devicelock_service_state == prev )
Apr 20, 2017
Apr 20, 2017
865
866
goto EXIT;
Feb 28, 2018
Feb 28, 2018
867
mce_log(LL_DEBUG, "devicelock_service_state = %s -> %s",
Apr 20, 2017
Apr 20, 2017
868
service_state_repr(prev),
Feb 28, 2018
Feb 28, 2018
869
service_state_repr(devicelock_service_state));
Apr 20, 2017
Apr 20, 2017
870
Feb 28, 2018
Feb 28, 2018
871
if( devicelock_service_state == SERVICE_STATE_RUNNING ) {
Apr 20, 2017
Apr 20, 2017
872
/* query initial device lock state on devicelock/mce startup */
Feb 28, 2018
Feb 28, 2018
873
tklock_ui_get_devicelock();
Apr 20, 2017
Apr 20, 2017
874
875
876
877
}
else {
/* if device lock service is not running, the device lock
* state is undefined */
Feb 28, 2018
Feb 28, 2018
878
tklock_datapipe_set_devicelock_state(DEVICELOCK_STATE_UNDEFINED);
Apr 20, 2017
Apr 20, 2017
879
880
881
882
883
884
}
EXIT:
return;
}
Jan 16, 2014
Jan 16, 2014
885
/** Lipstick dbus name is reserved; assume false */
Feb 28, 2018
Feb 28, 2018
886
static service_state_t lipstick_service_state = SERVICE_STATE_UNDEF;
Jan 14, 2014
Jan 14, 2014
887
Feb 28, 2018
Feb 28, 2018
888
/** Change notifications for lipstick_service_state
Nov 22, 2011
Nov 22, 2011
889
*/
Feb 28, 2018
Feb 28, 2018
890
static void tklock_datapipe_lipstick_service_state_cb(gconstpointer data)
Nov 22, 2011
Nov 22, 2011
891
{
Feb 28, 2018
Feb 28, 2018
892
893
service_state_t prev = lipstick_service_state;
lipstick_service_state = GPOINTER_TO_INT(data);
Jan 16, 2014
Jan 16, 2014
894
Feb 28, 2018
Feb 28, 2018
895
if( lipstick_service_state == prev )
Jan 16, 2014
Jan 16, 2014
896
897
goto EXIT;
Feb 28, 2018
Feb 28, 2018
898
mce_log(LL_DEBUG, "lipstick_service_state = %s -> %s",
Jan 23, 2015
Jan 23, 2015
899
service_state_repr(prev),
Feb 28, 2018
Feb 28, 2018
900
service_state_repr(lipstick_service_state));
Nov 22, 2011
Nov 22, 2011
901
Mar 8, 2019
Mar 8, 2019
902
903
904
905
bool enable_tklock = false;
/* Tklock is applicable only when lipstick is running */
if( lipstick_service_state == SERVICE_STATE_RUNNING ) {
Mar 2, 2023
Mar 2, 2023
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
if( prev == SERVICE_STATE_UNDEF ) {
/* UNDEF -> RUNNING: Implies a mce restart while lipstick
* is running. What we would like to happen is that things
* stay exactly as they were. However there is no passive
* way to recover lockscreen state from lipstick and we
* have to do something active in order to get tklock
* state in sync between mce and lipstick.
*
* If display is in powered on state, request lockscreen
* deactivation. If device happens to be locked, this is
* transformed into show-unlock-screen request.
*
* Otherwise activate lockscreen.
*/
if( display_state_next != MCE_DISPLAY_ON )
enable_tklock = true;
}
else {
/* STOPPED -> RUNNING: Implies lipstick start during
* bootup / restart later on. In this case lockscreen
* status is decided by lipstick and it defaults to having
* lockscreen active and changes are not really accepted
* until lipstick startup has finished. Making a lockscreen
* activation request merely serves as a way to ensure that
* mce and lipstick get in sync about tklock state.
*/
Mar 8, 2019
Mar 8, 2019
932
enable_tklock = true;
Mar 2, 2023
Mar 2, 2023
933
}
Mar 8, 2019
Mar 8, 2019
934
935
}
Jan 14, 2014
Jan 14, 2014
936
// force tklock ipc
Oct 28, 2014
Oct 28, 2014
937
tklock_ui_notified = -1;
Mar 8, 2019
Mar 8, 2019
938
tklock_ui_set_enabled(enable_tklock);
Jan 16, 2014
Jan 16, 2014
939
940
941
EXIT:
return;
Nov 22, 2011
Nov 22, 2011
942
943
}
Jun 12, 2014
Jun 12, 2014
944
/** Update mode is active; assume false */
Feb 28, 2018
Feb 28, 2018
945
static bool osupdate_running = false;
Jun 12, 2014
Jun 12, 2014
946
Feb 28, 2018
Feb 28, 2018
947
/** Change notifications for osupdate_running
Jun 12, 2014
Jun 12, 2014
948
*/
Feb 28, 2018
Feb 28, 2018
949
static void tklock_datapipe_osupdate_running_cb(gconstpointer data)
Jun 12, 2014
Jun 12, 2014
950
{
Feb 28, 2018
Feb 28, 2018
951
952
bool prev = osupdate_running;
osupdate_running = GPOINTER_TO_INT(data);
Jun 12, 2014
Jun 12, 2014
953
Feb 28, 2018
Feb 28, 2018
954
if( osupdate_running == prev )
Jun 12, 2014
Jun 12, 2014
955
956
goto EXIT;
Feb 28, 2018
Feb 28, 2018
957
mce_log(LL_DEBUG, "osupdate_running = %d -> %d", prev, osupdate_running);
Jun 12, 2014
Jun 12, 2014
958
Feb 28, 2018
Feb 28, 2018
959
if( osupdate_running ) {
Jun 12, 2014
Jun 12, 2014
960
/* undo tklock when update mode starts */
Mar 15, 2018
Mar 15, 2018
961
mce_datapipe_request_tklock(TKLOCK_REQUEST_OFF);
Jun 12, 2014
Jun 12, 2014
962
963
964
965
966
967
}
EXIT:
return;
}
May 13, 2015
May 13, 2015
968
969
970
971
972
973
974
975
976
977
978
979
980
/** Device is shutting down; assume false */
static bool shutting_down = false;
/** Change notifications for shutting_down
*/
static void tklock_datapipe_shutting_down_cb(gconstpointer data)
{
bool prev = shutting_down;
shutting_down = GPOINTER_TO_INT(data);
if( shutting_down == prev )
goto EXIT;
Feb 28, 2018
Feb 28, 2018
981
982
mce_log(LL_DEBUG, "shutting_down = %d -> %d",
prev, shutting_down);
May 13, 2015
May 13, 2015
983
984
985
986
987
988
989
tklock_evctrl_rethink();
EXIT:
return;
}
Dec 12, 2014
Dec 12, 2014
990
991
992
/** Autorelock trigger: assume disabled */
static autorelock_t autorelock_trigger = AUTORELOCK_NO_TRIGGERS;
Feb 28, 2018
Feb 28, 2018
993
/** Change notifications for display_state_curr
Nov 21, 2011
Nov 21, 2011
994
*/
Feb 28, 2018
Feb 28, 2018
995
static void tklock_datapipe_display_state_curr_cb(gconstpointer data)
Nov 21, 2011
Nov 21, 2011
996
{
Feb 28, 2018
Feb 28, 2018
997
998
display_state_t prev = display_state_curr;
display_state_curr = GPOINTER_TO_INT(data);
Nov 21, 2011
Nov 21, 2011
999
Feb 28, 2018
Feb 28, 2018
1000
if( display_state_curr == prev )