Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent location state changes during emergency calls #27

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

LaakkonenJussi
Copy link
Contributor

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 funcionality. When
state is "Active" and type is "Emergency" all changes made to the
location or GPS status are prevented and warning is logged.

…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.
Copy link
Contributor

@spiiroin spiiroin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic wise lgtm.
Some behavioral bits of which I'm not sure if they matter or not.

src/locationsettings.cpp Outdated Show resolved Hide resolved
@@ -466,6 +479,12 @@ bool LocationSettings::locationEnabled() const
void LocationSettings::setLocationEnabled(bool enabled)
{
Q_D(LocationSettings);

if (d->isEmergencyCallActive()) {
qWarning() << "Cannot allow to change location enabled status when emergency call is active";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering whether we want debug logging for any attempt to enable/disable, or just for the ones that would actually lead to changes i.e. should this be withing the below "if it differs from current" conditional block?

Also, is it okay for qml property setter not to set the property? I'd guess yes, but does somebody know for sure?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort of related, if there were properties like "canToggleLocationEnabled" or stte -> those could perhaps be used in (qml) ui to disable/hide those element that could lead to attempts to make such changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good option I think, to have a canToggleLocation visible upwards to UI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some with 517f7bd -> naming needs to be rethought. On Friday evening brain just shortcircuits.

return;

m_callstate = m_mceCallState->state();
m_calltype = m_mceCallState->type();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to have member variables for these instead of just calling getters when evaluating the state?

Copy link
Contributor Author

@LaakkonenJussi LaakkonenJussi Mar 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, not any particular reason. I can drop those if polling is preferred.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like on mce-qt these are in the end plain "return iValue;" type of code so the extra copies shouldn't provide much. -> Let's just call the getters when the status is needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I was just looking the same that it does not create a new request but just returns internal value. On it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But, if we'd need the canToggleGPS property I think we'd need to keep track of the state in order for that to work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case it could boil down to boolean. Not sure which would be better but such canToggle & protection could be even implemented fully in the UI side as the location setting modification is couple very specific places.

Speaking of that, there's also already the policy support for disallowing location settings changes in the UI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An enum vs. boolean? I'd take the former any day in state tracking. It is more future proof. I think the safeguard should not be only in UI but could be also there to track what is going on beneath.

Where is that policy support implemented?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean as in canToggleGPS sounds quite much like such.

Policy is sailfish-policy, living with the mdm libraries. UI side honors the policy, e.g. systemsettings / location.qml, disables the settings if the policy prevents usage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really think the enum serves here as we might need more granularity 517f7bd (naming improvement suggestions are welcome).

@@ -466,6 +479,12 @@ bool LocationSettings::locationEnabled() const
void LocationSettings::setLocationEnabled(bool enabled)
{
Q_D(LocationSettings);

if (d->isEmergencyCallActive()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pondering should it be allowed to turn the location/gps on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? AML does it already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And AML controls the location anyways, when battery is low it keeps running but shuts down all power consumers to have some grace period for the user to find a charger. Anyways, it would compete with AML requirements and the AML service, which will force the value to the file causing maybe confusion as in such case user would see "-> on -> off" and vice versa. Better to have this ignore all cases.

Or maybe if we could have an additional QMceCallState or variable aml_enabled ? In such case all actions would be blocked but when AML is not enabled user could control this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking of robustness and limiting only the minimum. AML is sort of an add-on so these rules on this level are not totally unproblematic, and also it's now assuming that AML will not use this component while on the other hand it would be good if all access to the file would go via this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AML is a service that at some point should also be launched at the lock UI so I think this is not available then. It is simple enough just to prevent user access to the options as there is a legislative requirement to do so. I left opening for enable only option in 517f7bd which might be needed. Anyways, all emergency calls != AML is on.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm starting to think that if the situation is not yet clear enough to have a future-proof mw policy it might be better not to implement such a thing. Especially if the only gotcha would be having device user repeatedly and persistently toggling things in settings app during an ongoing emergency call. Or was there something else too?

This adds the properties and signals for getting info whether the
location and GPS state can be modified. An enum is used to define the
level of access to enabling location&GPS with a bit more granularity.
Not all emergency calls are AML enabled calls that need explicit access
to location. As of now, we can just detect emergency call -> always
disabled when it is active.
@LaakkonenJussi
Copy link
Contributor Author

In general I think the org.sailfishos.aml service name is the best to monitor here as that is only registered when AML is active for the region the emergency call is made in. But this is to be split off from the JB#57710 and will be continued in another task somewhere in the future.

@LaakkonenJussi LaakkonenJussi marked this pull request as draft March 25, 2022 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants