Skip to content

Commit

Permalink
[tklock] Add setting to disable input device grabbing. Fixes MER#1250
Browse files Browse the repository at this point in the history
There have been issues with unresponsive touch screen in various porting
projects. It is difficult to tell whether problems occur because

a) mce is denying touch events from reaching ui, or
b) ui side does not process touch events as expected

To ease debugging of such issues, add a setting that can be used to
control whether mce is allowed to grab input devices or not.

The setting is enabled by default and can be changed with:

  mcetool --set-input-policy-mode=<enabled|disabled>

The value of the setting persists over mce / device restarts.
  • Loading branch information
spiiroin committed Aug 19, 2015
1 parent 01706a1 commit ccc324d
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
5 changes: 5 additions & 0 deletions builtin-gconf.c
Expand Up @@ -1225,6 +1225,11 @@ static const setting_t gconf_defaults[] =
.type = "b",
.def = "true",
},
{
.key = MCE_GCONF_TK_INPUT_POLICY_ENABLED,
.type = "b",
.def = G_STRINGIFY(DEFAULT_TK_INPUT_POLICY_ENABLED),
},
{
// MCE_GCONF_TK_DOUBLE_TAP_GESTURE_PATH @ tklock.h
.key = "/system/osso/dsm/locks/tklock_double_tap_gesture",
Expand Down
30 changes: 30 additions & 0 deletions tklock.c
Expand Up @@ -377,6 +377,11 @@ static gboolean tk_autolock_enabled = DEFAULT_TK_AUTOLOCK;
/** GConf callback ID for tk_autolock_enabled */
static guint tk_autolock_enabled_cb_id = 0;

/** Flag: Grabbing input devices is allowed */
static gboolean tk_input_policy_enabled = DEFAULT_TK_INPUT_POLICY_ENABLED;
/** GConf callback ID for tk_input_policy_enabled */
static guint tk_input_policy_enabled_cb_id = 0;

/** Delay for automatick locking (after ON->DIM->OFF cycle) */
static gint tklock_autolock_delay = DEFAULT_AUTOLOCK_DELAY;
/** GConf notifier id for tklock_autolock_delay */
Expand Down Expand Up @@ -3845,6 +3850,9 @@ static void tklock_evctrl_rethink(void)
break;
}

if( !tk_input_policy_enabled )
grab_ts = false;

/* Grabbing touch input is always permitted, but ungrabbing
* only when proximity sensor is not covered / proximity
* blocks input feature is disabled */
Expand All @@ -3866,6 +3874,9 @@ static void tklock_evctrl_rethink(void)

bool grab_kp = !enable_kp;

if( !tk_input_policy_enabled )
grab_kp = false;

execute_datapipe(&keypad_grab_wanted_pipe,
GINT_TO_POINTER(grab_kp),
USE_INDATA, CACHE_INDATA);
Expand Down Expand Up @@ -4050,6 +4061,15 @@ static void tklock_gconf_cb(GConfClient *const gcc, const guint id,
tk_autolock_enabled = gconf_value_get_bool(gcv) ? 1 : 0;
tklock_autolock_rethink();
}
else if( id == tk_input_policy_enabled_cb_id ) {
gboolean old = tk_input_policy_enabled;
tk_input_policy_enabled = gconf_value_get_bool(gcv) ? 1 : 0;
if( tk_input_policy_enabled != old ) {
mce_log(LL_NOTICE, "input grabbing %s",
tk_input_policy_enabled ? "allowed" : "denied");
tklock_evctrl_rethink();
}
}
else if( id == lid_sensor_enabled_cb_id ) {
lid_sensor_enabled = gconf_value_get_bool(gcv) ? 1 : 0;
tklock_lid_sensor_rethink();
Expand Down Expand Up @@ -4224,6 +4244,13 @@ static void tklock_gconf_init(void)
tklock_gconf_cb,
&tk_autolock_enabled_cb_id);

/* Grabbing input devices allowed */
mce_gconf_track_bool(MCE_GCONF_TK_INPUT_POLICY_ENABLED,
&tk_input_policy_enabled,
DEFAULT_TK_INPUT_POLICY_ENABLED,
tklock_gconf_cb,
&tk_input_policy_enabled_cb_id);

/* Touchscreen/keypad autolock delay */
mce_gconf_track_int(MCE_GCONF_AUTOLOCK_DELAY,
&tklock_autolock_delay,
Expand Down Expand Up @@ -4395,6 +4422,9 @@ static void tklock_gconf_quit(void)
mce_gconf_notifier_remove(tk_autolock_enabled_cb_id),
tk_autolock_enabled_cb_id = 0;

mce_gconf_notifier_remove(tk_input_policy_enabled_cb_id),
tk_input_policy_enabled_cb_id = 0;

mce_gconf_notifier_remove(tklock_autolock_delay_cb_id),
tklock_autolock_delay_cb_id = 0;

Expand Down
4 changes: 4 additions & 0 deletions tklock.h
Expand Up @@ -227,6 +227,10 @@ enum
#define MCE_GCONF_EXCEPTION_LENGTH_ACTIVITY MCE_GCONF_LOCK_PATH"/exception_length_activity"
#define DEFAULT_EXCEPTION_LENGTH_ACTIVITY 2000

/** Is mce allowed to grab input devices */
#define MCE_GCONF_TK_INPUT_POLICY_ENABLED MCE_GCONF_LOCK_PATH "/touchscreen_policy_enabled"
#define DEFAULT_TK_INPUT_POLICY_ENABLED true

/** Name of D-Bus callback to provide to Touchscreen/Keypad Lock SystemUI */
#define MCE_TKLOCK_CB_REQ "tklock_callback"

Expand Down
43 changes: 43 additions & 0 deletions tools/mcetool.c
Expand Up @@ -4340,6 +4340,33 @@ static void xmce_get_memnotify_level(void)
free(str);
}

/* ------------------------------------------------------------------------- *
* input policy
* ------------------------------------------------------------------------- */

/* Set input policy mode
*
* @param args string suitable for interpreting as enabled/disabled
*/
static bool xmce_set_input_policy_mode(const char *args)
{
gboolean val = xmce_parse_enabled(args);
mcetool_gconf_set_bool(MCE_GCONF_TK_INPUT_POLICY_ENABLED, val);
return true;
}

/* Show input policy mode
*/
static void xmce_get_input_policy_mode(void)
{
gboolean val = 0;
char txt[32] = "unknown";

if( mcetool_gconf_get_bool(MCE_GCONF_TK_INPUT_POLICY_ENABLED, &val) )
snprintf(txt, sizeof txt, "%s", val ? "enabled" : "disabled");
printf("%-"PAD1"s %s\n", "Input grab policy:", txt);
}

/* ------------------------------------------------------------------------- *
* touch input unblocking
* ------------------------------------------------------------------------- */
Expand Down Expand Up @@ -4779,6 +4806,7 @@ static bool xmce_get_status(const char *args)
#endif
xmce_get_tklock_blank();
xmce_get_lipstick_core_delay();
xmce_get_input_policy_mode();
xmce_get_touch_unblock_delay();
xmce_get_exception_lengths();

Expand Down Expand Up @@ -5718,6 +5746,21 @@ static const mce_opt_t options[] =
.usage =
"set the delay for dumping core from unresponsive lipstick\n"
},
{
.name = "set-input-policy-mode",
.with_arg = xmce_set_input_policy_mode,
.values = "enabled|disabled",
.usage =
"allow/deny grabbing of input devices based on input policy\n"
"\n"
"Normally this should be always set to 'enabled'.\n"
"\n"
"Setting to 'disabled' can be useful when debugging things like\n"
"unresponsive touch screen: If the issue goes away when mce is\n"
"allowed to grab input device, problem is likely to reside in\n"
"mce policy logic. If the problem persists, the problem is more\n"
"likely to exist at the ui side input handling logic.\n"
},
{
.name = "set-touch-unblock-delay",
.with_arg = xmce_set_touch_unblock_delay,
Expand Down

0 comments on commit ccc324d

Please sign in to comment.