Skip to content

Commit 0bb5052

Browse files
[location] Prevent location state changes during emergency calls. JB#57710
AML is ran with the emergency calls and it requires to keep location services, i.e., GPS on during the call. It must not be allowed for the user to try to change this during the call. This change tracks the call state with QMceCallState functionality. When state is "Active" and type is "Emergency" all changes made to the location or GPS status are prevented and warning is logged.
1 parent 7fef6e7 commit 0bb5052

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

rpm/nemo-qml-plugin-systemsettings.spec

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ BuildRequires: pkgconfig(Qt5XmlPatterns)
2121
BuildRequires: pkgconfig(timed-qt5)
2222
BuildRequires: pkgconfig(profile)
2323
BuildRequires: pkgconfig(mce) >= 1.21.0
24+
BuildRequires: pkgconfig(mce-qt5) >= 1.4.2
2425
BuildRequires: pkgconfig(mlite5) >= 0.3.6
2526
BuildRequires: pkgconfig(usb-moded-qt5)
2627
BuildRequires: pkgconfig(blkid)

src/locationsettings.cpp

+39
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ LocationSettingsPrivate::LocationSettingsPrivate(LocationSettings::Mode mode, Lo
206206
"net.connman",
207207
"/net/connman/technology/gps",
208208
"net.connman.Technology"))
209+
, m_mceCallState(new QMceCallState(this))
210+
, m_callstate(QMceCallState::None)
211+
, m_calltype(QMceCallState::Normal)
209212
{
210213
loadProviders();
211214

@@ -233,6 +236,16 @@ LocationSettingsPrivate::LocationSettingsPrivate(LocationSettings::Mode mode, Lo
233236
this, &LocationSettingsPrivate::findGpsTech);
234237
findGpsTech();
235238
}
239+
240+
connect(m_mceCallState, &QMceCallState::validChanged,
241+
this, &LocationSettingsPrivate::onCallStateChanged);
242+
connect(m_mceCallState, &QMceCallState::stateChanged,
243+
this, &LocationSettingsPrivate::onCallStateChanged);
244+
connect(m_mceCallState, &QMceCallState::typeChanged,
245+
this, &LocationSettingsPrivate::onCallStateChanged);
246+
247+
/* To check the current status of the call if it is valid */
248+
onCallStateChanged();
236249
}
237250

238251
LocationSettingsPrivate::~LocationSettingsPrivate()
@@ -466,6 +479,12 @@ bool LocationSettings::locationEnabled() const
466479
void LocationSettings::setLocationEnabled(bool enabled)
467480
{
468481
Q_D(LocationSettings);
482+
483+
if (d->isEmergencyCallActive()) {
484+
qWarning() << "Cannot allow to change location enabled status when emergency call is active";
485+
return;
486+
}
487+
469488
if (enabled != d->m_locationEnabled) {
470489
d->m_locationEnabled = enabled;
471490
d->writeSettings();
@@ -482,6 +501,12 @@ bool LocationSettings::gpsEnabled() const
482501
void LocationSettings::setGpsEnabled(bool enabled)
483502
{
484503
Q_D(LocationSettings);
504+
505+
if (d->isEmergencyCallActive()) {
506+
qWarning() << "Cannot allow to change GPS status when emergency call is active";
507+
return;
508+
}
509+
485510
if (enabled != d->m_gpsEnabled) {
486511
d->m_gpsEnabled = enabled;
487512
d->writeSettings();
@@ -814,3 +839,17 @@ void LocationSettingsPrivate::writeSettings()
814839
}
815840
}
816841
}
842+
843+
bool LocationSettingsPrivate::isEmergencyCallActive()
844+
{
845+
return m_callstate == QMceCallState::Active && m_calltype == QMceCallState::Emergency;
846+
}
847+
848+
void LocationSettingsPrivate::onCallStateChanged()
849+
{
850+
if (!m_mceCallState->valid())
851+
return;
852+
853+
m_callstate = m_mceCallState->state();
854+
m_calltype = m_mceCallState->type();
855+
}

src/locationsettings_p.h

+6
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <QHash>
4242

4343
#include <nemo-dbus/interface.h>
44+
#include <mce-qt5/qmcecallstate.h>
4445

4546
#include <sailfishkeyprovider_processmutex.h>
4647

@@ -67,6 +68,7 @@ class LocationSettingsPrivate : public QObject
6768
void updateOnlineAgpsState(const QString &name, LocationSettings::OnlineAGpsState state);
6869
LocationSettings::LocationMode calculateLocationMode() const;
6970
void writeSettings();
71+
bool isEmergencyCallActive();
7072

7173
QFileSystemWatcher m_watcher;
7274
bool m_locationEnabled;
@@ -79,11 +81,15 @@ class LocationSettingsPrivate : public QObject
7981
NetworkManager *m_connMan;
8082
NetworkTechnology *m_gpsTech;
8183
NemoDBus::Interface *m_gpsTechInterface;
84+
QMceCallState *m_mceCallState;
85+
QMceCallState::State m_callstate;
86+
QMceCallState::Type m_calltype;
8287

8388
private slots:
8489
void readSettings();
8590
void findGpsTech();
8691
void gpsTechPropertyChanged(const QString &propertyName, const QDBusVariant &value);
92+
void onCallStateChanged();
8793
};
8894

8995
// TODO: replace this with DBus calls to a central settings service...

0 commit comments

Comments
 (0)