~sergiusens/powerd/daily

« back to all changes in this revision

Viewing changes to src/powerd.cpp

  • Committer: Tarmac
  • Author(s): Matthew Fischer
  • Date: 2013-05-23 16:53:44 UTC
  • mfrom: (16.2.2 ofono)
  • Revision ID: tarmac-20130523165344-baiulpcx3yt73div
Listen for ofono signals and request active state (and turn the screen on) when an incoming SMS or phone call arrives.

Approved by Seth Forshee, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
/* Assume screen is off to start; we will force it on */
88
88
static enum screen_state current_screen_state = SCREEN_OFF;
89
89
static uint internal_request_cookie;
 
90
static uint ofono_call_request_cookie;
90
91
static bool internal_cookie_valid;
91
92
 
92
93
gboolean activity_monitor(gpointer data);
312
313
 
313
314
}   //namespace
314
315
 
 
316
void
 
317
on_ofono_signal (GDBusProxy *proxy,
 
318
           gchar      *sender_name,
 
319
           gchar      *signal_name,
 
320
           GVariant   *parameters,
 
321
           gpointer    user_data)
 
322
{
 
323
    int ret;
 
324
 
 
325
    g_debug("we get signal from %s: %s", sender_name, signal_name);
 
326
    if (!strcmp(signal_name, "IncomingMessage")) {
 
327
        g_debug("Waking up the device - Incoming SMS");
 
328
        reset_activity_timer(1);
 
329
        set_screen_state(SCREEN_ON);
 
330
    }
 
331
    else if (!strcmp(signal_name, "CallAdded")) {
 
332
        g_debug("Waking up the device - Incoming Call");
 
333
        ret = request_sys_state_internal(NULL, POWERD_SYS_STATE_ACTIVE,
 
334
                getpid(), &ofono_call_request_cookie);
 
335
        if (!ret) {
 
336
            g_warning("Request for active state failed");
 
337
        }
 
338
        set_screen_state(SCREEN_ON);
 
339
    }
 
340
    else if (!strcmp(signal_name, "CallRemoved")) {
 
341
        g_debug("Call over, dropping active state request");
 
342
        ret = clear_sys_state_internal(NULL, ofono_call_request_cookie);
 
343
        if (!ret)
 
344
            g_warning("Internal system state request cookie invalid: %d\n",
 
345
                      ofono_call_request_cookie);
 
346
    }
 
347
}
 
348
 
 
349
 
315
350
int main(int argc, char** argv)
316
351
{
317
352
    int i, ret;
322
357
        powerd_name_acquired_cb, powerd_name_lost_cb, NULL, NULL);
323
358
    g_debug("owner id: %u", name_id);
324
359
 
 
360
    g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
 
361
        G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
 
362
        NULL,
 
363
        "org.ofono",
 
364
        "/ril_0",
 
365
        "org.ofono.MessageManager",
 
366
        NULL,
 
367
        (GAsyncReadyCallback)ofono_proxy_connect_cb,
 
368
        NULL);
 
369
 
 
370
    g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
 
371
        G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
 
372
        NULL,
 
373
        "org.ofono",
 
374
        "/ril_0",
 
375
        "org.ofono.VoiceCallManager",
 
376
        NULL,
 
377
        (GAsyncReadyCallback)ofono_proxy_connect_cb,
 
378
        NULL);
 
379
 
325
380
    libsuspend_init(0);
326
381
    power_request_init();
327
382