Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[mce-hybris] Enablers for masking hybris plugin features. JB#46746
In some cases functionality from mce-plugin-libhybris that works and
is needed in some devices can cause problems in other devices - for
example using android hwc2 interface for display blank/unblank purposes
can interfere with minui based unlock/upgrade UIs on devices that use
kms/drm instead of legacy frame buffer.

Make it possible to use configuration files for enabling / disabling
features implemented in the hybris plugin.

Keep all features enabled by default.

Install configuration file that keeps enabled those features that actually
might be used by mce and disables the rest.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Sep 12, 2019
1 parent 0a04373 commit e0d2362
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 6 deletions.
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -467,6 +467,7 @@ install:: build
$(INSTALL_DTA) inifiles/mce.ini $(DESTDIR)$(CONFDIR)/$(CONFFILE)
$(INSTALL_DTA) inifiles/mce-radio-states.ini $(DESTDIR)$(CONFDIR)/$(RADIOSTATESCONFFILE)
$(INSTALL_DTA) inifiles/hybris-led.ini $(DESTDIR)$(CONFDIR)/20hybris-led.ini
$(INSTALL_DTA) inifiles/hybris-features.ini $(DESTDIR)$(CONFDIR)/20hybris-features.ini
$(INSTALL_DTA) inifiles/debug-led.ini $(DESTDIR)$(CONFDIR)/20debug-led.ini
$(INSTALL_DTA) inifiles/als-defaults.ini $(DESTDIR)$(CONFDIR)/20als-defaults.ini
$(INSTALL_DTA) inifiles/legacy.ini $(DESTDIR)$(CONFDIR)/11legacy.ini
Expand Down
19 changes: 19 additions & 0 deletions inifiles/hybris-features.ini
@@ -0,0 +1,19 @@
# Configuration file for MCE - allow/mask features provided by hybris backend

[FeatureHybris]

# If no configuration file is provided, all functionality implemented in
# mce-plugin-libhybris is enabled by default. If some feature is causing
# problems for some device, it should be disabled in hw specific configuration
# file by overriding one of the values below.

FrameBuffer = true
BackLight = true
KeyPad = true
IndicatorLed = true

# Supporting sensors via hybris plugin is a vestigial feature. Masking via
# config solely for the sake of symmetry. Keep all of them disabled.

ProximitySensor = false
LightSensor = false
41 changes: 35 additions & 6 deletions mce-hybris.c
Expand Up @@ -45,6 +45,29 @@
#include <errno.h>
#include <dlfcn.h>

/* ========================================================================= *
* On some devices using in theory supported hybris functionality can lead
* to problems. As a solution mce side configuration files can be used to
* disable individual features.
* ========================================================================= */

#define MCE_CONF_FEATURE_HYBRIS_GROUP "FeatureHybris"

#define MCE_CONF_FEATURE_HYBRIS_FRAMEBUFFER "FrameBuffer"
#define MCE_CONF_FEATURE_HYBRIS_BACKLIGHT "BackLight"
#define MCE_CONF_FEATURE_HYBRIS_KEYPAD "KeyPad"
#define MCE_CONF_FEATURE_HYBRIS_INDICATOR_LED "IndicatorLed"
#define MCE_CONF_FEATURE_HYBRIS_PROXIMITY_SENSOR "ProximitySensor"
#define MCE_CONF_FEATURE_HYBRIS_LIGHT_SENSOR "LightSensor"

static bool
mce_hybris_feature_supported(const char *key)
{
bool res = mce_conf_get_bool(MCE_CONF_FEATURE_HYBRIS_GROUP, key, true);
mce_log(LL_WARN, "hybris feature %s is %s", key, res ? "allowed" : "denied");
return res;
}

static void mce_hybris_ps_set_hook(mce_hybris_ps_fn cb);
static void mce_hybris_als_set_hook(mce_hybris_als_fn cb);

Expand Down Expand Up @@ -403,7 +426,8 @@ void mce_hybris_quit(void)
bool mce_hybris_framebuffer_init(void)
{
static bool (*real)(void) = 0;
RESOLVE;
if( mce_hybris_feature_supported(MCE_CONF_FEATURE_HYBRIS_FRAMEBUFFER) )
RESOLVE;
return !real ? false : real();
}

Expand Down Expand Up @@ -440,7 +464,8 @@ bool mce_hybris_framebuffer_set_power(bool state)
bool mce_hybris_backlight_init(void)
{
static bool (*real)(void) = 0;
RESOLVE;
if( mce_hybris_feature_supported(MCE_CONF_FEATURE_HYBRIS_BACKLIGHT) )
RESOLVE;
return !real ? false : real();
}

Expand Down Expand Up @@ -477,7 +502,8 @@ bool mce_hybris_backlight_set_brightness(int level)
bool mce_hybris_keypad_init(void)
{
static bool (*real)(void) = 0;
RESOLVE;
if( mce_hybris_feature_supported(MCE_CONF_FEATURE_HYBRIS_KEYPAD) )
RESOLVE;
return !real ? false : real();
}

Expand Down Expand Up @@ -514,7 +540,8 @@ bool mce_hybris_keypad_set_brightness(int level)
bool mce_hybris_indicator_init(void)
{
static bool (*real)(void) = 0;
RESOLVE;
if( mce_hybris_feature_supported(MCE_CONF_FEATURE_HYBRIS_INDICATOR_LED) )
RESOLVE;
return !real ? false : real();
}

Expand Down Expand Up @@ -595,7 +622,8 @@ bool mce_hybris_indicator_set_brightness(int level)
bool mce_hybris_ps_init(void)
{
bool (*real)(void) = 0;
RESOLVE;
if( mce_hybris_feature_supported(MCE_CONF_FEATURE_HYBRIS_PROXIMITY_SENSOR) )
RESOLVE;
return !real ? false : real();
}

Expand Down Expand Up @@ -670,7 +698,8 @@ bool mce_hybris_ps_set_callback(mce_hybris_ps_fn cb)
bool mce_hybris_als_init(void)
{
bool (*real)(void) = 0;
RESOLVE;
if( mce_hybris_feature_supported(MCE_CONF_FEATURE_HYBRIS_LIGHT_SENSOR) )
RESOLVE;
return !real ? false : real();
}

Expand Down
1 change: 1 addition & 0 deletions rpm/mce.spec
Expand Up @@ -106,6 +106,7 @@ systemctl daemon-reload || :
%config %{_sysconfdir}/%{name}/10mce.ini
%config %{_sysconfdir}/%{name}/20mce-radio-states.ini
%config %{_sysconfdir}/%{name}/20hybris-led.ini
%config %{_sysconfdir}/%{name}/20hybris-features.ini
%config %{_sysconfdir}/%{name}/20debug-led.ini
%config %{_sysconfdir}/%{name}/20als-defaults.ini
# empty /var/lib/mce -> rpm
Expand Down

0 comments on commit e0d2362

Please sign in to comment.