Commit 0bf8f08e authored by spiiroin's avatar spiiroin

[displaysettings] Add lidSensorFilteringEnabled property. Contributes to JB#32093

Magnetic lid sensors might report closed state also when the cover is
folded underneath the device.

If use of ambient light sensor is allowed (ambientLightSensorEnabled
property) and lid close filtering is requested (lidSensorFilteringEnabled
property), MCE will ignore lid close events unless they happen in close
proximity to drop in ambient light level (cover in front obstructs also
the ambient light sensor).
parent bd1c1d77
......@@ -46,6 +46,7 @@ static const char *MceDisplayUseAmbientLightSensor = "/system/osso/dsm/display/a
static const char *MceDisplayAutoBrightnessEnabled = "/system/osso/dsm/display/als_autobrightness";
static const char *MceDoubleTapMode = "/system/osso/dsm/doubletap/mode";
static const char *MceLidSensorEnabled = "/system/osso/dsm/locks/lid_sensor_enabled";
static const char *MceLidSensorFilteringEnabled = "/system/osso/dsm/locks/filter_lid_with_als";
DisplaySettings::DisplaySettings(QObject *parent)
: QObject(parent)
......@@ -94,6 +95,10 @@ DisplaySettings::DisplaySettings(QObject *parent)
result.waitForFinished();
m_lidSensorEnabled = result.value().variant().toBool();
result = m_mceIface->get_config(QDBusObjectPath(MceLidSensorFilteringEnabled));
result.waitForFinished();
m_lidSensorFilteringEnabled = result.value().variant().toBool();
m_mceSignalIface = new ComNokiaMceSignalInterface(MCE_SERVICE, MCE_SIGNAL_PATH, QDBusConnection::systemBus(), this);
connect(m_mceSignalIface, SIGNAL(config_change_ind(QString,QDBusVariant)), this, SLOT(configChange(QString,QDBusVariant)));
}
......@@ -256,6 +261,20 @@ void DisplaySettings::setLidSensorEnabled(bool enabled)
}
}
bool DisplaySettings::lidSensorFilteringEnabled() const
{
return m_lidSensorFilteringEnabled;
}
void DisplaySettings::setLidSensorFilteringEnabled(bool enabled)
{
if (m_lidSensorFilteringEnabled != enabled) {
m_lidSensorFilteringEnabled = enabled;
m_mceIface->set_config(QDBusObjectPath(MceLidSensorFilteringEnabled), QDBusVariant(enabled));
emit lidSensorFilteringEnabledChanged();
}
}
void DisplaySettings::configChange(const QString &key, const QDBusVariant &value)
{
if (key == MceDisplayBrightness) {
......@@ -318,5 +337,11 @@ void DisplaySettings::configChange(const QString &key, const QDBusVariant &value
m_lidSensorEnabled = val;
emit lidSensorEnabledChanged();
}
} else if (key == MceLidSensorFilteringEnabled) {
bool val = value.variant().toBool();
if (val != m_lidSensorFilteringEnabled) {
m_lidSensorFilteringEnabled = val;
emit lidSensorFilteringEnabledChanged();
}
}
}
......@@ -57,6 +57,7 @@ class DisplaySettings: public QObject
Q_PROPERTY(int doubleTapMode READ doubleTapMode WRITE setDoubleTapMode NOTIFY doubleTapModeChanged)
Q_PROPERTY(QVariant orientationLock READ orientationLock WRITE setOrientationLock NOTIFY orientationLockChanged)
Q_PROPERTY(bool lidSensorEnabled READ lidSensorEnabled WRITE setLidSensorEnabled NOTIFY lidSensorEnabledChanged)
Q_PROPERTY(bool lidSensorFilteringEnabled READ lidSensorFilteringEnabled WRITE setLidSensorFilteringEnabled NOTIFY lidSensorFilteringEnabledChanged)
public:
enum DoubleTapMode {
......@@ -116,6 +117,9 @@ public:
bool lidSensorEnabled() const;
void setLidSensorEnabled(bool);
bool lidSensorFilteringEnabled() const;
void setLidSensorFilteringEnabled(bool);
signals:
void brightnessChanged();
void dimTimeoutChanged();
......@@ -128,6 +132,7 @@ signals:
void doubleTapModeChanged();
void orientationLockChanged();
void lidSensorEnabledChanged();
void lidSensorFilteringEnabledChanged();
private slots:
void configChange(const QString &key, const QDBusVariant &value);
......@@ -146,6 +151,7 @@ private:
bool m_autoBrightnessEnabled;
bool m_doubleTapMode;
bool m_lidSensorEnabled;
bool m_lidSensorFilteringEnabled;
};
QML_DECLARE_TYPE(DisplaySettings)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment