powerd proximity sensors enable/disable code will fail when the phone can accept more than 1 call

Bug #1191033 reported by Matt Fischer
This bug affects 2 people
Affects Status Importance Assigned to Milestone
powerd (Ubuntu)

Bug Description

RIght now the proximity sensor code in powerd triggers off the active/alerting and disconnected signals. When multiple calls are allowed, there will be multiple signals. Prototype code to handle this is below, but powerd will also need to listen on dbus for the creation of a new call and attach to the new object. There is 1 dbus object per call and right now powerd only listens for signals from voicecall01. This is not handled in the code below.

static void
update_proximity_sensor_state(int active_call_count)
    if (active_call_count > 0) {
        //call is active, enable sensor
        if (powerd_add_display_request(&prox_sensor_req))
            powerd_warn("Request to use proximity sensor failed");
    else {
        //call is disconnected, disable sensor


on_ofono_voicecall_signal (GDBusProxy *proxy,
           gchar *sender_name,
           gchar *signal_name,
           GVariant *parameters,
           gpointer user_data)
    GVariant *value = NULL;
    const char *prop_name;
    const char *prop_value;
    static uint active_call_count = 0;
    static gboolean alerted = FALSE;

    powerd_debug("we get signal from %s: %s", sender_name, signal_name);

    /* This function enables and disables the proximity sensor based
     * on the state of the call.
     * Active - meaning, the call is in progress --> Proximity On
     * Alerting - a signal made on outbound calls only which means that
     * the phone is ringing on the other side, but has not
     * been picked up. --> Proximity On (this signal is not
     * sent on inbound calls)
     * Disconnected - the call is over. --> Proximity Off.
     * For more details on states see voicecall-api.txt in the ofono source
     * The mappings of the states aren't exact because you can be on
     * more than 1 call at a time, so instead they modify counters
     * which then affect the state. For a single call the mappings
     * above are correct.

    /* Note: As of June 13, 2013, the phone cannot successfully
     * accept a call while another call is in progress. Until this is
     * fixed, there will only ever be one accept message, although
     * two disconnect signals will be seen. Once this is fixed, we
     * need to re-test this block and then delete this comment (mfisch) */

    if (!strcmp(signal_name, "PropertyChanged")) {
        g_variant_get(parameters, "(&sv)", &prop_name, &value);
        if (!strcmp(prop_name,"State")) {
            g_variant_get(value, "&s", &prop_value);
            powerd_debug("State = %s, Alerted: %d, Active Count: %d",
                prop_value, alerted, active_call_count);
            if (!strcmp(prop_value,"active")) {
                if (!alerted) {
                else {
                    // If alerted is TRUE then we already incremented
                    // active_call_count, so skip the increment and turn
                    // the flag off.
                    alerted = FALSE;
            else if (!strcmp(prop_value,"alerting")) {
                alerted = TRUE;
            else if (!strcmp(prop_value,"disconnected")) {
                if (active_call_count > 0) {
                // Clear the flag in case the remote call did not answer.
                alerted = FALSE;

Related branches

Changed in powerd:
status: New → Confirmed
importance: Undecided → High
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package powerd - 0.13+14.04.20140328.1-0ubuntu1

powerd (0.13+14.04.20140328.1-0ubuntu1) trusty; urgency=low

  [ Alfonso Sanchez-Beato ]
  * Add support for multiple ofono modems (LP#1295085). Handle
    simultaneous voice calls (LP#1191033). Listen to ofono USSD signals
    (LP: #1191033, #1295085)

  [ Ubuntu daily release ]
  * New rebuild forced
 -- Ubuntu daily release <email address hidden> Fri, 28 Mar 2014 15:30:54 +0000

Changed in powerd (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers