HFP modem doesn't have IMSI at all. In order to notify SIM ready to the core, we create a special sim driver with a faked IMSI number. --- Makefile.am | 3 +- drivers/hfpmodem/hfpmodem.c | 2 + drivers/hfpmodem/hfpmodem.h | 3 + drivers/hfpmodem/sim.c | 114 +++++++++++++++++++++++++++++++++++++++++++ plugins/hfp.c | 6 ++ 5 files changed, 127 insertions(+), 1 deletions(-) create mode 100644 drivers/hfpmodem/sim.c
diff --git a/Makefile.am b/Makefile.am index f31180e..a1ec0e7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -187,7 +187,8 @@ builtin_sources += drivers/atmodem/atutil.h \ drivers/hfpmodem/hfpmodem.c \ drivers/hfpmodem/voicecall.c \ drivers/hfpmodem/network-registration.c \ - drivers/hfpmodem/call-volume.c + drivers/hfpmodem/call-volume.c \ + drivers/hfpmodem/sim.c builtin_modules += mbmmodem builtin_sources += drivers/atmodem/atutil.h \ diff --git a/drivers/hfpmodem/hfpmodem.c b/drivers/hfpmodem/hfpmodem.c index 4471a7b..ecbabe3 100644 --- a/drivers/hfpmodem/hfpmodem.c +++ b/drivers/hfpmodem/hfpmodem.c @@ -44,6 +44,7 @@ static int hfpmodem_init(void) hfp_voicecall_init(); hfp_netreg_init(); hfp_call_volume_init(); + hfp_sim_init(); return 0; } @@ -53,6 +54,7 @@ static void hfpmodem_exit(void) hfp_voicecall_exit(); hfp_netreg_exit(); hfp_call_volume_exit(); + hfp_sim_exit(); } OFONO_PLUGIN_DEFINE(hfpmodem, "Hands-Free Profile Driver", VERSION, diff --git a/drivers/hfpmodem/hfpmodem.h b/drivers/hfpmodem/hfpmodem.h index bf5d563..631f773 100644 --- a/drivers/hfpmodem/hfpmodem.h +++ b/drivers/hfpmodem/hfpmodem.h @@ -80,3 +80,6 @@ extern void hfp_call_volume_exit(); extern void hfp_voicecall_init(); extern void hfp_voicecall_exit(); + +extern void hfp_sim_init(); +extern void hfp_sim_exit(); diff --git a/drivers/hfpmodem/sim.c b/drivers/hfpmodem/sim.c new file mode 100644 index 0000000..e42cfb9 --- /dev/null +++ b/drivers/hfpmodem/sim.c @@ -0,0 +1,114 @@ +/* + * + * oFono - Open Source Telephony + * + * Copyright (C) 2008-2010 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <string.h> +#include <stdlib.h> +#include <stdio.h> + +#include <glib.h> + +#include <ofono/log.h> +#include <ofono/modem.h> +#include <ofono/sim.h> + +#include "gatchat.h" +#include "gatresult.h" +#include "hfpmodem.h" + +static void hfp_read_imsi(struct ofono_sim *sim, ofono_sim_imsi_cb_t cb, + void *data) +{ + struct ofono_error error; + const char *imsi = "1234567890123456"; + + DBG("%s", imsi); + + /* + * Return the faked IMSI since HFP doesn't have IMSI. + */ + error.type = OFONO_ERROR_TYPE_NO_ERROR; + cb(&error, imsi, data); +} + +static void hfp_sim_read_binary(struct ofono_sim *sim, int fileid, + int start, int length, + ofono_sim_read_cb_t cb, void *data) +{ + DBG(""); + + CALLBACK_WITH_FAILURE(cb, NULL, 0, data); +} + +static void hfp_sim_read_info(struct ofono_sim *sim, int fileid, + ofono_sim_file_info_cb_t cb, + void *data) +{ + DBG(""); + + CALLBACK_WITH_FAILURE(cb, -1, -1, -1, NULL, data); +} + +static int hfp_sim_probe(struct ofono_sim *sim, unsigned int vendor, + void *data) +{ + ofono_sim_register(sim); + + return 0; +} + +static void hfp_sim_remove(struct ofono_sim *sim) +{ +} + +static struct ofono_sim_driver driver = { + .name = "hfpmodem", + .probe = hfp_sim_probe, + .remove = hfp_sim_remove, + .read_file_info = hfp_sim_read_info, + .read_file_transparent = hfp_sim_read_binary, + .read_file_linear = NULL, + .read_file_cyclic = NULL, + .write_file_transparent = NULL, + .write_file_linear = NULL, + .write_file_cyclic = NULL, + .read_imsi = hfp_read_imsi, + .query_passwd_state = NULL, + .send_passwd = NULL, + .reset_passwd = NULL, + .lock = NULL, + .change_passwd = NULL, + .query_locked = NULL, +}; + +void hfp_sim_init() +{ + ofono_sim_driver_register(&driver); +} + +void hfp_sim_exit() +{ + ofono_sim_driver_unregister(&driver); +} diff --git a/plugins/hfp.c b/plugins/hfp.c index 9a892db..612fe0d 100644 --- a/plugins/hfp.c +++ b/plugins/hfp.c @@ -40,6 +40,7 @@ #include <ofono/netreg.h> #include <ofono/voicecall.h> #include <ofono/call-volume.h> +#include <ofono/sim.h> #include <drivers/hfpmodem/hfpmodem.h> @@ -649,12 +650,17 @@ static int hfp_disable(struct ofono_modem *modem) static void hfp_pre_sim(struct ofono_modem *modem) { struct hfp_data *data = ofono_modem_get_data(modem); + struct ofono_sim *sim; DBG("%p", modem); ofono_voicecall_create(modem, 0, "hfpmodem", data); ofono_netreg_create(modem, 0, "hfpmodem", data); ofono_call_volume_create(modem, 0, "hfpmodem", data); + sim = ofono_sim_create(modem, 0, "hfpmodem", data); + + if (sim) + ofono_sim_inserted_notify(sim, TRUE); } static void hfp_post_sim(struct ofono_modem *modem) -- 1.7.0.4 _______________________________________________ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono