Phosh 0.27.0 together with GNOME calls 45.alpha.0 added initial support for emergency calling from the locked phone screen. The following gives a short overview on the involved interfaces so you can check if this should already work for your provider or country, how to enable this feature and where the journey is going.

Enabling emergency call support Link to heading

Until we have tested more providers emergency call support is disabled by default to not give a false sense of security. You can enable the feature in the mobile settings app or via

gsettings get sm.puri.phosh.emergency-calls enabled true

This enables the emergency call button in the menu shown when long pressing the power button:

Power button menu

If the button is still disabled afterwards then likely calls didn’t get any emergency call numbers from your SIM card. See below.

Note that initiating emergency calls isn’t allowed outside of actual emergency situations so check this first. There’s some places where it’s simple to actually trigger emergency calls for testing. See here.

If you have additional links that explain how to test emergency calls in a country feel free to add it to the calls wiki or to this issue as this will make it easier for others to validate if support is reliable on their device for their provider.

As the emergency contact and emergency number terms are a bit overloaded let’s clarify this upfront:

  1. Some providers in some countries store emergency call numbers on the SIM that are callable without unlocking the SIM and also work without any prepaid credit.
  2. In some countries even a simless phone can make emergency calls. This is the case in some EU countries for 112. The phone application needs to know which numbers apply. These numbers are also used when the SIM hasn’t any numbers specified.
  3. Users often want to store emergency contacts (e.g. family members, doctors, etc). Those are user defined and only work with an unlocked SIM (and enough credit to place a call)

The current support in calls already handles the 1st case but the implementation takes the other two cases into account already (see below).

How does it work Link to heading

All of the logic and information gathering to decide whether emergency calls are allowed and what the possible emergency call numbers are is handled by GNOME calls and exposed on the session’s DBus. Calls uses different backends to handle different kinds of call origins:

  • ModemManager: Hardware modem managed by ModemManager
  • SIP: SIP calls managed via sofia-sip and GStreamer
  • Ofono (pretty deprecated nowadays): Hardware modem managed via ofono
  • Dummy (very useful for testing and debugging): Dummy backend that doesn’t call anywhere

Usually calls tries to figure out the relevant backends on it’s own but you can force a specific backend via the -p option:

gnome-calls -p dummy

This would force the dummy backend. Calls exposes the properties of different calls over the same DBus interface so consumers don’t need to worry about the backend a call originates from. The same is true for emergency number information, it merges those of the different backends and origins together so users of this interface don’t have to worry. That list of emergency numbers is augmented with details like call type (police, fire brigade, …). Phosh consumes that to display those details:

Emergency contacts

Testing with the dummy backend Link to heading

Even without a modem you can test the above using calls dummy backend. First make sure that calls is not running. Then you can start it using the dummy backend. If you use the installed package use the invocation above. If you’re building calls from source use:

git clone https://gitlab.gnome.org/GNOME/calls.git
cd calls
meson setup _build
meson compile -C _build
_build/run -p dummy

The _build/run makes sure that necessary environment variables are set to find the backends and that GSettings schemas are looked for in the local source tree too.

You can test if the dummy backend is working by sending it a SIGUSR1.

kill -SIGUSR1 $(pidof gnome-calls)

This triggers an incoming call:

Incoming call form call’s dummy backend

You can then query the dummy backends emergency call numbers via DBus:

gdbus call -e -o /org/gnome/Calls -d org.gnome.Calls -m org.gnome.Calls.EmergencyCalls.GetEmergencyContacts

gives

([('123', '123', 0, @a{sv} {}), ('456', '456', 0, {})],)

That’s a bit dull as the dummy backends doesn’t bother with metadata but you get the idea and it’s enough to call those numbers:

gdbus call -e -o /org/gnome/Calls -d org.gnome.Calls -m org.gnome.Calls.EmergencyCalls.CallEmergencyContact 123

As this is the dummy backend no actual call is being placed on the phone network, everything happens within the calls application. Calling a non emergency number via that interfaces gives an error. As 1234 is not in the list of emergency numbers calling it:

gdbus call -e -o /org/gnome/Calls -d org.gnome.Calls -m org.gnome.Calls.EmergencyCalls.CallEmergencyContact 1234

correctly results in the following error:

Error: GDBus.Error:org.freedesktop.DBus.Error.NotSupported: 1234 not a known emergency number

This DBus interface is consumed by Phosh and used to build the emergency call menu:

Note that (as usual) you can do that all on your development machine / laptop as explained here. As we want to bring up the emergency call menu via a power button long press we can use wtype when running nested to simulate that:

WAYLAND_DISPLAY=wayland-1 wtype -P XF86PowerOff -s 4100 -p XF86Poweroff

Testing with the modem manager backend Link to heading

Equipped with that knowledge let’s see what happens when using the same on the ModemManager backend with a SIM card inserted. As this is about emergency calls the SIM doesn’t need to be unlocked.

Let’s first check which emergency numbers are stored on the SIM. The example is from a SIM in Germany’s O2 network:

mmcli -i any
  -------------------------------
  General    |              path: /org/freedesktop/ModemManager1/SIM/0
  -------------------------------
  Properties |            active: yes
             |              imsi: <redacted>
             |             iccid: <redacted>
             |       operator id: 26207
             |     operator name: o2 - de
             | emergency numbers: 112, 275766, 026456, 575627

Then we can check if calls got them correctly and was able to identify the type of emergency number:

gdbus call -e -o /org/gnome/Calls -d org.gnome.Calls -m org.gnome.Calls.EmergencyCalls.GetEmergencyContacts
([('112', 'Police, Ambulance, Fire Brigade', 0, @a{sv} {}), ('275766', '275766', 0, {}), ('026456', '026456', 0, {}), ('575627', '575627', 0, {})],)

As you can see that worked for 112 but not for the other numbers. Their usage is currently unknown and O2 currently didn’t respond to inquiries regarding what those numbers should be used for.

In contrast to the dummy backend we won’t be calling any of these numbers with the ModemManager backend as this would trigger a real emergency call on the phone network.

You can try the above steps with your device. Please report success or failure here. For that please specify your phone hardware, country, provider, the data you fetched from modem manager, from gnome-calls DBus API and whether you did an actual emergency call. This will allow us to improve things in this important area.

Summary / Outlook Link to heading

In the above we’ve seen how different parts of the emergency call stack interact and how to query the individual bits. We can now easily check which numbers show up and Phosh’s emergency call menu and zoom in case something is going wrong or missing.

As noted initially there’s broadly two more cases we want to handle:

  • Calling well known emergency numbers without any SIM inserted or when the SIM has no emergency numbers stored. There’s a merge request pending on the calls side to improve on this.
  • Having users define their own emergency contacts. These would then get added to the list of emergency numbers when there’s an unlocked SIM. The status is tracked by this issue. Feel free to reach out if you want to help there. It’s a good task to get into calls and GNOME development.

Once the new functionality lands in calls Phosh can automatically make use of it without further changes.