diff --git a/plugins/hfp_ag.c b/plugins/hfp_ag.c index 41081c51..cbf3ccd8 100644 --- a/plugins/hfp_ag.c +++ b/plugins/hfp_ag.c @@ -94,6 +94,10 @@ static gboolean hfp_ag_disconnect_cb(GIOChannel *io, GIOCondition cond, static void hfp_ag_connect_cb(GIOChannel *io, GError *err, gpointer user_data) { + struct ofono_modem *modem; + struct ofono_emulator *em; + int fd; + DBG(""); if (err) { @@ -101,6 +105,19 @@ static void hfp_ag_connect_cb(GIOChannel *io, GError *err, gpointer user_data) goto failed; } + /* Pick the first voicecall capable modem */ + modem = modems->data; + if (modem == NULL) + goto failed; + DBG("Picked modem %p for emulator", modem); + + em = ofono_emulator_create(modem, OFONO_EMULATOR_TYPE_HFP); + if (em == NULL) + goto failed; + + fd = g_io_channel_unix_get_fd(io); + ofono_emulator_register(em, fd); + channel_watch = g_io_add_watch(io, G_IO_NVAL | G_IO_HUP | G_IO_ERR, hfp_ag_disconnect_cb, NULL);